AccessType Fix
This commit is contained in:
parent
8fbe7d0800
commit
5529704693
@ -17,7 +17,7 @@ public class ClassNode extends ASTNode{
|
||||
|
||||
public void ensureConstructor(){
|
||||
if(!hasConstructor) {
|
||||
ConstructorNode constructor = new ConstructorNode(new TypeNode("public"), name);
|
||||
ConstructorNode constructor = new ConstructorNode(new AccessTypeNode(EnumAccessTypeNode.PUBLIC), name);
|
||||
members.add(0,constructor);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ast;
|
||||
|
||||
public class ConstructorNode extends MethodNode{
|
||||
public ConstructorNode(TypeNode visibility, String name) {
|
||||
public ConstructorNode(AccessTypeNode visibility, String name) {
|
||||
super(visibility, name);
|
||||
}
|
||||
}
|
||||
|
@ -4,22 +4,24 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MethodNode extends MemberNode{
|
||||
public TypeNode visibility;
|
||||
public AccessTypeNode visibility;
|
||||
public TypeNode type;
|
||||
public String name;
|
||||
|
||||
public ParameterListNode parameters;
|
||||
|
||||
public List<StatementNode> statements = new ArrayList<>();
|
||||
|
||||
public MethodNode(TypeNode visibility, String name, ParameterListNode parameters,
|
||||
public MethodNode(AccessTypeNode visibility, TypeNode type, String name, ParameterListNode parameters,
|
||||
List<StatementNode> statements){
|
||||
this.visibility = visibility;
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.parameters = parameters;
|
||||
this.statements = statements;
|
||||
}
|
||||
|
||||
public MethodNode(TypeNode visibility, String name){
|
||||
public MethodNode(AccessTypeNode visibility, String name){
|
||||
this.visibility = visibility;
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ public class ASTBuilder extends SimpleJavaBaseVisitor<ASTNode> {
|
||||
|
||||
@Override
|
||||
public ASTNode visitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) {
|
||||
AccessTypeNode accessType = (AccessTypeNode) visit(ctx.accessType());
|
||||
TypeNode returnType = (TypeNode) visit(ctx.type());
|
||||
String methodName = ctx.IDENTIFIER().getText();
|
||||
ParameterListNode parameterListNode = (ParameterListNode) visit(ctx.parameterList());
|
||||
@ -45,7 +46,7 @@ public class ASTBuilder extends SimpleJavaBaseVisitor<ASTNode> {
|
||||
statements.add((StatementNode) visit(stmtCtx));
|
||||
}
|
||||
|
||||
MethodNode method = new MethodNode(returnType, methodName, parameterListNode, statements);
|
||||
MethodNode method = new MethodNode(accessType,returnType, methodName, parameterListNode, statements);
|
||||
|
||||
return method;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user