### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v retrieving revision 1.415 diff -u -r1.415 Parser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 22 Jan 2010 03:00:10 -0000 1.415 +++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 23 Feb 2010 14:47:30 -0000 @@ -7742,11 +7742,17 @@ this.listTypeParameterLength = 0; - if (this.currentElement != null) { // is recovering - RecoveredType recoveredType = (RecoveredType) this.currentElement; - recoveredType.pendingTypeParameters = null; - - this.lastCheckPoint = typeDecl.bodyStart; + if (this.currentElement != null) { + // is recovering + if (this.currentElement instanceof RecoveredType) { + RecoveredType recoveredType = (RecoveredType) this.currentElement; + recoveredType.pendingTypeParameters = null; + this.lastCheckPoint = typeDecl.bodyStart; + } else { + this.lastCheckPoint = typeDecl.bodyStart; + this.currentElement = this.currentElement.add(typeDecl, 0); + this.lastIgnoredToken = -1; + } } } protected void consumeTypeImportOnDemandDeclarationName() { #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java,v retrieving revision 1.43 diff -u -r1.43 SourceElementParserTest.java --- src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java 27 Jun 2008 16:04:46 -0000 1.43 +++ src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java 23 Feb 2010 14:47:31 -0000 @@ -11,9 +11,11 @@ package org.eclipse.jdt.core.tests.compiler.parser; import java.util.Locale; +import java.util.Map; import junit.framework.Test; +import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.compiler.CategorizedProblem; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.tests.util.AbstractCompilerTest; @@ -44,7 +46,7 @@ this.source = source; } static { -// TESTS_NUMBERS = new int[] { 99662 }; + TESTS_NUMBERS = new int[] { 81 }; } public static Test suite() { return buildAllCompliancesTestSuite(SourceElementParserTest.class); @@ -227,7 +229,7 @@ if (typeInfo.typeParameters != null) { for (int i = 0, length = typeInfo.typeParameters.length; i < length; i++) { TypeParameterInfo typeParameterInfo = typeInfo.typeParameters[i]; - addTypeParameter(typeParameterInfo); + addTypeParameterToType(typeParameterInfo); } } } @@ -279,11 +281,11 @@ if (methodInfo.typeParameters != null) { for (int i = 0, length = methodInfo.typeParameters.length; i < length; i++) { TypeParameterInfo typeParameterInfo = methodInfo.typeParameters[i]; - addTypeParameter(typeParameterInfo); + addTypeParameterToMethod(typeParameterInfo); } } } -public void addTypeParameter(TypeParameterInfo typeParameterInfo) { +public void addTypeParameterToMethod(TypeParameterInfo typeParameterInfo) { if (this.currentMethod.typeParameterNames == null) { this.currentMethod.typeParameterNames = new char[][] {typeParameterInfo.name}; this.currentMethod.typeParameterBounds = new char[][][] {typeParameterInfo.bounds}; @@ -295,6 +297,18 @@ this.currentMethod.typeParameterBounds[length] = typeParameterInfo.bounds; } } +public void addTypeParameterToType(TypeParameterInfo typeParameterInfo) { + if (this.currentType.typeParameterNames == null) { + this.currentType.typeParameterNames = new char[][] {typeParameterInfo.name}; + this.currentType.typeParameterBounds = new char[][][] {typeParameterInfo.bounds}; + } else { + int length = this.currentType.typeParameterNames.length; + System.arraycopy(this.currentType.typeParameterNames, 0, this.currentType.typeParameterNames = new char[length+1][],0, length); + this.currentMethod.typeParameterNames[length] = typeParameterInfo.name; + System.arraycopy(this.currentType.typeParameterBounds, 0, this.currentType.typeParameterBounds = new char[length+1][][],0, length); + this.currentType.typeParameterBounds[length] = typeParameterInfo.bounds; + } +} public void exitType(int declarationEnd) { this.currentType.setDeclarationSourceEnd(declarationEnd); if (this.currentType.parent != null) { @@ -317,13 +331,16 @@ public void fullParse(String s, String testName) { this.fullParse(s, testName, false); } -public void fullParse(String s, String testName, boolean recordLocalDeclaration) { +public void fullParse(String s, String testName, Map options) { + this.fullParse(s, testName, false, options); +} +public void fullParse(String s, String testName, boolean recordLocalDeclaration, Map options) { this.source = s.toCharArray(); reset(); SourceElementParser parser = new SourceElementParser( this, new DefaultProblemFactory(Locale.getDefault()), - new CompilerOptions(getCompilerOptions()), + new CompilerOptions(options), recordLocalDeclaration/*don't record local declarations*/, true/*optimize string literals*/); @@ -331,6 +348,9 @@ parser.parseCompilationUnit(sourceUnit, true, null); } +public void fullParse(String s, String testName, boolean recordLocalDeclaration) { + this.fullParse(s, testName, recordLocalDeclaration, getCompilerOptions()); +} public void reset() { this.currentType = null; this.currentMethod = null; @@ -5276,4 +5296,81 @@ expectedUnitToString, this.currentType.toString()); } +public void test81() { + + Map options = getCompilerOptions(); + options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); + options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); + options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); + + String s = + "import java.util.Collection;\n" + + "\n" + + "public class X {\n" + + " public abstract class AbstractData {}\n" + + " \n" + + " public interface IScalarData {}\n" + + "\n" + + " private static interface ValueObjectPropertyIterator {\n" + + " public void iterateOnValueObjectProperty(IScalarData scalarObject, T valueObject, Class valueObjectType, final String name, final Class scalarType) throws Exception;\n" + + " }\n" + + "\n" + + " private static void iterateOnValueObjectProperties(IScalarData scalarObject, T valueObject, ValueObjectPropertyIterator valueObjectPropertyIterator) {}\n" + + " \n" + + " public static void loadScalarFromValueObject(IScalarData scalarObject, T valueObject) {\n" + + " iterateOnValueObjectProperties(scalarObject, valueObject, new ValueObjectPropertyIterator() {\n" + + " public void iterateOnValueObjectProperty(IScalarData scalarObject, T valueObject, Class valueObjectType, String name, Class scalarType) throws Exception {\n" + + " if (true) {\n" + + " if (true) {\n" + + " if (true) {\n" + + " final Collection> lazyCollection = createLazyCollection(\n" + + " name, scalarType, null, null,\n" + + " new CollectionProviderForTargetCollection>() {\n" + + " @Override\n" + + " public Collection> provideCollection(\n" + + " final Collection targetCollection, final Class> scalarCollectionType) {\n" + + " return null;\n" + + " }\n" + + " });\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + "\n" + + " abstract class CollectionProviderForTargetCollection {\n" + + " abstract public Collection provideCollection(Collection targetCollection, Class scalarCollectionType);\n" + + " }\n" + + "\n" + + " private Collection createLazyCollection(String name,\n" + + " Class scalarType, final Collection valueObjectCollection,\n" + + " final Class scalarCollectionType, CollectionProviderForTargetCollection collectionProvider) {\n" + + " return null;\n" + + " }\n" + + " });\n" + + " }\n" + + "}"; + + String expectedUnitToString = + "import java.util.Collection;\n" + + "public class X {\n" + + " public abstract class AbstractData {\n" + + " java.lang.Object(0)\n" + + " }\n" + + " public interface IScalarData {\n" + + " }\n" + + " private static interface ValueObjectPropertyIterator {\n" + + " public void iterateOnValueObjectProperty(IScalarData scalarObject, T valueObject, Class valueObjectType, String name, Class scalarType, ) throws Exception, {}\n" + + " }\n" + + " java.lang.Object(0)\n" + + " private static void iterateOnValueObjectProperties(IScalarData scalarObject, T valueObject, ValueObjectPropertyIterator valueObjectPropertyIterator, ) {}\n" + + " public static void loadScalarFromValueObject(IScalarData scalarObject, T valueObject, ) {}\n" + + "}"; + + String testName = "test81: full parse"; + fullParse(s,testName, options); + assertEquals( + "Invalid source " + testName, + expectedUnitToString, + this.currentType.toString()); +} } Index: src/org/eclipse/jdt/core/tests/compiler/parser/SourceType.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceType.java,v retrieving revision 1.13 diff -u -r1.13 SourceType.java --- src/org/eclipse/jdt/core/tests/compiler/parser/SourceType.java 28 Apr 2009 17:17:31 -0000 1.13 +++ src/org/eclipse/jdt/core/tests/compiler/parser/SourceType.java 23 Feb 2010 14:47:31 -0000 @@ -33,6 +33,8 @@ private int numberOfFields; private char[] source; SourceType parent; + char[][] typeParameterNames; + char[][][] typeParameterBounds; // Buffering. private char[] qualifiedName;