GitOrigin-RevId: 8edcbb87c482c4d73925aa9f3f9211368b29b2d2
This commit is contained in:
Vladimir Krivosheev
2020-05-16 16:34:41 +00:00
committed by intellij-monorepo-bot
parent 7f7188b8ad
commit 3ffbaa92d3
15 changed files with 122 additions and 177 deletions
@@ -1,18 +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-2020 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.packaging.impl.run;
import com.intellij.execution.BeforeRunTask;
@@ -29,7 +15,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public abstract class BuildArtifactsBeforeRunTaskBase<Self extends BuildArtifactsBeforeRunTaskBase>
public abstract class BuildArtifactsBeforeRunTaskBase<Self extends BuildArtifactsBeforeRunTaskBase<?>>
extends BeforeRunTask<Self> {
@NonNls public static final String NAME_ATTRIBUTE = "name";
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// Copyright 2000-2020 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.packaging.impl.run;
import com.intellij.execution.BeforeRunTaskProvider;
@@ -30,7 +30,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public abstract class BuildArtifactsBeforeRunTaskProviderBase<T extends BuildArtifactsBeforeRunTaskBase>
public abstract class BuildArtifactsBeforeRunTaskProviderBase<T extends BuildArtifactsBeforeRunTaskBase<?>>
extends BeforeRunTaskProvider<T> {
private final Project myProject;
@NotNull final private Class<T> myTaskClass;
@@ -99,7 +99,7 @@ public abstract class BuildArtifactsBeforeRunTaskProviderBase<T extends BuildArt
@Override
public boolean canExecuteTask(@NotNull RunConfiguration configuration, @NotNull T task) {
for (ArtifactPointer pointer : (List<ArtifactPointer>)task.getArtifactPointers()) {
for (ArtifactPointer pointer : task.getArtifactPointers()) {
if (pointer.getArtifact() != null) {
return true;
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2020 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;
import com.intellij.execution.*;
@@ -17,7 +17,7 @@ import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.ThreeStateCheckBox;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.tree.TreeUtil;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -33,9 +33,7 @@ import java.awt.event.MouseEvent;
import java.util.List;
import java.util.*;
public abstract class BaseExecuteBeforeRunDialog<T extends BeforeRunTask> extends DialogWrapper {
public abstract class BaseExecuteBeforeRunDialog<T extends BeforeRunTask<?>> extends DialogWrapper {
private final static Object TEMPLATE_ROOT = new Object();
private final Project myProject;
private DefaultMutableTreeNode myRoot;
@@ -107,11 +105,11 @@ public abstract class BaseExecuteBeforeRunDialog<T extends BeforeRunTask> extend
private static void expandChecked(Tree tree) {
TreeNode root = (TreeNode)tree.getModel().getRoot();
Enumeration factories = root.children();
Enumeration<?> factories = root.children();
ArrayList<TreeNode[]> toExpand = new ArrayList<>();
while (factories.hasMoreElements()) {
DefaultMutableTreeNode factoryNode = (DefaultMutableTreeNode)factories.nextElement();
Enumeration configurations = factoryNode.children();
Enumeration<?> configurations = factoryNode.children();
while (configurations.hasMoreElements()) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)configurations.nextElement();
Descriptor config = (Descriptor)node.getUserObject();
@@ -154,7 +152,7 @@ public abstract class BaseExecuteBeforeRunDialog<T extends BeforeRunTask> extend
GroupConfigurationDescriptor groupConfigurationDescriptor = new GroupConfigurationDescriptor(type, icon);
DefaultMutableTreeNode typeNode = new DefaultMutableTreeNode(groupConfigurationDescriptor);
root.add(typeNode);
final Set<String> addedNames = new THashSet<>();
Set<String> addedNames = new ObjectOpenHashSet<>();
for (List<RunnerAndConfigurationSettings> list : entry.getValue().values()) {
for (RunnerAndConfigurationSettings configuration : list) {
final String configurationName = configuration.getName();
@@ -169,17 +167,16 @@ public abstract class BaseExecuteBeforeRunDialog<T extends BeforeRunTask> extend
groupConfigurationDescriptor.setChecked(selectedAll);
}
}
buildTemplatesNode(root, runManager);
buildTemplatesNode(root);
return root;
}
private void buildTemplatesNode(DefaultMutableTreeNode root, RunManagerImpl manager) {
private void buildTemplatesNode(DefaultMutableTreeNode root) {
DefaultMutableTreeNode node = new DefaultMutableTreeNode(TEMPLATE_ROOT);
root.add(node);
for (ConfigurationType type : ConfigurationType.CONFIGURATION_TYPE_EP.getExtensionList()) {
final Icon icon = type.getIcon();
DefaultMutableTreeNode typeNode =
new DefaultMutableTreeNode(new ConfigurationTypeDescriptor(type, icon, isConfigurationAssigned(type)));
Icon icon = type.getIcon();
DefaultMutableTreeNode typeNode = new DefaultMutableTreeNode(new ConfigurationTypeDescriptor(type, icon, isConfigurationAssigned(type)));
node.add(typeNode);
}
}
@@ -194,7 +191,7 @@ public abstract class BaseExecuteBeforeRunDialog<T extends BeforeRunTask> extend
}
private boolean isConfigurationAssigned(RunConfiguration configuration) {
for (T task : RunManagerEx.getInstanceEx(myProject).getBeforeRunTasks(configuration, getTaskID())) {
for (T task : RunManagerEx.getInstanceEx(myProject).getBeforeRunTasks(configuration, getTaskId())) {
if (isRunning(task))
return true;
}
@@ -204,7 +201,7 @@ public abstract class BaseExecuteBeforeRunDialog<T extends BeforeRunTask> extend
@Override
protected void doOKAction() {
final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(myProject);
for (Enumeration nodes = myRoot.depthFirstEnumeration(); nodes.hasMoreElements(); ) {
for (Enumeration<?> nodes = myRoot.depthFirstEnumeration(); nodes.hasMoreElements(); ) {
final DefaultMutableTreeNode node = (DefaultMutableTreeNode)nodes.nextElement();
Object object = node.getUserObject();
if (!(object instanceof Descriptor)) {
@@ -232,18 +229,18 @@ public abstract class BaseExecuteBeforeRunDialog<T extends BeforeRunTask> extend
protected abstract String getTargetDisplayString();
protected abstract Key<T> getTaskID();
protected abstract Key<T> getTaskId();
protected abstract boolean isRunning(T task);
private void update(RunConfiguration config, boolean enabled, RunManagerImpl runManager) {
List<BeforeRunTask<?>> tasks = RunManagerImplKt.doGetBeforeRunTasks(config);
BeforeRunTaskProvider<T> provider = BeforeRunTaskProvider.getProvider(myProject, getTaskID());
BeforeRunTaskProvider<T> provider = BeforeRunTaskProvider.getProvider(myProject, getTaskId());
if (provider == null) {
return;
}
T task = provider.createTask(config);
T task = Objects.requireNonNull(provider.createTask(config));
update(task);
task.setEnabled(true);
if (enabled) {
@@ -261,7 +258,7 @@ public abstract class BaseExecuteBeforeRunDialog<T extends BeforeRunTask> extend
runManager.setBeforeRunTasks(config, tasks);
}
protected abstract void update(T task);
protected abstract void update(@NotNull T task);
protected abstract void clear(T task);
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// Copyright 2000-2020 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;
import com.intellij.execution.BeforeRunTask;
@@ -13,6 +13,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonShortcuts;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.ListPopup;
import com.intellij.openapi.util.Conditions;
@@ -21,7 +22,7 @@ import com.intellij.ui.*;
import com.intellij.ui.components.JBList;
import com.intellij.ui.scale.JBUIScale;
import com.intellij.util.SmartList;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -50,7 +51,7 @@ final class BeforeRunStepsPanel extends JPanel {
private final StepsBeforeRunListener myListener;
private final JPanel myPanel;
private final Set<BeforeRunTask<?>> clonedTasks = new THashSet<>();
private final Set<BeforeRunTask<?>> clonedTasks = new ObjectOpenHashSet<>();
BeforeRunStepsPanel(@NotNull StepsBeforeRunListener listener) {
myListener = listener;
@@ -159,15 +160,13 @@ final class BeforeRunStepsPanel extends JPanel {
updateText();
}
@Nullable
private BeforeRunTaskAndProvider getSelection() {
final int index = myList.getSelectedIndex();
private @Nullable BeforeRunTaskAndProvider getSelection() {
int index = myList.getSelectedIndex();
if (index == -1) {
return null;
}
BeforeRunTask<?> task = myModel.getElementAt(index);
@SuppressWarnings("unchecked")
BeforeRunTaskProvider<BeforeRunTask<?>> provider = BeforeRunTaskProvider.getProvider(myRunConfiguration.getProject(), (Key)task.getProviderId());
BeforeRunTaskProvider<BeforeRunTask<?>> provider = getProvider(myRunConfiguration.getProject(), task.getProviderId());
return provider == null ? null : new BeforeRunTaskAndProvider(task, provider, index);
}
@@ -196,8 +195,7 @@ final class BeforeRunStepsPanel extends JPanel {
myListener.titleChanged(title + suffix);
}
@NotNull
public List<BeforeRunTask<?>> getTasks() {
public @NotNull List<BeforeRunTask<?>> getTasks() {
List<BeforeRunTask<?>> items = myModel.getItems();
return items.isEmpty() ? Collections.emptyList() : Collections.unmodifiableList(items);
}
@@ -215,8 +213,8 @@ final class BeforeRunStepsPanel extends JPanel {
return false;
}
Set<Key> activeProviderKeys = getActiveProviderKeys();
for (final BeforeRunTaskProvider<BeforeRunTask> provider : getBeforeRunTaskProviders()) {
Set<Key<?>> activeProviderKeys = getActiveProviderKeys();
for (BeforeRunTaskProvider<BeforeRunTask<?>> provider : getBeforeRunTaskProviders()) {
if (provider.createTask(myRunConfiguration) != null) {
if (!checkOnlyAddAction) {
return true;
@@ -238,9 +236,9 @@ final class BeforeRunStepsPanel extends JPanel {
return;
}
Set<Key> activeProviderKeys = getActiveProviderKeys();
Set<Key<?>> activeProviderKeys = getActiveProviderKeys();
DefaultActionGroup actionGroup = new DefaultActionGroup();
for (final BeforeRunTaskProvider<BeforeRunTask> provider : getBeforeRunTaskProviders()) {
for (BeforeRunTaskProvider<BeforeRunTask<?>> provider : getBeforeRunTaskProviders()) {
if (provider.createTask(myRunConfiguration) == null || activeProviderKeys.contains(provider.getId()) && provider.isSingleton()) {
continue;
}
@@ -248,7 +246,7 @@ final class BeforeRunStepsPanel extends JPanel {
actionGroup.add(new AnAction(provider.getName(), null, provider.getIcon()) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
BeforeRunTask task = provider.createTask(myRunConfiguration);
BeforeRunTask<?> task = provider.createTask(myRunConfiguration);
if (task == null) {
return;
}
@@ -260,7 +258,7 @@ final class BeforeRunStepsPanel extends JPanel {
}
task.setEnabled(true);
Set<RunConfiguration> configurationSet = new THashSet<>();
Set<RunConfiguration> configurationSet = new ObjectOpenHashSet<>();
getAllRunBeforeRuns(task, configurationSet);
if (configurationSet.contains(myRunConfiguration)) {
JOptionPane.showMessageDialog(BeforeRunStepsPanel.this,
@@ -282,28 +280,27 @@ final class BeforeRunStepsPanel extends JPanel {
popup.show(Objects.requireNonNull(button.getPreferredPopupPoint()));
}
@NotNull
private List<BeforeRunTaskProvider<BeforeRunTask>> getBeforeRunTaskProviders() {
return BeforeRunTaskProvider.EXTENSION_POINT_NAME.getExtensionList(myRunConfiguration.getProject());
private @NotNull List<BeforeRunTaskProvider<BeforeRunTask<?>>> getBeforeRunTaskProviders() {
return BeforeRunTaskProvider.EP_NAME.getExtensions(myRunConfiguration.getProject());
}
public void addTask(@NotNull BeforeRunTask task) {
public void addTask(@NotNull BeforeRunTask<?> task) {
myModel.add(task);
}
@NotNull
private Set<Key> getActiveProviderKeys() {
Set<Key> result = new THashSet<>();
for (BeforeRunTask task : myModel.getItems()) {
private @NotNull Set<Key<?>> getActiveProviderKeys() {
List<BeforeRunTask<?>> items = myModel.getItems();
Set<Key<?>> result = new ObjectOpenHashSet<>(items.size());
for (BeforeRunTask<?> task : items) {
result.add(task.getProviderId());
}
return result;
}
private void getAllRunBeforeRuns(@NotNull BeforeRunTask task, @NotNull Set<? super RunConfiguration> configurationSet) {
private void getAllRunBeforeRuns(@NotNull BeforeRunTask<?> task, @NotNull Set<? super RunConfiguration> configurationSet) {
if (task instanceof RunConfigurableBeforeRunTask) {
RunConfiguration configuration = Objects.requireNonNull(((RunConfigurableBeforeRunTask)task).getSettings()).getConfiguration();
for (BeforeRunTask beforeRunTask : RunManagerImplKt.doGetBeforeRunTasks(configuration)) {
for (BeforeRunTask<?> beforeRunTask : RunManagerImplKt.doGetBeforeRunTasks(configuration)) {
if (beforeRunTask instanceof RunConfigurableBeforeRunTask) {
if (configurationSet.add(Objects.requireNonNull(((RunConfigurableBeforeRunTask)beforeRunTask).getSettings()).getConfiguration())) {
getAllRunBeforeRuns(beforeRunTask, configurationSet);
@@ -319,14 +316,13 @@ final class BeforeRunStepsPanel extends JPanel {
void titleChanged(@NotNull String title);
}
private class MyListCellRenderer extends JBList.StripedListCellRenderer {
private final class MyListCellRenderer extends JBList.StripedListCellRenderer {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof BeforeRunTask) {
BeforeRunTask task = (BeforeRunTask)value;
@SuppressWarnings("unchecked")
BeforeRunTaskProvider<BeforeRunTask> provider = BeforeRunTaskProvider.getProvider(myRunConfiguration.getProject(), task.getProviderId());
BeforeRunTask<?> task = (BeforeRunTask<?>)value;
BeforeRunTaskProvider<BeforeRunTask<?>> provider = getProvider(myRunConfiguration.getProject(), task.getProviderId());
if (provider != null) {
Icon icon = provider.getTaskIcon(task);
setIcon(icon != null ? icon : provider.getIcon());
@@ -336,4 +332,13 @@ final class BeforeRunStepsPanel extends JPanel {
return this;
}
}
private static @Nullable BeforeRunTaskProvider<BeforeRunTask<?>> getProvider(@NotNull Project project, Key<?> key) {
for (BeforeRunTaskProvider<BeforeRunTask<?>> provider : BeforeRunTaskProvider.EP_NAME.getIterable(project)) {
if (provider.getId() == key) {
return provider;
}
}
return null;
}
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2020 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
import com.intellij.execution.BeforeRunTask
@@ -32,7 +32,7 @@ internal fun getEffectiveBeforeRunTaskList(ownTasks: List<BeforeRunTask<*>>, tem
internal fun getHardcodedBeforeRunTasks(configuration: RunConfiguration, factory: ConfigurationFactory): List<BeforeRunTask<*>> {
var result: MutableList<BeforeRunTask<*>>? = null
for (provider in BeforeRunTaskProvider.EXTENSION_POINT_NAME.getExtensionList(configuration.project)) {
for (provider in BeforeRunTaskProvider.EP_NAME.getExtensions(configuration.project)) {
val task = provider.createTask(configuration) ?: continue
if (task.isEnabled) {
factory.configureBeforeRunTaskDefaults(provider.id, task)
@@ -4,7 +4,6 @@ package com.intellij.execution.impl
import com.intellij.ProjectTopics
import com.intellij.configurationStore.*
import com.intellij.execution.*
import com.intellij.execution.configuration.ConfigurationFactoryEx
import com.intellij.execution.configurations.*
import com.intellij.execution.runners.ExecutionEnvironment
import com.intellij.execution.runners.ExecutionUtil
@@ -195,7 +194,7 @@ open class RunManagerImpl @JvmOverloads constructor(val project: Project, shared
private val stringIdToBeforeRunProvider = object : ClearableLazyValue<ConcurrentMap<String, BeforeRunTaskProvider<*>>>() {
override fun compute(): ConcurrentMap<String, BeforeRunTaskProvider<*>> {
val result = ConcurrentHashMap<String, BeforeRunTaskProvider<*>>()
for (provider in BeforeRunTaskProvider.EXTENSION_POINT_NAME.getExtensionList(project)) {
for (provider in BeforeRunTaskProvider.EP_NAME.getExtensions(project)) {
result.put(provider.id.toString(), provider)
}
return result
@@ -222,7 +221,7 @@ open class RunManagerImpl @JvmOverloads constructor(val project: Project, shared
}
})
BeforeRunTaskProvider.EXTENSION_POINT_NAME.getPoint(project).addChangeListener(Runnable(stringIdToBeforeRunProvider::drop), project)
BeforeRunTaskProvider.EP_NAME.getPoint(project).addChangeListener(Runnable(stringIdToBeforeRunProvider::drop), project)
}
private fun clearSelectedConfigurationIcon() {
@@ -239,7 +238,7 @@ open class RunManagerImpl @JvmOverloads constructor(val project: Project, shared
private fun buildConfigurationTypeMap(factories: List<ConfigurationType>): Map<String, ConfigurationType> {
val types = factories.toMutableList()
types.add(UnknownConfigurationType.getInstance())
val map = THashMap<String, ConfigurationType>()
val map = HashMap<String, ConfigurationType>()
for (type in types) {
map.put(type.id, type)
}
@@ -691,7 +690,7 @@ open class RunManagerImpl @JvmOverloads constructor(val project: Project, shared
settings.setConfiguration(configuration)
}
}
lock.write { templateIdToConfiguration.retainEntries { _, settings -> settings.type != extension } }
}
}, this)
@@ -1308,13 +1307,13 @@ internal fun RunConfiguration.cloneBeforeRunTasks() {
fun callNewConfigurationCreated(factory: ConfigurationFactory, configuration: RunConfiguration) {
@Suppress("UNCHECKED_CAST", "DEPRECATION")
(factory as? ConfigurationFactoryEx<RunConfiguration>)?.onNewConfigurationCreated(configuration)
(factory as? com.intellij.execution.configuration.ConfigurationFactoryEx<RunConfiguration>)?.onNewConfigurationCreated(configuration)
(configuration as? ConfigurationCreationListener)?.onNewConfigurationCreated()
}
private fun getFactoryKey(factory: ConfigurationFactory): String {
return when {
factory.type is SimpleConfigurationType -> factory.type.id
return when (factory.type) {
is SimpleConfigurationType -> factory.type.id
else -> "${factory.type.id}.${factory.id}"
}
}
@@ -26,8 +26,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class BeforeRunFragment<S extends RunConfigurationBase<?>> extends RunConfigurationEditorFragment<S, BeforeRunFragment.BeforeRunComponent> {
public final class BeforeRunFragment<S extends RunConfigurationBase<?>> extends RunConfigurationEditorFragment<S, BeforeRunFragment.BeforeRunComponent> {
public static <S extends RunConfigurationBase<?>> List<SettingsEditorFragment<S, ?>> createGroup() {
ArrayList<SettingsEditorFragment<S, ?>> list = new ArrayList<>();
list.add(new BeforeRunFragment<>());
@@ -107,9 +106,10 @@ public class BeforeRunFragment<S extends RunConfigurationBase<?>> extends RunCon
if (myTags == null) {
myTags = new ArrayList<>();
RunConfiguration configuration = s.getConfiguration();
for (BeforeRunTaskProvider<BeforeRunTask> provider : BeforeRunTaskProvider.EXTENSION_POINT_NAME
.getExtensionList(configuration.getProject())) {
if (provider.createTask(configuration) == null) continue;
for (BeforeRunTaskProvider<BeforeRunTask<?>> provider : BeforeRunTaskProvider.EP_NAME.getExtensions(configuration.getProject())) {
if (provider.createTask(configuration) == null) {
continue;
}
TaskButton button = new TaskButton(provider);
add(button);
myTags.add(button);
@@ -123,13 +123,14 @@ public class BeforeRunFragment<S extends RunConfigurationBase<?>> extends RunCon
public void apply(RunnerAndConfigurationSettingsImpl s) {
RunConfiguration configuration = s.getConfiguration();
List<BeforeRunTask> tasks =
myTags.stream().filter(button -> button.isVisible()).map(button -> button.myProvider.createTask(configuration))
.collect(Collectors.toList());
List<BeforeRunTask<?>> tasks = myTags.stream()
.filter(button -> button.isVisible())
.map(button -> button.myProvider.createTask(configuration))
.collect(Collectors.toList());
s.getManager().setBeforeRunTasks(configuration, tasks);
}
private class TaskButton extends TagButton {
private final class TaskButton extends TagButton {
@NotNull private final BeforeRunTaskProvider<?> myProvider;
private TaskButton(BeforeRunTaskProvider<?> provider) {
@@ -4,6 +4,7 @@ package com.intellij.openapi.extensions;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.extensions.impl.ExtensionProcessingHelper;
import com.intellij.util.ThreeState;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -75,4 +76,9 @@ public final class ProjectExtensionPointName<T> extends BaseExtensionPointName<T
public void processWithPluginDescriptor(@NotNull AreaInstance areaInstance, @NotNull BiConsumer<? super T, ? super PluginDescriptor> consumer) {
getPointImpl(areaInstance).processWithPluginDescriptor(true, consumer);
}
@ApiStatus.Experimental
public final @NotNull Iterable<T> getIterable(@NotNull AreaInstance areaInstance) {
return getPointImpl(areaInstance);
}
}
@@ -1,18 +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-2020 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;
@@ -21,12 +7,8 @@ import com.intellij.openapi.util.Key;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
/**
* @author Eugene Zhuravlev
*/
public abstract class BeforeRunTask<T extends BeforeRunTask> implements Cloneable {
@NotNull
protected final Key<T> myProviderId;
public abstract class BeforeRunTask<T extends BeforeRunTask<?>> implements Cloneable {
protected final @NotNull Key<T> myProviderId;
// cannot be set to true by default, because RunManager.getHardcodedBeforeRunTasks creates before run task for each provider
// and some providers set enabled to true in the constructor to indicate, that before run task should be added to RC by default (on create)
@@ -36,8 +18,7 @@ public abstract class BeforeRunTask<T extends BeforeRunTask> implements Cloneabl
myProviderId = providerId;
}
@NotNull
public final Key<T> getProviderId() {
public final @NotNull Key<T> getProviderId() {
return myProviderId;
}
@@ -93,7 +74,7 @@ public abstract class BeforeRunTask<T extends BeforeRunTask> implements Cloneabl
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BeforeRunTask that = (BeforeRunTask)o;
BeforeRunTask<?> that = (BeforeRunTask<?>)o;
if (myProviderId != that.myProviderId) return false;
if (myIsEnabled != that.myIsEnabled) return false;
@@ -1,10 +1,11 @@
// Copyright 2000-2019 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.
// Copyright 2000-2020 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.RunConfiguration;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.extensions.ProjectExtensionPointName;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import org.jetbrains.annotations.NotNull;
@@ -14,16 +15,22 @@ import org.jetbrains.concurrency.Promises;
import javax.swing.*;
public abstract class BeforeRunTaskProvider<T extends BeforeRunTask> {
public static final ExtensionPointName<BeforeRunTaskProvider<BeforeRunTask>> EXTENSION_POINT_NAME =
public abstract class BeforeRunTaskProvider<T extends BeforeRunTask<?>> {
public static final ProjectExtensionPointName<BeforeRunTaskProvider<BeforeRunTask<?>>> EP_NAME =
new ProjectExtensionPointName<>("com.intellij.stepsBeforeRunProvider");
/**
* @deprecated Use {@link #EP_NAME}
*/
@Deprecated
public static final ExtensionPointName<BeforeRunTaskProvider<BeforeRunTask<?>>> EXTENSION_POINT_NAME =
new ExtensionPointName<>("com.intellij.stepsBeforeRunProvider");
public abstract Key<T> getId();
public abstract String getName();
@Nullable
public Icon getIcon() {
public @Nullable Icon getIcon() {
return null;
}
@@ -31,8 +38,7 @@ public abstract class BeforeRunTaskProvider<T extends BeforeRunTask> {
return getName();
}
@Nullable
public Icon getTaskIcon(T task) {
public @Nullable Icon getTaskIcon(T task) {
return null;
}
@@ -43,8 +49,7 @@ public abstract class BeforeRunTaskProvider<T extends BeforeRunTask> {
/**
* @return 'before run' task for the configuration or null, if the task from this provider is not applicable to the specified configuration
*/
@Nullable
public abstract T createTask(@NotNull RunConfiguration runConfiguration);
public abstract @Nullable T createTask(@NotNull RunConfiguration runConfiguration);
/**
* @return {@code true} if task configuration is changed
@@ -77,9 +82,8 @@ public abstract class BeforeRunTaskProvider<T extends BeforeRunTask> {
return false;
}
@Nullable
public static <T extends BeforeRunTask> BeforeRunTaskProvider<T> getProvider(@NotNull Project project, Key<T> key) {
for (BeforeRunTaskProvider<BeforeRunTask> provider : EXTENSION_POINT_NAME.getExtensionList(project)) {
public static @Nullable <T extends BeforeRunTask<?>> BeforeRunTaskProvider<T> getProvider(@NotNull Project project, Key<T> key) {
for (BeforeRunTaskProvider<BeforeRunTask<?>> provider : EP_NAME.getIterable(project)) {
if (provider.getId() == key) {
//noinspection unchecked
return (BeforeRunTaskProvider<T>)provider;
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// Copyright 2000-2020 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.configurations;
import com.intellij.execution.BeforeRunTask;
@@ -35,8 +35,7 @@ public interface RunConfiguration extends RunProfile, Cloneable {
/**
* Returns the type of the run configuration.
*/
@NotNull
default ConfigurationType getType() {
default @NotNull ConfigurationType getType() {
ConfigurationFactory factory = getFactory();
return factory == null ? UnknownConfigurationType.getInstance() : factory.getType();
}
@@ -44,8 +43,7 @@ public interface RunConfiguration extends RunProfile, Cloneable {
/**
* Returns the factory that has created the run configuration.
*/
@Nullable
ConfigurationFactory getFactory();
@Nullable ConfigurationFactory getFactory();
// do not annotate as Nullable because in this case Kotlin compiler will forbid field style access (because of different nullability for getter and setter).
/**
@@ -61,8 +59,7 @@ public interface RunConfiguration extends RunProfile, Cloneable {
*
* @return the settings editor component.
*/
@NotNull
SettingsEditor<? extends RunConfiguration> getConfigurationEditor();
@NotNull SettingsEditor<? extends RunConfiguration> getConfigurationEditor();
/**
* Returns the project in which the run configuration exists.
@@ -76,8 +73,7 @@ public interface RunConfiguration extends RunProfile, Cloneable {
* @param provider source of assorted information about the configuration being edited.
* @return the per-runner settings.
*/
@Nullable
default ConfigurationPerRunnerSettings createRunnerSettings(ConfigurationInfoProvider provider) {
default @Nullable ConfigurationPerRunnerSettings createRunnerSettings(ConfigurationInfoProvider provider) {
return null;
}
@@ -88,8 +84,7 @@ public interface RunConfiguration extends RunProfile, Cloneable {
* @param runner the runner the settings for which need to be edited.
* @return the editor for the per-runner settings.
*/
@Nullable
default SettingsEditor<ConfigurationPerRunnerSettings> getRunnerSettingsEditor(ProgramRunner runner) {
default @Nullable SettingsEditor<ConfigurationPerRunnerSettings> getRunnerSettingsEditor(ProgramRunner runner) {
return null;
}
@@ -113,14 +108,12 @@ public interface RunConfiguration extends RunProfile, Cloneable {
* Returns the unique identifier of the run configuration. Return null if not applicable.
* Used only for non-managed RC type.
*/
@Nullable
default String getId() {
default @Nullable String getId() {
return null;
}
@NotNull
@Transient
default String getPresentableType() {
default @NotNull String getPresentableType() {
if (PlatformUtils.isPhpStorm()) {
return " (" + StringUtil.first(getType().getDisplayName(), 10, true) + ")";
}
@@ -154,8 +147,7 @@ public interface RunConfiguration extends RunProfile, Cloneable {
default void writeExternal(@NotNull Element element) {
}
@NotNull
default List<BeforeRunTask<?>> getBeforeRunTasks() {
default @NotNull List<BeforeRunTask<?>> getBeforeRunTasks() {
return Collections.emptyList();
}
@@ -18,11 +18,11 @@ import org.jetbrains.annotations.Nullable;
import java.util.List;
public abstract class AbstractToolBeforeRunTask<ToolBeforeRunTask extends AbstractToolBeforeRunTask, T extends Tool>
public abstract class AbstractToolBeforeRunTask<ToolBeforeRunTask extends AbstractToolBeforeRunTask<?, ?>, T extends Tool>
extends BeforeRunTask<ToolBeforeRunTask> {
@NonNls private final static String ACTION_ID_ATTRIBUTE = "actionId";
private static final Logger LOG = Logger.getInstance(AbstractToolBeforeRunTask.class);
protected String myToolActionId;
private String myToolActionId;
public AbstractToolBeforeRunTask(Key<ToolBeforeRunTask> providerId) {
super(providerId);
@@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public abstract class AbstractToolBeforeRunTaskProvider<T extends AbstractToolBeforeRunTask> extends BeforeRunTaskProvider<T> {
public abstract class AbstractToolBeforeRunTaskProvider<T extends AbstractToolBeforeRunTask<?, ?>> extends BeforeRunTaskProvider<T> {
protected static final Logger LOG = Logger.getInstance(ToolBeforeRunTaskProvider.class);
@Override
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2009 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-2020 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.lang.ant.config.explorer;
import com.intellij.execution.impl.BaseExecuteBeforeRunDialog;
@@ -23,6 +9,7 @@ import com.intellij.lang.ant.config.impl.AntBeforeRunTaskProvider;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
public final class AntExecuteBeforeRunDialog extends BaseExecuteBeforeRunDialog<AntBeforeRunTask> {
private final AntBuildTarget myTarget;
@@ -39,7 +26,7 @@ public final class AntExecuteBeforeRunDialog extends BaseExecuteBeforeRunDialog<
}
@Override
protected Key<AntBeforeRunTask> getTaskID() {
protected Key<AntBeforeRunTask> getTaskId() {
return AntBeforeRunTaskProvider.ID;
}
@@ -49,7 +36,7 @@ public final class AntExecuteBeforeRunDialog extends BaseExecuteBeforeRunDialog<
}
@Override
protected void update(AntBeforeRunTask task) {
protected void update(@NotNull AntBeforeRunTask task) {
VirtualFile f = myTarget.getModel().getBuildFile().getVirtualFile();
task.setAntFileUrl(f != null ? f.getUrl() : null);
task.setTargetName(f != null ? myTarget.getName() : null);
@@ -1,23 +1,10 @@
/*
* Copyright 2000-2009 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-2020 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 org.jetbrains.idea.maven.tasks.actions;
import com.intellij.execution.impl.BaseExecuteBeforeRunDialog;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.maven.project.MavenProject;
import org.jetbrains.idea.maven.tasks.MavenBeforeRunTask;
import org.jetbrains.idea.maven.tasks.MavenBeforeRunTasksProvider;
@@ -40,7 +27,7 @@ public class MavenExecuteBeforeRunDialog extends BaseExecuteBeforeRunDialog<Mave
}
@Override
protected Key<MavenBeforeRunTask> getTaskID() {
protected Key<MavenBeforeRunTask> getTaskId() {
return MavenBeforeRunTasksProvider.ID;
}
@@ -50,7 +37,7 @@ public class MavenExecuteBeforeRunDialog extends BaseExecuteBeforeRunDialog<Mave
}
@Override
protected void update(MavenBeforeRunTask task) {
protected void update(@NotNull MavenBeforeRunTask task) {
task.setProjectPath(myMavenProject.getPath());
task.setGoal(myGoal);
}