001 /* This file was generated with JastAdd2 (http://jastadd.org) version 2.1.13-12-g880e696 */ 002 package org.extendj.ast; 003 004 import java.util.HashSet; 005 import java.io.File; 006 import java.util.Set; 007 import java.util.Collections; 008 import java.util.Collection; 009 import java.util.ArrayList; 010 import beaver.*; 011 import java.util.*; 012 import java.io.ByteArrayOutputStream; 013 import java.io.PrintStream; 014 import java.lang.reflect.InvocationTargetException; 015 import java.lang.reflect.Method; 016 import org.jastadd.util.*; 017 import java.util.zip.*; 018 import java.io.*; 019 import org.jastadd.util.PrettyPrintable; 020 import org.jastadd.util.PrettyPrinter; 021 import java.io.FileNotFoundException; 022 import java.io.BufferedInputStream; 023 import java.io.DataInputStream; 024 /** 025 * @ast node 026 * @declaredat /home/jesper/git/extendj/java4/grammar/Java.ast:32 027 * @production ParseName : {@link Access} ::= <span class="component"><ID:String></span>; 028 029 */ 030 public class ParseName extends Access implements Cloneable { 031 /** 032 * @aspect Java4PrettyPrint 033 * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrint.jadd:475 034 */ 035 public void prettyPrint(PrettyPrinter out) { 036 out.print(getID()); 037 } 038 /** 039 * Parser debug printout. 040 * @aspect PrettyPrint 041 * @declaredat /home/jesper/git/extendj/java7/frontend/PrettyPrint.jrag:36 042 */ 043 public void prettyPrint(StringBuffer sb) { 044 sb.append(getID()); 045 } 046 /** 047 * @declaredat ASTNode:1 048 */ 049 public ParseName() { 050 super(); 051 } 052 /** 053 * Initializes the child array to the correct size. 054 * Initializes List and Opt nta children. 055 * @apilevel internal 056 * @ast method 057 * @declaredat ASTNode:10 058 */ 059 public void init$Children() { 060 } 061 /** 062 * @declaredat ASTNode:12 063 */ 064 public ParseName(String p0) { 065 setID(p0); 066 } 067 /** 068 * @declaredat ASTNode:15 069 */ 070 public ParseName(beaver.Symbol p0) { 071 setID(p0); 072 } 073 /** 074 * @apilevel low-level 075 * @declaredat ASTNode:21 076 */ 077 protected int numChildren() { 078 return 0; 079 } 080 /** 081 * @apilevel internal 082 * @declaredat ASTNode:27 083 */ 084 public boolean mayHaveRewrite() { 085 return true; 086 } 087 /** 088 * @apilevel internal 089 * @declaredat ASTNode:33 090 */ 091 public void flushAttrCache() { 092 super.flushAttrCache(); 093 } 094 /** 095 * @apilevel internal 096 * @declaredat ASTNode:39 097 */ 098 public void flushCollectionCache() { 099 super.flushCollectionCache(); 100 } 101 /** 102 * @apilevel internal 103 * @declaredat ASTNode:45 104 */ 105 public void flushRewriteCache() { 106 super.flushRewriteCache(); 107 } 108 /** 109 * @apilevel internal 110 * @declaredat ASTNode:51 111 */ 112 public ParseName clone() throws CloneNotSupportedException { 113 ParseName node = (ParseName) super.clone(); 114 return node; 115 } 116 /** 117 * @apilevel internal 118 * @declaredat ASTNode:58 119 */ 120 public ParseName copy() { 121 try { 122 ParseName node = (ParseName) clone(); 123 node.parent = null; 124 if (children != null) { 125 node.children = (ASTNode[]) children.clone(); 126 } 127 return node; 128 } catch (CloneNotSupportedException e) { 129 throw new Error("Error: clone not supported for " + getClass().getName()); 130 } 131 } 132 /** 133 * Create a deep copy of the AST subtree at this node. 134 * The copy is dangling, i.e. has no parent. 135 * @return dangling copy of the subtree at this node 136 * @apilevel low-level 137 * @deprecated Please use treeCopy or treeCopyNoTransform instead 138 * @declaredat ASTNode:77 139 */ 140 @Deprecated 141 public ParseName fullCopy() { 142 return treeCopyNoTransform(); 143 } 144 /** 145 * Create a deep copy of the AST subtree at this node. 146 * The copy is dangling, i.e. has no parent. 147 * @return dangling copy of the subtree at this node 148 * @apilevel low-level 149 * @declaredat ASTNode:87 150 */ 151 public ParseName treeCopyNoTransform() { 152 ParseName tree = (ParseName) copy(); 153 if (children != null) { 154 for (int i = 0; i < children.length; ++i) { 155 ASTNode child = (ASTNode) children[i]; 156 if (child != null) { 157 child = child.treeCopyNoTransform(); 158 tree.setChild(child, i); 159 } 160 } 161 } 162 return tree; 163 } 164 /** 165 * Create a deep copy of the AST subtree at this node. 166 * The subtree of this node is traversed to trigger rewrites before copy. 167 * The copy is dangling, i.e. has no parent. 168 * @return dangling copy of the subtree at this node 169 * @apilevel low-level 170 * @declaredat ASTNode:107 171 */ 172 public ParseName treeCopy() { 173 doFullTraversal(); 174 return treeCopyNoTransform(); 175 } 176 /** 177 * @apilevel internal 178 * @declaredat ASTNode:114 179 */ 180 protected boolean is$Equal(ASTNode node) { 181 return super.is$Equal(node) && (tokenString_ID == ((ParseName)node).tokenString_ID); 182 } 183 /** 184 * Replaces the lexeme ID. 185 * @param value The new value for the lexeme ID. 186 * @apilevel high-level 187 */ 188 public void setID(String value) { 189 tokenString_ID = value; 190 } 191 /** 192 * @apilevel internal 193 */ 194 protected String tokenString_ID; 195 /** 196 */ 197 public int IDstart; 198 /** 199 */ 200 public int IDend; 201 /** 202 * JastAdd-internal setter for lexeme ID using the Beaver parser. 203 * @param symbol Symbol containing the new value for the lexeme ID 204 * @apilevel internal 205 */ 206 public void setID(beaver.Symbol symbol) { 207 if (symbol.value != null && !(symbol.value instanceof String)) 208 throw new UnsupportedOperationException("setID is only valid for String lexemes"); 209 tokenString_ID = (String)symbol.value; 210 IDstart = symbol.getStart(); 211 IDend = symbol.getEnd(); 212 } 213 /** 214 * Retrieves the value for the lexeme ID. 215 * @return The value for the lexeme ID. 216 * @apilevel high-level 217 */ 218 @ASTNodeAnnotation.Token(name="ID") 219 public String getID() { 220 return tokenString_ID != null ? tokenString_ID : ""; 221 } 222 /** 223 * @attribute syn 224 * @aspect TypeScopePropagation 225 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:553 226 */ 227 @ASTNodeAnnotation.Attribute 228 public SimpleSet qualifiedLookupType(String name) { 229 SimpleSet qualifiedLookupType_String_value = SimpleSet.emptySet; 230 231 return qualifiedLookupType_String_value; 232 } 233 /** 234 * @attribute syn 235 * @aspect VariableScope 236 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:237 237 */ 238 @ASTNodeAnnotation.Attribute 239 public SimpleSet qualifiedLookupVariable(String name) { 240 SimpleSet qualifiedLookupVariable_String_value = SimpleSet.emptySet; 241 242 return qualifiedLookupVariable_String_value; 243 } 244 /** 245 * @attribute syn 246 * @aspect Names 247 * @declaredat /home/jesper/git/extendj/java4/frontend/QualifiedNames.jrag:35 248 */ 249 @ASTNodeAnnotation.Attribute 250 public String name() { 251 String name_value = getID(); 252 253 return name_value; 254 } 255 /** 256 * @apilevel internal 257 */ 258 public ASTNode rewriteTo() { 259 // Declared at /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:204 260 return rewriteRule0(); 261 } 262 /** 263 * @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:204 264 * @apilevel internal 265 */ 266 private Access rewriteRule0() { 267 { 268 switch (nameType()) { 269 case PACKAGE_NAME: 270 return new PackageAccess(name(), start, end); 271 case TYPE_NAME: 272 return new TypeAccess(name(), start, end); 273 case PACKAGE_OR_TYPE_NAME: 274 if (lookupType(name()).isEmpty()) { 275 return new PackageAccess(name(), start, end); 276 } else { 277 return new TypeAccess(name(), start, end); 278 } 279 case AMBIGUOUS_NAME: 280 if (!lookupVariable(name()).isEmpty()) { 281 return new VarAccess(name(), start(), end()); 282 } else { 283 if (lookupType(name()).isEmpty()) { 284 return new PackageAccess(name(), start(), end()); 285 } else { 286 return new TypeAccess(name(), start(), end()); 287 } 288 } 289 case EXPRESSION_NAME: 290 return new VarAccess(name(), start, end); 291 case NOT_CLASSIFIED: 292 default: 293 throw new Error("Failure in name classification: unknown name type encountered"); 294 } 295 } } 296 }