From: Jussi Koskela Date: Thu, 4 Jan 2018 08:24:58 +0000 (+0200) Subject: List SCL references in order of reference location in search results X-Git-Tag: v1.43.0~136^2~638 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F49%2F1349%2F2;p=simantics%2Fplatform.git List SCL references in order of reference location in search results refs #7683 Change-Id: I8842ffad7133a4dddf98e691f741ba8dbe48a95c --- diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/search/SCLSearchResultPage.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/search/SCLSearchResultPage.java index ebc2cbf9e..86b3ea4a3 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/search/SCLSearchResultPage.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/search/SCLSearchResultPage.java @@ -29,6 +29,7 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; +import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.module.debug.SymbolReference; import org.simantics.scl.ui.editor2.OpenDeclaration; import org.simantics.scl.ui.editor2.OpenSCLDefinition; @@ -51,7 +52,19 @@ public class SCLSearchResultPage extends AbstractTextSearchViewPage { } - private static final ViewerComparator comparator = new ViewerComparator((o1, o2) -> o1.compareTo(o2)); + private static final ViewerComparator comparator = new ViewerComparator() { + @Override + public int compare(Viewer viewer, Object e1, Object e2) { + SymbolReference r1 = (SymbolReference)e1; + SymbolReference r2 = (SymbolReference)e2; + int c = r1.referrer.toString().compareTo(r2.referrer.toString()); + if (c != 0) { + return c; + } else { + return Integer.compare(Locations.beginOf(r1.referenceLocation), Locations.beginOf(r2.referenceLocation)); + } + } + }; @Override protected void configureTreeViewer(TreeViewer viewer) {