]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
List SCL references in order of reference location in search results 49/1349/2
authorJussi Koskela <jussi.koskela@semantum.fi>
Thu, 4 Jan 2018 08:24:58 +0000 (10:24 +0200)
committerJani Simomaa <jani.simomaa@semantum.fi>
Thu, 4 Jan 2018 11:25:32 +0000 (13:25 +0200)
refs #7683

Change-Id: I8842ffad7133a4dddf98e691f741ba8dbe48a95c

bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/search/SCLSearchResultPage.java

index ebc2cbf9ed9c3f144aa65168ef10711e8a83cda6..86b3ea4a359632b6fab1b78fe6f4fa604599a9d1 100644 (file)
@@ -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) {