View | Details | Raw Unified | Return to bug 204417
Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java (-6 / +13 lines)
Lines 87-99 Link Here
87
		// if selecting a type for an anonymous type creation, we have to
87
		// if selecting a type for an anonymous type creation, we have to
88
		// find its target super constructor (if extending a class) or its target 
88
		// find its target super constructor (if extending a class) or its target 
89
		// super interface (if extending an interface)
89
		// super interface (if extending an interface)
90
		if (anonymousType.binding.superInterfaces == Binding.NO_SUPERINTERFACES) {
90
		if (anonymousType.binding != null) {
91
			// find the constructor binding inside the super constructor call
91
			if (anonymousType.binding.superInterfaces == Binding.NO_SUPERINTERFACES) {
92
			ConstructorDeclaration constructor = (ConstructorDeclaration) anonymousType.declarationOf(binding.original());
92
				// find the constructor binding inside the super constructor call
93
			throw new SelectionNodeFound(constructor.constructorCall.binding);
93
				ConstructorDeclaration constructor = (ConstructorDeclaration) anonymousType.declarationOf(binding.original());
94
				throw new SelectionNodeFound(constructor.constructorCall.binding);
95
			} else {
96
				// open on the only superinterface
97
				throw new SelectionNodeFound(anonymousType.binding.superInterfaces[0]);
98
			}
94
		} else {
99
		} else {
95
			// open on the only superinterface
100
			if (this.resolvedType.isInterface()) {
96
			throw new SelectionNodeFound(anonymousType.binding.superInterfaces[0]);
101
				throw new SelectionNodeFound(resolvedType);
102
			}
103
			throw new SelectionNodeFound(binding);
97
		}
104
		}
98
	}
105
	}
99
}
106
}
(-)src/org/eclipse/jdt/core/tests/model/ResolveTests.java (+47 lines)
Lines 285-290 Link Here
285
		elements
285
		elements
286
	);
286
	);
287
}
287
}
288
/*
289
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=204417
290
 */
291
public void testConstructor3() throws JavaModelException {
292
	this.workingCopies = new ICompilationUnit[1];
293
	this.workingCopies[0] = getWorkingCopy(
294
		"/Resolve/src/test/p/Type.java",
295
		"package test.p;\n" + 
296
		"public class Type {\n" +
297
		"  void foo() {\n" +
298
		"    new AClass(unknown) {};\n" +
299
		"  }\n" + 
300
		"}\n" +
301
		"class AClass {\n" +
302
		"}\n"
303
	);
304
	IJavaElement[] elements = codeSelect(this.workingCopies[0], "AClass(unknown)", "AClass");
305
	assertElementsEqual(
306
		"Unexpected elements",
307
		"AClass [in [Working copy] Type.java [in test.p [in src [in Resolve]]]]",
308
		elements
309
	);
310
}
311
/*
312
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=204417
313
 */
314
public void testConstructor4() throws JavaModelException {
315
	this.workingCopies = new ICompilationUnit[1];
316
	this.workingCopies[0] = getWorkingCopy(
317
		"/Resolve/src/test/p/Type.java",
318
		"package test.p;\n" + 
319
		"public class Type {\n" +
320
		"  void foo() {\n" +
321
		"    new AClass(unknown) {};\n" +
322
		"  }\n" + 
323
		"}\n" +
324
		"class AClass {\n" +
325
		"  public AClass(Object o) {}\n" +
326
		"}\n"
327
	);
328
	IJavaElement[] elements = codeSelect(this.workingCopies[0], "AClass(unknown)", "AClass");
329
	assertElementsEqual(
330
		"Unexpected elements",
331
		"AClass(Object) [in AClass [in [Working copy] Type.java [in test.p [in src [in Resolve]]]]]",
332
		elements
333
	);
334
}
288
/**
335
/**
289
 * Resolve constructor call
336
 * Resolve constructor call
290
 */
337
 */

Return to bug 204417