Index: src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java,v retrieving revision 1.33 diff -u -r1.33 ASTModelBridgeTests.java --- src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java 15 Jun 2005 16:29:39 -0000 1.33 +++ src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java 19 Aug 2005 10:36:56 -0000 @@ -36,7 +36,7 @@ // All specified tests which do not belong to the class are skipped... static { // TESTS_PREFIX = "testBug86380"; -// TESTS_NAMES = new String[] { "testAnonymousType2" }; +// TESTS_NAMES = new String[] { "testBinaryMemberTypeFromAnonymousClassFile" }; // TESTS_NUMBERS = new int[] { 83230 }; // TESTS_RANGE = new int[] { 83304, -1 }; } @@ -85,6 +85,15 @@ "public class Y {\n" + " public Y(T t) {\n" + " }\n" + + "}", + "p/Z.java", + "package p;\n" + + "public class Z {\n" + + " /*start*/class Member {\n" + + " }/*end*/\n" + + " void foo() {\n" + + " new Member() {};\n" + + " }\n" + "}" }, "1.5"); @@ -243,6 +252,28 @@ } /* + * Ensures that the IJavaElement for a binary member type coming from an anoumous class file is correct. + * (regression test for bug 100636 [model] Can't find overriden methods of protected nonstatic inner class.) + */ + public void testBinaryMemberTypeFromAnonymousClassFile() throws JavaModelException { + IClassFile classFile = getClassFile("P", "/P/lib.jar", "p", "Z$1.class"); + String source = classFile.getSource(); + MarkerInfo markerInfo = new MarkerInfo(source); + markerInfo.astStarts = new int[] {source.indexOf("/*start*/") + "/*start*/".length()}; + markerInfo.astEnds = new int[] {source.indexOf("/*end*/")}; + ASTNode node = buildAST(markerInfo, classFile); + IBinding binding = ((TypeDeclaration) node).resolveBinding(); + assertNotNull("No binding", binding); + IJavaElement element = binding.getJavaElement(); + assertElementEquals( + "Unexpected Java element", + "Member [in Z$Member.class [in p [in lib.jar [in P]]]]", + element + ); + assertTrue("Element should exist", element.exists()); + } + + /* * Ensures that the correct IBindings are created for a given set of IJavaElement * (test several kinds of elements) */