Merge pull request 'Constructor Fix' (#18) from NewParser into main
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
Reviewed-on: #18 Reviewed-by: Johannes Ehlert <i22005@hb.dhbw-stuttgart.de>
This commit is contained in:
commit
903e87901e
@ -75,7 +75,12 @@ public class ASTBuilder extends SimpleJavaBaseVisitor<ASTNode> {
|
||||
|
||||
@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));
|
||||
|
Loading…
Reference in New Issue
Block a user