Fixed syntaxtreegenerator to determine correct receiver of methodcall

This commit is contained in:
luca9913 2023-06-21 20:46:23 +02:00
parent 89a791b81e
commit 81e19f5315

View File

@ -468,7 +468,7 @@ public class StatementGenerator {
case PrimaryexpressionContext primary:
return convert(primary.primary());
case DottedexpressionContext dotted:
return convert((DottedexpressionContext) expression, expression.getStart());
return convert(dotted, expression.getStart());
case MethodcallexpressionContext methodcall:
return convert(methodcall.methodCall(), methodcall.getStart());
case NewinstanceexpressionContext newinstance:
@ -518,10 +518,6 @@ public class StatementGenerator {
private Expression convert(DottedexpressionContext expr, Token offset) {
if (!Objects.isNull(expr.methodCall())) {
return convert(expr.methodCall(), expr.expression(), offset);
} else if (!Objects.isNull(expr.THIS())) {
return new This(offset);
} else if (!Objects.isNull(expr.NEW()) && Objects.isNull(expr.nonWildcardTypeArguments())) {
return convert(expr.innerCreator());
} else if (!Objects.isNull(expr.identifier())) {
return generateLocalOrFieldVarOrClassName(expr.getText(), offset);
} else {
@ -567,7 +563,7 @@ public class StatementGenerator {
}
public Receiver getReceiver(ExpressionContext expr) {
Expression expression = generateLocalOrFieldVarOrClassName(expr.getText(), expr.getStart());
Expression expression = convert(expr);
/*
* if (expr instanceof PrimaryexpressionContext pc) { expression = convert(pc.primary()); } else { expression = generateLocalOrFieldVarOrClassName(expr.getText(), expr.getStart()); }
*/