1 package spoon.reflect.visitor; 2 3 import java.util.Stack ; 4 5 import spoon.reflect.declaration.CtElement; 6 import spoon.reflect.reference.CtReference; 7 8 12 public class CtStackScanner extends CtScanner { 13 14 17 public CtStackScanner() { 18 } 19 20 23 protected Stack <CtElement> elementStack = new Stack <CtElement>(); 24 25 28 protected Stack <CtReference> referenceStack = new Stack <CtReference>(); 29 30 33 protected void exit(CtElement e) { 34 CtElement ret = elementStack.pop(); 35 if (ret != e) 36 throw new RuntimeException ("Unconsitant Stack"); 37 super.exit(e); 38 } 39 40 43 protected void exitReference(CtReference e) { 44 CtReference ret = referenceStack.pop(); 45 if (ret != e) 46 throw new RuntimeException ("Unconsitant Stack"); 47 super.exitReference(e); 48 } 49 50 53 protected void enter(CtElement e) { 54 elementStack.push(e); 55 super.enter(e); 56 } 57 58 61 protected void enterReference(CtReference e) { 62 referenceStack.push(e); 63 enterReference(e); 64 super.enterReference(e); 65 } 66 } 67 | Popular Tags |