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:4 027 * @production CompilationUnit : {@link ASTNode} ::= <span class="component"><PackageDecl:String></span> <span class="component">{@link ImportDecl}*</span> <span class="component">{@link TypeDecl}*</span>; 028 029 */ 030 public class CompilationUnit extends ASTNode<ASTNode> implements Cloneable { 031 /** 032 * @aspect ClassPath 033 * @declaredat /home/jesper/git/extendj/java4/frontend/ClassPath.jrag:396 034 */ 035 private ClassSource classSource = ClassSource.NONE; 036 /** 037 * @aspect ClassPath 038 * @declaredat /home/jesper/git/extendj/java4/frontend/ClassPath.jrag:397 039 */ 040 private boolean fromSource = false; 041 /** 042 * @aspect ClassPath 043 * @declaredat /home/jesper/git/extendj/java4/frontend/ClassPath.jrag:399 044 */ 045 public void setClassSource(ClassSource source) { 046 this.classSource = source; 047 } 048 /** 049 * @aspect ClassPath 050 * @declaredat /home/jesper/git/extendj/java4/frontend/ClassPath.jrag:402 051 */ 052 public ClassSource getClassSource() { 053 return classSource; 054 } 055 /** 056 * @aspect ClassPath 057 * @declaredat /home/jesper/git/extendj/java4/frontend/ClassPath.jrag:405 058 */ 059 public void setFromSource(boolean value) { 060 this.fromSource = value; 061 } 062 /** 063 * @aspect ErrorCheck 064 * @declaredat /home/jesper/git/extendj/java4/frontend/ErrorCheck.jrag:88 065 */ 066 protected Collection<Problem> errors = new LinkedList<Problem>(); 067 /** 068 * @aspect ErrorCheck 069 * @declaredat /home/jesper/git/extendj/java4/frontend/ErrorCheck.jrag:89 070 */ 071 protected Collection<Problem> warnings = new LinkedList<Problem>(); 072 /** 073 * @aspect ErrorCheck 074 * @declaredat /home/jesper/git/extendj/java4/frontend/ErrorCheck.jrag:91 075 */ 076 public Collection parseErrors() { return parseErrors; } 077 /** 078 * @aspect ErrorCheck 079 * @declaredat /home/jesper/git/extendj/java4/frontend/ErrorCheck.jrag:92 080 */ 081 public void addParseError(Problem msg) { parseErrors.add(msg); } 082 /** 083 * @aspect ErrorCheck 084 * @declaredat /home/jesper/git/extendj/java4/frontend/ErrorCheck.jrag:93 085 */ 086 protected Collection parseErrors = new ArrayList(); 087 /** 088 * @return collection of semantic errors 089 * @aspect ErrorCheck 090 * @declaredat /home/jesper/git/extendj/java4/frontend/ErrorCheck.jrag:261 091 */ 092 public Collection<Problem> errors() { 093 return errors; 094 } 095 /** 096 * @return collection of semantic warnings 097 * @aspect ErrorCheck 098 * @declaredat /home/jesper/git/extendj/java4/frontend/ErrorCheck.jrag:268 099 */ 100 public Collection<Problem> warnings() { 101 return warnings; 102 } 103 /** 104 * @aspect NameCheck 105 * @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:63 106 */ 107 public void refined_NameCheck_CompilationUnit_nameCheck() { 108 for (int i = 0; i < getNumImportDecl(); i++) { 109 ImportDecl decl = getImportDecl(i); 110 if (!decl.isOnDemand()) { 111 Iterator importIter = decl.importedTypes().iterator(); 112 while (importIter.hasNext()) { 113 TypeDecl importedType = (TypeDecl) importIter.next(); 114 Iterator iter = localLookupType(importedType.name()).iterator(); 115 while (iter.hasNext()) { 116 TypeDecl local = (TypeDecl) iter.next(); 117 if (local != importedType) { 118 errorf("imported type %s conflicts with visible type", decl.typeName()); 119 } 120 } 121 } 122 } 123 } 124 } 125 /** 126 * @aspect Java4PrettyPrint 127 * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrint.jadd:302 128 */ 129 public void prettyPrint(PrettyPrinter out) { 130 if (hasPackageDecl()) { 131 out.print("package "); 132 out.print(getPackageDecl()); 133 out.print(";"); 134 out.println(); 135 } 136 if (!out.isNewLine()) { 137 out.println(); 138 } 139 out.print(getImportDeclList()); 140 if (!out.isNewLine()) { 141 out.println(); 142 } 143 out.println(); 144 out.join(getTypeDecls(), new PrettyPrinter.Joiner() { 145 @Override 146 public void printSeparator(PrettyPrinter out) { 147 out.println(); 148 out.println(); 149 } 150 }); 151 } 152 /** 153 * @aspect GenerateClassfile 154 * @declaredat /home/jesper/git/extendj/java4/backend/GenerateClassfile.jrag:39 155 */ 156 public void generateClassfile() { 157 if (fromSource()) { 158 for (int i = 0; i < getNumTypeDecl(); i++) { 159 getTypeDecl(i).generateClassfile(); 160 getTypeDecl(i).clear(); 161 } 162 } 163 } 164 /** 165 * @aspect Transformations 166 * @declaredat /home/jesper/git/extendj/java4/backend/Transformations.jrag:39 167 */ 168 public void transformation() { 169 if (fromSource()) { 170 for (int i = 0; i < getNumTypeDecl(); i++) { 171 getTypeDecl(i).transformation(); 172 } 173 } 174 } 175 /** 176 * @declaredat ASTNode:1 177 */ 178 public CompilationUnit() { 179 super(); 180 } 181 /** 182 * Initializes the child array to the correct size. 183 * Initializes List and Opt nta children. 184 * @apilevel internal 185 * @ast method 186 * @declaredat ASTNode:10 187 */ 188 public void init$Children() { 189 children = new ASTNode[2]; 190 setChild(new List(), 0); 191 setChild(new List(), 1); 192 } 193 /** 194 * @declaredat ASTNode:15 195 */ 196 public CompilationUnit(String p0, List<ImportDecl> p1, List<TypeDecl> p2) { 197 setPackageDecl(p0); 198 setChild(p1, 0); 199 setChild(p2, 1); 200 } 201 /** 202 * @declaredat ASTNode:20 203 */ 204 public CompilationUnit(beaver.Symbol p0, List<ImportDecl> p1, List<TypeDecl> p2) { 205 setPackageDecl(p0); 206 setChild(p1, 0); 207 setChild(p2, 1); 208 } 209 /** 210 * @apilevel low-level 211 * @declaredat ASTNode:28 212 */ 213 protected int numChildren() { 214 return 2; 215 } 216 /** 217 * @apilevel internal 218 * @declaredat ASTNode:34 219 */ 220 public boolean mayHaveRewrite() { 221 return false; 222 } 223 /** 224 * @apilevel internal 225 * @declaredat ASTNode:40 226 */ 227 public void flushAttrCache() { 228 super.flushAttrCache(); 229 packageName_reset(); 230 destinationPath_reset(); 231 lookupType_String_reset(); 232 } 233 /** 234 * @apilevel internal 235 * @declaredat ASTNode:49 236 */ 237 public void flushCollectionCache() { 238 super.flushCollectionCache(); 239 } 240 /** 241 * @apilevel internal 242 * @declaredat ASTNode:55 243 */ 244 public void flushRewriteCache() { 245 super.flushRewriteCache(); 246 } 247 /** 248 * @apilevel internal 249 * @declaredat ASTNode:61 250 */ 251 public CompilationUnit clone() throws CloneNotSupportedException { 252 CompilationUnit node = (CompilationUnit) super.clone(); 253 return node; 254 } 255 /** 256 * @apilevel internal 257 * @declaredat ASTNode:68 258 */ 259 public CompilationUnit copy() { 260 try { 261 CompilationUnit node = (CompilationUnit) clone(); 262 node.parent = null; 263 if (children != null) { 264 node.children = (ASTNode[]) children.clone(); 265 } 266 return node; 267 } catch (CloneNotSupportedException e) { 268 throw new Error("Error: clone not supported for " + getClass().getName()); 269 } 270 } 271 /** 272 * Create a deep copy of the AST subtree at this node. 273 * The copy is dangling, i.e. has no parent. 274 * @return dangling copy of the subtree at this node 275 * @apilevel low-level 276 * @deprecated Please use treeCopy or treeCopyNoTransform instead 277 * @declaredat ASTNode:87 278 */ 279 @Deprecated 280 public CompilationUnit fullCopy() { 281 return treeCopyNoTransform(); 282 } 283 /** 284 * Create a deep copy of the AST subtree at this node. 285 * The copy is dangling, i.e. has no parent. 286 * @return dangling copy of the subtree at this node 287 * @apilevel low-level 288 * @declaredat ASTNode:97 289 */ 290 public CompilationUnit treeCopyNoTransform() { 291 CompilationUnit tree = (CompilationUnit) copy(); 292 if (children != null) { 293 for (int i = 0; i < children.length; ++i) { 294 ASTNode child = (ASTNode) children[i]; 295 if (child != null) { 296 child = child.treeCopyNoTransform(); 297 tree.setChild(child, i); 298 } 299 } 300 } 301 return tree; 302 } 303 /** 304 * Create a deep copy of the AST subtree at this node. 305 * The subtree of this node is traversed to trigger rewrites before copy. 306 * The copy is dangling, i.e. has no parent. 307 * @return dangling copy of the subtree at this node 308 * @apilevel low-level 309 * @declaredat ASTNode:117 310 */ 311 public CompilationUnit treeCopy() { 312 doFullTraversal(); 313 return treeCopyNoTransform(); 314 } 315 /** 316 * @apilevel internal 317 * @declaredat ASTNode:124 318 */ 319 protected boolean is$Equal(ASTNode node) { 320 return super.is$Equal(node) && (tokenString_PackageDecl == ((CompilationUnit)node).tokenString_PackageDecl); 321 } 322 /** 323 * Replaces the lexeme PackageDecl. 324 * @param value The new value for the lexeme PackageDecl. 325 * @apilevel high-level 326 */ 327 public void setPackageDecl(String value) { 328 tokenString_PackageDecl = value; 329 } 330 /** 331 * @apilevel internal 332 */ 333 protected String tokenString_PackageDecl; 334 /** 335 */ 336 public int PackageDeclstart; 337 /** 338 */ 339 public int PackageDeclend; 340 /** 341 * JastAdd-internal setter for lexeme PackageDecl using the Beaver parser. 342 * @param symbol Symbol containing the new value for the lexeme PackageDecl 343 * @apilevel internal 344 */ 345 public void setPackageDecl(beaver.Symbol symbol) { 346 if (symbol.value != null && !(symbol.value instanceof String)) 347 throw new UnsupportedOperationException("setPackageDecl is only valid for String lexemes"); 348 tokenString_PackageDecl = (String)symbol.value; 349 PackageDeclstart = symbol.getStart(); 350 PackageDeclend = symbol.getEnd(); 351 } 352 /** 353 * Retrieves the value for the lexeme PackageDecl. 354 * @return The value for the lexeme PackageDecl. 355 * @apilevel high-level 356 */ 357 @ASTNodeAnnotation.Token(name="PackageDecl") 358 public String getPackageDecl() { 359 return tokenString_PackageDecl != null ? tokenString_PackageDecl : ""; 360 } 361 /** 362 * Replaces the ImportDecl list. 363 * @param list The new list node to be used as the ImportDecl list. 364 * @apilevel high-level 365 */ 366 public void setImportDeclList(List<ImportDecl> list) { 367 setChild(list, 0); 368 } 369 /** 370 * Retrieves the number of children in the ImportDecl list. 371 * @return Number of children in the ImportDecl list. 372 * @apilevel high-level 373 */ 374 public int getNumImportDecl() { 375 return getImportDeclList().getNumChild(); 376 } 377 /** 378 * Retrieves the number of children in the ImportDecl list. 379 * Calling this method will not trigger rewrites. 380 * @return Number of children in the ImportDecl list. 381 * @apilevel low-level 382 */ 383 public int getNumImportDeclNoTransform() { 384 return getImportDeclListNoTransform().getNumChildNoTransform(); 385 } 386 /** 387 * Retrieves the element at index {@code i} in the ImportDecl list. 388 * @param i Index of the element to return. 389 * @return The element at position {@code i} in the ImportDecl list. 390 * @apilevel high-level 391 */ 392 public ImportDecl getImportDecl(int i) { 393 return (ImportDecl) getImportDeclList().getChild(i); 394 } 395 /** 396 * Check whether the ImportDecl list has any children. 397 * @return {@code true} if it has at least one child, {@code false} otherwise. 398 * @apilevel high-level 399 */ 400 public boolean hasImportDecl() { 401 return getImportDeclList().getNumChild() != 0; 402 } 403 /** 404 * Append an element to the ImportDecl list. 405 * @param node The element to append to the ImportDecl list. 406 * @apilevel high-level 407 */ 408 public void addImportDecl(ImportDecl node) { 409 List<ImportDecl> list = (parent == null) ? getImportDeclListNoTransform() : getImportDeclList(); 410 list.addChild(node); 411 } 412 /** 413 * @apilevel low-level 414 */ 415 public void addImportDeclNoTransform(ImportDecl node) { 416 List<ImportDecl> list = getImportDeclListNoTransform(); 417 list.addChild(node); 418 } 419 /** 420 * Replaces the ImportDecl list element at index {@code i} with the new node {@code node}. 421 * @param node The new node to replace the old list element. 422 * @param i The list index of the node to be replaced. 423 * @apilevel high-level 424 */ 425 public void setImportDecl(ImportDecl node, int i) { 426 List<ImportDecl> list = getImportDeclList(); 427 list.setChild(node, i); 428 } 429 /** 430 * Retrieves the ImportDecl list. 431 * @return The node representing the ImportDecl list. 432 * @apilevel high-level 433 */ 434 @ASTNodeAnnotation.ListChild(name="ImportDecl") 435 public List<ImportDecl> getImportDeclList() { 436 List<ImportDecl> list = (List<ImportDecl>) getChild(0); 437 return list; 438 } 439 /** 440 * Retrieves the ImportDecl list. 441 * <p><em>This method does not invoke AST transformations.</em></p> 442 * @return The node representing the ImportDecl list. 443 * @apilevel low-level 444 */ 445 public List<ImportDecl> getImportDeclListNoTransform() { 446 return (List<ImportDecl>) getChildNoTransform(0); 447 } 448 /** 449 * Retrieves the ImportDecl list. 450 * @return The node representing the ImportDecl list. 451 * @apilevel high-level 452 */ 453 public List<ImportDecl> getImportDecls() { 454 return getImportDeclList(); 455 } 456 /** 457 * Retrieves the ImportDecl list. 458 * <p><em>This method does not invoke AST transformations.</em></p> 459 * @return The node representing the ImportDecl list. 460 * @apilevel low-level 461 */ 462 public List<ImportDecl> getImportDeclsNoTransform() { 463 return getImportDeclListNoTransform(); 464 } 465 /** 466 * Replaces the TypeDecl list. 467 * @param list The new list node to be used as the TypeDecl list. 468 * @apilevel high-level 469 */ 470 public void setTypeDeclList(List<TypeDecl> list) { 471 setChild(list, 1); 472 } 473 /** 474 * Retrieves the number of children in the TypeDecl list. 475 * @return Number of children in the TypeDecl list. 476 * @apilevel high-level 477 */ 478 public int getNumTypeDecl() { 479 return getTypeDeclList().getNumChild(); 480 } 481 /** 482 * Retrieves the number of children in the TypeDecl list. 483 * Calling this method will not trigger rewrites. 484 * @return Number of children in the TypeDecl list. 485 * @apilevel low-level 486 */ 487 public int getNumTypeDeclNoTransform() { 488 return getTypeDeclListNoTransform().getNumChildNoTransform(); 489 } 490 /** 491 * Retrieves the element at index {@code i} in the TypeDecl list. 492 * @param i Index of the element to return. 493 * @return The element at position {@code i} in the TypeDecl list. 494 * @apilevel high-level 495 */ 496 public TypeDecl getTypeDecl(int i) { 497 return (TypeDecl) getTypeDeclList().getChild(i); 498 } 499 /** 500 * Check whether the TypeDecl list has any children. 501 * @return {@code true} if it has at least one child, {@code false} otherwise. 502 * @apilevel high-level 503 */ 504 public boolean hasTypeDecl() { 505 return getTypeDeclList().getNumChild() != 0; 506 } 507 /** 508 * Append an element to the TypeDecl list. 509 * @param node The element to append to the TypeDecl list. 510 * @apilevel high-level 511 */ 512 public void addTypeDecl(TypeDecl node) { 513 List<TypeDecl> list = (parent == null) ? getTypeDeclListNoTransform() : getTypeDeclList(); 514 list.addChild(node); 515 } 516 /** 517 * @apilevel low-level 518 */ 519 public void addTypeDeclNoTransform(TypeDecl node) { 520 List<TypeDecl> list = getTypeDeclListNoTransform(); 521 list.addChild(node); 522 } 523 /** 524 * Replaces the TypeDecl list element at index {@code i} with the new node {@code node}. 525 * @param node The new node to replace the old list element. 526 * @param i The list index of the node to be replaced. 527 * @apilevel high-level 528 */ 529 public void setTypeDecl(TypeDecl node, int i) { 530 List<TypeDecl> list = getTypeDeclList(); 531 list.setChild(node, i); 532 } 533 /** 534 * Retrieves the TypeDecl list. 535 * @return The node representing the TypeDecl list. 536 * @apilevel high-level 537 */ 538 @ASTNodeAnnotation.ListChild(name="TypeDecl") 539 public List<TypeDecl> getTypeDeclList() { 540 List<TypeDecl> list = (List<TypeDecl>) getChild(1); 541 return list; 542 } 543 /** 544 * Retrieves the TypeDecl list. 545 * <p><em>This method does not invoke AST transformations.</em></p> 546 * @return The node representing the TypeDecl list. 547 * @apilevel low-level 548 */ 549 public List<TypeDecl> getTypeDeclListNoTransform() { 550 return (List<TypeDecl>) getChildNoTransform(1); 551 } 552 /** 553 * Retrieves the TypeDecl list. 554 * @return The node representing the TypeDecl list. 555 * @apilevel high-level 556 */ 557 public List<TypeDecl> getTypeDecls() { 558 return getTypeDeclList(); 559 } 560 /** 561 * Retrieves the TypeDecl list. 562 * <p><em>This method does not invoke AST transformations.</em></p> 563 * @return The node representing the TypeDecl list. 564 * @apilevel low-level 565 */ 566 public List<TypeDecl> getTypeDeclsNoTransform() { 567 return getTypeDeclListNoTransform(); 568 } 569 /** 570 * @aspect StaticImports 571 * @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:273 572 */ 573 public void nameCheck() { 574 refined_NameCheck_CompilationUnit_nameCheck(); 575 for (int i = 0; i < getNumImportDecl(); i++) { 576 if (getImportDecl(i) instanceof SingleStaticImportDecl) { 577 SingleStaticImportDecl decl = (SingleStaticImportDecl) getImportDecl(i); 578 String name = decl.name(); 579 if (!decl.importedTypes(name).isEmpty()) { 580 TypeDecl type = (TypeDecl) decl.importedTypes(name).iterator().next(); 581 if (localLookupType(name).contains(type)) { 582 decl.errorf("the imported name %s.%s is already declared in this compilation unit", 583 packageName(), name); 584 } 585 } 586 } 587 } 588 } 589 /** 590 * @aspect TypeScopePropagation 591 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:347 592 */ 593 private SimpleSet refined_TypeScopePropagation_CompilationUnit_Child_lookupType_String(String name) 594 { 595 // Locally declared types in the compilation unit. 596 SimpleSet set = localLookupType(name); 597 if (!set.isEmpty()) { 598 return set; 599 } 600 601 // Imported types. 602 set = importedTypes(name); 603 if (!set.isEmpty()) { 604 return set; 605 } 606 607 // Types in the same package. 608 TypeDecl result = lookupType(packageName(), name); 609 if (result.accessibleFromPackage(packageName())) { 610 return result; 611 } 612 613 // Types imported on demand. 614 set = importedTypesOnDemand(name); 615 if (!set.isEmpty()) { 616 return set; 617 } 618 619 // Include primitive types. 620 result = lookupType(PRIMITIVE_PACKAGE_NAME, name); 621 if (!result.isUnknown()) { 622 return result; 623 } 624 625 // 7.5.5 Automatic Imports 626 result = lookupType("java.lang", name); 627 if (result.accessibleFromPackage(packageName())) { 628 return result; 629 } 630 return lookupType(name); 631 } 632 /** 633 * @return The path to the source file, or the path to the file inside a Jar 634 * file. 635 * @attribute syn 636 * @aspect ClassPath 637 * @declaredat /home/jesper/git/extendj/java4/frontend/ClassPath.jrag:66 638 */ 639 @ASTNodeAnnotation.Attribute 640 public String relativeName() { 641 String relativeName_value = getClassSource().relativeName(); 642 643 return relativeName_value; 644 } 645 /** 646 * @return The path to the source file, or the enclosing Jar file. 647 * @attribute syn 648 * @aspect ClassPath 649 * @declaredat /home/jesper/git/extendj/java4/frontend/ClassPath.jrag:71 650 */ 651 @ASTNodeAnnotation.Attribute 652 public String pathName() { 653 String pathName_value = getClassSource().pathName(); 654 655 return pathName_value; 656 } 657 /** 658 * @return {@code true} if this compilation unit was parsed from source. 659 * @attribute syn 660 * @aspect ClassPath 661 * @declaredat /home/jesper/git/extendj/java4/frontend/ClassPath.jrag:76 662 */ 663 @ASTNodeAnnotation.Attribute 664 public boolean fromSource() { 665 boolean fromSource_value = fromSource; 666 667 return fromSource_value; 668 } 669 /** Searches for a type with the given simple name in this compilation unit. 670 * @attribute syn 671 * @aspect TypeScopePropagation 672 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:387 673 */ 674 @ASTNodeAnnotation.Attribute 675 public SimpleSet localLookupType(String name) { 676 { 677 for (int i = 0; i < getNumTypeDecl(); i++) { 678 if (getTypeDecl(i).name().equals(name)) { 679 return SimpleSet.emptySet.add(getTypeDecl(i)); 680 } 681 } 682 return SimpleSet.emptySet; 683 } 684 } 685 /** 686 * @attribute syn 687 * @aspect TypeScopePropagation 688 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:396 689 */ 690 @ASTNodeAnnotation.Attribute 691 public SimpleSet importedTypes(String name) { 692 { 693 SimpleSet set = SimpleSet.emptySet; 694 for (int i = 0; i < getNumImportDecl(); i++) { 695 if (!getImportDecl(i).isOnDemand()) { 696 for (Iterator iter = getImportDecl(i).importedTypes(name).iterator(); iter.hasNext(); ) { 697 set = set.add(iter.next()); 698 } 699 } 700 } 701 return set; 702 } 703 } 704 /** 705 * @attribute syn 706 * @aspect TypeScopePropagation 707 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:408 708 */ 709 @ASTNodeAnnotation.Attribute 710 public SimpleSet importedTypesOnDemand(String name) { 711 { 712 SimpleSet set = SimpleSet.emptySet; 713 for (int i = 0; i < getNumImportDecl(); i++) { 714 if (getImportDecl(i).isOnDemand()) { 715 for (Iterator iter = getImportDecl(i).importedTypes(name).iterator(); iter.hasNext(); ) { 716 set = set.add(iter.next()); 717 } 718 } 719 } 720 return set; 721 } 722 } 723 /** 724 * @attribute syn 725 * @aspect PrettyPrintUtil 726 * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:261 727 */ 728 @ASTNodeAnnotation.Attribute 729 public boolean hasPackageDecl() { 730 boolean hasPackageDecl_value = !getPackageDecl().isEmpty(); 731 732 return hasPackageDecl_value; 733 } 734 /** 735 * @apilevel internal 736 */ 737 protected boolean packageName_computed = false; 738 /** 739 * @apilevel internal 740 */ 741 protected String packageName_value; 742 /** 743 * @apilevel internal 744 */ 745 private void packageName_reset() { 746 packageName_computed = false; 747 packageName_value = null; 748 } 749 /** 750 * @attribute syn 751 * @aspect TypeName 752 * @declaredat /home/jesper/git/extendj/java4/frontend/QualifiedNames.jrag:106 753 */ 754 @ASTNodeAnnotation.Attribute 755 public String packageName() { 756 ASTNode$State state = state(); 757 if (packageName_computed) { 758 return packageName_value; 759 } 760 boolean intermediate = state.INTERMEDIATE_VALUE; 761 state.INTERMEDIATE_VALUE = false; 762 int num = state.boundariesCrossed; 763 boolean isFinal = this.is$Final(); 764 packageName_value = packageName_compute(); 765 if (isFinal && num == state().boundariesCrossed) { 766 packageName_computed = true; 767 } else { 768 } 769 state.INTERMEDIATE_VALUE |= intermediate; 770 771 return packageName_value; 772 } 773 /** 774 * @apilevel internal 775 */ 776 private String packageName_compute() {return getPackageDecl();} 777 /** 778 * @apilevel internal 779 */ 780 protected boolean destinationPath_computed = false; 781 /** 782 * @apilevel internal 783 */ 784 protected String destinationPath_value; 785 /** 786 * @apilevel internal 787 */ 788 private void destinationPath_reset() { 789 destinationPath_computed = false; 790 destinationPath_value = null; 791 } 792 /** 793 * Computes the path to the parent directory of the source file of this 794 * compilation unit. 795 * 796 * <p>If the parent directory of the source file could not be computed 797 * the path to the working directory is returned. 798 * 799 * @return The path to the parent directory of the source file for this 800 * compilation unit, or "." if the path could not be computed. 801 * @attribute syn 802 * @aspect ConstantPoolNames 803 * @declaredat /home/jesper/git/extendj/java4/backend/ConstantPoolNames.jrag:146 804 */ 805 @ASTNodeAnnotation.Attribute 806 public String destinationPath() { 807 ASTNode$State state = state(); 808 if (destinationPath_computed) { 809 return destinationPath_value; 810 } 811 boolean intermediate = state.INTERMEDIATE_VALUE; 812 state.INTERMEDIATE_VALUE = false; 813 int num = state.boundariesCrossed; 814 boolean isFinal = this.is$Final(); 815 destinationPath_value = destinationPath_compute(); 816 if (isFinal && num == state().boundariesCrossed) { 817 destinationPath_computed = true; 818 } else { 819 } 820 state.INTERMEDIATE_VALUE |= intermediate; 821 822 return destinationPath_value; 823 } 824 /** 825 * @apilevel internal 826 */ 827 private String destinationPath_compute() { 828 String parentPath = new File(pathName()).getParent(); 829 if (parentPath == null) { 830 return "."; 831 } else { 832 return parentPath; 833 } 834 } 835 /** 836 * @attribute syn 837 * @aspect StaticImports 838 * @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:186 839 */ 840 @ASTNodeAnnotation.Attribute 841 public SimpleSet importedFields(String name) { 842 { 843 SimpleSet set = SimpleSet.emptySet; 844 for (int i = 0; i < getNumImportDecl(); i++) { 845 if (!getImportDecl(i).isOnDemand()) { 846 for (Iterator iter = getImportDecl(i).importedFields(name).iterator(); iter.hasNext(); ) { 847 set = set.add(iter.next()); 848 } 849 } 850 } 851 return set; 852 } 853 } 854 /** 855 * @attribute syn 856 * @aspect StaticImports 857 * @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:198 858 */ 859 @ASTNodeAnnotation.Attribute 860 public SimpleSet importedFieldsOnDemand(String name) { 861 { 862 SimpleSet set = SimpleSet.emptySet; 863 for (int i = 0; i < getNumImportDecl(); i++) { 864 if (getImportDecl(i).isOnDemand()) { 865 for (Iterator iter = getImportDecl(i).importedFields(name).iterator(); iter.hasNext(); ) { 866 set = set.add(iter.next()); 867 } 868 } 869 } 870 return set; 871 } 872 } 873 /** 874 * @attribute syn 875 * @aspect StaticImports 876 * @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:228 877 */ 878 @ASTNodeAnnotation.Attribute 879 public Collection importedMethods(String name) { 880 { 881 Collection list = new ArrayList(); 882 for (int i = 0; i < getNumImportDecl(); i++) { 883 if (!getImportDecl(i).isOnDemand()) { 884 list.addAll(getImportDecl(i).importedMethods(name)); 885 } 886 } 887 return list; 888 } 889 } 890 /** 891 * @attribute syn 892 * @aspect StaticImports 893 * @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:238 894 */ 895 @ASTNodeAnnotation.Attribute 896 public Collection importedMethodsOnDemand(String name) { 897 { 898 Collection list = new ArrayList(); 899 for (int i = 0; i < getNumImportDecl(); i++) { 900 if (getImportDecl(i).isOnDemand()) { 901 list.addAll(getImportDecl(i).importedMethods(name)); 902 } 903 } 904 return list; 905 } 906 } 907 /** 908 * @attribute inh 909 * @aspect LookupFullyQualifiedTypes 910 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:133 911 */ 912 /** 913 * @attribute inh 914 * @aspect LookupFullyQualifiedTypes 915 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:133 916 */ 917 @ASTNodeAnnotation.Attribute 918 public TypeDecl lookupType(String packageName, String typeName) { 919 TypeDecl lookupType_String_String_value = getParent().Define_lookupType(this, null, packageName, typeName); 920 921 return lookupType_String_String_value; 922 } 923 /** 924 * @attribute inh 925 * @aspect TypeScopePropagation 926 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:336 927 */ 928 /** 929 * @attribute inh 930 * @aspect TypeScopePropagation 931 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:336 932 */ 933 @ASTNodeAnnotation.Attribute 934 public SimpleSet lookupType(String name) { 935 Object _parameters = name; 936 if (lookupType_String_values == null) lookupType_String_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 937 ASTNode$State state = state(); 938 if (lookupType_String_values.containsKey(_parameters)) { 939 return (SimpleSet) lookupType_String_values.get(_parameters); 940 } 941 boolean intermediate = state.INTERMEDIATE_VALUE; 942 state.INTERMEDIATE_VALUE = false; 943 int num = state.boundariesCrossed; 944 boolean isFinal = this.is$Final(); 945 SimpleSet lookupType_String_value = getParent().Define_lookupType(this, null, name); 946 if (isFinal && num == state().boundariesCrossed) { 947 lookupType_String_values.put(_parameters, lookupType_String_value); 948 } else { 949 } 950 state.INTERMEDIATE_VALUE |= intermediate; 951 952 return lookupType_String_value; 953 } 954 /** 955 * @apilevel internal 956 */ 957 protected java.util.Map lookupType_String_values; 958 /** 959 * @apilevel internal 960 */ 961 private void lookupType_String_reset() { 962 lookupType_String_values = null; 963 } 964 /** 965 * @attribute inh 966 * @aspect StaticImports 967 * @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:184 968 */ 969 /** 970 * @attribute inh 971 * @aspect StaticImports 972 * @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:184 973 */ 974 @ASTNodeAnnotation.Attribute 975 public SimpleSet lookupVariable(String name) { 976 SimpleSet lookupVariable_String_value = getParent().Define_lookupVariable(this, null, name); 977 978 return lookupVariable_String_value; 979 } 980 /** 981 * @attribute inh 982 * @aspect StaticImports 983 * @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:226 984 */ 985 /** 986 * @attribute inh 987 * @aspect StaticImports 988 * @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:226 989 */ 990 @ASTNodeAnnotation.Attribute 991 public Collection lookupMethod(String name) { 992 Collection lookupMethod_String_value = getParent().Define_lookupMethod(this, null, name); 993 994 return lookupMethod_String_value; 995 } 996 /** 997 * @declaredat /home/jesper/git/extendj/java7/frontend/Literals.jrag:490 998 * @apilevel internal 999 */ 1000 public CompilationUnit Define_compilationUnit(ASTNode caller, ASTNode child) { 1001 int childIndex = this.getIndexOfChild(caller); 1002 return this; 1003 } 1004 protected boolean canDefine_compilationUnit(ASTNode caller, ASTNode child) { 1005 return true; 1006 } 1007 /** 1008 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:71 1009 * @apilevel internal 1010 */ 1011 public boolean Define_isIncOrDec(ASTNode caller, ASTNode child) { 1012 if (caller == getTypeDeclListNoTransform()) { 1013 // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:73 1014 int childIndex = caller.getIndexOfChild(child); 1015 return false; 1016 } 1017 else { 1018 return getParent().Define_isIncOrDec(this, caller); 1019 } 1020 } 1021 protected boolean canDefine_isIncOrDec(ASTNode caller, ASTNode child) { 1022 return true; 1023 } 1024 /** 1025 * @declaredat /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag:113 1026 * @apilevel internal 1027 */ 1028 public boolean Define_handlesException(ASTNode caller, ASTNode child, TypeDecl exceptionType) { 1029 if (caller == getImportDeclListNoTransform()) { 1030 // @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:292 1031 int childIndex = caller.getIndexOfChild(child); 1032 return false; 1033 } 1034 else if (caller == getTypeDeclListNoTransform()) { 1035 // @declaredat /home/jesper/git/extendj/java4/frontend/ExceptionHandling.jrag:177 1036 int childIndex = caller.getIndexOfChild(child); 1037 return false; 1038 } 1039 else { 1040 return getParent().Define_handlesException(this, caller, exceptionType); 1041 } 1042 } 1043 protected boolean canDefine_handlesException(ASTNode caller, ASTNode child, TypeDecl exceptionType) { 1044 return true; 1045 } 1046 /** 1047 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericMethods.jrag:197 1048 * @apilevel internal 1049 */ 1050 public SimpleSet Define_lookupType(ASTNode caller, ASTNode child, String name) { 1051 if (caller == getImportDeclListNoTransform()) { 1052 // @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:470 1053 int childIndex = caller.getIndexOfChild(child); 1054 return lookupType(name); 1055 } 1056 else { 1057 int childIndex = this.getIndexOfChild(caller); 1058 { 1059 SimpleSet result = SimpleSet.emptySet; 1060 for (Iterator iter = refined_TypeScopePropagation_CompilationUnit_Child_lookupType_String(name).iterator(); iter.hasNext(); ) { 1061 TypeDecl typeDecl = (TypeDecl) iter.next(); 1062 if (typeDecl instanceof ParTypeDecl) { 1063 result = result.add(((ParTypeDecl) typeDecl).genericDecl()); 1064 } else { 1065 result = result.add(typeDecl); 1066 } 1067 } 1068 return result; 1069 } 1070 } 1071 } 1072 protected boolean canDefine_lookupType(ASTNode caller, ASTNode child, String name) { 1073 return true; 1074 } 1075 /** 1076 * @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:52 1077 * @apilevel internal 1078 */ 1079 public SimpleSet Define_allImportedTypes(ASTNode caller, ASTNode child, String name) { 1080 if (caller == getImportDeclListNoTransform()) { 1081 // @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:53 1082 int childIndex = caller.getIndexOfChild(child); 1083 return importedTypes(name); 1084 } 1085 else { 1086 return getParent().Define_allImportedTypes(this, caller, name); 1087 } 1088 } 1089 protected boolean canDefine_allImportedTypes(ASTNode caller, ASTNode child, String name) { 1090 return true; 1091 } 1092 /** 1093 * @declaredat /home/jesper/git/extendj/java4/frontend/QualifiedNames.jrag:103 1094 * @apilevel internal 1095 */ 1096 public String Define_packageName(ASTNode caller, ASTNode child) { 1097 int childIndex = this.getIndexOfChild(caller); 1098 return packageName(); 1099 } 1100 protected boolean canDefine_packageName(ASTNode caller, ASTNode child) { 1101 return true; 1102 } 1103 /** 1104 * @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36 1105 * @apilevel internal 1106 */ 1107 public NameType Define_nameType(ASTNode caller, ASTNode child) { 1108 if (caller == getImportDeclListNoTransform()) { 1109 // @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:96 1110 int childIndex = caller.getIndexOfChild(child); 1111 return NameType.PACKAGE_NAME; 1112 } 1113 else { 1114 return getParent().Define_nameType(this, caller); 1115 } 1116 } 1117 protected boolean canDefine_nameType(ASTNode caller, ASTNode child) { 1118 return true; 1119 } 1120 /** 1121 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:544 1122 * @apilevel internal 1123 */ 1124 public TypeDecl Define_enclosingType(ASTNode caller, ASTNode child) { 1125 int childIndex = this.getIndexOfChild(caller); 1126 return null; 1127 } 1128 protected boolean canDefine_enclosingType(ASTNode caller, ASTNode child) { 1129 return true; 1130 } 1131 /** 1132 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:569 1133 * @apilevel internal 1134 */ 1135 public boolean Define_isNestedType(ASTNode caller, ASTNode child) { 1136 int childIndex = this.getIndexOfChild(caller); 1137 return false; 1138 } 1139 protected boolean canDefine_isNestedType(ASTNode caller, ASTNode child) { 1140 return true; 1141 } 1142 /** 1143 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:577 1144 * @apilevel internal 1145 */ 1146 public boolean Define_isMemberType(ASTNode caller, ASTNode child) { 1147 if (caller == getTypeDeclListNoTransform()) { 1148 // @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:580 1149 int childIndex = caller.getIndexOfChild(child); 1150 return false; 1151 } 1152 else { 1153 return getParent().Define_isMemberType(this, caller); 1154 } 1155 } 1156 protected boolean canDefine_isMemberType(ASTNode caller, ASTNode child) { 1157 return true; 1158 } 1159 /** 1160 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:591 1161 * @apilevel internal 1162 */ 1163 public boolean Define_isLocalClass(ASTNode caller, ASTNode child) { 1164 int childIndex = this.getIndexOfChild(caller); 1165 return false; 1166 } 1167 protected boolean canDefine_isLocalClass(ASTNode caller, ASTNode child) { 1168 return true; 1169 } 1170 /** 1171 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:622 1172 * @apilevel internal 1173 */ 1174 public String Define_hostPackage(ASTNode caller, ASTNode child) { 1175 int childIndex = this.getIndexOfChild(caller); 1176 return packageName(); 1177 } 1178 protected boolean canDefine_hostPackage(ASTNode caller, ASTNode child) { 1179 return true; 1180 } 1181 /** 1182 * @declaredat /home/jesper/git/extendj/java7/frontend/MultiCatch.jrag:71 1183 * @apilevel internal 1184 */ 1185 public TypeDecl Define_hostType(ASTNode caller, ASTNode child) { 1186 if (caller == getImportDeclListNoTransform()) { 1187 // @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:635 1188 int childIndex = caller.getIndexOfChild(child); 1189 return null; 1190 } 1191 else { 1192 return getParent().Define_hostType(this, caller); 1193 } 1194 } 1195 protected boolean canDefine_hostType(ASTNode caller, ASTNode child) { 1196 return true; 1197 } 1198 /** 1199 * @declaredat /home/jesper/git/extendj/java8/frontend/LookupVariable.jrag:30 1200 * @apilevel internal 1201 */ 1202 public SimpleSet Define_lookupVariable(ASTNode caller, ASTNode child, String name) { 1203 if (caller == getTypeDeclListNoTransform()) { 1204 // @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:172 1205 int childIndex = caller.getIndexOfChild(child); 1206 { 1207 SimpleSet set = importedFields(name); 1208 if (!set.isEmpty()) { 1209 return set; 1210 } 1211 set = importedFieldsOnDemand(name); 1212 if (!set.isEmpty()) { 1213 return set; 1214 } 1215 return lookupVariable(name); 1216 } 1217 } 1218 else { 1219 return getParent().Define_lookupVariable(this, caller, name); 1220 } 1221 } 1222 protected boolean canDefine_lookupVariable(ASTNode caller, ASTNode child, String name) { 1223 return true; 1224 } 1225 /** 1226 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupMethod.jrag:46 1227 * @apilevel internal 1228 */ 1229 public Collection Define_lookupMethod(ASTNode caller, ASTNode child, String name) { 1230 if (caller == getTypeDeclListNoTransform()) { 1231 // @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:214 1232 int childIndex = caller.getIndexOfChild(child); 1233 { 1234 Collection list = importedMethods(name); 1235 if (!list.isEmpty()) { 1236 return list; 1237 } 1238 list = importedMethodsOnDemand(name); 1239 if (!list.isEmpty()) { 1240 return list; 1241 } 1242 return lookupMethod(name); 1243 } 1244 } 1245 else { 1246 return getParent().Define_lookupMethod(this, caller, name); 1247 } 1248 } 1249 protected boolean canDefine_lookupMethod(ASTNode caller, ASTNode child, String name) { 1250 return true; 1251 } 1252 /** 1253 * @declaredat /home/jesper/git/extendj/java8/frontend/EnclosingLambda.jrag:37 1254 * @apilevel internal 1255 */ 1256 public LambdaExpr Define_enclosingLambda(ASTNode caller, ASTNode child) { 1257 int childIndex = this.getIndexOfChild(caller); 1258 return null; 1259 } 1260 protected boolean canDefine_enclosingLambda(ASTNode caller, ASTNode child) { 1261 return true; 1262 } 1263 /** 1264 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:196 1265 * @apilevel internal 1266 */ 1267 public boolean Define_assignmentContext(ASTNode caller, ASTNode child) { 1268 int childIndex = this.getIndexOfChild(caller); 1269 return false; 1270 } 1271 protected boolean canDefine_assignmentContext(ASTNode caller, ASTNode child) { 1272 return true; 1273 } 1274 /** 1275 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:197 1276 * @apilevel internal 1277 */ 1278 public boolean Define_invocationContext(ASTNode caller, ASTNode child) { 1279 int childIndex = this.getIndexOfChild(caller); 1280 return false; 1281 } 1282 protected boolean canDefine_invocationContext(ASTNode caller, ASTNode child) { 1283 return true; 1284 } 1285 /** 1286 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:198 1287 * @apilevel internal 1288 */ 1289 public boolean Define_castContext(ASTNode caller, ASTNode child) { 1290 int childIndex = this.getIndexOfChild(caller); 1291 return false; 1292 } 1293 protected boolean canDefine_castContext(ASTNode caller, ASTNode child) { 1294 return true; 1295 } 1296 /** 1297 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:199 1298 * @apilevel internal 1299 */ 1300 public boolean Define_stringContext(ASTNode caller, ASTNode child) { 1301 int childIndex = this.getIndexOfChild(caller); 1302 return false; 1303 } 1304 protected boolean canDefine_stringContext(ASTNode caller, ASTNode child) { 1305 return true; 1306 } 1307 /** 1308 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:200 1309 * @apilevel internal 1310 */ 1311 public boolean Define_numericContext(ASTNode caller, ASTNode child) { 1312 int childIndex = this.getIndexOfChild(caller); 1313 return false; 1314 } 1315 protected boolean canDefine_numericContext(ASTNode caller, ASTNode child) { 1316 return true; 1317 } 1318 /** 1319 * @declaredat /home/jesper/git/extendj/java8/frontend/TypeVariablePositions.jrag:29 1320 * @apilevel internal 1321 */ 1322 public int Define_typeVarPosition(ASTNode caller, ASTNode child) { 1323 int childIndex = this.getIndexOfChild(caller); 1324 return -1; 1325 } 1326 protected boolean canDefine_typeVarPosition(ASTNode caller, ASTNode child) { 1327 return true; 1328 } 1329 /** 1330 * @declaredat /home/jesper/git/extendj/java8/frontend/TypeVariablePositions.jrag:32 1331 * @apilevel internal 1332 */ 1333 public boolean Define_typeVarInMethod(ASTNode caller, ASTNode child) { 1334 int childIndex = this.getIndexOfChild(caller); 1335 return false; 1336 } 1337 protected boolean canDefine_typeVarInMethod(ASTNode caller, ASTNode child) { 1338 return true; 1339 } 1340 /** 1341 * @declaredat /home/jesper/git/extendj/java8/frontend/TypeVariablePositions.jrag:30 1342 * @apilevel internal 1343 */ 1344 public int Define_genericMethodLevel(ASTNode caller, ASTNode child) { 1345 int childIndex = this.getIndexOfChild(caller); 1346 return 0; 1347 } 1348 protected boolean canDefine_genericMethodLevel(ASTNode caller, ASTNode child) { 1349 return true; 1350 } 1351 /** 1352 * @apilevel internal 1353 */ 1354 public ASTNode rewriteTo() { 1355 return super.rewriteTo(); 1356 } 1357 }