Package org.sonar.java.resolve
Class JavaSymbol
- java.lang.Object
-
- org.sonar.java.resolve.JavaSymbol
-
- All Implemented Interfaces:
Symbol
- Direct Known Subclasses:
JavaSymbol.JavaLabelSymbol,JavaSymbol.MethodJavaSymbol,JavaSymbol.PackageJavaSymbol,JavaSymbol.TypeJavaSymbol,JavaSymbol.VariableJavaSymbol,Resolve.AccessErrorJavaSymbol,Resolve.AmbiguityErrorJavaSymbol,Resolve.JavaSymbolNotFound
public class JavaSymbol extends Object implements Symbol
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJavaSymbol.JavaLabelSymbolstatic classJavaSymbol.MethodJavaSymbolRepresents a method, constructor or initializer (static or instance).static classJavaSymbol.PackageJavaSymbolRepresents package.static classJavaSymbol.TypeJavaSymbolRepresents a class, interface, enum or annotation type.static classJavaSymbol.TypeVariableJavaSymbolRepresents type variable of a parametrized type ie: T in class Foo{} static classJavaSymbol.VariableJavaSymbolRepresents a field, enum constant, method or constructor parameter, local variable, resource variable or exception parameter.static classJavaSymbol.WildcardSymbol-
Nested classes/interfaces inherited from interface org.sonar.plugins.java.api.semantic.Symbol
Symbol.LabelSymbol, Symbol.MethodSymbol, Symbol.TypeSymbol, Symbol.VariableSymbol
-
-
Constructor Summary
Constructors Constructor Description JavaSymbol(int kind, int flags, String name, JavaSymbol owner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddUsage(IdentifierTree tree)voidcallbackOnceComplete(Runnable callback)voidcomplete()Treedeclaration()Declaration node of this symbol.JavaSymbol.TypeJavaSymbolenclosingClass()The closest enclosing class.intflags()StringgetName()JavaTypegetType()booleanisAbstract()booleanisAnnotation()booleanisDefault()booleanisDeprecated()booleanisEnum()booleanisFinal()protected booleanisFlag(int flag)booleanisInterface()booleanisMethodSymbol()booleanisPackageSymbol()booleanisPackageVisibility()booleanisPrivate()booleanisProtected()booleanisPublic()booleanisStatic()booleanisTypeSymbol()booleanisUnknown()booleanisVariableSymbol()booleanisVolatile()SymbolMetadataResolvemetadata()Symbol metadata informations, annotations for instance.Stringname()Name of this symbol.JavaSymbol.TypeJavaSymboloutermostClass()The outermost class which indirectly owns this symbol.JavaSymbolowner()The owner of this symbol.JavaSymbol.PackageJavaSymbolpackge()The package which indirectly owns this symbol.Typetype()Type of symbol.List<IdentifierTree>usages()The identifier trees that reference this symbol.
-
-
-
Field Detail
-
PCK
public static final int PCK
- See Also:
- Constant Field Values
-
TYP
public static final int TYP
- See Also:
- Constant Field Values
-
VAR
public static final int VAR
- See Also:
- Constant Field Values
-
MTH
public static final int MTH
- See Also:
- Constant Field Values
-
ERRONEOUS
public static final int ERRONEOUS
- See Also:
- Constant Field Values
-
AMBIGUOUS
public static final int AMBIGUOUS
- See Also:
- Constant Field Values
-
ABSENT
public static final int ABSENT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JavaSymbol
public JavaSymbol(int kind, int flags, @Nullable String name, @Nullable JavaSymbol owner)
-
-
Method Detail
-
flags
public int flags()
- See Also:
Flags
-
owner
public JavaSymbol owner()
Description copied from interface:SymbolThe owner of this symbol.
-
getName
public String getName()
-
metadata
public SymbolMetadataResolve metadata()
Description copied from interface:SymbolSymbol metadata informations, annotations for instance.
-
complete
public void complete()
-
outermostClass
public JavaSymbol.TypeJavaSymbol outermostClass()
The outermost class which indirectly owns this symbol.
-
packge
public JavaSymbol.PackageJavaSymbol packge()
The package which indirectly owns this symbol.
-
enclosingClass
public JavaSymbol.TypeJavaSymbol enclosingClass()
The closest enclosing class.- Specified by:
enclosingClassin interfaceSymbol- Returns:
- null for package symbols, themselves for type symbol and enclosing class of methods or variables.
-
getType
public JavaType getType()
-
isVariableSymbol
public boolean isVariableSymbol()
- Specified by:
isVariableSymbolin interfaceSymbol
-
isTypeSymbol
public boolean isTypeSymbol()
- Specified by:
isTypeSymbolin interfaceSymbol
-
isMethodSymbol
public boolean isMethodSymbol()
- Specified by:
isMethodSymbolin interfaceSymbol
-
isPackageSymbol
public boolean isPackageSymbol()
- Specified by:
isPackageSymbolin interfaceSymbol
-
isInterface
public boolean isInterface()
- Specified by:
isInterfacein interfaceSymbol
-
isAnnotation
public boolean isAnnotation()
-
isAbstract
public boolean isAbstract()
- Specified by:
isAbstractin interfaceSymbol
-
isProtected
public boolean isProtected()
- Specified by:
isProtectedin interfaceSymbol
-
isDeprecated
public boolean isDeprecated()
- Specified by:
isDeprecatedin interfaceSymbol
-
isVolatile
public boolean isVolatile()
- Specified by:
isVolatilein interfaceSymbol
-
isDefault
public boolean isDefault()
-
isFlag
protected boolean isFlag(int flag)
-
isPackageVisibility
public boolean isPackageVisibility()
- Specified by:
isPackageVisibilityin interfaceSymbol
-
addUsage
public void addUsage(IdentifierTree tree)
-
usages
public List<IdentifierTree> usages()
Description copied from interface:SymbolThe identifier trees that reference this symbol.
-
declaration
@Nullable public Tree declaration()
Description copied from interface:SymbolDeclaration node of this symbol. Currently, only works for declaration within the same file.- Specified by:
declarationin interfaceSymbol- Returns:
- the Tree of the declaration of this symbol. Null if declaration does not occur in the currently analyzed file.
-
callbackOnceComplete
public void callbackOnceComplete(Runnable callback)
-
-