1 28 package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify; 29 30 import java.util.ArrayList ; 31 import java.util.Iterator ; 32 import java.util.List ; 33 34 import com.puppycrawl.tools.checkstyle.api.TokenTypes; 35 36 43 public class DotIterator implements Iterator { 44 Iterator _nodesIter; 45 List _nodes; 46 47 public DotIterator(SymTabAST topNode) 48 { 49 _nodes = new ArrayList (); 50 makeNodes(topNode); 51 _nodesIter = _nodes.iterator(); 52 } 53 54 private void makeNodes(SymTabAST node) 55 { 56 if (node.getType() == TokenTypes.DOT) { 57 SymTabAST left = (SymTabAST) node.getFirstChild(); 58 SymTabAST right = (SymTabAST) left.getNextSibling(); 59 60 makeNodes(left); 61 makeNodes(right); 62 } 63 else { 64 _nodes.add(node); 65 } 66 } 67 68 75 public boolean hasNext() 76 { 77 return _nodesIter.hasNext(); 78 } 79 80 85 public Object next() 86 { 87 return _nodesIter.next(); 88 } 89 90 95 public SymTabAST nextNode() 96 { 97 return (SymTabAST) _nodesIter.next(); 98 } 99 100 104 public void remove() 105 { 106 throw new UnsupportedOperationException (); 107 } 108 } 109 | Popular Tags |