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 CmpPattern::Matches(const wxString& line, BuildLineInfo& lineInfo) { long fidx, lidx; if ( !m_fileIndex.ToLong ( &fidx ) || !m_lineIndex.ToLong ( &lidx ) ) return false; if ( !m_regex || !m_regex->IsValid() ) return false; if ( !m_regex->Matches( line ) ) return false; lineInfo.SetSeverity(m_severity); if ( m_regex->GetMatchCount() > (size_t)fidx ) { lineInfo.SetFilename( m_regex->GetMatch(line, fidx) ); } // keep the match length lineInfo.SetRegexLineMatch( m_regex->GetMatch(line, 0).length() ); if ( m_regex->GetMatchCount() > (size_t)lidx ) { long lineNumber; wxString strLine = m_regex->GetMatch(line, lidx); strLine.ToLong(&lineNumber); lineInfo.SetLineNumber( --lineNumber ); } return true; }
bool CmpPattern::Matches(const wxString& line, BuildLineInfo& lineInfo) { long fidx, lidx; if(!m_fileIndex.ToLong(&fidx) || !m_lineIndex.ToLong(&lidx)) return false; if(!m_regex || !m_regex->IsValid()) return false; if(!m_regex->Matches(line)) return false; long colIndex; if(!m_colIndex.ToLong(&colIndex)) return false; lineInfo.SetSeverity(m_severity); if(m_regex->GetMatchCount() > (size_t)fidx) { lineInfo.SetFilename(m_regex->GetMatch(line, fidx)); } // keep the match length lineInfo.SetRegexLineMatch(m_regex->GetMatch(line, 0).length()); if(m_regex->GetMatchCount() > (size_t)lidx) { long lineNumber; wxString strLine = m_regex->GetMatch(line, lidx); strLine.ToLong(&lineNumber); lineInfo.SetLineNumber(--lineNumber); } if(m_regex->GetMatchCount() > (size_t)colIndex) { long column; wxString strCol = m_regex->GetMatch(line, colIndex); if(strCol.StartsWith(":")) { strCol.Remove(0, 1); } if(!strCol.IsEmpty() && strCol.ToLong(&column)) { lineInfo.SetColumn(column); } } return true; }
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; }
void NewBuildTab::DoProcessOutput(bool compilationEnded, bool isSummaryLine) { wxUnusedVar(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); // keep the line info if(buildLineInfo->GetFilename().IsEmpty() == false) { m_buildInfoPerFile.insert(std::make_pair(buildLineInfo->GetFilename(), buildLineInfo)); } if(isSummaryLine) { buildLine.Trim(); buildLine.Prepend("===="); buildLine.Append("===="); buildLineInfo->SetSeverity(SV_NONE); } // Keep the line number in the build tab buildLineInfo->SetLineInBuildTab(m_view->GetLineCount() - 1); // -1 because the view always has 1 extra "\n" // Store the line info *before* we add the text // it is needed in the OnStyle function m_viewData.insert(std::make_pair(buildLineInfo->GetLineInBuildTab(), buildLineInfo)); m_view->SetEditable(true); buildLine.Trim(); wxString modText; ::clStripTerminalColouring(buildLine, modText); int curline = m_view->GetLineCount() - 1; m_view->AppendText(modText + "\n"); // get the newly added line width int endPosition = m_view->GetLineEndPosition(curline); // get character position from begin int beginPosition = m_view->PositionFromLine(curline); // and end of line wxPoint beginPos = m_view->PointFromPosition(beginPosition); wxPoint endPos = m_view->PointFromPosition(endPosition); int curLen = (endPos.x - beginPos.x) + 10; m_maxlineWidth = wxMax(m_maxlineWidth, curLen); if(m_maxlineWidth > 0) { m_view->SetScrollWidth(m_maxlineWidth); } m_view->SetEditable(false); if(clConfig::Get().Read(kConfigBuildAutoScroll, true)) { m_view->ScrollToEnd(); } } }