From b43ba0c3b4467d43d57738b8c82e67524ef035eb Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Tue, 15 Nov 2016 13:02:55 +0300 Subject: [PATCH 01/10] javac ast indices: don't add to log PCE --- .../backwardRefs/CompilerReferenceServiceImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceImpl.java b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceImpl.java index bba107fcd03f..248ca7b7c154 100644 --- a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceImpl.java @@ -178,6 +178,9 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceService imple PsiModificationTracker.MODIFICATION_COUNT, this)); } + catch (ProcessCanceledException e) { + throw e; + } catch (Exception e) { LOG.error("an exception during scope without code references calculation", e); return null; @@ -211,7 +214,6 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceService imple if (!isServiceEnabledFor(aClass) || searchScope == LibraryScopeCache.getInstance(myProject).getLibrariesOnlyScope()) return null; try { - Map candidatesPerFile = ReadAction.compute(() -> { if (myProject.isDisposed()) throw new ProcessCanceledException(); return CachedValuesManager.getCachedValue(aClass, () -> CachedValueProvider.Result.create( @@ -234,6 +236,9 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceService imple } return new CompilerHierarchyInfoImpl(candidatesPerFile, aClass, dirtyScope, searchScope, myProject, searchFileType, searchType); } + catch (ProcessCanceledException e) { + throw e; + } catch (Exception e) { LOG.error("an exception during hierarchy calculation", e); return null; From 875be969cb6de0eab8dacad4b846ed0c897010c7 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 14 Nov 2016 11:02:50 +0100 Subject: [PATCH 02/10] simplify ModifiableModel --- .../codeInspection/InspectionProfile.java | 5 +---- .../codeInspection/ModifiableModel.java | 21 ------------------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfile.java b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfile.java index 0cd11db2e062..d9968db36ede 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfile.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfile.java @@ -34,8 +34,6 @@ import java.util.List; * Date: Dec 7, 2004 */ public interface InspectionProfile extends Comparable { - void setName(@NotNull String name); - @NotNull String getName(); @@ -56,8 +54,7 @@ public interface InspectionProfile extends Comparable { InspectionProfileEntry getUnwrappedTool(@NotNull String shortName, @NotNull PsiElement element); /** Returns (unwrapped) inspection */ - - T getUnwrappedTool(@NotNull Key shortNameKey, @NotNull PsiElement element); + T getUnwrappedTool(@NotNull Key shortNameKey, @NotNull PsiElement element); /** * Allows a plugin to modify the settings of the inspection tool with the specified ID programmatically, without going through diff --git a/platform/analysis-api/src/com/intellij/codeInspection/ModifiableModel.java b/platform/analysis-api/src/com/intellij/codeInspection/ModifiableModel.java index fa2619335b41..54181b862648 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/ModifiableModel.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/ModifiableModel.java @@ -13,42 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.intellij.codeInspection; import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.codeInsight.daemon.HighlightDisplayKey; -import com.intellij.codeInspection.ex.InspectionToolWrapper; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.intellij.psi.search.scope.packageSet.NamedScope; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -/** - * User: anna - * Date: 15-Feb-2006 - */ public interface ModifiableModel extends InspectionProfile { void enableTool(@NotNull String inspectionTool, NamedScope namedScope, Project project); void setErrorLevel(HighlightDisplayKey key, @NotNull HighlightDisplayLevel level, Project project); - @Override - HighlightDisplayLevel getErrorLevel(HighlightDisplayKey inspectionToolKey, PsiElement element); - - @Override - boolean isToolEnabled(HighlightDisplayKey key); - - @Override - boolean isToolEnabled(@Nullable HighlightDisplayKey key, @Nullable PsiElement element); - - @Override - InspectionProfileEntry getUnwrappedTool(@NotNull String shortName, @NotNull PsiElement element); - - @Override - InspectionToolWrapper[] getInspectionTools(PsiElement element); - /** * @see InspectionProfile#getSingleTool() */ From 02719388403712abd9ed491c4381e1c04f43a5f3 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 14 Nov 2016 12:36:17 +0100 Subject: [PATCH 03/10] cleanup --- .../intellij/execution/impl/RunConfigurableTest.java | 5 ++--- .../configurations/RunConfigurationBase.java | 12 +++++------- .../intellij/execution/junit/JUnitConfiguration.java | 3 +-- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java b/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java index 5592ae030f1a..d00b71835a4e 100644 --- a/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java +++ b/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -21,7 +21,6 @@ import com.intellij.execution.configurations.UnknownConfigurationType; import com.intellij.execution.junit.JUnitConfigurationType; import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Trinity; import com.intellij.testFramework.LightIdeaTestCase; @@ -196,7 +195,7 @@ public class RunConfigurableTest extends LightIdeaTestCase { assertEquals(expected, myConfigurable.getAvailableDropPosition(direction)); } - private static RunManagerImpl createRunManager(Element element) throws InvalidDataException { + private static RunManagerImpl createRunManager(Element element) { Project project = getProject(); RunManagerImpl runManager = new RunManagerImpl(project, PropertiesComponent.getInstance(project)); runManager.initializeConfigurationTypes(new ConfigurationType[]{ApplicationConfigurationType.getInstance(), diff --git a/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java b/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java index adad3dd2de19..fa9e71b0e82e 100644 --- a/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java +++ b/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -33,7 +33,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.ArrayList; -import java.util.List; /** * Standard base class for run configuration implementations. @@ -196,16 +195,15 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements @Override public void readExternal(Element element) throws InvalidDataException { myLogFiles.clear(); - for (final Object o : element.getChildren(LOG_FILE)) { + for (Element o : element.getChildren(LOG_FILE)) { LogFileOptions logFileOptions = new LogFileOptions(); - logFileOptions.readExternal((Element)o); + logFileOptions.readExternal(o); myLogFiles.add(logFileOptions); } myPredefinedLogFiles.clear(); - final List list = element.getChildren(PREDEFINED_LOG_FILE_ELEMENT); - for (Object fileElement : list) { + for (Element fileElement : element.getChildren(PREDEFINED_LOG_FILE_ELEMENT)) { final PredefinedLogFile logFile = new PredefinedLogFile(); - logFile.readExternal((Element)fileElement); + logFile.readExternal(fileElement); myPredefinedLogFiles.add(logFile); } final Element fileOutputElement = element.getChild(FILE_OUTPUT); diff --git a/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java b/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java index 7d5fe0b9098e..8dd209be8bab 100644 --- a/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java +++ b/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java @@ -351,8 +351,7 @@ public class JUnitConfiguration extends JavaTestConfigurationBase { final Element patternsElement = element.getChild(PATTERNS_EL_NAME); if (patternsElement != null) { final LinkedHashSet tests = new LinkedHashSet<>(); - for (Object o : patternsElement.getChildren(PATTERN_EL_NAME)) { - Element patternElement = (Element)o; + for (Element patternElement : patternsElement.getChildren(PATTERN_EL_NAME)) { tests.add(patternElement.getAttributeValue(TEST_CLASS_ATT_NAME)); } myData.setPatterns(tests); From ceb292fc889e00d0076a57786d6b3ecac20770a1 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 14 Nov 2016 15:37:36 +0100 Subject: [PATCH 04/10] cleanup --- .../execution/remote/RemoteConfiguration.java | 5 +-- .../ModuleBasedConfiguration.java | 39 +++++++++---------- .../RunConfigurationModule.java | 17 +++----- .../openapi/module/ModuleUtilCore.java | 9 +++-- 4 files changed, 31 insertions(+), 39 deletions(-) diff --git a/java/execution/impl/src/com/intellij/execution/remote/RemoteConfiguration.java b/java/execution/impl/src/com/intellij/execution/remote/RemoteConfiguration.java index 7054fdb3b2eb..8460555c30bf 100644 --- a/java/execution/impl/src/com/intellij/execution/remote/RemoteConfiguration.java +++ b/java/execution/impl/src/com/intellij/execution/remote/RemoteConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -43,7 +43,6 @@ import java.util.Collection; public class RemoteConfiguration extends ModuleBasedConfiguration implements RunConfigurationWithSuppressedDefaultRunAction, RemoteRunProfile { - @Override public void writeExternal(final Element element) throws WriteExternalException { super.writeExternal(element); @@ -100,6 +99,4 @@ public class RemoteConfiguration extends ModuleBasedConfiguration getValidModules() { return getAllModules(); } - - } diff --git a/platform/lang-api/src/com/intellij/execution/configurations/ModuleBasedConfiguration.java b/platform/lang-api/src/com/intellij/execution/configurations/ModuleBasedConfiguration.java index 5ab405254a93..d7e5aa27bf00 100644 --- a/platform/lang-api/src/com/intellij/execution/configurations/ModuleBasedConfiguration.java +++ b/platform/lang-api/src/com/intellij/execution/configurations/ModuleBasedConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -25,13 +25,13 @@ import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; import com.intellij.util.xmlb.annotations.Property; +import gnu.trove.THashSet; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.Collection; -import java.util.HashSet; import java.util.Set; /** @@ -68,11 +68,11 @@ public abstract class ModuleBasedConfiguration() { - @Override - @SuppressWarnings({"ConstantConditions"}) - public Module[] compute() { - final Module module = getConfigurationModule().getModule(); - return module == null ? Module.EMPTY_ARRAY : new Module[] {module}; - } - }); + Module module = ApplicationManager.getApplication().runReadAction((Computable)() -> getConfigurationModule().getModule()); + return module == null ? Module.EMPTY_ARRAY : new Module[] {module}; } public void restoreOriginalModule(final Module originalModule) { - if (originalModule == null) return; - final Module[] classModules = getModules(); - final Set modules = new HashSet<>(); - for (Module classModule : classModules) { + if (originalModule == null) { + return; + } + + Set modules = new THashSet<>(); + for (Module classModule : getModules()) { ModuleUtilCore.collectModulesDependsOn(classModule, modules); } - if (modules.contains(originalModule)) setModule(originalModule); + if (modules.contains(originalModule)) { + setModule(originalModule); + } } public void onNewConfigurationCreated() { diff --git a/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationModule.java b/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationModule.java index de230e2e8e0d..100aa02ce077 100644 --- a/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationModule.java +++ b/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationModule.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -55,7 +55,6 @@ public class RunConfigurationModule implements JDOMExternalizable { } @Override - @SuppressWarnings({"unchecked"}) public void readExternal(@NotNull Element element) { List modules = element.getChildren(ELEMENT); if (!modules.isEmpty()) { @@ -97,7 +96,8 @@ public class RunConfigurationModule implements JDOMExternalizable { @Nullable @Transient public Module getModule() { - if (myModuleName != null) { //caching + //caching + if (myModuleName != null) { myModule = findModule(myModuleName); } if (myModule != null && myModule.isDisposed()) { @@ -107,18 +107,11 @@ public class RunConfigurationModule implements JDOMExternalizable { } @Nullable - public Module findModule(final String moduleName) { + public Module findModule(@NotNull String moduleName) { if (myProject.isDisposed()) { return null; } - - return ApplicationManager.getApplication().runReadAction(new Computable() { - @Nullable - @Override - public Module compute() { - return getModuleManager().findModuleByName(moduleName); - } - }); + return ApplicationManager.getApplication().runReadAction((Computable)() -> getModuleManager().findModuleByName(moduleName)); } public void setModule(final Module module) { diff --git a/platform/projectModel-api/src/com/intellij/openapi/module/ModuleUtilCore.java b/platform/projectModel-api/src/com/intellij/openapi/module/ModuleUtilCore.java index f5c18dcab0aa..d3a82734d399 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/module/ModuleUtilCore.java +++ b/platform/projectModel-api/src/com/intellij/openapi/module/ModuleUtilCore.java @@ -157,8 +157,10 @@ public class ModuleUtilCore { * @param result resulted set */ public static void collectModulesDependsOn(@NotNull final Module module, @NotNull Set result) { - if (result.contains(module)) return; - result.add(module); + if (!result.add(module)) { + return; + } + final ModuleManager moduleManager = ModuleManager.getInstance(module.getProject()); final List dependentModules = moduleManager.getModuleDependentModules(module); for (final Module dependentModule : dependentModules) { @@ -169,7 +171,8 @@ public class ModuleUtilCore { if (orderEntry.getModule() == module) { if (orderEntry.isExported()) { collectModulesDependsOn(dependentModule, result); - } else { + } + else { result.add(dependentModule); } break; From c01e5f139587badcd63d0081ffa3d396b560c6ce Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 14 Nov 2016 16:38:20 +0100 Subject: [PATCH 05/10] cleanup --- .../configuration/RunConfigurationPathMacroFilter.java | 4 ++-- .../intellij/application/options/ReplacePathToMacroMap.java | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/configuration/RunConfigurationPathMacroFilter.java b/platform/lang-impl/src/com/intellij/execution/configuration/RunConfigurationPathMacroFilter.java index e6293c649f2a..1656d7bcf301 100644 --- a/platform/lang-impl/src/com/intellij/execution/configuration/RunConfigurationPathMacroFilter.java +++ b/platform/lang-impl/src/com/intellij/execution/configuration/RunConfigurationPathMacroFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -22,7 +22,7 @@ import org.jdom.Element; /** * @author yole */ -public class RunConfigurationPathMacroFilter extends PathMacroFilter { +class RunConfigurationPathMacroFilter extends PathMacroFilter { @Override public boolean skipPathMacros(Attribute attribute) { final Element parent = attribute.getParent(); diff --git a/platform/projectModel-impl/src/com/intellij/application/options/ReplacePathToMacroMap.java b/platform/projectModel-impl/src/com/intellij/application/options/ReplacePathToMacroMap.java index 7ff4ffcd249a..2e8533179e1d 100644 --- a/platform/projectModel-impl/src/com/intellij/application/options/ReplacePathToMacroMap.java +++ b/platform/projectModel-impl/src/com/intellij/application/options/ReplacePathToMacroMap.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -19,7 +19,6 @@ import com.intellij.openapi.components.PathMacroMap; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.ArrayUtil; -import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.ContainerUtilRt; import gnu.trove.TObjectIntHashMap; @@ -28,7 +27,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; -import java.util.Comparator; import java.util.List; import java.util.Map; From bc15e074131dc810c00d3d08270fa7c426edf99a Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 14 Nov 2016 16:42:45 +0100 Subject: [PATCH 06/10] move methods from PathMacroManager to PathMacroSubstitutor to avoid misunderstaning add javadoc to collapsePaths/collapsePathsRecursively --- .../execution/ConfigurationsTest.java | 35 +++++++++++-------- .../openapi/components/PathMacroMap.java | 6 ++++ .../openapi/components/PathMacroManager.java | 15 +++----- .../components/PathMacroSubstitutor.java | 32 ++++++++++++++--- .../components/impl/BasePathMacroManager.java | 26 +++++--------- 5 files changed, 67 insertions(+), 47 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/execution/ConfigurationsTest.java b/java/java-tests/testSrc/com/intellij/execution/ConfigurationsTest.java index 61a1e0c14ed9..b490dde8f147 100644 --- a/java/java-tests/testSrc/com/intellij/execution/ConfigurationsTest.java +++ b/java/java-tests/testSrc/com/intellij/execution/ConfigurationsTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -20,6 +20,8 @@ import com.intellij.execution.application.ApplicationConfiguration; import com.intellij.execution.application.ApplicationConfigurationType; import com.intellij.execution.configurations.*; import com.intellij.execution.executors.DefaultRunExecutor; +import com.intellij.execution.impl.RunManagerImpl; +import com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl; import com.intellij.execution.junit.*; import com.intellij.execution.junit2.configuration.JUnitConfigurable; import com.intellij.execution.junit2.configuration.JUnitConfigurationModel; @@ -27,6 +29,7 @@ import com.intellij.execution.runners.ExecutionEnvironmentBuilder; import com.intellij.execution.testframework.SearchForTestsTask; import com.intellij.execution.testframework.TestSearchScope; import com.intellij.execution.ui.CommonJavaParametersPanel; +import com.intellij.ide.util.AppPropertiesComponentImpl; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.options.Configurable; @@ -37,10 +40,7 @@ import com.intellij.openapi.roots.ContentEntry; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.openapi.ui.LabeledComponent; -import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.LocalFileSystem; @@ -67,6 +67,8 @@ import java.util.Collections; import java.util.List; import java.util.StringTokenizer; +import static org.assertj.core.api.Assertions.assertThat; + public class ConfigurationsTest extends BaseConfigurationTestCase { private final Assertion CHECK = new Assertion(); @@ -253,17 +255,22 @@ public class ConfigurationsTest extends BaseConfigurationTestCase { CHECK.singleOccurence(classPath, getFSPath(findFile(MOCK_JUNIT))); } - public void testExternalizeJUnitConfiguration() throws WriteExternalException, InvalidDataException { - JUnitConfiguration configuration = createConfiguration(findTestA(getModule1())); - Element element = new Element("cfg"); - configuration.writeExternal(element); - JUnitConfiguration newCfg = - new JUnitConfiguration(null, myProject, JUnitConfigurationType.getInstance().getConfigurationFactories()[0]); + public void testExternalizeJUnitConfiguration() { + Module module = getModule1(); + JUnitConfiguration oldRc = createConfiguration(findTestA(module)); + oldRc.setWorkingDirectory(module.getModuleFilePath()); - newCfg.readExternal(element); - checkTestObject(configuration.getPersistentData().TEST_OBJECT, newCfg); - assertEquals(Collections.singleton(getModule1()), ContainerUtilRt.newHashSet(newCfg.getModules())); - checkClassName(configuration.getPersistentData().getMainClassName(), newCfg); + RunManagerImpl runManager = new RunManagerImpl(myProject, new AppPropertiesComponentImpl()); + Element element = new Element("configuration"); + new RunnerAndConfigurationSettingsImpl(runManager, oldRc, false).writeExternal(element); + + RunnerAndConfigurationSettingsImpl settings = new RunnerAndConfigurationSettingsImpl(runManager); + settings.readExternal(element); + JUnitConfiguration newRc = (JUnitConfiguration)settings.getConfiguration(); + + checkTestObject(oldRc.getPersistentData().TEST_OBJECT, newRc); + assertThat(newRc.getModules()).containsOnly(module); + checkClassName(oldRc.getPersistentData().getMainClassName(), newRc); } public void testTestClassPathWhenRunningConfigurations() throws IOException, ExecutionException { diff --git a/jps/model-serialization/src/com/intellij/openapi/components/PathMacroMap.java b/jps/model-serialization/src/com/intellij/openapi/components/PathMacroMap.java index ba6b779a3766..bd5c592f384e 100644 --- a/jps/model-serialization/src/com/intellij/openapi/components/PathMacroMap.java +++ b/jps/model-serialization/src/com/intellij/openapi/components/PathMacroMap.java @@ -31,6 +31,12 @@ public abstract class PathMacroMap { public abstract String substitute(String text, boolean caseSensitive); + public final String substitute(String text, boolean caseSensitive, boolean recursively) { + return recursively + ? substituteRecursively(text, caseSensitive) + : substitute(text, caseSensitive); + } + public final void substitute(@NotNull Element e, boolean caseSensitive) { substitute(e, caseSensitive, false); } diff --git a/platform/projectModel-impl/src/com/intellij/openapi/components/PathMacroManager.java b/platform/projectModel-impl/src/com/intellij/openapi/components/PathMacroManager.java index 659f345fbd18..8be21446b96c 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/components/PathMacroManager.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/components/PathMacroManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -15,20 +15,13 @@ */ package com.intellij.openapi.components; -import org.jdom.Element; import org.jetbrains.annotations.NotNull; public abstract class PathMacroManager implements PathMacroSubstitutor { - public static PathMacroManager getInstance(@NotNull ComponentManager componentManager) { - final PathMacroManager component = (PathMacroManager)componentManager.getPicoContainer().getComponentInstance(PathMacroManager.class); - assert component != null; - return component; - } - - public abstract void collapsePathsRecursively(@NotNull Element element); - @NotNull - public abstract String collapsePathsRecursively(@NotNull String text); + public static PathMacroManager getInstance(@NotNull ComponentManager componentManager) { + return (PathMacroManager)componentManager.getPicoContainer().getComponentInstance(PathMacroManager.class); + } @NotNull public abstract TrackingPathMacroSubstitutor createTrackingSubstitutor(); diff --git a/platform/projectModel-impl/src/com/intellij/openapi/components/PathMacroSubstitutor.java b/platform/projectModel-impl/src/com/intellij/openapi/components/PathMacroSubstitutor.java index bcffa0bc34ee..9bb789a09c94 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/components/PathMacroSubstitutor.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/components/PathMacroSubstitutor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -17,14 +17,38 @@ package com.intellij.openapi.components; import org.jdom.Element; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public interface PathMacroSubstitutor { String expandPath(String path); - String collapsePath(@Nullable String path); + @NotNull + default String collapsePath(@NotNull String text) { + return collapsePath(text, false); + } + + String collapsePath(@NotNull String text, boolean recursively); void expandPaths(@NotNull Element element); - void collapsePaths(@NotNull Element element); + /** + * Path will be collapsed only if the entire content of an attribute (tag text) is a path, if a path is a substring of an attribute value it won't be collapsed. + * @param element + */ + default void collapsePaths(@NotNull Element element) { + collapsePaths(element, false); + } + + /** + * Path will be collapsed even if a path is a substring of an attribute value. + * @param element + */ + default void collapsePathsRecursively(@NotNull Element element) { + collapsePaths(element, true); + } + + void collapsePaths(@NotNull Element element, boolean recursively); + + default String collapsePathsRecursively(@NotNull String string) { + return collapsePath(string, true); + } } diff --git a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java index 36d1a2ccfeff..58f18c39afc2 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java @@ -131,20 +131,10 @@ public class BasePathMacroManager extends PathMacroManager { return getExpandMacroMap().substitute(path, SystemInfo.isFileSystemCaseSensitive); } - @Override - public String collapsePath(@Nullable String path) { - return getReplacePathMap().substitute(path, SystemInfo.isFileSystemCaseSensitive); - } - - @Override - public void collapsePathsRecursively(@NotNull final Element element) { - getReplacePathMap().substitute(element, SystemInfo.isFileSystemCaseSensitive, true); - } - @NotNull @Override - public String collapsePathsRecursively(@NotNull final String text) { - return getReplacePathMap().substituteRecursively(text, SystemInfo.isFileSystemCaseSensitive); + public String collapsePath(@NotNull final String text, boolean recursively) { + return getReplacePathMap().substitute(text, SystemInfo.isFileSystemCaseSensitive, recursively); } @Override @@ -153,8 +143,8 @@ public class BasePathMacroManager extends PathMacroManager { } @Override - public void collapsePaths(@NotNull final Element element) { - getReplacePathMap().substitute(element, SystemInfo.isFileSystemCaseSensitive); + public void collapsePaths(@NotNull final Element element, boolean recursively) { + getReplacePathMap().substitute(element, SystemInfo.isFileSystemCaseSensitive, recursively); } @NotNull @@ -185,8 +175,8 @@ public class BasePathMacroManager extends PathMacroManager { } @Override - public String collapsePath(@Nullable String path) { - return getReplacePathMap().substitute(path, SystemInfo.isFileSystemCaseSensitive); + public String collapsePath(@Nullable String path, boolean recursively) { + return getReplacePathMap().substitute(path, SystemInfo.isFileSystemCaseSensitive, recursively); } @Override @@ -195,8 +185,8 @@ public class BasePathMacroManager extends PathMacroManager { } @Override - public void collapsePaths(@NotNull final Element element) { - getReplacePathMap().substitute(element, SystemInfo.isFileSystemCaseSensitive, false, Holder.FILTER); + public void collapsePaths(@NotNull final Element element, boolean recursively) { + getReplacePathMap().substitute(element, SystemInfo.isFileSystemCaseSensitive, recursively, Holder.FILTER); } public int hashCode() { From 6d20503df0025d4e998668f57e0d19b64a295f72 Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Tue, 15 Nov 2016 13:53:57 +0300 Subject: [PATCH 07/10] IDEA-157763 Settings repository for IDE: unit tests --- .../configuration-store-impl/src/StateStorageManagerImpl.kt | 2 +- .../configuration-store-impl/src/StreamProviderWrapper.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/platform/configuration-store-impl/src/StateStorageManagerImpl.kt b/platform/configuration-store-impl/src/StateStorageManagerImpl.kt index 5e054292a2f5..325f8c27769a 100644 --- a/platform/configuration-store-impl/src/StateStorageManagerImpl.kt +++ b/platform/configuration-store-impl/src/StateStorageManagerImpl.kt @@ -60,7 +60,7 @@ open class StateStorageManagerImpl(private val rootTagName: String, var streamProvider: StreamProvider? get() = streamWrapper set (value) { - streamWrapper.setStreamProvider(value) + streamWrapper.streamProvider = value } // access under storageLock diff --git a/platform/configuration-store-impl/src/StreamProviderWrapper.java b/platform/configuration-store-impl/src/StreamProviderWrapper.java index 24f0aca09e5f..31bc97893348 100644 --- a/platform/configuration-store-impl/src/StreamProviderWrapper.java +++ b/platform/configuration-store-impl/src/StreamProviderWrapper.java @@ -22,6 +22,10 @@ public class StreamProviderWrapper implements StreamProvider { return null; } + public StreamProvider getStreamProvider() { + return myStreamProvider; + } + public void setStreamProvider(@Nullable StreamProvider streamProvider) { myStreamProvider = streamProvider; } From 042d35e060b2b827ad4c0138a5bd139e74002e61 Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Tue, 15 Nov 2016 14:13:02 +0300 Subject: [PATCH 08/10] EA-91784 - Throwable: BalloonImpl.hideAndDispose --- .../src/com/intellij/notification/Notification.java | 4 ++++ .../intellij/notification/impl/NotificationsManagerImpl.java | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/platform-api/src/com/intellij/notification/Notification.java b/platform/platform-api/src/com/intellij/notification/Notification.java index a8c6bf444724..14ddd5c4eead 100644 --- a/platform/platform-api/src/com/intellij/notification/Notification.java +++ b/platform/platform-api/src/com/intellij/notification/Notification.java @@ -263,6 +263,10 @@ public class Notification { } public void expire() { + if (myExpired) { + return; + } + NotificationsManager.getNotificationsManager().expire(this); hideBalloon(); myExpired = true; diff --git a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java index bdce240d9644..420fb013e6af 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java @@ -265,12 +265,13 @@ public class NotificationsManagerImpl extends NotificationsManager { } final Balloon balloon = createBalloon((IdeFrame)window, notification, false, false, layoutDataRef, project != null ? project : ApplicationManager.getApplication()); - ((BalloonImpl)balloon).traceDispose(true); if (notification.isExpired()) { return null; } + ((BalloonImpl)balloon).traceDispose(true); + layout.add(balloon, layoutDataRef == null ? null : layoutDataRef.get()); if (layoutDataRef != null && layoutDataRef.get() instanceof BalloonLayoutData) { ((BalloonLayoutData)layoutDataRef.get()).project = project; From 6ee83fe7de5d219eff15ffa307e033153610e8a0 Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Tue, 15 Nov 2016 14:21:15 +0300 Subject: [PATCH 09/10] EA-91739 - assert: DataBindingWizardAction.actionPerformed --- .../intellij/uiDesigner/actions/DataBindingWizardAction.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/DataBindingWizardAction.java b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/DataBindingWizardAction.java index b5bbd645b26e..767be0a4192c 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/DataBindingWizardAction.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/DataBindingWizardAction.java @@ -46,7 +46,9 @@ public final class DataBindingWizardAction extends AnAction{ final Project project; final VirtualFile formFile; GuiEditor editor = FormEditingUtil.getActiveEditor(e.getDataContext()); - assert editor != null; + if (editor == null) { + return; + } project = editor.getProject(); formFile = editor.getFile(); From 4f109f5dbd1dd51d575a1c90bc962f996dbe406f Mon Sep 17 00:00:00 2001 From: Yaroslav Lepenkin Date: Tue, 15 Nov 2016 13:09:01 +0300 Subject: [PATCH 10/10] [Formatter] remove obvious comments --- .../src/com/intellij/formatting/Alignment.java | 17 ++--------------- .../AbstractBlockAlignmentProcessor.java | 6 ------ .../com/intellij/formatting/AlignmentImpl.java | 10 ---------- 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/platform/lang-api/src/com/intellij/formatting/Alignment.java b/platform/lang-api/src/com/intellij/formatting/Alignment.java index 68eb0d6ee900..48ad2b4f32ed 100644 --- a/platform/lang-api/src/com/intellij/formatting/Alignment.java +++ b/platform/lang-api/src/com/intellij/formatting/Alignment.java @@ -22,8 +22,8 @@ import org.jetbrains.annotations.NotNull; * alignment object instance from the getAlignment method * are aligned with each other. * - * @see com.intellij.formatting.Block#getAlignment() - * @see com.intellij.formatting.ChildAttributes#getAlignment() + * @see Block#getAlignment() + * @see ChildAttributes#getAlignment() */ public abstract class Alignment { @@ -36,23 +36,10 @@ public abstract class Alignment { myFactory = factory; } - /** - * Shorthand for calling {@link #createAlignment(boolean)} with 'false'. - * - * @return alignment object with default settings - */ public static Alignment createAlignment() { return createAlignment(false, Anchor.LEFT); } - /** - * Delegates the processing to {@link #createAlignment(boolean, Anchor)} with given 'allow backward shift' value - * and {@link Anchor#LEFT}. - * - * @param allowBackwardShift flag that specifies if former aligned block may be shifted to right in order to align to subsequent - * aligned block - * @return alignment object with the given 'allow backward shift' setting - */ public static Alignment createAlignment(boolean allowBackwardShift) { return createAlignment(allowBackwardShift, Anchor.LEFT); } diff --git a/platform/lang-impl/src/com/intellij/formatting/AbstractBlockAlignmentProcessor.java b/platform/lang-impl/src/com/intellij/formatting/AbstractBlockAlignmentProcessor.java index f3571b6d7c03..c202510eabbe 100644 --- a/platform/lang-impl/src/com/intellij/formatting/AbstractBlockAlignmentProcessor.java +++ b/platform/lang-impl/src/com/intellij/formatting/AbstractBlockAlignmentProcessor.java @@ -20,12 +20,6 @@ import org.jetbrains.annotations.Nullable; import java.util.Set; -/** - * Gof Template Method for {@link BlockAlignmentProcessor}. - * - * @author Denis Zhdanov - * @since 4/29/11 11:52 AM - */ public abstract class AbstractBlockAlignmentProcessor implements BlockAlignmentProcessor { @Override diff --git a/platform/lang-impl/src/com/intellij/formatting/AlignmentImpl.java b/platform/lang-impl/src/com/intellij/formatting/AlignmentImpl.java index 3af772a999e2..35b60ee4db4a 100644 --- a/platform/lang-impl/src/com/intellij/formatting/AlignmentImpl.java +++ b/platform/lang-impl/src/com/intellij/formatting/AlignmentImpl.java @@ -33,20 +33,10 @@ public class AlignmentImpl extends Alignment { private AlignmentImpl myParentAlignment; private ProbablyIncreasingLowerboundAlgorithm myOffsetRespBlocksCalculator; - /** - * Creates new AlignmentImpl object with 'false' as 'allows backward shift' argument flag. - */ AlignmentImpl() { this(false, Anchor.LEFT); } - /** - * Creates new AlignmentImpl object with the given 'allows backward shift' argument flag. - * - * @param allowBackwardShift flag that indicates if it should be possible to shift former aligned block to right - * in order to align to subsequent aligned block (see {@link Alignment#createAlignment(boolean, Anchor)}) - * @param anchor alignment anchor (see {@link Alignment#createAlignment(boolean, Anchor)}) - */ AlignmentImpl(boolean allowBackwardShift, @NotNull Anchor anchor) { myAllowBackwardShift = allowBackwardShift; myAnchor = anchor;