X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;ds=inline;f=util-testing%2Forg%2Fcacert%2Fgigi%2Flocalisation%2FTranslationCollectingVisitor.java;fp=util-testing%2Forg%2Fcacert%2Fgigi%2Flocalisation%2FTranslationCollectingVisitor.java;h=53e5c1cae0f9ff04bd258f1e234d93951bf3cc2b;hb=44cd191010b3e67c80127e05ee78e94032edd8dc;hp=16f7c41f0070e8c5f125a8c3803f81b34093cc95;hpb=edb152f5a1d445e97b6a9db4a0288c5020b3a476;p=gigi.git diff --git a/util-testing/org/cacert/gigi/localisation/TranslationCollectingVisitor.java b/util-testing/org/cacert/gigi/localisation/TranslationCollectingVisitor.java index 16f7c41f..53e5c1ca 100644 --- a/util-testing/org/cacert/gigi/localisation/TranslationCollectingVisitor.java +++ b/util-testing/org/cacert/gigi/localisation/TranslationCollectingVisitor.java @@ -2,6 +2,7 @@ package org.cacert.gigi.localisation; import java.io.File; import java.io.IOException; import java.lang.reflect.Method; +import java.util.Stack; import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.ast.AllocationExpression; @@ -13,6 +14,7 @@ import org.eclipse.jdt.internal.compiler.ast.Expression; import org.eclipse.jdt.internal.compiler.ast.MessageSend; import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.NullLiteral; +import org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression; import org.eclipse.jdt.internal.compiler.ast.StringLiteral; import org.eclipse.jdt.internal.compiler.lookup.BlockScope; import org.eclipse.jdt.internal.compiler.lookup.ClassScope; @@ -25,6 +27,8 @@ public final class TranslationCollectingVisitor extends ASTVisitor { TaintSource[] ts; private TranslationCollector translationCollector; + Stack anonymousConstructorCall = new Stack<>(); + public TranslationCollectingVisitor(CompilationUnitDeclaration unit, TaintSource[] target, TranslationCollector c) { this.unit = unit; @@ -67,6 +71,20 @@ public final class TranslationCollectingVisitor extends ASTVisitor { } return super.visit(allocationExpression, scope); } + + @Override + public boolean visit(QualifiedAllocationExpression qualifiedAllocationExpression, BlockScope scope) { + anonymousConstructorCall.push(qualifiedAllocationExpression); + return super.visit(qualifiedAllocationExpression, scope); + } + + @Override + public void endVisit(QualifiedAllocationExpression qualifiedAllocationExpression, BlockScope scope) { + if(anonymousConstructorCall.pop() != qualifiedAllocationExpression){ + throw new Error("stack illegally manipulated"); + } + } + @Override public boolean visit(ExplicitConstructorCall explicitConstructor, BlockScope scope) { @@ -76,6 +94,9 @@ public final class TranslationCollectingVisitor extends ASTVisitor { for (TaintSource t0 : ts) { if (t0.equals(t)) { Expression[] ags = explicitConstructor.arguments; + if (anonymousConstructorCall.size() > 0) { + ags = anonymousConstructorCall.peek().arguments; + } if (ags == null) { System.out.println(explicitConstructor); return true; @@ -183,7 +204,8 @@ public final class TranslationCollectingVisitor extends ASTVisitor { + (call == null ? "constructor" : call.sourceStart) + " => " + caller); System.out.println(e.getClass()); - System.out.println("To ignore: " + b.toConfLine()); + System.out.println( + "To ignore: " + (b == null ? "don't know" : b.toConfLine())); } private void testEnum(Expression e, MethodBinding binding) { if (binding.parameters.length != 0) {