diff --git a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java index 25ac46d1..afe9946a 100644 --- a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java +++ b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java @@ -573,12 +573,10 @@ public class StatementGenerator { } public Receiver getReceiver(ExpressionContext expr) { - Expression expression; - if (expr instanceof PrimaryexpressionContext pc) { - expression = convert(pc.primary()); - } else { - expression = generateLocalOrFieldVarOrClassName(expr.getText(), expr.getStart()); - } + Expression expression = generateLocalOrFieldVarOrClassName(expr.getText(), expr.getStart()); + /* + * if (expr instanceof PrimaryexpressionContext pc) { expression = convert(pc.primary()); } else { expression = generateLocalOrFieldVarOrClassName(expr.getText(), expr.getStart()); } + */ return getReceiver(expression); } @@ -816,7 +814,7 @@ public class StatementGenerator { case PrimaryLiteralContext primliteral: return convert(primliteral.literal()); case PrimaryIdentifierContext primidentifier: - return new LocalVar(primidentifier.getText(), TypePlaceholder.fresh(primidentifier.getStart()), primidentifier.getStart()); + return generateLocalOrFieldVarOrClassName(primidentifier.getText(), primidentifier.getStart()); case PrimaryClassrefContext primclassref: throw new NotImplementedException(); default: diff --git a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java index 60045643..5a8735c1 100644 --- a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java +++ b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java @@ -308,7 +308,12 @@ public class SyntaxTreeGenerator { break; } case MembermethodContext membermethod: { - methods.add(convert(membermodifiers, membermethod.method(), name, superClass, generics)); + Method convertedMethod = convert(membermodifiers, membermethod.method(), name, superClass, generics); + if (convertedMethod instanceof Constructor constructor) { + constructors.add(constructor); + } else { + methods.add(convertedMethod); + } break; } case MemberconstructorContext memberconstructor: { @@ -516,7 +521,11 @@ public class SyntaxTreeGenerator { MethodblockContext methodblock = (MethodblockContext) body; block = stmtgen.convert(methodblock.block(), true); } - return new Method(modifiers, name, retType, paramlist, block, gtvDeclarations, header.getStart()); + if (name.equals(parentClass.getClassName())) { + return new Constructor(modifiers, name, retType, paramlist, block, gtvDeclarations, methoddeclaration.getStart()); + } else { + return new Method(modifiers, name, retType, paramlist, block, gtvDeclarations, methoddeclaration.getStart()); + } } public Constructor convert(int modifiers, Java17Parser.ConstructorContext constructorContext, JavaClassName parentClass, RefType superClass, GenericsRegistry generics) { diff --git a/src/test/java/syntaxtreegenerator/TestNewFeatures.java b/src/test/java/syntaxtreegenerator/TestNewFeatures.java new file mode 100644 index 00000000..f35b0f11 --- /dev/null +++ b/src/test/java/syntaxtreegenerator/TestNewFeatures.java @@ -0,0 +1,5 @@ +package syntaxtreegenerator; + +public class TestNewFeatures { + +} \ No newline at end of file diff --git a/src/test/resources/syntaxtreegenerator/Faculty.ast b/src/test/resources/syntaxtreegenerator/Faculty.ast index 66c777a8..9cc4ca71 100644 --- a/src/test/resources/syntaxtreegenerator/Faculty.ast +++ b/src/test/resources/syntaxtreegenerator/Faculty.ast @@ -4,7 +4,7 @@ class Faculty { Faculty(){ super(()); } - TPH DDBK getFact(java.lang.Integer x){ + TPH DDBK getFact(TPH DDBL x){ return this.fact.apply Signature: [TPH DDBM, TPH DDBN](x); }