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


Java LookupElementBuilder.create方法代码示例

本文整理汇总了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;
}
 
开发者ID:1tontech,项目名称:intellij-spring-assistant,代码行数:20,代码来源:Suggestion.java

示例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);
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:23,代码来源:AppleScriptReferenceElementImpl.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ActionOrGroupResolveConverter.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:WordCompletionContributor.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:AndroidAddStringResourceAction.java

示例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();
    }
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:14,代码来源:UrlCompletionContributor.java

示例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));
    }
}
 
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:12,代码来源:BaseEnvCompletionProvider.java

示例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;
}
 
开发者ID:xylo,项目名称:intellij-postfix-templates,代码行数:11,代码来源:SuggestShortVariableNameMacro.java

示例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;
}
 
开发者ID:zalando,项目名称:intellij-swagger,代码行数:10,代码来源:FieldCompletion.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:GroovyMapCompletionUtil.java

示例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));
    }
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:40,代码来源:CamelSmartCompletionEndpointValue.java

示例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));
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:16,代码来源:CamelSmartCompletionEndpointValue.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ChainCompletionLookupElementUtil.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ParameterNameExpression.java


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