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-223
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 |
if (typeBinding != null) { |
219 |
return new String(typeBinding.compoundName[typeBinding.compoundName.length - 1]); |
220 |
} |
221 |
} |
215 |
} |
222 |
return this.getTypeNameFrom(getType()); |
216 |
return this.getTypeNameFrom(getType()); |
223 |
} |
217 |
} |
Lines 226-231
Link Here
|
226 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getPackage() |
220 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getPackage() |
227 |
*/ |
221 |
*/ |
228 |
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 |
case Binding.INTERSECTION_TYPE: |
230 |
return null; |
231 |
} |
232 |
IPackageBinding packageBinding = this.resolver.getPackageBinding(this.binding.getPackage()); |
233 |
if (packageBinding != null) return packageBinding; |
234 |
} |
235 |
if (this.innerTypeBinding != null && this.dimensions > 0) { |
236 |
return null; |
237 |
} |
229 |
CompilationUnitScope scope = this.resolver.scope(); |
238 |
CompilationUnitScope scope = this.resolver.scope(); |
230 |
if (scope != null) { |
239 |
if (scope != null) { |
231 |
return this.resolver.getPackageBinding(scope.getCurrentPackage()); |
240 |
return this.resolver.getPackageBinding(scope.getCurrentPackage()); |
Lines 237-249
Link Here
|
237 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getQualifiedName() |
246 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getQualifiedName() |
238 |
*/ |
247 |
*/ |
239 |
public String getQualifiedName() { |
248 |
public String getQualifiedName() { |
240 |
return this.getName(); |
249 |
ReferenceBinding referenceBinding = getReferenceBinding(); |
|
|
250 |
if (referenceBinding != null) { |
251 |
StringBuffer buffer = new StringBuffer(); |
252 |
char[] brackets = new char[this.dimensions * 2]; |
253 |
for (int i = this.dimensions * 2 - 1; i >= 0; i -= 2) { |
254 |
brackets[i] = ']'; |
255 |
brackets[i - 1] = '['; |
256 |
} |
257 |
buffer.append(CharOperation.toString(referenceBinding.compoundName)); |
258 |
buffer.append(brackets); |
259 |
return String.valueOf(buffer); |
260 |
} else { |
261 |
return getName(); |
262 |
} |
263 |
} |
264 |
|
265 |
private ReferenceBinding getReferenceBinding() { |
266 |
if (this.binding != null) { |
267 |
if (this.binding.isArrayType()) { |
268 |
ArrayBinding arrayBinding = (ArrayBinding) this.binding; |
269 |
if (arrayBinding.leafComponentType instanceof ReferenceBinding) { |
270 |
return (ReferenceBinding) arrayBinding.leafComponentType; |
271 |
} |
272 |
} else if (this.binding instanceof ReferenceBinding) { |
273 |
return (ReferenceBinding) this.binding; |
274 |
} |
275 |
} else if (this.innerTypeBinding != null) { |
276 |
return this.innerTypeBinding.getReferenceBinding(); |
277 |
} |
278 |
return null; |
241 |
} |
279 |
} |
242 |
|
280 |
|
243 |
/* (non-Javadoc) |
281 |
/* (non-Javadoc) |
244 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getSuperclass() |
282 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getSuperclass() |
245 |
*/ |
283 |
*/ |
246 |
public ITypeBinding getSuperclass() { |
284 |
public ITypeBinding getSuperclass() { |
|
|
285 |
if (getQualifiedName().equals("java.lang.Object")) { //$NON-NLS-1$ |
286 |
return null; |
287 |
} |
247 |
return this.resolver.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ |
288 |
return this.resolver.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ |
248 |
} |
289 |
} |
249 |
|
290 |
|
Lines 251-257
Link Here
|
251 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeArguments() |
292 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeArguments() |
252 |
*/ |
293 |
*/ |
253 |
public ITypeBinding[] getTypeArguments() { |
294 |
public ITypeBinding[] getTypeArguments() { |
254 |
if (this.referenceBinding != null) { |
295 |
if (this.binding != null) { |
255 |
return this.typeArguments = TypeBinding.NO_TYPE_BINDINGS; |
296 |
return this.typeArguments = TypeBinding.NO_TYPE_BINDINGS; |
256 |
} |
297 |
} |
257 |
if (this.typeArguments != null) { |
298 |
if (this.typeArguments != null) { |
Lines 523-531
Link Here
|
523 |
} else if (this.currentType != null) { |
564 |
} else if (this.currentType != null) { |
524 |
buffer.append("currentType") //$NON-NLS-1$ |
565 |
buffer.append("currentType") //$NON-NLS-1$ |
525 |
.append(this.currentType.toString()); |
566 |
.append(this.currentType.toString()); |
526 |
} else if (this.referenceBinding != null) { |
567 |
} else if (this.binding != null) { |
527 |
buffer.append("referenceBinding") //$NON-NLS-1$ |
568 |
buffer.append("typeBinding") //$NON-NLS-1$ |
528 |
.append(this.referenceBinding.computeUniqueKey()); |
569 |
.append(this.binding.computeUniqueKey()); |
529 |
} else if (variableDeclaration != null) { |
570 |
} else if (variableDeclaration != null) { |
530 |
buffer |
571 |
buffer |
531 |
.append("variableDeclaration") //$NON-NLS-1$ |
572 |
.append("variableDeclaration") //$NON-NLS-1$ |