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


Java LookupElementBuilder类代码示例

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


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

示例1: addCompletions

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
    PsiElement caller = parameters.getPosition().getPrevSibling().getPrevSibling();
    String ns = TSUtil.getElementNamespace(caller);

    //All global functions
    Project project = parameters.getOriginalFile().getProject();
    Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project);
    for (TSFnDeclStmt function : functions) {
        if (function.getFunctionType() == TSFunctionType.GLOBAL)
            continue;

        result.addElement(
                LookupElementBuilder.create(function.getFunctionName())
                        .withCaseSensitivity(false)
                        .withPresentableText(function.getNamespace() + "." + function.getFunctionName())
                        .withBoldness(ns != null && function.getNamespace().equalsIgnoreCase(ns))
                        .withTailText(function.getArgList())
                        .withInsertHandler(TSCaseCorrectingInsertHandler.INSTANCE)
        );
    }
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:23,代码来源:TSMethodCallCompletionContributor.java

示例2: extendWithTemplateDefinitionLevelKeywords

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入依赖的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

示例3: buildLookup

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入依赖的package包/类
@NotNull
private LookupElementBuilder buildLookup(PhpClassMember field, PhpExpression position, boolean autoValue) {
    String lookupString = field instanceof Method ? ClassUtils.getAsPropertyName((Method) field) : field.getName();
    LookupElementBuilder builder = LookupElementBuilder.create(field, lookupString).withIcon(field.getIcon());
    if (autoValue) {
        builder = builder.withInsertHandler((insertionContext, lookupElement) -> {

            Document document = insertionContext.getDocument();
            int insertPosition = insertionContext.getSelectionEndOffset();

            if (position.getParent().getParent() instanceof ArrayCreationExpression) {
                document.insertString(insertPosition + 1, " => ");
                insertPosition += 5;
                insertionContext.getEditor().getCaretModel().getCurrentCaret().moveToOffset(insertPosition);
            }
        });
    }
    if (field instanceof Field) {
        builder = builder.withTypeText(field.getType().toString());
    }
    return builder;
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:23,代码来源:ValidationCompletionProvider.java

示例4: buildLookup

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入依赖的package包/类
@NotNull
private LookupElementBuilder buildLookup(PhpClassMember field, PhpExpression position) {
    String lookupString = field instanceof Method ? ClassUtils.getAsPropertyName((Method) field) : field.getName();
    LookupElementBuilder builder =  LookupElementBuilder.create(field, lookupString).withIcon(field.getIcon())
            .withInsertHandler((insertionContext, lookupElement) -> {

                Document document = insertionContext.getDocument();
                int insertPosition = insertionContext.getSelectionEndOffset();

                if (position.getParent().getParent() instanceof ArrayCreationExpression) {
                    document.insertString(insertPosition + 1, " => ");
                    insertPosition += 5;
                    insertionContext.getEditor().getCaretModel().getCurrentCaret().moveToOffset(insertPosition);
                }
            });
    if (field instanceof Field) {
        builder = builder.withTypeText(field.getType().toString());
    }
    return builder;
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:21,代码来源:FieldAttributesCompletionProvider.java

示例5: getLookupItemsTables

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入依赖的package包/类
public static ArrayList<LookupElementBuilder> getLookupItemsTables(Project project, PhpExpression position) {
    DbPsiFacade facade = DbPsiFacade.getInstance(project);
    List<DbDataSource> dataSources = facade.getDataSources();

    // Code to test tests :)
    //dataSources.clear();
    //dataSources.add(new TestDataSource(project));

    ArrayList<LookupElementBuilder> list = new ArrayList<>();
    for (DbDataSource source : dataSources) {
        JBIterable<DasTable> filtered = source.getModel().traverser().filter(DasTable.class);
         for (Object item : filtered) {
            if (item instanceof DasTable) {
                list.add(DatabaseUtils.buildLookup(item, true, project));
            }
        }
    }
    return list;
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:20,代码来源:DatabaseUtils.java

示例6: newLookupElement

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入依赖的package包/类
public LookupElementBuilder newLookupElement(ClassLoader classLoader) {
  LookupElementBuilder builder = LookupElementBuilder.create(this, suggestion);
  if (referringToValue) {
    if (description != null) {
      builder = builder.withTypeText(description, true);
    }
    if (representingDefaultValue) {
      builder = builder.bold();
    }
    if (yaml) {
      builder = builder.withInsertHandler(new YamlValueInsertHandler());
    }
  } else {
    builder = builder.withRenderer(CUSTOM_SUGGESTION_RENDERER).withInsertHandler(yaml ?
        new YamlKeyInsertHandler(ref, classLoader) :
        new YamlKeyInsertHandler(ref, classLoader));
  }
  return builder;
}
 
开发者ID:1tontech,项目名称:intellij-spring-assistant,代码行数:20,代码来源:Suggestion.java

示例7: addCompletions

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
    List<TSVarExpr> variables = new ArrayList<>();
    for (PsiElement current = parameters.getPosition().getPrevSibling(); current != null; current = current.getPrevSibling()) {
        if (current.getNode().getElementType().equals(TSTypes.FUNCTION))
            break;

        if (current.getNode().getElementType().equals(TSTypes.LOCALVAR)) {
            String prefixless = current.getText().substring(1);
            result.addElement(
                    LookupElementBuilder.create(prefixless)
                    .withPresentableText(current.getText())
                    .withCaseSensitivity(false)
            );
        }
    }
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:18,代码来源:TSLocalVariableCompletionContributor.java

示例8: addCompletions

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
    String namespace = parameters.getPosition().getPrevSibling().getPrevSibling().getText();

    Project project = parameters.getOriginalFile().getProject();
    Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project);

    for (TSFnDeclStmt function : functions) {
        if (function.getFunctionType() == TSFunctionType.GLOBAL)
            continue;
        if (namespace != null && !function.getNamespace().equalsIgnoreCase(namespace))
            continue;

        result.addElement(
                LookupElementBuilder.create(function.getFunctionName())
                        .withCaseSensitivity(false)
                        .withPresentableText(function.getNamespace() + "::" + function.getFunctionName())
                        .withTailText(function.getArgList())
                        .withInsertHandler(TSCaseCorrectingInsertHandler.INSTANCE)
        );
    }
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:23,代码来源:TSGlobalNSCallCompletionContributor.java

示例9: addCompletions

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
    //All global functions
    Project project = parameters.getOriginalFile().getProject();
    Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project);
    for (TSFnDeclStmt function : functions) {
        if (function.getFunctionType() != TSFunctionType.GLOBAL)
            continue;

        result.addElement(
                LookupElementBuilder.create(function)
                        .withCaseSensitivity(false)
                        .withTailText(function.getArgList())
                        .withInsertHandler(TSCaseCorrectingInsertHandler.INSTANCE)
        );
    }
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:18,代码来源:TSGlobalCallCompletionContributor.java

示例10: getVariants

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入依赖的package包/类
@NotNull
@Override
public Object[] getVariants() {
    Project project = myElement.getProject();
    Collection<TSVarExpr> globals = TSUtil.getGlobalList(project);
    List<LookupElement> variants = new ArrayList<>();

    for (final TSVarExpr global : globals) {
        if (global.getName() != null && global.getName().length() > 0) {
            variants.add(LookupElementBuilder.create(global)
                    .withIcon(TSIcons.FILE)
                    .withTypeText(global.getContainingFile().getName())
                    .withCaseSensitivity(false)

            );
        }
    }

    return variants.toArray();
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:21,代码来源:TSGlobalVariableReference.java

示例11: getVariants

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入依赖的package包/类
@NotNull
@Override
public Object[] getVariants() {
    Project project = myElement.getProject();
    Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project);
    List<LookupElement> variants = new ArrayList<>();

    for (final TSFnDeclStmt function : functions) {
        if (function.getFunctionName() != null && function.getFunctionName().length() > 0) {
            variants.add(LookupElementBuilder.create(function)
                    .withIcon(TSIcons.FILE)
                    .withTypeText(function.getContainingFile().getName())
                    .withCaseSensitivity(false)

            );
        }
    }

    return variants.toArray();
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:21,代码来源:TSFunctionCallReference.java

示例12: getVariants

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入依赖的package包/类
@NotNull
@Override
public Object[] getVariants() {
    Project project = myElement.getProject();
    Collection<TSObjectExpr> globals = TSUtil.getObjectList(project);
    List<LookupElement> variants = new ArrayList<>();

    for (final TSObjectExpr global : globals) {
        if (global.getName() != null && global.getName().length() > 0) {
            variants.add(LookupElementBuilder.create(global)
                    .withIcon(TSIcons.FILE)
                    .withTypeText(global.getContainingFile().getName())
                    .withCaseSensitivity(false)

            );
        }
    }

    return variants.toArray();
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:21,代码来源:TSLiteralReference.java

示例13: KeywordCompletionContributor

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入依赖的package包/类
public KeywordCompletionContributor() {

    extend(CompletionType.BASIC, psiElement().inFile(StandardPatterns.instanceOf(AppleScriptFile.class)),
        new CompletionProvider<CompletionParameters>() {
          @Override
          protected void addCompletions(@NotNull CompletionParameters completionParameters,
                                        ProcessingContext processingContext,
                                        @NotNull CompletionResultSet completionResultSet) {
            PsiFile file = completionParameters.getOriginalFile();
            if (!(file instanceof AppleScriptFile)) return;
            PsiElement position = completionParameters.getPosition();
            if (position instanceof PsiComment) return;

            ASTNode node = position.getNode();
            if (node.getElementType() == AppleScriptTypes.STRING_LITERAL) return;

            for (IElementType kwElem : AppleScriptTokenTypesSets.KEYWORDS.getTypes()) {
              completionResultSet.addElement(LookupElementBuilder
                  .create(kwElem.toString().toLowerCase().replaceAll("_", " ")).bold()
                  .withTypeText("keyword", true));
            }
          }
        });
  }
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:25,代码来源:KeywordCompletionContributor.java

示例14: addLookupElement

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入依赖的package包/类
private void addLookupElement(List<LookupElement> lookupElements, PsiElement el) {
  if (!el.isValid()) return;
  LookupElementBuilder builder;
  if (el instanceof DictionaryComponent) {
    DictionaryComponent dc = (DictionaryComponent) el;
    String dName = dc.getDictionary().getName();
    builder = LookupElementBuilder.createWithIcon(dc).appendTailText("   " + dName, true);
  } else if (el instanceof AppleScriptComponent) {
    builder = LookupElementBuilder.createWithIcon((AppleScriptComponent) el);
    if (el instanceof AppleScriptHandlerPositionalParametersDefinition) {
      AppleScriptHandlerPositionalParametersDefinition handlerCall = (AppleScriptHandlerPositionalParametersDefinition) el;
      builder = builder.withInsertHandler(handlerCall.getFormalParameterList() != null ?
          ParenthesesInsertHandler.WITH_PARAMETERS : ParenthesesInsertHandler.NO_PARAMETERS);
    }
  } else {
    builder = LookupElementBuilder.create(el);
  }
  AppleScriptComponentType componentType = AppleScriptComponentType.typeOf(el);
  String typeText = componentType != null ? componentType.toString().toLowerCase() : null;
  builder = builder.withTypeText(typeText, null, true);
  lookupElements.add(builder);
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:23,代码来源:AppleScriptReferenceElementImpl.java

示例15: complete

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入依赖的package包/类
static void complete(Project project, PsiModuleName name, @NotNull CompletionResultSet resultSet) {
    // Get the correct module
    Collection<PsiModule> modules = StubIndex.getElements(IndexKeys.MODULES, name.getName(), project, GlobalSearchScope.allScope(project), PsiModule.class);

    if (!modules.isEmpty()) {
        for (PsiModule module : modules) {
            Collection<PsiNamedElement> expressions = module.getExpressions();

            for (PsiNamedElement expression : expressions) {
                resultSet.addElement(
                        LookupElementBuilder.create(expression).
                                withIcon(PsiIconUtil.getProvidersIcon(expression, 0)).
                                withTypeText(PsiInferredTypeUtil.getTypeInfo(expression))
                );
            }
        }
    }
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:19,代码来源:ModuleDotCompletionProvider.java


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