mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
factory-less RC
This commit is contained in:
@@ -1,16 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution;
|
||||
|
||||
import com.intellij.execution.configurations.*;
|
||||
@@ -150,6 +138,7 @@ public interface RunnerAndConfigurationSettings {
|
||||
*
|
||||
* @return copying factory instance
|
||||
*/
|
||||
@NotNull
|
||||
Factory<RunnerAndConfigurationSettings> createFactory();
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,11 +59,4 @@ public interface ConfigurationType extends PossiblyDumbAware {
|
||||
* @return the run configuration factories.
|
||||
*/
|
||||
ConfigurationFactory[] getConfigurationFactories();
|
||||
|
||||
/**
|
||||
* Is configuration fully managed by RunManager.
|
||||
*/
|
||||
default boolean isManaged() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,7 @@ public interface RunConfiguration extends RunProfile, Cloneable {
|
||||
/**
|
||||
* Returns the factory that has created the run configuration.
|
||||
*/
|
||||
@Nullable
|
||||
ConfigurationFactory getFactory();
|
||||
|
||||
/**
|
||||
|
||||
+5
-4
@@ -35,10 +35,10 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
|
||||
private static final String SHOW_CONSOLE_ON_STD_OUT = "show_console_on_std_out";
|
||||
private static final String SHOW_CONSOLE_ON_STD_ERR = "show_console_on_std_err";
|
||||
|
||||
@Nullable
|
||||
private final ConfigurationFactory myFactory;
|
||||
private final Project myProject;
|
||||
private String myName;
|
||||
private final Icon myIcon;
|
||||
|
||||
private RunConfigurationOptions myOptions = createOptions();
|
||||
|
||||
@@ -46,11 +46,10 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
|
||||
|
||||
private List<BeforeRunTask> myBeforeRunTasks = Collections.emptyList();
|
||||
|
||||
protected RunConfigurationBase(@NotNull Project project, @NotNull ConfigurationFactory factory, String name) {
|
||||
protected RunConfigurationBase(@NotNull Project project, @Nullable ConfigurationFactory factory, String name) {
|
||||
myProject = project;
|
||||
myFactory = factory;
|
||||
myName = name;
|
||||
myIcon = factory.getIcon();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -74,6 +73,7 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
|
||||
myBeforeRunTasks = value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public final ConfigurationFactory getFactory() {
|
||||
return myFactory;
|
||||
@@ -91,8 +91,9 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Icon getIcon() {
|
||||
return myIcon;
|
||||
return myFactory == null ? null : myFactory.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
-5
@@ -41,9 +41,4 @@ public final class UnknownConfigurationType extends ConfigurationTypeBase {
|
||||
public static ConfigurationFactory getFactory() {
|
||||
return INSTANCE.getConfigurationFactories()[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isManaged() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.intellij.execution.impl
|
||||
|
||||
import com.intellij.execution.BeforeRunTask
|
||||
import com.intellij.execution.BeforeRunTaskProvider
|
||||
import com.intellij.execution.configurations.ConfigurationFactory
|
||||
import com.intellij.execution.configurations.RunConfiguration
|
||||
import com.intellij.openapi.extensions.Extensions
|
||||
import com.intellij.util.SmartList
|
||||
@@ -30,12 +31,12 @@ internal fun getEffectiveBeforeRunTaskList(ownTasks: List<BeforeRunTask<*>>, tem
|
||||
return result
|
||||
}
|
||||
|
||||
internal fun getHardcodedBeforeRunTasks(configuration: RunConfiguration): List<BeforeRunTask<*>> {
|
||||
internal fun getHardcodedBeforeRunTasks(configuration: RunConfiguration, factory: ConfigurationFactory): List<BeforeRunTask<*>> {
|
||||
var result: MutableList<BeforeRunTask<*>>? = null
|
||||
for (provider in Extensions.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME, configuration.project)) {
|
||||
val task = provider.createTask(configuration) ?: continue
|
||||
if (task.isEnabled) {
|
||||
configuration.factory.configureBeforeRunTaskDefaults(provider.id, task)
|
||||
factory.configureBeforeRunTaskDefaults(provider.id, task)
|
||||
if (task.isEnabled) {
|
||||
if (result == null) {
|
||||
result = SmartList<BeforeRunTask<*>>()
|
||||
|
||||
@@ -257,7 +257,7 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
|
||||
if (configuration is UnknownRunConfiguration) {
|
||||
configuration.isDoNotStore = true
|
||||
}
|
||||
configuration.beforeRunTasks = getHardcodedBeforeRunTasks(configuration)
|
||||
configuration.beforeRunTasks = getHardcodedBeforeRunTasks(configuration, factory)
|
||||
return template
|
||||
}
|
||||
|
||||
@@ -733,12 +733,12 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
|
||||
if (element?.getAttributeValue("v") == null) {
|
||||
if (settings.isTemplate) {
|
||||
if (result.isNullOrEmpty()) {
|
||||
configuration.beforeRunTasks = getHardcodedBeforeRunTasks(configuration)
|
||||
configuration.beforeRunTasks = getHardcodedBeforeRunTasks(configuration, configuration.factory!!)
|
||||
return
|
||||
}
|
||||
}
|
||||
else {
|
||||
configuration.beforeRunTasks = getEffectiveBeforeRunTaskList(result ?: emptyList(), getConfigurationTemplate(configuration.factory).configuration.beforeRunTasks, true, false)
|
||||
configuration.beforeRunTasks = getEffectiveBeforeRunTaskList(result ?: emptyList(), getConfigurationTemplate(configuration.factory!!).configuration.beforeRunTasks, true, false)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -807,7 +807,7 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
|
||||
tasks.add(task as T)
|
||||
}
|
||||
else {
|
||||
val template = getConfigurationTemplate(configuration.factory)
|
||||
val template = getConfigurationTemplate(configuration.factory!!)
|
||||
if (!checkedTemplates.contains(template)) {
|
||||
checkedTemplates.add(template)
|
||||
for (templateTask in getBeforeRunTasks(template.configuration)) {
|
||||
@@ -1012,4 +1012,7 @@ private inline fun Collection<RunnerAndConfigurationSettings>.forEachManaged(han
|
||||
handler(settings)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal val ConfigurationType.isManaged: Boolean
|
||||
get() = this is UnknownRunConfiguration
|
||||
+6
-5
@@ -102,9 +102,11 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(private val m
|
||||
|
||||
override fun getConfiguration() = _configuration ?: UnknownConfigurationType.getFactory().createTemplateConfiguration(manager.project)
|
||||
|
||||
override fun createFactory() = Factory<RunnerAndConfigurationSettings> {
|
||||
val configuration = configuration
|
||||
RunnerAndConfigurationSettingsImpl(manager, configuration.factory.createConfiguration(ExecutionBundle.message("default.run.configuration.name"), configuration), false)
|
||||
override fun createFactory(): Factory<RunnerAndConfigurationSettings> {
|
||||
return Factory {
|
||||
val configuration = configuration
|
||||
RunnerAndConfigurationSettingsImpl(manager, configuration.factory!!.createConfiguration(ExecutionBundle.message("default.run.configuration.name"), configuration))
|
||||
}
|
||||
}
|
||||
|
||||
override fun setName(name: String) {
|
||||
@@ -115,7 +117,7 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(private val m
|
||||
override fun getName(): String {
|
||||
val configuration = configuration
|
||||
if (isTemplate) {
|
||||
return "<template> of ${configuration.factory.id}"
|
||||
return "<template> of ${factory.id}"
|
||||
}
|
||||
return configuration.name
|
||||
}
|
||||
@@ -229,7 +231,6 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(private val m
|
||||
// cannot be private - used externally
|
||||
fun writeExternal(element: Element) {
|
||||
val configuration = configuration
|
||||
val factory = configuration.factory
|
||||
if (configuration !is UnknownRunConfiguration) {
|
||||
if (isTemplate) {
|
||||
element.setAttribute(TEMPLATE_FLAG_ATTRIBUTE, "true")
|
||||
|
||||
+6
-16
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.impl.statistics;
|
||||
|
||||
import com.intellij.execution.RunManager;
|
||||
@@ -34,7 +20,6 @@ import java.util.Set;
|
||||
* @author Nikolay Matveev
|
||||
*/
|
||||
public abstract class AbstractRunConfigurationTypeUsagesCollector extends ProjectUsagesCollector {
|
||||
|
||||
protected abstract boolean isApplicable(@NotNull RunManager runManager, @NotNull RunnerAndConfigurationSettings settings);
|
||||
|
||||
@NotNull
|
||||
@@ -48,6 +33,11 @@ public abstract class AbstractRunConfigurationTypeUsagesCollector extends Projec
|
||||
RunConfiguration runConfiguration = settings.getConfiguration();
|
||||
if (isApplicable(runManager, settings)) {
|
||||
final ConfigurationFactory configurationFactory = runConfiguration.getFactory();
|
||||
if (configurationFactory == null) {
|
||||
// not realistic
|
||||
continue;
|
||||
}
|
||||
|
||||
final ConfigurationType configurationType = configurationFactory.getType();
|
||||
final StringBuilder keyBuilder = new StringBuilder();
|
||||
keyBuilder.append(configurationType.getId());
|
||||
|
||||
Reference in New Issue
Block a user