当前位置: 首页>>代码示例>>Java>>正文


Java CompletionProvider类代码示例

本文整理汇总了Java中com.intellij.codeInsight.completion.CompletionProvider的典型用法代码示例。如果您正苦于以下问题:Java CompletionProvider类的具体用法?Java CompletionProvider怎么用?Java CompletionProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CompletionProvider类属于com.intellij.codeInsight.completion包,在下文中一共展示了CompletionProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extendWithTemplateDefinitionLevelKeywords

import com.intellij.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
/**
 * Complete the "visibility" and "stricthtml" keywords in template definition open tags.
 */
private void extendWithTemplateDefinitionLevelKeywords() {
  extend(
      CompletionType.BASIC,
      psiElement().andOr(psiElement().inside(SoyBeginTemplate.class)),
      new CompletionProvider<CompletionParameters>() {
        @Override
        protected void addCompletions(
            @NotNull CompletionParameters completionParameters,
            ProcessingContext processingContext,
            @NotNull CompletionResultSet completionResultSet) {
          if (isPrecededBy(completionParameters.getPosition(),
              elt -> elt instanceof SoyTemplateDefinitionIdentifier)) {
            completionResultSet.addElement(
                LookupElementBuilder.create("visibility=\"private\""));
            completionResultSet.addElement(
                LookupElementBuilder.create("stricthtml=\"true\""));
          }
        }
      });
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:24,代码来源:SoyCompletionContributor.java

示例2: extendWithParameterTypes

import com.intellij.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
/**
 * Complete types in {@param ...} .
 */
private void extendWithParameterTypes() {
  // Complete types in @param.
  extend(
      CompletionType.BASIC,
      psiElement()
          .andOr(
              psiElement().inside(SoyAtParamSingle.class).afterLeaf(":"),
              psiElement().inside(SoyAtInjectSingle.class).afterLeaf(":"),

              // List type literal.
              psiElement().inside(SoyListType.class).afterLeaf("<"),

              // Map type literal.
              psiElement().inside(SoyMapType.class).afterLeaf("<"),
              psiElement().inside(SoyMapType.class).afterLeaf(",")),
      new CompletionProvider<CompletionParameters>() {
        @Override
        protected void addCompletions(
            @NotNull CompletionParameters completionParameters,
            ProcessingContext processingContext,
            @NotNull CompletionResultSet completionResultSet) {
          completionResultSet.addAllElements(soyTypeLiterals);
        }
      });
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:29,代码来源:SoyCompletionContributor.java

示例3: EmojiResourceCompletionContributor

import com.intellij.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public EmojiResourceCompletionContributor() {
	extend(CompletionType.BASIC, PlatformPatterns.psiElement(PsiElement.class), new CompletionProvider<CompletionParameters>() {
		@Override
		protected void addCompletions(@NotNull CompletionParameters completionParameters,
									  ProcessingContext processingContext,
									  @NotNull CompletionResultSet completionResultSet) {
			Document document = completionParameters.getEditor().getDocument();
			int lineStart = document.getLineStartOffset(document.getLineNumber(completionParameters.getOffset()));
			String lineText = document.getText(new TextRange(lineStart, completionParameters.getOffset()));
			if (includeCount(lineText) == 1) {
				for (Map.Entry<String, Icon> iconEntry : EmojiUtil.getEmojiMap().entrySet()) {
					completionResultSet.addElement(LookupElementBuilder.create(iconEntry.getKey(), ":" + iconEntry.getKey() + ":")
							.withIcon(iconEntry.getValue())
							.withInsertHandler((insertionContext, lookupElement) -> {
								int startOffset = insertionContext.getStartOffset();
								Document insertDocument = insertionContext.getDocument();
								if (startOffset > 0 && insertDocument.getCharsSequence().charAt(startOffset - 1) == ':') {
									insertDocument.deleteString(startOffset - 1, startOffset);
								}
							}));
				}
			}
		}
	});
}
 
开发者ID:syuchan1005,项目名称:EmojiPrefix,代码行数:26,代码来源:EmojiResourceCompletionContributor.java

示例4: ExtensionsNameContributor

import com.intellij.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public ExtensionsNameContributor() {
    extend(
        CompletionType.BASIC,
        tagAttributePattern("extension", "name", null),
        new CompletionProvider<CompletionParameters>() {

            @Override
            protected void addCompletions(
                @NotNull final CompletionParameters parameters,
                final ProcessingContext context,
                @NotNull final CompletionResultSet result
            ) {
                final HybrisProjectSettings hybrisProjectSettings
                    = HybrisProjectSettingsComponent.getInstance(parameters.getOriginalFile().getProject())
                                                    .getState();
                final Set<String> extensions = hybrisProjectSettings.getCompleteSetOfAvailableExtensionsInHybris();

                extensions.forEach(name -> result.addElement(LookupElementBuilder.create(name)));
            }
        }
    );

}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:24,代码来源:ExtensionsNameContributor.java

示例5: WorkspaceTypeCompletionContributor

import com.intellij.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public WorkspaceTypeCompletionContributor() {
  extend(
      CompletionType.BASIC,
      psiElement()
          .withLanguage(ProjectViewLanguage.INSTANCE)
          .inside(ProjectViewPsiScalarSection.class)
          .afterLeaf(psiElement().withText(":").afterLeaf(WorkspaceTypeSection.KEY.getName())),
      new CompletionProvider<CompletionParameters>() {
        @Override
        protected void addCompletions(
            CompletionParameters parameters,
            ProcessingContext context,
            CompletionResultSet result) {
          for (WorkspaceType type : WorkspaceType.values()) {
            result.addElement(LookupElementBuilder.create(type.getName()));
          }
        }
      });
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:20,代码来源:WorkspaceTypeCompletionContributor.java

示例6: AdditionalLanguagesCompletionContributor

import com.intellij.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public AdditionalLanguagesCompletionContributor() {
  extend(
      CompletionType.BASIC,
      psiElement()
          .withLanguage(ProjectViewLanguage.INSTANCE)
          .inside(
              psiElement(ProjectViewPsiListSection.class)
                  .withText(
                      StandardPatterns.string()
                          .startsWith(AdditionalLanguagesSection.KEY.getName()))),
      new CompletionProvider<CompletionParameters>() {
        @Override
        protected void addCompletions(
            CompletionParameters parameters,
            ProcessingContext context,
            CompletionResultSet result) {
          for (LanguageClass type :
              availableAdditionalLanguages(parameters.getEditor().getProject())) {
            result.addElement(LookupElementBuilder.create(type.getName()));
          }
        }
      });
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:24,代码来源:AdditionalLanguagesCompletionContributor.java

示例7: ProjectViewKeywordCompletionContributor

import com.intellij.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public ProjectViewKeywordCompletionContributor() {
  extend(
      CompletionType.BASIC,
      psiElement()
          .withLanguage(ProjectViewLanguage.INSTANCE)
          .withElementType(ProjectViewTokenType.IDENTIFIERS)
          .andOr(psiElement().afterLeaf("\n"), psiElement().afterLeaf(psiElement().isNull())),
      new CompletionProvider<CompletionParameters>() {
        @Override
        protected void addCompletions(
            CompletionParameters parameters,
            ProcessingContext context,
            CompletionResultSet result) {
          result.addAllElements(keywordLookups);
        }
      });
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:18,代码来源:ProjectViewKeywordCompletionContributor.java

示例8: BuiltInSymbolCompletionContributor

import com.intellij.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public BuiltInSymbolCompletionContributor() {
  extend(
      CompletionType.BASIC,
      psiElement()
          .withLanguage(BuildFileLanguage.INSTANCE)
          .andNot(psiComment())
          .withParent(ReferenceExpression.class)
          .andNot(psiElement().inside(FuncallExpression.class))
          .andNot(psiElement().afterLeaf(psiElement().withText("."))),
      new CompletionProvider<CompletionParameters>() {
        @Override
        protected void addCompletions(
            CompletionParameters parameters,
            ProcessingContext context,
            CompletionResultSet result) {
          for (String symbol : BuiltInNamesProvider.GLOBALS) {
            result.addElement(LookupElementBuilder.create(symbol));
          }
        }
      });
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:22,代码来源:BuiltInSymbolCompletionContributor.java

示例9: extendForVariablesAndFunctions

import com.intellij.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
private void extendForVariablesAndFunctions() {
    extend(CompletionType.BASIC, referencePattern(XQueryTypes.NCNAME).withReferenceOfAnyOfTypes
                    (XQueryFunctionReference.class),
            new CompletionProvider<CompletionParameters>() {
                @Override
                protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context,
                                              @NotNull CompletionResultSet result) {
                    XQueryFile originalFile = (XQueryFile) parameters.getOriginalFile();
                    VariableCollector variableCollector = new VariableCollector(parameters
                            .getPosition());

                    result.addAllElements(FunctionCollector.getLookUpItems(originalFile));
                    result.addAllElements(variableCollector.getProposedLookUpItems());
                }
            });
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:17,代码来源:XQueryCompletionContributor.java

示例10: addCompletions

import com.intellij.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
                              ProcessingContext context,
                              @NotNull CompletionResultSet result) {
    for (CompletionProvider<CompletionParameters> provider : providers) {
        provider.addCompletionVariants(parameters, context, result);
    }
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:9,代码来源:CompositeCompletionProvider.java

示例11: extendWithVariableNamesInScope

import com.intellij.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
/**
 * Complete variable names that are in lang when in an expression.
 */
private void extendWithVariableNamesInScope() {
  extend(
      CompletionType.BASIC,
      psiElement().andOr(
          psiElement().inside(SoyExpr.class),
          psiElement().inside(SoyBeginIf.class),
          psiElement().inside(SoyBeginElseIf.class),
          psiElement().inside(SoyBeginFor.class),
          psiElement().inside(SoyBeginForeach.class),
          psiElement().inside(SoyPrintStatement.class),
          psiElement().inside(SoyBeginParamTag.class).and(
              psiElement().afterLeafSkipping(psiElement(PsiWhiteSpace.class),
                  psiElement(SoyTypes.COLON)))
      ),
      new CompletionProvider<CompletionParameters>() {
        @Override
        protected void addCompletions(
            @NotNull CompletionParameters completionParameters,
            ProcessingContext processingContext,
            @NotNull CompletionResultSet completionResultSet) {
          Collection<Variable> params =
              Scope.getScopeOrEmpty(completionParameters.getPosition()).getVariables();
          completionResultSet.addAllElements(
              params
                  .stream()
                  .map(param -> "$" + param.name)
                  .map(LookupElementBuilder::create)
                  .collect(Collectors.toList()));
        }
      });
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:35,代码来源:SoyCompletionContributor.java

示例12: extendWithIdentifierFragmentsForAlias

import com.intellij.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
/**
 * Complete fully qualified namespace fragments for alias declaration.
 */
private void extendWithIdentifierFragmentsForAlias() {
  extend(
      CompletionType.BASIC,
      psiElement().inside(SoyAliasBlock.class),
      new CompletionProvider<CompletionParameters>() {
        @Override
        protected void addCompletions(
            @NotNull CompletionParameters completionParameters,
            ProcessingContext processingContext,
            @NotNull CompletionResultSet completionResultSet) {
          PsiElement identifierElement =
              PsiTreeUtil.getParentOfType(
                  completionParameters.getPosition(), SoyNamespaceIdentifier.class);
          String identifier = identifierElement == null ? "" : identifierElement.getText();

          String prefix = identifier.replaceFirst("IntellijIdeaRulezzz", "");
          Collection<TemplateNameUtils.Fragment> completions =
              TemplateNameUtils.getTemplateNamespaceFragments(
                  completionParameters.getPosition().getProject(), prefix);

          completionResultSet.addAllElements(
              completions
                  .stream()
                  .map(
                      (fragment) ->
                          LookupElementBuilder.create(fragment.text)
                              .withTypeText(
                                  fragment.isFinalFragment ? "Namespace" : "Partial namespace"))
                  .collect(Collectors.toList()));
        }
      });
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:36,代码来源:SoyCompletionContributor.java

示例13: CloudSlangCompletionContributor

import com.intellij.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public CloudSlangCompletionContributor() {
    extend(CompletionType.BASIC,
            PlatformPatterns.psiElement().withLanguage(YAMLLanguage.INSTANCE),
            new CompletionProvider<CompletionParameters>() {
                public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) {
                    addSlangKeywords(resultSet);
                    addYamlKeywordsUsedByCloudSlang(resultSet);
                }
            }
    );
}
 
开发者ID:CloudSlang,项目名称:cs-intellij-plugin,代码行数:12,代码来源:CloudSlangCompletionContributor.java

示例14: ArgumentCompletionContributor

import com.intellij.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public ArgumentCompletionContributor() {
  extend(
      CompletionType.BASIC,
      psiElement()
          .withLanguage(BuildFileLanguage.INSTANCE)
          .withElementType(BuildToken.fromKind(TokenKind.IDENTIFIER))
          .withParents(ReferenceExpression.class, Argument.Positional.class)
          .andNot(psiComment())
          .andNot(psiElement().afterLeaf("="))
          .andNot(psiElement().afterLeaf(psiElement(BuildToken.fromKind(TokenKind.IDENTIFIER)))),
      new CompletionProvider<CompletionParameters>() {
        @Override
        protected void addCompletions(
            CompletionParameters parameters,
            ProcessingContext context,
            CompletionResultSet result) {
          Argument.Positional arg =
              PsiTreeUtil.getParentOfType(parameters.getPosition(), Argument.Positional.class);
          if (arg != null) {
            Object[] lookups = arg.getReference().getVariants();
            for (Object lookup : lookups) {
              if (lookup instanceof LookupElement) {
                result.addElement((LookupElement) lookup);
              }
            }
          }
        }
      });
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:30,代码来源:ArgumentCompletionContributor.java

示例15: BuiltInFunctionCompletionContributor

import com.intellij.codeInsight.completion.CompletionProvider; //导入依赖的package包/类
public BuiltInFunctionCompletionContributor() {
  extend(
      CompletionType.BASIC,
      psiElement()
          .withLanguage(BuildFileLanguage.INSTANCE)
          .andNot(psiComment())
          .andOr(
              // Handles only top-level rules, and rules inside a function statement.
              // There are several other possibilities (e.g. inside top-level list comprehension),
              // but leaving out less common cases to avoid cluttering the autocomplete
              // suggestions when it's not valid to enter a rule.
              psiElement()
                  .withParents(
                      ReferenceExpression.class,
                      BuildFile.class), // leaf node => BuildReference => BuildFile
              psiElement()
                  .inside(
                      psiElement(StatementList.class).inside(psiElement(FunctionStatement.class)))
                  .afterLeaf(
                      psiElement().withText(".").afterLeaf(psiElement().withText("native")))),
      new CompletionProvider<CompletionParameters>() {
        @Override
        protected void addCompletions(
            CompletionParameters parameters,
            ProcessingContext context,
            CompletionResultSet result) {
          ImmutableSet<String> builtInNames =
              BuiltInNamesProvider.getBuiltInFunctionNames(parameters.getPosition().getProject());
          for (String ruleName : builtInNames) {
            result.addElement(
                LookupElementBuilder.create(ruleName)
                    .withIcon(BlazeIcons.BuildRule)
                    .withInsertHandler(ParenthesesInsertHandler.getInstance(true)));
          }
        }
      });
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:38,代码来源:BuiltInFunctionCompletionContributor.java


注:本文中的com.intellij.codeInsight.completion.CompletionProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。