mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't load project view nesting rules in <clinit>, remove unnecessary sorting
This commit is contained in:
+3
-2
@@ -11,6 +11,7 @@ import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.intellij.ui.table.TableView;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -141,7 +142,7 @@ public class FileNestingInProjectViewDialog extends DialogWrapper {
|
||||
return new Action[]{new DialogWrapperAction(IdeBundle.message("file.nesting.reset.to.default.button")) {
|
||||
@Override
|
||||
protected void doAction(ActionEvent e) {
|
||||
resetTable(Arrays.asList(ProjectViewFileNestingService.DEFAULT_NESTING_RULES));
|
||||
resetTable(ProjectViewFileNestingService.loadDefaultNestingRules());
|
||||
}
|
||||
}};
|
||||
}
|
||||
@@ -188,7 +189,7 @@ public class FileNestingInProjectViewDialog extends DialogWrapper {
|
||||
|
||||
private void resetTable(@NotNull final List<NestingRule> rules) {
|
||||
final SortedMap<String, CombinedNestingRule> result = new TreeMap<>();
|
||||
for (NestingRule rule : rules) {
|
||||
for (NestingRule rule : ContainerUtil.sorted(rules, ProjectViewFileNestingService.RULE_COMPARATOR)) {
|
||||
final CombinedNestingRule r = result.get(rule.getParentFileSuffix());
|
||||
if (r == null) {
|
||||
result.put(rule.getParentFileSuffix(), new CombinedNestingRule(rule.getParentFileSuffix(), rule.getChildFileSuffix()));
|
||||
|
||||
+5
-7
@@ -14,7 +14,7 @@ import com.intellij.util.xmlb.annotations.Attribute;
|
||||
import com.intellij.util.xmlb.annotations.XCollection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@@ -34,8 +34,6 @@ public class ProjectViewFileNestingService implements PersistentStateComponent<P
|
||||
static final Comparator<NestingRule> RULE_COMPARATOR =
|
||||
Comparator.comparing(o -> o.getParentFileSuffix() + " " + o.getChildFileSuffix());
|
||||
|
||||
static final NestingRule[] DEFAULT_NESTING_RULES = loadDefaultNestingRules();
|
||||
|
||||
private MyState myState = new MyState();
|
||||
private long myModCount;
|
||||
|
||||
@@ -45,8 +43,8 @@ public class ProjectViewFileNestingService implements PersistentStateComponent<P
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static NestingRule[] loadDefaultNestingRules() {
|
||||
final List<NestingRule> result = new SortedList<>(RULE_COMPARATOR);
|
||||
static List<NestingRule> loadDefaultNestingRules() {
|
||||
List<NestingRule> result = new ArrayList<>();
|
||||
|
||||
final ProjectViewNestingRulesProvider.Consumer consumer = (parentFileSuffix, childFileSuffix) -> {
|
||||
LOG.assertTrue(!parentFileSuffix.isEmpty() && !childFileSuffix.isEmpty(), "file suffix must not be empty");
|
||||
@@ -58,7 +56,7 @@ public class ProjectViewFileNestingService implements PersistentStateComponent<P
|
||||
provider.addFileNestingRules(consumer);
|
||||
}
|
||||
|
||||
return result.toArray(new NestingRule[0]);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,7 +95,7 @@ public class ProjectViewFileNestingService implements PersistentStateComponent<P
|
||||
public List<NestingRule> myRules = new SortedList<>(Comparator.comparing(o -> o.getParentFileSuffix()));
|
||||
|
||||
public MyState() {
|
||||
myRules.addAll(Arrays.asList(DEFAULT_NESTING_RULES));
|
||||
myRules.addAll(loadDefaultNestingRules());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user