1 24 25 package org.aspectj.compiler.base.ast; 26 27 import org.aspectj.compiler.base.*; 28 import org.aspectj.compiler.base.cst.*; 29 30 35 36 public class Import extends ASTObject { 37 38 public void checkSpec() { 39 if (!getStar()) { 40 getType(); 41 } else { 42 } 44 } 45 46 public boolean capturesId(String id) { 47 return typeName.getId().equals(id); 48 } 49 50 public Scope makeTypeNameScope() { 51 return new Scope(getCompiler(), null) { 52 public Type findType(String name, ASTObject fromWhere) { 53 return this.getTypeManager().findType(null, name); 54 } 55 public Expr bindUnqualifiedName(String name, ASTObject fromWhere) { 56 return null; 57 } 58 }; 59 } 60 61 private Type myType = null; 62 public Type getType() { 63 if (myType == null) { 64 myType = typeName.resolveType(makeTypeNameScope()); 65 66 if (myType == null) { 67 showError("type not found"); 68 } else if (getOptions().strict) { 69 if (myType.getPackageName() == null) { 70 showError("import from default package not allowed"); 71 } 72 } 73 } 74 75 return myType; 76 } 77 78 public String getName() { 79 return typeName.toString(); 80 } 81 82 public void unparse(CodeWriter writer) { 83 writer.writeKeyword("import"); 84 writer.requiredSpace(); 85 writer.write(typeName.toString()); 86 if (star) writer.write(".*"); 87 writer.closeStmt(); 88 writer.newLine(); 89 } 90 91 protected Name typeName; 93 public Name getTypeName() { return typeName; } 94 public void setTypeName(Name _typeName) { typeName = _typeName; } 95 96 protected boolean star; 97 public boolean getStar() { return star; } 98 public void setStar(boolean _star) { star = _star; } 99 100 public Import(SourceLocation location, Name _typeName, boolean _star) { 101 super(location); 102 setTypeName(_typeName); 103 setStar(_star); 104 } 105 protected Import(SourceLocation source) { 106 super(source); 107 } 108 109 public ASTObject copyWalk(CopyWalker walker) { 110 Import ret = new Import(getSourceLocation()); 111 ret.preCopy(walker, this); 112 ret.typeName = typeName; 113 ret.star = star; 114 return ret; 115 } 116 117 118 public String getDefaultDisplayName() { 119 return "Import(typeName: "+typeName+", "+"star: "+star+")"; 120 } 121 122 } 124 | Popular Tags |