public class DependentTypesHelper extends Object
@KeyFor("m")
would be changed to
@KeyFor("[error for expression: m error: m: identifier not found]")
if m is not a
valid identifier. This allows subtyping checks to assume that if two strings are equal and
not errors, the reference the same valid Java expression.
Steps 3 and 4 are separated so that an error is issued only once per invalid expression string rather than every time the expression string is parsed. (The expression string is parsed multiple times because annotated types are created multiple times.)
Modifier and Type | Field and Description |
---|---|
protected AnnotatedTypeFactory |
factory |
Constructor and Description |
---|
DependentTypesHelper(AnnotatedTypeFactory factory) |
Modifier and Type | Method and Description |
---|---|
void |
checkAnnotation(AnnotationMirror annotation,
Tree errorTree)
Checks every Java expression element of the annotation to see if the expression is an error
string as specified by DependentTypesError#isExpressionError.
|
void |
checkClass(ClassTree classTree,
AnnotatedTypeMirror.AnnotatedDeclaredType type)
Checks all Java expressions in the class declaration AnnotatedTypeMirror to see if the
expression string is an error string as specified by DependentTypesError#isExpressionError.
|
void |
checkMethod(MethodTree methodTree,
AnnotatedTypeMirror.AnnotatedExecutableType type)
Checks all Java expressions in the method declaration AnnotatedTypeMirror to see if the
expression string is an error string as specified by DependentTypesError#isExpressionError.
|
void |
checkType(AnnotatedTypeMirror atm,
Tree errorTree)
Checks all Java expressions in the given annotated type to see if the expression string is an
error string as specified by
DependentTypesError.isExpressionError(java.lang.String) . |
TreeAnnotator |
createDependentTypesTreeAnnotator(AnnotatedTypeFactory factory)
Creates a TreeAnnotator that standardizes dependent type annotations.
|
boolean |
hasDependentAnnotations()
Returns true if any qualifier in the type system is a dependent type annotation.
|
protected void |
reportErrors(Tree errorTree,
List<DependentTypesError> errors) |
AnnotationMirror |
standardizeAnnotation(FlowExpressionParseUtil.FlowExpressionContext context,
TreePath localScope,
AnnotationMirror anno,
boolean useLocalScope)
Standardizes Java expressions in an annotation.
|
void |
standardizeClass(ClassTree node,
AnnotatedTypeMirror type,
Element ele)
Standardize the Java expressions in annotations in a class declaration.
|
void |
standardizeExpression(ExpressionTree tree,
AnnotatedTypeMirror annotatedType) |
void |
standardizeFieldAccess(MemberSelectTree node,
AnnotatedTypeMirror type)
Standardize the Java expressions in annotations in a field access.
|
void |
standardizeNewClassTree(NewClassTree tree,
AnnotatedTypeMirror.AnnotatedDeclaredType type)
Standardizes new class declarations in Java expressions.
|
void |
standardizeReturnType(MethodTree m,
AnnotatedTypeMirror atm)
Standardizes a method return in a Java expression.
|
protected String |
standardizeString(String expression,
FlowExpressionParseUtil.FlowExpressionContext context,
TreePath localScope,
boolean useLocalScope) |
void |
standardizeVariable(AnnotatedTypeMirror type,
Element elt) |
void |
standardizeVariable(Tree node,
AnnotatedTypeMirror type,
Element ele)
Standardize the Java expressions in annotations in a variable declaration.
|
void |
viewpointAdaptConstructor(NewClassTree newClassTree,
AnnotatedTypeMirror.AnnotatedExecutableType constructorType)
Viewpoint-adapts the dependent type annotations in the constructorType based on the
newClassTree.
|
void |
viewpointAdaptMethod(MethodInvocationTree methodInvocationTree,
AnnotatedTypeMirror.AnnotatedExecutableType methodDeclType)
Viewpoint-adapts the dependent type annotations in the methodDeclType based on the
methodInvocationTree.
|
void |
viewpointAdaptTypeVariableBounds(TypeElement classDecl,
List<AnnotatedTypeParameterBounds> bounds,
TreePath pathToUse)
Viewpoint-adapts the dependent type annotations on the bounds to the use of the type.
|
protected final AnnotatedTypeFactory factory
public DependentTypesHelper(AnnotatedTypeFactory factory)
public TreeAnnotator createDependentTypesTreeAnnotator(AnnotatedTypeFactory factory)
factory
- annotated type factorypublic void viewpointAdaptTypeVariableBounds(TypeElement classDecl, List<AnnotatedTypeParameterBounds> bounds, TreePath pathToUse)
classDecl
- class or interface declaration whose type variables should be viewpoint
adaptedbounds
- annotated types of the bounds of the type variablespathToUse
- tree path to the use of the class or interfacepublic void viewpointAdaptMethod(MethodInvocationTree methodInvocationTree, AnnotatedTypeMirror.AnnotatedExecutableType methodDeclType)
methodInvocationTree
- use of the methodmethodDeclType
- type of the method declarationpublic void viewpointAdaptConstructor(NewClassTree newClassTree, AnnotatedTypeMirror.AnnotatedExecutableType constructorType)
newClassTree
- invocation of the constructorconstructorType
- type of the constructorpublic void standardizeNewClassTree(NewClassTree tree, AnnotatedTypeMirror.AnnotatedDeclaredType type)
tree
- the new class declarationtype
- the type representing the classpublic void standardizeReturnType(MethodTree m, AnnotatedTypeMirror atm)
m
- the method to be standardizedatm
- the method return typepublic void standardizeClass(ClassTree node, AnnotatedTypeMirror type, Element ele)
node
- the class declarationtype
- the type of the class declarationele
- the element of the class declarationpublic void standardizeVariable(Tree node, AnnotatedTypeMirror type, Element ele)
node
- the variable declarationtype
- the type of the variable declarationele
- the element of the variable declarationpublic void standardizeFieldAccess(MemberSelectTree node, AnnotatedTypeMirror type)
public void standardizeExpression(ExpressionTree tree, AnnotatedTypeMirror annotatedType)
public void standardizeVariable(AnnotatedTypeMirror type, Element elt)
protected String standardizeString(String expression, FlowExpressionParseUtil.FlowExpressionContext context, TreePath localScope, boolean useLocalScope)
public boolean hasDependentAnnotations()
public AnnotationMirror standardizeAnnotation(FlowExpressionParseUtil.FlowExpressionContext context, TreePath localScope, AnnotationMirror anno, boolean useLocalScope)
context
- information about any receiver and argumentslocalScope
- path to local scope to useanno
- the annotation to be standardizeduseLocalScope
- whether localScope
should be used to resolve identifierspublic void checkType(AnnotatedTypeMirror atm, Tree errorTree)
DependentTypesError.isExpressionError(java.lang.String)
. If the annotated
type has any errors, a flowexpr.parse.error is issued at the errorTree.atm
- annotated type to check for expression errorserrorTree
- the tree at which to report any found errorsprotected void reportErrors(Tree errorTree, List<DependentTypesError> errors)
public void checkAnnotation(AnnotationMirror annotation, Tree errorTree)
errorTree
.annotation
- annotation to checkerrorTree
- location at which to issue errorspublic void checkClass(ClassTree classTree, AnnotatedTypeMirror.AnnotatedDeclaredType type)
classTree
- class to checktype
- annotated type of the classpublic void checkMethod(MethodTree methodTree, AnnotatedTypeMirror.AnnotatedExecutableType type)
methodTree
- method to checktype
- annotated type of the method