本文整理汇总了Java中com.intellij.codeInsight.lookup.LookupElementBuilder.create方法的典型用法代码示例。如果您正苦于以下问题:Java LookupElementBuilder.create方法的具体用法?Java LookupElementBuilder.create怎么用?Java LookupElementBuilder.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.lookup.LookupElementBuilder
的用法示例。
在下文中一共展示了LookupElementBuilder.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: createLookupElement
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
@Nullable
@Override
public LookupElement createLookupElement(ActionOrGroup actionOrGroup) {
if (actionOrGroup instanceof Action) {
Action action = (Action)actionOrGroup;
final PsiElement element = getPsiElement(actionOrGroup);
if (element == null) {
throw new IllegalStateException(action.getId().getStringValue() + " in " + DomUtil.getFile(action) + " " + action.isValid() + " ");
}
LookupElementBuilder builder =
LookupElementBuilder.create(ObjectUtils.assertNotNull(element),
ObjectUtils.assertNotNull(getName(action)));
final String text = action.getText().getStringValue();
if (StringUtil.isNotEmpty(text)) {
String withoutMnemonic = StringUtil.replace(text, "_", "");
builder = builder.withTailText(" \"" + withoutMnemonic + "\"", true);
}
return builder;
}
return super.createLookupElement(actionOrGroup);
}
示例4: addWordCompletionVariants
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
public static void addWordCompletionVariants(CompletionResultSet result, final CompletionParameters parameters, Set<String> excludes) {
final Set<String> realExcludes = new HashSet<String>(excludes);
for (String exclude : excludes) {
String[] words = exclude.split("[ \\.-]");
if (words.length > 0 && StringUtil.isNotEmpty(words[0])) {
realExcludes.add(words[0]);
}
}
int startOffset = parameters.getOffset();
final PsiElement position = parameters.getPosition();
final CompletionResultSet javaResultSet = result.withPrefixMatcher(CompletionUtil.findJavaIdentifierPrefix(parameters));
final CompletionResultSet plainResultSet = result.withPrefixMatcher(CompletionUtil.findAlphanumericPrefix(parameters));
for (final String word : getAllWords(position, startOffset)) {
if (!realExcludes.contains(word)) {
final LookupElement item = LookupElementBuilder.create(word);
javaResultSet.addElement(item);
plainResultSet.addElement(item);
}
}
addValuesFromOtherStringLiterals(result, parameters, realExcludes, position);
}
示例5: calculateLookupItems
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
@Override
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) {
final PsiElement[] vars = getVariables(params, context);
if (vars == null || vars.length == 0) {
return null;
}
final Set<LookupElement> set = new LinkedHashSet<LookupElement>();
for (PsiElement var : vars) {
JavaTemplateUtil.addElementLookupItem(set, var);
}
LookupElement[] elements = set.toArray(new LookupElement[set.size()]);
if (elements.length == 0) {
return elements;
}
LookupElement lookupElementForDefValue = LookupElementBuilder.create(myDefaultValue);
LookupElement[] result = new LookupElement[elements.length + 1];
result[0] = lookupElementForDefValue;
System.arraycopy(elements, 0, result, 1, elements.length);
return result;
}
示例6: buildUrlCompletionList
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
private void buildUrlCompletionList(@NotNull CompletionResultSet completionResultSet, PsiElement position) {
HashMap<String, Method> routes = UrlUtils.getRoutes(position.getProject());
Iterator it = routes.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next();
Method method = (Method) pair.getValue();
LookupElementBuilder builder = LookupElementBuilder.create(pair.getValue(), pair.getKey().toString());
builder = builder.withTypeText(method.getContainingClass().getFQN(), true);
completionResultSet.addElement(builder);
it.remove();
}
}
示例7: fillCompletionResultSet
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
protected void fillCompletionResultSet(@NotNull CompletionResultSet completionResultSet, @NotNull Project project) {
for(Map.Entry<String, String> entry : EnvironmentVariablesApi.getAllKeyValues(project).entrySet()) {
LookupElementBuilder lockup = LookupElementBuilder.create(entry.getKey());
if(StringUtils.isNotEmpty(entry.getValue())) {
lockup = lockup.withTailText(" = " + entry.getValue(), true);
}
completionResultSet.addElement(PrioritizedLookupElement.withPriority(lockup, 100));
}
}
示例8: calculateLookupItems
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
@Override
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, final ExpressionContext context) {
String[] names = getNames(context);
if (names == null || names.length < 2) return null;
LookupElement[] items = new LookupElement[names.length];
for(int i = 0; i < names.length; i++) {
items[i] = LookupElementBuilder.create(names[i]);
}
return items;
}
示例9: create
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
private LookupElementBuilder create(final Field field) {
LookupElementBuilder lookupElementBuilder = LookupElementBuilder.create(field, field.getName());
if (field.isRequired()) {
lookupElementBuilder = lookupElementBuilder.bold();
}
return lookupElementBuilder;
}
示例10: addKeyVariants
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
public static void addKeyVariants(@NotNull GroovyMapContentProvider contentProvider, @NotNull GrExpression qualifier, @Nullable PsiElement resolve, @NotNull CompletionResultSet result) {
for (String key : contentProvider.getKeyVariants(qualifier, resolve)) {
LookupElement lookup = LookupElementBuilder.create(key);
lookup = PrioritizedLookupElement.withPriority(lookup, 1);
result.addElement(lookup);
}
}
示例11: addBooleanSuggestions
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
private static void addBooleanSuggestions(Editor editor, String val, String suffix, List<LookupElement> answer,
String deprecated, String defaultValue, boolean xmlMode) {
// for boolean types then give a choice between true|false
String lookup = val + "true";
LookupElementBuilder builder = LookupElementBuilder.create(lookup);
builder = addInsertHandler(editor, suffix, builder, xmlMode);
// only show the option in the UI
builder = builder.withPresentableText("true");
if ("true".equals(deprecated)) {
// mark as deprecated
builder = builder.withStrikeoutness(true);
}
boolean isDefaultValue = defaultValue != null && "true".equals(defaultValue);
if (isDefaultValue) {
builder = builder.withTailText(" (default value)");
// add default value first in the list
answer.add(0, builder.withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE));
} else {
answer.add(builder.withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE));
}
lookup = val + "false";
builder = LookupElementBuilder.create(lookup);
builder = addInsertHandler(editor, suffix, builder, xmlMode);
// only show the option in the UI
builder = builder.withPresentableText("false");
if ("true".equals(deprecated)) {
// mark as deprecated
builder = builder.withStrikeoutness(true);
}
isDefaultValue = defaultValue != null && "false".equals(defaultValue);
if (isDefaultValue) {
builder = builder.withTailText(" (default value)");
// add default value first in the list
answer.add(0, builder.withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE));
} else {
answer.add(builder.withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE));
}
}
示例12: addDefaultValueSuggestions
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
private static void addDefaultValueSuggestions(Editor editor, String val, String suffix, List<LookupElement> answer,
String deprecated, String defaultValue, boolean xmlMode) {
String lookup = val + defaultValue;
LookupElementBuilder builder = LookupElementBuilder.create(lookup);
builder = addInsertHandler(editor, suffix, builder, xmlMode);
// only show the option in the UI
builder = builder.withPresentableText(defaultValue);
if ("true".equals(deprecated)) {
// mark as deprecated
builder = builder.withStrikeoutness(true);
}
builder = builder.withTailText(" (default value)");
// there is only one value in the list and its the default value, so never auto complete it but show as suggestion
answer.add(0, builder.withAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE));
}
示例13: createLookupElement
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
@Nullable
@Override
public LookupElement createLookupElement(String s) {
LookupElementBuilder res = LookupElementBuilder.create(s);
res = res.withInsertHandler(MavenGroupIdInsertHandler.INSTANCE);
return res;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:MavenArtifactCoordinatesGroupIdConverter.java
示例14: createLookupElement
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
public static LookupElement createLookupElement(final PsiMethod method,
final @Nullable TIntObjectHashMap<SubLookupElement> replaceElements) {
if (method.isConstructor()) {
//noinspection ConstantConditions
return LookupElementBuilder.create(String.format("%s %s", PsiKeyword.NEW, method.getContainingClass().getName()));
} else if (method.hasModifierProperty(PsiModifier.STATIC)) {
return new ChainCompletionMethodCallLookupElement(method, replaceElements, false, true);
} else {
return new ChainCompletionMethodCallLookupElement(method, replaceElements);
}
}
示例15: calculateLookupItems
import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
@Override
public LookupElement[] calculateLookupItems(ExpressionContext context) {
SuggestedNameInfo info = getNameInfo(context);
if (info == null) return null;
LookupElement[] result = new LookupElement[info.names.length];
int i = 0;
for (String name : info.names) {
result[i++] = LookupElementBuilder.create(name);
}
return result;
}