public abstract class PsiNameHelper
extends java.lang.Object
Constructor and Description |
---|
PsiNameHelper() |
Modifier and Type | Method and Description |
---|---|
static boolean |
appendAnnotations(java.lang.StringBuilder sb,
java.util.List<? extends PsiAnnotation> annotations,
boolean canonical) |
static boolean |
appendAnnotations(java.lang.StringBuilder sb,
PsiAnnotation [] annotations,
boolean canonical) |
static void |
appendTypeArgs(java.lang.StringBuilder sb,
PsiType [] types,
boolean canonical,
boolean annotated) |
static java.lang.String [] |
getClassParametersText(java.lang.String referenceText)
Obtains text of all type parameter values in a reference.
|
static PsiNameHelper |
getInstance(Project project) |
static java.lang.String |
getPresentableText(PsiJavaCodeReferenceElement ref) |
static java.lang.String |
getPresentableText(java.lang.String refName,
PsiAnnotation [] annotations,
PsiType [] types) |
static java.lang.String |
getQualifiedClassName(java.lang.String referenceText,
boolean removeWhitespace) |
static java.lang.String |
getShortClassName(java.lang.String referenceText) |
abstract boolean |
isIdentifier(java.lang.String text)
Checks if the specified text is a Java identifier, using the language level of the project
with which the name helper is associated to filter out keywords.
|
abstract boolean |
isIdentifier(java.lang.String text,
LanguageLevel languageLevel)
Checks if the specified text is a Java identifier, using the specified language level
with which the name helper is associated to filter out keywords.
|
abstract boolean |
isKeyword(java.lang.String text)
Checks if the specified text is a Java keyword, using the language level of the project
with which the name helper is associated.
|
abstract boolean |
isQualifiedName(java.lang.String text)
Checks if the specified string is a qualified name (sequence of identifiers separated by
periods).
|
static boolean |
isSubpackageOf(java.lang.String subpackageName,
java.lang.String packageName) |
static boolean |
isValidModuleName(java.lang.String name,
PsiElement context) |
public static PsiNameHelper getInstance(Project project)
public abstract boolean isIdentifier(java.lang.String text)
text
- the text to check.public abstract boolean isIdentifier(java.lang.String text, LanguageLevel languageLevel)
text
- the text to check.languageLevel
- to check text against. For instance 'assert' or 'enum' might or might not be identifiers depending on language levelpublic abstract boolean isKeyword(java.lang.String text)
text
- the text to check.public abstract boolean isQualifiedName(java.lang.String text)
text
- the text to check.public static java.lang.String getShortClassName(java.lang.String referenceText)
public static java.lang.String getPresentableText(PsiJavaCodeReferenceElement ref)
ref
- reference to get presentable text forpublic static java.lang.String getPresentableText(java.lang.String refName, PsiAnnotation [] annotations, PsiType [] types)
refName
- name of a reference to get presentable text forannotations
- reference annotationstypes
- reference type parameterspublic static java.lang.String getQualifiedClassName(java.lang.String referenceText, boolean removeWhitespace)
public static java.lang.String [] getClassParametersText(java.lang.String referenceText)
A<List<String>, B<Integer>>
yields
["List<String>", "B<Integer>"]
. Parameters of the outer reference are ignored:
A<List<String>>.B<Integer>
yields ["Integer"]
referenceText
- the text of the reference to calculate type parameters for.public static boolean isSubpackageOf(java.lang.String subpackageName, java.lang.String packageName)
public static void appendTypeArgs(java.lang.StringBuilder sb, PsiType [] types, boolean canonical, boolean annotated)
public static boolean appendAnnotations(java.lang.StringBuilder sb, PsiAnnotation [] annotations, boolean canonical)
public static boolean appendAnnotations(java.lang.StringBuilder sb, java.util.List<? extends PsiAnnotation> annotations, boolean canonical)
public static boolean isValidModuleName(java.lang.String name, PsiElement context)