### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java,v retrieving revision 1.127 diff -u -r1.127 CompilationUnitResolver.java --- dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java 21 Nov 2007 14:11:48 -0000 1.127 +++ dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java 18 Jan 2008 20:50:41 -0000 @@ -426,7 +426,7 @@ } else if (enclosingTypeDeclaration != null) { if (node instanceof org.eclipse.jdt.internal.compiler.ast.Initializer) { ((org.eclipse.jdt.internal.compiler.ast.Initializer) node).parseStatements(parser, enclosingTypeDeclaration, compilationUnitDeclaration); - } else { + } else if (node instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) { ((org.eclipse.jdt.internal.compiler.ast.TypeDeclaration)node).parseMethods(parser, compilationUnitDeclaration); } } #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java,v retrieving revision 1.134 diff -u -r1.134 ASTConverterTestAST3_2.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 6 Nov 2007 08:39:39 -0000 1.134 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 18 Jan 2008 20:50:47 -0000 @@ -24,6 +24,7 @@ import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IInitializer; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; @@ -120,7 +121,7 @@ static { // TESTS_NAMES = new String[] {"test0602"}; // TESTS_RANGE = new int[] { 670, -1 }; -// TESTS_NUMBERS = new int[] { 687 }; + TESTS_NUMBERS = new int[] { 688 }; } public static Test suite() { return buildModelTestSuite(ASTConverterTestAST3_2.class); @@ -9546,8 +9547,24 @@ Expression leftOperand = infixExpression.getLeftOperand(); checkSourceRange(leftOperand, "(\"\" + string + \"\")", contents); } finally { - if (workingCopy != null) + if (workingCopy != null) { workingCopy.discardWorkingCopy(); + } } } + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=40474 + */ + public void test0688() throws JavaModelException { + ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0688", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + IType[] types = sourceUnit.getTypes(); + assertNotNull(types); + assertEquals("wrong size", 1, types.length); + IType type = types[0]; + IField field = type.getField("i"); + assertNotNull("No field", field); + ISourceRange sourceRange = field.getNameRange(); + ASTNode result = runConversion(AST.JLS3, sourceUnit, sourceRange.getOffset() + sourceRange.getLength() / 2, false); + assertNotNull(result); + } } Index: workspace/Converter/src/test0688/X.java =================================================================== RCS file: workspace/Converter/src/test0688/X.java diff -N workspace/Converter/src/test0688/X.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/Converter/src/test0688/X.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,6 @@ +package test0688; + +public class X { + protected int i; + protected void foo(String string) {} +}