Skip to content

Commit

Permalink
Handle annotations equivalent to nextEog/nextDfg
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianSchuette committed Aug 13, 2020
1 parent 42cb333 commit 14ea792
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public <T> PhysicalLocation getLocationFromRawNode(T astNode) {
public void processAttributes(@NonNull Node node, @NonNull IASTAttributeOwner owner) {
if (this.config.processAnnotations) {
// set attributes
node.setAnnotations(handleAttributes(owner));
node.addAnnotations(handleAttributes(owner));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static ConstructorDeclaration from(MethodDeclaration methodDeclaration) {
c.setBody(methodDeclaration.getBody());
c.setLocation(methodDeclaration.getLocation());
c.setParameters(methodDeclaration.getParameters());
c.setAnnotations(methodDeclaration.getAnnotations());
c.addAnnotations(methodDeclaration.getAnnotations());
c.setIsDefinition(methodDeclaration.isDefinition());

if (!c.isDefinition()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static MethodDeclaration from(
md.setParameters(functionDeclaration.getParameters());
md.setBody(functionDeclaration.getBody());
md.setType(functionDeclaration.getType());
md.setAnnotations(functionDeclaration.getAnnotations());
md.addAnnotations(functionDeclaration.getAnnotations());
md.setRecordDeclaration(recordDeclaration);
md.setIsDefinition(functionDeclaration.isDefinition());

Expand All @@ -80,6 +80,7 @@ public void setStatic(boolean isStatic) {
this.isStatic = isStatic;
}

@Nullable
public RecordDeclaration getRecordDeclaration() {
return recordDeclaration;
}
Expand Down
13 changes: 4 additions & 9 deletions src/main/java/de/fraunhofer/aisec/cpg/graph/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@
import de.fraunhofer.aisec.cpg.helpers.LocationConverter;
import de.fraunhofer.aisec.cpg.processing.IVisitable;
import de.fraunhofer.aisec.cpg.sarif.PhysicalLocation;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.checkerframework.checker.nullness.qual.NonNull;
Expand Down Expand Up @@ -96,8 +92,7 @@ public class Node extends IVisitable<Node> {
@Relationship(value = "DFG")
protected Set<Node> nextDFG = new HashSet<>();

@NonNull
protected Set<TypedefDeclaration> typedefs = new HashSet<>();
@NonNull protected Set<TypedefDeclaration> typedefs = new HashSet<>();

/**
* If a node is marked as being a dummy, it means that it was created artificially and does not
Expand Down Expand Up @@ -272,8 +267,8 @@ public List<Annotation> getAnnotations() {
return annotations;
}

public void setAnnotations(@NonNull List<Annotation> annotations) {
this.annotations = annotations;
public void addAnnotations(@NonNull Collection<Annotation> annotations) {
this.annotations.addAll(annotations);
}

/**
Expand Down

0 comments on commit 14ea792

Please sign in to comment.