ClTokenPosition ClangPlugin::GetFunctionScopeLocation( const ClTranslUnitId id, const wxString& filename, const wxString& scope, const wxString& functioname) { ClFileId fId = m_Database.GetFilenameId(filename); std::vector<ClTokenId> tokenIdList = m_Database.GetFileTokens(fId); for ( std::vector<ClTokenId>::const_iterator it = tokenIdList.begin(); it != tokenIdList.end(); ++it) { ClAbstractToken token = m_Database.GetToken(*it); if ((token.scopeName == scope)&&(token.displayName == functioname)) { return token.location; } } return ClTokenPosition(0,0); }
void ClangPlugin::OnClangGetDiagnosticsFinished( wxEvent& event ) { #ifdef CLANGPLUGIN_TRACE_FUNCTIONS //fprintf(stdout,"%s\n", __PRETTY_FUNCTION__); #endif ClDiagnosticLevel diagLv = dlFull; // TODO ClangProxy::GetDiagnosticsJob* pJob = static_cast<ClangProxy::GetDiagnosticsJob*>(event.GetEventObject()); ClangEvent evt( clEVT_DIAGNOSTICS_UPDATED, pJob->GetTranslationUnitId(), pJob->GetFilename(), ClTokenPosition(0,0), pJob->GetResults()); ProcessEvent(evt); #if 0 EditorManager* edMgr = Manager::Get()->GetEditorManager(); cbEditor* ed = edMgr->GetBuiltinActiveEditor(); if (!ed) { std::cout<<"No editor..."<<std::endl; return; } if ((pJob->m_TranslId != m_TranslUnitId)||(ed != m_pLastEditor)) { // No longer the current editor std::cout<<"Diagnostics requested but another file was loaded..."<<std::endl; return; } cbStyledTextCtrl* stc = ed->GetControl(); if (diagLv == dlFull) stc->AnnotationClearAll(); const int warningIndicator = 0; // predefined const int errorIndicator = 15; // hopefully we do not clash with someone else... stc->SetIndicatorCurrent(warningIndicator); stc->IndicatorClearRange(0, stc->GetLength()); stc->IndicatorSetStyle(errorIndicator, wxSCI_INDIC_SQUIGGLE); stc->IndicatorSetForeground(errorIndicator, *wxRED); stc->SetIndicatorCurrent(errorIndicator); stc->IndicatorClearRange(0, stc->GetLength()); const wxString& fileNm = ed->GetFilename(); for ( std::vector<ClDiagnostic>::const_iterator dgItr = pJob->m_Diagnostic.begin(); dgItr != pJob->m_Diagnostic.end(); ++dgItr ) { //Manager::Get()->GetLogManager()->Log(dgItr->file + wxT(" ") + dgItr->message + F(wxT(" %d, %d"), dgItr->range.first, dgItr->range.second)); if (dgItr->file != fileNm) continue; if (diagLv == dlFull) { wxString str = stc->AnnotationGetText(dgItr->line - 1); if (!str.IsEmpty()) str += wxT('\n'); stc->AnnotationSetText(dgItr->line - 1, str + dgItr->message); stc->AnnotationSetStyle(dgItr->line - 1, 50); } int pos = stc->PositionFromLine(dgItr->line - 1) + dgItr->range.first - 1; int range = dgItr->range.second - dgItr->range.first; if (range == 0) { range = stc->WordEndPosition(pos, true) - pos; if (range == 0) { pos = stc->WordStartPosition(pos, true); range = stc->WordEndPosition(pos, true) - pos; } } if (dgItr->severity == sError) stc->SetIndicatorCurrent(errorIndicator); else if ( dgItr != pJob->m_Diagnostics.begin() && dgItr->line == (dgItr - 1)->line && dgItr->range.first <= (dgItr - 1)->range.second ) { continue; // do not overwrite the last indicator } else stc->SetIndicatorCurrent(warningIndicator); stc->IndicatorFillRange(pos, range); } if (diagLv == dlFull) stc->AnnotationSetVisible(wxSCI_ANNOTATION_BOXED); #endif }
wxString ClangCodeCompletion::GetDocumentation( const cbCodeCompletionPlugin::CCToken &token ) { EditorManager* edMgr = Manager::Get()->GetEditorManager(); cbEditor* ed = edMgr->GetBuiltinActiveEditor(); if (ed) { return m_pClangPlugin->GetCodeCompletionTokenDocumentation( m_TranslUnitId, ed->GetFilename(), ClTokenPosition(0,0), token.id ); } return wxEmptyString; }