Class CastInsertion
java.lang.Object
org.checkerframework.afu.annotator.find.Insertion
org.checkerframework.afu.annotator.find.CastInsertion
Specifies an insertion of a cast into a source file. Stores the type of cast to insert in
addition to the annotation and location.
In order to restrict the cast to only the specified expression, a cast insertion is of the form:
((cast type) (original expression))This insertion inserts the cast type and parentheses that go before the original expression. A
CloseParenthesisInsertion
must be used after the expression to close the parentheses left
open by this insertion.-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.afu.annotator.find.Insertion
Insertion.Kind
-
Field Summary
FieldsModifier and TypeFieldDescriptionboolean
True if insertion is to take place on a bare array literal.Fields inherited from class org.checkerframework.afu.annotator.find.Insertion
alwaysQualify, packageNames
-
Constructor Summary
Constructors -
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.getKind()
Gets the kind of this insertion.protected String
getText
(boolean abbreviate) Gets the insertion text.getType()
Gets the type for this insertion.boolean
void
setOnArrayLiteral
(boolean onArrayLiteral) protected void
Methods inherited from class org.checkerframework.afu.annotator.find.Insertion
collectionToString, decorateType, decorateType, getAlwaysQualify, getCriteria, getPackageNames, getText, getText, isInserted, isSeparateLine, removePackage, setAlwaysQualify, setInserted, toString, toStringWithoutClass, typeToString
-
Field Details
-
onArrayLiteral
public boolean onArrayLiteralTrue if insertion is to take place on a bare array literal.
-
-
Constructor Details
-
CastInsertion
Creates a new CastInsertion.- Parameters:
criteria
- where to insert the texttype
- the un-annotated type to cast to
-
-
Method Details
-
getType
Gets the type for this insertion. It is assumed that the returned value will be modified to update the type to be inserted.- Returns:
- the type
-
setType
-
getText
Description copied from class:Insertion
Gets the insertion text.- Specified by:
getText
in classInsertion
- Parameters:
abbreviate
- if true, the package name will be removed from the annotations. The package name can be retrieved again by calling theInsertion.getPackageNames()
method.- Returns:
- the text to insert
-
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
-
isOnArrayLiteral
public boolean isOnArrayLiteral() -
setOnArrayLiteral
public void setOnArrayLiteral(boolean onArrayLiteral) -
getKind
Description copied from class:Insertion
Gets the kind of this insertion.
-