src/share/classes/com/sun/tools/javac/code/Symbol.java

changeset 80
5c9cdeb740f2
parent 54
eaf608c64fec
child 94
6542933af8f4
equal deleted inserted replaced
79:36df13bde238 80:5c9cdeb740f2
138 public String toString() { 138 public String toString() {
139 return name.toString(); 139 return name.toString();
140 } 140 }
141 141
142 /** A Java source description of the location of this symbol; used for 142 /** A Java source description of the location of this symbol; used for
143 * error reporting. Use of this method may result in the loss of the 143 * error reporting.
144 * symbol's description. 144 *
145 */ 145 * @return null if the symbol is a package or a toplevel class defined in
146 public String location() { 146 * the default package; otherwise, the owner symbol is returned
147 */
148 public Symbol location() {
147 if (owner.name == null || (owner.name.len == 0 && owner.kind != PCK)) { 149 if (owner.name == null || (owner.name.len == 0 && owner.kind != PCK)) {
148 return ""; 150 return null;
149 } 151 }
150 return owner.toString(); 152 return owner;
151 } 153 }
152 154
153 public String location(Type site, Types types) { 155 public Symbol location(Type site, Types types) {
154 if (owner.name == null || owner.name.len == 0) { 156 if (owner.name == null || owner.name.len == 0) {
155 return location(); 157 return location();
156 } 158 }
157 if (owner.type.tag == CLASS) { 159 if (owner.type.tag == CLASS) {
158 Type ownertype = types.asOuterSuper(site, owner); 160 Type ownertype = types.asOuterSuper(site, owner);
159 if (ownertype != null) return ownertype.toString(); 161 if (ownertype != null) return ownertype.tsym;
160 } 162 }
161 return owner.toString(); 163 return owner;
162 } 164 }
163 165
164 /** The symbol's erased type. 166 /** The symbol's erased type.
165 */ 167 */
166 public Type erasure(Types types) { 168 public Type erasure(Types types) {
449 public DelegatedSymbol(Symbol other) { 451 public DelegatedSymbol(Symbol other) {
450 super(other.kind, other.flags_field, other.name, other.type, other.owner); 452 super(other.kind, other.flags_field, other.name, other.type, other.owner);
451 this.other = other; 453 this.other = other;
452 } 454 }
453 public String toString() { return other.toString(); } 455 public String toString() { return other.toString(); }
454 public String location() { return other.location(); } 456 public Symbol location() { return other.location(); }
455 public String location(Type site, Types types) { return other.location(site, types); } 457 public Symbol location(Type site, Types types) { return other.location(site, types); }
456 public Type erasure(Types types) { return other.erasure(types); } 458 public Type erasure(Types types) { return other.erasure(types); }
457 public Type externalType(Types types) { return other.externalType(types); } 459 public Type externalType(Types types) { return other.externalType(types); }
458 public boolean isLocal() { return other.isLocal(); } 460 public boolean isLocal() { return other.isLocal(); }
459 public boolean isConstructor() { return other.isConstructor(); } 461 public boolean isConstructor() { return other.isConstructor(); }
460 public Name getQualifiedName() { return other.getQualifiedName(); } 462 public Name getQualifiedName() { return other.getQualifiedName(); }

mercurial