From 748869ab2b45ceb34b9df4c03fbc2b93f3a26f1d Mon Sep 17 00:00:00 2001 From: Jussi Koskela Date: Thu, 4 Jan 2018 10:24:58 +0200 Subject: [PATCH] List SCL references in order of reference location in search results refs #7683 Change-Id: I8842ffad7133a4dddf98e691f741ba8dbe48a95c --- .../scl/ui/search/SCLSearchResultPage.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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) { -- 2.47.1