@Override public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) { super.fillCompletionVariants(parameters, result); PsiElement position = parameters.getPosition(); if (insideGoOrDeferStatements().accepts(position) || anonymousFunction().accepts(position)) { InsertHandler<LookupElement> insertHandler = GoKeywordCompletionProvider.createTemplateBasedInsertHandler("go_lang_anonymous_func"); result.addElement(GoKeywordCompletionProvider.createKeywordLookupElement("func", CONTEXT_KEYWORD_PRIORITY, insertHandler)); } if (referenceExpression().accepts(position)) { InsertHandler<LookupElement> insertHandler = GoKeywordCompletionProvider.createTemplateBasedInsertHandler("go_lang_anonymous_struct"); result.addElement(GoKeywordCompletionProvider.createKeywordLookupElement("struct", CONTEXT_KEYWORD_PRIORITY, insertHandler)); } }
/** * Run all contributors until any of them returns false or the list is exhausted. If from parameter is not null, contributors * will be run starting from the next one after that. */ public static void getVariantsFromContributors(final CompletionParameters parameters, final String prefix, final CompletionContributor from, final Consumer<CompletionResult> consumer) { final List<CompletionContributor> contributors = CompletionContributor.forParameters(parameters); for (int i = contributors.indexOf(from) + 1; i < contributors.size(); i++) { final CompletionContributor contributor = contributors.get(i); CompletionResultSet result = createResultSet(parameters, prefix, consumer, contributor); contributor.fillCompletionVariants(parameters, result); if (result.isStopped()) { return; } } }
void addTo(CompletionContributor contributor) { contributor.extend(CompletionType.BASIC, KEYWORD_PATTERN, this); }
@Override void addTo(CompletionContributor contributor) { //not in composed words, these will be completed by the DynamicPathCompletionProvider contributor.extend(CompletionType.BASIC, StandardPatterns.instanceOf(PsiElement.class), this); }
@Override public void addTo(CompletionContributor contributor) { final Capture<PsiElement> symbolPattern = PlatformPatterns.psiElement().withParent(Symbol.class); contributor.extend(CompletionType.BASIC, symbolPattern, this); }
@Override public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) { PsiElement position = parameters.getPosition(); PsiFile file = parameters.getOriginalFile(); ASTNode node = position.getNode(); if (file instanceof GoFile && position.getParent() instanceof GoPackageClause && node.getElementType() == GoTypes.IDENTIFIER) { boolean isTestFile = GoTestFinder.isTestFile(file); PsiDirectory directory = file.getParent(); String currentPackageName = ((GoFile)file).getPackageName(); Collection<String> packagesInDirectory = GoPackageUtil.getAllPackagesInDirectory(directory, null, true); for (String packageName : packagesInDirectory) { if (!packageName.equals(currentPackageName)) { result.addElement(packageLookup(packageName, GoCompletionUtil.PACKAGE_PRIORITY - 1)); } if (isTestFile) { result.addElement(packageLookup(packageName + GoConstants.TEST_SUFFIX, GoCompletionUtil.PACKAGE_PRIORITY)); } } if (directory != null && ContainerUtil.filter(directory.getFiles(), Conditions.instanceOf(GoFile.class)).size() == 1) { String packageFromDirectory = GoPsiImplUtil.getLocalPackageName(directory.getName()); if (!packageFromDirectory.isEmpty()) { result.addElement(packageLookup(packageFromDirectory, GoCompletionUtil.PACKAGE_PRIORITY - 1)); } } result.addElement(packageLookup(GoConstants.MAIN, GoCompletionUtil.PACKAGE_PRIORITY - 2)); } super.fillCompletionVariants(parameters, result); }
@Override public void addTo(CompletionContributor contributor) { final Capture<PsiElement> funcPattern = psiElement().withSuperParent(2, FunctionCall.class); contributor.extend(CompletionType.SMART, funcPattern, this); }
@Override void addTo(CompletionContributor contributor) { BashPsiPattern insideVar = new BashPsiPattern().withParent(BashVar.class); contributor.extend(CompletionType.BASIC, insideVar, this); }
@Override public void addTo(CompletionContributor contributor) { final Capture<PsiComment> psiCommentCapture = psiComment().withLanguage(MathematicaLanguage.INSTANCE); contributor.extend(CompletionType.BASIC, psiCommentCapture, this); }
@Override public void addTo(CompletionContributor contributor) { final Capture<PsiElement> symbolPattern = psiElement().withElementType(MathematicaElementTypes.IDENTIFIER); contributor.extend(CompletionType.BASIC, symbolPattern, this); }
@Override void addTo(CompletionContributor contributor) { contributor.extend(CompletionType.BASIC, new BashPsiPattern().inside(BashShebang.class), this); }
@Override void addTo(CompletionContributor contributor) { contributor.extend(CompletionType.BASIC, new BashPsiPattern().withParent(BashWord.class), this); }
@Override void addTo(CompletionContributor contributor) { BashPsiPattern internal = new BashPsiPattern().withParent(BashInternalCommand.class); BashPsiPattern generic = new BashPsiPattern().withParent(BashGenericCommand.class); ElementPattern<PsiElement> internalOrGeneric = StandardPatterns.or(internal, generic); BashPsiPattern pattern = new BashPsiPattern().withParent(internalOrGeneric); contributor.extend(CompletionType.BASIC, pattern, this); }