From 351b9ed6256590b38beab4e819a142b72eaacf42 Mon Sep 17 00:00:00 2001 From: "Dmitriy.Panov" Date: Fri, 28 Sep 2018 11:39:44 +0300 Subject: [PATCH 01/62] IJI-9: `git abort` on failed `git rebase`, more details on exception --- .../src/org/jetbrains/intellij/build/images/sync/gitUtils.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/build-scripts/icons/src/org/jetbrains/intellij/build/images/sync/gitUtils.kt b/platform/build-scripts/icons/src/org/jetbrains/intellij/build/images/sync/gitUtils.kt index e8babf275724..430dfcd1ff56 100644 --- a/platform/build-scripts/icons/src/org/jetbrains/intellij/build/images/sync/gitUtils.kt +++ b/platform/build-scripts/icons/src/org/jetbrains/intellij/build/images/sync/gitUtils.kt @@ -37,7 +37,9 @@ private fun listGitTree( listOf(GIT, "pull", "--rebase").execute(repo) } catch (e: Exception) { - listOf(GIT, "rebase", "--abort").execute(repo) + callSafely { + listOf(GIT, "rebase", "--abort").execute(repo) + } throw e } return listOf(GIT, "ls-tree", "HEAD", "-r", relativeDirToList) From b53fa7c736089321ac6697e752b8dec3f366d3b4 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Fri, 28 Sep 2018 11:44:08 +0300 Subject: [PATCH 02/62] fix blinking DaemonRespondToChangesTest.testCodeFoldingPassRestartsOnRegionUnfolding Sometimes a situation occurs when daemon highlighting is canceled is restarted by GeneralHighlightingPass, but DaemonCodeAnalyzerImpl.isRunningOrPending returns 'false', so DaemonRespondToChangesTest.waitForDaemon returns before highlighting has finished actually --- .../daemon/impl/GeneralHighlightingPass.java | 10 ++++++++++ .../daemon/impl/DaemonCodeAnalyzerImpl.java | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java index 930243222b75..efd7a30e1449 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java @@ -47,6 +47,7 @@ import com.intellij.xml.util.XmlStringUtil; import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; import java.util.*; import java.util.concurrent.TimeUnit; @@ -424,12 +425,21 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP private static final int POST_UPDATE_ALL = 5; + private static final AtomicInteger RESTART_REQUESTS = new AtomicInteger(); + + @TestOnly + static boolean isRestartPending() { + return RESTART_REQUESTS.get() > 0; + } + private static void cancelAndRestartDaemonLater(@NotNull ProgressIndicator progress, @NotNull final Project project) throws ProcessCanceledException { + RESTART_REQUESTS.incrementAndGet(); progress.cancel(); Application application = ApplicationManager.getApplication(); int delay = application.isUnitTestMode() ? 0 : RESTART_DAEMON_RANDOM.nextInt(100); EdtExecutorService.getScheduledExecutorInstance().schedule(() -> { + RESTART_REQUESTS.decrementAndGet(); if (!project.isDisposed()) { DaemonCodeAnalyzer.getInstance(project).restart(); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java index 8a46fc7d959f..5412f9996523 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java @@ -599,7 +599,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements Pers @TestOnly public boolean isRunningOrPending() { ApplicationManager.getApplication().assertIsDispatchThread(); - return isRunning() || !myUpdateRunnableFuture.isDone(); + return isRunning() || !myUpdateRunnableFuture.isDone() || GeneralHighlightingPass.isRestartPending(); } // return true if the progress really was canceled From 6fb3d6e02f06792d87e98010aaa95d7bbb3a347d Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 28 Sep 2018 11:16:08 +0200 Subject: [PATCH 03/62] use dedicated API for subtree updates --- .../lang/ant/config/explorer/AntExplorer.java | 34 +++++++------------ 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntExplorer.java b/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntExplorer.java index 1a907b28f425..f4b0b0c1d1ec 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntExplorer.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntExplorer.java @@ -41,7 +41,6 @@ import com.intellij.psi.PsiElement; import com.intellij.ui.*; import com.intellij.ui.tree.AsyncTreeModel; import com.intellij.ui.tree.StructureTreeModel; -import com.intellij.ui.tree.TreeVisitor; import com.intellij.ui.treeStructure.Tree; import com.intellij.util.EditSourceOnDoubleClickHandler; import com.intellij.util.Function; @@ -128,19 +127,7 @@ public class AntExplorer extends SimpleToolWindowPanel implements DataProvider, @Override public void buildFileChanged(AntBuildFile buildFile) { - TreeUtil.visit(myTree, path -> { - final AntNodeDescriptor descriptor = TreeUtil.getLastUserObject(AntNodeDescriptor.class, path); - if (descriptor != null) { - final Object element = descriptor.getElement(); - if (element instanceof AntBuildFile) { - return buildFile.equals(element) ? TreeVisitor.Action.INTERRUPT : TreeVisitor.Action.SKIP_CHILDREN; - } - if (element instanceof AntBuildTarget) { - return TreeVisitor.Action.SKIP_SIBLINGS; - } - } - return TreeVisitor.Action.CONTINUE; - }, path -> treeModel.invalidate(path, true)); + treeModel.invalidate(buildFile, true); } @Override @@ -437,10 +424,11 @@ public class AntExplorer extends SimpleToolWindowPanel implements DataProvider, @Nullable private AntBuildFileNodeDescriptor getCurrentBuildFileNodeDescriptor() { - if (myTree == null) { + final Tree tree = myTree; + if (tree == null) { return null; } - final TreePath path = myTree.getSelectionPath(); + final TreePath path = tree.getSelectionPath(); if (path == null) { return null; } @@ -815,12 +803,14 @@ public class AntExplorer extends SimpleToolWindowPanel implements DataProvider, @Override public void actionPerformed(@NotNull AnActionEvent e) { final AntBuildFile buildFile = getCurrentBuildFile(); - final List targets = getTargetNamesFromPaths(myTree.getSelectionPaths()); - final ExecuteCompositeTargetEvent event = new ExecuteCompositeTargetEvent(targets); - final SaveMetaTargetDialog dialog = new SaveMetaTargetDialog(myTree, event, AntConfigurationBase.getInstance(myProject), buildFile); - dialog.setTitle(e.getPresentation().getText()); - if (dialog.showAndGet()) { - myTreeModel.invalidate(); + if (buildFile != null) { + final List targets = getTargetNamesFromPaths(myTree.getSelectionPaths()); + final ExecuteCompositeTargetEvent event = new ExecuteCompositeTargetEvent(targets); + final SaveMetaTargetDialog dialog = new SaveMetaTargetDialog(myTree, event, AntConfigurationBase.getInstance(myProject), buildFile); + dialog.setTitle(e.getPresentation().getText()); + if (dialog.showAndGet()) { + myTreeModel.invalidate(buildFile, true); + } } } From 5cb290e9a55a65c9577c0b53c07b402e9cf264b9 Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Fri, 28 Sep 2018 12:28:43 +0300 Subject: [PATCH 04/62] Bugfix: skip macro when it's not specified in parameters --- .../intellij/execution/util/ProgramParametersConfigurator.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/lang-impl/src/com/intellij/execution/util/ProgramParametersConfigurator.java b/platform/lang-impl/src/com/intellij/execution/util/ProgramParametersConfigurator.java index 51677ab47890..4c3f134d17ab 100644 --- a/platform/lang-impl/src/com/intellij/execution/util/ProgramParametersConfigurator.java +++ b/platform/lang-impl/src/com/intellij/execution/util/ProgramParametersConfigurator.java @@ -71,6 +71,7 @@ public class ProgramParametersConfigurator { if (path != null && Registry.is("allow.macros.for.run.configurations")) { Collection macros = MacroManager.getInstance().getMacros(); for (Macro macro: macros) { + if (!path.contains("$" + macro.getName())) continue; String value = StringUtil.notNullize( macro instanceof PromptMacro ? ((PromptMacro)macro).promptUser(): macro.preview(), ""); From 2e56d3c5e674866cc7a17f06dbc1d18597f23afa Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 28 Sep 2018 10:58:57 +0200 Subject: [PATCH 05/62] compute keyToType only if need --- .../src/RunConfigurationListReader.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/configuration-script/src/RunConfigurationListReader.kt b/plugins/configuration-script/src/RunConfigurationListReader.kt index 72556879bebb..2a8f0fe91032 100644 --- a/plugins/configuration-script/src/RunConfigurationListReader.kt +++ b/plugins/configuration-script/src/RunConfigurationListReader.kt @@ -16,11 +16,7 @@ import org.yaml.snakeyaml.nodes.SequenceNode internal class RunConfigurationListReader(private val processor: (factory: ConfigurationFactory, state: Any) -> Unit) { // rc grouped by type fun read(parentNode: MappingNode, isTemplatesOnly: Boolean) { - val keyToType = THashMap() - processConfigurationTypes { configurationType, propertyName, _ -> - keyToType.put(propertyName.toString(), configurationType) - } - + var keyToType: MutableMap? = null for (tuple in parentNode.value) { val keyNode = tuple.keyNode if (keyNode !is ScalarNode) { @@ -35,6 +31,14 @@ internal class RunConfigurationListReader(private val processor: (factory: Confi continue } + // compute keyToType only if need + if (keyToType == null) { + keyToType = THashMap() + processConfigurationTypes { configurationType, propertyName, _ -> + keyToType.put(propertyName.toString(), configurationType) + } + } + val configurationType = keyToType.get(keyNode.value) if (configurationType == null) { LOG.warn("Unknown run configuration type: ${keyNode.value}") From fcd488390b4ea02fdd364661002b058400342c5c Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 28 Sep 2018 11:49:12 +0200 Subject: [PATCH 06/62] IDEA-98563 IntelliJ Project Configuration must allow to configure base properties for ANY run configuration regardless of is RC migrated to persistence state component or not --- .../application/ApplicationConfiguration.java | 4 ++-- .../configurations/RunConfigurationBase.java | 10 +++++----- .../com/intellij/openapi/components/BaseState.kt | 13 +++++++++---- .../src/RunConfigurationListReader.kt | 9 +-------- .../providers/runConfigurationTemplateProvider.kt | 2 +- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java index 77f1e5dd0cce..471f952c2158 100644 --- a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java +++ b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java @@ -307,8 +307,8 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration extends UserDataHolderBase impleme result.doCopyOptionsFrom(this); return result; } - + void doCopyOptionsFrom(@NotNull RunConfigurationBase template) { myOptions.copyFrom(template.myOptions); myOptions.resetModificationCount(); @@ -198,7 +198,7 @@ public abstract class RunConfigurationBase extends UserDataHolderBase impleme public void customizeLogConsole(LogConsole console) { } - + @Nullable public T getState() { //noinspection unchecked @@ -226,8 +226,8 @@ public abstract class RunConfigurationBase extends UserDataHolderBase impleme } @ApiStatus.Experimental - public void setState(@NotNull BaseState state) { - myOptions = (RunConfigurationOptions)state; + public void setOptionsFromConfigurationFile(@NotNull BaseState state) { + myOptions.copyFrom(state, /* isMustBeTheSameType= */false); } // we can break compatibility and make this method final (API is new and used only by our plugins), but let's avoid any inconvenience and mark as "final" after/prior to 2018.3 release. @@ -305,7 +305,7 @@ public abstract class RunConfigurationBase extends UserDataHolderBase impleme public boolean excludeCompileBeforeLaunchOption() { return false; } - + @Override public String toString() { return getType().getDisplayName() + ": " + getName(); diff --git a/platform/projectModel-api/src/com/intellij/openapi/components/BaseState.kt b/platform/projectModel-api/src/com/intellij/openapi/components/BaseState.kt index 41cb4afcdf4c..f30d9d979a1b 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/components/BaseState.kt +++ b/platform/projectModel-api/src/com/intellij/openapi/components/BaseState.kt @@ -210,11 +210,16 @@ abstract class BaseState : SerializationFilter, ModificationTracker { return builder.toString() } - fun copyFrom(state: BaseState) { - LOG.assertTrue(state.properties.size == properties.size) + @JvmOverloads + fun copyFrom(state: BaseState, isMustBeTheSameType: Boolean = true) { + val propertyCount = state.properties.size + if (isMustBeTheSameType) { + LOG.assertTrue(propertyCount == properties.size) + } + var changed = false - for ((index, property) in properties.withIndex()) { - val otherProperty = state.properties.get(index) + for ((index, otherProperty) in state.properties.withIndex()) { + val property = properties.get(index) LOG.assertTrue(otherProperty.name == property.name) if (property.setValue(otherProperty)) { changed = true diff --git a/plugins/configuration-script/src/RunConfigurationListReader.kt b/plugins/configuration-script/src/RunConfigurationListReader.kt index 2a8f0fe91032..349b3f1308f8 100644 --- a/plugins/configuration-script/src/RunConfigurationListReader.kt +++ b/plugins/configuration-script/src/RunConfigurationListReader.kt @@ -4,7 +4,6 @@ import com.intellij.execution.configurations.ConfigurationFactory import com.intellij.execution.configurations.ConfigurationType import com.intellij.execution.configurations.RunConfigurationOptions import com.intellij.openapi.components.BaseState -import com.intellij.openapi.diagnostic.debug import com.intellij.openapi.diagnostic.runAndLogException import com.intellij.util.ReflectionUtil import gnu.trove.THashMap @@ -51,7 +50,6 @@ internal class RunConfigurationListReader(private val processor: (factory: Confi } val valueNode = tuple.valueNode - if (factories.size > 1) { if (valueNode !is MappingNode) { LOG.warn("Unexpected valueNode type: ${valueNode.nodeId}") @@ -87,12 +85,7 @@ internal class RunConfigurationListReader(private val processor: (factory: Confi } private fun readRunConfigurationGroup(node: Node, factory: ConfigurationFactory) { - val optionsClass = factory.optionsClass - if (optionsClass == null) { - LOG.debug { "Configuration factory \"${factory.name}\" is not described because options class not defined" } - return - } - + val optionsClass = factory.optionsClass ?: RunConfigurationOptions::class.java if (node is MappingNode) { // direct child LOG.runAndLogException { diff --git a/plugins/configuration-script/src/providers/runConfigurationTemplateProvider.kt b/plugins/configuration-script/src/providers/runConfigurationTemplateProvider.kt index 5f3a3deee628..b8f2f39791c4 100644 --- a/plugins/configuration-script/src/providers/runConfigurationTemplateProvider.kt +++ b/plugins/configuration-script/src/providers/runConfigurationTemplateProvider.kt @@ -52,7 +52,7 @@ private class MyRunConfigurationTemplateProvider(private val project: Project) : (configuration as PersistentStateComponent).loadState(item.state!!) } else { - (configuration as RunConfigurationBase<*>).setState(item.state as BaseState) + (configuration as RunConfigurationBase<*>).setOptionsFromConfigurationFile(item.state as BaseState) } settings = RunnerAndConfigurationSettingsImpl(runManager, configuration, isTemplate = true) item.state = null From 4b70cbc6cd8f3a6be16370baa9f6b6ee87aca976 Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Fri, 28 Sep 2018 12:56:15 +0300 Subject: [PATCH 07/62] ensure new empty file for context test --- .../intellij/tasks/context/ContextTest.java | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/plugins/tasks/tasks-tests/test/com/intellij/tasks/context/ContextTest.java b/plugins/tasks/tasks-tests/test/com/intellij/tasks/context/ContextTest.java index 075417652925..28daf1e81eff 100644 --- a/plugins/tasks/tasks-tests/test/com/intellij/tasks/context/ContextTest.java +++ b/plugins/tasks/tasks-tests/test/com/intellij/tasks/context/ContextTest.java @@ -50,21 +50,31 @@ public class ContextTest extends TaskManagerTestCase { } public void testPack() throws Exception { + ProjectImpl project = (ProjectImpl)getProject(); + String name = project.getName(); WorkingContextManager contextManager = getContextManager(); - for (int i = 0; i < 5; i++) { - contextManager.saveContext("context" + i, null); - Thread.sleep(2000); + try { + project.setProjectName("pack"); + contextManager.getContextFile().delete(); + + for (int i = 0; i < 5; i++) { + contextManager.saveContext("context" + i, null); + Thread.sleep(2000); + } + List history = contextManager.getContextHistory(); + ContextInfo first = history.get(0); + System.out.println(first.date); + ContextInfo last = history.get(history.size() - 1); + System.out.println(last.date); + contextManager.pack(3, 1); + history = contextManager.getContextHistory(); + assertEquals(3, history.size()); + System.out.println(history.get(0).date); + assertEquals("/context2", history.get(0).name); + } + finally { + project.setProjectName(name); } - List history = contextManager.getContextHistory(); - ContextInfo first = history.get(0); - System.out.println(first.date); - ContextInfo last = history.get(history.size() - 1); - System.out.println(last.date); - contextManager.pack(3, 1); - history = contextManager.getContextHistory(); - assertEquals(3, history.size()); - System.out.println(history.get(0).date); - assertEquals("/context2", history.get(0).name); } public void testContextFileRepair() throws Exception { From 90fc647ff729bd8467d5c86750e38c3b9acedbe3 Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Fri, 28 Sep 2018 12:56:58 +0300 Subject: [PATCH 08/62] clear old entries --- .../util/src/com/intellij/util/io/zip/JBZipFile.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/platform/util/src/com/intellij/util/io/zip/JBZipFile.java b/platform/util/src/com/intellij/util/io/zip/JBZipFile.java index 0b7dcc9ae653..f932df487222 100644 --- a/platform/util/src/com/intellij/util/io/zip/JBZipFile.java +++ b/platform/util/src/com/intellij/util/io/zip/JBZipFile.java @@ -439,15 +439,17 @@ public class JBZipFile implements Closeable { myOutputStream.finish(); myOutputStream = null; - final Map existingEntries = new LinkedHashMap(); - for (Map.Entry entry : nameMap.entrySet()) { - existingEntries.put(entry.getKey(), entry.getValue().getData()); + final Map existingEntries = new LinkedHashMap(); + for (JBZipEntry entry : entries) { + existingEntries.put(entry, entry.getData()); } currentCfdOffset = 0; nameMap.clear(); - for (Map.Entry entry : existingEntries.entrySet()) { - JBZipEntry zipEntry = getOrCreateEntry(entry.getKey()); + entries.clear(); + for (Map.Entry entry : existingEntries.entrySet()) { + JBZipEntry zipEntry = getOrCreateEntry(entry.getKey().getName()); + zipEntry.setComment(entry.getKey().getComment()); zipEntry.setData(entry.getValue()); } getOutputStream().finish(); From 800c9526a1569ae1289ffe7f8526f4377eb948de Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Fri, 28 Sep 2018 13:11:53 +0300 Subject: [PATCH 09/62] IDEA-199646 Input dialog should be displayed only when there is $Prompt$ in run configuration arguments --- .../intellij/execution/util/ProgramParametersConfigurator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/execution/util/ProgramParametersConfigurator.java b/platform/lang-impl/src/com/intellij/execution/util/ProgramParametersConfigurator.java index 4c3f134d17ab..14062a845405 100644 --- a/platform/lang-impl/src/com/intellij/execution/util/ProgramParametersConfigurator.java +++ b/platform/lang-impl/src/com/intellij/execution/util/ProgramParametersConfigurator.java @@ -71,7 +71,7 @@ public class ProgramParametersConfigurator { if (path != null && Registry.is("allow.macros.for.run.configurations")) { Collection macros = MacroManager.getInstance().getMacros(); for (Macro macro: macros) { - if (!path.contains("$" + macro.getName())) continue; + if (!path.contains("$" + macro.getName() + "$")) continue; String value = StringUtil.notNullize( macro instanceof PromptMacro ? ((PromptMacro)macro).promptUser(): macro.preview(), ""); From fb8a6e93ec75539f910cf2d3a208eb9c4ff9d5a7 Mon Sep 17 00:00:00 2001 From: "Dmitriy.Panov" Date: Fri, 28 Sep 2018 13:14:15 +0300 Subject: [PATCH 10/62] IJI-9: `git abort` on failed `git rebase`, do not fail, print message --- .../src/org/jetbrains/intellij/build/images/sync/gitUtils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/build-scripts/icons/src/org/jetbrains/intellij/build/images/sync/gitUtils.kt b/platform/build-scripts/icons/src/org/jetbrains/intellij/build/images/sync/gitUtils.kt index 430dfcd1ff56..db4705dcc26e 100644 --- a/platform/build-scripts/icons/src/org/jetbrains/intellij/build/images/sync/gitUtils.kt +++ b/platform/build-scripts/icons/src/org/jetbrains/intellij/build/images/sync/gitUtils.kt @@ -40,7 +40,7 @@ private fun listGitTree( callSafely { listOf(GIT, "rebase", "--abort").execute(repo) } - throw e + log("Unable to pull changes for $repo") } return listOf(GIT, "ls-tree", "HEAD", "-r", relativeDirToList) .execute(repo).trim().lineSequence() From 991b869773da10104c8c31d95210ef728f6916f4 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 28 Sep 2018 12:19:21 +0200 Subject: [PATCH 11/62] mark nodejs 183.2635.17 as broken --- platform/platform-resources/src/brokenPlugins.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-resources/src/brokenPlugins.txt b/platform/platform-resources/src/brokenPlugins.txt index 987d4b3d25cf..8c1b0a099913 100644 --- a/platform/platform-resources/src/brokenPlugins.txt +++ b/platform/platform-resources/src/brokenPlugins.txt @@ -1,7 +1,7 @@ // This file contains list of broken plugins. // Each line contains plugin ID and list of versions that are broken. // If plugin name or version contains a space you can quote it like in command line. -NodeJS 182.2757.12 182.2371.6 182.1950 +NodeJS 182.2757.12 182.2371.6 182.1950 183.2635.17 com.jetbrains.php 162.646.18 162.426.10 145.970.40 145.258.2 144.4199.11 144.3891.12 144.3656 144.3168 143.790 143.1770 143.1184.87 143.382.38 143.279 143.381.48 143.129 142.5282 142.2716 142.3969 142.4491 140.2765 141.332 139.732 139.659 139.496 139.173 139.105 138.2502 138.2000.2262 138.1751 138.1806 138.1505 138.1161 138.826 136.1768 136.1672 134.1456 133.982 133.679 133.51 133.326 131.98 131.374 131.332 131.235 131.205 130.1639 130.1481 130.1176 129.91 129.814 129.672 129.362 127.67 127.100 126.334 123.66 122.875 121.62 121.390 121.215 121.12 com.intellij.phing 145.258.2 143.381.48 143.1770 142.5282 141.2325 139.732 133.51 131.374 129.672 127.67 124.347 121.62 121.390 121.215 121.12 117.746 117.694 117.501 117.257 117.222 117.132 114.282 114.158 com.intellij.plugins.html.instantEditing 162.5 0.4.1 0.4 0.3.9 0.3.8 0.3.7 0.3.6 0.3.5 0.3.3 0.3.2 0.3.10 0.3.1 0.3 0.2.27 0.2.25 0.2.24 0.2.23 From 37a3fcab85266034061f3719a0837b806f4715af Mon Sep 17 00:00:00 2001 From: Pavel Dolgov Date: Thu, 27 Sep 2018 15:49:53 +0300 Subject: [PATCH 12/62] Java: Convert intention "Join Declaration And Assignment" into inspection (IDEA-178919) --- java/java-impl/src/META-INF/JavaPlugin.xml | 9 +- .../JoinDeclarationAndAssignmentAction.java | 129 ----------------- ...eclarationAndAssignmentJavaInspection.java | 136 ++++++++++++++++++ .../JoinDeclarationAndAssignmentJava.html | 5 + .../after.java.template | 5 - .../before.java.template | 6 - .../description.html | 5 - .../joinDeclaration/afterComment.java | 8 ++ .../joinDeclaration/beforeComment.java | 8 ++ .../JoinDeclarationAndAssignmentTest.java | 24 ++++ .../intention/JoinDeclarationTest.java | 26 ---- .../src/messages/CodeInsightBundle.properties | 2 - .../src/messages/InspectionsBundle.properties | 4 + 13 files changed, 190 insertions(+), 177 deletions(-) delete mode 100644 java/java-impl/src/com/intellij/codeInsight/intention/impl/JoinDeclarationAndAssignmentAction.java create mode 100644 java/java-impl/src/com/intellij/codeInspection/JoinDeclarationAndAssignmentJavaInspection.java create mode 100644 java/java-impl/src/inspectionDescriptions/JoinDeclarationAndAssignmentJava.html delete mode 100644 java/java-impl/src/intentionDescriptions/JoinDeclarationAndAssignmentAction/after.java.template delete mode 100644 java/java-impl/src/intentionDescriptions/JoinDeclarationAndAssignmentAction/before.java.template delete mode 100644 java/java-impl/src/intentionDescriptions/JoinDeclarationAndAssignmentAction/description.html create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/joinDeclaration/afterComment.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/joinDeclaration/beforeComment.java create mode 100644 java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/quickFix/JoinDeclarationAndAssignmentTest.java delete mode 100644 java/java-tests/testSrc/com/intellij/java/codeInsight/intention/JoinDeclarationTest.java diff --git a/java/java-impl/src/META-INF/JavaPlugin.xml b/java/java-impl/src/META-INF/JavaPlugin.xml index 6c70a0438e3f..ff147317611c 100644 --- a/java/java-impl/src/META-INF/JavaPlugin.xml +++ b/java/java-impl/src/META-INF/JavaPlugin.xml @@ -907,6 +907,11 @@ groupKey="group.names.probable.bugs" groupBundle="messages.InspectionsBundle" enabledByDefault="true" level="WARNING" implementationClass="com.siyeh.ig.bugs.SortedCollectionWithNonComparableKeysInspection" /> + @@ -1045,10 +1050,6 @@ com.intellij.codeInsight.intention.impl.MoveInitializerToConstructorAction Java/Declaration - - com.intellij.codeInsight.intention.impl.JoinDeclarationAndAssignmentAction - Java/Declaration - com.intellij.codeInsight.intention.impl.SplitDeclarationAction Java/Declaration diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/JoinDeclarationAndAssignmentAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/JoinDeclarationAndAssignmentAction.java deleted file mode 100644 index aea31ebf1744..000000000000 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/JoinDeclarationAndAssignmentAction.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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.codeInsight.intention.impl; - -import com.intellij.codeInsight.CodeInsightBundle; -import com.intellij.codeInsight.FileModificationService; -import com.intellij.codeInsight.editorActions.DeclarationJoinLinesHandler; -import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction; -import com.intellij.codeInspection.RemoveInitializerFix; -import com.intellij.lang.java.JavaLanguage; -import com.intellij.openapi.application.WriteAction; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Pair; -import com.intellij.psi.*; -import com.intellij.psi.search.LocalSearchScope; -import com.intellij.psi.search.searches.ReferencesSearch; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NotNull; - -public class JoinDeclarationAndAssignmentAction extends PsiElementBaseIntentionAction { - @Override - @NotNull - public String getFamilyName() { - return CodeInsightBundle.message("intention.join.declaration.family"); - } - - @Override - public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) { - - if (element instanceof PsiCompiledElement) return false; - if (!element.getManager().isInProject(element)) return false; - if (!element.getLanguage().isKindOf(JavaLanguage.INSTANCE)) return false; - - if (getPair(element) != null) { - setText(CodeInsightBundle.message("intention.join.declaration.text")); - return true; - } - return false; - } - - private static Pair getPair(PsiElement element) { - PsiAssignmentExpression assignmentExpression = PsiTreeUtil.getParentOfType(element, PsiAssignmentExpression.class); - PsiDeclarationStatement declarationStatement = PsiTreeUtil.getParentOfType(element, PsiDeclarationStatement.class); - if (declarationStatement != null) { - assignmentExpression = getAssignmentStatement(declarationStatement); - } else if (assignmentExpression != null) { - declarationStatement = getDeclarationStatement(assignmentExpression); - } - - if (declarationStatement != null && assignmentExpression != null) { - final PsiExpression lExpression = assignmentExpression.getLExpression(); - final PsiExpression rExpression = assignmentExpression.getRExpression(); - if (lExpression instanceof PsiReferenceExpression && rExpression != null) { - final PsiElement resolve = ((PsiReferenceExpression)lExpression).resolve(); - if (resolve instanceof PsiLocalVariable && resolve.getParent() == declarationStatement) { - final PsiLocalVariable variable = (PsiLocalVariable)resolve; - if (ReferencesSearch.search(variable, new LocalSearchScope(rExpression), false).findFirst() != null) { - return null; - } - return Pair.createNonNull(variable, assignmentExpression); - } - } - } - return null; - } - - private static PsiAssignmentExpression getAssignmentStatement(PsiDeclarationStatement statement) { - final PsiElement element = PsiTreeUtil.skipWhitespacesForward(statement); - if (element instanceof PsiExpressionStatement) { - final PsiExpression expression = ((PsiExpressionStatement)element).getExpression(); - if (expression instanceof PsiAssignmentExpression) { - return (PsiAssignmentExpression)expression; - } - } - return null; - } - - private static PsiDeclarationStatement getDeclarationStatement(PsiAssignmentExpression assignmentExpression) { - final PsiElement parent = assignmentExpression.getParent(); - if (parent instanceof PsiExpressionStatement) { - final PsiElement element = PsiTreeUtil.skipWhitespacesBackward(parent); - if (element instanceof PsiDeclarationStatement) { - return (PsiDeclarationStatement)element; - } - } - return null; - } - - @Override - public boolean startInWriteAction() { - return false; - } - - @Override - public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { - if (!FileModificationService.getInstance().preparePsiElementForWrite(element)) return; - - final Pair pair = getPair(element); - if (pair == null) return; - final PsiLocalVariable variable = pair.getFirst(); - final PsiAssignmentExpression assignmentExpression = pair.getSecond(); - final PsiExpression initializer = variable.getInitializer(); - if (initializer != null && assignmentExpression.getOperationTokenType() == JavaTokenType.EQ) { - RemoveInitializerFix.sideEffectAwareRemove(project, initializer, initializer, variable); - } - WriteAction.run(() -> { - final PsiExpression initializerExpression = DeclarationJoinLinesHandler.getInitializerExpression(variable, assignmentExpression); - if (initializerExpression != null) { - variable.setInitializer(initializerExpression); - assignmentExpression.delete(); - } - }); - } -} diff --git a/java/java-impl/src/com/intellij/codeInspection/JoinDeclarationAndAssignmentJavaInspection.java b/java/java-impl/src/com/intellij/codeInspection/JoinDeclarationAndAssignmentJavaInspection.java new file mode 100644 index 000000000000..ba604afcbaba --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInspection/JoinDeclarationAndAssignmentJavaInspection.java @@ -0,0 +1,136 @@ +// 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.codeInspection; + +import com.intellij.codeInsight.FileModificationService; +import com.intellij.codeInsight.editorActions.DeclarationJoinLinesHandler; +import com.intellij.openapi.application.WriteAction; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Pair; +import com.intellij.psi.*; +import com.intellij.psi.search.LocalSearchScope; +import com.intellij.psi.search.searches.ReferencesSearch; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.util.ObjectUtils; +import com.siyeh.ig.psiutils.CommentTracker; +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * It's called "Java" inspection because the name without "Java" already exists. + * + * @author Pavel.Dolgov + */ +public class JoinDeclarationAndAssignmentJavaInspection extends AbstractBaseJavaLocalInspectionTool { + @NotNull + @Override + public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) { + return new JavaElementVisitor() { + @Override + public void visitAssignmentExpression(PsiAssignmentExpression assignmentExpression) { + super.visitAssignmentExpression(assignmentExpression); + + final Pair.NonNull pair = getPair(assignmentExpression); + if (pair != null) { + String name = pair.getFirst().getName(); + if (name != null) { + String message = InspectionsBundle.message("inspection.join.declaration.and.assignment.message", name); + JoinDeclarationAndAssignmentFix fix = new JoinDeclarationAndAssignmentFix(); + holder.registerProblem(pair.getFirst(), message, fix); + holder.registerProblem(pair.getSecond(), message, fix); + } + } + } + }; + } + + @Nullable + private static Pair.NonNull getPair(@Nullable PsiElement element) { + PsiLocalVariable variable = null; + PsiAssignmentExpression assignmentExpression = null; + if (element instanceof PsiAssignmentExpression) { + assignmentExpression = (PsiAssignmentExpression)element; + variable = findVariable(assignmentExpression); + } + else if (element instanceof PsiLocalVariable) { + variable = (PsiLocalVariable)element; + assignmentExpression = findAssignment(variable); + } + if (variable != null && assignmentExpression != null) { + PsiExpression rExpression = assignmentExpression.getRExpression(); + if (rExpression != null && + ReferencesSearch.search(variable, new LocalSearchScope(rExpression), false).findFirst() == null) { + return Pair.createNonNull(variable, assignmentExpression); + } + } + return null; + } + + @Nullable + private static PsiLocalVariable findVariable(@NotNull PsiAssignmentExpression assignmentExpression) { + PsiElement assignmentParent = assignmentExpression.getParent(); + if (assignmentParent instanceof PsiExpressionStatement) { + PsiElement candidate = PsiTreeUtil.skipWhitespacesAndCommentsBackward(assignmentParent); + if (candidate instanceof PsiDeclarationStatement) { + PsiExpression lExpression = assignmentExpression.getLExpression(); + if (lExpression instanceof PsiReferenceExpression) { + PsiElement resolved = ((PsiReferenceExpression)lExpression).resolve(); + if (resolved instanceof PsiLocalVariable && resolved.getParent() == candidate) { + return (PsiLocalVariable)resolved; + } + } + } + } + return null; + } + + @Nullable + private static PsiAssignmentExpression findAssignment(@NotNull PsiVariable variable) { + PsiDeclarationStatement statement = ObjectUtils.tryCast(variable.getParent(), PsiDeclarationStatement.class); + PsiElement candidate = PsiTreeUtil.skipWhitespacesAndCommentsForward(statement); + if (candidate instanceof PsiExpressionStatement) { + PsiExpression expression = ((PsiExpressionStatement)candidate).getExpression(); + if (expression instanceof PsiAssignmentExpression) { + return (PsiAssignmentExpression)expression; + } + } + return null; + } + + + private static class JoinDeclarationAndAssignmentFix implements LocalQuickFix { + @Nls(capitalization = Nls.Capitalization.Sentence) + @NotNull + @Override + public String getFamilyName() { + return InspectionsBundle.message("inspection.join.declaration.and.assignment.fix.family.name"); + } + + @Override + public boolean startInWriteAction() { + return false; + } + + @Override + public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { + Pair.NonNull pair = getPair(descriptor.getPsiElement()); + if (pair != null) { + PsiLocalVariable variable = pair.getFirst(); + PsiAssignmentExpression assignmentExpression = pair.getSecond(); + PsiExpression initializer = variable.getInitializer(); + if (initializer != null && assignmentExpression.getOperationTokenType() == JavaTokenType.EQ) { + RemoveInitializerFix.sideEffectAwareRemove(project, initializer, initializer, variable); + } + + if (!FileModificationService.getInstance().prepareFileForWrite(assignmentExpression.getContainingFile())) return; + WriteAction.run(() -> { + PsiExpression initializerExpression = DeclarationJoinLinesHandler.getInitializerExpression(variable, assignmentExpression); + if (initializerExpression != null) { + variable.setInitializer(initializerExpression); + new CommentTracker().deleteAndRestoreComments(assignmentExpression); + } + }); + } + } + } +} diff --git a/java/java-impl/src/inspectionDescriptions/JoinDeclarationAndAssignmentJava.html b/java/java-impl/src/inspectionDescriptions/JoinDeclarationAndAssignmentJava.html new file mode 100644 index 000000000000..bc4690658d79 --- /dev/null +++ b/java/java-impl/src/inspectionDescriptions/JoinDeclarationAndAssignmentJava.html @@ -0,0 +1,5 @@ + + +Reports variable assignments that can be joined with the variable's declaration. + + \ No newline at end of file diff --git a/java/java-impl/src/intentionDescriptions/JoinDeclarationAndAssignmentAction/after.java.template b/java/java-impl/src/intentionDescriptions/JoinDeclarationAndAssignmentAction/after.java.template deleted file mode 100644 index f0d31c13ecbe..000000000000 --- a/java/java-impl/src/intentionDescriptions/JoinDeclarationAndAssignmentAction/after.java.template +++ /dev/null @@ -1,5 +0,0 @@ -public class X { - void f() { - int i = 0; - } -} \ No newline at end of file diff --git a/java/java-impl/src/intentionDescriptions/JoinDeclarationAndAssignmentAction/before.java.template b/java/java-impl/src/intentionDescriptions/JoinDeclarationAndAssignmentAction/before.java.template deleted file mode 100644 index 17b0e530a8f7..000000000000 --- a/java/java-impl/src/intentionDescriptions/JoinDeclarationAndAssignmentAction/before.java.template +++ /dev/null @@ -1,6 +0,0 @@ -public class X { - void f() { - int i; - i = 0; - } -} \ No newline at end of file diff --git a/java/java-impl/src/intentionDescriptions/JoinDeclarationAndAssignmentAction/description.html b/java/java-impl/src/intentionDescriptions/JoinDeclarationAndAssignmentAction/description.html deleted file mode 100644 index a12e0cedeb87..000000000000 --- a/java/java-impl/src/intentionDescriptions/JoinDeclarationAndAssignmentAction/description.html +++ /dev/null @@ -1,5 +0,0 @@ - - -This intention converts a local variable declaration and consequence assignment to the same variable into one declaration - - \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/joinDeclaration/afterComment.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/joinDeclaration/afterComment.java new file mode 100644 index 000000000000..39af6b8af2ae --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/joinDeclaration/afterComment.java @@ -0,0 +1,8 @@ +// "Join declaration and assignment" "true" +class Test { + { + String ss = "hello"; // comment A + // comment B + /*comment C*/ /*comment D*/ // comment E + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/joinDeclaration/beforeComment.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/joinDeclaration/beforeComment.java new file mode 100644 index 000000000000..c12c5447385c --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/joinDeclaration/beforeComment.java @@ -0,0 +1,8 @@ +// "Join declaration and assignment" "true" +class Test { + { + String ss = ""; // comment A + // comment B + /*comment C*/ ss /*comment D*/ = "hello"; // comment E + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/quickFix/JoinDeclarationAndAssignmentTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/quickFix/JoinDeclarationAndAssignmentTest.java new file mode 100644 index 000000000000..f8ad374b867d --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/quickFix/JoinDeclarationAndAssignmentTest.java @@ -0,0 +1,24 @@ +// 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.java.codeInsight.daemon.quickFix; + +import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase; +import com.intellij.codeInspection.JoinDeclarationAndAssignmentJavaInspection; +import com.intellij.codeInspection.LocalInspectionTool; +import org.jetbrains.annotations.NotNull; + +/** + * @author Pavel.Dolgov + */ +public class JoinDeclarationAndAssignmentTest extends LightQuickFixParameterizedTestCase { + + @NotNull + @Override + protected LocalInspectionTool[] configureLocalInspectionTools() { + return new LocalInspectionTool[]{new JoinDeclarationAndAssignmentJavaInspection()}; + } + + @Override + protected String getBasePath() { + return "/codeInsight/daemonCodeAnalyzer/quickFix/joinDeclaration"; + } +} diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/intention/JoinDeclarationTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/intention/JoinDeclarationTest.java deleted file mode 100644 index 7b7264969235..000000000000 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/intention/JoinDeclarationTest.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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.java.codeInsight.intention; - -import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase; - -public class JoinDeclarationTest extends LightQuickFixParameterizedTestCase { - - @Override - protected String getBasePath() { - return "/codeInsight/daemonCodeAnalyzer/quickFix/joinDeclaration"; - } -} diff --git a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties index b89306fc4e66..a8e9449a2620 100644 --- a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties +++ b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties @@ -164,9 +164,7 @@ i18nize.dialog.template.link.label=Edit I18n template i18nize.dialog.error.property.already.defined.message=Property ''{0}'' already exists in the file ''{1}''. Override its value? i18nize.dialog.error.property.already.defined.title=Property Already Exists intention.split.declaration.family=Split Declaration -intention.join.declaration.family=Join Declaration and Assignment intention.split.declaration.text=Split into separate declarations -intention.join.declaration.text=Join declaration and assignment intention.split.declaration.assignment.text=Split into declaration and assignment intention.split.if.family=Split If intention.split.if.text=Split into 2 if's diff --git a/platform/platform-resources-en/src/messages/InspectionsBundle.properties b/platform/platform-resources-en/src/messages/InspectionsBundle.properties index 9526a67feda3..72669a4eeada 100644 --- a/platform/platform-resources-en/src/messages/InspectionsBundle.properties +++ b/platform/platform-resources-en/src/messages/InspectionsBundle.properties @@ -1017,3 +1017,7 @@ inspection.duplicate.expressions.replace.other.occurrences.fix.name=Replace with inspection.sorted.collection.with.non.comparable.keys.display.name=Sorted collection with non-comparable elements inspection.sorted.collection.with.non.comparable.keys.message=Construction of sorted collection with non-comparable elements inspection.sorted.collection.with.non.comparable.keys.option.type.parameters=Don't report non-comparable type parameters + +inspection.join.declaration.and.assignment.display.name=Assignment can be joined with declaration +inspection.join.declaration.and.assignment.message=Assignment can be joined with declaration of ''{0}'' +inspection.join.declaration.and.assignment.fix.family.name=Join declaration and assignment \ No newline at end of file From f316ca72b52346d61c604651fbbd60916289bfc2 Mon Sep 17 00:00:00 2001 From: Piotr Tomiak Date: Fri, 28 Sep 2018 12:22:00 +0200 Subject: [PATCH 13/62] WEB-31391 - Go to Angular component's HTML template from usage --- .../actions/GotoTypeDeclarationAction.java | 21 +++++++++++++++++-- .../actions/TypeDeclarationProvider.java | 5 +++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoTypeDeclarationAction.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoTypeDeclarationAction.java index 19354c9f357e..f7053ab0d482 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoTypeDeclarationAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoTypeDeclarationAction.java @@ -9,6 +9,8 @@ import com.intellij.codeInsight.TargetElementUtil; import com.intellij.codeInsight.actions.BaseCodeInsightAction; import com.intellij.codeInsight.navigation.NavigationUtil; import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.Presentation; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.OpenFileDescriptor; @@ -27,6 +29,8 @@ import java.util.Set; public class GotoTypeDeclarationAction extends BaseCodeInsightAction implements CodeInsightActionHandler, DumbAware { + private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.navigation.actions.GotoTypeDeclarationAction"); + @NotNull @Override protected CodeInsightActionHandler getHandler(){ @@ -42,10 +46,23 @@ public class GotoTypeDeclarationAction extends BaseCodeInsightAction implements public void update(@NotNull final AnActionEvent event) { if (TypeDeclarationProvider.EP_NAME.getExtensionList().size() == 0) { event.getPresentation().setVisible(false); + return; } - else { - super.update(event); + for (TypeDeclarationProvider provider : TypeDeclarationProvider.EP_NAME.getExtensionList()) { + //noinspection Duplicates + try { + String text = provider.getActionText(event.getDataContext()); + if (text != null) { + Presentation presentation = event.getPresentation(); + presentation.setText(text); + break; + } + } + catch (AbstractMethodError e) { + LOG.error(provider.toString(), e); + } } + super.update(event); } @Override diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/TypeDeclarationProvider.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/TypeDeclarationProvider.java index 4aed3ac05673..0bbab0f8432a 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/TypeDeclarationProvider.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/TypeDeclarationProvider.java @@ -16,6 +16,7 @@ package com.intellij.codeInsight.navigation.actions; +import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; @@ -29,4 +30,8 @@ public interface TypeDeclarationProvider { @Nullable PsiElement[] getSymbolTypeDeclarations(@NotNull PsiElement symbol); + + default String getActionText(DataContext context) { + return null; + } } From 2ec914c9097c9bf8a52f7dd943bf596b9ab49517 Mon Sep 17 00:00:00 2001 From: anstarovoyt Date: Fri, 28 Sep 2018 13:31:40 +0300 Subject: [PATCH 14/62] platform: add internal action to enable "file tree load" assertion --- .../internal/AssertOnFileTreeLoadAction.java | 41 +++++++++++++++++++ .../src/idea/PlatformActions.xml | 1 + 2 files changed, 42 insertions(+) create mode 100644 platform/lang-impl/src/com/intellij/internal/AssertOnFileTreeLoadAction.java diff --git a/platform/lang-impl/src/com/intellij/internal/AssertOnFileTreeLoadAction.java b/platform/lang-impl/src/com/intellij/internal/AssertOnFileTreeLoadAction.java new file mode 100644 index 000000000000..6fc10e374ebb --- /dev/null +++ b/platform/lang-impl/src/com/intellij/internal/AssertOnFileTreeLoadAction.java @@ -0,0 +1,41 @@ +// 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.internal; + +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.ToggleAction; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Key; +import com.intellij.openapi.vfs.VirtualFileFilter; +import com.intellij.psi.impl.PsiManagerEx; +import org.jetbrains.annotations.NotNull; + +public class AssertOnFileTreeLoadAction extends ToggleAction { + + private static final Key KEY = Key.create("assertion.file.tree.load.is.set"); + + @Override + public boolean isSelected(@NotNull AnActionEvent e) { + Project project = e.getProject(); + if (project == null) return false; + + return project.getUserData(KEY) == Boolean.TRUE; + } + + @Override + public void setSelected(@NotNull AnActionEvent e, boolean state) { + Project project = e.getProject(); + if (project == null) return; + if (state) { + PsiManagerEx.getInstanceEx(project).setAssertOnFileLoadingFilter(VirtualFileFilter.ALL, project); + project.putUserData(KEY, Boolean.TRUE); + } else { + PsiManagerEx.getInstanceEx(project).setAssertOnFileLoadingFilter(VirtualFileFilter.NONE, project); + project.putUserData(KEY, null); + } + } + + @Override + public boolean isDumbAware() { + return true; + } +} diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index 9f891f9688ef..63eecfd18fd1 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -851,6 +851,7 @@ + From e0589f99860ec4e57d1d5a195241d4bfe55420e3 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 27 Sep 2018 19:56:13 +0300 Subject: [PATCH 15/62] remove unnecessary @SuppressWarnings("JavadocReference") --- .../editor/event/DocumentListener.java | 1 - .../intellij/openapi/project/DumbAware.java | 5 ++--- .../com/intellij/openapi/vfs/VirtualFile.java | 2 -- .../src/com/intellij/psi/PsiReference.java | 3 +-- .../configurations/RunProfileState.java | 3 +-- .../src/com/intellij/ExtensionPoints.java | 20 ++++++++++++------- .../impl/IdeDocumentHistoryImpl.java | 2 +- .../openapi/roots/SyntheticLibrary.java | 1 - .../SkipInHeadlessEnvironment.java | 1 - .../testFramework/SkipSlowTestLocally.java | 1 - 10 files changed, 18 insertions(+), 21 deletions(-) diff --git a/platform/core-api/src/com/intellij/openapi/editor/event/DocumentListener.java b/platform/core-api/src/com/intellij/openapi/editor/event/DocumentListener.java index bc9c371dbc07..afb3833b5acc 100644 --- a/platform/core-api/src/com/intellij/openapi/editor/event/DocumentListener.java +++ b/platform/core-api/src/com/intellij/openapi/editor/event/DocumentListener.java @@ -13,7 +13,6 @@ import java.util.EventListener; * @see com.intellij.openapi.editor.Document#addDocumentListener(DocumentListener) * @see EditorEventMulticaster#addDocumentListener(DocumentListener) */ -@SuppressWarnings("JavadocReference") public interface DocumentListener extends EventListener{ DocumentListener[] EMPTY_ARRAY = new DocumentListener[0]; ArrayFactory ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new DocumentListener[count]; diff --git a/platform/core-api/src/com/intellij/openapi/project/DumbAware.java b/platform/core-api/src/com/intellij/openapi/project/DumbAware.java index c9cb054463f4..02e73d831377 100644 --- a/platform/core-api/src/com/intellij/openapi/project/DumbAware.java +++ b/platform/core-api/src/com/intellij/openapi/project/DumbAware.java @@ -35,10 +35,9 @@ package com.intellij.openapi.project; *
  • {@link com.intellij.lang.injection.MultiHostInjector}s * * @author peter - * @see com.intellij.openapi.project.DumbService - * @see com.intellij.openapi.project.DumbAwareRunnable + * @see DumbService + * @see DumbAwareRunnable * @see PossiblyDumbAware */ -@SuppressWarnings("JavadocReference") public interface DumbAware { } diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java index 608146c9ed3f..3e0d183627eb 100644 --- a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java +++ b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java @@ -131,7 +131,6 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica * * @return the path */ - @SuppressWarnings("JavadocReference") @NotNull public abstract String getPath(); @@ -327,7 +326,6 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica * When IDEA has no idea what the file type is (i.e. file type is not registered via {@link FileTypeRegistry}), * it returns {@link com.intellij.openapi.fileTypes.FileTypes#UNKNOWN} */ - @SuppressWarnings("JavadocReference") @NotNull public FileType getFileType() { return FileTypeRegistry.getInstance().getFileTypeByFile(this); diff --git a/platform/core-api/src/com/intellij/psi/PsiReference.java b/platform/core-api/src/com/intellij/psi/PsiReference.java index 08f484afe8dc..c08b0a4cf286 100644 --- a/platform/core-api/src/com/intellij/psi/PsiReference.java +++ b/platform/core-api/src/com/intellij/psi/PsiReference.java @@ -106,7 +106,7 @@ public interface PsiReference { boolean isReferenceTo(@NotNull PsiElement element); /** - * Returns the array of String, {@link PsiElement} and/or {@link LookupElement} + * Returns the array of String, {@link PsiElement} and/or {@link com.intellij.codeInsight.lookup.LookupElement} * instances representing all identifiers that are visible at the location of the reference. The contents * of the returned array is used to build the lookup list for basic code completion. (The list * of visible identifiers may not be filtered by the completion prefix string - the @@ -116,7 +116,6 @@ public interface PsiReference { * * @return the array of available identifiers. */ - @SuppressWarnings("JavadocReference") @NotNull default Object[] getVariants() { return ArrayUtil.EMPTY_OBJECT_ARRAY; diff --git a/platform/lang-api/src/com/intellij/execution/configurations/RunProfileState.java b/platform/lang-api/src/com/intellij/execution/configurations/RunProfileState.java index ecf740e7b6b2..65b4352dc4ce 100644 --- a/platform/lang-api/src/com/intellij/execution/configurations/RunProfileState.java +++ b/platform/lang-api/src/com/intellij/execution/configurations/RunProfileState.java @@ -27,10 +27,9 @@ import org.jetbrains.annotations.Nullable; * variables, working directory etc. * * @see CommandLineState - * @see RunConfiguration#getState(com.intellij.execution.Executor, com.intellij.execution.runners.ExecutionEnvironment) + * @see RunConfiguration#getState(Executor, com.intellij.execution.runners.ExecutionEnvironment) * @see com.intellij.execution.configuration.EmptyRunProfileState */ -@SuppressWarnings("JavadocReference") public interface RunProfileState { /** * Starts the process. diff --git a/platform/platform-api/src/com/intellij/ExtensionPoints.java b/platform/platform-api/src/com/intellij/ExtensionPoints.java index eb73434862b2..b17e3294bf5f 100644 --- a/platform/platform-api/src/com/intellij/ExtensionPoints.java +++ b/platform/platform-api/src/com/intellij/ExtensionPoints.java @@ -23,7 +23,8 @@ public interface ExtensionPoints extends ToolExtensionPoints { * Possible registration areas are IDEA_PROJECT, MODULE_PROJECT which stand for ProjectComponent and ModuleComponent correspondingly. * If area attribute is omitted the component will be registered in root area which corresponds to application component. */ - @NonNls String COMPONENT = "com.intellij.component"; + @NonNls + String COMPONENT = "com.intellij.component"; /** * This extension point allows a plugin vendor to provide the user ability to report fatal errors (aka exceptions) that happened in @@ -34,9 +35,10 @@ public interface ExtensionPoints extends ToolExtensionPoints { * <errorHandler implementation="my.plugin.package.MyErrorHandler"/> * </extensions> * - * my.plugin.package.MyErrorHandler class must implement {@link com.intellij.openapi.diagnostic.ErrorReportSubmitter} abstract class. + * my.plugin.package.MyErrorHandler class must implement {@link ErrorReportSubmitter} abstract class. */ - @NonNls String ERROR_HANDLER = "com.intellij.errorHandler"; + @NonNls + String ERROR_HANDLER = "com.intellij.errorHandler"; ExtensionPointName ERROR_HANDLER_EP = ExtensionPointName.create(ERROR_HANDLER); @@ -50,7 +52,8 @@ public interface ExtensionPoints extends ToolExtensionPoints { * * my.plugin.package.MyJUnitPatcher class must implement {@link com.intellij.execution.JUnitPatcher} abstract class. */ - @SuppressWarnings("JavadocReference") @NonNls String JUNIT_PATCHER = "com.intellij.junitPatcher"; + @NonNls + String JUNIT_PATCHER = "com.intellij.junitPatcher"; /** * This extensions allows to run custom [command-line] application based on IDEA platform @@ -61,12 +64,15 @@ public interface ExtensionPoints extends ToolExtensionPoints { * * my.plugin.package.MyApplicationStarter class must implement {@link com.intellij.openapi.application.ApplicationStarter} interface. */ - @NonNls String APPLICATION_STARTER = "com.intellij.appStarter"; + @NonNls + String APPLICATION_STARTER = "com.intellij.appStarter"; - @NonNls String ANT_BUILD_GEN = "com.intellij.antBuildGen"; + @NonNls + String ANT_BUILD_GEN = "com.intellij.antBuildGen"; /** * Ant custom compiler extension point */ - @NonNls String ANT_CUSTOM_COMPILER = "com.intellij.antCustomCompiler"; + @NonNls + String ANT_CUSTOM_COMPILER = "com.intellij.antCustomCompiler"; } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/IdeDocumentHistoryImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/IdeDocumentHistoryImpl.java index d0f57624324f..3c563f2247b1 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/IdeDocumentHistoryImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/IdeDocumentHistoryImpl.java @@ -114,7 +114,7 @@ public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements Dispos EditorEventListener listener = new EditorEventListener() { @Override - public void documentChanged(DocumentEvent e) { + public void documentChanged(@NotNull DocumentEvent e) { Document document = e.getDocument(); final VirtualFile file = getFileDocumentManager().getFile(document); if (file != null && !(file instanceof LightVirtualFile) && !ApplicationManager.getApplication().hasWriteAction(ExternalChangeAction.class)) { diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/SyntheticLibrary.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/SyntheticLibrary.java index d2aa4eddebfb..6eced7460ff3 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/SyntheticLibrary.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/SyntheticLibrary.java @@ -41,7 +41,6 @@ import java.util.Set; * * @see AdditionalLibraryRootsProvider */ -@SuppressWarnings("JavadocReference") @ApiStatus.Experimental public abstract class SyntheticLibrary { diff --git a/platform/testFramework/core/src/com/intellij/testFramework/SkipInHeadlessEnvironment.java b/platform/testFramework/core/src/com/intellij/testFramework/SkipInHeadlessEnvironment.java index b79bfb7d5321..f9f175d3867d 100644 --- a/platform/testFramework/core/src/com/intellij/testFramework/SkipInHeadlessEnvironment.java +++ b/platform/testFramework/core/src/com/intellij/testFramework/SkipInHeadlessEnvironment.java @@ -25,7 +25,6 @@ import java.lang.annotation.Target; * * @author nik */ -@SuppressWarnings("JavadocReference") @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface SkipInHeadlessEnvironment { diff --git a/platform/testFramework/core/src/com/intellij/testFramework/SkipSlowTestLocally.java b/platform/testFramework/core/src/com/intellij/testFramework/SkipSlowTestLocally.java index fb972d69208e..80768b5fad93 100644 --- a/platform/testFramework/core/src/com/intellij/testFramework/SkipSlowTestLocally.java +++ b/platform/testFramework/core/src/com/intellij/testFramework/SkipSlowTestLocally.java @@ -24,7 +24,6 @@ import java.lang.annotation.Target; * Mark dog slow {@link com.intellij.testFramework.UsefulTestCase} implementations for skip in local test pass * if "skip.slow.tests.locally" property is defined. */ -@SuppressWarnings("JavadocReference") @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface SkipSlowTestLocally { } From 1e9909e575257b89c0315f42c26feed839e65531 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 27 Sep 2018 20:27:58 +0300 Subject: [PATCH 16/62] IDEA-198547 'Remove modifier' quickfix deletes the containing file when applied to injected code in batch mode --- .../com/intellij/psi/util/PsiTreeUtil.java | 19 +++++++++++++------ .../testFramework/ParsingTestCase.java | 9 +++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/platform/core-api/src/com/intellij/psi/util/PsiTreeUtil.java b/platform/core-api/src/com/intellij/psi/util/PsiTreeUtil.java index 10740fef2f9a..bbfa11fcc588 100644 --- a/platform/core-api/src/com/intellij/psi/util/PsiTreeUtil.java +++ b/platform/core-api/src/com/intellij/psi/util/PsiTreeUtil.java @@ -3,6 +3,7 @@ package com.intellij.psi.util; import com.intellij.lang.ASTNode; import com.intellij.lang.Language; +import com.intellij.lang.injection.InjectedLanguageManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Key; @@ -18,10 +19,7 @@ import com.intellij.psi.stubs.StubBase; import com.intellij.psi.stubs.StubElement; import com.intellij.psi.templateLanguages.OuterLanguageElement; import com.intellij.psi.tree.IElementType; -import com.intellij.util.ArrayUtil; -import com.intellij.util.Consumer; -import com.intellij.util.PairProcessor; -import com.intellij.util.SmartList; +import com.intellij.util.*; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; @@ -123,8 +121,17 @@ public class PsiTreeUtil { public static PsiElement findCommonParent(@NotNull PsiElement element1, @NotNull PsiElement element2) { // optimization if (element1 == element2) return element1; - final PsiFile containingFile = element1.getContainingFile(); - final PsiElement topLevel = containingFile == element2.getContainingFile() ? containingFile : null; + PsiFile file1 = element1.getContainingFile(); + PsiFile file2 = element2.getContainingFile(); + if (file1 != null && file2 != null) { + InjectedLanguageManager ilm = InjectedLanguageManager.getInstance(file1.getProject()); + if (ilm.isInjectedFragment(file1) != ilm.isInjectedFragment(file2)) { + // injected and non-injected files have no common ancestor + return null; + } + } + + PsiElement topLevel = file1 == file2 ? file1 : null; int depth1 = getDepth(element1, topLevel); int depth2 = getDepth(element2, topLevel); diff --git a/platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java b/platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java index ca62e02c3987..e369e7c0188f 100644 --- a/platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java @@ -18,6 +18,8 @@ package com.intellij.testFramework; import com.intellij.ide.startup.impl.StartupManagerImpl; import com.intellij.lang.*; import com.intellij.lang.impl.PsiBuilderFactoryImpl; +import com.intellij.lang.injection.InjectedLanguageManager; +import com.intellij.lang.injection.MultiHostInjector; import com.intellij.mock.*; import com.intellij.openapi.application.ex.PathManagerEx; import com.intellij.openapi.editor.EditorFactory; @@ -46,6 +48,7 @@ import com.intellij.psi.*; import com.intellij.psi.impl.*; import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry; import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistryImpl; +import com.intellij.psi.impl.source.tree.injected.InjectedLanguageManagerImpl; import com.intellij.psi.util.CachedValuesManager; import com.intellij.util.CachedValuesManagerImpl; import com.intellij.util.containers.ContainerUtil; @@ -393,4 +396,10 @@ public abstract class ParsingTestCase extends PlatformLiteFixture { TestCase.assertEquals(psiToStringDefault, DebugUtil.psiToString(file, false, false)); } + + public void registerMockInjectedLanguageManager() { + registerExtensionPoint(Extensions.getArea(myProject), MultiHostInjector.MULTIHOST_INJECTOR_EP_NAME, MultiHostInjector.class); + registerExtensionPoint(LanguageInjector.EXTENSION_POINT_NAME, LanguageInjector.class); + myProject.registerService(InjectedLanguageManager.class, new InjectedLanguageManagerImpl(myProject, new MockDumbService(myProject))); + } } From ff1a94ba417790f38d972a944e2e13d427294c0d Mon Sep 17 00:00:00 2001 From: Dmitry Zhuravlev Date: Tue, 25 Sep 2018 13:24:07 +0300 Subject: [PATCH 17/62] vcs: do not mark files dirty in the VcsVfsListener Marking affected files dirty at the end of the CommandListener, makes no sense, since all custom implementations of VcsVfsListener perform addition/deletion/move in the background. Marking affected files dirty should be done after these background procedures complete. The API doesn't provide a common way to do it, but all implementations should do it on their own. --- .../intellij/openapi/vcs/VcsVFSListener.java | 48 ++++--------------- .../src/git4idea/vfs/GitVFSListener.java | 4 +- 2 files changed, 11 insertions(+), 41 deletions(-) diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsVFSListener.java b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsVFSListener.java index df08cd369325..3997959a5b1e 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsVFSListener.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsVFSListener.java @@ -11,7 +11,6 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vcs.actions.VcsContextFactory; import com.intellij.openapi.vcs.changes.ChangeListManager; -import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager; import com.intellij.openapi.vfs.*; import com.intellij.openapi.vfs.newvfs.NewVirtualFile; import com.intellij.util.SmartList; @@ -29,7 +28,6 @@ import java.util.*; public abstract class VcsVFSListener implements Disposable { protected static final Logger LOG = Logger.getInstance(VcsVFSListener.class); - private final VcsDirtyScopeManager myDirtyScopeManager; private final ProjectLevelVcsManager myVcsManager; private final VcsFileListenerContextHelper myVcsFileListenerContextHelper; @@ -64,7 +62,6 @@ public abstract class VcsVFSListener implements Disposable { protected final List myDeletedFiles = new ArrayList<>(); protected final List myDeletedWithoutConfirmFiles = new ArrayList<>(); protected final List myMovedFiles = new ArrayList<>(); - private final LinkedHashSet myDirtyFiles = ContainerUtil.newLinkedHashSet(); protected enum VcsDeleteType {SILENT, CONFIRM, IGNORE} @@ -72,7 +69,6 @@ public abstract class VcsVFSListener implements Disposable { myProject = project; myVcs = vcs; myChangeListManager = ChangeListManager.getInstance(project); - myDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject); myVcsManager = ProjectLevelVcsManager.getInstance(project); myAddOption = myVcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.ADD, vcs); @@ -87,13 +83,9 @@ public abstract class VcsVFSListener implements Disposable { public void dispose() { } - protected boolean isEventIgnored(@NotNull VirtualFileEvent event, boolean putInDirty) { + protected boolean isEventIgnored(@NotNull VirtualFileEvent event) { if (event.isFromRefresh()) return true; - boolean vcsIgnored = !isUnderMyVcs(event.getFile()); - if (vcsIgnored) { - myDirtyFiles.add(event.getFile()); - } - return vcsIgnored; + return !isUnderMyVcs(event.getFile()); } private boolean isUnderMyVcs(@NotNull VirtualFile file) { @@ -217,7 +209,7 @@ public abstract class VcsVFSListener implements Disposable { } protected void fileAdded(@NotNull VirtualFileEvent event, @NotNull VirtualFile file) { - if (!isEventIgnored(event, true) && !myChangeListManager.isIgnoredFile(file) && + if (!isEventIgnored(event) && !myChangeListManager.isIgnoredFile(file) && (isDirectoryVersioningSupported() || !file.isDirectory())) { LOG.debug("Adding [", file, "] to added files"); myAddedFiles.add(event.getFile()); @@ -245,12 +237,6 @@ public abstract class VcsVFSListener implements Disposable { protected void processMovedFile(@NotNull VirtualFile file, @NotNull String newParentPath, @NotNull String newName) { final FileStatus status = ChangeListManager.getInstance(myProject).getStatus(file); LOG.debug("Checking moved file ", file, "; status=", status); - if (status == FileStatus.IGNORED) { - if (file.getParent() != null) { - myDirtyFiles.add(file.getParent()); - myDirtyFiles.add(file); // will be at new path - } - } String newPath = newParentPath + "/" + newName; if (!(filterOutUnknownFiles() && status == FileStatus.UNKNOWN) && status != FileStatus.IGNORED) { @@ -322,7 +308,7 @@ public abstract class VcsVFSListener implements Disposable { @Override public void fileCopied(@NotNull final VirtualFileCopyEvent event) { - if (isEventIgnored(event, true) || myChangeListManager.isIgnoredFile(event.getFile())) return; + if (isEventIgnored(event) || myChangeListManager.isIgnoredFile(event.getFile())) return; final AbstractVcs oldVcs = ProjectLevelVcsManager.getInstance(myProject).getVcsFor(event.getOriginalFile()); if (oldVcs == myVcs) { final VirtualFile parent = event.getFile().getParent(); @@ -339,7 +325,7 @@ public abstract class VcsVFSListener implements Disposable { @Override public void beforeFileDeletion(@NotNull final VirtualFileEvent event) { final VirtualFile file = event.getFile(); - if (isEventIgnored(event, true)) { + if (isEventIgnored(event)) { return; } if (!myChangeListManager.isIgnoredFile(file)) { @@ -360,7 +346,7 @@ public abstract class VcsVFSListener implements Disposable { @Override public void beforeFileMovement(@NotNull final VirtualFileMoveEvent event) { - if (isEventIgnored(event, true)) return; + if (isEventIgnored(event)) return; final VirtualFile file = event.getFile(); final AbstractVcs newVcs = ProjectLevelVcsManager.getInstance(myProject).getVcsFor(event.getNewParent()); LOG.debug("beforeFileMovement ", event, " into ", newVcs); @@ -374,7 +360,7 @@ public abstract class VcsVFSListener implements Disposable { @Override public void fileMoved(@NotNull final VirtualFileMoveEvent event) { - if (isEventIgnored(event, true)) return; + if (isEventIgnored(event)) return; final AbstractVcs oldVcs = ProjectLevelVcsManager.getInstance(myProject).getVcsFor(event.getOldParent()); if (oldVcs != myVcs) { myAddedFiles.add(event.getFile()); @@ -383,7 +369,7 @@ public abstract class VcsVFSListener implements Disposable { @Override public void beforePropertyChange(@NotNull final VirtualFilePropertyEvent event) { - if (!isEventIgnored(event, false) && event.getPropertyName().equalsIgnoreCase(VirtualFile.PROP_NAME)) { + if (!isEventIgnored(event) && event.getPropertyName().equalsIgnoreCase(VirtualFile.PROP_NAME)) { LOG.debug("before file rename ", event); String oldName = (String)event.getOldValue(); String newName = (String)event.getNewValue(); @@ -461,8 +447,7 @@ public abstract class VcsVFSListener implements Disposable { if (myProject != event.getProject()) return; myCommandLevel--; if (myCommandLevel == 0) { - if (!myAddedFiles.isEmpty() || !myDeletedFiles.isEmpty() || !myDeletedWithoutConfirmFiles.isEmpty() || !myMovedFiles.isEmpty() || - ! myDirtyFiles.isEmpty()) { + if (!myAddedFiles.isEmpty() || !myDeletedFiles.isEmpty() || !myDeletedWithoutConfirmFiles.isEmpty() || !myMovedFiles.isEmpty()) { doNotDeleteAddedCopiedOrMovedFiles(); checkMovedAddedSourceBack(); if (!myAddedFiles.isEmpty()) { @@ -478,21 +463,6 @@ public abstract class VcsVFSListener implements Disposable { executeMoveRename(); myMovedFiles.clear(); } - if (! myDirtyFiles.isEmpty()) { - final List files = new ArrayList<>(); - final List dirs = new ArrayList<>(); - for (VirtualFile dirtyFile : myDirtyFiles) { - if (dirtyFile != null) { - if (dirtyFile.isDirectory()) { - dirs.add(dirtyFile); - } else { - files.add(dirtyFile); - } - } - } - myDirtyScopeManager.filesDirty(files, dirs); - myDirtyFiles.clear(); - } if (! myExceptions.isEmpty()) { AbstractVcsHelper.getInstance(myProject).showErrors(myExceptions, myVcs.getDisplayName() + " operations errors"); } diff --git a/plugins/git4idea/src/git4idea/vfs/GitVFSListener.java b/plugins/git4idea/src/git4idea/vfs/GitVFSListener.java index 557bedba909b..3d400d7177be 100644 --- a/plugins/git4idea/src/git4idea/vfs/GitVFSListener.java +++ b/plugins/git4idea/src/git4idea/vfs/GitVFSListener.java @@ -72,8 +72,8 @@ public class GitVFSListener extends VcsVFSListener { } @Override - protected boolean isEventIgnored(@NotNull VirtualFileEvent event, boolean putInDirty) { - return super.isEventIgnored(event, putInDirty) || myEventsSuppressLevel.get() != 0; + protected boolean isEventIgnored(@NotNull VirtualFileEvent event) { + return super.isEventIgnored(event) || myEventsSuppressLevel.get() != 0; } @NotNull From d91bae2fb677a918fe88d7458d5a6f856c1ee160 Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Fri, 28 Sep 2018 13:51:46 +0300 Subject: [PATCH 18/62] catch java.lang.Error too (EA-128261 - NCDFE: WinProcess.) --- .../intellij/execution/process/KillableProcessHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/execution/process/KillableProcessHandler.java b/platform/platform-impl/src/com/intellij/execution/process/KillableProcessHandler.java index 03dc8c08e639..acda4cd55204 100644 --- a/platform/platform-impl/src/com/intellij/execution/process/KillableProcessHandler.java +++ b/platform/platform-impl/src/com/intellij/execution/process/KillableProcessHandler.java @@ -167,8 +167,8 @@ public class KillableProcessHandler extends OSProcessHandler implements Killable try { return new WinProcess(myProcess).sendCtrlC(); } - catch (Exception e) { - LOG.warn("Failed to send Ctrl+C, fallback to default termination: " + getCommandLine(), e); + catch (Error e) { + LOG.error("Failed to send Ctrl+C, fallback to default termination: " + getCommandLine(), e); } } } From e182fce12a66a2b6a3d4370192c0305e4c36bcfb Mon Sep 17 00:00:00 2001 From: Artem Gainanov Date: Fri, 28 Sep 2018 18:08:41 +0700 Subject: [PATCH 19/62] WEB-35033 "Unknown HTML tag attribute" inspection: allow "alt" attribute for the "applet" tag --- .../src/resources/patches/0007_legacy.patch | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 xml/relaxng/src/resources/patches/0007_legacy.patch diff --git a/xml/relaxng/src/resources/patches/0007_legacy.patch b/xml/relaxng/src/resources/patches/0007_legacy.patch new file mode 100644 index 000000000000..67946ccbfcbe --- /dev/null +++ b/xml/relaxng/src/resources/patches/0007_legacy.patch @@ -0,0 +1,26 @@ +Index: xml/relaxng/src/resources/html5-schema/html5/legacy.rnc +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +--- html5/legacy.rnc (revision d1fb137d55cd5a5f1b9d6228d3bd49669e148540) ++++ html5/legacy.rnc (revision aebff73f628a2e4a9321b0530831e1e36b280397) +@@ -142,6 +142,7 @@ + element applet { applet.inner.phrasing & applet.attrs } + applet.attrs = + ( common.attrs ++ & applet.attrs.alt? + & applet.attrs.archive? + & applet.attrs.code + & applet.attrs.codebase? +@@ -149,6 +150,10 @@ + & applet.attrs.height + & applet.attrs.width + ) ++ applet.attrs.alt = ++ attribute alt { ++ string ++ } + applet.attrs.archive = + attribute archive { + common.data.uri #FIXME *comma* separated URI list (*grumble*) From ca1c783ed1e4d7a9a7cd77297e67e9c416087dd3 Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Fri, 28 Sep 2018 18:15:29 +0700 Subject: [PATCH 20/62] InlineStreamMapAction: correctly handle lambda parameters with explicit types --- .../codeInsight/intention/impl/InlineStreamMapAction.java | 2 +- .../quickFix/inlineStreamMap/afterLambdaWithType.java | 8 ++++++++ .../quickFix/inlineStreamMap/afterLambdaWithType2.java | 8 ++++++++ .../quickFix/inlineStreamMap/beforeLambdaWithType.java | 8 ++++++++ .../quickFix/inlineStreamMap/beforeLambdaWithType2.java | 8 ++++++++ 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterLambdaWithType.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterLambdaWithType2.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeLambdaWithType.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeLambdaWithType2.java diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/InlineStreamMapAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/InlineStreamMapAction.java index 7aa89c18a760..fdcc8b4bc905 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/InlineStreamMapAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/InlineStreamMapAction.java @@ -240,7 +240,7 @@ public class InlineStreamMapAction extends PsiElementBaseIntentionAction { } ct.replace(e, replacement); } - ct.replace(nextParameters[0], prevParameters[0]); + ct.replace(lambda.getParameterList(), previousLambda.getParameterList()); ExpressionUtils.bindReferenceTo(nextRef, newName); PsiExpression prevQualifier = mapCall.getMethodExpression().getQualifierExpression(); if(prevQualifier == null) { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterLambdaWithType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterLambdaWithType.java new file mode 100644 index 000000000000..9a375917e36e --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterLambdaWithType.java @@ -0,0 +1,8 @@ +// "Inline 'map' body into the next 'forEach' call" "true" +import java.util.List; + +public class Main { + public static void test(List list) { + list.stream().forEach((String s) -> System.out.println(s.trim())); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterLambdaWithType2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterLambdaWithType2.java new file mode 100644 index 000000000000..16e59f26c0f9 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/afterLambdaWithType2.java @@ -0,0 +1,8 @@ +// "Inline 'map' body into the next 'forEach' call" "true" +import java.util.List; + +public class Main { + public static void test(List list) { + list.stream().forEach(s -> System.out.println(s.trim())); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeLambdaWithType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeLambdaWithType.java new file mode 100644 index 000000000000..240175b17a09 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeLambdaWithType.java @@ -0,0 +1,8 @@ +// "Inline 'map' body into the next 'forEach' call" "true" +import java.util.List; + +public class Main { + public static void test(List list) { + list.stream().map((String s) -> s.trim()).forEach(x -> System.out.println(x)); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeLambdaWithType2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeLambdaWithType2.java new file mode 100644 index 000000000000..aa060d73a6c4 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/inlineStreamMap/beforeLambdaWithType2.java @@ -0,0 +1,8 @@ +// "Inline 'map' body into the next 'forEach' call" "true" +import java.util.List; + +public class Main { + public static void test(List list) { + list.stream().map(s -> s.trim()).forEach((String x) -> System.out.println(x)); + } +} \ No newline at end of file From d1db9f1afb3cac7a09c36c63a57c9d8e789a7995 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Fri, 28 Sep 2018 13:45:49 +0300 Subject: [PATCH 21/62] IDEA-199471 vcs: do not set shortcut for "Show Diff from Annotation" action This action can't be invoked by shortcut, so it shouldn't be advertised. --- .../intellij/openapi/vcs/actions/ShowDiffFromAnnotation.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowDiffFromAnnotation.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowDiffFromAnnotation.java index 94c426ea2acd..0085857197b0 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowDiffFromAnnotation.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowDiffFromAnnotation.java @@ -24,6 +24,7 @@ import com.intellij.diff.util.DiffUserDataKeysEx; import com.intellij.openapi.ListSelection; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CustomShortcutSet; import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.actionSystem.ex.ActionUtil; import com.intellij.openapi.diagnostic.Logger; @@ -66,6 +67,7 @@ class ShowDiffFromAnnotation extends DumbAwareAction implements UpToDateLineNumb ShowDiffFromAnnotation(@NotNull Project project, @NotNull FileAnnotation fileAnnotation) { ActionUtil.copyFrom(this, IdeActions.ACTION_SHOW_DIFF_COMMON); + setShortcutSet(CustomShortcutSet.EMPTY); myProject = project; myFileAnnotation = fileAnnotation; myChangesProvider = fileAnnotation.getRevisionsChangesProvider(); From cb0c2407a5b80e6291df4448b8d122f66af386cb Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 28 Sep 2018 13:46:11 +0200 Subject: [PATCH 22/62] renamed WelcomeScreen.Separator.color to WelcomeScreen.separatorColor for consistency --- .../openapi/wm/impl/welcomeScreen/FlatWelcomeFrame.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/FlatWelcomeFrame.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/FlatWelcomeFrame.java index 97e7c301672b..2d9920caf751 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/FlatWelcomeFrame.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/FlatWelcomeFrame.java @@ -185,7 +185,7 @@ public class FlatWelcomeFrame extends JFrame implements IdeFrame, Disposable, Ac } public static JBColor getSeparatorColor() { - return JBColor.namedColor("WelcomeScreen.Separator.color", new JBColor(Gray.xEC, new Color(72, 75, 78))); + return JBColor.namedColor("WelcomeScreen.separatorColor", new JBColor(Gray.xEC, new Color(72, 75, 78))); } @Override From 0aa3127b482984c47c0381bbac897004bcc9b164 Mon Sep 17 00:00:00 2001 From: Egor Ushakov Date: Fri, 28 Sep 2018 14:47:57 +0300 Subject: [PATCH 23/62] IDEA-199545 Cannot re-attach to restarted process --- .../debugger/engine/DebugProcessImpl.java | 2 +- .../attach/JavaAttachDebuggerProvider.java | 35 ++++++++++++++----- .../impl/attach/PidRemoteConnection.java | 15 ++++++-- .../impl/attach/SAJDWPRemoteConnection.java | 3 +- 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java index 4e6e634ac83f..91f5d7373456 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java @@ -452,7 +452,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb final String address = myConnection.getAddress(); - if (myConnection instanceof PidRemoteConnection) { + if (myConnection instanceof PidRemoteConnection && !((PidRemoteConnection)myConnection).isFixedAddress()) { PidRemoteConnection pidRemoteConnection = (PidRemoteConnection)myConnection; Connector connector = pidRemoteConnection.getConnector(this); String pid = pidRemoteConnection.getPid(); diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/attach/JavaAttachDebuggerProvider.java b/java/debugger/impl/src/com/intellij/debugger/impl/attach/JavaAttachDebuggerProvider.java index 6ca349ff7efa..5868d47cd06d 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/attach/JavaAttachDebuggerProvider.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/attach/JavaAttachDebuggerProvider.java @@ -3,6 +3,7 @@ package com.intellij.debugger.impl.attach; import com.intellij.debugger.DebuggerManagerEx; import com.intellij.debugger.engine.RemoteStateState; +import com.intellij.debugger.impl.DebuggerManagerImpl; import com.intellij.debugger.impl.GenericDebuggerRunner; import com.intellij.execution.*; import com.intellij.execution.configurations.*; @@ -172,7 +173,7 @@ public class JavaAttachDebuggerProvider implements XLocalAttachDebuggerProvider if (param.startsWith("address")) { try { address = param.split("=")[1]; - return new DebuggerLocalAttachInfo(socket, address, null, pid); + return new DebuggerLocalAttachInfo(socket, address, null, pid, false); } catch (Exception e) { LOG.error(e); @@ -222,14 +223,23 @@ public class JavaAttachDebuggerProvider implements XLocalAttachDebuggerProvider String command = agentProperties.getProperty("sun.java.command"); if (!StringUtil.isEmpty(command)) { command = StringUtil.replace(command, AppMainV2.class.getName(), "").trim(); - command = StringUtil.substringBefore(command, " "); + command = StringUtil.notNullize(StringUtil.substringBefore(command, " "), command); } String property = agentProperties.getProperty("sun.jdwp.listenerAddress"); if (property != null && property.indexOf(':') != -1) { + boolean autoAddress = false; + String args = agentProperties.getProperty("sun.jvm.args"); + if (!StringUtil.isEmpty(args)) { + for (String arg : args.split(" ")) { + if (arg.startsWith("-agentlib:jdwp")) { + autoAddress = !arg.contains("address="); + break; + } + } + } return new DebuggerLocalAttachInfo(!"dt_shmem".equals(StringUtil.substringBefore(property, ":")), StringUtil.substringAfter(property, ":"), - command, - pid); + command, pid, autoAddress); } //do not allow further for idea process @@ -267,18 +277,27 @@ public class JavaAttachDebuggerProvider implements XLocalAttachDebuggerProvider } private static class DebuggerLocalAttachInfo extends LocalAttachInfo { - final boolean myUseSocket; - final String myAddress; + private final boolean myUseSocket; + private final String myAddress; + private final boolean myAutoAddress; - DebuggerLocalAttachInfo(boolean socket, @NotNull String address, String aClass, String pid) { + DebuggerLocalAttachInfo(boolean socket, @NotNull String address, String aClass, String pid, boolean autoAddress) { super(aClass, pid); myUseSocket = socket; myAddress = address; + myAutoAddress = autoAddress; } @Override RemoteConnection createConnection() { - return new PidRemoteConnection(myPid); + return myAutoAddress + ? new PidRemoteConnection(myPid) + : new PidRemoteConnection(myPid, myUseSocket, DebuggerManagerImpl.LOCALHOST_ADDRESS_FALLBACK, myAddress, false); + } + + @Override + String getSessionName() { + return myAutoAddress ? super.getSessionName() : "localhost:" + myAddress; } @Override diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/attach/PidRemoteConnection.java b/java/debugger/impl/src/com/intellij/debugger/impl/attach/PidRemoteConnection.java index 526463dda051..16ad857c127e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/attach/PidRemoteConnection.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/attach/PidRemoteConnection.java @@ -11,13 +11,17 @@ import com.sun.jdi.connect.Connector; */ public class PidRemoteConnection extends RemoteConnection { private final String myPid; + private final boolean myFixedAddress; public PidRemoteConnection(String pid) { - this(pid, false); + super(false, null, null, false); + myFixedAddress = false; + myPid = pid; } - PidRemoteConnection(String pid, boolean serverMode) { - super(false, null, null, serverMode); + public PidRemoteConnection(String pid, boolean useSockets, String hostName, String address, boolean serverMode) { + super(useSockets, hostName, address, serverMode); + myFixedAddress = true; myPid = pid; } @@ -26,6 +30,11 @@ public class PidRemoteConnection extends RemoteConnection { } public Connector getConnector(DebugProcessImpl debugProcess) throws ExecutionException { + assert !myFixedAddress; return DebugProcessImpl.findConnector("com.sun.jdi.ProcessAttach"); } + + public boolean isFixedAddress() { + return myFixedAddress; + } } diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/attach/SAJDWPRemoteConnection.java b/java/debugger/impl/src/com/intellij/debugger/impl/attach/SAJDWPRemoteConnection.java index 6311b9499bda..84f7e0758189 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/attach/SAJDWPRemoteConnection.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/attach/SAJDWPRemoteConnection.java @@ -29,7 +29,8 @@ public class SAJDWPRemoteConnection extends PidRemoteConnection { private static final Logger LOG = Logger.getInstance(SAJDWPRemoteConnection.class); public SAJDWPRemoteConnection(String pid) { - super(pid, true); + super(pid); + setServerMode(true); setAddress("0"); } From aefbcc9ad8b779b250105be53cac809bad31393c Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 28 Sep 2018 14:36:25 +0300 Subject: [PATCH 24/62] cleanup --- .../openapi/application/WriteAction.java | 31 ++---------- .../codeInsight/lookup/LookupAdapter.java | 2 +- .../vfs/impl/VirtualFilePointerImpl.java | 2 +- .../application/impl/ApplicationImplTest.java | 48 +++++++++++-------- .../util/containers/ContainerUtilRt.java | 5 +- .../util/containers/ContainerUtil.java | 4 +- 6 files changed, 41 insertions(+), 51 deletions(-) diff --git a/platform/core-api/src/com/intellij/openapi/application/WriteAction.java b/platform/core-api/src/com/intellij/openapi/application/WriteAction.java index b458841be3c4..941556378a8c 100644 --- a/platform/core-api/src/com/intellij/openapi/application/WriteAction.java +++ b/platform/core-api/src/com/intellij/openapi/application/WriteAction.java @@ -81,12 +81,7 @@ public abstract class WriteAction extends BaseActionRunnable { @NotNull public static AccessToken start() { // get useful information about the write action - return start(4); - } - - @NotNull - private static AccessToken start(int stackDepthToMeaningfulFrame) { - Class callerClass = ObjectUtils.notNull(ReflectionUtil.getCallerClass(stackDepthToMeaningfulFrame), WriteAction.class); + Class callerClass = ObjectUtils.notNull(ReflectionUtil.getCallerClass(3), WriteAction.class); return start(callerClass); } @@ -106,7 +101,7 @@ public abstract class WriteAction extends BaseActionRunnable { * Must be called from the EDT. */ public static void run(@NotNull ThrowableRunnable action) throws E { - AccessToken token = start(4); + AccessToken token = start(action.getClass()); try { action.run(); } @@ -120,13 +115,7 @@ public abstract class WriteAction extends BaseActionRunnable { * Must be called from the EDT. */ public static T compute(@NotNull ThrowableComputable action) throws E { - AccessToken token = start(4); - try { - return action.compute(); - } - finally { - token.finish(); - } + return ApplicationManager.getApplication().runWriteAction(action); } /** @@ -159,13 +148,7 @@ public abstract class WriteAction extends BaseActionRunnable { public static T computeAndWait(@NotNull ThrowableComputable action) throws E { Application application = ApplicationManager.getApplication(); if (application.isDispatchThread()) { - AccessToken token = start(action.getClass()); - try { - return action.compute(); - } - finally { - token.finish(); - } + return ApplicationManager.getApplication().runWriteAction(action); } if (application.isReadAccessAllowed()) { @@ -174,16 +157,12 @@ public abstract class WriteAction extends BaseActionRunnable { final AtomicReference result = new AtomicReference<>(); final AtomicReference exception = new AtomicReference<>(); TransactionGuard.getInstance().submitTransactionAndWait(() -> { - AccessToken token = start(action.getClass()); try { - result.set(action.compute()); + result.set(compute(action)); } catch (Throwable e) { exception.set(e); } - finally { - token.finish(); - } }); Throwable t = exception.get(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/LookupAdapter.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/LookupAdapter.java index b2112989f37c..59d8bd6a871b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/LookupAdapter.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/LookupAdapter.java @@ -3,7 +3,7 @@ package com.intellij.codeInsight.lookup; /** - * @deprecated Use LookupListener directly + * @deprecated Use {@link LookupListener} instead */ public abstract class LookupAdapter implements LookupListener { } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFilePointerImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFilePointerImpl.java index b7e921fe49e1..a44d04e389ec 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFilePointerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFilePointerImpl.java @@ -113,7 +113,7 @@ class VirtualFilePointerImpl extends TraceableDisposable implements VirtualFileP public void dispose() { checkDisposed(); if (myNode.incrementUsageCount(-1) == 0) { - kill("URL when die: "+ toString()); + kill("URL when die: " + this); VirtualFilePointerManager pointerManager = VirtualFilePointerManager.getInstance(); if (pointerManager instanceof VirtualFilePointerManagerImpl) { ((VirtualFilePointerManagerImpl)pointerManager).removeNodeFrom(this); diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/ApplicationImplTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/ApplicationImplTest.java index 8ebb238fff01..e5c1b71c6fec 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/ApplicationImplTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/ApplicationImplTest.java @@ -30,10 +30,7 @@ import com.intellij.openapi.util.EmptyRunnable; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.ThrowableComputable; import com.intellij.testFramework.*; -import com.intellij.util.ArrayUtil; -import com.intellij.util.ConcurrencyUtil; -import com.intellij.util.ExceptionUtil; -import com.intellij.util.TimeoutUtil; +import com.intellij.util.*; import com.intellij.util.concurrency.Semaphore; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; @@ -560,12 +557,21 @@ public class ApplicationImplTest extends LightPlatformTestCase { }); } - private static void safeWrite(Runnable r) { - ApplicationManager.getApplication().invokeLater(() -> WriteAction.run(r::run)); + private static void safeWrite(ThrowableRunnable r) throws Throwable { + Ref e = new Ref<>(); + ApplicationManager.getApplication().invokeLater(() -> { + try { + WriteAction.run(r); + } + catch (Throwable e1) { + e.set(e1); + } + }); UIUtil.dispatchAllInvocationEvents(); + if (e.get() != null) throw e.get(); } - public void testSuspendWriteActionDelaysForeignReadActions() { + public void testSuspendWriteActionDelaysForeignReadActions() throws Throwable { Semaphore mayStartForeignRead = new Semaphore(); mayStartForeignRead.down(); @@ -607,21 +613,25 @@ public class ApplicationImplTest extends LightPlatformTestCase { } } - public void testHasWriteActionWorksInOtherThreads() { - Class actionClass = getClass(); - + public void testHasWriteActionWorksInOtherThreads() throws Throwable { ApplicationImpl app = (ApplicationImpl)ApplicationManager.getApplication(); - assertFalse(app.hasWriteAction(actionClass)); - safeWrite(() -> { - assertTrue(app.hasWriteAction(actionClass)); - app.executeSuspendingWriteAction(ourProject, "", () -> ReadAction.run(() -> { + ThrowableRunnable runnable = new ThrowableRunnable() { + @Override + public void run() throws RuntimeException { + Class> actionClass = getClass(); assertTrue(app.hasWriteAction(actionClass)); - waitForFuture(app.executeOnPooledThread(() -> ReadAction.run(() -> assertTrue(app.hasWriteAction(actionClass))))); - })); - }); + app.executeSuspendingWriteAction(ourProject, "", () -> ReadAction.run(() -> { + assertTrue(app.hasWriteAction(actionClass)); + waitForFuture(app.executeOnPooledThread(() -> ReadAction.run(() -> assertTrue(app.hasWriteAction(actionClass))))); + })); + } + }; + + assertFalse(app.hasWriteAction(runnable.getClass())); + safeWrite(runnable); } - public void testPooledThreadsThatHappenInSuspendedWriteActionStayInSuspendedWriteAction() { + public void testPooledThreadsThatHappenInSuspendedWriteActionStayInSuspendedWriteAction() throws Throwable { LoggedErrorProcessor.getInstance().disableStderrDumping(getTestRootDisposable()); Ref future = Ref.create(); @@ -646,7 +656,7 @@ public class ApplicationImplTest extends LightPlatformTestCase { waitForFuture(future.get()); } - public void testPooledThreadsStartedAfterQuickSuspendedWriteActionDontGetReadPrivileges() { + public void testPooledThreadsStartedAfterQuickSuspendedWriteActionDontGetReadPrivileges() throws Throwable { for (int i = 0; i < 1000; i++) { safeWrite(ApplicationImplTest::checkPooledThreadsDontGetWrongPrivileges); } diff --git a/platform/util-rt/src/com/intellij/util/containers/ContainerUtilRt.java b/platform/util-rt/src/com/intellij/util/containers/ContainerUtilRt.java index 511d584a5c2f..295dc8ef89c1 100644 --- a/platform/util-rt/src/com/intellij/util/containers/ContainerUtilRt.java +++ b/platform/util-rt/src/com/intellij/util/containers/ContainerUtilRt.java @@ -453,15 +453,16 @@ public class ContainerUtilRt { } /** - * @deprecated use simply collection.toArray(array) + * @deprecated use {@link List#toArray(Object[])} instead */ + @Deprecated @NotNull public static T[] toArray(@NotNull List collection, @NotNull T[] array) { return collection.toArray(array); } /** - * @deprecated use simply c.toArray(sample) + * @deprecated use {@link Collection#toArray(Object[])} instead */ @Deprecated @NotNull diff --git a/platform/util/src/com/intellij/util/containers/ContainerUtil.java b/platform/util/src/com/intellij/util/containers/ContainerUtil.java index 1aa84e261df8..e574429db07f 100644 --- a/platform/util/src/com/intellij/util/containers/ContainerUtil.java +++ b/platform/util/src/com/intellij/util/containers/ContainerUtil.java @@ -2697,7 +2697,7 @@ public class ContainerUtil extends ContainerUtilRt { } /** - * @deprecated use simply collection.toArray(array) + * @deprecated use {@link List#toArray(Object[])} instead */ @Deprecated @NotNull @@ -2707,7 +2707,7 @@ public class ContainerUtil extends ContainerUtilRt { } /** - * @deprecated use simply c.toArray(sample) + * @deprecated use {@link Collection#toArray(Object[])} instead */ @Deprecated @NotNull From c256e19b1133ce3f1820a7cd2107709da53b50d8 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 28 Sep 2018 14:40:25 +0300 Subject: [PATCH 25/62] enable "missing @override" inspection to spot deprecated methods easier in byte code too; added missing @override --- .idea/inspectionProfiles/idea_default.xml | 1 + .../moveClassesOrPackages/MoveClassesOrPackagesDialog.java | 2 ++ .../src/com/intellij/openapi/command/WriteCommandAction.java | 1 + .../com/intellij/openapi/components/ApplicationComponent.java | 1 + .../core-api/src/com/intellij/util/graph/GraphAlgorithms.java | 1 + .../intellij/openapi/editor/EditorCustomElementRenderer.java | 3 +++ platform/indexing-api/src/com/intellij/find/FindModel.java | 2 ++ platform/lang-api/src/com/intellij/execution/Location.java | 1 + .../com/intellij/psi/codeStyle/CodeStyleSettingsProvider.java | 1 + platform/lang-api/src/com/intellij/util/LazyUtil.java | 1 + .../src/com/intellij/codeInsight/lookup/LookupAdapter.java | 1 + .../com/intellij/execution/configurations/PtyCommandLine.java | 4 ++++ .../src/com/intellij/ide/actions/ActionsCollector.java | 1 + .../src/com/intellij/ui/SimpleColoredComponent.java | 1 + .../platform-api/src/com/intellij/util/io/RequestBuilder.java | 1 + .../com/intellij/execution/impl/EditorHyperlinkSupport.java | 1 + platform/util/src/com/intellij/openapi/util/JDOMUtil.java | 2 ++ platform/util/src/com/intellij/openapi/util/SystemInfo.java | 2 +- platform/util/src/com/intellij/util/Producer.java | 1 + plugins/git4idea/src/git4idea/util/GitFileUtils.java | 1 + .../gradle/native/tooling/src/builder/CppModelBuilder.java | 1 + .../src/com/intellij/xml/util/ColorIconCache.java | 1 + 22 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.idea/inspectionProfiles/idea_default.xml b/.idea/inspectionProfiles/idea_default.xml index 9a8b5868550f..9a301ff8c3f0 100644 --- a/.idea/inspectionProfiles/idea_default.xml +++ b/.idea/inspectionProfiles/idea_default.xml @@ -504,6 +504,7 @@ +