|
37 | 37 | import org.eclipse.jdt.core.dom.FieldDeclaration;
|
38 | 38 | import org.eclipse.jdt.core.dom.ForStatement;
|
39 | 39 | import org.eclipse.jdt.core.dom.IBinding;
|
| 40 | +import org.eclipse.jdt.core.dom.IMethodBinding; |
40 | 41 | import org.eclipse.jdt.core.dom.IPackageBinding;
|
41 | 42 | import org.eclipse.jdt.core.dom.ITypeBinding;
|
42 | 43 | import org.eclipse.jdt.core.dom.IVariableBinding;
|
|
45 | 46 | import org.eclipse.jdt.core.dom.InfixExpression;
|
46 | 47 | import org.eclipse.jdt.core.dom.InstanceofExpression;
|
47 | 48 | import org.eclipse.jdt.core.dom.LabeledStatement;
|
| 49 | +import org.eclipse.jdt.core.dom.MethodDeclaration; |
48 | 50 | import org.eclipse.jdt.core.dom.MethodInvocation;
|
49 | 51 | import org.eclipse.jdt.core.dom.Modifier;
|
50 | 52 | import org.eclipse.jdt.core.dom.Name;
|
|
57 | 59 | import org.eclipse.jdt.core.dom.QualifiedName;
|
58 | 60 | import org.eclipse.jdt.core.dom.ReturnStatement;
|
59 | 61 | import org.eclipse.jdt.core.dom.SimpleName;
|
| 62 | +import org.eclipse.jdt.core.dom.SingleVariableDeclaration; |
60 | 63 | import org.eclipse.jdt.core.dom.StringLiteral;
|
61 | 64 | import org.eclipse.jdt.core.dom.SuperFieldAccess;
|
62 | 65 | import org.eclipse.jdt.core.dom.SuperMethodInvocation;
|
@@ -442,7 +445,36 @@ public void endVisit(Block node) {
|
442 | 445 | blockLevel--;
|
443 | 446 | super.endVisit(node);
|
444 | 447 | }
|
445 |
| - |
| 448 | + |
| 449 | + public void endVisit(MethodDeclaration node) { |
| 450 | + List finalVars = ((ASTVariableVisitor) getAdaptable(ASTVariableVisitor.class)).finalVars; |
| 451 | + List visitedVars = ((ASTVariableVisitor) getAdaptable(ASTVariableVisitor.class)).visitedVars; |
| 452 | + List normalVars = ((ASTVariableVisitor) getAdaptable(ASTVariableVisitor.class)).normalVars; |
| 453 | + List parameters = node.parameters(); |
| 454 | + String methodSig = null; |
| 455 | + IMethodBinding resolveBinding = node.resolveBinding(); |
| 456 | + if (resolveBinding != null) { |
| 457 | + methodSig = resolveBinding.getKey(); |
| 458 | + } |
| 459 | + for (int i = parameters.size() - 1; i >= 0; i--) { |
| 460 | + SingleVariableDeclaration varDecl = (SingleVariableDeclaration) parameters.get(i); |
| 461 | + |
| 462 | + SimpleName name = varDecl.getName(); |
| 463 | + IBinding binding = name.resolveBinding(); |
| 464 | + if (binding != null) { |
| 465 | + String identifier = name.getIdentifier(); |
| 466 | + ASTFinalVariable f = new ASTFinalVariable(blockLevel + 1, identifier, methodSig); |
| 467 | + f.toVariableName = getIndexedVarName(identifier, normalVars.size()); |
| 468 | + normalVars.remove(f); |
| 469 | + if ((binding.getModifiers() & Modifier.FINAL) != 0) { |
| 470 | + finalVars.remove(f); |
| 471 | + } |
| 472 | + visitedVars.remove(f); |
| 473 | + } |
| 474 | + } |
| 475 | + super.endVisit(node); |
| 476 | + } |
| 477 | + |
446 | 478 | public boolean visit(BooleanLiteral node) {
|
447 | 479 | buffer.append(node.booleanValue());
|
448 | 480 | return false;
|
|
0 commit comments