From c94c7a647770454b3a8ac4b2633cbdac3702f08a Mon Sep 17 00:00:00 2001 From: i22035 Date: Mon, 1 Jul 2024 23:20:15 +0200 Subject: [PATCH] Constructor Fix --- src/main/java/parser/astBuilder/ASTBuilder.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/parser/astBuilder/ASTBuilder.java b/src/main/java/parser/astBuilder/ASTBuilder.java index 7ee199b..db153db 100644 --- a/src/main/java/parser/astBuilder/ASTBuilder.java +++ b/src/main/java/parser/astBuilder/ASTBuilder.java @@ -75,7 +75,12 @@ public class ASTBuilder extends SimpleJavaBaseVisitor { @Override public ASTNode visitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) { - ConstructorNode constructorNode = new ConstructorNode(ctx.AccessModifier().getText(), ctx.Identifier().getText(), (BlockNode) visit(ctx.blockStatement())); + ConstructorNode constructorNode; + if(ctx.AccessModifier() != null) { + constructorNode = new ConstructorNode(ctx.AccessModifier().getText(), ctx.Identifier().getText(), (BlockNode) visit(ctx.blockStatement())); + } else { + constructorNode = new ConstructorNode(null, ctx.Identifier().getText(), (BlockNode) visit(ctx.blockStatement())); + } if(ctx.parameterList() != null) { for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) { constructorNode.addParameter((ParameterNode) visit(parameter));