Java Code Examples for com.intellij.codeInsight.completion.CompletionResultSet#addAllElements()
The following examples show how to use
com.intellij.codeInsight.completion.CompletionResultSet#addAllElements() .
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: LSContentAssistProcessor.java From intellij-quarkus with Eclipse Public License 2.0 | 6 votes |
@Override public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) { Document document = parameters.getEditor().getDocument(); Editor editor = parameters.getEditor(); Project project = parameters.getOriginalFile().getProject(); int offset = parameters.getOffset(); initiateLanguageServers(project, document); CompletionParams param; try { param = LSPIJUtils.toCompletionParams(LSPIJUtils.toUri(document), offset, document); List<LookupElement> proposals = Collections.synchronizedList(new ArrayList<>()); this.completionLanguageServersFuture .thenComposeAsync(languageServers -> CompletableFuture.allOf(languageServers.stream() .map(languageServer -> languageServer.getTextDocumentService().completion(param) .thenAcceptAsync(completion -> proposals .addAll(toProposals(project, editor, document, offset, completion, languageServer)))) .toArray(CompletableFuture[]::new))) .get(); result.addAllElements(proposals); } catch (RuntimeException | InterruptedException | ExecutionException e) { LOGGER.warn(e.getLocalizedMessage(), e); result.addElement(createErrorProposal(offset, e)); } super.fillCompletionVariants(parameters, result); }
Example 2
Source File: YamlCompletionProvider.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; } if(this.lookupList != null) { resultSet.addAllElements(this.lookupList); } else if(lookupMap != null) { for (Map.Entry<String, String> lookup : lookupMap.entrySet()) { LookupElementBuilder lookupElement = LookupElementBuilder.create(lookup.getKey()).withTypeText(lookup.getValue(), true).withIcon(Symfony2Icons.SYMFONY); if(lookup.getValue() != null && lookup.getValue().contains("deprecated")) { lookupElement = lookupElement.withStrikeoutness(true); } resultSet.addElement(lookupElement); } } }
Example 3
Source File: AnnotationExpressionGotoCompletionRegistrar.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@Override public void getLookupElements(@NotNull GotoCompletionProviderLookupArguments arguments) { final CompletionResultSet resultSet = arguments.getResultSet(); String blockNamePrefix = resultSet.getPrefixMatcher().getPrefix(); // find caret position: // - "has_role('" // - "has_role('YAML_ROLE_" if(!blockNamePrefix.matches("^.*(has_role|is_granted)\\s*\\(\\s*'[\\w-]*$")) { return; } // clear prefix caret string; for a clean completion independent from inside content CompletionResultSet myResultSet = resultSet.withPrefixMatcher(""); VoterUtil.LookupElementPairConsumer consumer = new VoterUtil.LookupElementPairConsumer(); VoterUtil.visitAttribute(getProject(), consumer); myResultSet.addAllElements(consumer.getLookupElements()); }
Example 4
Source File: LatteVariableCompletionProvider.java From intellij-latte with MIT License | 6 votes |
@Override protected void addCompletions( @NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result ) { PsiElement element = parameters.getPosition().getParent(); if ((element instanceof LattePhpVariable) && ((LattePhpVariable) element).isDefinition()) { return; } List<LookupElement> elements = attachPhpVariableCompletions(element, parameters.getOriginalFile().getVirtualFile()); result.addAllElements(elements); if (parameters.getOriginalFile() instanceof LatteFile) { attachTemplateTypeCompletions(result, element.getProject(), (LatteFile) parameters.getOriginalFile()); } }
Example 5
Source File: PropertiesCompletionProvider.java From component-runtime with Apache License 2.0 | 5 votes |
@Override protected void addCompletions(final CompletionParameters completionParameters, final ProcessingContext processingContext, final CompletionResultSet resultSet) { final PsiElement element = completionParameters.getPosition(); if (!LeafPsiElement.class.isInstance(element)) { return; // ignore comment } final Project project = element.getProject(); final Module module = findModule(element); final SuggestionService service = ServiceManager.getService(project, SuggestionService.class); if ((module == null || !service.isSupported(completionParameters))) { // limit suggestion to Messages return; } if (PropertyValueImpl.class.isInstance(element)) { ofNullable(PropertyValueImpl.class.cast(element).getPrevSibling()) .map(PsiElement::getPrevSibling) .map(PsiElement::getText) .ifPresent(text -> resultSet.addAllElements(service.computeValueSuggestions(text))); } else if (PropertyKeyImpl.class.isInstance(element)) { final List<String> containerElements = PropertiesFileImpl.class .cast(element.getContainingFile()) .getProperties() .stream() .filter(p -> !Objects.equals(p.getKey(), element.getText())) .map(IProperty::getKey) .collect(toList()); resultSet .addAllElements(service .computeKeySuggestions(project, module, getPropertiesPackage(module, completionParameters), containerElements, truncateIdeaDummyIdentifier(element))); } }
Example 6
Source File: EventCompletionProvider.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Override protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, final @NotNull CompletionResultSet completionResultSet) { if(!Symfony2ProjectComponent.isEnabled(completionParameters.getPosition())) { return; } completionResultSet.addAllElements( EventDispatcherSubscriberUtil.getEventNameLookupElements(completionParameters.getPosition().getProject()) ); }
Example 7
Source File: TagNameCompletionProvider.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Override protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { if(!Symfony2ProjectComponent.isEnabled(completionParameters.getPosition())) { return; } completionResultSet.addAllElements(getTagLookupElements(completionParameters.getPosition().getProject())); }
Example 8
Source File: PhpDocTagGotoCompletionContributor.java From idea-php-toolbox with MIT License | 5 votes |
@Override public void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) { PsiElement psiElement = completionParameters.getPosition().getParent(); Collection<PhpDocParamTag> docTags = PhpDocUtil.getDocTagsForScope(psiElement); if(docTags == null || docTags.size() == 0) { return; } PhpToolboxCompletionContributorParameter parameter = null; for(PhpDocParamTag phpDocParamTag: docTags) { String providerName = extractProviderName(phpDocParamTag.getText()); if(providerName == null) { continue; } List<PhpToolboxProviderInterface> filter = getProvidersByName( psiElement, providerName ); if(filter.size() == 0) { continue; } if(parameter == null) { parameter = new PhpToolboxCompletionContributorParameter(completionParameters, context, resultSet, new HashSet<>()); } for (PhpToolboxProviderInterface provider : filter) { resultSet.addAllElements(provider.getLookupElements(parameter)); } } }
Example 9
Source File: DynamicPathCompletionProvider.java From BashSupport with Apache License 2.0 | 5 votes |
@Override protected void addBashCompletions(String currentText, CompletionParameters parameters, ProcessingContext context, CompletionResultSet result) { //if we are in a combined word, get it PsiElement parentElement = parameters.getPosition().getParent(); if (parentElement instanceof BashWord) { currentText = findCurrentText(parameters, parentElement); } result = result.withPrefixMatcher(currentText); String usedPrefix = findUsedPrefix(currentText); if (usedPrefix == null) { return; } //fixme shouldn't be needed String baseDir = findBaseDir(parameters, usedPrefix); if (baseDir == null) { return; } String relativePath = currentText.substring(usedPrefix.length()); if (relativePath.startsWith("/")) { relativePath = relativePath.substring(1); } List<String> completions = CompletionUtil.completeRelativePath(baseDir, usedPrefix, relativePath); result.addAllElements(CompletionProviderUtils.createPathItems(completions)); }
Example 10
Source File: VariableNameCompletionProvider.java From BashSupport with Apache License 2.0 | 5 votes |
private void addBuiltInVariables(CompletionResultSet result, Project project) { if (BashProjectSettings.storedSettings(project).isAutocompleteBuiltinVars()) { Collection<LookupElement> shellBuiltIns = CompletionProviderUtils.createItems(LanguageBuiltins.bashShellVars, BashIcons.BASH_VAR_ICON, true, CompletionGrouping.BuiltInVar.ordinal()); result.addAllElements(shellBuiltIns); Collection<LookupElement> bashBuiltIns = CompletionProviderUtils.createItems(LanguageBuiltins.bourneShellVars, BashIcons.BOURNE_VAR_ICON, true, CompletionGrouping.BuiltInVar.ordinal()); result.addAllElements(bashBuiltIns); } }
Example 11
Source File: VariableNameCompletionProvider.java From BashSupport with Apache License 2.0 | 5 votes |
private int addCollectedVariables(PsiElement element, CompletionResultSet result, BashVarCollectorProcessor processor) { PsiTreeUtil.treeWalkUp(processor, element, BashPsiUtils.findFileContext(element), ResolveState.initial()); Collection<LookupElement> items = CompletionProviderUtils.createFromPsiItems(processor.getVariables(), BashIcons.VAR_ICON, CompletionGrouping.NormalVar.ordinal()); result.addAllElements(items); return items.size(); }
Example 12
Source File: PhpDocTagGotoCompletionContributor.java From idea-php-toolbox with MIT License | 5 votes |
@Override public void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) { PsiElement psiElement = completionParameters.getPosition().getParent(); Collection<PhpDocParamTag> docTags = PhpDocUtil.getDocTagsForScope(psiElement); if(docTags == null || docTags.size() == 0) { return; } PhpToolboxCompletionContributorParameter parameter = null; for(PhpDocParamTag phpDocParamTag: docTags) { String providerName = extractProviderName(phpDocParamTag.getText()); if(providerName == null) { continue; } List<PhpToolboxProviderInterface> filter = getProvidersByName( psiElement, providerName ); if(filter.size() == 0) { continue; } if(parameter == null) { parameter = new PhpToolboxCompletionContributorParameter(completionParameters, context, resultSet, new HashSet<>()); } for (PhpToolboxProviderInterface provider : filter) { resultSet.addAllElements(provider.getLookupElements(parameter)); } } }
Example 13
Source File: NewViewNameCompletionProvider.java From idea-php-laravel-plugin with MIT License | 4 votes |
@Override protected void addCompletionVariants(@NotNull String s, int i, @NotNull String s1, @NotNull CompletionResultSet completionResultSet) { completionResultSet.addAllElements(completions); }
Example 14
Source File: VariableNameCompletionProvider.java From BashSupport with Apache License 2.0 | 4 votes |
private void addGlobalVariables(CompletionResultSet result, Project project) { if (BashProjectSettings.storedSettings(project).isAutcompleteGlobalVars()) { Collection<LookupElement> globalVars = CompletionProviderUtils.createItems(BashProjectSettings.storedSettings(project).getGlobalVariables(), BashIcons.GLOBAL_VAR_ICON, true, CompletionGrouping.GlobalVar.ordinal()); result.addAllElements(globalVars); } }
Example 15
Source File: KeywordCompletionProvider.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 4 votes |
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { result.addAllElements(CypherKeywords.KEYWORD_LOOKUP_ELEMENTS); }
Example 16
Source File: BuiltInFunctionCompletionProvider.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 4 votes |
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { result.addAllElements(CypherBuiltInFunctions.FUNCTION_LOOKUP_ELEMENTS); }
Example 17
Source File: ControllerCompletionProvider.java From idea-php-symfony2-plugin with MIT License | 3 votes |
@Override protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { if(!Symfony2ProjectComponent.isEnabled(completionParameters.getPosition())) { return; } completionResultSet.addAllElements(ControllerIndex.getControllerLookupElements(completionParameters.getPosition().getProject())); }