diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index d3266eb935a..60846085d7c 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,8 @@ +2004-09-02 Alain Magloire + + Deal with WorkingCopy vs TranslationUnit in the hashCode. + * src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java + 2004-09-02 Bogdan Gheorghe Fix for 72816: [Search] Selection Search For Working Set diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java index 332fa3d1cd8..b8bfa1b7c60 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java @@ -58,15 +58,13 @@ public class CViewElementComparer implements IElementComparer { ICElement c1= (o1 instanceof ICElement) ? (ICElement)o1 : null; if (c1 == null) return o1.hashCode(); - if (c1 instanceof ITranslationUnit) { - ITranslationUnit t1= (ITranslationUnit)c1; - if (t1.isWorkingCopy()) { - c1= ((IWorkingCopy)t1).getOriginalElement(); - } - } - if (c1 == null) { + ITranslationUnit u1= (ITranslationUnit)c1.getAncestor(ICElement.C_UNIT); + if (u1 == null || !u1.isWorkingCopy()) return o1.hashCode(); - } + // From here on c1 is a working copy. + c1= ((IWorkingCopy)u1).getOriginal(c1); + if (c1 == null) + return o1.hashCode(); return c1.hashCode(); } }