Skip to content

Commit 5a18762

Browse files
committed
Merge branch 'main' into feat/IDE-715_filter-tree
2 parents 16c5cf2 + efb46f9 commit 5a18762

8 files changed

Lines changed: 87 additions & 6 deletions

File tree

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterCriticalHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
2929
return null;
3030
}
3131

32-
}

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterHighHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,3 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
2828
return null;
2929
}
3030

31-
}

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterIgnoresIgnoredIssuesHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
2727

2828
return null;
2929
}
30-
}

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterIgnoresOpenIssuesHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
2929

3030
return null;
3131
}
32-
}

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterLowHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,3 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
2828
return null;
2929
}
3030

31-
}

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterMediumHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
2929
return null;
3030
}
3131

32-
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package io.snyk.eclipse.plugin.views.snyktoolview.handlers;
2+
3+
import org.eclipse.core.commands.ExecutionEvent;
4+
import org.eclipse.core.commands.ExecutionException;
5+
import org.eclipse.jface.viewers.TreeViewer;
6+
import org.eclipse.ui.PlatformUI;
7+
import org.eclipse.ui.commands.ICommandService;
8+
import org.eclipse.ui.commands.IElementUpdater;
9+
10+
import io.snyk.eclipse.plugin.SnykStartup;
11+
import io.snyk.eclipse.plugin.properties.preferences.Preferences;
12+
import io.snyk.eclipse.plugin.utils.SnykIcons;
13+
import io.snyk.eclipse.plugin.views.snyktoolview.TreeViewerFilter;
14+
15+
public class snykFilterFixableIssuesHandler extends BaseHandler implements IElementUpdater {
16+
17+
public snykFilterFixableIssuesHandler() {
18+
super();
19+
20+
iconEnabled = SnykIcons.ENABLED;
21+
iconDisabled = SnykIcons.DISABLED;
22+
preferenceKey = Preferences.FILTER_FIXABLE_ISSUES;
23+
}
24+
25+
@Override
26+
public Object execute(ExecutionEvent event) throws ExecutionException {
27+
28+
TreeViewer treeView = SnykStartup.getView().getTreeViewer();
29+
TreeViewerFilter filter = new TreeViewerFilter();
30+
31+
filter.addSearchText("⚡"); // Ai Fix filter flash string
32+
33+
// TODO remove these search strings and make sure we just filter out items of
34+
// the correct node type in our TreeViewerFilter.select() function.
35+
filter.addSearchText("Open Source");
36+
filter.addSearchText("Code");
37+
filter.addSearchText("Configuration");
38+
39+
// TODO Add the correct filter strings here when we have items in the treeview.
40+
// The fixable states open source issues can have are one of: Fixable,
41+
// Partially Fixable, No Supported Fix, Any Fixability Level
42+
// filter.addSearchText(""); // OSS Upgradable filter string
43+
44+
filter.setMatchAll(false);
45+
46+
boolean booleanPref = Preferences.getInstance().getBooleanPref(preferenceKey);
47+
if (booleanPref) {
48+
applyTreeFilter(treeView, filter);
49+
} else {
50+
removeTreeFilter(treeView);
51+
}
52+
53+
// Update the application state for the preference.
54+
Preferences.getInstance().store(preferenceKey, Boolean.valueOf(!booleanPref).toString());
55+
56+
// Lastly update the UI.
57+
String commandId = event.getCommand().getId();
58+
ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
59+
if (commandService != null) {
60+
commandService.refreshElements(commandId, null);
61+
}
62+
63+
return null;
64+
}
65+
66+
private void removeTreeFilter(TreeViewer treeView) {
67+
treeView.resetFilters();
68+
updateTree(treeView);
69+
}
70+
71+
private void applyTreeFilter(TreeViewer treeView, TreeViewerFilter filter) {
72+
treeView.addFilter(filter);
73+
updateTree(treeView);
74+
}
75+
76+
private void updateTree(TreeViewer treeView) {
77+
treeView.getControl().setRedraw(false);
78+
treeView.refresh();
79+
treeView.getControl().setRedraw(true);
80+
}
81+
82+
}

tests/src/test/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClientTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ void testPublishDiagnosticsShouldChangeCache() {
202202
future.get(10, TimeUnit.SECONDS);
203203
} catch (Exception ex) {
204204

205+
Collection<Issue> actualIssueList = null;
206+
if (issue.additionalData().isSecurityType()) {
207+
actualIssueList = issueCache.getCodeSecurityIssuesForPath(filePath);
208+
} else {
209+
actualIssueList = issueCache.getCodeQualityIssuesForPath(filePath);
205210
}
206211

207212
Collection<Issue> actualIssueList = null;

0 commit comments

Comments
 (0)