-
Notifications
You must be signed in to change notification settings - Fork 7
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e59fa6d
Added changes to handle arrays corectly
avenger2597 e4641c3
Merge branch 'master' of https://github.com/avenger2597/NullAwayAnnot…
avenger2597 367d145
Updated master branch and added code change in AddTypeUseMarkerAnnota…
avenger2597 2b8ab91
Using tokenRange to identify range
avenger2597 1f8ec0e
Updated token retrieval logic and added simple junit
avenger2597 b58ca67
Update test case to match expected outcome
avenger2597 b0848ca
reformat
nimakarimipour 883fc4e
fix issue with component type
nimakarimipour 8a81e90
add unit test
nimakarimipour 9330ab8
add unit test
nimakarimipour File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,6 +69,13 @@ public Modification computeTextModificationOnType(Type type, AnnotationExpr anno | |
if (range == null) { | ||
return null; | ||
} | ||
|
||
if (type instanceof ArrayType) { | ||
ArrayType.Origin origin = ((ArrayType) type).getOrigin(); | ||
if (origin == ArrayType.Origin.TYPE) { | ||
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. Let's not worry about this yet. 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. Removed |
||
range = range.withBeginColumn(range.end.column + 1); | ||
} | ||
} | ||
return new Insertion(annotationExpr.toString(), range.begin); | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 As mentioned previously in this comment your changes should be in
findSimpleNameRangeInTypeName
method where we are returning the array's component type as the place to insert / remove annotation for arrays. You should just change the existing case for array and usetype.getTokenRange()
to compute the range right before the first[
.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.
Done.