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


Java PrioritizedLookupElement类代码示例

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


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

示例1: getResult

import com.intellij.codeInsight.completion.PrioritizedLookupElement; //导入依赖的package包/类
/**
 * @return result lookup elements (to display in {@link PsiReference#getVariants()} for example)
 */
@NotNull
LookupElement[] getResult() {
  final List<LookupElement> result = new ArrayList<LookupElement>(myMap.size());
  for (final Entry<LookupElementBuilder, Pair<String, Integer>> entry : myMap.entrySet()) {
    LookupElementBuilder elementBuilder = entry.getKey();
    final Pair<String, Integer> helpAndPriority = entry.getValue();
    final String help = helpAndPriority.first;

    if (!StringUtil.isEmptyOrSpaces(help)) {
      final int padding = myMaxLength - elementBuilder.getLookupString().length();
      elementBuilder = elementBuilder.withTailText(String.format("%s : %s", StringUtil.repeat(" ", padding), help));
    }
    if (myHasPriority) {
      // If we have priority and it is not provided for certain element we believe it is 0
      final int priority = (helpAndPriority.second == null ? 0 : helpAndPriority.second);
      result.add(PrioritizedLookupElement.withPriority(elementBuilder, priority));
    }
    else {
      result.add(elementBuilder);
    }
  }
  return result.toArray(new LookupElement[result.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:LookupWithIndentsBuilder.java

示例2: getVariants

import com.intellij.codeInsight.completion.PrioritizedLookupElement; //导入依赖的package包/类
@NotNull
public Object[] getVariants() {
  final ASTNode categoryNode = getCategoryNode();
  if (categoryNode != null && categoryNode.getText().startsWith("In") && !categoryNode.getText().startsWith("Intelli")) {
    return UNICODE_BLOCKS;
  }
  else {
    boolean startsWithIs = categoryNode != null && categoryNode.getText().startsWith("Is");
    Collection<LookupElement> result = ContainerUtil.newArrayList();
    for (String[] properties : RegExpLanguageHosts.getInstance().getAllKnownProperties(getElement())) {
      String name = ArrayUtil.getFirstElement(properties);
      if (name != null) {
        String typeText = properties.length > 1 ? properties[1] : ("Character.is" + name.substring("java".length()) + "()");
        result.add(PrioritizedLookupElement.withPriority(LookupElementBuilder.create(name)
                                                           .withPresentableText(startsWithIs ? "Is" + name : name)
                                                           .withIcon(PlatformIcons.PROPERTY_ICON)
                                                           .withTypeText(typeText), getPriority(name)));
      }
    }
    return ArrayUtil.toObjectArray(result);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:RegExpPropertyImpl.java

示例3: getVariants

import com.intellij.codeInsight.completion.PrioritizedLookupElement; //导入依赖的package包/类
@NotNull
public Object[] getVariants() {
  final ProjectFileIndex projectFileIndex = ProjectFileIndex.SERVICE.getInstance(getElement().getProject());
  final PropertiesReferenceManager referenceManager = PropertiesReferenceManager.getInstance(getElement().getProject());

  final Set<String> bundleNames = new HashSet<String>();
  final List<LookupElement> variants = new SmartList<LookupElement>();
  PropertiesFileProcessor processor = new PropertiesFileProcessor() {
    @Override
    public boolean process(String baseName, PropertiesFile propertiesFile) {
      if (!bundleNames.add(baseName)) return true;

      final LookupElementBuilder builder =
        LookupElementBuilder.create(baseName)
          .withIcon(AllIcons.Nodes.ResourceBundle);
      boolean isInContent = projectFileIndex.isInContent(propertiesFile.getVirtualFile());
      variants.add(isInContent ? PrioritizedLookupElement.withPriority(builder, Double.MAX_VALUE) : builder);
      return true;
    }
  };

  referenceManager.processPropertiesFiles(myElement.getResolveScope(), processor, this);
  return variants.toArray(new LookupElement[variants.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ResourceBundleReference.java

示例4: getLookupElements

import com.intellij.codeInsight.completion.PrioritizedLookupElement; //导入依赖的package包/类
@NotNull
@Override
public Collection<LookupElement> getLookupElements() {

    final Collection<LookupElement> lookupElements = new ArrayList<>();

    ControllerCollector.visitController(getProject(), (method, name) ->
        namespaceCutter.cut(name, (processedClassName, prioritised) -> {
            LookupElement lookupElement = LookupElementBuilder.create(processedClassName)
                    .withIcon(LaravelIcons.ROUTE);

            if(prioritised) {
                lookupElement = PrioritizedLookupElement.withPriority(lookupElement, 10);
            }

            lookupElements.add(lookupElement);
        })
    );

    return lookupElements;
}
 
开发者ID:Haehnchen,项目名称:idea-php-laravel-plugin,代码行数:22,代码来源:ControllerReferences.java

示例5: addAllElementsWithPriority

import com.intellij.codeInsight.completion.PrioritizedLookupElement; //导入依赖的package包/类
private void addAllElementsWithPriority(@Nullable ArrayList<LookupElementBuilder> lookups, @NotNull CompletionResultSet completionResultSet, double priority, boolean bold) {
    if (lookups != null) {
        for (LookupElementBuilder element : lookups) {
            element = element.withBoldness(bold);
            completionResultSet.addElement(PrioritizedLookupElement.withPriority(element, priority));
        }
    }
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:9,代码来源:QueryCompletionProvider.java

示例6: createNamedParameterLookup

import com.intellij.codeInsight.completion.PrioritizedLookupElement; //导入依赖的package包/类
/**
 * Constructs new lookup element for completion of keyword argument with equals sign appended.
 *
 * @param name    name of the parameter
 * @param project project instance to check code style settings and surround equals sign with spaces if necessary
 * @return lookup element
 */
@NotNull
public static LookupElement createNamedParameterLookup(@NotNull String name, @Nullable Project project) {
  final String suffix;
  if (CodeStyleSettingsManager.getSettings(project).getCustomSettings(PyCodeStyleSettings.class).SPACE_AROUND_EQ_IN_KEYWORD_ARGUMENT) {
    suffix = " = ";
  }
  else {
    suffix = "=";
  }
  LookupElementBuilder lookupElementBuilder = LookupElementBuilder.create(name + suffix).withIcon(PlatformIcons.PARAMETER_ICON);
  lookupElementBuilder = lookupElementBuilder.withInsertHandler(OverwriteEqualsInsertHandler.INSTANCE);
  return PrioritizedLookupElement.withGrouping(lookupElementBuilder, 1);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PyUtil.java

示例7: UserColorLookup

import com.intellij.codeInsight.completion.PrioritizedLookupElement; //导入依赖的package包/类
public UserColorLookup(final Function<Color, String> colorToStringConverter, int priority) {
  super(PrioritizedLookupElement.withPriority(LookupElementBuilder.create(COLOR_STRING).withInsertHandler(
    new InsertHandler<LookupElement>() {
      @Override
      public void handleInsert(InsertionContext context, LookupElement item) {
        handleUserSelection(context, colorToStringConverter);
      }
    }), priority));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:UserColorLookup.java

示例8: createLookupElement

import com.intellij.codeInsight.completion.PrioritizedLookupElement; //导入依赖的package包/类
@Nullable
@Override
public LookupElement createLookupElement(String s) {
  AndroidVersion version = SdkVersionInfo.getVersion(s, null);
  if (version == null) {
    return null;
  }
  return PrioritizedLookupElement.withPriority(LookupElementBuilder.create(s).
    withTypeText(version.getApiString()), version.getFeatureLevel());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:ApiVersionConverter.java

示例9: addKeyVariants

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

示例10: UserColorLookup

import com.intellij.codeInsight.completion.PrioritizedLookupElement; //导入依赖的package包/类
public UserColorLookup(final Function<Color, String> colorToStringConverter) {
  super(PrioritizedLookupElement.withPriority(LookupElementBuilder.create(COLOR_STRING).withInsertHandler(
    new InsertHandler<LookupElement>() {
      @Override
      public void handleInsert(InsertionContext context, LookupElement item) {
        handleUserSelection(context, colorToStringConverter);
      }
    }), LookupValueWithPriority.HIGH));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:UserColorLookup.java

示例11: addKeyVariants

import com.intellij.codeInsight.completion.PrioritizedLookupElement; //导入依赖的package包/类
public void addKeyVariants(@NotNull GrExpression qualifier, @Nullable PsiElement resolve, @NotNull CompletionResultSet result) {
  for (String key : getKeyVariants(qualifier, resolve)) {
    LookupElement lookup = LookupElementBuilder.create(key);
    lookup = PrioritizedLookupElement.withPriority(lookup, 1);
    result.addElement(lookup);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:8,代码来源:GroovyMapContentProvider.java

示例12: UserColorLookup

import com.intellij.codeInsight.completion.PrioritizedLookupElement; //导入依赖的package包/类
public UserColorLookup() {
  super(PrioritizedLookupElement.withPriority(LookupElementBuilder.create(COLOR_STRING).withInsertHandler(
    new InsertHandler<LookupElement>() {
      @Override
      public void handleInsert(InsertionContext context, LookupElement item) {
        handleUserSelection(context);
      }
    }), LookupValueWithPriority.HIGH));
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:10,代码来源:UserColorLookup.java

示例13: lookupExpression

import com.intellij.codeInsight.completion.PrioritizedLookupElement; //导入依赖的package包/类
@NotNull
private static LookupElement lookupExpression(@NotNull PsiExpression expression, @Nullable Icon icon, @NotNull String presentableText, @NotNull String lookupText)
{
	final LookupElement element = new ExpressionLookupItem(expression, icon, presentableText, lookupText)
	{
		@Override
		public void handleInsert(InsertionContext context)
		{
			context.getDocument().deleteString(context.getStartOffset(), context.getTailOffset());
			context.commitDocument();
			replaceText(context, getObject().getText());
		}
	};
	return PrioritizedLookupElement.withPriority(element, 1);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:16,代码来源:JavaMethodHandleCompletionContributor.java

示例14: addSmartCompletionContextPathEnumSuggestions

import com.intellij.codeInsight.completion.PrioritizedLookupElement; //导入依赖的package包/类
private static List<LookupElement> addSmartCompletionContextPathEnumSuggestions(String val, ComponentModel component,
                                                                                Map<String, String> existing) {
    List<LookupElement> answer = new ArrayList<>();

    double priority = 100.0d;

    // lets help the suggestion list if we are editing the context-path and only have 1 enum type option
    // and the option has not been in use yet, then we can populate the list with the enum values.

    long enums = component.getEndpointOptions().stream().filter(o -> "path".equals(o.getKind()) && !o.getEnums().isEmpty()).count();
    if (enums == 1) {
        for (EndpointOptionModel option : component.getEndpointOptions()) {

            // only add support for enum in the context-path smart completion
            if ("path".equals(option.getKind()) && !option.getEnums().isEmpty()) {
                String name = option.getName();
                // only add if not already used
                String old = existing != null ? existing.get(name) : "";
                if (existing == null || old == null || old.isEmpty()) {

                    // add all enum as choices
                    for (String choice : option.getEnums().split(",")) {

                        String key = choice;
                        String lookup = val + key;

                        LookupElementBuilder builder = LookupElementBuilder.create(lookup);
                        // only show the option in the UI
                        builder = builder.withPresentableText(choice);
                        // lets use the option name as the type so its visible
                        builder = builder.withTypeText(name, true);
                        builder = builder.withIcon(AllIcons.Nodes.Enum);

                        if ("true".equals(option.getDeprecated())) {
                            // mark as deprecated
                            builder = builder.withStrikeoutness(true);
                        }

                        // its an enum so always auto complete the choices
                        LookupElement element = builder.withAutoCompletionPolicy(AutoCompletionPolicy.ALWAYS_AUTOCOMPLETE);

                        // they should be in the exact order
                        element = PrioritizedLookupElement.withPriority(element, priority);

                        priority -= 1.0d;

                        answer.add(element);
                    }
                }
            }
        }
    }

    return answer;
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:56,代码来源:CamelSmartCompletionEndpointOptions.java

示例15: TemplateExpressionLookupElement

import com.intellij.codeInsight.completion.PrioritizedLookupElement; //导入依赖的package包/类
public TemplateExpressionLookupElement(final TemplateState state, LookupElement element, int index) {
  super(PrioritizedLookupElement.withPriority(element, Integer.MAX_VALUE - 10 - index));
  myState = state;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:TemplateExpressionLookupElement.java


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