Esempio n. 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;
}
Esempio n. 2
0
void NewBuildTab::OnStyleNeeded(wxStyledTextEvent& event)
{
    int startPos = m_view->GetEndStyled();
    int endPos = event.GetPosition();
    wxString text = m_view->GetTextRange(startPos, endPos);
#if wxCHECK_VERSION(3, 1, 1) && !defined(__WXOSX__)
    // The scintilla syntax in e.g. wx3.1.1 changed
    m_view->StartStyling(startPos);
#else
    m_view->StartStyling(startPos, 0x1f);
#endif

    int curline = m_view->GetLineCount();
    curline -= 1; // The view always ends with a "\n", we don't count it as a line
    wxArrayString lines = ::wxStringTokenize(text, wxT("\n"), wxTOKEN_RET_DELIMS);

    // the last line that we coloured
    curline -= lines.size();

    for(size_t i = 0; i < lines.size(); ++i) {
        const wxString& strLine = lines.Item(i);
        if(m_viewData.count(curline)) {
            BuildLineInfo* b = m_viewData.find(curline)->second;
            switch(b->GetSeverity()) {
            case SV_WARNING:
                m_view->SetStyling(strLine.length(), LEX_GCC_WARNING);
                break;
            case SV_ERROR:
                m_view->SetStyling(strLine.length(), LEX_GCC_ERROR);
                break;
            case SV_SUCCESS:
                m_view->SetStyling(strLine.length(), LEX_GCC_DEFAULT);
                break;
            case SV_DIR_CHANGE:
                m_view->SetStyling(strLine.length(), LEX_GCC_INFO);
                break;
            case SV_NONE:
            default:
                m_view->SetStyling(strLine.length(), LEX_GCC_DEFAULT);
                break;
            }
        } else {
            m_view->SetStyling(strLine.length(), LEX_GCC_DEFAULT);
        }
        ++curline;
    }
}
Esempio n. 3
0
void NewBuildTab::DoProcessOutput(bool compilationEnded, bool isSummaryLine)
{
    if ( !compilationEnded && m_output.Find(wxT("\n")) == wxNOT_FOUND ) {
        // still dont have a complete line
        return;
    }

    wxArrayString lines = ::wxStringTokenize(m_output, wxT("\n"), wxTOKEN_RET_DELIMS);
    m_output.Clear();

    // Process only completed lines (i.e. a line that ends with '\n')
    for(size_t i=0; i<lines.GetCount(); i++) {
        if( !compilationEnded && !lines.Item(i).EndsWith(wxT("\n")) ) {
            m_output << lines.Item(i);
            return;
        }

        wxString buildLine = lines.Item(i);//.Trim().Trim(false);
        // If this is a line similar to 'Entering directory `'
        // add the path in the directories array
        DoSearchForDirectory(buildLine);
        BuildLineInfo *buildLineInfo = DoProcessLine(buildLine, isSummaryLine);

        //keep the line info
        if(buildLineInfo->GetFilename().IsEmpty() == false) {
            m_buildInfoPerFile.insert(std::make_pair(buildLineInfo->GetFilename(), buildLineInfo));
        }

        // Append the line content

        if( buildLineInfo->GetSeverity() == SV_ERROR ) {
            if ( !isSummaryLine ) {
                buildLine.Prepend(ERROR_MARKER);
            }

        } else if( buildLineInfo->GetSeverity() == SV_WARNING ) {
            if ( !isSummaryLine ) {
                buildLine.Prepend(WARNING_MARKER);
            }
        }

        if ( isSummaryLine ) {

            // Add a marker for drawing the bitmap
            if ( m_errorCount ) {
                buildLine.Prepend(SUMMARY_MARKER_ERROR);

            } else if ( m_warnCount ) {
                buildLine.Prepend(SUMMARY_MARKER_WARNING);

            } else {
                buildLine.Prepend(SUMMARY_MARKER_SUCCESS);
            }
            buildLine.Prepend(SUMMARY_MARKER);
        }

        wxVector<wxVariant> data;
        data.push_back( wxVariant(buildLine) );
        
        // Keep the line number in the build tab
        buildLineInfo->SetLineInBuildTab( m_listctrl->GetItemCount() );
        m_listctrl->AppendItem(data, (wxUIntPtr)buildLineInfo);
        
        
        if ( clConfig::Get().Read("build-auto-scroll", true) ) {
            unsigned int count = m_listctrl->GetStore()->GetItemCount();
            wxDataViewItem lastItem = m_listctrl->GetStore()->GetItem(count-1);
            m_listctrl->EnsureVisible( lastItem );
        }

    }

}
Esempio n. 4
0
void NewBuildTab::MarkEditor(LEditor* editor)
{
    if ( !editor )
        return;

    editor->DelAllCompilerMarkers();
    editor->AnnotationClearAll();
    editor->AnnotationSetVisible(2); // Visible with box around it

    BuildTabSettingsData options;
    EditorConfigST::Get()->ReadObject(wxT("build_tab_settings"), &options);

    // Are markers or annotations enabled?
    if( options.GetErrorWarningStyle() == BuildTabSettingsData::EWS_NoMarkers ) {
        return;
    }

    std::pair<MultimapBuildInfo_t::iterator, MultimapBuildInfo_t::iterator> iter = m_buildInfoPerFile.equal_range(editor->GetFileName().GetFullPath());
    if ( iter.first == iter.second ) {
        // could not find any, try the fullname
        iter = m_buildInfoPerFile.equal_range(editor->GetFileName().GetFullName());
#if defined(__WXGTK__)
        if ( iter.first == iter.second ) {
            // Nope. Perhaps it's a symlink
            iter = m_buildInfoPerFile.equal_range(CLRealPath(editor->GetFileName().GetFullPath()));
        }
#endif
    }
    
    editor->InitializeAnnotations();
    
    // Merge all the errors from the same line into a single error
    AnnotationInfoByLineMap_t annotations;
    
    for(; iter.first != iter.second; ++iter.first) {
        BuildLineInfo *bli = iter.first->second;
        wxString text = m_listctrl->GetTextValue(bli->GetLineInBuildTab(), 0).Trim().Trim(false);
        
        // strip any build markers
        StripBuildMarkders(text);
        
        // remove the line part from the text
        text = text.Mid(bli->GetRegexLineMatch());
        
        // if the line starts with ':' remove it as well
        text.StartsWith(":", &text);
        text.Trim().Trim(false);
        
        if ( !text.IsEmpty() ) {
            if( bli && (bli->GetSeverity() == SV_ERROR || bli->GetSeverity() == SV_WARNING) ) {
                if( annotations.count(bli->GetLineNumber()) ) {
                    // we already have an error on this line, concatenate the message
                    AnnotationInfo &info = annotations[bli->GetLineNumber()];
                    info.text << "\n" << text;
                    
                    if ( bli->GetSeverity() == SV_ERROR ) {
                        // override the severity to ERROR
                        info.severity = SV_ERROR; 
                    }
                    
                } else {
                    // insert new one
                    AnnotationInfo info;
                    info.line = bli->GetLineNumber();
                    info.severity = bli->GetSeverity();
                    info.text = text;
                    annotations.insert( std::make_pair(bli->GetLineNumber(), info) );
                }
            }
            
        }
    }
    
    AnnotationInfoByLineMap_t::iterator annIter = annotations.begin();
    for(; annIter != annotations.end(); ++annIter) {
        if ( annIter->second.severity == SV_ERROR ) {
            editor->SetErrorMarker(annIter->first, annIter->second.text);
        } else {
            editor->SetWarningMarker(annIter->first, annIter->second.text);
        }
    }
    // now place the errors
    editor->Refresh();
}
Esempio n. 5
0
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 {

        DoUpdateCurrentCompiler(line); // Usering the current line, update the active compiler based on the current project being compiled
        // Find *warnings* first
        bool isWarning = false;

        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());
                
                // 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());
                    
                    // 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;
}