Fixing duplicate entries from SCL search result page 50/1350/4
authorjsimomaa <jani.simomaa@gmail.com>
Thu, 4 Jan 2018 11:24:45 +0000 (13:24 +0200)
committerJani Simomaa <jani.simomaa@semantum.fi>
Fri, 5 Jan 2018 20:48:25 +0000 (22:48 +0200)
refs #7683

Change-Id: Ie57502323d18be7106f1264688b2a500bc37465d

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

index 86b3ea4a359632b6fab1b78fe6f4fa604599a9d1..f38d8d539ead6f35c863b9c89bcb057c8ee02e53 100644 (file)
@@ -1,15 +1,17 @@
 package org.simantics.scl.ui.search;
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 
 import org.eclipse.jface.viewers.AbstractTreeViewer;
 import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
 import org.eclipse.jface.viewers.DecorationContext;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
 import org.eclipse.jface.viewers.IColorProvider;
 import org.eclipse.jface.viewers.ILabelProvider;
 import org.eclipse.jface.viewers.ILabelProviderListener;
@@ -21,7 +23,6 @@ import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
 import org.eclipse.search.ui.text.AbstractTextSearchResult;
 import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
 import org.eclipse.search.ui.text.Match;
@@ -31,7 +32,6 @@ 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;
 
 public class SCLSearchResultPage extends AbstractTextSearchViewPage {
@@ -145,6 +145,17 @@ public class SCLSearchResultPage extends AbstractTextSearchViewPage {
             Set<Object> toRemove= new HashSet<>();
             Set<Object> toUpdate= new HashSet<>();
             Map<Object, Set<Object>> toAdd= new HashMap<>();
+            
+            // TODO: Clear this for now at this point but probably this has some 
+            // side-effects once nested children can be shown, never?
+            for (Entry<Object, Set<Object>> e : fChildrenMap.entrySet()) {
+                Collection<Object> refs = (Collection<Object>) e.getValue();
+                refs.forEach(r -> {
+                    remove(toRemove, toUpdate, r);
+                });
+            }
+            
+            
             for (int i= 0; i < updatedElements.length; i++) {
                 if (getPage().getDisplayedMatchCount(updatedElements[i]) > 0)
                     insert(toAdd, toUpdate, updatedElements[i]);