mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[Parameter Hints Settings] store blacklist diff
This commit is contained in:
+1
-1
@@ -69,7 +69,7 @@ public class ParameterHintsPassFactory extends AbstractProjectComponent implemen
|
||||
|
||||
List<Matcher> matchers = ParameterNameHintsSettings
|
||||
.getInstance()
|
||||
.getIgnorePatternList()
|
||||
.getIgnorePatternSet()
|
||||
.stream()
|
||||
.map((item) -> MatcherConstructor.INSTANCE.createMatcher(item))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
+44
-25
@@ -24,11 +24,12 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@State(name = "ParameterNameHintsSettings", storages = @Storage("parameter.name.hints.xml"))
|
||||
public class ParameterNameHintsSettings implements PersistentStateComponent<ParameterNameHintsSettings.State> {
|
||||
|
||||
public static final String[] defaultPatterns = {
|
||||
private static final int VERSION = 1;
|
||||
private static final Set<String> DEFAULT = ContainerUtil.newHashSet(
|
||||
"(begin*, end*)",
|
||||
"(start*, end*)",
|
||||
"(first*, last*)",
|
||||
@@ -50,18 +51,9 @@ public class ParameterNameHintsSettings implements PersistentStateComponent<Para
|
||||
"*.contains(*)",
|
||||
"*.startsWith(*)",
|
||||
"*.endsWith(*)"
|
||||
};
|
||||
);
|
||||
|
||||
public void addIgnorePattern(@NotNull String pattern) {
|
||||
myState.ignorePatterns.add(pattern);
|
||||
}
|
||||
|
||||
public static class State {
|
||||
public int version = 1;
|
||||
public List<String> ignorePatterns = ContainerUtil.newArrayList(defaultPatterns);
|
||||
}
|
||||
|
||||
private ParameterNameHintsSettings.State myState = new State();
|
||||
private ParameterNameHintsSettings.State state = new State();
|
||||
|
||||
public static ParameterNameHintsSettings getInstance() {
|
||||
return ServiceManager.getService(ParameterNameHintsSettings.class);
|
||||
@@ -70,29 +62,56 @@ public class ParameterNameHintsSettings implements PersistentStateComponent<Para
|
||||
@Nullable
|
||||
@Override
|
||||
public ParameterNameHintsSettings.State getState() {
|
||||
return myState;
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(ParameterNameHintsSettings.State state) {
|
||||
myState = state;
|
||||
}
|
||||
|
||||
|
||||
public int getVersion() {
|
||||
return myState.version;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public List<String> getIgnorePatternList() {
|
||||
return myState.ignorePatterns;
|
||||
public void addIgnorePattern(@NotNull String pattern) {
|
||||
state.diff.add('+' + pattern);
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return state.version;
|
||||
}
|
||||
|
||||
public Set<String> getIgnorePatternSet() {
|
||||
Set<String> ignoreSet = ContainerUtil.newHashSet(DEFAULT);
|
||||
state.diff.forEach((item) -> {
|
||||
if (item.startsWith("+")) {
|
||||
ignoreSet.add(item.substring(1));
|
||||
}
|
||||
else if (item.startsWith("-")) {
|
||||
ignoreSet.remove(item.substring(1));
|
||||
}
|
||||
});
|
||||
return ignoreSet;
|
||||
}
|
||||
|
||||
public void setVersion(int newVersion) {
|
||||
myState.version = newVersion;
|
||||
state.version = newVersion;
|
||||
}
|
||||
|
||||
public void setIgnorePatternList(@NotNull List<String> newBlacklist) {
|
||||
myState.ignorePatterns = newBlacklist;
|
||||
public void setIgnorePatternSet(@NotNull Set<String> updatedBlackList) {
|
||||
Set<String> addedItems = ContainerUtil.newHashSet(updatedBlackList);
|
||||
DEFAULT.forEach((pattern) -> addedItems.remove(pattern));
|
||||
|
||||
Set<String> removedItems = ContainerUtil.newHashSet(DEFAULT);
|
||||
updatedBlackList.forEach((pattern) -> removedItems.remove(pattern));
|
||||
|
||||
List<String> diff = ContainerUtil.newArrayList();
|
||||
addedItems.forEach((item) -> diff.add('+' + item));
|
||||
removedItems.forEach((item) -> diff.remove('-' + item));
|
||||
|
||||
state.diff = diff;
|
||||
}
|
||||
|
||||
public static class State {
|
||||
public int version = VERSION;
|
||||
public List<String> diff = ContainerUtil.newArrayList();
|
||||
}
|
||||
|
||||
}
|
||||
+5
-4
@@ -32,6 +32,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ParameterNameHintsConfigurable extends DialogWrapper {
|
||||
@@ -61,13 +62,13 @@ public class ParameterNameHintsConfigurable extends DialogWrapper {
|
||||
protected void doOKAction() {
|
||||
super.doOKAction();
|
||||
|
||||
List<String> updatedBlackList = StringUtil
|
||||
Set<String> updatedBlackList = StringUtil
|
||||
.split(myEditorTextField.getText(), "\n")
|
||||
.stream()
|
||||
.filter((e) -> !e.trim().isEmpty())
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
ParameterNameHintsSettings.getInstance().setIgnorePatternList(updatedBlackList);
|
||||
ParameterNameHintsSettings.getInstance().setIgnorePatternSet(updatedBlackList);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -83,7 +84,7 @@ public class ParameterNameHintsConfigurable extends DialogWrapper {
|
||||
EditorTextFieldProvider service = ServiceManager.getService(myProject, EditorTextFieldProvider.class);
|
||||
myEditorTextField = service.getEditorField(PlainTextLanguage.INSTANCE, myProject, ContainerUtil.emptyIterable());
|
||||
|
||||
List<String> blacklist = ParameterNameHintsSettings.getInstance().getIgnorePatternList();
|
||||
Set<String> blacklist = ParameterNameHintsSettings.getInstance().getIgnorePatternSet();
|
||||
String text = StringUtil.join(blacklist, "\n");
|
||||
|
||||
myEditorTextField.setText(text);
|
||||
|
||||
Reference in New Issue
Block a user