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 110592 Details for
Bug 239096
Implementation oddness in TypeHierarchy#getAllSuper*(IType)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix and tests
239096.txt (text/plain), 5.08 KB, created by
Jerome Lanneluc
on 2008-08-21 12:52:29 EDT
(
hide
)
Description:
Proposed fix and tests
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2008-08-21 12:52:29 EDT
Size:
5.08 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java,v >retrieving revision 1.103 >diff -u -r1.103 TypeHierarchy.java >--- model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java 27 Jun 2008 16:04:14 -0000 1.103 >+++ model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java 21 Aug 2008 16:48:26 -0000 >@@ -438,54 +438,62 @@ > * @see ITypeHierarchy > */ > public IType[] getAllSuperInterfaces(IType type) { >- ArrayList supers = new ArrayList(); >- if (this.typeToSuperInterfaces.get(type) == null) { >+ ArrayList supers = getAllSuperInterfaces0(type, null); >+ if (supers == null) > return NO_TYPE; >- } >- getAllSuperInterfaces0(type, supers); > IType[] superinterfaces = new IType[supers.size()]; > supers.toArray(superinterfaces); > return superinterfaces; > } >-private void getAllSuperInterfaces0(IType type, ArrayList supers) { >+private ArrayList getAllSuperInterfaces0(IType type, ArrayList supers) { > IType[] superinterfaces = (IType[]) this.typeToSuperInterfaces.get(type); >- if (superinterfaces != null && superinterfaces.length != 0) { >+ if (superinterfaces == null) // type is not part of the hierarchy >+ return supers; >+ if (superinterfaces.length != 0) { >+ if (supers == null) >+ supers = new ArrayList(); > addAllCheckingDuplicates(supers, superinterfaces); > for (int i = 0; i < superinterfaces.length; i++) { >- getAllSuperInterfaces0(superinterfaces[i], supers); >+ supers = getAllSuperInterfaces0(superinterfaces[i], supers); > } > } > IType superclass = (IType) this.classToSuperclass.get(type); > if (superclass != null) { >- getAllSuperInterfaces0(superclass, supers); >+ supers = getAllSuperInterfaces0(superclass, supers); > } >+ return supers; > } > /** > * @see ITypeHierarchy > */ > public IType[] getAllSupertypes(IType type) { >- ArrayList supers = new ArrayList(); >- if (this.typeToSuperInterfaces.get(type) == null) { >+ ArrayList supers = getAllSupertypes0(type, null); >+ if (supers == null) > return NO_TYPE; >- } >- getAllSupertypes0(type, supers); > IType[] supertypes = new IType[supers.size()]; > supers.toArray(supertypes); > return supertypes; > } >-private void getAllSupertypes0(IType type, ArrayList supers) { >+private ArrayList getAllSupertypes0(IType type, ArrayList supers) { > IType[] superinterfaces = (IType[]) this.typeToSuperInterfaces.get(type); >- if (superinterfaces != null && superinterfaces.length != 0) { >+ if (superinterfaces == null) // type is not part of the hierarchy >+ return supers; >+ if (superinterfaces.length != 0) { >+ if (supers == null) >+ supers = new ArrayList(); > addAllCheckingDuplicates(supers, superinterfaces); > for (int i = 0; i < superinterfaces.length; i++) { >- getAllSuperInterfaces0(superinterfaces[i], supers); >+ supers = getAllSuperInterfaces0(superinterfaces[i], supers); > } > } > IType superclass = (IType) this.classToSuperclass.get(type); > if (superclass != null) { >+ if (supers == null) >+ supers = new ArrayList(); > supers.add(superclass); >- getAllSupertypes0(superclass, supers); >+ supers = getAllSupertypes0(superclass, supers); > } >+ return supers; > } > /** > * @see ITypeHierarchy >#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.90 >diff -u -r1.90 TypeHierarchyTests.java >--- src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 27 Jun 2008 16:02:38 -0000 1.90 >+++ src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 21 Aug 2008 16:48:30 -0000 >@@ -1240,6 +1240,34 @@ > types); > } > /** >+ * Ensures that the correct supertypes of a type exist in the type >+ * hierarchy. >+ * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=239096 ) >+ */ >+public void testGetAllSupertypes3() throws JavaModelException { >+ IType type = getCompilationUnit("TypeHierarchy", "src", "p1", "A.java").getType("B"); >+ ITypeHierarchy hierarchy = type.newTypeHierarchy(null); >+ IType[] types = hierarchy.getAllSupertypes(type); >+ assertTypesEqual( >+ "Unexpected all super types of B", >+ "java.lang.Object\n", >+ types); >+} >+/** >+ * Ensures that the correct supertypes of a type exist in the type >+ * hierarchy. >+ * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=239096 ) >+ */ >+public void testGetAllSupertypes4() throws JavaModelException { >+ IType type = getCompilationUnit("TypeHierarchy", "src", "p1", "A.java").getType("B"); >+ ITypeHierarchy hierarchy = type.newTypeHierarchy(null); >+ IType[] types = hierarchy.getAllSuperInterfaces(type); >+ assertTypesEqual( >+ "Unexpected all super interfaces of B", >+ "", >+ types); >+} >+/** > * Ensures that the correct types exist in the type > * hierarchy. > */
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 239096
: 110592