com.jetbrains.php.completion.PhpCompletionUtil Java Examples
The following examples show how to use
com.jetbrains.php.completion.PhpCompletionUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LattePhpNamespaceCompletionProvider.java From intellij-latte with MIT License | 6 votes |
@Override protected void addCompletions(@NotNull CompletionParameters params, ProcessingContext context, @NotNull CompletionResultSet result) { PsiElement curr = params.getPosition().getOriginalElement(); if (PsiTreeUtil.getParentOfType(curr, LattePhpContent.class) == null) { return; } PhpIndex phpIndex = PhpIndex.getInstance(curr.getProject()); String prefix = result.getPrefixMatcher().getPrefix(); String namespace = ""; if (prefix.contains("\\")) { int index = prefix.lastIndexOf("\\"); namespace = prefix.substring(0, index) + "\\"; prefix = prefix.substring(index + 1); } PhpCompletionUtil.addSubNamespaces(namespace, result.withPrefixMatcher(prefix), phpIndex, PhpNamespaceInsertHandler.getInstance()); }
Example #2
Source File: PhpEntityClassCompletionProvider.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) { if(!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) { return; } PhpIndex phpIndex = PhpIndex.getInstance(parameters.getOriginalFile().getProject()); Map<String, String> entityNamespaces = ServiceXmlParserFactory.getInstance(parameters.getOriginalFile().getProject(), EntityNamesServiceParser.class).getEntityNameMap(); // copied from PhpCompletionUtil::addClassesInNamespace looks the official way to find classes in namespaces // its a really performance nightmare Collection<String> names = phpIndex.getAllClassNames(new CamelHumpMatcher(resultSet.getPrefixMatcher().getPrefix())); for (String name : names) { Collection<PhpClass> classes = phpIndex.getClassesByName(name); for(Map.Entry<String, String> entry: entityNamespaces.entrySet()) { String namespaceFqn = PhpLangUtil.toFQN(entry.getValue()); Collection<PhpClass> filtered = PhpCompletionUtil.filterByNamespace(classes, namespaceFqn); for (PhpClass phpClass : filtered) { resultSet.addElement(new PhpClassLookupElement(phpClass, true, PhpClassReferenceInsertHandler.getInstance())); } } } }
Example #3
Source File: ClassCompletionPanelWrapper.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void init() { this.field = new EditorTextField("", project, com.jetbrains.php.lang.PhpFileType.INSTANCE); PhpCompletionUtil.installClassCompletion(this.field, null, getDisposable()); this.field.getDocument().addDocumentListener(new DocumentAdapter() { @Override public void documentChanged(DocumentEvent e) { String text = field.getText(); if (StringUtil.isEmpty(text) || StringUtil.endsWith(text, "\\")) { return; } addUpdateRequest(250, () -> consumer.consume(field.getText())); } }); GridBagConstraints gbConstraints = new GridBagConstraints(); gbConstraints.fill = 1; gbConstraints.weightx = 1.0D; gbConstraints.gridx = 1; gbConstraints.gridy = 1; panel.add(field, gbConstraints); }
Example #4
Source File: PhpConstGotoCompletionProvider.java From idea-php-symfony2-plugin with MIT License | 5 votes |
public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement lookupElement) { super.handleInsert(context, lookupElement); if (context.getCompletionChar() == ':') { context.setAddCompletionChar(false); } if (!PhpInsertHandlerUtil.isStringAtCaret(context.getEditor(), SCOPE_OPERATOR)) { PhpInsertHandlerUtil.insertStringAtCaret(context.getEditor(), SCOPE_OPERATOR); } PhpCompletionUtil.showCompletion(context); }
Example #5
Source File: ClassCompletionProviderAbstract.java From idea-php-annotation-plugin with MIT License | 5 votes |
@Override public void getPropertyValueCompletions(AnnotationPropertyParameter parameter, AnnotationCompletionProviderParameter completionParameter) { if(!supports(parameter)) { return; } String className = ""; PsiElement element = parameter.getElement(); if(element instanceof StringLiteralExpression) { className = ((StringLiteralExpression) element).getContents(); } PhpIndex phpIndex = PhpIndex.getInstance(parameter.getProject()); PhpCompletionUtil.addClasses(className, completionParameter.getResult(), phpIndex, null); }
Example #6
Source File: PhpAutoPopupTypedHandler.java From idea-php-advanced-autocomplete with MIT License | 5 votes |
@NotNull @Override public Result checkAutoPopup(char charTyped, @NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { if (!(file instanceof PhpFile)) { return Result.CONTINUE; } if (charTyped != '%') { return Result.CONTINUE; } int offset = editor.getCaretModel().getOffset(); PsiElement psiElement = file.findElementAt(offset); ParameterList parameterList = PhpPsiUtil.getParentByCondition(psiElement, true, ParameterList.INSTANCEOF, Statement.INSTANCEOF); if (parameterList != null) { FunctionReference functionCall = ObjectUtils.tryCast(parameterList.getParent(), FunctionReference.class); String fqn = PhpElementsUtil.resolveFqn(functionCall); if (/*charTyped == '%' &&*/ PhpElementsUtil.isFormatFunction(fqn)) { if (StringUtil.getPrecedingCharNum(editor.getDocument().getCharsSequence(), offset, '%') % 2 == 0) { PhpCompletionUtil.showCompletion(editor); } } } return Result.CONTINUE; }
Example #7
Source File: PhpFunctionCompletionContributor.java From idea-php-advanced-autocomplete with MIT License | 4 votes |
@Override public void handleInsert(InsertionContext context, LookupElement lookupElement) { PhpCompletionUtil.showCompletion(context); }