void PHPCodeCompletion::OnFunctionCallTip(clCodeCompletionEvent& e) { e.Skip(); 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)) { // this is our to complete e.Skip(false); // get the position PHPEntityBase::Ptr_t resolved = DoGetPHPEntryUnderTheAtPos(editor, editor->GetCurrentPosition(), true); if(resolved) { // In PHP there is no overloading, so there can be only one signature for a function // so we simply place our match into TagEntryPtrVector_t structure and pass it to the editor TagEntryPtrVector_t tags; tags.push_back(DoPHPEntityToTagEntry(resolved)); clCallTipPtr callTip(new clCallTip(tags)); editor->ShowCalltip(callTip); } } } } }
void PHPCodeCompletion::OnFindSymbol(clCodeCompletionEvent& e) { if(PHPWorkspace::Get()->IsOpen()) { if(!CanCodeComplete(e)) return; IEditor* editor = dynamic_cast<IEditor*>(e.GetEditor()); if(editor) { PHPEntityBase::Ptr_t resolved = GetPHPEntryUnderTheAtPos(editor, editor->GetCurrentPosition()); if(resolved) { m_manager->OpenFile(resolved->GetFilename().GetFullPath(), "", resolved->GetLine()); } } } else { e.Skip(); } }
void PHPCodeCompletion::OnTypeinfoTip(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)) { // FIXME: implement this using the new method return; } } } else { e.Skip(); } }
void PHPCodeCompletion::OnFindSymbol(clCodeCompletionEvent& e) { e.Skip(); if(PHPWorkspace::Get()->IsOpen()) { if(!CanCodeComplete(e)) return; e.Skip(false); IEditor* editor = dynamic_cast<IEditor*>(e.GetEditor()); if(editor) { wxString word = editor->GetWordAtCaret(); if(word.IsEmpty()) return; PHPEntityBase::List_t symbols = m_lookupTable.FindSymbol(word); if(symbols.size() == 1) { PHPEntityBase::Ptr_t match = *symbols.begin(); DoOpenEditorForEntry(match); } else { // Convert the matches to clSelectSymbolDialogEntry::List_t clSelectSymbolDialogEntry::List_t entries; std::for_each(symbols.begin(), symbols.end(), [&](PHPEntityBase::Ptr_t entry) { TagEntryPtr tag = DoPHPEntityToTagEntry(entry); wxBitmap bmp = wxCodeCompletionBox::GetBitmap(tag); clSelectSymbolDialogEntry m; m.bmp = bmp; m.name = entry->GetFullName(); m.clientData = new PHPFindSymbol_ClientData(entry); m.help = tag->GetKind(); entries.push_back(m); }); // Show selection dialog clSelectSymbolDialog dlg(EventNotifier::Get()->TopFrame(), entries); if(dlg.ShowModal() != wxID_OK) return; PHPFindSymbol_ClientData* cd = dynamic_cast<PHPFindSymbol_ClientData*>(dlg.GetSelection()); if(cd) { DoOpenEditorForEntry(cd->m_ptr); } } } } }
void PHPCodeCompletion::OnTypeinfoTip(clCodeCompletionEvent& e) { if(PHPWorkspace::Get()->IsOpen()) { if(!CanCodeComplete(e)) return; IEditor* editor = dynamic_cast<IEditor*>(e.GetEditor()); if(editor) { if(IsPHPFile(editor)) { PHPEntityBase::Ptr_t entity = GetPHPEntityAtPos(editor, e.GetPosition()); if(entity) { e.SetTooltip(entity->ToTooltip()); } return; } } } else { e.Skip(); } }
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(); } }