Skip to content

Commit b8d7a06

Browse files
author
emmanue1
committed
Fix syntax errors in decompiled sources
1 parent b6b7551 commit b8d7a06

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/main/java/org/jd/core/v1/service/converter/classfiletojavasyntax/visitor/AddCastExpressionVisitor.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import static org.jd.core.v1.model.javasyntax.type.ObjectType.TYPE_OBJECT;
2222

2323
public class AddCastExpressionVisitor extends AbstractJavaSyntaxVisitor {
24+
protected SearchFirstLineNumberVisitor searchFirstLineNumberVisitor = new SearchFirstLineNumberVisitor();
25+
2426
protected TypeMaker typeMaker;
2527
protected Type returnedType;
2628
protected Type type;
@@ -177,7 +179,7 @@ public void visit(MethodInvocationExpression expression) {
177179
parameters.accept(this);
178180
expression.setParameters(updateExpressions(mie.getParameterTypes(), parameters));
179181
}
180-
182+
181183
expression.getExpression().accept(this);
182184
}
183185

@@ -203,6 +205,19 @@ public void visit(NewInitializedArray expression) {
203205
}
204206
}
205207

208+
@Override
209+
public void visit(FieldReferenceExpression expression) {
210+
Expression exp = expression.getExpression();
211+
212+
if ((exp != null) && (exp.getClass() != ObjectTypeReferenceExpression.class)) {
213+
Type type = typeMaker.makeFromInternalTypeName(expression.getInternalTypeName());
214+
215+
if (type.getName() != null) {
216+
expression.setExpression(updateExpression(type, exp));
217+
}
218+
}
219+
}
220+
206221
@Override
207222
public void visit(BinaryOperatorExpression expression) {
208223
expression.getLeftExpression().accept(this);
@@ -313,7 +328,7 @@ private static final boolean match(Expression expression) {
313328
return true;
314329
}
315330

316-
private static final Expression addCastExpression(Type type, Expression expression) {
331+
private Expression addCastExpression(Type type, Expression expression) {
317332
if (expression.getClass() == CastExpression.class) {
318333
CastExpression ce = (CastExpression)expression;
319334

@@ -324,7 +339,9 @@ private static final Expression addCastExpression(Type type, Expression expressi
324339
return ce;
325340
}
326341
} else {
327-
return new CastExpression(expression.getLineNumber(), type, expression);
342+
searchFirstLineNumberVisitor.init();
343+
expression.accept(searchFirstLineNumberVisitor);
344+
return new CastExpression(searchFirstLineNumberVisitor.getLineNumber(), type, expression);
328345
}
329346
}
330347

0 commit comments

Comments
 (0)