本文整理汇总了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\""));
}
}
});
}
示例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);
}
});
}
示例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);
}
}));
}
}
}
});
}
示例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()));
}
}
});
}
示例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()));
}
}
});
}
示例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);
}
});
}
示例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));
}
}
});
}
示例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());
}
});
}
示例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);
}
}
示例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()));
}
});
}
示例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()));
}
});
}
示例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);
}
}
);
}
示例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);
}
}
}
}
});
}
示例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)));
}
}
});
}