Skip to content
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

Use TypeUse Annotations for Jspecify and Checkers frameworks #265

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import edu.ucr.cs.riple.injector.changes.AddAnnotation;
import edu.ucr.cs.riple.injector.changes.AddMarkerAnnotation;
import edu.ucr.cs.riple.injector.changes.AddSingleElementAnnotation;
import edu.ucr.cs.riple.injector.changes.AddTypeUseMarkerAnnotation;
import edu.ucr.cs.riple.injector.location.Location;
import edu.ucr.cs.riple.injector.location.OnField;
import edu.ucr.cs.riple.injector.location.OnParameter;
Expand Down Expand Up @@ -129,10 +130,15 @@ private NullAwayError deserializeErrorFromTSVLine(ModuleInfo moduleInfo, String
if (nonnullTarget != null && nonnullTarget.isOnField()) {
nonnullTarget = extendVariableList(nonnullTarget.toField(), moduleInfo);
}
Set<AddAnnotation> annotations =
nonnullTarget == null
? Set.of()
: Set.of(new AddMarkerAnnotation(nonnullTarget, config.nullableAnnot));
Set<AddAnnotation> annotations;
if (nonnullTarget == null) {
annotations = Set.of();
} else if (Utility.isTypeUseAnnotation(config.nullableAnnot)) {
annotations = Set.of(new AddTypeUseMarkerAnnotation(nonnullTarget, config.nullableAnnot));
} else {
annotations = Set.of(new AddMarkerAnnotation(nonnullTarget, config.nullableAnnot));
}

return createError(
errorType,
errorMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,15 @@ public static List<String> readFileLines(Path path) {
throw new RuntimeException("Exception while reading file: " + path, e);
}
}

/**
* Check whether an annotation is a type-use annotation.
*
* @param annotName annotation name
* @return true if we annotName is a type-use annotation, false otherwise
*/
public static boolean isTypeUseAnnotation(String annotName) {
return annotName.contains(".jspecify.annotations.Nullable")
|| annotName.contains(".checkerframework.checker.nullness.qual.Nullable");
}
}
Loading