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


Java LookupElementBuilder.withTypeText方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: forMethod

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
public static LookupElementBuilder forMethod(@NotNull PsiMethod method,
                                             @NotNull String lookupString, final @NotNull PsiSubstitutor substitutor,
                                             @Nullable PsiClass qualifierClass) {
  LookupElementBuilder builder = LookupElementBuilder.create(method, lookupString)
    .withIcon(method.getIcon(Iconable.ICON_FLAG_VISIBILITY))
    .withPresentableText(method.getName())
    .withTailText(PsiFormatUtil.formatMethod(method, substitutor,
                                             PsiFormatUtilBase.SHOW_PARAMETERS,
                                             PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE));
  final PsiType returnType = method.getReturnType();
  if (returnType != null) {
    builder = builder.withTypeText(substitutor.substitute(returnType).getPresentableText());
  }
  builder = setBoldIfInClass(method, qualifierClass, builder);
  return builder;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JavaLookupElementBuilder.java

示例6: createLookupBuilder

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
public LookupElementBuilder createLookupBuilder(@NotNull final T item) {
  LookupElementBuilder builder = LookupElementBuilder.create(item, getLookupString(item))
    .withIcon(getIcon(item));

  final InsertHandler<LookupElement> handler = createInsertHandler(item);
  if (handler != null) {
    builder = builder.withInsertHandler(handler);
  }

  final String tailText = getTailText(item);
  if (tailText != null) {
    builder = builder.withTailText(tailText, true);
  }

  final String typeText = getTypeText(item);
  if (typeText != null) {
    builder = builder.withTypeText(typeText);
  }
  return builder;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:TextFieldWithAutoCompletionListProvider.java

示例7: setTypeText

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
private static LookupElementBuilder setTypeText(PsiElement element,
                                                LookupElementBuilder builder,
                                                PsiSubstitutor substitutor,
                                                @Nullable PsiElement position) {
  PsiType type = null;
  if (element instanceof GrVariable) {
    if (position != null && org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.isLocalVariable(element)) {
      type = TypeInferenceHelper.getInferredType(position, ((GrVariable)element).getName());
    }
    else {
      type = ((GrVariable)element).getTypeGroovy();
    }
  }
  else if (element instanceof PsiVariable) {
    type = ((PsiVariable)element).getType();
  }
  else if (element instanceof PsiMethod) {
    type = substitutor.substitute(((PsiMethod)element).getReturnType());
  }
  return type != null ? builder.withTypeText(type.getPresentableText()) : builder;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GroovyCompletionUtil.java

示例8: 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

示例9: createLookupElement

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
public static LookupElementBuilder createLookupElement(@NotNull XmlElementDescriptor descriptor) {
  LookupElementBuilder builder = LookupElementBuilder.create(descriptor.getName());
  if (descriptor instanceof XmlElementDescriptorImpl) {
    builder = builder.withTypeText(((XmlElementDescriptorImpl)descriptor).getNamespace(), true);
  }
  return builder;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:XmlSmartCompletionProvider.java

示例10: createLookupElement

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
public static LookupElement createLookupElement(XmlExtension.TagInfo tagInfo,
                                                final String tailText, @Nullable String namespacePrefix) {
  LookupElementBuilder builder =
    LookupElementBuilder.create(tagInfo, tagInfo.name).withInsertHandler(
      new ExtendedTagInsertHandler(tagInfo.name, tagInfo.namespace, namespacePrefix));
  if (!StringUtil.isEmpty(tailText)) {
    builder = builder.withTypeText(tailText, true);
  }
  return builder;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:XmlCompletionContributor.java

示例11: createPropertyLookupElement

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
@NotNull
public static LookupElementBuilder createPropertyLookupElement(@NotNull String name, @Nullable PsiType type) {
  LookupElementBuilder res = LookupElementBuilder.create(name).withIcon(JetgroovyIcons.Groovy.Property);
  if (type != null) {
    res = res.withTypeText(type.getPresentableText());
  }
  return res;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:CompleteReferenceExpression.java

示例12: buildLookup

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
@NotNull
public static LookupElementBuilder buildLookup(Object field, boolean showSchema, Project project) {
    String lookupString = "-";

    if (field instanceof DasObject) {
        lookupString = ((DasObject) field).getName();
        lookupString = RemoveTablePrefix(lookupString, project);
    }
    if (field instanceof Field) {
        lookupString = ((Field) field).getName();
    }
    LookupElementBuilder builder = LookupElementBuilder.create(field, lookupString);

    if (field instanceof Field) {
        builder = builder.withTypeText(((Field) field).getType().toString())
                .withIcon(((Field) field).getIcon());
    }
    if (field instanceof PhpDocProperty) {
        builder = builder.withTypeText(((PhpDocProperty) field).getType().toString())
                .withIcon(((PhpDocProperty) field).getIcon());
    }
    if (field instanceof DasColumn) {
        DasColumn column = (DasColumn) field;
        builder = builder.withTypeText(column.getDataType().typeName, true);
        if (column.getDbParent() != null && showSchema && column.getDbParent().getDbParent() != null) {
            builder = builder.withTailText(" (" + column.getDbParent().getDbParent().getName() + "." + RemoveTablePrefix(column.getDbParent().getName(), project) + ")", true);
        }
        if (column instanceof DasColumn)
            builder = builder.withIcon(TypePresentationService.getService().getIcon(field));
        if (column instanceof DbColumnImpl)
            builder = builder.withIcon(((DbColumnImpl) column).getIcon());
    }
    if (field instanceof DasTable) {
        DasTable table = (DasTable) field;
        DasObject tableSchema = table.getDbParent();
        if (tableSchema != null) {
            if (tableSchema instanceof DbNamespaceImpl) {
                Object dataSource = tableSchema.getDbParent();
               // DbDataSourceImpl dataSource = (DbDataSourceImpl) ((DbNamespaceImpl) tableSchema).getDbParent();
                if (dataSource != null && dataSource instanceof DbDataSourceImpl ) {
                    builder = builder.withTypeText(((DbDataSourceImpl)dataSource).getName(), true);
                }
                if (dataSource != null && dataSource instanceof DbDataSourceImpl ) {
                    builder = builder.withTypeText(((DbDataSourceImpl)dataSource).getName(), true);
                }
            }
        }
        if (showSchema && tableSchema != null) {
            builder = builder.withTailText(" (" + table.getDbParent().getName() + ")", true);
        }
        if (table instanceof DasTable)
            builder = builder.withIcon(TypePresentationService.getService().getIcon(table));
        if (table instanceof DbElement)
            builder = builder.withIcon(((DbElement) table).getIcon());

        builder = builder.withInsertHandler((insertionContext, lookupElement) -> {
            if (Yii2SupportSettings.getInstance(project).insertWithTablePrefix) {
                Document document = insertionContext.getDocument();
                int insertPosition = insertionContext.getSelectionEndOffset();
                document.insertString(insertPosition - lookupElement.getLookupString().length(), "{{%");
                document.insertString(insertPosition + 3, "}}");
                insertionContext.getEditor().getCaretModel().getCurrentCaret().moveToOffset(insertPosition + 5);
            }
        });
    }


    return builder;
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:70,代码来源:DatabaseUtils.java

示例13: addSmartCompletionContextPathEnumSuggestions

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

示例14: setupItem

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
protected LookupElementBuilder setupItem(LookupElementBuilder item) {
  final Object object = item.getObject();
  if (!myPlainNamesOnly) {
    if (!mySuppressParentheses &&
        object instanceof PyFunction && ((PyFunction)object).getProperty() == null &&
        !PyUtil.hasCustomDecorators((PyFunction)object) &&
        !isSingleArgDecoratorCall(myContext, (PyFunction)object)) {
      final Project project = ((PyFunction)object).getProject();
      item = item.withInsertHandler(PyFunctionInsertHandler.INSTANCE);
      final TypeEvalContext context = TypeEvalContext.codeCompletion(project, myContext != null ? myContext.getContainingFile() : null);
      final List<PyParameter> parameters = PyUtil.getParameters((PyFunction)object, context);
      final String params = StringUtil.join(parameters, new Function<PyParameter, String>() {
        @Override
        public String fun(PyParameter pyParameter) {
          return pyParameter.getName();
        }
      }, ", ");
      item = item.withTailText("(" + params + ")");
    }
    else if (object instanceof PyClass) {
      item = item.withInsertHandler(PyClassInsertHandler.INSTANCE);
    }
  }
  String source = null;
  if (object instanceof PsiElement) {
    final PsiElement element = (PsiElement)object;
    PyClass cls = null;

    if (element instanceof PyFunction) {
      cls = ((PyFunction)element).getContainingClass();
    }
    else if (element instanceof PyTargetExpression) {
      final PyTargetExpression expr = (PyTargetExpression)element;
      if (expr.isQualified() || ScopeUtil.getScopeOwner(expr) instanceof PyClass) {
        cls = expr.getContainingClass();
      }
    }
    else if (element instanceof PyClass) {
      final ScopeOwner owner = ScopeUtil.getScopeOwner(element);
      if (owner instanceof PyClass) {
        cls = (PyClass)owner;
      }
    }

    if (cls != null) {
      source = cls.getName();
    }
    else if (myContext == null || !PyUtil.inSameFile(myContext, element)) {
      QualifiedName path = QualifiedNameFinder.findCanonicalImportPath(element, null);
      if (path != null) {
        if (element instanceof PyFile) {
          path = path.removeLastComponent();
        }
        source = path.toString();
      }
    }
  }
  if (source != null) {
    item = item.withTypeText(source);
  }
  return item;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:63,代码来源:CompletionVariantsProcessor.java

示例15: setItemNotice

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
protected static LookupElementBuilder setItemNotice(final LookupElementBuilder item, String notice) {
  return item.withTypeText(notice);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:CompletionVariantsProcessor.java


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