From 69ecf165725a19235c6c166471a33189985848bb Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Thu, 2 Sep 2004 17:04:25 +0000 Subject: [PATCH] 2004-09-02 Alain Magloire Deal with WorkingCopy vs TranslationUnit in the hashCode. * src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java --- core/org.eclipse.cdt.ui/ChangeLog | 5 +++++ .../internal/ui/cview/CViewElementComparer.java | 14 ++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) 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(); } }