Beispiel #1
0
BuildLineInfo* NewBuildTab::DoProcessLine(const wxString& line)
{
    BuildLineInfo* buildLineInfo = new BuildLineInfo();
    LINE_SEVERITY severity;
    // Get the matching regex for this line
    CmpPatternPtr cmpPatterPtr = GetMatchingRegex(line, severity);
    buildLineInfo->SetSeverity(severity);
    BuildLineInfo bli;
    if(cmpPatterPtr && cmpPatterPtr->Matches(line, bli)) {
        buildLineInfo->SetFilename(bli.GetFilename());
        buildLineInfo->SetSeverity(bli.GetSeverity());
        buildLineInfo->SetLineNumber(bli.GetLineNumber());
        buildLineInfo->NormalizeFilename(m_directories, m_cygwinRoot);
        buildLineInfo->SetRegexLineMatch(bli.GetRegexLineMatch());
        buildLineInfo->SetColumn(bli.GetColumn());
        if(severity == SV_WARNING) {
            // Warning
            m_errorsAndWarningsList.push_back(buildLineInfo);
            m_warnCount++;
        } else {
            // Error
            m_errorsAndWarningsList.push_back(buildLineInfo);
            m_errorsList.push_back(buildLineInfo);
            m_errorCount++;
        }
    }
    return buildLineInfo;
}
bool NewBuildTab::DoSelectAndOpen(const wxDataViewItem& item)
{
    if(item.IsOk() == false) return false;

    m_listctrl->UnselectAll(); // Clear any selection
    m_listctrl->EnsureVisible(item);
    m_listctrl->Select(item);

    BuildLineInfo* bli = (BuildLineInfo*)m_listctrl->GetItemData(item);
    if(bli) {
        wxFileName fn(bli->GetFilename());

        if(!fn.IsAbsolute()) {
            std::vector<wxFileName> files;
            std::vector<wxFileName> candidates;
            ManagerST::Get()->GetWorkspaceFiles(files, true);

            for(size_t i = 0; i < files.size(); ++i) {
                if(files.at(i).GetFullName() == fn.GetFullName()) {
                    candidates.push_back(files.at(i));
                }
            }

            if(candidates.empty()) return false;

            if(candidates.size() == 1)
                fn = candidates.at(0);

            else {
                // prompt the user
                wxArrayString fileArr;
                for(size_t i = 0; i < candidates.size(); ++i) {
                    fileArr.Add(candidates.at(i).GetFullPath());
                }

                wxString selection = wxGetSingleChoice(_("Select a file to open:"), _("Choose a file"), fileArr);
                if(selection.IsEmpty()) return false;

                fn = wxFileName(selection);
                // if we resolved it now, open the file there is no point in searching this file
                // in m_buildInfoPerFile since the key on this map is kept as full name
                LEditor* editor = clMainFrame::Get()->GetMainBook()->FindEditor(fn.GetFullPath());
                if(!editor) {
                    editor = clMainFrame::Get()->GetMainBook()->OpenFile(
                        fn.GetFullPath(), wxT(""), bli->GetLineNumber(), wxNOT_FOUND, OF_AddJump);
                }

                if(editor) {
                    // We already got compiler markers set here, just goto the line
                    clMainFrame::Get()->GetMainBook()->SelectPage(editor);
                    editor->GotoLine(bli->GetLineNumber());
                    
                    // Convert the compiler column to scintilla's position
                    if(bli->GetColumn() != wxNOT_FOUND) {
                        int pos = editor->PositionFromLine(bli->GetLineNumber());
                        pos += bli->GetColumn() - 1;
                        editor->GotoPos(pos);
                    }
                    SetActive(editor);
                    return true;
                }
            }
        }

        if(fn.IsAbsolute()) {

            // try to locate the editor first
            LEditor* editor = clMainFrame::Get()->GetMainBook()->FindEditor(fn.GetFullPath());
            if(!editor) {
                // Open it
                editor = clMainFrame::Get()->GetMainBook()->OpenFile(
                    bli->GetFilename(), wxT(""), bli->GetLineNumber(), wxNOT_FOUND, OF_AddJump);
            }

            if(editor) {
                if(!editor->HasCompilerMarkers()) MarkEditor(editor);

                int lineNumber = bli->GetLineNumber();
                if(lineNumber > 0) {
                    lineNumber--;
                }

                // We already got compiler markers set here, just goto the line
                clMainFrame::Get()->GetMainBook()->SelectPage(editor);
                editor->GotoLine(bli->GetLineNumber());
                // Convert the compiler column to scintilla's position
                if(bli->GetColumn() != wxNOT_FOUND) {
                    int pos = editor->PositionFromLine(bli->GetLineNumber());
                    pos += bli->GetColumn() - 1;
                    editor->GotoPos(pos);
                }
                editor->ScrollToLine(bli->GetLineNumber());
                editor->EnsureVisible(lineNumber);
                editor->EnsureCaretVisible();
                SetActive(editor);
                return true;
            }
        }
    }
    return false;
}
BuildLineInfo* NewBuildTab::DoProcessLine(const wxString& line, bool isSummaryLine)
{
    BuildLineInfo* buildLineInfo = new BuildLineInfo();

    if(isSummaryLine) {
        // Set the severity
        if(m_errorCount == 0 && m_warnCount == 0) {
            buildLineInfo->SetSeverity(SV_SUCCESS);

        } else if(m_errorCount) {
            buildLineInfo->SetSeverity(SV_ERROR);

        } else {

            buildLineInfo->SetSeverity(SV_WARNING);
        }

    } else {

        // Find *warnings* first
        bool isWarning = false;

        if(!m_cmp) {
            return buildLineInfo;
        }

        CmpPatterns cmpPatterns;
        if(!DoGetCompilerPatterns(m_cmp->GetName(), cmpPatterns)) {
            return buildLineInfo;
        }

        // If it is not an error, maybe it's a warning
        for(size_t i = 0; i < cmpPatterns.warningPatterns.size(); i++) {
            CmpPatternPtr cmpPatterPtr = cmpPatterns.warningPatterns.at(i);
            BuildLineInfo bli;
            if(cmpPatterPtr->Matches(line, bli)) {
                buildLineInfo->SetFilename(bli.GetFilename());
                buildLineInfo->SetSeverity(bli.GetSeverity());
                buildLineInfo->SetLineNumber(bli.GetLineNumber());
                buildLineInfo->NormalizeFilename(m_directories, m_cygwinRoot);
                buildLineInfo->SetRegexLineMatch(bli.GetRegexLineMatch());
                buildLineInfo->SetColumn(bli.GetColumn());
                // keep this info in the errors+warnings list only
                m_errorsAndWarningsList.push_back(buildLineInfo);

                m_warnCount++;
                isWarning = true;
                break;
            }
        }
        if(!isWarning) {
            for(size_t i = 0; i < cmpPatterns.errorsPatterns.size(); i++) {
                BuildLineInfo bli;
                CmpPatternPtr cmpPatterPtr = cmpPatterns.errorsPatterns.at(i);
                if(cmpPatterPtr->Matches(line, bli)) {
                    buildLineInfo->SetFilename(bli.GetFilename());
                    buildLineInfo->SetSeverity(bli.GetSeverity());
                    buildLineInfo->SetLineNumber(bli.GetLineNumber());
                    buildLineInfo->NormalizeFilename(m_directories, m_cygwinRoot);
                    buildLineInfo->SetRegexLineMatch(bli.GetRegexLineMatch());
                    buildLineInfo->SetColumn(bli.GetColumn());

                    // keep this info in both lists (errors+warnings AND errors)
                    m_errorsAndWarningsList.push_back(buildLineInfo);
                    m_errorsList.push_back(buildLineInfo);
                    m_errorCount++;
                    break;
                }
            }
        }
    }
    return buildLineInfo;
}