Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 44420 Details for
Bug 120667
[hierarchy] Type hierarchy for enum type does not include anonymous subtypes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch and regression test
120667.txt (text/plain), 11.42 KB, created by
Jerome Lanneluc
on 2006-06-14 12:37:55 EDT
(
hide
)
Description:
Proposed patch and regression test
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2006-06-14 12:37:55 EDT
Size:
11.42 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java,v >retrieving revision 1.59 >diff -u -r1.59 TypeHierarchyTests.java >--- src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 14 Jun 2006 10:53:55 -0000 1.59 >+++ src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 14 Jun 2006 16:40:26 -0000 >@@ -149,6 +149,15 @@ > " public int compareTo(CycleChild o) { return 0; }\n" + > "}" > ); >+ createFile( >+ "/TypeHierarchy15/src/Try.java", >+ "public enum Try {\n" + >+ " THIS,\n" + >+ " THAT(),\n" + >+ " ANONYMOUS() {}\n" + >+ "}" >+ ); >+ > } > > /* (non-Javadoc) >@@ -271,6 +280,42 @@ > IType[] subtypes = hierarchy.getSubtypes(type); > assertEquals("Unexpected key", "Lmy/pkg/Y$1;", subtypes.length < 1 ? null : subtypes[0].getKey()); > } >+/* >+ * Ensure that hierarchy on an enum also include the anonymous of its enum contants >+ * (regression test for bug 120667 [hierarchy] Type hierarchy for enum type does not include anonymous subtypes) >+ */ >+public void testAnonymousType8() throws CoreException { >+ IType type = getCompilationUnit("TypeHierarchy15/src/Try.java").getType("Try"); >+ ITypeHierarchy hierarchy = type.newTypeHierarchy(null); >+ assertHierarchyEquals( >+ "Focus: Try [in Try.java [in <default> [in src [in TypeHierarchy15]]]]\n" + >+ "Super types:\n" + >+ " Enum [in Enum.class [in java.lang [in "+ getExternalJCLPathString("1.5") + "]]]\n" + >+ " Comparable [in Comparable.class [in java.lang [in "+ getExternalJCLPathString("1.5") + "]]]\n" + >+ " Object [in Object.class [in java.lang [in "+ getExternalJCLPathString("1.5") + "]]]\n" + >+ " Serializable [in Serializable.class [in java.io [in "+ getExternalJCLPathString("1.5") + "]]]\n" + >+ "Sub types:\n" + >+ " <anonymous #1> [in ANONYMOUS [in Try [in Try.java [in <default> [in src [in TypeHierarchy15]]]]]]\n", >+ hierarchy); >+} >+/* >+ * Ensure that hierarchy on the anonymous type of an enum constant is correct >+ * (regression test for bug 120667 [hierarchy] Type hierarchy for enum type does not include anonymous subtypes) >+ */ >+public void testAnonymousType9() throws CoreException { >+ IType type = getCompilationUnit("TypeHierarchy15/src/Try.java").getType("Try").getField("ANONYMOUS").getType("", 1); >+ ITypeHierarchy hierarchy = type.newTypeHierarchy(null); >+ assertHierarchyEquals( >+ "Focus: <anonymous #1> [in ANONYMOUS [in Try [in Try.java [in <default> [in src [in TypeHierarchy15]]]]]]\n" + >+ "Super types:\n" + >+ " Try [in Try.java [in <default> [in src [in TypeHierarchy15]]]]\n" + >+ " Enum [in Enum.class [in java.lang [in "+ getExternalJCLPathString("1.5") + "]]]\n" + >+ " Comparable [in Comparable.class [in java.lang [in "+ getExternalJCLPathString("1.5") + "]]]\n" + >+ " Object [in Object.class [in java.lang [in "+ getExternalJCLPathString("1.5") + "]]]\n" + >+ " Serializable [in Serializable.class [in java.io [in "+ getExternalJCLPathString("1.5") + "]]]\n" + >+ "Sub types:\n", >+ hierarchy); >+} > /** > * Ensures that the superclass can be retrieved for a binary inner type. > */ >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java,v >retrieving revision 1.47 >diff -u -r1.47 SourceTypeConverter.java >--- model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java 24 Apr 2006 15:04:29 -0000 1.47 >+++ model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java 14 Jun 2006 16:40:28 -0000 >@@ -248,27 +248,36 @@ > if ((this.flags & LOCAL_TYPE) != 0) { > IJavaElement[] children = fieldInfo.getChildren(); > int childrenLength = children.length; >- if (childrenLength > 0) { >+ if (childrenLength == 1) { >+ field.initialization = convert(children[0], isEnumConstant ? field : null, compilationResult); >+ } else if (childrenLength > 1) { > ArrayInitializer initializer = new ArrayInitializer(); > field.initialization = initializer; > Expression[] expressions = new Expression[childrenLength]; > initializer.expressions = expressions; > for (int i = 0; i < childrenLength; i++) { >- IJavaElement localType = children[i]; >- TypeDeclaration anonymousLocalTypeDeclaration = convert((SourceType) localType, compilationResult); >- QualifiedAllocationExpression expression = new QualifiedAllocationExpression(anonymousLocalTypeDeclaration); >- expression.type = anonymousLocalTypeDeclaration.superclass; >- anonymousLocalTypeDeclaration.superclass = null; >- anonymousLocalTypeDeclaration.superInterfaces = null; >- anonymousLocalTypeDeclaration.allocation = expression; >- anonymousLocalTypeDeclaration.modifiers &= ~ClassFileConstants.AccEnum; // remove tag in case this is the init of an enum constant >- expressions[i] = expression; >+ expressions[i] = convert(children[i], isEnumConstant ? field : null, compilationResult); > } > } > } > return field; > } > >+ private QualifiedAllocationExpression convert(IJavaElement localType, FieldDeclaration enumConstant, CompilationResult compilationResult) throws JavaModelException { >+ TypeDeclaration anonymousLocalTypeDeclaration = convert((SourceType) localType, compilationResult); >+ QualifiedAllocationExpression expression = new QualifiedAllocationExpression(anonymousLocalTypeDeclaration); >+ expression.type = anonymousLocalTypeDeclaration.superclass; >+ anonymousLocalTypeDeclaration.superclass = null; >+ anonymousLocalTypeDeclaration.superInterfaces = null; >+ anonymousLocalTypeDeclaration.allocation = expression; >+ if (enumConstant != null) { >+ anonymousLocalTypeDeclaration.modifiers &= ~ClassFileConstants.AccEnum; >+ expression.enumConstant = enumConstant; >+ expression.type = null; >+ } >+ return expression; >+ } >+ > /* > * Convert a method source element into a parsed method/constructor declaration > */ >Index: search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java,v >retrieving revision 1.39 >diff -u -r1.39 SourceIndexerRequestor.java >--- search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java 29 Mar 2006 03:13:59 -0000 1.39 >+++ search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java 14 Jun 2006 16:40:29 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.jdt.core.compiler.*; > import org.eclipse.jdt.internal.compiler.ISourceElementRequestor; > import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; >+import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; > import org.eclipse.jdt.internal.core.search.processing.JobManager; > > /** >@@ -196,7 +197,8 @@ > } else { > typeNames = this.enclosingTypeNames(); > } >- this.indexer.addEnumDeclaration(typeInfo.modifiers, packageName, typeInfo.name, typeNames, typeInfo.superinterfaces, typeInfo.secondary); >+ char[] superclass = typeInfo.superclass == null ? CharOperation.concatWith(TypeConstants.JAVA_LANG_ENUM, '.'): typeInfo.superclass; >+ this.indexer.addEnumDeclaration(typeInfo.modifiers, packageName, typeInfo.name, typeNames, superclass, typeInfo.superinterfaces, typeInfo.secondary); > this.pushTypeName(typeInfo.name); > } > /** >Index: search/org/eclipse/jdt/internal/core/search/indexing/AbstractIndexer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AbstractIndexer.java,v >retrieving revision 1.35 >diff -u -r1.35 AbstractIndexer.java >--- search/org/eclipse/jdt/internal/core/search/indexing/AbstractIndexer.java 29 Mar 2006 03:13:59 -0000 1.35 >+++ search/org/eclipse/jdt/internal/core/search/indexing/AbstractIndexer.java 14 Jun 2006 16:40:28 -0000 >@@ -89,14 +89,14 @@ > if (innermostTypeName != simpleTypeName) > addIndexEntry(CONSTRUCTOR_REF, ConstructorPattern.createIndexKey(innermostTypeName, argCount)); > } >- public void addEnumDeclaration(int modifiers, char[] packageName, char[] name, char[][] enclosingTypeNames, char[][] superinterfaces, boolean secondary) { >+ public void addEnumDeclaration(int modifiers, char[] packageName, char[] name, char[][] enclosingTypeNames, char[] superclass, char[][] superinterfaces, boolean secondary) { > char[] indexKey = TypeDeclarationPattern.createIndexKey(modifiers, name, packageName, enclosingTypeNames, secondary); > addIndexEntry(TYPE_DECL, indexKey); > > addIndexEntry( > SUPER_REF, > SuperTypeReferencePattern.createIndexKey( >- modifiers, packageName, name, enclosingTypeNames, null, ENUM_SUFFIX, CharOperation.concatWith(TypeConstants.JAVA_LANG_ENUM, '.'), CLASS_SUFFIX)); >+ modifiers, packageName, name, enclosingTypeNames, null, ENUM_SUFFIX, superclass, CLASS_SUFFIX)); > if (superinterfaces != null) { > for (int i = 0, max = superinterfaces.length; i < max; i++) { > char[] superinterface = erasure(superinterfaces[i]); >Index: search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java,v >retrieving revision 1.55 >diff -u -r1.55 BinaryIndexer.java >--- search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java 8 Jun 2006 13:08:58 -0000 1.55 >+++ search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java 14 Jun 2006 16:40:29 -0000 >@@ -677,7 +677,8 @@ > addInterfaceDeclaration(modifiers, packageName, name, enclosingTypeNames, superinterfaces, typeParameterSignatures, false); > break; > case TypeDeclaration.ENUM_DECL : >- addEnumDeclaration(modifiers, packageName, name, enclosingTypeNames, superinterfaces, false); >+ superclass = replace('/', '.', reader.getSuperclassName()); >+ addEnumDeclaration(modifiers, packageName, name, enclosingTypeNames, superclass, superinterfaces, false); > break; > case TypeDeclaration.ANNOTATION_TYPE_DECL : > addAnnotationTypeDeclaration(modifiers, packageName, name, enclosingTypeNames, false); >Index: search/org/eclipse/jdt/internal/core/index/DiskIndex.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/DiskIndex.java,v >retrieving revision 1.50 >diff -u -r1.50 DiskIndex.java >--- search/org/eclipse/jdt/internal/core/index/DiskIndex.java 8 Jun 2006 13:08:58 -0000 1.50 >+++ search/org/eclipse/jdt/internal/core/index/DiskIndex.java 14 Jun 2006 16:40:28 -0000 >@@ -37,7 +37,7 @@ > private HashtableOfObject categoryTables; // category name -> HashtableOfObject(words -> int[] of document #'s) or offset if not read yet > private char[] cachedCategoryName; > >-public static final String SIGNATURE= "INDEX VERSION 1.112"; //$NON-NLS-1$ >+public static final String SIGNATURE= "INDEX VERSION 1.113"; //$NON-NLS-1$ > public static boolean DEBUG = false; > > private static final int RE_INDEXED = -1;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 120667
: 44420