Interface ResolvedDeclaration
- All Superinterfaces:
AssociableToAST
- All Known Subinterfaces:
ResolvedAnnotationDeclaration, ResolvedAnnotationMemberDeclaration, ResolvedClassDeclaration, ResolvedConstructorDeclaration, ResolvedEnumConstantDeclaration, ResolvedEnumDeclaration, ResolvedFieldDeclaration, ResolvedInterfaceDeclaration, ResolvedMethodDeclaration, ResolvedMethodLikeDeclaration, ResolvedParameterDeclaration, ResolvedRecordDeclaration, ResolvedReferenceTypeDeclaration, ResolvedTypeDeclaration, ResolvedTypeParameterDeclaration, ResolvedTypePatternDeclaration, ResolvedValueDeclaration
A generic declaration.
- Author:
- Federico Tomassetti
-
Method Summary
Modifier and TypeMethodDescriptiondefault ResolvedEnumConstantDeclarationReturn this as a EnumConstantDeclaration or throw an UnsupportedOperationExceptiondefault ResolvedFieldDeclarationasField()Return this as a FieldDeclaration or throw an UnsupportedOperationExceptiondefault ResolvedMethodDeclarationasMethod()Return this as a MethodDeclaration or throw an UnsupportedOperationException // FIXME: This is never overridden.default ResolvedParameterDeclarationReturn this as a ParameterDeclaration or throw an UnsupportedOperationExceptiondefault ResolvedTypeDeclarationasType()Return this as a TypeDeclaration or throw an UnsupportedOperationExceptiondefault ResolvedTypePatternDeclarationReturn this as a PatternDeclaration or throw an UnsupportedOperationExceptiongetName()Should return the name or return null if the name is not available.default booleanhasName()Anonymous classes do not have a name, for example.default booleanDoes this declaration represent the array length pseudo-field? array.length is the only synthetic pseudo-field defined by the JLS (§10.7).default booleanDoes this declaration represents an enum constant?default booleanisField()Does this declaration represents a class field?default booleanisMethod()Does this declaration represents a method? // FIXME: This is never overridden.default booleanDoes this declaration represents a method parameter?default booleanisType()Does this declaration represents a type?default booleanDoes this declaration represents a pattern declaration?default booleanDoes this declaration represents a variable?Methods inherited from interface AssociableToAST
toAst, toAst
-
Method Details
-
hasName
default boolean hasName()Anonymous classes do not have a name, for example. -
getName
String getName()Should return the name or return null if the name is not available. -
isField
default boolean isField()Does this declaration represents a class field? -
isVariable
default boolean isVariable()Does this declaration represents a variable? -
isEnumConstant
default boolean isEnumConstant()Does this declaration represents an enum constant? -
isTypePattern
default boolean isTypePattern()Does this declaration represents a pattern declaration? -
isParameter
default boolean isParameter()Does this declaration represents a method parameter? -
isType
default boolean isType()Does this declaration represents a type? -
isMethod
default boolean isMethod()Does this declaration represents a method? // FIXME: This is never overridden. -
isArrayLength
default boolean isArrayLength()Does this declaration represent the array length pseudo-field? array.length is the only synthetic pseudo-field defined by the JLS (§10.7). It is a singleton with a fixed name and a fixed type (int), so a dedicated interface would carry no meaningful contract beyond the flag itself. The existing codebase already follows this lighter approach: isVariable() in ResolvedDeclaration has no companion ResolvedVariableDeclaration interface. Introducing an empty marker interface just to be symmetric with isField() / isEnumConstant() would be over-engineering for a one-off case. The fix is therefore: Add default boolean isArrayLength() { return false; } to ResolvedDeclaration Override it to return true inside ArrayLengthValueDeclaration If more extensibility were needed in the future — for instance, to expose getArrayType() to retrieve the component type of the backing array — the right move would be to introduce a ResolvedArrayLengthDeclaration interface at that point. Because all new methods on ResolvedDeclaration are default, and because ArrayLengthValueDeclaration already implements ResolvedValueDeclaration, that refactor could be done without any breaking change. -
asField
Return this as a FieldDeclaration or throw an UnsupportedOperationException -
asParameter
Return this as a ParameterDeclaration or throw an UnsupportedOperationException -
asType
Return this as a TypeDeclaration or throw an UnsupportedOperationException -
asMethod
Return this as a MethodDeclaration or throw an UnsupportedOperationException // FIXME: This is never overridden. -
asEnumConstant
Return this as a EnumConstantDeclaration or throw an UnsupportedOperationException -
asTypePattern
Return this as a PatternDeclaration or throw an UnsupportedOperationException
-