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