Class WholeProgramInferenceJavaParserStorage.CallableDeclarationAnnos
java.lang.Object
org.checkerframework.common.wholeprograminference.WholeProgramInferenceJavaParserStorage.CallableDeclarationAnnos
- All Implemented Interfaces:
- org.plumelib.util.DeepCopyable<WholeProgramInferenceJavaParserStorage.CallableDeclarationAnnos>
- Enclosing class:
- WholeProgramInferenceJavaParserStorage
public class WholeProgramInferenceJavaParserStorage.CallableDeclarationAnnos
extends Object
implements org.plumelib.util.DeepCopyable<WholeProgramInferenceJavaParserStorage.CallableDeclarationAnnos>
Stores the JavaParser node for a method or constructor and the annotations that have been
 inferred about its parameters and return type.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionfinal com.github.javaparser.ast.body.CallableDeclaration<?>Wrapped method or constructor declaration.
- 
Constructor SummaryConstructorsConstructorDescriptionCallableDeclarationAnnos(com.github.javaparser.ast.body.CallableDeclaration<?> declaration) Creates a wrapper for the given method or constructor declaration.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanaddDeclarationAnnotation(AnnotationMirror annotation) Adds a declaration annotation to this callable declaration and returns whether it was a new annotation.booleanaddDeclarationAnnotationToFormalParameter(AnnotationMirror annotation, int index) Adds a declaration annotation to this parameter and returns whether it was a new annotation.deepCopy()Returns the inferred declaration annotations on this executable.getParameterType(int index) Returns the inferred type for the parameter at the given index, or null if there's no parameter at the given index or there's no inferred type for that parameter.getParameterTypeInitialized(AnnotatedTypeMirror type, int index, AnnotatedTypeFactory atf) Returns the inferred type for the parameter at the given index.Map<String,org.plumelib.util.IPair<AnnotatedTypeMirror, AnnotatedTypeMirror>> Returns the inferred postconditions for this callable declaration.getPostconditionsForExpression(String expression, AnnotatedTypeMirror declaredType, AnnotatedTypeFactory atf) Returns an AnnotatedTypeMirror containing the postconditions for the given expression.Map<String,org.plumelib.util.IPair<AnnotatedTypeMirror, AnnotatedTypeMirror>> Returns the inferred preconditions for this callable declaration.getPreconditionsForExpression(String expression, AnnotatedTypeMirror declaredType, AnnotatedTypeFactory atf) Returns an AnnotatedTypeMirror containing the preconditions for the given expression.If this wrapper holds a method, returns the inferred type of the receiver.getReturnType(AnnotatedTypeMirror type, AnnotatedTypeFactory atf) If this wrapper holds a method, returns the inferred type of the return type.toString()voidTransfers all annotations inferred by whole program inference for the return type, receiver type, and parameter types for the wrapped declaration to their corresponding JavaParser locations.
- 
Field Details- 
declarationpublic final com.github.javaparser.ast.body.CallableDeclaration<?> declarationWrapped method or constructor declaration.
 
- 
- 
Constructor Details- 
CallableDeclarationAnnospublic CallableDeclarationAnnos(com.github.javaparser.ast.body.CallableDeclaration<?> declaration) Creates a wrapper for the given method or constructor declaration.- Parameters:
- declaration- method or constructor declaration to wrap
 
 
- 
- 
Method Details- 
deepCopy- Specified by:
- deepCopyin interface- org.plumelib.util.DeepCopyable<WholeProgramInferenceJavaParserStorage.CallableDeclarationAnnos>
 
- 
getParameterTypeInitializedpublic AnnotatedTypeMirror getParameterTypeInitialized(AnnotatedTypeMirror type, int index, AnnotatedTypeFactory atf) Returns the inferred type for the parameter at the given index. If necessary, initializes theAnnotatedTypeMirrorfor that location usingtypeandatfto a wrapper around the base type for the parameter.- Parameters:
- type- type for the parameter at- index, used for initializing the returned- AnnotatedTypeMirrorthe first time it's accessed
- atf- the annotated type factory of a given type system, whose type hierarchy will be used
- index- index of the parameter to return the inferred annotations of
- Returns:
- an AnnotatedTypeMirrorcontaining all annotations inferred for the parameter at the given index
 
- 
getParameterTypeReturns the inferred type for the parameter at the given index, or null if there's no parameter at the given index or there's no inferred type for that parameter.- Parameters:
- index- index of the parameter to return the inferred annotations of
- Returns:
- an AnnotatedTypeMirrorcontaining all annotations inferred for the parameter at the given index, or null if there's no parameter atindexor if there's not inferred annotations for that parameter
 
- 
addDeclarationAnnotationToFormalParameterAdds a declaration annotation to this parameter and returns whether it was a new annotation.- Parameters:
- annotation- the declaration annotation to add
- index- index of the parameter
- Returns:
- true if annotationwasn't previously stored for this parameter
 
- 
getReceiverTypeIf this wrapper holds a method, returns the inferred type of the receiver. If necessary, initializes theAnnotatedTypeMirrorfor that location usingtypeandatfto a wrapper around the base type for the receiver type.- Parameters:
- type- base type for the receiver type, used for initializing the returned- AnnotatedTypeMirrorthe first time it's accessed
- atf- the annotated type factory of a given type system, whose type hierarchy will be used
- Returns:
- an AnnotatedTypeMirrorcontaining all annotations inferred for the receiver type
 
- 
getReturnTypeIf this wrapper holds a method, returns the inferred type of the return type. If necessary, initializes theAnnotatedTypeMirrorfor that location usingtypeandatfto a wrapper around the base type for the return type.- Parameters:
- type- base type for the return type, used for initializing the returned- AnnotatedTypeMirrorthe first time it's accessed
- atf- the annotated type factory of a given type system, whose type hierarchy will be used
- Returns:
- an AnnotatedTypeMirrorcontaining all annotations inferred for the return type
 
- 
getDeclarationAnnotationsReturns the inferred declaration annotations on this executable. Returns an empty set if there are no annotations.- Returns:
- the declaration annotations for this callable declaration
 
- 
addDeclarationAnnotationAdds a declaration annotation to this callable declaration and returns whether it was a new annotation.- Parameters:
- annotation- the declaration annotation to add
- Returns:
- true if annotationwasn't previously stored for this callable declaration
 
- 
getPreconditionspublic Map<String,org.plumelib.util.IPair<AnnotatedTypeMirror, getPreconditions()AnnotatedTypeMirror>> Returns the inferred preconditions for this callable declaration. The keys of the returned map use the same string formatting as theRequiresQualifierannotation, e.g. "#1" for the first parameter.Although the map is immutable, the AnnotatedTypeMirrors within it can be modified, and such changes will be reflected in the receiver CallableDeclarationAnnos object. - Returns:
- a mapping from Java expression string to pairs of (inferred precondition for the expression, declared type of the expression)
- See Also:
 
- 
getPostconditionspublic Map<String,org.plumelib.util.IPair<AnnotatedTypeMirror, getPostconditions()AnnotatedTypeMirror>> Returns the inferred postconditions for this callable declaration. The keys of the returned map use the same string formatting as theEnsuresQualifierannotation, e.g. "#1" for the first parameter.Although the map is immutable, the AnnotatedTypeMirrors within it can be modified, and such changes will be reflected in the receiver CallableDeclarationAnnos object. - Returns:
- a mapping from Java expression string to pairs of (inferred postcondition for the expression, declared type of the expression)
- See Also:
 
- 
getPreconditionsForExpressionpublic AnnotatedTypeMirror getPreconditionsForExpression(String expression, AnnotatedTypeMirror declaredType, AnnotatedTypeFactory atf) Returns an AnnotatedTypeMirror containing the preconditions for the given expression. Changes to the returned AnnotatedTypeMirror are reflected in this CallableDeclarationAnnos.- Parameters:
- expression- a string representing a Java expression, in the same format as the argument to a- RequiresQualifierannotation
- declaredType- the declared type of- expression
- atf- the annotated type factory of a given type system, whose type hierarchy will be used
- Returns:
- an AnnotatedTypeMirrorcontaining the annotations for the inferred preconditions for the given expression
 
- 
getPostconditionsForExpressionpublic AnnotatedTypeMirror getPostconditionsForExpression(String expression, AnnotatedTypeMirror declaredType, AnnotatedTypeFactory atf) Returns an AnnotatedTypeMirror containing the postconditions for the given expression. Changes to the returned AnnotatedTypeMirror are reflected in this CallableDeclarationAnnos.- Parameters:
- expression- a string representing a Java expression, in the same format as the argument to a- EnsuresQualifierannotation
- declaredType- the declared type of- expression
- atf- the annotated type factory of a given type system, whose type hierarchy will be used
- Returns:
- an AnnotatedTypeMirrorcontaining the annotations for the inferred postconditions for the given expression
 
- 
transferAnnotationspublic void transferAnnotations()Transfers all annotations inferred by whole program inference for the return type, receiver type, and parameter types for the wrapped declaration to their corresponding JavaParser locations.
- 
toString
 
-