mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
simplify code and avoid list allocation
This commit is contained in:
@@ -825,32 +825,38 @@ class RunConfigurable extends BaseConfigurable {
|
||||
}
|
||||
|
||||
final RunManagerImpl runManager = getRunManager();
|
||||
final List<RunConfiguration> allConfigurations = runManager.getAllConfigurationsList();
|
||||
final List<RunConfiguration> currentConfigurations = new ArrayList<>();
|
||||
final List<RunnerAndConfigurationSettings> allSettings = runManager.getAllSettings();
|
||||
final List<RunnerAndConfigurationSettings> currentSettings = new ArrayList<>();
|
||||
for (int i = 0; i < myRoot.getChildCount(); i++) {
|
||||
DefaultMutableTreeNode typeNode = (DefaultMutableTreeNode)myRoot.getChildAt(i);
|
||||
final Object object = typeNode.getUserObject();
|
||||
if (object instanceof ConfigurationType) {
|
||||
List<DefaultMutableTreeNode> configurationNodes = new ArrayList<>();
|
||||
collectNodesRecursively(typeNode, configurationNodes, CONFIGURATION, TEMPORARY_CONFIGURATION);
|
||||
if (runManager.getConfigurationSettingsList((ConfigurationType)object).size() != configurationNodes.size()) {
|
||||
return true;
|
||||
}
|
||||
if (!(object instanceof ConfigurationType)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < configurationNodes.size(); j++) {
|
||||
final Object userObject = configurationNodes.get(j).getUserObject();
|
||||
if (userObject instanceof SingleConfigurationConfigurable) {
|
||||
SingleConfigurationConfigurable configurable = (SingleConfigurationConfigurable)userObject;
|
||||
if (configurable.isModified()) return true;
|
||||
currentConfigurations.add(configurable.getConfiguration());
|
||||
}
|
||||
else if (userObject instanceof RunnerAndConfigurationSettingsImpl) {
|
||||
currentConfigurations.add(((RunnerAndConfigurationSettings)userObject).getConfiguration());
|
||||
List<DefaultMutableTreeNode> configurationNodes = new ArrayList<>();
|
||||
collectNodesRecursively(typeNode, configurationNodes, CONFIGURATION, TEMPORARY_CONFIGURATION);
|
||||
if (RunConfigurableHelperKt.countSettingsOfType(allSettings, (ConfigurationType)object) != configurationNodes.size()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (DefaultMutableTreeNode configurationNode : configurationNodes) {
|
||||
final Object userObject = configurationNode.getUserObject();
|
||||
if (userObject instanceof SingleConfigurationConfigurable) {
|
||||
SingleConfigurationConfigurable configurable = (SingleConfigurationConfigurable)userObject;
|
||||
if (configurable.isModified()) {
|
||||
return true;
|
||||
}
|
||||
currentSettings.add((RunnerAndConfigurationSettings)configurable.getSettings());
|
||||
}
|
||||
else if (userObject instanceof RunnerAndConfigurationSettings) {
|
||||
currentSettings.add(((RunnerAndConfigurationSettings)userObject));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (allConfigurations.size() != currentConfigurations.size() || !allConfigurations.containsAll(currentConfigurations)) return true;
|
||||
if (allSettings.size() != currentSettings.size() || !allSettings.containsAll(currentSettings)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Configurable configurable : myStoredComponents.values()) {
|
||||
if (configurable.isModified()) return true;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.impl
|
||||
|
||||
import com.intellij.execution.RunnerAndConfigurationSettings
|
||||
import com.intellij.execution.configurations.ConfigurationType
|
||||
|
||||
fun countSettingsOfType(allSettings: List<RunnerAndConfigurationSettings>, type: ConfigurationType) = allSettings.count { it.type == type }
|
||||
Reference in New Issue
Block a user