void CppCheckPlugin::DoSettingsItem(ProjectPtr project/*= NULL*/) { // Find the default path for the CppCheckSettingsDialog's wxFileDialog wxString defaultpath; IEditor* ed = m_mgr->GetActiveEditor(); if (ed && ed->GetFileName().IsOk()) { defaultpath = ed->GetFileName().GetPath(); } // If there's an active project, first load any project-specific settings: definitions and undefines // (We couldn't do that with the rest of the settings as the workspace hadn't yet been loaded) m_settings.LoadProjectSpecificSettings(project); // NB we still do this if !project, as that will clear any stale settings CppCheckSettingsDialog dlg(m_mgr->GetTheApp()->GetTopWindow(), &m_settings, m_mgr->GetConfigTool(), defaultpath, project.Get() != NULL); if (dlg.ShowModal() == wxID_OK) { m_mgr->GetConfigTool()->WriteObject(wxT("CppCheck"), &m_settings); if (project) { // Also save any project-specific settings: definitions and undefines wxString definitions = wxJoin(m_settings.GetDefinitions(), ','); wxString undefines = wxJoin(m_settings.GetUndefines(), ','); if (!(definitions.empty() && undefines.empty())) { project->SetPluginData("CppCheck", definitions + ';' + undefines); } else { project->SetPluginData("CppCheck", ""); } } } }
void ClangCodeCompletion::OnFileLoaded(wxCommandEvent& e) { e.Skip(); CHECK_CLANG_ENABLED_RET(); if(TagsManagerST::Get()->GetCtagsOptions().GetClangCachePolicy() == TagsOptionsData::CLANG_CACHE_ON_FILE_LOAD) { CL_DEBUG(wxT("ClangCodeCompletion::OnFileLoaded() START")); if(m_clang.IsBusy() || m_allEditorsAreClosing) { CL_DEBUG(wxT("ClangCodeCompletion::OnFileLoaded() ENDED")); return; } if(e.GetClientData()) { IEditor *editor = (IEditor*)e.GetClientData(); // sanity if(editor->GetProjectName().IsEmpty() || editor->GetFileName().GetFullName().IsEmpty()) return; if(!TagsManagerST::Get()->IsValidCtagsFile(editor->GetFileName())) return; m_clang.SetContext(CTX_CachePCH); m_clang.CodeCompletion(editor); } CL_DEBUG(wxT("ClangCodeCompletion::OnFileLoaded() ENDED")); } }
void OutlineTab::OnEditorClosed(wxCommandEvent& e) { e.Skip(); IEditor* editor = reinterpret_cast<IEditor*>(e.GetClientData()); if(editor) { if(m_tree->GetFilename() == editor->GetFileName()) { m_tree->Clear(); m_tree->ClearCache(); } else if(m_treeCtrlPhp->GetFilename() == editor->GetFileName()) { m_treeCtrlPhp->Clear(); } } }
void CscopeTab::DoItemActivated(const wxDataViewItem& item ) { CscopeTabClientData *data = dynamic_cast<CscopeTabClientData*>(m_dataviewModel->GetClientObject(item)); if (data) { wxString wsp_path = clCxxWorkspaceST::Get()->GetPrivateFolder(); //a single entry was activated, open the file //convert the file path to absolut path. We do it here, to improve performance wxFileName fn(data->GetEntry().GetFile()); if ( !fn.MakeAbsolute(wsp_path) ) { wxLogMessage(wxT("failed to convert file to absolute path")); } if(m_mgr->OpenFile(fn.GetFullPath(), wxEmptyString, data->GetEntry().GetLine()-1)) { IEditor *editor = m_mgr->GetActiveEditor(); if( editor && editor->GetFileName().GetFullPath() == fn.GetFullPath() && !GetFindWhat().IsEmpty()) { // We can't use data->GetEntry().GetPattern() as the line to search for as any appended comments have been truncated // For some reason LEditor::DoFindAndSelect checks it against the whole current line // and won't believe a match unless their lengths are the same int line = data->GetEntry().GetLine() - 1; int start = editor->PosFromLine(line); // PosFromLine() returns the line start position int end = editor->LineEnd(line); wxString searchline(editor->GetTextRange(start, end)); // Find and select the entry in the file editor->FindAndSelectV(searchline, GetFindWhat(), start); // The async version of FindAndSelect() editor->DelayedSetActive(); // We need to SetActive() editor. At least in wxGTK, this won't work synchronously } } } else { // Parent item, expand it m_dataview->Expand( item ); } }
void NodeJSDebugger::OnToggleBreakpoint(clDebugEvent& event) { event.Skip(); if(NodeJSWorkspace::Get()->IsOpen()) { event.Skip(false); IEditor* editor = clGetManager()->GetActiveEditor(); if(editor && (editor->GetFileName().GetFullPath() == event.GetFileName())) { // Correct editor // add marker NodeJSBreakpoint bp = m_bptManager.GetBreakpoint(event.GetFileName(), event.GetInt()); if(bp.IsOk()) { if(bp.IsApplied() && IsConnected()) { // Tell NodeJS to delete this breakpoint DeleteBreakpoint(bp); } m_bptManager.DeleteBreakpoint(event.GetFileName(), event.GetInt()); } else { // We have no breakpoint on this file/line (yet) m_bptManager.AddBreakpoint(event.GetFileName(), event.GetInt()); bp = m_bptManager.GetBreakpoint(event.GetFileName(), event.GetInt()); if(IsConnected()) { SetBreakpoint(bp); } } // Update the UI m_bptManager.SetBreakpoints(editor); clDebugEvent event(wxEVT_NODEJS_DEBUGGER_UPDATE_BREAKPOINTS_VIEW); EventNotifier::Get()->AddPendingEvent(event); } } }
void XDebugManager::OnToggleBreakpoint(clDebugEvent& e) { if ( !PHPWorkspace::Get()->IsOpen() ) { e.Skip(); return; } // User toggled a breakpoint IEditor* editor = m_plugin->GetManager()->GetActiveEditor(); if ( editor && editor->GetFileName().GetFullPath() == e.GetFileName() ) { // Correct editor // add marker if ( m_breakpointsMgr.HasBreakpoint(e.GetFileName(), e.GetInt()) ) { XDebugBreakpoint bp; m_breakpointsMgr.GetBreakpoint(e.GetFileName(), e.GetInt(), bp); if ( bp.IsApplied() && m_readerThread ) { // Remove it from XDebug as well DoDeleteBreakpoint( bp.GetBreakpointId() ); } m_breakpointsMgr.DeleteBreakpoint( e.GetFileName(), e.GetInt() ); } else { m_breakpointsMgr.AddBreakpoint( e.GetFileName(), e.GetInt() ); DoApplyBreakpoints(); } DoRefreshBreakpointsMarkersForEditor( editor ); } }
void ZoomNavigator::DoUpdate() { // sanity tests CHECK_CONDITION(m_enabled); CHECK_CONDITION(!m_mgr->IsShutdownInProgress()); IEditor* curEditor = m_mgr->GetActiveEditor(); if(!curEditor && !m_text->IsEmpty()) { DoCleanup(); } CHECK_CONDITION(curEditor); wxStyledTextCtrl* stc = curEditor->GetCtrl(); CHECK_CONDITION(stc); if(curEditor->GetFileName().GetFullPath() != m_curfile) { SetEditorText(curEditor); } int first = stc->GetFirstVisibleLine(); int last = stc->LinesOnScreen() + first; if(m_markerFirstLine != first || m_markerLastLine != last) { PatchUpHighlights(first, last); SetZoomTextScrollPosToMiddle(stc); } }
void CMakeHelpTab::CreateHelpPage(const wxString& content, const wxString& subject) { wxString text = content; text.Replace("<br />", "\n"); text.Replace("<" , "<"); text.Replace(">" , ">"); text.Replace("\r", ""); text.Replace("\n\n", "\n"); text.Replace("::\n", "\n\n"); IManager* manager = ::clGetManager(); // Write the content of the help into a temporary file wxFileName fnTemp = wxFileName::CreateTempFileName("cmake"); wxFileName fnCMakeHelpFile = fnTemp; fnCMakeHelpFile.SetFullName("CMakeHelp.cmake"); if(!FileUtils::WriteFileContent(fnCMakeHelpFile, text)) return; if(manager->OpenFile(fnCMakeHelpFile.GetFullPath())) { IEditor* activeEditor = manager->GetActiveEditor(); if(activeEditor && activeEditor->GetFileName().GetFullPath() == fnCMakeHelpFile.GetFullPath()) { activeEditor->GetCtrl()->SetEditable(true); activeEditor->ReloadFile(); activeEditor->GetCtrl()->SetFirstVisibleLine(0); activeEditor->GetCtrl()->SetEditable(false); } } }
void Copyright::OnInsertCopyrights(wxCommandEvent& e) { wxUnusedVar(e); // read configuration CopyrightsConfigData data; m_mgr->GetConfigTool()->ReadObject(wxT("CopyrightsConfig"), &data); // make sure that the template file exists if(!wxFileName::FileExists(data.GetTemplateFilename())) { wxMessageBox( wxString::Format(_("Template file name '%s', does not exist!"), data.GetTemplateFilename().GetData()), _("CodeLite"), wxICON_WARNING | wxOK); return; } // read the copyrights file wxString content; if(!ReadFileWithConversion(data.GetTemplateFilename(), content)) { wxMessageBox(wxString::Format(_("Failed to read template file '%s'"), data.GetTemplateFilename().c_str()), _("CodeLite"), wxICON_WARNING | wxOK); return; } IEditor* editor = m_mgr->GetActiveEditor(); if(!editor) { wxMessageBox(wxString::Format(_("There is no active editor\n")), _("CodeLite"), wxICON_WARNING | wxOK); return; } // verify that the file consist only with comment code CppWordScanner scanner(data.GetTemplateFilename().mb_str().data()); CppTokensMap l; scanner.FindAll(l); if(!l.is_empty()) { if(wxMessageBox(_("Template file contains text which is not comment, continue anyway?"), _("CodeLite"), wxICON_QUESTION | wxYES_NO) == wxNO) { return; } } // expand constants wxString _content = ExpandAllVariables(content, m_mgr->GetWorkspace(), wxEmptyString, wxEmptyString, editor->GetFileName().GetFullPath()); // we are good to go :) wxString ignoreString = data.GetIgnoreString(); ignoreString = ignoreString.Trim().Trim(false); if(ignoreString.IsEmpty() == false) { if(editor->GetEditorText().Find(data.GetIgnoreString()) != wxNOT_FOUND) { clLogMessage(_("File contains ignore string, skipping it")); return; } } editor->InsertText(0, _content); }
void WebTools::OnTimer(wxTimerEvent& event) { event.Skip(); time_t curtime = time(NULL); if((curtime - m_lastColourUpdate) < 5) return; IEditor* editor = m_mgr->GetActiveEditor(); // Sanity CHECK_PTR_RET(editor); CHECK_PTR_RET(editor->IsModified()); if(!IsJavaScriptFile(editor->GetFileName())) return; // This file is a modified JS file m_lastColourUpdate = time(NULL); m_jsColourThread->QueueBuffer(editor->GetFileName().GetFullPath(), editor->GetTextRange(0, editor->GetLength())); }
void OutlineTab::OnActiveEditorChanged(wxCommandEvent& e) { e.Skip(); IEditor* editor = reinterpret_cast<IEditor*>(e.GetClientData()); if(editor) { m_tree->BuildTree(editor->GetFileName()); } }
void LanguageServerCluster::OnLSPInitialized(LSPEvent& event) { wxUnusedVar(event); // Now that the workspace is loaded, parse the active file IEditor* editor = clGetManager()->GetActiveEditor(); CHECK_PTR_RET(editor); LanguageServerProtocol::Ptr_t lsp = GetServerForFile(editor->GetFileName()); if(lsp) { lsp->OpenEditor(editor); } }
void Cscope::OnEditorContentMenu(clContextMenuEvent& event) { event.Skip(); IEditor* editor = m_mgr->GetActiveEditor(); CHECK_PTR_RET(editor); if(FileExtManager::IsCxxFile(editor->GetFileName())) { event.GetMenu()->Append(wxID_ANY, _("CScope"), CreateEditorPopMenu()); } }
CodeFormatterDlg::CodeFormatterDlg(wxWindow* parent, IManager* mgr, CodeFormatter* cf, const FormatOptions& opts, const wxString& sampleCode) : CodeFormatterBaseDlg(parent) , m_cf(cf) , m_sampleCode(sampleCode) , m_isDirty(false) , m_mgr(mgr) { ::wxPGPropertyBooleanUseCheckbox(m_pgMgrAstyle->GetGrid()); ::wxPGPropertyBooleanUseCheckbox(m_pgMgrClang->GetGrid()); ::wxPGPropertyBooleanUseCheckbox(m_pgMgrPhp->GetGrid()); // center the dialog Centre(); m_options = opts; m_textCtrlPreview->SetText(m_sampleCode); GetSizer()->Fit(this); InitDialog(); UpdatePreview(); // Clear the modified status m_pgMgrPhp->GetGrid()->ClearModifiedStatus(); m_pgMgrAstyle->GetGrid()->ClearModifiedStatus(); m_pgMgrClang->GetGrid()->ClearModifiedStatus(); // set the selection based on the editor IEditor* editor = m_mgr->GetActiveEditor(); if(editor && FileExtManager::IsPHPFile(editor->GetFileName())) { m_treebook->SetSelection(4); } else if(editor && FileExtManager::IsCxxFile(editor->GetFileName())) { m_treebook->SetSelection(1); } else { m_treebook->SetSelection(0); } SetName("CodeFormatterDlg"); WindowAttrManager::Load(this); }
void NavBar::OnEditorChanged(wxCommandEvent& e) { e.Skip(); IEditor* editor = reinterpret_cast<IEditor*>(e.GetClientData()); if(!editor) { return; } const wxFileName& fn = editor->GetFileName(); DoPopulateTags(fn); }
void PHPCodeCompletion::OnCodeComplete(clCodeCompletionEvent& e) { e.Skip(true); if(PHPWorkspace::Get()->IsOpen()) { IEditor* editor = dynamic_cast<IEditor*>(e.GetEditor()); if(editor && IsPHPFile(editor)) { e.Skip(false); // Update the settings TagsOptionsData d; clConfig ccConfig("code-completion.conf"); ccConfig.ReadItem(&d); m_lookupTable.SetSizeLimit(d.GetCcNumberOfDisplayItems()); // Check if the code completion was triggered due to user // typing '(', in this case, call OnFunctionCallTip() wxChar charAtPos = editor->GetCharAtPos(editor->GetCurrentPosition() - 1); if(charAtPos == '(') { OnFunctionCallTip(e); } else { // Perform the code completion here PHPExpression::Ptr_t expr(new PHPExpression(editor->GetTextRange(0, e.GetPosition()))); bool isExprStartsWithOpenTag = expr->IsExprStartsWithOpenTag(); PHPEntityBase::Ptr_t entity = expr->Resolve(m_lookupTable, editor->GetFileName().GetFullPath()); if(entity) { // Suggets members for the resolved entity PHPEntityBase::List_t matches; expr->Suggest(entity, m_lookupTable, matches); if(!expr->GetFilter().IsEmpty() && (expr->GetCount() == 0)) { // Word completion PHPEntityBase::List_t keywords = PhpKeywords(expr->GetFilter()); // Preprend the keywords matches.insert(matches.end(), keywords.begin(), keywords.end()); // Did user typed "<?ph" or "<?php" ?? // If so, clear the matches if(isExprStartsWithOpenTag && (expr->GetFilter() == "ph" || expr->GetFilter() == "php")) { matches.clear(); } } // Remove duplicates from the list if(!matches.empty()) { // Show the code completion box DoShowCompletionBox(matches, expr); } } } } } }
void PhpPlugin::OnGetCurrentFileProjectFiles(wxCommandEvent& e) { if(PHPWorkspace::Get()->IsOpen()) { IEditor* editor = m_mgr->GetActiveEditor(); wxArrayString* pfiles = (wxArrayString*)e.GetClientData(); if(editor && pfiles) { PHPWorkspace::Get()->GetFileProjectFiles(editor->GetFileName().GetFullPath(), *pfiles); } } else e.Skip(); }
void SnipWiz::OnEditorContextMenu(clContextMenuEvent& event) { event.Skip(); IEditor* editor = m_mgr->GetActiveEditor(); CHECK_PTR_RET(editor); if(FileExtManager::IsCxxFile(editor->GetFileName())) { wxMenu* newMenu = CreateSubMenu(); event.GetMenu()->Append(wxID_ANY, _("Snippets"), newMenu); } }
void TestClassDlg::OnUseActiveEditor(wxCommandEvent& event) { if(event.IsChecked()) { IEditor* editor = m_manager->GetActiveEditor(); if(editor) { m_textCtrlFileName->SetValue(editor->GetFileName().GetFullPath()); } m_textCtrlFileName->Enable(true); } else { m_textCtrlFileName->Enable(false); } }
void OutlineTab::OnActiveEditorChanged(wxCommandEvent& e) { e.Skip(); IEditor* editor = m_mgr->GetActiveEditor(); LexerConf::Ptr_t phpLexer = ColoursAndFontsManager::Get().GetLexer("php"); LexerConf::Ptr_t cxxLexer = ColoursAndFontsManager::Get().GetLexer("c++"); // Use the lexer to determine if we can show outline if(editor && cxxLexer && FileUtils::WildMatch(cxxLexer->GetFileSpec(), editor->GetFileName())) { m_tree->BuildTree(editor->GetFileName(), false); m_simpleBook->SetSelection(OUTLINE_TAB_CXX); m_textCtrlSearch->Enable(true); } else if(editor && phpLexer && FileUtils::WildMatch(phpLexer->GetFileSpec(), editor->GetFileName())) { m_treeCtrlPhp->BuildTree(editor->GetFileName()); m_simpleBook->SetSelection(OUTLINE_TAB_PHP); m_textCtrlSearch->Enable(true); } else { m_simpleBook->SetSelection(OUTLINE_PLACE_HOLDER_PAGE); m_textCtrlSearch->Enable(false); } }
void CodeLiteDiff::OnTabContextMenu(clContextMenuEvent& event) { event.Skip(); DoClear(); IEditor* activeEditor = m_mgr->GetActiveEditor(); CHECK_PTR_RET(activeEditor); m_leftFile = activeEditor->GetFileName(); // Edit the context menu wxMenuItem* mi = new wxMenuItem(event.GetMenu(), XRCID("diff_compare_with"), _("Compare with..."), ""); mi->SetBitmap(m_mgr->GetStdIcons()->LoadBitmap("diff")); event.GetMenu()->Append(mi); event.GetMenu()->Bind(wxEVT_MENU, &CodeLiteDiff::OnDiff, this, XRCID("diff_compare_with")); }
void OutlineTab::OnFilesTagged(wxCommandEvent& e) { e.Skip(); IEditor* editor = m_mgr->GetActiveEditor(); if( editor ) { m_tree->BuildTree( editor->GetFileName() ); if(editor->GetSTC()) { // make sure we dont steal the focus from the editor... editor->GetSTC()->SetFocus(); } } else { m_tree->Clear(); } }
void SFTP::OnEditorClosed(wxCommandEvent& e) { e.Skip(); IEditor* editor = (IEditor*)e.GetClientData(); if(editor) { wxString localFile = editor->GetFileName().GetFullPath(); if(m_remoteFiles.count(localFile)) { wxLogNull noLog; // Remove the file from our cache ::wxRemoveFile(localFile); m_remoteFiles.erase(localFile); } } }
void ZoomText::OnIdle(wxIdleEvent& event) { event.Skip(); // sanity if(!m_classes.IsEmpty() || IsEmpty()) return; IEditor* editor = clGetManager()->GetActiveEditor(); if(!editor) return; if(m_classes.IsEmpty() && !editor->GetKeywordClasses().IsEmpty() && (editor->GetFileName().GetFullPath() == m_filename)) { // Sync between the keywords SetKeyWords(1, editor->GetKeywordClasses()); // classes SetKeyWords(3, editor->GetKeywordLocals()); // locals Colourise(0, GetLength()); } }
void CppCheckPlugin::OnCheckFileEditorItem(wxCommandEvent& e) { if(m_cppcheckProcess) { clLogMessage(_("CppCheckPlugin: CppCheck is currently busy please wait for it to complete the current check")); return; } ProjectPtr proj; IEditor* editor = m_mgr->GetActiveEditor(); if(editor) { wxString projectName = editor->GetProjectName(); if(!projectName.IsEmpty()) { proj = clCxxWorkspaceST::Get()->GetProject(projectName); } m_filelist.Add(editor->GetFileName().GetFullPath()); } DoStartTest(); }
void OutlineTab::OnFilesTagged(wxCommandEvent& e) { e.Skip(); IEditor* editor = m_mgr->GetActiveEditor(); if(editor) { wxWindow* oldFocusedWindow = wxWindow::FindFocus(); m_tree->BuildTree(editor->GetFileName(), false); wxWindow* focusedWindow = wxWindow::FindFocus(); if(oldFocusedWindow != focusedWindow && oldFocusedWindow) { // restore the focus back the old window oldFocusedWindow->SetFocus(); } } else { m_tree->Clear(); } }
void PHPWorkspaceView::OnRenameFile(wxCommandEvent& e) { wxTreeItemId item = DoGetSingleSelection(); CHECK_ITEM_RET(item); ItemData *data = DoGetItemData(item); CHECK_PTR_RET(data); CHECK_ID_FILE(data); wxFileName old_file_name = data->GetFile(); wxString new_name = ::wxGetTextFromUser(_("New file name:"), _("Rename file"), old_file_name.GetFullName() ); if ( new_name.IsEmpty() ) return; if ( new_name == old_file_name.GetFullName() ) return; // Check to see if we got a file with the old path opened bool reopenFile = false; IEditor *editor = m_mgr->FindEditor(old_file_name.GetFullPath()); if ( editor ) { m_mgr->ClosePage( editor->GetFileName().GetFullName() ); reopenFile = true; editor = NULL; } PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(DoGetSelectedProject()); CHECK_PTR_RET(pProject); if ( pProject->RenameFile(old_file_name.GetFullPath(), new_name) ) { // Locate the folder pProject->Save(); m_treeCtrlView->SetItemText(item, new_name); // Update the item data old_file_name.SetFullName(new_name); data->SetFile( old_file_name.GetFullPath() ); // Open the file if it was opened earlier // old_file_name now contains the new full path to the new file if ( reopenFile ) { m_mgr->OpenFile( old_file_name.GetFullPath() ); } } }
void PHPEditorContextMenu::OnGenerateSettersGetters(wxCommandEvent& e) { // CHeck the current context IEditor* editor = m_manager->GetActiveEditor(); if(editor) { // determine the scope name at the current position // Parse until the current position wxString text = editor->GetTextRange(0, editor->GetCurrentPosition()); PHPSourceFile sourceFile(text); sourceFile.SetParseFunctionBody(true); sourceFile.SetFilename(editor->GetFileName()); sourceFile.Parse(); const PHPEntityClass* scopeAtPoint = sourceFile.Class()->Cast<PHPEntityClass>(); if(!scopeAtPoint) { // Could not determine the scope at the give location return; } // get the class name wxString className = scopeAtPoint->GetShortName(); // generate the code to generate wxString textToAdd; PHPSettersGettersDialog dlg(EventNotifier::Get()->TopFrame(), editor, m_manager); if(dlg.ShowModal() == wxID_OK) { PHPSetterGetterEntry::Vec_t members = dlg.GetMembers(); for(size_t i = 0; i < members.size(); ++i) { textToAdd << members.at(i).GetSetter(dlg.GetScope(), dlg.GetFlags()) << "\n"; textToAdd << members.at(i).GetGetter(dlg.GetFlags()) << "\n"; } if(!textToAdd.IsEmpty()) { int line = PHPCodeCompletion::Instance()->GetLocationForSettersGetters( editor->GetTextRange(0, editor->GetLength()), className); if(!textToAdd.IsEmpty() && line != wxNOT_FOUND) { editor->GetCtrl()->InsertText(editor->PosFromLine(line), textToAdd); } } } } }
void PHPWorkspaceView::OnEditorChanged(wxCommandEvent& e) { e.Skip(); IEditor* editor = reinterpret_cast<IEditor*>(e.GetClientData()); wxUnusedVar(editor); CHECK_PTR_RET(editor); wxFileName filename = editor->GetFileName(); // FIXME : Load all breakpoints for this file and apply them to the UI // Locate the editor for this file PHPProject::Ptr_t pProject(NULL); const PHPProject::Map_t& projects = PHPWorkspace::Get()->GetProjects(); PHPProject::Map_t::const_iterator iter = projects.begin(); for(; iter != projects.end(); ++iter) { if(filename.GetPath().StartsWith(iter->second->GetFilename().GetPath())) { // found our project pProject = iter->second; break; } } CHECK_PTR_RET(pProject); PHPFolder::Ptr_t pFolder = pProject->FolderByFileFullPath(filename.GetFullPath()); CHECK_PTR_RET(pFolder); wxTreeItemId projectItem = DoGetProjectItem(pProject->GetName()); CHECK_ITEM_RET(projectItem); wxTreeItemId folderItem = DoGetFolderItem(projectItem, pFolder); CHECK_ITEM_RET(folderItem); wxTreeItemId fileItem = DoGetFileItem(folderItem, filename.GetFullPath()); CHECK_ITEM_RET(fileItem); m_treeCtrlView->SelectItem(fileItem); m_treeCtrlView->EnsureVisible(fileItem); }
void PHPCodeCompletion::OnCodeComplete(clCodeCompletionEvent& e) { if(PHPWorkspace::Get()->IsOpen()) { if(!CanCodeComplete(e)) return; IEditor* editor = dynamic_cast<IEditor*>(e.GetEditor()); if(editor) { // we handle only .php files if(IsPHPFile(editor)) { // Check if the code completion was triggered due to user // typing '(', in this case, call OnFunctionCallTip() wxChar charAtPos = editor->GetCharAtPos(editor->GetCurrentPosition() - 1); if(charAtPos == '(') { OnFunctionCallTip(e); } else { // Perform the code completion here PHPExpression::Ptr_t expr(new PHPExpression(editor->GetTextRange(0, e.GetPosition()))); PHPEntityBase::Ptr_t entity = expr->Resolve(m_lookupTable, editor->GetFileName().GetFullPath()); if(entity) { // Suggets members for the resolved entity PHPEntityBase::List_t matches; expr->Suggest(entity, m_lookupTable, matches); // Remove duplicates from the list if(!matches.empty()) { // Show the code completion box DoShowCompletionBox(matches, expr); } } } } } } else { e.Skip(); } }