-
Notifications
You must be signed in to change notification settings - Fork 8
feat: add handlers and refactor handler logic [IDE-782] #247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8d09031
feat: add handlers and refactor handler logic
bastiandoetsch 3e76b37
fix: refactoring error
bastiandoetsch c72016a
fix: handlers
bastiandoetsch c52c699
fix: possible issue description retrieval problem
bastiandoetsch 84270dd
Merge branch 'main' into feat/IDE-782_add-additional-handlers
bastiandoetsch aa2c9dd
fix: tests
bastiandoetsch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 27 additions & 2 deletions
29
plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/filters/BaseFilter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,30 @@ | ||
package io.snyk.eclipse.plugin.views.snyktoolview.filters; | ||
|
||
public interface BaseFilter { | ||
public void applyFilter(); | ||
import java.util.function.Predicate; | ||
|
||
import io.snyk.eclipse.plugin.preferences.Preferences; | ||
import io.snyk.eclipse.plugin.views.snyktoolview.TreeFilterManager; | ||
|
||
@SuppressWarnings("rawtypes") | ||
public abstract class BaseFilter { | ||
private TreeFilterManager filterManager; | ||
private Preferences preferences; | ||
protected String preferenceKey; | ||
protected Predicate predicate; | ||
|
||
public BaseFilter(String preferenceKey, Predicate predicate) { | ||
this.preferenceKey = preferenceKey; | ||
this.predicate = predicate; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public void applyFilter() { | ||
boolean booleanPref = this.preferences.getBooleanPref(this.preferenceKey); | ||
|
||
if (booleanPref) { | ||
this.filterManager.addTreeFilter(this.preferenceKey, predicate); | ||
} else { | ||
this.filterManager.removeTreeFilter(this.preferenceKey); | ||
} | ||
} | ||
} |
29 changes: 7 additions & 22 deletions
29
plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/filters/FixableFilter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,13 @@ | ||
package io.snyk.eclipse.plugin.views.snyktoolview.filters; | ||
|
||
import io.snyk.eclipse.plugin.preferences.Preferences; | ||
import io.snyk.eclipse.plugin.views.snyktoolview.TreeFilterManager; | ||
import java.util.function.Predicate; | ||
|
||
public class FixableFilter implements BaseFilter { | ||
private TreeFilterManager filterManager; | ||
private Preferences preferences; | ||
private String preferenceKey; | ||
import io.snyk.languageserver.protocolextension.messageObjects.scanResults.Issue; | ||
|
||
public FixableFilter(TreeFilterManager filterManager, Preferences preferences, String preferenceKey) { | ||
this.filterManager = filterManager; | ||
this.preferences = preferences; | ||
this.preferenceKey = preferenceKey; | ||
|
||
} | ||
|
||
@Override | ||
public void applyFilter() { | ||
boolean booleanPref = this.preferences.getBooleanPref(this.preferenceKey); | ||
|
||
if (booleanPref) { | ||
this.filterManager.addTreeFilter(this.preferenceKey, issue -> issue.hasFix()); | ||
} else { | ||
this.filterManager.removeTreeFilter(this.preferenceKey); | ||
} | ||
public class FixableFilter extends BaseFilter { | ||
private static final Predicate<Issue> predicate = issue -> issue.hasFix(); | ||
|
||
public FixableFilter(String preferenceKey) { | ||
super(preferenceKey, predicate); | ||
} | ||
} |
30 changes: 8 additions & 22 deletions
30
plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/filters/IgnoresFilter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,14 @@ | ||
package io.snyk.eclipse.plugin.views.snyktoolview.filters; | ||
|
||
import io.snyk.eclipse.plugin.preferences.Preferences; | ||
import io.snyk.eclipse.plugin.views.snyktoolview.TreeFilterManager; | ||
import java.util.function.Predicate; | ||
|
||
public class IgnoresFilter implements BaseFilter { | ||
private TreeFilterManager filterManager; | ||
private Preferences preferences; | ||
private String preferenceKey; | ||
import io.snyk.languageserver.protocolextension.messageObjects.scanResults.Issue; | ||
|
||
public IgnoresFilter(TreeFilterManager filterManager, Preferences preferences, String preferenceKey) { | ||
this.filterManager = filterManager; | ||
this.preferences = preferences; | ||
this.preferenceKey = preferenceKey; | ||
} | ||
|
||
@Override | ||
public void applyFilter() { | ||
boolean booleanPref = this.preferences.getBooleanPref(this.preferenceKey); | ||
|
||
if (booleanPref) { | ||
filterManager.removeTreeFilter(preferenceKey); | ||
} else { | ||
filterManager.addTreeFilter(preferenceKey, issue -> !issue.isIgnored()); | ||
public class IgnoresFilter extends BaseFilter { | ||
private static final Predicate<Issue> predicate = issue -> issue.isIgnored(); | ||
|
||
|
||
public IgnoresFilter(String preferenceKey) { | ||
super(preferenceKey, predicate); | ||
} | ||
|
||
} | ||
} |
28 changes: 8 additions & 20 deletions
28
.../main/java/io/snyk/eclipse/plugin/views/snyktoolview/filters/IgnoresOpenIssuesFilter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,16 @@ | ||
package io.snyk.eclipse.plugin.views.snyktoolview.filters; | ||
|
||
import java.util.function.Predicate; | ||
|
||
import io.snyk.eclipse.plugin.preferences.Preferences; | ||
import io.snyk.eclipse.plugin.views.snyktoolview.TreeFilterManager; | ||
import io.snyk.languageserver.protocolextension.messageObjects.scanResults.Issue; | ||
|
||
public class IgnoresOpenIssuesFilter implements BaseFilter { | ||
private TreeFilterManager filterManager; | ||
private Preferences preferences; | ||
private String preferenceKey; | ||
|
||
public IgnoresOpenIssuesFilter(TreeFilterManager filterManager, Preferences preferences, String preferenceKey) { | ||
this.filterManager = filterManager; | ||
this.preferences = preferences; | ||
this.preferenceKey = preferenceKey; | ||
} | ||
|
||
@Override | ||
public void applyFilter() { | ||
boolean booleanPref = this.preferences.getBooleanPref(Preferences.FILTER_IGNORES_SHOW_OPEN_ISSUES); | ||
|
||
if (booleanPref) { | ||
filterManager.removeTreeFilter(preferenceKey); | ||
} else { | ||
filterManager.addTreeFilter(preferenceKey, issue -> issue.isIgnored()); | ||
} | ||
public class IgnoresOpenIssuesFilter extends BaseFilter { | ||
// FIXME think about what happens if this and ignores are both set | ||
private static final Predicate<Issue> predicate = issue -> !issue.isIgnored(); | ||
|
||
public IgnoresOpenIssuesFilter(String preferenceKey) { | ||
super(preferenceKey, predicate); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.