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()); 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() ); editor->ScrollToLine( bli->GetLineNumber() ); editor->EnsureVisible( lineNumber ); editor->EnsureCaretVisible(); SetActive(editor); return true; } } } return false; }
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 ); } } }
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; }
bool NewBuildTab::DoSelectAndOpen(int buildViewLine, bool centerLine) { if(!m_viewData.count(buildViewLine)) { return false; } BuildLineInfo* bli = m_viewData.find(buildViewLine)->second; if(bli) { wxFileName fn(bli->GetFilename()); // Highlight the clicked line on the view m_view->MarkerDeleteAll(LEX_GCC_MARKER); m_view->MarkerAdd(bli->GetLineInBuildTab(), LEX_GCC_MARKER); if(!fn.IsAbsolute()) { std::set<wxString> files; std::vector<wxFileName> candidates; ManagerST::Get()->GetWorkspaceFiles(files); std::for_each(files.begin(), files.end(), [&](const wxString& filepath) { wxFileName fnFilePath(filepath); if(fnFilePath.GetFullName() == fn.GetFullName()) { candidates.push_back(fnFilePath); } }); 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()); } clSingleChoiceDialog dlg(EventNotifier::Get()->TopFrame(), fileArr); dlg.SetLabel(_("Select a file to open")); if(dlg.ShowModal() != wxID_OK) return false; wxString selection = dlg.GetSelection(); 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 clEditor* 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) { DoCentreErrorLine(bli, editor, centerLine); return true; } } } if(fn.IsAbsolute()) { // try to locate the editor first clEditor* 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--; } DoCentreErrorLine(bli, editor, centerLine); return true; } } } return false; }
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(); } } }