本文整理汇总了Java中com.intellij.psi.util.PsiFormatUtilBase类的典型用法代码示例。如果您正苦于以下问题:Java PsiFormatUtilBase类的具体用法?Java PsiFormatUtilBase怎么用?Java PsiFormatUtilBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PsiFormatUtilBase类属于com.intellij.psi.util包,在下文中一共展示了PsiFormatUtilBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: forMethod
import com.intellij.psi.util.PsiFormatUtilBase; //导入依赖的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;
}
示例2: generateVariableJavaDoc
import com.intellij.psi.util.PsiFormatUtilBase; //导入依赖的package包/类
private void generateVariableJavaDoc(@NonNls StringBuilder buffer, PsiVariable variable, boolean generatePrologueAndEpilogue) {
if (generatePrologueAndEpilogue)
generatePrologue(buffer);
buffer.append("<PRE>");
String modifiers = PsiFormatUtil.formatModifiers(variable, PsiFormatUtilBase.JAVADOC_MODIFIERS_ONLY);
if (!modifiers.isEmpty()) {
buffer.append(modifiers);
buffer.append(" ");
}
generateType(buffer, variable.getType(), variable);
buffer.append(" ");
buffer.append("<b>");
buffer.append(variable.getName());
appendInitializer(buffer, variable);
buffer.append("</b>");
buffer.append("</PRE>");
//buffer.append("<br>");
ColorUtil.appendColorPreview(variable, buffer);
if (generatePrologueAndEpilogue)
generateEpilogue(buffer);
}
示例3: formatMethodSignature
import com.intellij.psi.util.PsiFormatUtilBase; //导入依赖的package包/类
private static String formatMethodSignature(PsiMethod method, boolean raw, boolean java8Format) {
int options = PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS;
int parameterOptions = PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.SHOW_FQ_CLASS_NAMES;
if (raw) {
options |= PsiFormatUtilBase.SHOW_RAW_NON_TOP_TYPE;
parameterOptions |= PsiFormatUtilBase.SHOW_RAW_NON_TOP_TYPE;
}
String signature = PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY, options, parameterOptions, 999);
if (java8Format) {
signature = signature.replaceAll("\\(|\\)|, ", "-").replaceAll("\\[\\]", ":A");
}
return signature;
}
示例4: updateImpl
import com.intellij.psi.util.PsiFormatUtilBase; //导入依赖的package包/类
@Override
public void updateImpl(PresentationData data) {
String name = PsiFormatUtil.formatMethod(
(PsiMethod)getPsiElement(),
PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_TYPE |
PsiFormatUtilBase.TYPE_AFTER |
PsiFormatUtilBase.SHOW_PARAMETERS,
PsiFormatUtilBase.SHOW_TYPE
);
int c = name.indexOf('\n');
if (c > -1) {
name = name.substring(0, c - 1);
}
data.setPresentableText(name);
}
示例5: updateImpl
import com.intellij.psi.util.PsiFormatUtilBase; //导入依赖的package包/类
@Override
public void updateImpl(PresentationData data) {
String name = PsiFormatUtil.formatMethod(
getValue(),
PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME |
PsiFormatUtilBase.SHOW_TYPE |
PsiFormatUtilBase.TYPE_AFTER |
PsiFormatUtilBase.SHOW_PARAMETERS,
PsiFormatUtilBase.SHOW_TYPE
);
int c = name.indexOf('\n');
if (c > -1) {
name = name.substring(0, c - 1);
}
data.setPresentableText(name);
}
示例6: OverridingMethodsDialog
import com.intellij.psi.util.PsiFormatUtilBase; //导入依赖的package包/类
public OverridingMethodsDialog(Project project, List<UsageInfo> overridingMethods) {
super(project, true);
myOverridingMethods = overridingMethods;
myChecked = new boolean[myOverridingMethods.size()];
for (int i = 0; i < myChecked.length; i++) {
myChecked[i] = true;
}
myMethodText = new String[myOverridingMethods.size()];
for (int i = 0; i < myMethodText.length; i++) {
myMethodText[i] = PsiFormatUtil.formatMethod(
((SafeDeleteOverridingMethodUsageInfo) myOverridingMethods.get(i)).getOverridingMethod(),
PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_CONTAINING_CLASS
| PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS | PsiFormatUtilBase.SHOW_TYPE,
PsiFormatUtilBase.SHOW_TYPE
);
}
myUsagePreviewPanel = new UsagePreviewPanel(project, new UsageViewPresentation());
setTitle(RefactoringBundle.message("unused.overriding.methods.title"));
init();
}
示例7: getMethodCandidateInfo
import com.intellij.psi.util.PsiFormatUtilBase; //导入依赖的package包/类
private static String getMethodCandidateInfo(GrReferenceExpression expr) {
final GroovyResolveResult[] candidates = expr.multiResolve(false);
final String text = expr.getText();
if (candidates.length > 0) {
@NonNls final StringBuilder sb = new StringBuilder();
for (final GroovyResolveResult candidate : candidates) {
final PsiElement element = candidate.getElement();
if (!(element instanceof PsiMethod)) {
continue;
}
final String str = PsiFormatUtil
.formatMethod((PsiMethod)element, candidate.getSubstitutor(),
PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.SHOW_PARAMETERS,
PsiFormatUtilBase.SHOW_TYPE);
createElementLink(sb, element, str);
}
return CodeInsightBundle.message("javadoc.candidates", text, sb);
}
return CodeInsightBundle.message("javadoc.candidates.not.found", text);
}
示例8: generateVariableJavaDoc
import com.intellij.psi.util.PsiFormatUtilBase; //导入依赖的package包/类
private static void generateVariableJavaDoc(@NonNls StringBuilder buffer, PsiVariable variable, boolean generatePrologueAndEpilogue) {
if (generatePrologueAndEpilogue)
generatePrologue(buffer);
buffer.append("<PRE>");
String modifiers = PsiFormatUtil.formatModifiers(variable, PsiFormatUtilBase.JAVADOC_MODIFIERS_ONLY);
if (modifiers.length() > 0) {
buffer.append(modifiers);
buffer.append(" ");
}
generateType(buffer, variable.getType(), variable);
buffer.append(" ");
buffer.append("<b>");
buffer.append(variable.getName());
appendInitializer(buffer, variable);
buffer.append("</b>");
buffer.append("</PRE>");
//buffer.append("<br>");
ColorUtil.appendColorPreview(variable, buffer);
if (generatePrologueAndEpilogue)
generateEpilogue(buffer);
}
示例9: createGenerateMethodElement
import com.intellij.psi.util.PsiFormatUtilBase; //导入依赖的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);
LookupElementBuilder element = LookupElementBuilder.create(prototype, signature).withLookupString(methodName).
withLookupString(signature).withInsertHandler(insertHandler).
appendTailText(parameters, false).appendTailText(" {...}", true).withTypeText(typeText).withIcon(icon);
element.putUserData(GENERATE_ELEMENT, true);
return element;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:JavaGenerateMemberCompletionContributor.java
示例10: MethodList
import com.intellij.psi.util.PsiFormatUtilBase; //导入依赖的package包/类
public MethodList(PsiClass psiClass)
{
super(new BorderLayout());
model = new SortedListModel<PsiMethod>(comparator);
list = new JBList(model);
this.psiClass = psiClass;
evaluate(psiClass.getAllMethods(), new TestMethodFilter());
add(ScrollPaneFactory.createScrollPane(list));
list.setCellRenderer(new ColoredListCellRenderer() {
@Override
protected void customizeCellRenderer(JList jlist, Object obj, int i, boolean flag, boolean flag1)
{
PsiMethod psimethod = (PsiMethod)obj;
append(PsiFormatUtil.formatMethod(psimethod, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME, 0), StructureNodeRenderer.applyDeprecation(psimethod, SimpleTextAttributes.REGULAR_ATTRIBUTES));
PsiClass psiclass1 = psimethod.getContainingClass();
if(!MethodList.this.psiClass.equals(psiclass1)) {
append(" (" + psiclass1.getQualifiedName() + ')', StructureNodeRenderer.applyDeprecation(psiclass1, SimpleTextAttributes.GRAY_ATTRIBUTES));
}
}
});
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ListScrollingUtil.ensureSelectionExists(list);
}
示例11: getMethodCandidateInfo
import com.intellij.psi.util.PsiFormatUtilBase; //导入依赖的package包/类
private static String getMethodCandidateInfo(GrReferenceExpression expr) {
final GroovyResolveResult[] candidates = expr.multiResolve(false);
final String text = expr.getText();
if (candidates.length > 0) {
@NonNls final StringBuilder sb = new StringBuilder();
for (final GroovyResolveResult candidate : candidates) {
final PsiElement element = candidate.getElement();
if (!(element instanceof PsiMethod)) {
continue;
}
final String str = PsiFormatUtil
.formatMethod((PsiMethod)element, candidate.getSubstitutor(),
PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.SHOW_PARAMETERS,
PsiFormatUtilBase.SHOW_TYPE);
createElementLink(sb, element, str);
}
return CodeInsightBundle.message("javadoc.candiates", text, sb);
}
return CodeInsightBundle.message("javadoc.candidates.not.found", text);
}
示例12: createGenerateMethodElement
import com.intellij.psi.util.PsiFormatUtilBase; //导入依赖的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;
}
示例13: forMethod
import com.intellij.psi.util.PsiFormatUtilBase; //导入依赖的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(IconDescriptorUpdaters.getIcon(method, 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;
}
示例14: generateFieldSignature
import com.intellij.psi.util.PsiFormatUtilBase; //导入依赖的package包/类
private static void generateFieldSignature(StringBuilder buffer, PsiField field, boolean generateLink)
{
generateAnnotations(buffer, field, generateLink, true, false);
String modifiers = PsiFormatUtil.formatModifiers(field, PsiFormatUtilBase.JAVADOC_MODIFIERS_ONLY);
if(!modifiers.isEmpty())
{
buffer.append(modifiers);
buffer.append(" ");
}
generateType(buffer, field.getType(), field, generateLink);
buffer.append(" ");
buffer.append("<b>");
buffer.append(field.getName());
appendInitializer(buffer, field);
enumConstantOrdinal(buffer, field, field.getContainingClass(), "\n");
buffer.append("</b>");
}
示例15: formatMethodSignature
import com.intellij.psi.util.PsiFormatUtilBase; //导入依赖的package包/类
public static String formatMethodSignature(PsiMethod method, boolean raw, boolean java8Format)
{
int options = PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS;
int parameterOptions = PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.SHOW_FQ_CLASS_NAMES;
if(raw)
{
options |= PsiFormatUtilBase.SHOW_RAW_NON_TOP_TYPE;
parameterOptions |= PsiFormatUtilBase.SHOW_RAW_NON_TOP_TYPE;
}
String signature = PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY, options, parameterOptions, 999);
if(java8Format)
{
signature = signature.replaceAll("\\(|\\)|, ", "-").replaceAll("\\[\\]", ":A");
}
return signature;
}