View | Details | Raw Unified | Return to bug 212100 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java (+85 lines)
Lines 19-24 Link Here
19
import org.eclipse.jdt.core.IClassFile;
19
import org.eclipse.jdt.core.IClassFile;
20
import org.eclipse.jdt.core.ICompilationUnit;
20
import org.eclipse.jdt.core.ICompilationUnit;
21
import org.eclipse.jdt.core.IJavaProject;
21
import org.eclipse.jdt.core.IJavaProject;
22
import org.eclipse.jdt.core.JavaModelException;
22
import org.eclipse.jdt.core.WorkingCopyOwner;
23
import org.eclipse.jdt.core.WorkingCopyOwner;
23
import org.eclipse.jdt.core.dom.*;
24
import org.eclipse.jdt.core.dom.*;
24
25
Lines 231-236 Link Here
231
}
232
}
232
233
233
/**
234
/**
235
 * @bug 212100: [dom] Can't create binding to inner class
236
 * @test Verify that the binding is well created for an inner class
237
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=212100"
238
 */
239
public void testBug212100a() throws JavaModelException {
240
	workingCopies = new ICompilationUnit[1];
241
	this.workingCopies[0] = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
242
	String contents =
243
		"public class X {\n" +
244
		"	public class Y {\n" +
245
		"      void foo() {}\n" +
246
		"   }\n" +
247
		"}";
248
	this.workingCopies[0].getBuffer().setContents(contents);
249
	this.workingCopies[0].save(null, true);
250
	final IBinding[] bindings = new IBinding[4];
251
	final String key = "Ljava/lang/Object;"; // this will make the test fail
252
//	final String key = "LX;"; // this would make the test pass
253
254
	resolveASTs(this.workingCopies,
255
			new String[] { key },
256
			new ASTRequestor() {
257
				public void acceptBinding(String bindingKey, IBinding binding) {
258
					if (key.equals(bindingKey)) {
259
						bindings[0] = binding;
260
						IBinding[] temp = createBindings(new String[] {"LX;", "LX$Y;", "[LX$Y;"});
261
						for (int i = 0; i < temp.length; ++i) {
262
							bindings[i + 1] = temp[i];
263
						}
264
					}
265
				}
266
			},
267
			getJavaProject("Converter15"),
268
			null);
269
	assertNotNull("Binding for java.lang.Object should not be null", bindings[0]);
270
	assertNotNull("Binding for X should not be null", bindings[1]);
271
	assertNotNull("Binding for X.Y should not be null", bindings[2]);
272
	assertNotNull("Binding for X.Y[] should not be null", bindings[3]);
273
}
274
public void testBug212100b() throws JavaModelException {
275
	this.workingCopies = new ICompilationUnit[2];
276
	this.workingCopies[0] = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
277
	String contents =
278
		"public class X {\n" +
279
		"	public class Y {\n" +
280
		"      void foo() {}\n" +
281
		"   }\n" +
282
		"}";
283
	this.workingCopies[0].getBuffer().setContents(contents);
284
	this.workingCopies[0].save(null, true);
285
286
	this.workingCopies[1] = getWorkingCopy("/Converter15/src/Z.java", true/*resolve*/);
287
	String contentsZ =
288
		"public class Z {\n" +
289
		"	public class W {\n" +
290
		"      void bar() {}\n" +
291
		"   }\n" +
292
		"}";
293
	this.workingCopies[1].getBuffer().setContents(contentsZ);
294
	this.workingCopies[1].save(null, true);
295
296
	final String keyX = "LX;";
297
	final String keyXY = "LX$Y;";
298
	final String keyZ = "LZ;";
299
	final String keyZW = "LZ$W;";
300
301
	resolveASTs(this.workingCopies,
302
			new String[] { keyX, keyZ },
303
			new ASTRequestor() {
304
				public void acceptBinding(String bindingKey, IBinding binding) {
305
					IBinding[] bindings = createBindings(new String[] {
306
							keyX, keyXY, keyZ, keyZW
307
					});
308
					assertNotNull("When accepting " + bindingKey + ", Binding for X should not be null", bindings[0]);
309
					assertNotNull("When accepting " + bindingKey + ", Binding for X.Y should not be null", bindings[1]);
310
					assertNotNull("When accepting " + bindingKey + ", Binding for Z should not be null", bindings[2]);
311
					assertNotNull("When accepting " + bindingKey + ", Binding for Z.W should not be null", bindings[3]);
312
				}
313
			},
314
			getJavaProject("Converter15"),
315
			null);
316
}
317
318
/**
234
 * @bug 212834: [dom] IMethodBinding.getParameterAnnotations does not return annotations
319
 * @bug 212834: [dom] IMethodBinding.getParameterAnnotations does not return annotations
235
 * @test Ensures that the method binding get the parameter annotations even on method invocation
320
 * @test Ensures that the method binding get the parameter annotations even on method invocation
236
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=212834"
321
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=212834"
(-)model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java (-15 / +13 lines)
Lines 28-34 Link Here
28
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
28
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
29
import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
29
import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
30
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
30
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
31
import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding;
32
import org.eclipse.jdt.internal.compiler.lookup.Binding;
31
import org.eclipse.jdt.internal.compiler.lookup.Binding;
33
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
32
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
34
import org.eclipse.jdt.internal.compiler.lookup.CaptureBinding;
33
import org.eclipse.jdt.internal.compiler.lookup.CaptureBinding;
Lines 503-522 Link Here
503
	}
502
	}
504
	
503
	
505
	private TypeBinding getTypeBinding(char[] simpleTypeName) {
504
	private TypeBinding getTypeBinding(char[] simpleTypeName) {
506
		if (this.typeBinding instanceof BinaryTypeBinding) {
505
		if (this.typeBinding instanceof ReferenceBinding) {
507
			return ((BinaryTypeBinding) this.typeBinding).getMemberType(simpleTypeName);
506
			return ((ReferenceBinding) this.typeBinding).getMemberType(simpleTypeName);
508
		} else {
507
		}
509
			TypeDeclaration[] typeDeclarations = 
508
		TypeDeclaration[] typeDeclarations = 
510
				this.typeDeclaration == null ? 
509
			this.typeDeclaration == null ? 
511
					(this.parsedUnit == null ? null : this.parsedUnit.types) : 
510
				(this.parsedUnit == null ? null : this.parsedUnit.types) : 
512
					this.typeDeclaration.memberTypes;
511
				this.typeDeclaration.memberTypes;
513
			if (typeDeclarations == null) return null;
512
		if (typeDeclarations == null) return null;
514
			for (int i = 0, length = typeDeclarations.length; i < length; i++) {
513
		for (int i = 0, length = typeDeclarations.length; i < length; i++) {
515
				TypeDeclaration declaration = typeDeclarations[i];
514
			TypeDeclaration declaration = typeDeclarations[i];
516
				if (CharOperation.equals(simpleTypeName, declaration.name)) {
515
			if (CharOperation.equals(simpleTypeName, declaration.name)) {
517
					this.typeDeclaration = declaration;
516
				this.typeDeclaration = declaration;
518
					return declaration.binding;
517
				return declaration.binding;
519
				}
520
			}
518
			}
521
		}
519
		}
522
		return null;
520
		return null;

Return to bug 212100