Lines 15-22
Link Here
|
15 |
|
15 |
|
16 |
import org.eclipse.jdt.core.IJavaElement; |
16 |
import org.eclipse.jdt.core.IJavaElement; |
17 |
import org.eclipse.jdt.core.JavaModelException; |
17 |
import org.eclipse.jdt.core.JavaModelException; |
|
|
18 |
import org.eclipse.jdt.core.compiler.CharOperation; |
18 |
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; |
19 |
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; |
|
|
20 |
import org.eclipse.jdt.internal.compiler.lookup.Binding; |
19 |
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; |
21 |
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; |
|
|
22 |
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; |
20 |
import org.eclipse.jdt.internal.compiler.util.Util; |
23 |
import org.eclipse.jdt.internal.compiler.util.Util; |
21 |
import org.eclipse.jdt.internal.core.CompilationUnit; |
24 |
import org.eclipse.jdt.internal.core.CompilationUnit; |
22 |
import org.eclipse.jdt.internal.core.PackageFragment; |
25 |
import org.eclipse.jdt.internal.core.PackageFragment; |
Lines 32-38
Link Here
|
32 |
private int dimensions; |
35 |
private int dimensions; |
33 |
private RecoveredTypeBinding innerTypeBinding; |
36 |
private RecoveredTypeBinding innerTypeBinding; |
34 |
private ITypeBinding[] typeArguments; |
37 |
private ITypeBinding[] typeArguments; |
35 |
private org.eclipse.jdt.internal.compiler.lookup.TypeBinding referenceBinding; |
38 |
private org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding; |
36 |
|
39 |
|
37 |
RecoveredTypeBinding(BindingResolver resolver, VariableDeclaration variableDeclaration) { |
40 |
RecoveredTypeBinding(BindingResolver resolver, VariableDeclaration variableDeclaration) { |
38 |
this.variableDeclaration = variableDeclaration; |
41 |
this.variableDeclaration = variableDeclaration; |
Lines 44-53
Link Here
|
44 |
} |
47 |
} |
45 |
} |
48 |
} |
46 |
|
49 |
|
47 |
RecoveredTypeBinding(BindingResolver resolver, org.eclipse.jdt.internal.compiler.lookup.TypeBinding referenceBinding) { |
50 |
RecoveredTypeBinding(BindingResolver resolver, org.eclipse.jdt.internal.compiler.lookup.TypeBinding typeBinding) { |
48 |
this.resolver = resolver; |
51 |
this.resolver = resolver; |
49 |
this.dimensions = referenceBinding.dimensions(); |
52 |
this.dimensions = typeBinding.dimensions(); |
50 |
this.referenceBinding = referenceBinding; |
53 |
this.binding = typeBinding; |
51 |
} |
54 |
} |
52 |
|
55 |
|
53 |
RecoveredTypeBinding(BindingResolver resolver, Type type) { |
56 |
RecoveredTypeBinding(BindingResolver resolver, Type type) { |
Lines 147-158
Link Here
|
147 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getElementType() |
150 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getElementType() |
148 |
*/ |
151 |
*/ |
149 |
public ITypeBinding getElementType() { |
152 |
public ITypeBinding getElementType() { |
150 |
if (this.referenceBinding != null) { |
153 |
if (this.binding != null) { |
151 |
if (this.referenceBinding.isArrayType()) { |
154 |
if (this.binding.isArrayType()) { |
152 |
ArrayBinding arrayBinding = (ArrayBinding) this.referenceBinding; |
155 |
ArrayBinding arrayBinding = (ArrayBinding) this.binding; |
153 |
return new RecoveredTypeBinding(this.resolver, arrayBinding.leafComponentType); |
156 |
return new RecoveredTypeBinding(this.resolver, arrayBinding.leafComponentType); |
154 |
} else { |
157 |
} else { |
155 |
return new RecoveredTypeBinding(this.resolver, this.referenceBinding); |
158 |
return new RecoveredTypeBinding(this.resolver, this.binding); |
156 |
} |
159 |
} |
157 |
} |
160 |
} |
158 |
if (this.innerTypeBinding != null) { |
161 |
if (this.innerTypeBinding != null) { |
Lines 205-221
Link Here
|
205 |
private String getInternalName() { |
208 |
private String getInternalName() { |
206 |
if (this.innerTypeBinding != null) { |
209 |
if (this.innerTypeBinding != null) { |
207 |
return this.innerTypeBinding.getInternalName(); |
210 |
return this.innerTypeBinding.getInternalName(); |
208 |
} else if (this.referenceBinding != null) { |
211 |
} |
209 |
org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding typeBinding = null; |
212 |
ReferenceBinding referenceBinding = getReferenceBinding(); |
210 |
if (this.referenceBinding.isArrayType()) { |
213 |
if (referenceBinding != null) { |
211 |
ArrayBinding arrayBinding = (ArrayBinding) this.referenceBinding; |
214 |
return new String(referenceBinding.compoundName[referenceBinding.compoundName.length - 1]); |
212 |
if (arrayBinding.leafComponentType instanceof org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) { |
|
|
213 |
typeBinding = (org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) arrayBinding.leafComponentType; |
214 |
} |
215 |
} else if (this.referenceBinding instanceof org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) { |
216 |
typeBinding = (org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) this.referenceBinding; |
217 |
} |
218 |
return new String(typeBinding.compoundName[typeBinding.compoundName.length - 1]); |
219 |
} |
215 |
} |
220 |
return this.getTypeNameFrom(getType()); |
216 |
return this.getTypeNameFrom(getType()); |
221 |
} |
217 |
} |
Lines 224-229
Link Here
|
224 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getPackage() |
220 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getPackage() |
225 |
*/ |
221 |
*/ |
226 |
public IPackageBinding getPackage() { |
222 |
public IPackageBinding getPackage() { |
|
|
223 |
if (this.binding != null) { |
224 |
switch (this.binding.kind()) { |
225 |
case Binding.BASE_TYPE : |
226 |
case Binding.ARRAY_TYPE : |
227 |
case Binding.TYPE_PARAMETER : // includes capture scenario |
228 |
case Binding.WILDCARD_TYPE : |
229 |
return null; |
230 |
} |
231 |
IPackageBinding packageBinding = this.resolver.getPackageBinding(this.binding.getPackage()); |
232 |
if (packageBinding != null) return packageBinding; |
233 |
} |
234 |
if (this.innerTypeBinding != null && this.dimensions > 0) { |
235 |
return null; |
236 |
} |
227 |
CompilationUnitScope scope = this.resolver.scope(); |
237 |
CompilationUnitScope scope = this.resolver.scope(); |
228 |
if (scope != null) { |
238 |
if (scope != null) { |
229 |
return this.resolver.getPackageBinding(scope.getCurrentPackage()); |
239 |
return this.resolver.getPackageBinding(scope.getCurrentPackage()); |
Lines 235-247
Link Here
|
235 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getQualifiedName() |
245 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getQualifiedName() |
236 |
*/ |
246 |
*/ |
237 |
public String getQualifiedName() { |
247 |
public String getQualifiedName() { |
238 |
return this.getName(); |
248 |
ReferenceBinding referenceBinding = getReferenceBinding(); |
|
|
249 |
if (referenceBinding != null) { |
250 |
StringBuffer buffer = new StringBuffer(); |
251 |
char[] brackets = new char[this.dimensions * 2]; |
252 |
for (int i = this.dimensions * 2 - 1; i >= 0; i -= 2) { |
253 |
brackets[i] = ']'; |
254 |
brackets[i - 1] = '['; |
255 |
} |
256 |
buffer.append(CharOperation.toString(referenceBinding.compoundName)); |
257 |
buffer.append(brackets); |
258 |
return String.valueOf(buffer); |
259 |
} else { |
260 |
return getName(); |
261 |
} |
262 |
} |
263 |
|
264 |
private ReferenceBinding getReferenceBinding() { |
265 |
if (this.binding != null) { |
266 |
if (this.binding.isArrayType()) { |
267 |
ArrayBinding arrayBinding = (ArrayBinding) this.binding; |
268 |
if (arrayBinding.leafComponentType instanceof ReferenceBinding) { |
269 |
return (ReferenceBinding) arrayBinding.leafComponentType; |
270 |
} |
271 |
} else if (this.binding instanceof ReferenceBinding) { |
272 |
return (ReferenceBinding) this.binding; |
273 |
} |
274 |
} else if (this.innerTypeBinding != null) { |
275 |
return this.innerTypeBinding.getReferenceBinding(); |
276 |
} |
277 |
return null; |
239 |
} |
278 |
} |
240 |
|
279 |
|
241 |
/* (non-Javadoc) |
280 |
/* (non-Javadoc) |
242 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getSuperclass() |
281 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getSuperclass() |
243 |
*/ |
282 |
*/ |
244 |
public ITypeBinding getSuperclass() { |
283 |
public ITypeBinding getSuperclass() { |
|
|
284 |
if (getQualifiedName().equals("java.lang.Object")) { //$NON-NLS-1$ |
285 |
return null; |
286 |
} |
245 |
return this.resolver.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ |
287 |
return this.resolver.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ |
246 |
} |
288 |
} |
247 |
|
289 |
|
Lines 249-255
Link Here
|
249 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeArguments() |
291 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeArguments() |
250 |
*/ |
292 |
*/ |
251 |
public ITypeBinding[] getTypeArguments() { |
293 |
public ITypeBinding[] getTypeArguments() { |
252 |
if (this.referenceBinding != null) { |
294 |
if (this.binding != null) { |
253 |
return this.typeArguments = TypeBinding.NO_TYPE_BINDINGS; |
295 |
return this.typeArguments = TypeBinding.NO_TYPE_BINDINGS; |
254 |
} |
296 |
} |
255 |
if (this.typeArguments != null) { |
297 |
if (this.typeArguments != null) { |
Lines 521-529
Link Here
|
521 |
} else if (this.currentType != null) { |
563 |
} else if (this.currentType != null) { |
522 |
buffer.append("currentType") //$NON-NLS-1$ |
564 |
buffer.append("currentType") //$NON-NLS-1$ |
523 |
.append(this.currentType.toString()); |
565 |
.append(this.currentType.toString()); |
524 |
} else if (this.referenceBinding != null) { |
566 |
} else if (this.binding != null) { |
525 |
buffer.append("referenceBinding") //$NON-NLS-1$ |
567 |
buffer.append("typeBinding") //$NON-NLS-1$ |
526 |
.append(this.referenceBinding.computeUniqueKey()); |
568 |
.append(this.binding.computeUniqueKey()); |
527 |
} else if (variableDeclaration != null) { |
569 |
} else if (variableDeclaration != null) { |
528 |
buffer |
570 |
buffer |
529 |
.append("variableDeclaration") //$NON-NLS-1$ |
571 |
.append("variableDeclaration") //$NON-NLS-1$ |