Skip to content

Commit

Permalink
change untainted to nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
nimakarimipour committed Oct 10, 2024
1 parent 1baffb1 commit 936c3d7
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 211 deletions.
15 changes: 0 additions & 15 deletions injector/src/main/java/edu/ucr/cs/riple/injector/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -414,21 +414,6 @@ public static Type getTypeFromNode(NodeWithAnnotations<?> node) {
return null;
}

/**
* Extracts the type of the given node implementing {@link NodeWithAnnotations}.
*
* @param node the node.
* @return the type of the node.
*/
public static Type getType(NodeWithAnnotations<?> node) {
// Currently, we only annotate the element types (contents) of an array, not the pointer
// itself.
// TODO: This should be updated in a follow-up PR. This will reflect both type-use and
// TODO: type-declaration annotations.
Type type = getTypeFromNode(node);
return type instanceof ArrayType ? ((ArrayType) type).getComponentType() : type;
}

/**
* Helper method to check if a type is annotated with a specific annotation.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public Modification computeTextModificationOnType(Type type, AnnotationExpr anno
Modification computeTextModificationOnNode(T node, AnnotationExpr annotationExpr) {
boolean addOnDeclaration =
typeIndex.stream().anyMatch(index -> index.size() == 1 && index.get(0) == 0);
Type type = Helper.getType(node);
Type type = Helper.getTypeFromNode(node);
// For annotation on fully qualified name or inner class, the annotation is on the type. (e.g.
// Map.@Annot Entry or java.util.@Annot Map)
if (addOnDeclaration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Modification computeTextModificationOnType(Type type, AnnotationExpr anno
@Override
public <T extends NodeWithAnnotations<?> & NodeWithRange<?>>
Modification computeTextModificationOnNode(T node, AnnotationExpr annotationExpr) {
Type type = Helper.getType(node);
Type type = Helper.getTypeFromNode(node);

boolean removeOnDeclaration =
typeIndex.stream().anyMatch(index -> index.size() == 1 && index.get(0) == 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public abstract Modification computeTextModificationOnType(
Modification computeTextModificationOn(T node) {
Set<Modification> modifications = new HashSet<>();
AnnotationExpr annotationExpr = new MarkerAnnotationExpr(annotationName.simpleName);
Type type = Helper.getType(node);
Type type = Helper.getTypeFromNode(node);
Modification onNode = computeTextModificationOnNode(node, annotationExpr);
if (onNode != null) {
modifications.add(onNode);
Expand Down
Loading

0 comments on commit 936c3d7

Please sign in to comment.