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


Java LookupElementBuilder.putUserData方法代码示例

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


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

示例1: createGenerateMethodElement

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
private static LookupElementBuilder createGenerateMethodElement(PsiMethod prototype,
                                                                PsiSubstitutor substitutor,
                                                                Icon icon,
                                                                String typeText, InsertHandler<LookupElement> insertHandler) {
  String methodName = prototype.getName();

  String visibility = VisibilityUtil.getVisibilityModifier(prototype.getModifierList());
  String modifiers = (visibility == PsiModifier.PACKAGE_LOCAL ? "" : visibility + " ");

  PsiType type = substitutor.substitute(prototype.getReturnType());
  String signature = modifiers + (type == null ? "" : type.getPresentableText() + " ") + methodName;

  String parameters = PsiFormatUtil.formatMethod(prototype, substitutor, PsiFormatUtilBase.SHOW_PARAMETERS, PsiFormatUtilBase.SHOW_NAME);

  String overrideSignature = " @Override " + signature; // leading space to make it a middle match, under all annotation suggestions
  LookupElementBuilder element = LookupElementBuilder.create(prototype, signature).withLookupString(methodName).
    withLookupString(signature).withLookupString(overrideSignature).withInsertHandler(insertHandler).
    appendTailText(parameters, false).appendTailText(" {...}", true).withTypeText(typeText).withIcon(icon);
  element.putUserData(GENERATE_ELEMENT, true);
  return element;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:JavaGenerateMemberCompletionContributor.java

示例2: createParametersLookupElement

import com.intellij.codeInsight.lookup.LookupElementBuilder; //导入方法依赖的package包/类
private static LookupElement createParametersLookupElement(final PsiMethod takeParametersFrom, PsiElement call, PsiMethod invoked) {
  final PsiParameter[] parameters = takeParametersFrom.getParameterList().getParameters();
  final String lookupString = StringUtil.join(parameters, new Function<PsiParameter, String>() {
    @Override
    public String fun(PsiParameter psiParameter) {
      return psiParameter.getName();
    }
  }, ", ");

  final int w = PlatformIcons.PARAMETER_ICON.getIconWidth();
  LayeredIcon icon = new LayeredIcon(2);
  icon.setIcon(PlatformIcons.PARAMETER_ICON, 0, 2*w/5, 0);
  icon.setIcon(PlatformIcons.PARAMETER_ICON, 1);

  LookupElementBuilder element = LookupElementBuilder.create(lookupString).withIcon(icon);
  if (PsiTreeUtil.isAncestor(takeParametersFrom, call, true)) {
    element = element.withInsertHandler(new InsertHandler<LookupElement>() {
      @Override
      public void handleInsert(InsertionContext context, LookupElement item) {
        context.commitDocument();
        for (PsiParameter parameter : CompletionUtil.getOriginalOrSelf(takeParametersFrom).getParameterList().getParameters()) {
          VariableLookupItem.makeFinalIfNeeded(context, parameter);
        }
      }
    });
  }
  element.putUserData(JavaCompletionUtil.SUPER_METHOD_PARAMETERS, Boolean.TRUE);

  return TailTypeDecorator.withTail(element, ExpectedTypesProvider.getFinalCallParameterTailType(call, invoked.getReturnType(), invoked));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:SameSignatureCallParametersProvider.java


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