diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeInfo.java index 396b937c614..cce9689a05e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeInfo.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/includes/IncludeInfo.java @@ -10,9 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.includes; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; - import com.ibm.icu.text.Collator; public class IncludeInfo implements Comparable { @@ -94,18 +91,37 @@ public class IncludeInfo implements Comparable { @Override public int compareTo(IncludeInfo other) { - if (isSystem != other.isSystem) { + if (isSystem != other.isSystem) return isSystem ? -1 : 1; - } - IPath path1 = Path.fromOSString(name); - IPath path2 = Path.fromOSString(other.name); - int length1 = path1.segmentCount(); - int length2 = path2.segmentCount(); + + int length1 = name.length(); + int length2 = other.name.length(); for (int i = 0; i < length1 && i < length2; i++) { - int c = COLLATOR.compare(path1.segment(i), path2.segment(i)); - if (c != 0) - return c; + char c1 = name.charAt(i); + char c2 = other.name.charAt(i); + int o1 = order(c1); + int o2 = order(c2); + if (o1 != o2) + return o1 - o2; + if (o1 == 0) { + int c = COLLATOR.compare(String.valueOf(c1), String.valueOf(c2)); + if (c != 0) + return c; + } } return length1 - length2; } + + private int order(char c) { + switch (c) { + case '/': + return -3; + case '\\': + return -2; + case '.': + return -1; + default: + return 0; + } + } }