-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insert annotations at the correct position for arrays #251
Changes from 4 commits
e59fa6d
e4641c3
367d145
2b8ab91
1f8ec0e
b58ca67
b0848ca
883fc4e
8a81e90
9330ab8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
import com.github.javaparser.ast.expr.AnnotationExpr; | ||
import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; | ||
import com.github.javaparser.ast.nodeTypes.NodeWithRange; | ||
import com.github.javaparser.ast.type.ArrayType; | ||
import com.github.javaparser.ast.type.Type; | ||
import com.google.common.collect.ImmutableList; | ||
import edu.ucr.cs.riple.injector.Helper; | ||
|
@@ -68,7 +69,12 @@ public Modification computeTextModificationOnType(Type type, AnnotationExpr anno | |
if (range == null) { | ||
return null; | ||
} | ||
return new Insertion(annotationExpr.toString(), range.begin); | ||
String annotationExpression = annotationExpr.toString(); | ||
// Need to add a space between annotation and simpleName if type is array type | ||
if (type instanceof ArrayType) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @avenger2597 As mentioned previously in this comment your changes should be in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
annotationExpression = " " + annotationExpression; | ||
} | ||
return new Insertion(annotationExpression, range.begin); | ||
} | ||
|
||
@Override | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the right way to compute the index. The
type.toString()
will return string representation of the type, not how it is written in the source code. You should find the index via:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to this logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@avenger2597 Nice, this is much cleaner now.