1 /*** 2 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html 3 */ 4 package test.net.sourceforge.pmd.symboltable; 5 6 import junit.framework.TestCase; 7 import net.sourceforge.pmd.ast.ASTLocalVariableDeclaration; 8 import net.sourceforge.pmd.ast.ASTVariableDeclarator; 9 import net.sourceforge.pmd.ast.ASTVariableDeclaratorId; 10 import net.sourceforge.pmd.ast.SimpleNode; 11 import net.sourceforge.pmd.symboltable.DeclarationFinder; 12 import net.sourceforge.pmd.symboltable.LocalScope; 13 import net.sourceforge.pmd.symboltable.NameOccurrence; 14 15 public class DeclarationFinderTest extends TestCase { 16 17 public void testDeclarationsAreFound() { 18 DeclarationFinder df = new DeclarationFinder(); 19 20 ASTVariableDeclaratorId node = new ASTVariableDeclaratorId(1); 21 node.setImage("foo"); 22 23 ASTVariableDeclarator parent = new ASTVariableDeclarator(2); 24 node.jjtSetParent(parent); 25 26 ASTLocalVariableDeclaration gparent = new ASTLocalVariableDeclaration(3); 27 parent.jjtSetParent(gparent); 28 29 LocalScope scope = new LocalScope(); 30 node.setScope(scope); 31 df.visit(node, null); 32 33 assertTrue(scope.contains(new NameOccurrence(new SimpleNode(4), "foo"))); 34 } 35 36 public void test1() { 37 } 38 }