Skip to content

Commit

Permalink
Correctly replacing ast node of constructor and method scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
oxisto committed Jul 30, 2020
1 parent eb7f68b commit 0e1d586
Showing 1 changed file with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import de.fraunhofer.aisec.cpg.graph.type.TypeParser;
import de.fraunhofer.aisec.cpg.graph.type.UnknownType;
import de.fraunhofer.aisec.cpg.passes.scopes.RecordScope;
import de.fraunhofer.aisec.cpg.passes.scopes.Scope;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -337,8 +336,6 @@ private void processMembers(

Declaration declaration = lang.getDeclarationHandler().handle(member);

Scope declarationScope = lang.getScopeManager().getScopeOfStatment(declaration);

if (declaration instanceof FunctionDeclaration) {
MethodDeclaration method =
MethodDeclaration.from((FunctionDeclaration) declaration, recordDeclaration);
Expand All @@ -347,10 +344,7 @@ private void processMembers(
// check, if its a constructor
if (declaration.getName().equals(recordDeclaration.getName())) {
ConstructorDeclaration constructor = ConstructorDeclaration.from(method);
if (declarationScope != null) {
declarationScope.setAstNode(
constructor); // Adjust cpg Node by which scopes are identified
}

Type type =
TypeParser.createFrom(
lang.getScopeManager()
Expand All @@ -369,10 +363,6 @@ private void processMembers(
// update scope manager, otherwise we point at the old function declaration
this.lang.getScopeManager().replaceNode(method, declaration);
}

if (declarationScope != null) {
declarationScope.setAstNode(method); // Adjust cpg Node by which scopes are identified
}
} else if (declaration instanceof VariableDeclaration) {
FieldDeclaration fieldDeclaration =
FieldDeclaration.from((VariableDeclaration) declaration);
Expand Down

0 comments on commit 0e1d586

Please sign in to comment.