本文整理汇总了Java中com.intellij.codeInsight.template.impl.JavaTemplateUtil类的典型用法代码示例。如果您正苦于以下问题:Java JavaTemplateUtil类的具体用法?Java JavaTemplateUtil怎么用?Java JavaTemplateUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JavaTemplateUtil类属于com.intellij.codeInsight.template.impl包,在下文中一共展示了JavaTemplateUtil类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateLookupItems
import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) {
if (params.length == 0) return LookupElement.EMPTY_ARRAY;
Result paramResult = params[0].calculateQuickResult(context);
if (paramResult instanceof PsiTypeResult) {
final PsiType type = ((PsiTypeResult)paramResult).getType();
final PsiFile file = PsiDocumentManager.getInstance(context.getProject()).getPsiFile(context.getEditor().getDocument());
final PsiElement element = file.findElementAt(context.getStartOffset());
final Set<LookupElement> set = new LinkedHashSet<LookupElement>();
JavaTemplateUtil.addTypeLookupItem(set, type);
CodeInsightUtil.processSubTypes(type, element, false, PrefixMatcher.ALWAYS_TRUE, new Consumer<PsiType>() {
@Override
public void consume(PsiType psiType) {
JavaTemplateUtil.addTypeLookupItem(set, psiType);
}
});
return set.toArray(new LookupElement[set.size()]);
}
return LookupElement.EMPTY_ARRAY;
}
示例2: calculateResult
import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public Result calculateResult(ExpressionContext context) {
final Project project = context.getProject();
PsiDocumentManager.getInstance(project).commitAllDocuments();
if (myItems.isEmpty()) return null;
final PsiType type = myItems.iterator().next().getType();
return type == null? null : new PsiTypeResult(type, project) {
@Override
public void handleRecalc(PsiFile psiFile, Document document, int segmentStart, int segmentEnd) {
if (myItems.size() <= 1) {
super.handleRecalc(psiFile, document, segmentStart, segmentEnd);
} else {
JavaTemplateUtil.updateTypeBindings(getType(), psiFile, document, segmentStart, segmentEnd, true);
}
}
@Override
public String toString() {
return myItems.size() == 1 ? super.toString() : type.getPresentableText();
}
};
}
示例3: calculateResult
import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public Result calculateResult(ExpressionContext context) {
final Project project = context.getProject();
PsiDocumentManager.getInstance(project).commitAllDocuments();
if (myItems.isEmpty()) return null;
final PsiType type = myItems.iterator().next().getType();
return type == null? null : new PsiTypeResult(type, project) {
@Override
public void handleRecalc(PsiFile psiFile, Document document, int segmentStart, int segmentEnd) {
if (myItems.size() <= 1) {
super.handleRecalc(psiFile, document, segmentStart, segmentEnd);
} else {
JavaTemplateUtil.updateTypeBindings(getType(), psiFile, document, segmentStart, segmentEnd, true);
}
}
@Override
public String toString() {
return myItems.size() == 1 ? type.getCanonicalText() : super.toString();
}
};
}
示例4: calculateLookupItems
import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, final ExpressionContext context) {
final PsiElement[] vars = getVariables(params, context);
if (vars == null || vars.length < 2) return null;
final Set<LookupElement> set = new LinkedHashSet<LookupElement>();
for (PsiElement var : vars) {
JavaTemplateUtil.addElementLookupItem(set, var);
}
return set.toArray(new LookupElement[set.size()]);
}
示例5: calculateLookupItems
import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, final ExpressionContext context) {
final PsiElement[] vars = getVariables(params, context);
if (vars == null || vars.length < 2) return null;
Set<LookupElement> set = new LinkedHashSet<LookupElement>();
for (PsiElement element : vars) {
JavaTemplateUtil.addElementLookupItem(set, element);
}
return set.toArray(new LookupElement[set.size()]);
}
示例6: calculateLookupItems
import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) {
PsiType[] types = guessTypes(params, context);
if (types == null || types.length < 2) return null;
Set<LookupElement> set = new LinkedHashSet<LookupElement>();
for (PsiType type : types) {
JavaTemplateUtil.addTypeLookupItem(set, type);
}
return set.toArray(new LookupElement[set.size()]);
}
示例7: calculateLookupItems
import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) {
PsiType[] types = getExpectedTypes(params, context);
if (types == null || types.length < 2) return null;
Set<LookupElement> set = new LinkedHashSet<LookupElement>();
for (PsiType type : types) {
JavaTemplateUtil.addTypeLookupItem(set, type);
}
return set.toArray(new LookupElement[set.size()]);
}
示例8: calculateResult
import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public Result calculateResult(ExpressionContext context) {
PsiDocumentManager.getInstance(context.getProject()).commitAllDocuments();
PsiType type = myTypePointer.getType();
if (type != null) {
if (myForGroovy && (type.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) || mySelectDef)) {
return new TextResult(GrModifier.DEF);
}
type = TypesUtil.unboxPrimitiveTypeWrapper(type);
if (type == null) return null;
final PsiType finalType = type;
return new PsiTypeResult(finalType, context.getProject()) {
@Override
public void handleRecalc(PsiFile psiFile, Document document, int segmentStart, int segmentEnd) {
if (myItems.size() <= 1) {
super.handleRecalc(psiFile, document, segmentStart, segmentEnd);
}
else {
JavaTemplateUtil.updateTypeBindings(getType(), psiFile, document, segmentStart, segmentEnd, true);
}
}
@Override
public String toString() {
return myItems.size() == 1 ? super.toString() : finalType.getPresentableText();
}
};
}
return null;
}
示例9: handleFocused
import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public void handleFocused(final PsiFile psiFile, final Document document, final int segmentStart, final int segmentEnd) {
JavaTemplateUtil.updateTypeBindings(getElement(), psiFile, document, segmentStart, segmentEnd);
}
示例10: handleFocused
import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public void handleFocused(final PsiFile psiFile, final Document document, final int segmentStart, final int segmentEnd) {
JavaTemplateUtil.updateTypeBindings(getType(), psiFile, document, segmentStart, segmentEnd);
}
示例11: handleRecalc
import com.intellij.codeInsight.template.impl.JavaTemplateUtil; //导入依赖的package包/类
@Override
public void handleRecalc(final PsiFile psiFile, final Document document, final int segmentStart, final int segmentEnd) {
JavaTemplateUtil.updateTypeBindings(getType(), psiFile, document, segmentStart, segmentEnd);
}