mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
i18n: JavaUsageViewDescriptionProvider
GitOrigin-RevId: 52f428976238d9bdae17542530be99a708c470b2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5a7329fa5e
commit
475ec48164
@@ -17,17 +17,24 @@ package com.intellij.usageView;
|
||||
|
||||
import com.intellij.core.JavaPsiBundle;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.psi.util.PsiFormatUtilBase;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class JavaUsageViewDescriptionProvider implements ElementDescriptionProvider {
|
||||
|
||||
public static final String NO_NAME_CLASS_VALUE = "";
|
||||
private static final @NlsSafe String CLINIT = "<clinit>";
|
||||
private static final @NlsSafe String INIT = "<init>";
|
||||
|
||||
@Override
|
||||
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
|
||||
if (location instanceof UsageViewShortNameLocation) {
|
||||
@@ -36,11 +43,11 @@ public class JavaUsageViewDescriptionProvider implements ElementDescriptionProvi
|
||||
}
|
||||
else if (element instanceof PsiAnonymousClass) {
|
||||
String name = ((PsiAnonymousClass)element).getBaseClassReference().getReferenceName();
|
||||
return "anonymous " + StringUtil.notNullize(name, "class");
|
||||
return getAnonymousClassName(name);
|
||||
}
|
||||
else if (element instanceof PsiClassInitializer) {
|
||||
boolean isStatic = ((PsiClassInitializer)element).hasModifierProperty(PsiModifier.STATIC);
|
||||
return isStatic ? "<clinit>" : "<init>";
|
||||
return isStatic ? CLINIT : INIT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,15 +58,15 @@ public class JavaUsageViewDescriptionProvider implements ElementDescriptionProvi
|
||||
else if (element instanceof PsiClass) {
|
||||
if (element instanceof PsiAnonymousClass) {
|
||||
String name = ((PsiAnonymousClass)element).getBaseClassReference().getReferenceName();
|
||||
return name != null ? JavaPsiBundle.message("java.terms.anonymous.class.base.ref", name)
|
||||
: JavaPsiBundle.message("java.terms.anonymous.class");
|
||||
return getAnonymousClassName(name);
|
||||
}
|
||||
else {
|
||||
String ret = ((PsiClass)element).getQualifiedName(); // It happens for local classes
|
||||
if (ret == null) {
|
||||
ret = ((PsiClass)element).getName();
|
||||
}
|
||||
return ObjectUtils.notNull(ret, "");
|
||||
@NonNls String finalName = ObjectUtils.notNull(ret, NO_NAME_CLASS_VALUE);
|
||||
return finalName;
|
||||
}
|
||||
}
|
||||
else if (element instanceof PsiVariable) {
|
||||
@@ -74,4 +81,11 @@ public class JavaUsageViewDescriptionProvider implements ElementDescriptionProvi
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nls
|
||||
private static String getAnonymousClassName(@Nls String name) {
|
||||
return name != null ? JavaPsiBundle.message("java.terms.anonymous.class.base.ref", name)
|
||||
: JavaPsiBundle.message("java.terms.anonymous.class");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.intellij.psi;
|
||||
|
||||
import com.intellij.lang.jvm.JvmPackage;
|
||||
import com.intellij.navigation.NavigationItem;
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -27,6 +28,7 @@ public interface PsiPackage extends PsiCheckedRenameElement, NavigationItem, Psi
|
||||
*/
|
||||
@Override
|
||||
@NotNull
|
||||
@NlsSafe
|
||||
String getQualifiedName();
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user