1 19 20 package org.netbeans.modules.java.source.script; 21 22 import com.sun.tools.javac.tree.*; 23 import com.sun.tools.javac.tree.JCTree.JCErroneous; 24 import com.sun.tools.javac.util.List; 25 import com.sun.tools.javac.util.Position; 26 27 public class Rule { 28 Rule next; 29 JCTree pattern; 30 JCTree replacement; 31 JCTree suchthat; 32 JCTree code; 33 int startLine; 34 Rule(JCTree p, JCTree r, JCTree s, JCTree c, int line) { 35 pattern = p; 36 replacement = r; 37 suchthat = s; 38 code = c; 39 this.startLine = line; 40 } 41 boolean isValid() { return this != invalidRule; } 42 public String toString() { 43 StringBuffer sb = new StringBuffer (); 44 sb.append(pattern); 45 if(replacement!=null) { 46 sb.append("=>"); 47 sb.append(replacement); 48 } 49 if(suchthat!=null) { 50 sb.append("::"); 51 sb.append(suchthat); 52 } 53 if(code!=null) { 54 sb.append(" "); 55 sb.append(code); 56 } 57 return sb.toString().replace('\n',' '); 58 } 59 60 private static class ErroneousRule extends JCTree.JCErroneous { 61 ErroneousRule() { 62 super(List.<JCTree>nil()); 63 } 64 } 65 public static final Rule invalidRule = 66 new Rule(new ErroneousRule(), null, null, null, -1); 67 } 68 | Popular Tags |