本文整理匯總了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));
}