Skip to content

Commit

Permalink
Remove anonymous class body ConstructorDeclaration from being parsed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bl3nd committed Sep 28, 2024
1 parent d76644e commit 9ce2b22
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.javaparser.Range;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.body.*;
import com.github.javaparser.ast.expr.*;
import com.github.javaparser.ast.stmt.*;
Expand Down Expand Up @@ -205,6 +206,16 @@ public void visit(ConstructorDeclaration n, Object arg)
this.classFileContainer.putParameter(parameterName, new ClassParameterLocation(getOwner(), n.getDeclarationAsString(false, false), "declaration", line, columnStart, columnEnd + 1));
});

if (n.getParentNode().get() instanceof ObjectCreationExpr)
{
ObjectCreationExpr objectCreationExpr = (ObjectCreationExpr) n.getParentNode().get();
NodeList<BodyDeclaration<?>> bodyDeclarations = objectCreationExpr.getAnonymousClassBody().get();
if (bodyDeclarations.getFirst().get().equals(n))
{
return;
}
}

ResolvedConstructorDeclaration resolve = n.resolve();
String signature = resolve.getQualifiedSignature();
String parameters = "";
Expand Down

0 comments on commit 9ce2b22

Please sign in to comment.