Class AnnotationInsertion
java.lang.Object
org.checkerframework.afu.annotator.find.Insertion
org.checkerframework.afu.annotator.find.AnnotationInsertion
- Direct Known Subclasses:
TypeBoundExtendsInsertion
Specifies an annotation to be inserted into a source file.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.afu.annotator.find.Insertion
Insertion.Kind
-
Field Summary
Fields inherited from class org.checkerframework.afu.annotator.find.Insertion
alwaysQualify, packageNames
-
Constructor Summary
ConstructorsConstructorDescriptionAnnotationInsertion
(String annotation) Creates a new insertion with an empty criteria and the text inserted on the same line.AnnotationInsertion
(String fullyQualifiedAnnotationText, Criteria criteria, boolean separateLine) Creates a new insertion.AnnotationInsertion
(String fullyQualifiedAnnotationText, Criteria criteria, boolean separateLine, Annotation annotation) Creates a new insertion. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
addLeadingSpace
(boolean gotSeparateLine, int pos, char precedingChar) Indicates if a preceding space should be added to this insertion.protected boolean
addTrailingSpace
(boolean gotSeparateLine) Indicates if a trailing space should be added to this insertion.Returns the annotation being inserted.Returns the fully-qualified name of the annotation.Gets the raw, unmodified annotation that was passed into the constructor.getKind()
Gets the kind of this insertion.protected String
getText
(boolean abbreviate) Gets the insertion text.boolean
boolean
void
setGenerateBound
(boolean b) void
setGenerateExtends
(boolean generateExtends) void
toString()
Methods inherited from class org.checkerframework.afu.annotator.find.Insertion
collectionToString, decorateType, decorateType, getAlwaysQualify, getCriteria, getPackageNames, getText, getText, isInserted, isSeparateLine, removePackage, setAlwaysQualify, setInserted, toStringWithoutClass, typeToString
-
Constructor Details
-
AnnotationInsertion
public AnnotationInsertion(String fullyQualifiedAnnotationText, Criteria criteria, boolean separateLine) Creates a new insertion.- Parameters:
fullyQualifiedAnnotationText
- the annotation text to be inserted into source code; starts with "@", and must be a fully-qualified namecriteria
- where to insert the annotationseparateLine
- if true, insert the annotation on its own line
-
AnnotationInsertion
public AnnotationInsertion(String fullyQualifiedAnnotationText, Criteria criteria, boolean separateLine, Annotation annotation) Creates a new insertion.- Parameters:
fullyQualifiedAnnotationText
- the annotation text to be inserted into source code; starts with "@", and must be a fully-qualified namecriteria
- where to insert the annotationseparateLine
- if true, insert the annotation on its own lineannotation
- the annotation being inserted
-
AnnotationInsertion
Creates a new insertion with an empty criteria and the text inserted on the same line.- Parameters:
annotation
- the text to insert
-
-
Method Details
-
isGenerateExtends
public boolean isGenerateExtends() -
isGenerateBound
public boolean isGenerateBound() -
setGenerateExtends
public void setGenerateExtends(boolean generateExtends) -
setGenerateBound
public void setGenerateBound(boolean b) -
getText
Gets the insertion text. -
getAnnotationText
Gets the raw, unmodified annotation that was passed into the constructor.- Returns:
- the annotation
-
getAnnotationFullyQualifiedName
Returns the fully-qualified name of the annotation.E.g. given
@com.foo.Bar(baz)
, the fully-qualified name of this annotation iscom.foo.Bar
.- Returns:
- the annotation's fully-qualified name
-
addLeadingSpace
protected boolean addLeadingSpace(boolean gotSeparateLine, int pos, char precedingChar) Description copied from class:Insertion
Indicates if a preceding space should be added to this insertion. Subclasses may override this method for custom leading space rules.- Overrides:
addLeadingSpace
in classInsertion
- Parameters:
gotSeparateLine
-true
if this insertion is actually added on a separate linepos
- the source position where this insertion will be insertedprecedingChar
- the character directly preceding where this insertion will be inserted. This value will be ignored ifpos
is 0.- Returns:
true
if a leading space should be added,false
otherwise
-
addTrailingSpace
protected boolean addTrailingSpace(boolean gotSeparateLine) Description copied from class:Insertion
Indicates if a trailing space should be added to this insertion. Subclasses may override this method for custom trailing space rules.- Overrides:
addTrailingSpace
in classInsertion
- Parameters:
gotSeparateLine
-true
if this insertion is actually added on a separate line- Returns:
- true if a trailing space should be added,
false
otherwise
-
getKind
Description copied from class:Insertion
Gets the kind of this insertion. -
toString
-
setType
-
getAnnotation
Returns the annotation being inserted.- Returns:
- the annotation being inserted
-