public class WholeProgramInferenceJavaParserStorage.CallableDeclarationAnnos extends Object
Modifier and Type | Field and Description |
---|---|
com.github.javaparser.ast.body.CallableDeclaration<?> |
declaration
Wrapped method or constructor declaration.
|
Constructor and Description |
---|
CallableDeclarationAnnos(com.github.javaparser.ast.body.CallableDeclaration<?> declaration)
Creates a wrapper for the given method or constructor declaration.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addDeclarationAnnotation(AnnotationMirror annotation)
Adds a declaration annotation to this callable declaration and returns whether it was a new
annotation.
|
boolean |
addDeclarationAnnotationToFormalParameter(AnnotationMirror annotation,
int index)
Adds a declaration annotation to this parameter and returns whether it was a new annotation.
|
Set<AnnotationMirror> |
getDeclarationAnnotations()
Returns the inferred declaration annotations on this executable, or null if there are no
annotations.
|
@Nullable AnnotatedTypeMirror |
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.
|
AnnotatedTypeMirror |
getParameterTypeInitialized(AnnotatedTypeMirror type,
int index,
AnnotatedTypeFactory atf)
Returns the inferred type for the parameter at the given index.
|
Map<String,Pair<AnnotatedTypeMirror,AnnotatedTypeMirror>> |
getPostconditions()
Returns the inferred postconditions for this callable declaration.
|
AnnotatedTypeMirror |
getPostconditionsForExpression(String expression,
AnnotatedTypeMirror declaredType,
AnnotatedTypeFactory atf)
Returns an AnnotatedTypeMirror containing the postconditions for the given expression.
|
Map<String,Pair<AnnotatedTypeMirror,AnnotatedTypeMirror>> |
getPreconditions()
Returns the inferred preconditions for this callable declaration.
|
AnnotatedTypeMirror |
getPreconditionsForExpression(String expression,
AnnotatedTypeMirror declaredType,
AnnotatedTypeFactory atf)
Returns an AnnotatedTypeMirror containing the preconditions for the given expression.
|
AnnotatedTypeMirror |
getReceiverType(AnnotatedTypeMirror type,
AnnotatedTypeFactory atf)
If this wrapper holds a method, returns the inferred type of the receiver.
|
AnnotatedTypeMirror |
getReturnType(AnnotatedTypeMirror type,
AnnotatedTypeFactory atf)
If this wrapper holds a method, returns the inferred type of the return type.
|
String |
toString() |
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.
|
public final com.github.javaparser.ast.body.CallableDeclaration<?> declaration
public CallableDeclarationAnnos(com.github.javaparser.ast.body.CallableDeclaration<?> declaration)
declaration
- method or constructor declaration to wrappublic AnnotatedTypeMirror getParameterTypeInitialized(AnnotatedTypeMirror type, int index, AnnotatedTypeFactory atf)
AnnotatedTypeMirror
for that location using type
and atf
to a wrapper
around the base type for the parameter.type
- type for the parameter at index
, used for initializing the returned
AnnotatedTypeMirror
the first time it's accessedatf
- the annotated type factory of a given type system, whose type hierarchy will be
usedindex
- index of the parameter to return the inferred annotations ofAnnotatedTypeMirror
containing all annotations inferred for the parameter
at the given indexpublic @Nullable AnnotatedTypeMirror getParameterType(int index)
index
- index of the parameter to return the inferred annotations ofAnnotatedTypeMirror
containing all annotations inferred for the parameter
at the given index, or null if there's no parameter at index
or if there's not
inferred annotations for that parameterpublic Set<AnnotationMirror> getDeclarationAnnotations()
public boolean addDeclarationAnnotation(AnnotationMirror annotation)
annotation
- declaration annotation to addannotation
wasn't previously stored for this callable declarationpublic boolean addDeclarationAnnotationToFormalParameter(AnnotationMirror annotation, int index)
annotation
- declaration annotation to addindex
- index of the parameterannotation
wasn't previously stored for this parameterpublic AnnotatedTypeMirror getReceiverType(AnnotatedTypeMirror type, AnnotatedTypeFactory atf)
AnnotatedTypeMirror
for that location using type
and atf
to a wrapper around the base type for the receiver type.type
- base type for the receiver type, used for initializing the returned AnnotatedTypeMirror
the first time it's accessedatf
- the annotated type factory of a given type system, whose type hierarchy will be
usedAnnotatedTypeMirror
containing all annotations inferred for the receiver
typepublic AnnotatedTypeMirror getReturnType(AnnotatedTypeMirror type, AnnotatedTypeFactory atf)
AnnotatedTypeMirror
for that location using type
and atf
to a wrapper around the base type for the return type.type
- base type for the return type, used for initializing the returned AnnotatedTypeMirror
the first time it's accessedatf
- the annotated type factory of a given type system, whose type hierarchy will be
usedAnnotatedTypeMirror
containing all annotations inferred for the return
typepublic Map<String,Pair<AnnotatedTypeMirror,AnnotatedTypeMirror>> getPreconditions()
RequiresQualifier
annotation, e.g. "#1" for the
first parameter.public Map<String,Pair<AnnotatedTypeMirror,AnnotatedTypeMirror>> getPostconditions()
EnsuresQualifier
annotation, e.g. "#1" for the first
parameter.public AnnotatedTypeMirror getPreconditionsForExpression(String expression, AnnotatedTypeMirror declaredType, AnnotatedTypeFactory atf)
expression
- a string representing a Java expression, in the same format as the argument
to a RequiresQualifier
annotationdeclaredType
- the declared type of expression
atf
- the annotated type factory of a given type system, whose type hierarchy will be
usedAnnotatedTypeMirror
containing the annotations for the inferred
preconditions for the given expressionpublic AnnotatedTypeMirror getPostconditionsForExpression(String expression, AnnotatedTypeMirror declaredType, AnnotatedTypeFactory atf)
expression
- a string representing a Java expression, in the same format as the argument
to a EnsuresQualifier
annotationdeclaredType
- the declared type of expression
atf
- the annotated type factory of a given type system, whose type hierarchy will be
usedAnnotatedTypeMirror
containing the annotations for the inferred
postconditions for the given expressionpublic void transferAnnotations()