-
Notifications
You must be signed in to change notification settings - Fork 13
Update region computation. #91
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
Changes from all commits
d820b07
6a5b075
38a79a6
af9fd46
74b7b3b
440608d
d218d29
c4e9d89
55cd6ae
7ee9a7b
28c52a1
898be2f
605171e
a0db707
adeaf9a
035053f
6a2898e
eba2200
c818b9f
21c8112
08d9e2c
b51475a
ba70c68
69e537b
851f8eb
2ae2b00
204ec6b
94d4efe
2db1d9a
e86efcd
606de6e
69e46e4
2218ea3
335ee94
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 |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| /* | ||
| * MIT License | ||
| * | ||
| * Copyright (c) 2022 Nima Karimipour | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in | ||
| * all copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| * THE SOFTWARE. | ||
| */ | ||
|
|
||
| package edu.ucr.cs.riple.core.adapters; | ||
|
|
||
| import com.google.common.base.Preconditions; | ||
| import edu.ucr.cs.riple.core.Config; | ||
| import edu.ucr.cs.riple.core.metadata.index.Error; | ||
| import edu.ucr.cs.riple.core.metadata.index.Fix; | ||
| import edu.ucr.cs.riple.core.metadata.trackers.Region; | ||
| import edu.ucr.cs.riple.core.metadata.trackers.TrackerNode; | ||
| import edu.ucr.cs.riple.injector.changes.AddMarkerAnnotation; | ||
| import edu.ucr.cs.riple.injector.location.Location; | ||
| import edu.ucr.cs.riple.injector.location.OnField; | ||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
| import java.util.Set; | ||
|
|
||
| /** | ||
| * Adapter working with versions below: | ||
| * | ||
| * <ul> | ||
| * <li>NullAway: Serialization version 0 | ||
| * <li>Type Annotator Scanner: 1.3.3 or below | ||
| * </ul> | ||
| */ | ||
| public class NullAwayV0Adapter implements NullAwayVersionAdapter { | ||
|
|
||
| /** Annotator config. */ | ||
| private final Config config; | ||
|
|
||
| public NullAwayV0Adapter(Config config) { | ||
| this.config = config; | ||
| } | ||
|
|
||
| @Override | ||
| public Fix deserializeFix(Location location, String[] values) { | ||
|
Collaborator
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. Wouldn't it be a good idea to have an initial precondition here (and in all similar methods taking
Member
Author
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. Sure, sounds good. 94d4efe |
||
| Preconditions.checkArgument( | ||
| values.length == 10, | ||
| "Expected 10 values to create Fix instance in NullAway serialization version 0 but found: " | ||
| + values.length); | ||
| Preconditions.checkArgument( | ||
| values[7].equals("nullable"), "unsupported annotation: " + values[7]); | ||
| String encMember = !Region.getType(values[9]).equals(Region.Type.METHOD) ? "null" : values[9]; | ||
| return new Fix( | ||
| new AddMarkerAnnotation(location, config.nullableAnnot), | ||
| values[6], | ||
| new Region(values[8], encMember), | ||
| true); | ||
| } | ||
|
|
||
| @Override | ||
| public Error deserializeError(String[] values) { | ||
| Preconditions.checkArgument( | ||
| values.length == 10, | ||
| "Expected 10 values to create Error instance in NullAway serialization version 0 but found: " | ||
| + values.length); | ||
| String encMember = !Region.getType(values[3]).equals(Region.Type.METHOD) ? "null" : values[3]; | ||
| return new Error( | ||
| values[0], | ||
| values[1], | ||
| new Region(values[2], encMember), | ||
| Location.createLocationFromArrayInfo(Arrays.copyOfRange(values, 4, 10))); | ||
| } | ||
|
|
||
| @Override | ||
| public TrackerNode deserializeTrackerNode(String[] values) { | ||
| Preconditions.checkArgument( | ||
| values.length == 4, | ||
| "Expected 4 values to create TrackerNode instance in NullAway serialization version 0 but found: " | ||
| + values.length); | ||
| String encMember = !Region.getType(values[1]).equals(Region.Type.METHOD) ? "null" : values[1]; | ||
| return new TrackerNode(values[0], encMember, values[2], values[3]); | ||
| } | ||
|
|
||
| @Override | ||
| public Set<Region> getFieldRegionScope(OnField onField) { | ||
| return Collections.singleton(new Region(onField.clazz, "null")); | ||
| } | ||
| } | ||
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.
I assume either now or in a follow up diff, we want to change all the above
distribution: 'adopt'totemurin. Not really needed for this PR (and it's already quite large) but worth keeping in mind.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.
#98