001 /* This file was generated with JastAdd2 (http://jastadd.org) version R20130213 */ 002 package AST; 003 004 import java.util.HashSet; 005 import java.io.File; 006 import java.util.*; 007 import beaver.*; 008 import java.util.ArrayList; 009 import java.util.zip.*; 010 import java.io.*; 011 import java.io.FileNotFoundException; 012 import java.util.Collection; 013 014 /** 015 * @production CompilationUnit : {@link ASTNode} ::= <span class="component"><PackageDecl:java.lang.String></span> <span class="component">{@link ImportDecl}*</span> <span class="component">{@link TypeDecl}*</span>; 016 * @ast node 017 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:4 018 */ 019 public class CompilationUnit extends ASTNode<ASTNode> implements Cloneable { 020 /** 021 * @apilevel low-level 022 */ 023 public void flushCache() { 024 } 025 /** 026 * @apilevel internal 027 */ 028 public void flushCollectionCache() { 029 } 030 /** 031 * @apilevel internal 032 */ 033 @SuppressWarnings({"unchecked", "cast"}) 034 public CompilationUnit clone() throws CloneNotSupportedException { 035 CompilationUnit node = (CompilationUnit)super.clone(); 036 node.packageName_computed = false; 037 node.packageName_value = null; 038 node.destinationPath_computed = false; 039 node.destinationPath_value = null; 040 node.lookupType_String_values = null; 041 node.in$Circle(false); 042 node.is$Final(false); 043 return node; 044 } 045 /** 046 * @apilevel internal 047 */ 048 @SuppressWarnings({"unchecked", "cast"}) 049 public CompilationUnit copy() { 050 051 try { 052 CompilationUnit node = (CompilationUnit) clone(); 053 node.parent = null; 054 if(children != null) 055 node.children = (ASTNode[]) children.clone(); 056 057 return node; 058 } catch (CloneNotSupportedException e) { 059 throw new Error("Error: clone not supported for " + getClass().getName()); 060 } 061 062 }/** 063 * Create a deep copy of the AST subtree at this node. 064 * The copy is dangling, i.e. has no parent. 065 * @return dangling copy of the subtree at this node 066 * @apilevel low-level 067 */ 068 @SuppressWarnings({"unchecked", "cast"}) 069 public CompilationUnit fullCopy() { 070 071 CompilationUnit tree = (CompilationUnit) copy(); 072 if (children != null) { 073 for (int i = 0; i < children.length; ++i) { 074 075 ASTNode child = (ASTNode) children[i]; 076 if(child != null) { 077 child = child.fullCopy(); 078 tree.setChild(child, i); 079 } 080 } 081 } 082 return tree; 083 084 } /** 085 * @ast method 086 * @aspect ClassPath 087 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ClassPath.jrag:159 088 */ 089 090 091 private String relativeName; 092 /** 093 * @ast method 094 * @aspect ClassPath 095 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ClassPath.jrag:160 096 */ 097 098 private String pathName; 099 /** 100 * @ast method 101 * @aspect ClassPath 102 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ClassPath.jrag:161 103 */ 104 105 private boolean fromSource; 106 /** 107 * @ast method 108 * @aspect ClassPath 109 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ClassPath.jrag:163 110 */ 111 public void setRelativeName(String name) { 112 relativeName = name; 113 } 114 /** 115 * @ast method 116 * @aspect ClassPath 117 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ClassPath.jrag:166 118 */ 119 public void setPathName(String name) { 120 pathName = name; 121 } 122 /** 123 * @ast method 124 * @aspect ClassPath 125 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ClassPath.jrag:169 126 */ 127 public void setFromSource(boolean value) { 128 fromSource = value; 129 } 130 /** 131 * @ast method 132 * @aspect ErrorCheck 133 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ErrorCheck.jrag:65 134 */ 135 136 137 protected java.util.ArrayList errors = new java.util.ArrayList(); 138 /** 139 * @ast method 140 * @aspect ErrorCheck 141 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ErrorCheck.jrag:66 142 */ 143 144 protected java.util.ArrayList warnings = new java.util.ArrayList(); 145 /** 146 * @ast method 147 * @aspect ErrorCheck 148 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ErrorCheck.jrag:68 149 */ 150 public Collection parseErrors() { return parseErrors; } 151 /** 152 * @ast method 153 * @aspect ErrorCheck 154 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ErrorCheck.jrag:69 155 */ 156 public void addParseError(Problem msg) { parseErrors.add(msg); } 157 /** 158 * @ast method 159 * @aspect ErrorCheck 160 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ErrorCheck.jrag:70 161 */ 162 163 protected Collection parseErrors = new ArrayList(); 164 /** 165 * @ast method 166 * @aspect ErrorCheck 167 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ErrorCheck.jrag:228 168 */ 169 public void errorCheck(Collection collection) { 170 collectErrors(); 171 collection.addAll(errors); 172 } 173 /** 174 * @ast method 175 * @aspect ErrorCheck 176 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ErrorCheck.jrag:232 177 */ 178 public void errorCheck(Collection err, Collection warn) { 179 collectErrors(); 180 err.addAll(errors); 181 warn.addAll(warnings); 182 } 183 /** 184 * @ast method 185 * @aspect NameCheck 186 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/NameCheck.jrag:35 187 */ 188 public void refined_NameCheck_CompilationUnit_nameCheck() { 189 for(int i = 0; i < getNumImportDecl(); i++) { 190 ImportDecl decl = getImportDecl(i); 191 if(decl instanceof SingleTypeImportDecl) { 192 TypeDecl importedType = decl.getAccess().type(); 193 Iterator iter = localLookupType(importedType.name()).iterator(); 194 while (iter.hasNext()) { 195 TypeDecl local = (TypeDecl) iter.next(); 196 if (local != importedType) 197 error("imported type " + decl + " is conflicting with visible type"); 198 } 199 } 200 } 201 } 202 /** 203 * @ast method 204 * @aspect PrettyPrint 205 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/PrettyPrint.jadd:32 206 */ 207 public void toString(StringBuffer s) { 208 try { 209 if(!getPackageDecl().equals("")) { 210 s.append("package " + getPackageDecl() + ";\n"); 211 } 212 for(int i = 0; i < getNumImportDecl(); i++) { 213 getImportDecl(i).toString(s); 214 } 215 for(int i = 0; i < getNumTypeDecl(); i++) { 216 getTypeDecl(i).toString(s); 217 s.append("\n"); 218 } 219 } catch (NullPointerException e) { 220 System.out.print("Error in compilation unit hosting " + getTypeDecl(0).typeName()); 221 throw e; 222 } 223 } 224 /** 225 * @ast method 226 * @aspect GenerateClassfile 227 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/GenerateClassfile.jrag:18 228 */ 229 public void generateClassfile() { 230 if(fromSource()) { 231 for(int i = 0; i < getNumTypeDecl(); i++) { 232 getTypeDecl(i).generateClassfile(); 233 getTypeDecl(i).clear(); 234 } 235 } 236 } 237 /** 238 * @ast method 239 * @aspect Transformations 240 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/Transformations.jrag:18 241 */ 242 public void transformation() { 243 if(fromSource()) { 244 for(int i = 0; i < getNumTypeDecl(); i++) { 245 getTypeDecl(i).transformation(); 246 } 247 } 248 } 249 /** 250 * @ast method 251 * 252 */ 253 public CompilationUnit() { 254 super(); 255 256 257 } 258 /** 259 * Initializes the child array to the correct size. 260 * Initializes List and Opt nta children. 261 * @apilevel internal 262 * @ast method 263 * @ast method 264 * 265 */ 266 public void init$Children() { 267 children = new ASTNode[2]; 268 setChild(new List(), 0); 269 setChild(new List(), 1); 270 } 271 /** 272 * @ast method 273 * 274 */ 275 public CompilationUnit(java.lang.String p0, List<ImportDecl> p1, List<TypeDecl> p2) { 276 setPackageDecl(p0); 277 setChild(p1, 0); 278 setChild(p2, 1); 279 } 280 /** 281 * @ast method 282 * 283 */ 284 public CompilationUnit(beaver.Symbol p0, List<ImportDecl> p1, List<TypeDecl> p2) { 285 setPackageDecl(p0); 286 setChild(p1, 0); 287 setChild(p2, 1); 288 } 289 /** 290 * @apilevel low-level 291 * @ast method 292 * 293 */ 294 protected int numChildren() { 295 return 2; 296 } 297 /** 298 * @apilevel internal 299 * @ast method 300 * 301 */ 302 public boolean mayHaveRewrite() { 303 return false; 304 } 305 /** 306 * Replaces the lexeme PackageDecl. 307 * @param value The new value for the lexeme PackageDecl. 308 * @apilevel high-level 309 * @ast method 310 * 311 */ 312 public void setPackageDecl(java.lang.String value) { 313 tokenjava_lang_String_PackageDecl = value; 314 } 315 /** 316 * @apilevel internal 317 * @ast method 318 * 319 */ 320 321 /** 322 * @apilevel internal 323 */ 324 protected java.lang.String tokenjava_lang_String_PackageDecl; 325 /** 326 * @ast method 327 * 328 */ 329 330 public int PackageDeclstart; 331 /** 332 * @ast method 333 * 334 */ 335 336 public int PackageDeclend; 337 /** 338 * JastAdd-internal setter for lexeme PackageDecl using the Beaver parser. 339 * @apilevel internal 340 * @ast method 341 * 342 */ 343 public void setPackageDecl(beaver.Symbol symbol) { 344 if(symbol.value != null && !(symbol.value instanceof String)) 345 throw new UnsupportedOperationException("setPackageDecl is only valid for String lexemes"); 346 tokenjava_lang_String_PackageDecl = (String)symbol.value; 347 PackageDeclstart = symbol.getStart(); 348 PackageDeclend = symbol.getEnd(); 349 } 350 /** 351 * Retrieves the value for the lexeme PackageDecl. 352 * @return The value for the lexeme PackageDecl. 353 * @apilevel high-level 354 * @ast method 355 * 356 */ 357 public java.lang.String getPackageDecl() { 358 return tokenjava_lang_String_PackageDecl != null ? tokenjava_lang_String_PackageDecl : ""; 359 } 360 /** 361 * Replaces the ImportDecl list. 362 * @param list The new list node to be used as the ImportDecl list. 363 * @apilevel high-level 364 * @ast method 365 * 366 */ 367 public void setImportDeclList(List<ImportDecl> list) { 368 setChild(list, 0); 369 } 370 /** 371 * Retrieves the number of children in the ImportDecl list. 372 * @return Number of children in the ImportDecl list. 373 * @apilevel high-level 374 * @ast method 375 * 376 */ 377 public int getNumImportDecl() { 378 return getImportDeclList().getNumChild(); 379 } 380 /** 381 * Retrieves the number of children in the ImportDecl list. 382 * Calling this method will not trigger rewrites.. 383 * @return Number of children in the ImportDecl list. 384 * @apilevel low-level 385 * @ast method 386 * 387 */ 388 public int getNumImportDeclNoTransform() { 389 return getImportDeclListNoTransform().getNumChildNoTransform(); 390 } 391 /** 392 * Retrieves the element at index {@code i} in the ImportDecl list.. 393 * @param i Index of the element to return. 394 * @return The element at position {@code i} in the ImportDecl list. 395 * @apilevel high-level 396 * @ast method 397 * 398 */ 399 @SuppressWarnings({"unchecked", "cast"}) 400 public ImportDecl getImportDecl(int i) { 401 return (ImportDecl)getImportDeclList().getChild(i); 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 * @ast method 408 * 409 */ 410 public void addImportDecl(ImportDecl node) { 411 List<ImportDecl> list = (parent == null || state == null) ? getImportDeclListNoTransform() : getImportDeclList(); 412 list.addChild(node); 413 } 414 /** 415 * @apilevel low-level 416 * @ast method 417 * 418 */ 419 public void addImportDeclNoTransform(ImportDecl node) { 420 List<ImportDecl> list = getImportDeclListNoTransform(); 421 list.addChild(node); 422 } 423 /** 424 * Replaces the ImportDecl list element at index {@code i} with the new node {@code node}. 425 * @param node The new node to replace the old list element. 426 * @param i The list index of the node to be replaced. 427 * @apilevel high-level 428 * @ast method 429 * 430 */ 431 public void setImportDecl(ImportDecl node, int i) { 432 List<ImportDecl> list = getImportDeclList(); 433 list.setChild(node, i); 434 } 435 /** 436 * Retrieves the ImportDecl list. 437 * @return The node representing the ImportDecl list. 438 * @apilevel high-level 439 * @ast method 440 * 441 */ 442 public List<ImportDecl> getImportDecls() { 443 return getImportDeclList(); 444 } 445 /** 446 * Retrieves the ImportDecl list. 447 * <p><em>This method does not invoke AST transformations.</em></p> 448 * @return The node representing the ImportDecl list. 449 * @apilevel low-level 450 * @ast method 451 * 452 */ 453 public List<ImportDecl> getImportDeclsNoTransform() { 454 return getImportDeclListNoTransform(); 455 } 456 /** 457 * Retrieves the ImportDecl list. 458 * @return The node representing the ImportDecl list. 459 * @apilevel high-level 460 * @ast method 461 * 462 */ 463 @SuppressWarnings({"unchecked", "cast"}) 464 public List<ImportDecl> getImportDeclList() { 465 List<ImportDecl> list = (List<ImportDecl>)getChild(0); 466 list.getNumChild(); 467 return list; 468 } 469 /** 470 * Retrieves the ImportDecl list. 471 * <p><em>This method does not invoke AST transformations.</em></p> 472 * @return The node representing the ImportDecl list. 473 * @apilevel low-level 474 * @ast method 475 * 476 */ 477 @SuppressWarnings({"unchecked", "cast"}) 478 public List<ImportDecl> getImportDeclListNoTransform() { 479 return (List<ImportDecl>)getChildNoTransform(0); 480 } 481 /** 482 * Replaces the TypeDecl list. 483 * @param list The new list node to be used as the TypeDecl list. 484 * @apilevel high-level 485 * @ast method 486 * 487 */ 488 public void setTypeDeclList(List<TypeDecl> list) { 489 setChild(list, 1); 490 } 491 /** 492 * Retrieves the number of children in the TypeDecl list. 493 * @return Number of children in the TypeDecl list. 494 * @apilevel high-level 495 * @ast method 496 * 497 */ 498 public int getNumTypeDecl() { 499 return getTypeDeclList().getNumChild(); 500 } 501 /** 502 * Retrieves the number of children in the TypeDecl list. 503 * Calling this method will not trigger rewrites.. 504 * @return Number of children in the TypeDecl list. 505 * @apilevel low-level 506 * @ast method 507 * 508 */ 509 public int getNumTypeDeclNoTransform() { 510 return getTypeDeclListNoTransform().getNumChildNoTransform(); 511 } 512 /** 513 * Retrieves the element at index {@code i} in the TypeDecl list.. 514 * @param i Index of the element to return. 515 * @return The element at position {@code i} in the TypeDecl list. 516 * @apilevel high-level 517 * @ast method 518 * 519 */ 520 @SuppressWarnings({"unchecked", "cast"}) 521 public TypeDecl getTypeDecl(int i) { 522 return (TypeDecl)getTypeDeclList().getChild(i); 523 } 524 /** 525 * Append an element to the TypeDecl list. 526 * @param node The element to append to the TypeDecl list. 527 * @apilevel high-level 528 * @ast method 529 * 530 */ 531 public void addTypeDecl(TypeDecl node) { 532 List<TypeDecl> list = (parent == null || state == null) ? getTypeDeclListNoTransform() : getTypeDeclList(); 533 list.addChild(node); 534 } 535 /** 536 * @apilevel low-level 537 * @ast method 538 * 539 */ 540 public void addTypeDeclNoTransform(TypeDecl node) { 541 List<TypeDecl> list = getTypeDeclListNoTransform(); 542 list.addChild(node); 543 } 544 /** 545 * Replaces the TypeDecl list element at index {@code i} with the new node {@code node}. 546 * @param node The new node to replace the old list element. 547 * @param i The list index of the node to be replaced. 548 * @apilevel high-level 549 * @ast method 550 * 551 */ 552 public void setTypeDecl(TypeDecl node, int i) { 553 List<TypeDecl> list = getTypeDeclList(); 554 list.setChild(node, i); 555 } 556 /** 557 * Retrieves the TypeDecl list. 558 * @return The node representing the TypeDecl list. 559 * @apilevel high-level 560 * @ast method 561 * 562 */ 563 public List<TypeDecl> getTypeDecls() { 564 return getTypeDeclList(); 565 } 566 /** 567 * Retrieves the TypeDecl list. 568 * <p><em>This method does not invoke AST transformations.</em></p> 569 * @return The node representing the TypeDecl list. 570 * @apilevel low-level 571 * @ast method 572 * 573 */ 574 public List<TypeDecl> getTypeDeclsNoTransform() { 575 return getTypeDeclListNoTransform(); 576 } 577 /** 578 * Retrieves the TypeDecl list. 579 * @return The node representing the TypeDecl list. 580 * @apilevel high-level 581 * @ast method 582 * 583 */ 584 @SuppressWarnings({"unchecked", "cast"}) 585 public List<TypeDecl> getTypeDeclList() { 586 List<TypeDecl> list = (List<TypeDecl>)getChild(1); 587 list.getNumChild(); 588 return list; 589 } 590 /** 591 * Retrieves the TypeDecl list. 592 * <p><em>This method does not invoke AST transformations.</em></p> 593 * @return The node representing the TypeDecl list. 594 * @apilevel low-level 595 * @ast method 596 * 597 */ 598 @SuppressWarnings({"unchecked", "cast"}) 599 public List<TypeDecl> getTypeDeclListNoTransform() { 600 return (List<TypeDecl>)getChildNoTransform(1); 601 } 602 /** 603 * @ast method 604 * @aspect StaticImports 605 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.jrag:181 606 */ 607 public void nameCheck() { 608 refined_NameCheck_CompilationUnit_nameCheck(); 609 for(int i = 0; i < getNumImportDecl(); i++) { 610 if(getImportDecl(i) instanceof SingleStaticImportDecl) { 611 SingleStaticImportDecl decl = (SingleStaticImportDecl)getImportDecl(i); 612 String name = decl.name(); 613 if(!decl.importedTypes(name).isEmpty()) { 614 TypeDecl type = (TypeDecl)decl.importedTypes(name).iterator().next(); 615 if(localLookupType(name).contains(type)) 616 decl.error(packageName() + "." + name + " is already defined in this compilation unit"); 617 } 618 } 619 } 620 } 621 /** 622 * @ast method 623 * @aspect TypeScopePropagation 624 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupType.jrag:270 625 */ 626 private SimpleSet refined_TypeScopePropagation_CompilationUnit_Child_lookupType_String(String name) 627 { 628 // locally declared types in compilation unit 629 SimpleSet set = localLookupType(name); 630 if(!set.isEmpty()) return set; 631 632 // imported types 633 set = importedTypes(name); 634 if(!set.isEmpty()) return set; 635 636 // types in the same package 637 TypeDecl result = lookupType(packageName(), name); 638 if(result != null && result.accessibleFromPackage(packageName())) 639 return SimpleSet.emptySet.add(result); 640 641 // types imported on demand 642 set = importedTypesOnDemand(name); 643 if(!set.isEmpty()) return set; 644 645 // include primitive types 646 result = lookupType(PRIMITIVE_PACKAGE_NAME, name); 647 if(result != null) return SimpleSet.emptySet.add(result); 648 649 // 7.5.5 Automatic Imports 650 result = lookupType("java.lang", name); 651 if(result != null && result.accessibleFromPackage(packageName())) 652 return SimpleSet.emptySet.add(result); 653 return lookupType(name); 654 } 655 /** 656 * @attribute syn 657 * @aspect ClassPath 658 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ClassPath.jrag:27 659 */ 660 public String relativeName() { 661 ASTNode$State state = state(); 662 try { return relativeName; } 663 finally { 664 } 665 } 666 /** 667 * @attribute syn 668 * @aspect ClassPath 669 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ClassPath.jrag:28 670 */ 671 public String pathName() { 672 ASTNode$State state = state(); 673 try { return pathName; } 674 finally { 675 } 676 } 677 /** 678 * @attribute syn 679 * @aspect ClassPath 680 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ClassPath.jrag:29 681 */ 682 public boolean fromSource() { 683 ASTNode$State state = state(); 684 try { return fromSource; } 685 finally { 686 } 687 } 688 /** 689 * @attribute syn 690 * @aspect TypeScopePropagation 691 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupType.jrag:299 692 */ 693 public SimpleSet localLookupType(String name) { 694 ASTNode$State state = state(); 695 try { 696 for(int i = 0; i < getNumTypeDecl(); i++) 697 if(getTypeDecl(i).name().equals(name)) 698 return SimpleSet.emptySet.add(getTypeDecl(i)); 699 return SimpleSet.emptySet; 700 } 701 finally { 702 } 703 } 704 /** 705 * @attribute syn 706 * @aspect TypeScopePropagation 707 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupType.jrag:306 708 */ 709 public SimpleSet importedTypes(String name) { 710 ASTNode$State state = state(); 711 try { 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 return set; 718 } 719 finally { 720 } 721 } 722 /** 723 * @attribute syn 724 * @aspect TypeScopePropagation 725 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupType.jrag:314 726 */ 727 public SimpleSet importedTypesOnDemand(String name) { 728 ASTNode$State state = state(); 729 try { 730 SimpleSet set = SimpleSet.emptySet; 731 for(int i = 0; i < getNumImportDecl(); i++) 732 if(getImportDecl(i).isOnDemand()) 733 for(Iterator iter = getImportDecl(i).importedTypes(name).iterator(); iter.hasNext(); ) 734 set = set.add(iter.next()); 735 return set; 736 } 737 finally { 738 } 739 } 740 /** 741 * @attribute syn 742 * @aspect PrettyPrint 743 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/PrettyPrint.jadd:800 744 */ 745 public String dumpString() { 746 ASTNode$State state = state(); 747 try { return getClass().getName() + " [" + getPackageDecl() + "]"; } 748 finally { 749 } 750 } 751 /** 752 * @apilevel internal 753 */ 754 protected boolean packageName_computed = false; 755 /** 756 * @apilevel internal 757 */ 758 protected String packageName_value; 759 /** 760 * @attribute syn 761 * @aspect TypeName 762 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/QualifiedNames.jrag:92 763 */ 764 @SuppressWarnings({"unchecked", "cast"}) 765 public String packageName() { 766 if(packageName_computed) { 767 return packageName_value; 768 } 769 ASTNode$State state = state(); 770 int num = state.boundariesCrossed; 771 boolean isFinal = this.is$Final(); 772 packageName_value = packageName_compute(); 773 if(isFinal && num == state().boundariesCrossed){ packageName_computed = true; } 774 return packageName_value; 775 } 776 /** 777 * @apilevel internal 778 */ 779 private String packageName_compute() {return getPackageDecl();} 780 /** 781 * @apilevel internal 782 */ 783 protected boolean destinationPath_computed = false; 784 /** 785 * @apilevel internal 786 */ 787 protected String destinationPath_value; 788 /** 789 * @attribute syn 790 * @aspect ConstantPoolNames 791 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/ConstantPoolNames.jrag:68 792 */ 793 @SuppressWarnings({"unchecked", "cast"}) 794 public String destinationPath() { 795 if(destinationPath_computed) { 796 return destinationPath_value; 797 } 798 ASTNode$State state = state(); 799 int num = state.boundariesCrossed; 800 boolean isFinal = this.is$Final(); 801 destinationPath_value = destinationPath_compute(); 802 if(isFinal && num == state().boundariesCrossed){ destinationPath_computed = true; } 803 return destinationPath_value; 804 } 805 /** 806 * @apilevel internal 807 */ 808 private String destinationPath_compute() { 809 if(options().hasValueForOption("-d")) { 810 return options().getValueForOption("-d"); 811 } 812 else { 813 if(fromSource()) { 814 // /home/torbjorn/sandbox/JavaCompiler/JCK/javasoft/sqe/tests/lang/icls045/icls04591m11/icls04591m11_c.java 815 // package javasoft.sqe.tests.lang.icls045.icls04591m11_p class icls04591m11_c 816 // /home/torbjorn/sandbox/JavaCompiler/JCK/javasoft/sqe/tests/lang/icls045/icls04591m11/icls04591m11.java 817 // package javasoft.sqe.tests.lang.icls045.icls04591m11 class icls04591m11 818 819 // ta paketnamnet p och om det har fler \ufffdn 3 delar s\ufffd kontrollera om det finns som substring i pathen 820 // anv\ufffdnd i s\ufffd fall den delen av pathen 821 // forts\ufffdtt genom att ta bort sista delen i paketnamnet och g\ufffdr om proceduren 822 // sluta n\ufffdr namnet \ufffdr mindre \ufffdr 3 eller mindre 823 824 String sourceName = pathName(); //relativeName(); // ex AST/Defines_AST_hello 825 // extract source path including package directories 826 String sourcePath = null; 827 if(sourceName.lastIndexOf(java.io.File.separator) == -1) 828 sourcePath = "."; 829 else 830 sourcePath = sourceName.substring(0, sourceName.lastIndexOf(java.io.File.separator)); 831 String sourcePathPattern = sourcePath.replace(java.io.File.separatorChar, '.'); 832 String[] parts = packageName().split("\\."); 833 int num = parts.length; 834 while(num > 3) { 835 StringBuffer packagePattern = new StringBuffer(); 836 for(int i = 0; i < num; i++) { 837 if(i != 0) packagePattern.append("."); 838 packagePattern.append(parts[i]); 839 } 840 int index = sourcePathPattern.lastIndexOf(packagePattern.toString()); 841 if(index > 0) { 842 return sourcePath.substring(0, index-1); 843 } 844 num--; 845 } 846 847 //System.err.println("SourcePath: " + sourcePath); 848 //String[] parts = packageName().split("\\."); 849 int k = parts.length - 1; 850 while(k >= 0 && !sourcePath.endsWith(parts[k])) { 851 //System.err.println(sourcePath + " does not end with " + parts[k]); 852 k--; 853 } 854 if(k >= 0) { 855 for(int i = k; i >= 0; i--) { 856 sourcePath = sourcePath.substring(0, sourcePath.lastIndexOf(parts[i])); 857 //System.err.println("new candidate is " + sourcePath); 858 } 859 } 860 if(sourcePath.equals("")) 861 sourcePath = "."; 862 //System.err.println("SourcePath after: " + sourcePath); 863 return sourcePath; 864 /* 865 // extract first part of package name 866 String prefix; 867 int pos = packageName().indexOf('.'); // AST 868 if(pos != -1) 869 prefix = packageName().substring(0, pos-1); 870 else 871 prefix = packageName(); 872 // add separator 873 prefix = prefix + java.io.File.separator; 874 // find last occurance 875 pos = sourceName.lastIndexOf(prefix); 876 if(pos > 0 && !packageName().equals("")) 877 return sourceName.substring(0, pos-1); 878 */ 879 } 880 if(pathName != null) 881 return pathName; 882 else 883 return "."; 884 } 885 } 886 /** 887 * @attribute syn 888 * @aspect StaticImports 889 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.jrag:112 890 */ 891 public SimpleSet importedFields(String name) { 892 ASTNode$State state = state(); 893 try { 894 SimpleSet set = SimpleSet.emptySet; 895 for(int i = 0; i < getNumImportDecl(); i++) 896 if(!getImportDecl(i).isOnDemand()) 897 for(Iterator iter = getImportDecl(i).importedFields(name).iterator(); iter.hasNext(); ) 898 set = set.add(iter.next()); 899 return set; 900 } 901 finally { 902 } 903 } 904 /** 905 * @attribute syn 906 * @aspect StaticImports 907 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.jrag:120 908 */ 909 public SimpleSet importedFieldsOnDemand(String name) { 910 ASTNode$State state = state(); 911 try { 912 SimpleSet set = SimpleSet.emptySet; 913 for(int i = 0; i < getNumImportDecl(); i++) 914 if(getImportDecl(i).isOnDemand()) 915 for(Iterator iter = getImportDecl(i).importedFields(name).iterator(); iter.hasNext(); ) 916 set = set.add(iter.next()); 917 return set; 918 } 919 finally { 920 } 921 } 922 /** 923 * @attribute syn 924 * @aspect StaticImports 925 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.jrag:141 926 */ 927 public Collection importedMethods(String name) { 928 ASTNode$State state = state(); 929 try { 930 Collection list = new ArrayList(); 931 for(int i = 0; i < getNumImportDecl(); i++) 932 if(!getImportDecl(i).isOnDemand()) 933 list.addAll(getImportDecl(i).importedMethods(name)); 934 return list; 935 } 936 finally { 937 } 938 } 939 /** 940 * @attribute syn 941 * @aspect StaticImports 942 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.jrag:148 943 */ 944 public Collection importedMethodsOnDemand(String name) { 945 ASTNode$State state = state(); 946 try { 947 Collection list = new ArrayList(); 948 for(int i = 0; i < getNumImportDecl(); i++) 949 if(getImportDecl(i).isOnDemand()) 950 list.addAll(getImportDecl(i).importedMethods(name)); 951 return list; 952 } 953 finally { 954 } 955 } 956 /** 957 * @attribute inh 958 * @aspect LookupFullyQualifiedTypes 959 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupType.jrag:99 960 */ 961 @SuppressWarnings({"unchecked", "cast"}) 962 public TypeDecl lookupType(String packageName, String typeName) { 963 ASTNode$State state = state(); 964 TypeDecl lookupType_String_String_value = getParent().Define_TypeDecl_lookupType(this, null, packageName, typeName); 965 return lookupType_String_String_value; 966 } 967 protected java.util.Map lookupType_String_values; 968 /** 969 * @attribute inh 970 * @aspect TypeScopePropagation 971 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupType.jrag:259 972 */ 973 @SuppressWarnings({"unchecked", "cast"}) 974 public SimpleSet lookupType(String name) { 975 Object _parameters = name; 976 if(lookupType_String_values == null) lookupType_String_values = new java.util.HashMap(4); 977 if(lookupType_String_values.containsKey(_parameters)) { 978 return (SimpleSet)lookupType_String_values.get(_parameters); 979 } 980 ASTNode$State state = state(); 981 int num = state.boundariesCrossed; 982 boolean isFinal = this.is$Final(); 983 SimpleSet lookupType_String_value = getParent().Define_SimpleSet_lookupType(this, null, name); 984 if(isFinal && num == state().boundariesCrossed){ lookupType_String_values.put(_parameters, lookupType_String_value); } 985 return lookupType_String_value; 986 } 987 /** 988 * @attribute inh 989 * @aspect StaticImports 990 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.jrag:111 991 */ 992 @SuppressWarnings({"unchecked", "cast"}) 993 public SimpleSet lookupVariable(String name) { 994 ASTNode$State state = state(); 995 SimpleSet lookupVariable_String_value = getParent().Define_SimpleSet_lookupVariable(this, null, name); 996 return lookupVariable_String_value; 997 } 998 /** 999 * @attribute inh 1000 * @aspect StaticImports 1001 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.jrag:140 1002 */ 1003 @SuppressWarnings({"unchecked", "cast"}) 1004 public Collection lookupMethod(String name) { 1005 ASTNode$State state = state(); 1006 Collection lookupMethod_String_value = getParent().Define_Collection_lookupMethod(this, null, name); 1007 return lookupMethod_String_value; 1008 } 1009 /** 1010 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ClassPath.jrag:32 1011 * @apilevel internal 1012 */ 1013 public CompilationUnit Define_CompilationUnit_compilationUnit(ASTNode caller, ASTNode child) { 1014 { 1015 int childIndex = this.getIndexOfChild(caller); 1016 return this; 1017 } 1018 } 1019 /** 1020 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:51 1021 * @apilevel internal 1022 */ 1023 public boolean Define_boolean_isIncOrDec(ASTNode caller, ASTNode child) { 1024 if(caller == getTypeDeclListNoTransform()) { 1025 int childIndex = caller.getIndexOfChild(child); 1026 return false; 1027 } 1028 else { return getParent().Define_boolean_isIncOrDec(this, caller); 1029 } 1030 } 1031 /** 1032 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.jrag:198 1033 * @apilevel internal 1034 */ 1035 public boolean Define_boolean_handlesException(ASTNode caller, ASTNode child, TypeDecl exceptionType) { 1036 if(caller == getImportDeclListNoTransform()) { 1037 int childIndex = caller.getIndexOfChild(child); 1038 { 1039 return !exceptionType.isUncheckedException(); 1040 } 1041 } 1042 else if(caller == getTypeDeclListNoTransform()) { 1043 int childIndex = caller.getIndexOfChild(child); 1044 return !exceptionType.isUncheckedException(); 1045 } 1046 else { return getParent().Define_boolean_handlesException(this, caller, exceptionType); 1047 } 1048 } 1049 /** 1050 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupType.jrag:355 1051 * @apilevel internal 1052 */ 1053 public SimpleSet Define_SimpleSet_lookupType(ASTNode caller, ASTNode child, String name) { 1054 if(caller == getImportDeclListNoTransform()) { 1055 int childIndex = caller.getIndexOfChild(child); 1056 return lookupType(name); 1057 } 1058 else { 1059 int childIndex = this.getIndexOfChild(caller); 1060 { 1061 SimpleSet result = SimpleSet.emptySet; 1062 for(Iterator iter = refined_TypeScopePropagation_CompilationUnit_Child_lookupType_String(name).iterator(); iter.hasNext(); ) { 1063 TypeDecl typeDecl = (TypeDecl)iter.next(); 1064 if(typeDecl instanceof ParTypeDecl) 1065 result = result.add(((ParTypeDecl)typeDecl).genericDecl()); 1066 else 1067 result = result.add(typeDecl); 1068 } 1069 return result; 1070 } 1071 } 1072 } 1073 /** 1074 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/NameCheck.jrag:27 1075 * @apilevel internal 1076 */ 1077 public SimpleSet Define_SimpleSet_allImportedTypes(ASTNode caller, ASTNode child, String name) { 1078 if(caller == getImportDeclListNoTransform()) { 1079 int childIndex = caller.getIndexOfChild(child); 1080 return importedTypes(name); 1081 } 1082 else { return getParent().Define_SimpleSet_allImportedTypes(this, caller, name); 1083 } 1084 } 1085 /** 1086 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/QualifiedNames.jrag:90 1087 * @apilevel internal 1088 */ 1089 public String Define_String_packageName(ASTNode caller, ASTNode child) { 1090 { 1091 int childIndex = this.getIndexOfChild(caller); 1092 return packageName(); 1093 } 1094 } 1095 /** 1096 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/SyntacticClassification.jrag:69 1097 * @apilevel internal 1098 */ 1099 public NameType Define_NameType_nameType(ASTNode caller, ASTNode child) { 1100 if(caller == getImportDeclListNoTransform()) { 1101 int childIndex = caller.getIndexOfChild(child); 1102 return NameType.PACKAGE_NAME; 1103 } 1104 else { return getParent().Define_NameType_nameType(this, caller); 1105 } 1106 } 1107 /** 1108 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:493 1109 * @apilevel internal 1110 */ 1111 public TypeDecl Define_TypeDecl_enclosingType(ASTNode caller, ASTNode child) { 1112 { 1113 int childIndex = this.getIndexOfChild(caller); 1114 return null; 1115 } 1116 } 1117 /** 1118 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:519 1119 * @apilevel internal 1120 */ 1121 public boolean Define_boolean_isNestedType(ASTNode caller, ASTNode child) { 1122 { 1123 int childIndex = this.getIndexOfChild(caller); 1124 return false; 1125 } 1126 } 1127 /** 1128 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:529 1129 * @apilevel internal 1130 */ 1131 public boolean Define_boolean_isMemberType(ASTNode caller, ASTNode child) { 1132 if(caller == getTypeDeclListNoTransform()) { 1133 int childIndex = caller.getIndexOfChild(child); 1134 return false; 1135 } 1136 else { return getParent().Define_boolean_isMemberType(this, caller); 1137 } 1138 } 1139 /** 1140 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:541 1141 * @apilevel internal 1142 */ 1143 public boolean Define_boolean_isLocalClass(ASTNode caller, ASTNode child) { 1144 { 1145 int childIndex = this.getIndexOfChild(caller); 1146 return false; 1147 } 1148 } 1149 /** 1150 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:563 1151 * @apilevel internal 1152 */ 1153 public String Define_String_hostPackage(ASTNode caller, ASTNode child) { 1154 { 1155 int childIndex = this.getIndexOfChild(caller); 1156 return packageName(); 1157 } 1158 } 1159 /** 1160 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:583 1161 * @apilevel internal 1162 */ 1163 public TypeDecl Define_TypeDecl_hostType(ASTNode caller, ASTNode child) { 1164 if(caller == getImportDeclListNoTransform()) { 1165 int childIndex = caller.getIndexOfChild(child); 1166 return null; 1167 } 1168 else { return getParent().Define_TypeDecl_hostType(this, caller); 1169 } 1170 } 1171 /** 1172 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/ConstantPoolNames.jrag:66 1173 * @apilevel internal 1174 */ 1175 public String Define_String_destinationPath(ASTNode caller, ASTNode child) { 1176 if(caller == getImportDeclListNoTransform()) { 1177 int index = caller.getIndexOfChild(child); 1178 return destinationPath(); 1179 } 1180 else if(caller == getTypeDeclListNoTransform()) { 1181 int index = caller.getIndexOfChild(child); 1182 return destinationPath(); 1183 } 1184 else { return getParent().Define_String_destinationPath(this, caller); 1185 } 1186 } 1187 /** 1188 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.jrag:104 1189 * @apilevel internal 1190 */ 1191 public SimpleSet Define_SimpleSet_lookupVariable(ASTNode caller, ASTNode child, String name) { 1192 if(caller == getTypeDeclListNoTransform()) { 1193 int childIndex = caller.getIndexOfChild(child); 1194 { 1195 SimpleSet set = importedFields(name); 1196 if(!set.isEmpty()) return set; 1197 set = importedFieldsOnDemand(name); 1198 if(!set.isEmpty()) return set; 1199 return lookupVariable(name); 1200 } 1201 } 1202 else { return getParent().Define_SimpleSet_lookupVariable(this, caller, name); 1203 } 1204 } 1205 /** 1206 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.jrag:133 1207 * @apilevel internal 1208 */ 1209 public Collection Define_Collection_lookupMethod(ASTNode caller, ASTNode child, String name) { 1210 if(caller == getTypeDeclListNoTransform()) { 1211 int childIndex = caller.getIndexOfChild(child); 1212 { 1213 Collection list = importedMethods(name); 1214 if(!list.isEmpty()) return list; 1215 list = importedMethodsOnDemand(name); 1216 if(!list.isEmpty()) return list; 1217 return lookupMethod(name); 1218 } 1219 } 1220 else { return getParent().Define_Collection_lookupMethod(this, caller, name); 1221 } 1222 } 1223 /** 1224 * @apilevel internal 1225 */ 1226 public ASTNode rewriteTo() { 1227 return super.rewriteTo(); 1228 } 1229 }