From 172299badebedf4960e752042a55c2cfb0162ac3 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Thu, 9 Jul 2015 18:31:51 +0300 Subject: [PATCH 01/21] diff: remove unnecessary wrapping into FairDiffIterable --- .../com/intellij/diff/comparison/iterables/DiffIterableUtil.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/diff-impl/src/com/intellij/diff/comparison/iterables/DiffIterableUtil.java b/platform/diff-impl/src/com/intellij/diff/comparison/iterables/DiffIterableUtil.java index 4bdecdf1451d..8316ae5f6094 100644 --- a/platform/diff-impl/src/com/intellij/diff/comparison/iterables/DiffIterableUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/comparison/iterables/DiffIterableUtil.java @@ -106,6 +106,7 @@ public class DiffIterableUtil { @NotNull public static FairDiffIterable fair(@NotNull DiffIterable iterable) { + if (iterable instanceof FairDiffIterable) return (FairDiffIterable)iterable; FairDiffIterable wrapper = new FairDiffIterableWrapper(iterable); verifyFair(wrapper); return wrapper; From 86b9a5103a29871d916a09358d5660fff7757c39 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Thu, 9 Jul 2015 18:37:47 +0300 Subject: [PATCH 02/21] diff: javadoc --- .../diff/comparison/ComparisonManager.java | 27 ++++++++++++++++++- .../intellij/diff/fragments/LineFragment.java | 5 +++- .../iterables/ChangeDiffIterableBase.java | 2 -- .../iterables/FairDiffIterable.java | 7 +++-- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/platform/diff-api/src/com/intellij/diff/comparison/ComparisonManager.java b/platform/diff-api/src/com/intellij/diff/comparison/ComparisonManager.java index db5bee21cf69..1287961c3474 100644 --- a/platform/diff-api/src/com/intellij/diff/comparison/ComparisonManager.java +++ b/platform/diff-api/src/com/intellij/diff/comparison/ComparisonManager.java @@ -27,7 +27,7 @@ import java.util.List; * Class for the text comparison * CharSequences should to have '\n' as line separator *

- * It's good idea not to compare String due to expensive subSequence() implementation. Try to wrap into CharSequenceSubSequence. + * It's good idea not to compare String due to expensive subSequence() implementation. Use CharSequenceSubSequence. */ public abstract class ComparisonManager { @NotNull @@ -35,12 +35,18 @@ public abstract class ComparisonManager { return ServiceManager.getService(ComparisonManager.class); } + /** + * Compare two texts by-line + */ @NotNull public abstract List compareLines(@NotNull CharSequence text1, @NotNull CharSequence text2, @NotNull ComparisonPolicy policy, @NotNull ProgressIndicator indicator) throws DiffTooBigException; + /** + * Compare two texts by-line and then compare changed fragments by-word + */ @NotNull public abstract List compareLinesInner(@NotNull CharSequence text1, @NotNull CharSequence text2, @@ -54,27 +60,46 @@ public abstract class ComparisonManager { @NotNull ComparisonPolicy policy, @NotNull ProgressIndicator indicator) throws DiffTooBigException; + /** + * Compare two texts by-word + */ @NotNull public abstract List compareWords(@NotNull CharSequence text1, @NotNull CharSequence text2, @NotNull ComparisonPolicy policy, @NotNull ProgressIndicator indicator) throws DiffTooBigException; + /** + * Compare two texts by-char + */ @NotNull public abstract List compareChars(@NotNull CharSequence text1, @NotNull CharSequence text2, @NotNull ComparisonPolicy policy, @NotNull ProgressIndicator indicator) throws DiffTooBigException; + /** + * Check if two texts are equal using ComparisonPolicy + */ public abstract boolean isEquals(@NotNull CharSequence text1, @NotNull CharSequence text2, @NotNull ComparisonPolicy policy); // // Post process line fragments // + /** + * compareLinesInner() comparison can produce adjustment line chunks. This method allows to squash shem. + * + * ex: "A\nB" vs "A X\nB Y" will result to two LineFragments: [0, 1) - [0, 1) and [1, 2) - [1, 2) + * squash will produce a single fragment: [0, 2) - [0, 2) + */ @NotNull public abstract List squash(@NotNull List oldFragments); + /** + * @see #squash + * @param trim - if leading/trailing LineFragments with equal contents should be skipped + */ @NotNull public abstract List processBlocks(@NotNull List oldFragments, @NotNull final CharSequence text1, @NotNull final CharSequence text2, diff --git a/platform/diff-api/src/com/intellij/diff/fragments/LineFragment.java b/platform/diff-api/src/com/intellij/diff/fragments/LineFragment.java index ad5e391e6bba..1cb657e6ac74 100644 --- a/platform/diff-api/src/com/intellij/diff/fragments/LineFragment.java +++ b/platform/diff-api/src/com/intellij/diff/fragments/LineFragment.java @@ -28,7 +28,10 @@ public interface LineFragment extends DiffFragment { int getEndLine2(); - /* + /** + * High-granularity changes inside line fragment (ex: detected by ByWord) + * Offsets of inner changes are relative to the start of LineFragment. + * * null - no inner similarities was found */ @Nullable diff --git a/platform/diff-impl/src/com/intellij/diff/comparison/iterables/ChangeDiffIterableBase.java b/platform/diff-impl/src/com/intellij/diff/comparison/iterables/ChangeDiffIterableBase.java index 0517ad1222e8..0a062defa43a 100644 --- a/platform/diff-impl/src/com/intellij/diff/comparison/iterables/ChangeDiffIterableBase.java +++ b/platform/diff-impl/src/com/intellij/diff/comparison/iterables/ChangeDiffIterableBase.java @@ -22,8 +22,6 @@ import java.util.Iterator; @SuppressWarnings("ConstantConditions") abstract class ChangeDiffIterableBase extends DiffIterableBase { - // TODO: non-abstract implementation could be faster - private final int myLength1; private final int myLength2; diff --git a/platform/diff-impl/src/com/intellij/diff/comparison/iterables/FairDiffIterable.java b/platform/diff-impl/src/com/intellij/diff/comparison/iterables/FairDiffIterable.java index 94f04eeeade2..f2ad74200f78 100644 --- a/platform/diff-impl/src/com/intellij/diff/comparison/iterables/FairDiffIterable.java +++ b/platform/diff-impl/src/com/intellij/diff/comparison/iterables/FairDiffIterable.java @@ -15,8 +15,11 @@ */ package com.intellij.diff.comparison.iterables; -/* - * Matched fragments are guaranteed to have same length +/** + * Elements are compared one-by-one. + * If range [a, b) is equal to [a', b'), than element(a + i) is equal to element(a' + i) for all i in [0, b-a) + * + * Matched fragments are guaranteed to have same length. */ public interface FairDiffIterable extends DiffIterable { } From ccee146e648ccd9985e3c294488b73d8828fea9a Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 13 Jul 2015 20:15:12 +0300 Subject: [PATCH 03/21] diff: fix isEquals(String, String, TRIM_WHITESPACES) for texts with more than one line --- .../comparison/ComparisonManagerImpl.java | 34 +++++++++- .../diff/comparison/ComparisonUtilTest.java | 63 +++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 platform/diff-impl/tests/com/intellij/diff/comparison/ComparisonUtilTest.java diff --git a/platform/diff-impl/src/com/intellij/diff/comparison/ComparisonManagerImpl.java b/platform/diff-impl/src/com/intellij/diff/comparison/ComparisonManagerImpl.java index 417d2450495e..69c86488e81d 100644 --- a/platform/diff-impl/src/com/intellij/diff/comparison/ComparisonManagerImpl.java +++ b/platform/diff-impl/src/com/intellij/diff/comparison/ComparisonManagerImpl.java @@ -27,6 +27,7 @@ import com.intellij.util.Consumer; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.diff.FilesTooBigForDiffException; import com.intellij.util.text.CharSequenceSubSequence; +import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -153,7 +154,7 @@ public class ComparisonManagerImpl extends ComparisonManager { case DEFAULT: return StringUtil.equals(text1, text2); case TRIM_WHITESPACES: - return StringUtil.equalsTrimWhitespaces(text1, text2); + return equalsTrimWhitespaces(text1, text2); case IGNORE_WHITESPACES: return StringUtil.equalsIgnoreWhitespaces(text1, text2); default: @@ -161,6 +162,37 @@ public class ComparisonManagerImpl extends ComparisonManager { } } + @Contract(pure = true) + private static boolean equalsTrimWhitespaces(@NotNull CharSequence s1, @NotNull CharSequence s2) { + int index1 = 0; + int index2 = 0; + + while (true) { + boolean lastLine1 = false; + boolean lastLine2 = false; + + int end1 = StringUtil.indexOf(s1, '\n', index1) + 1; + int end2 = StringUtil.indexOf(s2, '\n', index2) + 1; + if (end1 == 0) { + end1 = s1.length(); + lastLine1 = true; + } + if (end2 == 0) { + end2 = s2.length(); + lastLine2 = true; + } + if (lastLine1 ^ lastLine2) return false; + + CharSequence line1 = s1.subSequence(index1, end1); + CharSequence line2 = s2.subSequence(index2, end2); + if (!StringUtil.equalsTrimWhitespaces(line1, line2)) return false; + + index1 = end1; + index2 = end2; + if (lastLine1) return true; + } + } + // // Post process line fragments // diff --git a/platform/diff-impl/tests/com/intellij/diff/comparison/ComparisonUtilTest.java b/platform/diff-impl/tests/com/intellij/diff/comparison/ComparisonUtilTest.java new file mode 100644 index 000000000000..fe71a6b26b1e --- /dev/null +++ b/platform/diff-impl/tests/com/intellij/diff/comparison/ComparisonUtilTest.java @@ -0,0 +1,63 @@ +/* + * Copyright 2000-2015 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.diff.comparison; + +import com.intellij.testFramework.UsefulTestCase; + +public class ComparisonUtilTest extends UsefulTestCase { + private static final ComparisonManager manager = new ComparisonManagerImpl(); + + public void testTrimEquals() { + assertTrue(manager.isEquals("", "", ComparisonPolicy.TRIM_WHITESPACES)); + assertTrue(manager.isEquals("", " ", ComparisonPolicy.TRIM_WHITESPACES)); + assertTrue(manager.isEquals(" ", " ", ComparisonPolicy.TRIM_WHITESPACES)); + assertTrue(manager.isEquals("\n ", " \n", ComparisonPolicy.TRIM_WHITESPACES)); + assertTrue(manager.isEquals("asd ", "asd ", ComparisonPolicy.TRIM_WHITESPACES)); + assertTrue(manager.isEquals(" asd", "asd", ComparisonPolicy.TRIM_WHITESPACES)); + assertTrue(manager.isEquals("\n\n\n", "\n\n\n", ComparisonPolicy.TRIM_WHITESPACES)); + assertTrue(manager.isEquals("\n \n \n ", " \n \n\n ", ComparisonPolicy.TRIM_WHITESPACES)); + assertFalse(manager.isEquals("\n\n", "\n\n\n", ComparisonPolicy.TRIM_WHITESPACES)); + + assertFalse(manager.isEquals("\nasd ", "asd\n ", ComparisonPolicy.TRIM_WHITESPACES)); + assertTrue(manager.isEquals("\nasd \n", "\n asd\n ", ComparisonPolicy.TRIM_WHITESPACES)); + assertFalse(manager.isEquals("x", "y", ComparisonPolicy.TRIM_WHITESPACES)); + assertFalse(manager.isEquals("\n", " ", ComparisonPolicy.TRIM_WHITESPACES)); + + assertTrue(manager.isEquals("\t ", "", ComparisonPolicy.TRIM_WHITESPACES)); + assertFalse(manager.isEquals("", "\t\n \n\t", ComparisonPolicy.TRIM_WHITESPACES)); + assertFalse(manager.isEquals("\t", "\n", ComparisonPolicy.TRIM_WHITESPACES)); + + assertTrue(manager.isEquals("x", " x", ComparisonPolicy.TRIM_WHITESPACES)); + assertTrue(manager.isEquals("x", "x ", ComparisonPolicy.TRIM_WHITESPACES)); + assertFalse(manager.isEquals("x\n", "x", ComparisonPolicy.TRIM_WHITESPACES)); + + assertFalse(manager.isEquals("abc", "a\nb\nc\n", ComparisonPolicy.TRIM_WHITESPACES)); + assertTrue(manager.isEquals("\nx y x\n", "\nx y x\n", ComparisonPolicy.TRIM_WHITESPACES)); + assertFalse(manager.isEquals("\nxyx\n", "\nx y x\n", ComparisonPolicy.TRIM_WHITESPACES)); + assertTrue(manager.isEquals("\nx y x", "\nx y x", ComparisonPolicy.TRIM_WHITESPACES)); + assertFalse(manager.isEquals("\nxyx", "\nx y x", ComparisonPolicy.TRIM_WHITESPACES)); + assertTrue(manager.isEquals("x y x", "x y x", ComparisonPolicy.TRIM_WHITESPACES)); + assertFalse(manager.isEquals("xyx", "x y x", ComparisonPolicy.TRIM_WHITESPACES)); + assertTrue(manager.isEquals(" x y x ", "x y x", ComparisonPolicy.TRIM_WHITESPACES)); + + assertFalse(manager.isEquals("x", "\t\n ", ComparisonPolicy.TRIM_WHITESPACES)); + assertFalse(manager.isEquals("", " x ", ComparisonPolicy.TRIM_WHITESPACES)); + assertFalse(manager.isEquals("", "x ", ComparisonPolicy.TRIM_WHITESPACES)); + assertFalse(manager.isEquals("", " x", ComparisonPolicy.TRIM_WHITESPACES)); + assertFalse(manager.isEquals("xyx", "xxx", ComparisonPolicy.TRIM_WHITESPACES)); + assertFalse(manager.isEquals("xyx", "xYx", ComparisonPolicy.TRIM_WHITESPACES)); + } +} From b558e32c3df8632ec27ff5c6bd9da4a528bdfef6 Mon Sep 17 00:00:00 2001 From: Elizaveta Shashkova Date: Tue, 14 Jul 2015 13:50:48 +0300 Subject: [PATCH 04/21] Show deque elements in Variables Pane (PY-12940) Add a special resolver for deque objects. It's necessary, cause unlike other data structures in collections, the deque is not subclass of the dict. --- python/helpers/pydev/pydevd_resolver.py | 11 +++++++++++ python/helpers/pydev/pydevd_xml.py | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/python/helpers/pydev/pydevd_resolver.py b/python/helpers/pydev/pydevd_resolver.py index a340943a7a8a..5a502512980d 100644 --- a/python/helpers/pydev/pydevd_resolver.py +++ b/python/helpers/pydev/pydevd_resolver.py @@ -481,6 +481,16 @@ class MultiValueDictResolver(DictResolver): return ret +#======================================================================================================================= +# DequeResolver +#======================================================================================================================= +class DequeResolver(TupleResolver): + def getDictionary(self, var): + d = TupleResolver.getDictionary(self, var) + d['maxlen'] = getattr(var, 'maxlen', None) + return d + + #======================================================================================================================= # FrameResolver #======================================================================================================================= @@ -539,4 +549,5 @@ jyArrayResolver = JyArrayResolver() setResolver = SetResolver() ndarrayResolver = NdArrayResolver() multiValueDictResolver = MultiValueDictResolver() +dequeResolver = DequeResolver() frameResolver = FrameResolver() diff --git a/python/helpers/pydev/pydevd_xml.py b/python/helpers/pydev/pydevd_xml.py index a8b90f429a04..d64fd95454ba 100644 --- a/python/helpers/pydev/pydevd_xml.py +++ b/python/helpers/pydev/pydevd_xml.py @@ -77,6 +77,12 @@ if not sys.platform.startswith("java"): except: pass #django may not be installed + try: + from collections import deque + typeMap.append((deque, pydevd_resolver.dequeResolver)) + except: + pass + if frame_type is not None: typeMap.append((frame_type, pydevd_resolver.frameResolver)) From 0dac547ef57b0e7b791f1cdd08107b815f814597 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 14 Jul 2015 11:37:16 +0200 Subject: [PATCH 05/21] extract isDirectoryBased --- .../ui/configuration/ProjectConfigurable.java | 4 +- .../SaveProjectAsTemplateAction.java | 10 ++-- .../impl/ConversionServiceImpl.java | 7 +-- .../impl/convert/ProjectFileVersionImpl.java | 26 ++++---- .../impl/ProjectRootManagerComponent.java | 6 +- .../SaveAsDirectoryBasedFormatAction.java | 59 ++++++++----------- .../com/intellij/ide/impl/ProjectUtil.java | 6 +- .../NonProjectFileWritingAccessProvider.java | 9 ++- .../impl/ProjectStoreImplIdeaDirTest.java | 6 +- .../impl/ProjectStoreImplIprFileTest.java | 6 +- .../testFramework/LightPlatformTestCase.java | 3 +- .../changes/shelf/ShelveChangesManager.java | 17 +++--- .../vcs/checkin/CheckinHandlerUtil.java | 8 +-- .../vcs/impl/DefaultVcsRootPolicy.java | 8 +-- .../vcs/impl/ModuleDefaultVcsRootPolicy.java | 14 ++--- .../vcs/impl/ProjectLevelVcsManagerImpl.java | 18 +++--- 16 files changed, 86 insertions(+), 121 deletions(-) diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectConfigurable.java index b7ba7b6fb307..5d0670093a99 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectConfigurable.java @@ -18,9 +18,9 @@ package com.intellij.openapi.roots.ui.configuration; import com.intellij.core.JavaCoreBundle; import com.intellij.icons.AllIcons; +import com.intellij.ide.impl.ProjectUtil; import com.intellij.ide.util.BrowseFilesListener; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.components.StorageScheme; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; import com.intellij.openapi.fileChooser.FileChooserFactory; @@ -131,7 +131,7 @@ public class ProjectConfigurable extends ProjectStructureElementConfigurableProject name:", SwingConstants.LEFT); diff --git a/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java b/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java index fa9ab673d45a..973ffa59426c 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java +++ b/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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,12 +19,12 @@ import com.intellij.CommonBundle; import com.intellij.codeInspection.defaultFileTemplateUsage.FileHeaderChecker; import com.intellij.ide.fileTemplates.FileTemplate; import com.intellij.ide.fileTemplates.FileTemplateManager; +import com.intellij.ide.impl.ProjectUtil; import com.intellij.ide.util.projectWizard.ProjectTemplateFileProcessor; import com.intellij.ide.util.projectWizard.ProjectTemplateParameterFactory; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.components.StorageScheme; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.module.Module; @@ -33,7 +33,6 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ex.ProjectEx; import com.intellij.openapi.roots.ContentIterator; import com.intellij.openapi.roots.FileIndex; import com.intellij.openapi.roots.ModuleRootManager; @@ -74,8 +73,7 @@ public class SaveProjectAsTemplateAction extends AnAction { public void actionPerformed(AnActionEvent e) { final Project project = getEventProject(e); assert project != null; - StorageScheme scheme = ((ProjectEx)project).getStateStore().getStorageScheme(); - if (scheme != StorageScheme.DIRECTORY_BASED) { + if (!ProjectUtil.isDirectoryBased(project)) { Messages.showErrorDialog(project, "Project templates do not support old .ipr (file-based) format.\n" + "Please convert your project via File->Save as Directory-Based format.", CommonBundle.getErrorTitle()); return; @@ -111,7 +109,7 @@ public class SaveProjectAsTemplateAction extends AnAction { } public static VirtualFile getDescriptionFile(Project project, String path) { - return VfsUtil.findRelativeFile(path, project.getBaseDir()); + return VfsUtilCore.findRelativeFile(path, project.getBaseDir()); } public static void saveProject(final Project project, diff --git a/platform/lang-impl/src/com/intellij/conversion/impl/ConversionServiceImpl.java b/platform/lang-impl/src/com/intellij/conversion/impl/ConversionServiceImpl.java index 99db0269d091..ba5692dc129c 100644 --- a/platform/lang-impl/src/com/intellij/conversion/impl/ConversionServiceImpl.java +++ b/platform/lang-impl/src/com/intellij/conversion/impl/ConversionServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 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,10 +21,8 @@ import com.intellij.conversion.impl.ui.ConvertProjectDialog; import com.intellij.ide.IdeBundle; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.PathManager; -import com.intellij.openapi.components.impl.stores.IProjectStore; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.impl.ProjectImpl; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Pair; @@ -307,8 +305,7 @@ public class ConversionServiceImpl extends ConversionService { @Override @NotNull public ConversionResult convertModule(@NotNull final Project project, @NotNull final File moduleFile) { - final IProjectStore stateStore = ((ProjectImpl)project).getStateStore(); - final String url = stateStore.getPresentableUrl(); + final String url = project.getPresentableUrl(); assert url != null : project; final String projectPath = FileUtil.toSystemDependentName(url); diff --git a/platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersionImpl.java b/platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersionImpl.java index 633822e99050..b905c5044feb 100644 --- a/platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersionImpl.java +++ b/platform/lang-impl/src/com/intellij/ide/impl/convert/ProjectFileVersionImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2015 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,12 +17,11 @@ package com.intellij.ide.impl.convert; import com.intellij.conversion.impl.ConversionServiceImpl; +import com.intellij.ide.impl.ProjectUtil; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.*; -import com.intellij.openapi.components.impl.stores.IProjectStore; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ex.ProjectEx; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.xmlb.XmlSerializerUtil; @@ -71,22 +70,17 @@ public class ProjectFileVersionImpl extends ProjectFileVersion implements Projec @Override public void disposeComponent() { - if (myProject.isDefault() || ApplicationManager.getApplication().isUnitTestMode()) return; - final IProjectStore stateStore = ((ProjectEx)myProject).getStateStore(); - final String filePath; - if (stateStore.getStorageScheme() == StorageScheme.DEFAULT) { - filePath = stateStore.getProjectFilePath(); + if (myProject.isDefault() || ApplicationManager.getApplication().isUnitTestMode()) { + return; } - else { - final VirtualFile baseDir = stateStore.getProjectBaseDir(); - filePath = baseDir != null ? baseDir.getPath() : null; - } - if (filePath != null) { - ConversionServiceImpl.saveConversionResult(FileUtil.toSystemDependentName(filePath)); - } - else { + + VirtualFile file = ProjectUtil.isDirectoryBased(myProject) ? myProject.getBaseDir() : myProject.getProjectFile(); + if (file == null) { LOG.info("Cannot save conversion result: filePath == null"); } + else { + ConversionServiceImpl.saveConversionResult(FileUtil.toSystemDependentName(file.getPath())); + } } @Override diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerComponent.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerComponent.java index 34bc35c19b30..4801d6bdb7aa 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerComponent.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerComponent.java @@ -38,6 +38,7 @@ import com.intellij.openapi.vfs.*; import com.intellij.openapi.vfs.ex.VirtualFileManagerAdapter; import com.intellij.openapi.vfs.pointers.VirtualFilePointer; import com.intellij.openapi.vfs.pointers.VirtualFilePointerListener; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashSet; import com.intellij.util.indexing.FileBasedIndex; import com.intellij.util.indexing.FileBasedIndexImpl; @@ -227,10 +228,7 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl { else { flat.add(projectFilePath); // may be not existing yet - final String workspaceFile = ((ProjectImpl)myProject).getStateStore().getWorkspaceFilePath(); - if (workspaceFile != null) { - flat.add(workspaceFile); - } + ContainerUtil.addIfNotNull(flat, ((ProjectImpl)myProject).getStateStore().getWorkspaceFilePath()); } for (WatchedRootsProvider extension : Extensions.getExtensions(WatchedRootsProvider.EP_NAME, myProject)) { diff --git a/platform/platform-impl/src/com/intellij/ide/actions/SaveAsDirectoryBasedFormatAction.java b/platform/platform-impl/src/com/intellij/ide/actions/SaveAsDirectoryBasedFormatAction.java index c14d4a44f4cd..b542beb9805b 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/SaveAsDirectoryBasedFormatAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/SaveAsDirectoryBasedFormatAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -18,7 +18,6 @@ package com.intellij.ide.actions; import com.intellij.ide.impl.ProjectUtil; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.components.StorageScheme; import com.intellij.openapi.components.impl.stores.IProjectStore; import com.intellij.openapi.components.impl.stores.StateStorageManager; import com.intellij.openapi.project.DumbAware; @@ -39,34 +38,34 @@ import java.util.ArrayList; public class SaveAsDirectoryBasedFormatAction extends AnAction implements DumbAware { public void actionPerformed(AnActionEvent e) { Project project = e.getProject(); - if (project instanceof ProjectEx) { + if (project == null || ProjectUtil.isDirectoryBased(project) || Messages.showOkCancelDialog(project, + "Project will be saved and reopened in new Directory-Based format.\nAre you sure you want to continue?", + "Save project to Directory-Based format", + Messages.getWarningIcon()) != Messages.OK) { + return; + } + + VirtualFile baseDir = project.getBaseDir(); + assert baseDir != null; + + File ideaDir = new File(baseDir.getPath(), Project.DIRECTORY_STORE_FOLDER + File.separatorChar); + if ((ideaDir.exists() && ideaDir.isDirectory()) || createDir(ideaDir)) { IProjectStore projectStore = ((ProjectEx)project).getStateStore(); - if (StorageScheme.DIRECTORY_BASED != projectStore.getStorageScheme()) { - if (Messages.showOkCancelDialog(project, - "Project will be saved and reopened in new Directory-Based format.\nAre you sure you want to continue?", - "Save project to Directory-Based format", Messages.getWarningIcon()) == Messages.OK) { - VirtualFile baseDir = project.getBaseDir(); - assert baseDir != null; - File ideaDir = new File(baseDir.getPath(), Project.DIRECTORY_STORE_FOLDER + File.separatorChar); - if ((ideaDir.exists() && ideaDir.isDirectory()) || createDir(ideaDir)) { - LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ideaDir); + LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ideaDir); - final StateStorageManager storageManager = projectStore.getStateStorageManager(); - for (String file : new ArrayList(storageManager.getStorageFileNames())) { - storageManager.clearStateStorage(file); - } - - projectStore.setProjectFilePath(baseDir.getPath()); - project.save(); - ProjectUtil.closeAndDispose(project); - ProjectUtil.openProject(baseDir.getPath(), null, false); - } - else { - Messages.showErrorDialog(project, String.format("Unable to create '.idea' directory (%s)", ideaDir), "Error saving project!"); - } - } + final StateStorageManager storageManager = projectStore.getStateStorageManager(); + for (String file : new ArrayList(storageManager.getStorageFileNames())) { + storageManager.clearStateStorage(file); } + + projectStore.setProjectFilePath(baseDir.getPath()); + project.save(); + ProjectUtil.closeAndDispose(project); + ProjectUtil.openProject(baseDir.getPath(), null, false); + } + else { + Messages.showErrorDialog(project, String.format("Unable to create '.idea' directory (%s)", ideaDir), "Error saving project!"); } } @@ -83,12 +82,6 @@ public class SaveAsDirectoryBasedFormatAction extends AnAction implements DumbAw @Override public void update(AnActionEvent e) { Project project = e.getProject(); - boolean visible = project != null; - - if (project instanceof ProjectEx) { - visible = ((ProjectEx)project).getStateStore().getStorageScheme() != StorageScheme.DIRECTORY_BASED; - } - - e.getPresentation().setVisible(visible); + e.getPresentation().setVisible(project != null && !ProjectUtil.isDirectoryBased(project)); } } diff --git a/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java b/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java index 7e96ba6ec706..79da05f596cb 100644 --- a/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java +++ b/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -285,4 +285,8 @@ public class ProjectUtil { return userHome.replace('/', File.separatorChar) + File.separator + ApplicationNamesInfo.getInstance().getLowercaseProductName() + "Projects"; } + + public static boolean isDirectoryBased(@NotNull Project project) { + return project instanceof ProjectEx && StorageScheme.DIRECTORY_BASED.equals(((ProjectEx)project).getStateStore().getStorageScheme()); + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/NonProjectFileWritingAccessProvider.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/NonProjectFileWritingAccessProvider.java index 2ee1634bc5fd..eefa8c1ccc55 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/NonProjectFileWritingAccessProvider.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/NonProjectFileWritingAccessProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -16,8 +16,8 @@ package com.intellij.openapi.fileEditor.impl; import com.intellij.ProjectTopics; +import com.intellij.ide.impl.ProjectUtil; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.components.StorageScheme; import com.intellij.openapi.components.impl.stores.IProjectStore; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.module.Module; @@ -154,14 +154,13 @@ public class NonProjectFileWritingAccessProvider extends WritingAccessProvider { if (!Registry.is("ide.hide.excluded.files") && fileIndex.isExcluded(file) && !fileIndex.isUnderIgnored(file)) return true; if (project instanceof ProjectEx) { - IProjectStore store = ((ProjectEx)project).getStateStore(); - - if (store.getStorageScheme() == StorageScheme.DIRECTORY_BASED) { + if (ProjectUtil.isDirectoryBased(project)) { VirtualFile baseDir = project.getBaseDir(); VirtualFile dotIdea = baseDir == null ? null : baseDir.findChild(Project.DIRECTORY_STORE_FOLDER); if (dotIdea != null && VfsUtilCore.isAncestor(dotIdea, file, false)) return true; } + IProjectStore store = ((ProjectEx)project).getStateStore(); if (file.equals(store.getWorkspaceFile()) || file.equals(store.getProjectFile())) return true; for (Module each : ModuleManager.getInstance(project).getModules()) { if (file.equals(each.getModuleFile())) return true; diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ProjectStoreImplIdeaDirTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ProjectStoreImplIdeaDirTest.java index afb8323dec97..5892e09ebe57 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ProjectStoreImplIdeaDirTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ProjectStoreImplIdeaDirTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 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,7 +15,6 @@ */ package com.intellij.openapi.components.impl; -import com.intellij.openapi.components.impl.stores.IProjectStore; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ex.ProjectEx; import com.intellij.openapi.util.io.FileUtil; @@ -37,11 +36,10 @@ public class ProjectStoreImplIdeaDirTest extends ProjectStoreBaseTestCase { } public void testLoadFromDirectoryStorage() throws Exception { - final IProjectStore projectStore = ((ProjectEx)myProject).getStateStore(); ((ProjectEx)myProject).setOptimiseTestLoadSpeed(false); final TestIprComponent testIprComponent = new TestIprComponent(); - projectStore.initComponent(testIprComponent, false); + ((ProjectEx)myProject).getStateStore().initComponent(testIprComponent, false); assertNotNull(testIprComponent.myState); } } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ProjectStoreImplIprFileTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ProjectStoreImplIprFileTest.java index 8452b1f214f2..09412b3f15f0 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ProjectStoreImplIprFileTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/ProjectStoreImplIprFileTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 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,7 +15,6 @@ */ package com.intellij.openapi.components.impl; -import com.intellij.openapi.components.impl.stores.IProjectStore; import com.intellij.openapi.project.ex.ProjectEx; import com.intellij.openapi.util.io.FileUtil; @@ -31,12 +30,11 @@ public class ProjectStoreImplIprFileTest extends ProjectStoreBaseTestCase { } public void testLoadFromOldStorage() throws Exception { - final IProjectStore projectStore = ((ProjectEx)myProject).getStateStore(); ((ProjectEx)myProject).setOptimiseTestLoadSpeed(false); final TestIprComponent testIprComponent = new TestIprComponent(); - projectStore.initComponent(testIprComponent, false); + ((ProjectEx)myProject).getStateStore().initComponent(testIprComponent, false); assertNotNull(testIprComponent.myState); } } diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java index 68f5021e7e0f..fedd6842a9aa 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java @@ -58,7 +58,6 @@ import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.project.ModuleAdapter; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; -import com.intellij.openapi.project.ex.ProjectEx; import com.intellij.openapi.project.ex.ProjectManagerEx; import com.intellij.openapi.project.impl.ProjectManagerImpl; import com.intellij.openapi.projectRoots.Sdk; @@ -786,7 +785,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da ApplicationManager.getApplication().assertWriteAccessAllowed(); if (!ourProject.isDisposed()) { - VirtualFile projectFile = ((ProjectEx)ourProject).getStateStore().getProjectFile(); + VirtualFile projectFile = ourProject.getProjectFile(); File ioFile = projectFile == null ? null : VfsUtilCore.virtualToIoFile(projectFile); Disposer.dispose(ourProject); if (ioFile != null) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java index bf934fa68569..5de3f17a5fbb 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java @@ -22,12 +22,12 @@ */ package com.intellij.openapi.vcs.changes.shelf; +import com.intellij.ide.impl.ProjectUtil; import com.intellij.lifecycle.PeriodicalTasksCloser; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.application.impl.LaterInvocator; import com.intellij.openapi.components.AbstractProjectComponent; -import com.intellij.openapi.components.StorageScheme; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.diff.impl.patch.*; import com.intellij.openapi.diff.impl.patch.apply.ApplyFilePatchBase; @@ -37,7 +37,6 @@ import com.intellij.openapi.progress.AsynchronousExecution; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ex.ProjectEx; import com.intellij.openapi.util.*; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.FileUtilRt; @@ -94,15 +93,13 @@ public class ShelveChangesManager extends AbstractProjectComponent implements JD if (project.isDefault()) { myFileProcessor = new CompoundShelfFileProcessor(null, PathManager.getConfigPath() + File.separator + SHELF_DIR_NAME); } + else if (ProjectUtil.isDirectoryBased(project)) { + VirtualFile dir = project.getBaseDir(); + String shelfBaseDirPath = dir == null ? "" : dir.getPath() + File.separator + Project.DIRECTORY_STORE_FOLDER; + myFileProcessor = new CompoundShelfFileProcessor(shelfBaseDirPath); + } else { - if (project instanceof ProjectEx && ((ProjectEx)project).getStateStore().getStorageScheme() == StorageScheme.DIRECTORY_BASED) { - VirtualFile dir = project.getBaseDir(); - String shelfBaseDirPath = dir == null ? "" : dir.getPath() + File.separator + Project.DIRECTORY_STORE_FOLDER; - myFileProcessor = new CompoundShelfFileProcessor(shelfBaseDirPath); - } - else { - myFileProcessor = new CompoundShelfFileProcessor(); - } + myFileProcessor = new CompoundShelfFileProcessor(); } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/checkin/CheckinHandlerUtil.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/checkin/CheckinHandlerUtil.java index f0512a13a1c3..37e171de962b 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/checkin/CheckinHandlerUtil.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/checkin/CheckinHandlerUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2015 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,10 +15,9 @@ */ package com.intellij.openapi.vcs.checkin; -import com.intellij.openapi.components.StorageScheme; +import com.intellij.ide.impl.ProjectUtil; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ex.ProjectEx; import com.intellij.openapi.projectRoots.OutOfSourcesChecker; import com.intellij.openapi.roots.GeneratedSourcesFilter; import com.intellij.openapi.roots.ProjectFileIndex; @@ -56,8 +55,7 @@ public class CheckinHandlerUtil { PsiManager psiManager = PsiManager.getInstance(project); VirtualFile projectFileDir = null; - final StorageScheme storageScheme = ((ProjectEx) project).getStateStore().getStorageScheme(); - if (StorageScheme.DIRECTORY_BASED.equals(storageScheme)) { + if (ProjectUtil.isDirectoryBased(project)) { VirtualFile baseDir = project.getBaseDir(); if (baseDir != null) { projectFileDir = baseDir.findChild(Project.DIRECTORY_STORE_FOLDER); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/DefaultVcsRootPolicy.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/DefaultVcsRootPolicy.java index 622099e7e0fa..bd9fde53f0ae 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/DefaultVcsRootPolicy.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/DefaultVcsRootPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 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,10 +15,9 @@ */ package com.intellij.openapi.vcs.impl; +import com.intellij.ide.impl.ProjectUtil; import com.intellij.lifecycle.PeriodicalTasksCloser; -import com.intellij.openapi.components.StorageScheme; import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ex.ProjectEx; import com.intellij.openapi.vcs.changes.DirtBuilder; import com.intellij.openapi.vcs.changes.VcsGuess; import com.intellij.openapi.vcs.impl.projectlevelman.NewMappings; @@ -49,8 +48,7 @@ public abstract class DefaultVcsRootPolicy { public abstract void markDefaultRootsDirty(final DirtBuilder builder, VcsGuess vcsGuess); public String getProjectConfigurationMessage(final Project project) { - final StorageScheme storageScheme = ((ProjectEx) project).getStateStore().getStorageScheme(); - boolean isDirectoryBased = StorageScheme.DIRECTORY_BASED.equals(storageScheme); + boolean isDirectoryBased = ProjectUtil.isDirectoryBased(project); final String[] parts = new String[] {"Content roots of all modules", "all immediate descendants of project base directory", Project.DIRECTORY_STORE_FOLDER + " directory contents"}; final StringBuilder sb = new StringBuilder(parts[0]); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java index 039ea1c69592..917a08e15878 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -16,14 +16,13 @@ package com.intellij.openapi.vcs.impl; +import com.intellij.ide.impl.ProjectUtil; import com.intellij.lifecycle.PeriodicalTasksCloser; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.components.StorageScheme; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ex.ProjectEx; import com.intellij.openapi.roots.FileIndexFacade; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.ProjectRootManager; @@ -66,8 +65,7 @@ public class ModuleDefaultVcsRootPolicy extends DefaultVcsRootPolicy { result.add(myBaseDir); } } - final StorageScheme storageScheme = ((ProjectEx) myProject).getStateStore().getStorageScheme(); - if (StorageScheme.DIRECTORY_BASED.equals(storageScheme) && (myBaseDir != null)) { + if (ProjectUtil.isDirectoryBased(myProject) && myBaseDir != null) { final VirtualFile ideaDir = myBaseDir.findChild(Project.DIRECTORY_STORE_FOLDER); if (ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory()) { final AbstractVcs vcsFor = vcsManager.getVcsFor(ideaDir); @@ -122,8 +120,7 @@ public class ModuleDefaultVcsRootPolicy extends DefaultVcsRootPolicy { if (contentRoot != null) { return contentRoot; } - final StorageScheme storageScheme = ((ProjectEx) myProject).getStateStore().getStorageScheme(); - if (StorageScheme.DIRECTORY_BASED.equals(storageScheme) && (myBaseDir != null)) { + if (ProjectUtil.isDirectoryBased(myProject) && (myBaseDir != null)) { final VirtualFile ideaDir = myBaseDir.findChild(Project.DIRECTORY_STORE_FOLDER); if (ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory()) { if (VfsUtilCore.isAncestor(ideaDir, file, false)) { @@ -140,8 +137,7 @@ public class ModuleDefaultVcsRootPolicy extends DefaultVcsRootPolicy { @Override public void run() { final Module[] modules = myModuleManager.getModules(); - final StorageScheme storageScheme = ((ProjectEx) myProject).getStateStore().getStorageScheme(); - if (StorageScheme.DIRECTORY_BASED.equals(storageScheme)) { + if (ProjectUtil.isDirectoryBased(myProject)) { FilePath fp = VcsUtil.getFilePath(myBaseDir, Project.DIRECTORY_STORE_FOLDER, true); final AbstractVcs vcs = vcsGuess.getVcsForDirty(fp); if (vcs != null) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java index 050020d4cdf3..fd8d46cf9da4 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java @@ -16,10 +16,10 @@ package com.intellij.openapi.vcs.impl; import com.intellij.icons.AllIcons; +import com.intellij.ide.impl.ProjectUtil; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.components.ProjectComponent; -import com.intellij.openapi.components.StorageScheme; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorFactory; @@ -30,7 +30,6 @@ import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.DumbAwareRunnable; import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ex.ProjectEx; import com.intellij.openapi.roots.FileIndexFacade; import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.util.*; @@ -883,14 +882,13 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme return false; } - private boolean isInDirectoryBasedRoot(final VirtualFile file) { - if (file == null) return false; - final StorageScheme storageScheme = ((ProjectEx)myProject).getStateStore().getStorageScheme(); - if (StorageScheme.DIRECTORY_BASED.equals(storageScheme)) { - final VirtualFile baseDir = myProject.getBaseDir(); - if (baseDir == null) return false; - final VirtualFile ideaDir = baseDir.findChild(Project.DIRECTORY_STORE_FOLDER); - return ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory() && VfsUtilCore.isAncestor(ideaDir, file, false); + private boolean isInDirectoryBasedRoot(@Nullable VirtualFile file) { + if (file != null && ProjectUtil.isDirectoryBased(myProject)) { + VirtualFile baseDir = myProject.getBaseDir(); + if (baseDir != null) { + VirtualFile ideaDir = baseDir.findChild(Project.DIRECTORY_STORE_FOLDER); + return ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory() && VfsUtilCore.isAncestor(ideaDir, file, false); + } } return false; } From cc28f1fa99ea73ce5e4b69615c3e54cd9eb53034 Mon Sep 17 00:00:00 2001 From: "Vladislav.Soroka" Date: Tue, 14 Jul 2015 14:33:49 +0300 Subject: [PATCH 06/21] IDEA-140550 gradle selective import support --- .../externalSystem/test/ExternalProjectBuilder.groovy | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalProjectBuilder.groovy b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalProjectBuilder.groovy index 1b01fa4e8fd0..4ed0e3f37ff8 100644 --- a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalProjectBuilder.groovy +++ b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalProjectBuilder.groovy @@ -57,16 +57,17 @@ class ExternalProjectBuilder extends BuilderSupport { @Override protected Object createNode(Object name, Map attributes) { + def projectPath = ExternalSystemApiUtil.normalizePath(projectDir.path) switch (name) { case 'project': ProjectSystemId projectSystemId = attributes.projectSystemId ?: TEST_EXTERNAL_SYSTEM_ID - ProjectData projectData = new ProjectData(projectSystemId, attributes.name ?: 'project', projectDir.path, projectDir.path) + ProjectData projectData = new ProjectData(projectSystemId, attributes.name ?: 'project', projectPath, projectPath) projectNode = new DataNode(ProjectKeys.PROJECT, projectData, null) return projectNode case 'module': ProjectSystemId projectSystemId = attributes.projectSystemId ?: TEST_EXTERNAL_SYSTEM_ID - String moduleFilePath = attributes.moduleFilePath ?: projectDir.path - String externalConfigPath = attributes.externalConfigPath ?: projectDir.path + String moduleFilePath = attributes.moduleFilePath ?: projectPath + String externalConfigPath = attributes.externalConfigPath ?: projectPath ModuleData moduleData = new ModuleData(attributes.name ?: name as String, projectSystemId, ModuleTypeId.JAVA_MODULE, From 144d927a6b0e3cf45fd91b79d72fd298c330c374 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Tue, 14 Jul 2015 14:49:47 +0300 Subject: [PATCH 07/21] show used variables from outer methods in debugger --- .../debugger/engine/JavaStackFrame.java | 53 +++++++++++-------- .../debugger/ui/impl/FrameVariablesTree.java | 3 ++ 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java index 2df38a77e926..0bd8f9ac372e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java @@ -30,7 +30,6 @@ import com.intellij.debugger.settings.NodeRendererSettings; import com.intellij.debugger.ui.breakpoints.Breakpoint; import com.intellij.debugger.ui.impl.FrameVariablesTree; import com.intellij.debugger.ui.impl.watch.*; -import com.intellij.debugger.ui.tree.render.ClassRenderer; import com.intellij.debugger.ui.tree.render.DescriptorLabelListener; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; @@ -38,6 +37,7 @@ import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.ColoredTextContainer; +import com.intellij.util.containers.ContainerUtil; import com.intellij.xdebugger.XDebugSession; import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.evaluation.XDebuggerEvaluator; @@ -209,25 +209,8 @@ public class JavaStackFrame extends XStackFrame { } } - final ClassRenderer classRenderer = NodeRendererSettings.getInstance().getClassRenderer(); - if (classRenderer.SHOW_VAL_FIELDS_AS_LOCAL_VARIABLES) { - if (thisObjectReference != null && debugProcess.getVirtualMachineProxy().canGetSyntheticAttribute()) { - final ReferenceType thisRefType = thisObjectReference.referenceType(); - if (thisRefType instanceof ClassType && location != null - && thisRefType.equals(location.declaringType()) && thisRefType.name().contains("$")) { // makes sense for nested classes only - final ClassType clsType = (ClassType)thisRefType; - for (Field field : clsType.fields()) { - if (DebuggerUtils.isSynthetic(field) && StringUtil.startsWith(field.name(), FieldDescriptorImpl.OUTER_LOCAL_VAR_FIELD_PREFIX)) { - final FieldDescriptorImpl fieldDescriptor = myNodeManager.getFieldDescriptor(myDescriptor, thisObjectReference, field); - children.add(JavaValue.create(fieldDescriptor, evaluationContext, myNodeManager)); - } - } - } - } - } - try { - buildVariables(debuggerContext, evaluationContext, children, node); + buildVariables(debuggerContext, evaluationContext, debugProcess, children, thisObjectReference, location); //if (classRenderer.SORT_ASCENDING) { // Collections.sort(myChildren, NodeManagerImpl.getNodeComparator()); //} @@ -255,7 +238,29 @@ public class JavaStackFrame extends XStackFrame { } // copied from FrameVariablesTree - private void buildVariables(DebuggerContextImpl debuggerContext, EvaluationContextImpl evaluationContext, XValueChildrenList children, XCompositeNode node) throws EvaluateException { + private void buildVariables(DebuggerContextImpl debuggerContext, + EvaluationContextImpl evaluationContext, + @NotNull DebugProcessImpl debugProcess, + XValueChildrenList children, + ObjectReference thisObjectReference, + Location location) throws EvaluateException { + final Set visibleLocals = new HashSet(); + if (NodeRendererSettings.getInstance().getClassRenderer().SHOW_VAL_FIELDS_AS_LOCAL_VARIABLES) { + if (thisObjectReference != null && debugProcess.getVirtualMachineProxy().canGetSyntheticAttribute()) { + final ReferenceType thisRefType = thisObjectReference.referenceType(); + if (thisRefType instanceof ClassType && location != null + && thisRefType.equals(location.declaringType()) && thisRefType.name().contains("$")) { // makes sense for nested classes only + for (Field field : thisRefType.fields()) { + if (DebuggerUtils.isSynthetic(field) && StringUtil.startsWith(field.name(), FieldDescriptorImpl.OUTER_LOCAL_VAR_FIELD_PREFIX)) { + final FieldDescriptorImpl fieldDescriptor = myNodeManager.getFieldDescriptor(myDescriptor, thisObjectReference, field); + children.add(JavaValue.create(fieldDescriptor, evaluationContext, myNodeManager)); + visibleLocals.add(fieldDescriptor.getName()); + } + } + } + } + } + boolean myAutoWatchMode = DebuggerSettings.getInstance().AUTO_VARIABLES_MODE; if (evaluationContext == null) { return; @@ -277,14 +282,16 @@ public class JavaStackFrame extends XStackFrame { ApplicationManager.getApplication().runReadAction(new Computable, Set>>() { @Override public Pair, Set> compute() { - return FrameVariablesTree.findReferencedVars(visibleVariables.keySet(), sourcePosition, evalContext); + return FrameVariablesTree.findReferencedVars(ContainerUtil.union(visibleVariables.keySet(), visibleLocals), sourcePosition, evalContext); } }); // add locals if (myAutoWatchMode) { for (String var : usedVars.first) { - final LocalVariableDescriptorImpl descriptor = myNodeManager.getLocalVariableDescriptor(null, visibleVariables.get(var)); - children.add(JavaValue.create(descriptor, evaluationContext, myNodeManager)); + LocalVariableProxyImpl local = visibleVariables.get(var); + if (local != null) { + children.add(JavaValue.create(myNodeManager.getLocalVariableDescriptor(null, local), evaluationContext, myNodeManager)); + } } } else { diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java index 5bf55df20844..5c41a8965b7e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java @@ -625,6 +625,9 @@ public class FrameVariablesTree extends DebuggerTree { if (myVisibleLocals.contains(var.getName())) { myVars.add(var.getName()); } + else if (var instanceof PsiLocalVariable) { + myExpressions.add(new TextWithImportsImpl(reference)); + } } } } From c004c5b1dd2702c9a5f88d7889726f6a0cd93462 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 14 Jul 2015 15:00:55 +0300 Subject: [PATCH 08/21] re IDEA-CR-3528: static methods moved outside, methods unused in platform removed --- .../openapi/roots/GeneratedSourcesFilter.java | 152 ------------------ .../com/intellij/ide/util/EditSourceUtil.java | 36 ++++- 2 files changed, 31 insertions(+), 157 deletions(-) diff --git a/platform/analysis-api/src/com/intellij/openapi/roots/GeneratedSourcesFilter.java b/platform/analysis-api/src/com/intellij/openapi/roots/GeneratedSourcesFilter.java index a988c619c722..32f14b235610 100644 --- a/platform/analysis-api/src/com/intellij/openapi/roots/GeneratedSourcesFilter.java +++ b/platform/analysis-api/src/com/intellij/openapi/roots/GeneratedSourcesFilter.java @@ -17,12 +17,9 @@ package com.intellij.openapi.roots; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Segment; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; -import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.List; @@ -42,71 +39,6 @@ public abstract class GeneratedSourcesFilter { return false; } - /** - * Collect original elements from all filters. - */ - @NotNull - public static List collectAllOriginalElements(@NotNull PsiElement element) { - List result = null; - for (GeneratedSourcesFilter filter : EP_NAME.getExtensions()) { - result = addAll(filter.getOriginalElements(element), result); - } - return orEmpty(result); - } - - /** - * Collect generated elements from all filters. - */ - @NotNull - public static List collectAllGeneratedElements(@NotNull PsiElement element) { - List result = null; - for (GeneratedSourcesFilter filter : EP_NAME.getExtensions()) { - result = addAll(filter.getGeneratedElements(element), result); - } - return orEmpty(result); - } - - /** - * Collect original locations from all filters. - */ - @NotNull - public static List collectAllOriginalLocations(@NotNull Project project, - @NotNull VirtualFile file, - @Nullable Segment segment) { - List result = null; - for (GeneratedSourcesFilter filter : EP_NAME.getExtensions()) { - result = addAll(filter.getOriginalLocations(project, file, segment), result); - } - return orEmpty(result); - } - - /** - * Collect generated locations from all filters. - */ - @NotNull - public static List collectAllGeneratedLocations(@NotNull Project project, - @NotNull VirtualFile file, - @Nullable Segment segment) { - List result = null; - for (GeneratedSourcesFilter filter : EP_NAME.getExtensions()) { - result = addAll(filter.getGeneratedLocations(project, file, segment), result); - } - return orEmpty(result); - } - - private static List addAll(List elements, List result) { - if (result == null) { - return ContainerUtil.newArrayList(elements); - } - result.addAll(elements); - return result; - } - - private static List orEmpty(List elements) { - if (elements != null) return elements; - return Collections.emptyList(); - } - public abstract boolean isGeneratedSource(@NotNull VirtualFile file, @NotNull Project project); /** @@ -119,88 +51,4 @@ public abstract class GeneratedSourcesFilter { public List getOriginalElements(@NotNull PsiElement element) { return Collections.emptyList(); } - - /** - * Returns all elements that have been generated from the given element. - * - * @param element the generated element - * @return a list of generated elements. An empty result indicates that no elements are known to be generated from the given element. - */ - @NotNull - public List getGeneratedElements(@NotNull PsiElement element) { - return Collections.emptyList(); - } - - /** - * Returns all locations that have been processed by a code generator to generate the given location. - * - * @return a list of locations. An empty result indicates that the given segment is not considered to be generated by the filter. - */ - @NotNull - public List getOriginalLocations(@NotNull Project project, - @NotNull VirtualFile file, - @Nullable Segment segment) { - return Collections.emptyList(); - } - - /** - * Returns all locations that have been generated from the given location. - * - * @return a list of locations. An empty result indicates that no locations are known to be generated from the given segments. - */ - @NotNull - public List getGeneratedLocations(@NotNull Project project, - @NotNull VirtualFile file, - @Nullable Segment segment) { - return Collections.emptyList(); - } - - public static class LocationInFile { - - @NotNull private final VirtualFile myFile; - @Nullable private final Segment mySegment; - - public LocationInFile(@NotNull VirtualFile file, @Nullable Segment segment) { - myFile = file; - mySegment = segment; - } - - @NotNull - public VirtualFile getFile() { - return myFile; - } - - @Nullable - public Segment getSegment() { - return mySegment; - } - - @Override - public String toString() { - return "LocationInFile{" + - "myFile=" + myFile + - ", mySegment=" + mySegment + - '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - LocationInFile that = (LocationInFile)o; - - if (!myFile.equals(that.myFile)) return false; - if (mySegment != null ? !mySegment.equals(that.mySegment) : that.mySegment != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = myFile.hashCode(); - result = 31 * result + (mySegment != null ? mySegment.hashCode() : 0); - return result; - } - } } diff --git a/platform/lang-api/src/com/intellij/ide/util/EditSourceUtil.java b/platform/lang-api/src/com/intellij/ide/util/EditSourceUtil.java index 8a709559a940..f58cfdfa2e61 100644 --- a/platform/lang-api/src/com/intellij/ide/util/EditSourceUtil.java +++ b/platform/lang-api/src/com/intellij/ide/util/EditSourceUtil.java @@ -28,19 +28,24 @@ import com.intellij.pom.PomTargetPsiElement; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.util.PsiUtilCore; +import com.intellij.util.ObjectUtils; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Collections; import java.util.List; public class EditSourceUtil { private EditSourceUtil() { } @Nullable - public static Navigatable getDescriptor(PsiElement element) { + public static Navigatable getDescriptor(@NotNull PsiElement element) { PsiElement original = getNavigatableOriginalElement(element); if (original != null) { element = original; - } else if (!canNavigate(element)) { + } + else if (!canNavigate(element)) { return null; } if (element instanceof PomTargetPsiElement) { @@ -60,8 +65,8 @@ public class EditSourceUtil { return desc; } - private static PsiElement getNavigatableOriginalElement(PsiElement element) { - final List originalElements = GeneratedSourcesFilter.collectAllOriginalElements(element); + private static PsiElement getNavigatableOriginalElement(@NotNull PsiElement element) { + final List originalElements = collectAllOriginalElements(element); for (PsiElement original: originalElements) { if (canNavigate(original)) { return original; @@ -79,7 +84,7 @@ public class EditSourceUtil { return file != null && file.isValid() && !file.is(VFileProperty.SPECIAL) && !VfsUtilCore.isBrokenLink(file); } - public static void navigate(NavigationItem item, boolean requestFocus, boolean useCurrentWindow) { + public static void navigate(@NotNull NavigationItem item, boolean requestFocus, boolean useCurrentWindow) { if (item instanceof UserDataHolder) { ((UserDataHolder)item).putUserData(FileEditorManager.USE_CURRENT_WINDOW, useCurrentWindow); } @@ -88,4 +93,25 @@ public class EditSourceUtil { ((UserDataHolder)item).putUserData(FileEditorManager.USE_CURRENT_WINDOW, null); } } + + /** + * Collect original elements from all filters. + */ + @NotNull + private static List collectAllOriginalElements(@NotNull PsiElement element) { + List result = null; + for (GeneratedSourcesFilter filter : GeneratedSourcesFilter.EP_NAME.getExtensions()) { + result = addAll(filter.getOriginalElements(element), result); + } + return ObjectUtils.notNull(result, Collections.emptyList()); + } + + @NotNull + private static List addAll(@NotNull List elements, List result) { + if (result == null) { + return ContainerUtil.newArrayList(elements); + } + result.addAll(elements); + return result; + } } From 6c3f60b348d4666a9f684d1d54ef63975ea64715 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 14 Jul 2015 15:02:51 +0300 Subject: [PATCH 09/21] cleanup names --- .../impl/CodeInsightTestFixtureImpl.java | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index e6f7fbdb778f..22f9ddf33243 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -143,7 +143,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig private final TempDirTestFixture myTempDirFixture; protected final IdeaProjectTestFixture myProjectFixture; - private VirtualFileFilter myFileTreeAccessFilter = new FileTreeAccessFilter(); + private VirtualFileFilter myVirtualFileFilter = new FileTreeAccessFilter(); private boolean myAllowDirt; private boolean myCaresAboutInjection = true; @@ -462,6 +462,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig @NotNull final InspectionToolWrapper... toolWrappers) { final InspectionProfileImpl profile = InspectionProfileImpl.createSimple("test", project, toolWrappers); GlobalInspectionContextForTests context = new GlobalInspectionContextForTests(project, inspectionManager.getContentManager()) { + @NotNull @Override protected List getUsedTools() { return InspectionProfileImpl.initAndDo(new Computable>() { @@ -1510,9 +1511,10 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig } final long start = System.currentTimeMillis(); - final VirtualFileFilter fileTreeAccessFilter = myFileTreeAccessFilter; + final VirtualFileFilter fileTreeAccessFilter = myVirtualFileFilter; + Disposable disposable = Disposer.newDisposable(); if (fileTreeAccessFilter != null) { - ((PsiManagerImpl)PsiManager.getInstance(project)).setAssertOnFileLoadingFilter(fileTreeAccessFilter, myTestRootDisposable); + ((PsiManagerImpl)PsiManager.getInstance(project)).setAssertOnFileLoadingFilter(fileTreeAccessFilter, disposable); } // ProfilingUtil.startCPUProfiling(); @@ -1522,9 +1524,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig removeDuplicatedRangesForInjected(infos); } finally { - if (fileTreeAccessFilter != null) { - ((PsiManagerImpl)PsiManager.getInstance(project)).setAssertOnFileLoadingFilter(VirtualFileFilter.NONE, myTestRootDisposable); - } + Disposer.dispose(disposable); } // ProfilingUtil.captureCPUSnapshot("testing"); final long elapsed = System.currentTimeMillis() - start; @@ -1534,14 +1534,14 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig return elapsed; } - public void setFileTreeAccessFilterForHighlighting(@Nullable VirtualFileFilter fileTreeAccessFilter) { - myFileTreeAccessFilter = fileTreeAccessFilter; + public void setVirtualFileFilter(@Nullable VirtualFileFilter filter) { + myVirtualFileFilter = filter; } private static void removeDuplicatedRangesForInjected(@NotNull List infos) { Collections.sort(infos, new Comparator() { @Override - public int compare(HighlightInfo o1, HighlightInfo o2) { + public int compare(@NotNull HighlightInfo o1, @NotNull HighlightInfo o2) { final int i = o2.startOffset - o1.startOffset; return i != 0 ? i : o1.getSeverity().myVal - o2.getSeverity().myVal; } @@ -1691,7 +1691,8 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig final IntentionAction action = actionInGroup.getAction(); if (ShowIntentionActionsHandler.availableFor(file, editor, action) - || (injectedElement != null && hostElement != injectedElement && ShowIntentionActionsHandler.availableFor(injectedFile, injectedEditor, action))) { + || + injectedElement != null && hostElement != injectedElement && ShowIntentionActionsHandler.availableFor(injectedFile, injectedEditor, action)) { descriptors.add(actionInGroup); } } @@ -1728,23 +1729,23 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig @Override public void allowTreeAccessForFile(@NotNull final VirtualFile file) { - assert myFileTreeAccessFilter instanceof FileTreeAccessFilter : "configured filter does not support this method"; - ((FileTreeAccessFilter)myFileTreeAccessFilter).allowTreeAccessForFile(file); + assert myVirtualFileFilter instanceof FileTreeAccessFilter : "configured filter does not support this method"; + ((FileTreeAccessFilter)myVirtualFileFilter).allowTreeAccessForFile(file); } @Override public void allowTreeAccessForAllFiles() { - assert myFileTreeAccessFilter instanceof FileTreeAccessFilter : "configured filter does not support this method"; - ((FileTreeAccessFilter)myFileTreeAccessFilter).allowTreeAccessForAllFiles(); + assert myVirtualFileFilter instanceof FileTreeAccessFilter : "configured filter does not support this method"; + ((FileTreeAccessFilter)myVirtualFileFilter).allowTreeAccessForAllFiles(); } private static class SelectionAndCaretMarkupLoader { - final String filePath; - final String newFileText; - final EditorTestUtil.CaretAndSelectionState caretState; + private final String filePath; + private final String newFileText; + private final EditorTestUtil.CaretAndSelectionState caretState; @NotNull - static SelectionAndCaretMarkupLoader fromFile(@NotNull String path, String charset) throws IOException { + private static SelectionAndCaretMarkupLoader fromFile(@NotNull String path, String charset) throws IOException { return new SelectionAndCaretMarkupLoader(StringUtil.convertLineSeparators(FileUtil.loadFile(new File(path), charset)), path); } @@ -1848,12 +1849,12 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig private static final String END_FOLD = ""; private static class Border implements Comparable { - public static final boolean LEFT = true; - public static final boolean RIGHT = false; - public boolean mySide; - public int myOffset; - public String myText; - public boolean myIsExpanded; + private static final boolean LEFT = true; + private static final boolean RIGHT = false; + private final boolean mySide; + private final int myOffset; + private final String myText; + private final boolean myIsExpanded; private Border(boolean side, int offset, String text, boolean isExpanded) { mySide = side; From b86335aafb35845c83e62d833a8606aa76ba5c50 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Tue, 14 Jul 2015 15:24:33 +0300 Subject: [PATCH 10/21] made getHighlightRange public --- .../com/intellij/debugger/engine/SourcePositionHighlighter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/SourcePositionHighlighter.java b/java/debugger/openapi/src/com/intellij/debugger/engine/SourcePositionHighlighter.java index f8349e8bffb2..35c56fb96b01 100644 --- a/java/debugger/openapi/src/com/intellij/debugger/engine/SourcePositionHighlighter.java +++ b/java/debugger/openapi/src/com/intellij/debugger/engine/SourcePositionHighlighter.java @@ -26,7 +26,7 @@ import org.jetbrains.annotations.Nullable; public abstract class SourcePositionHighlighter { public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.debugger.sourcePositionHighlighter"); - abstract TextRange getHighlightRange(SourcePosition sourcePosition); + public abstract TextRange getHighlightRange(SourcePosition sourcePosition); @Nullable public static TextRange getHighlightRangeFor(SourcePosition sourcePosition) { From 9158775e484e4a4f341f7f423e36d041c282dc11 Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 14 Jul 2015 15:37:11 +0300 Subject: [PATCH 11/21] gradle and maven integration tests moved to separate groups --- community-tests/src/tests/testGroups.properties | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/community-tests/src/tests/testGroups.properties b/community-tests/src/tests/testGroups.properties index c2fe8974b334..eee771707459 100644 --- a/community-tests/src/tests/testGroups.properties +++ b/community-tests/src/tests/testGroups.properties @@ -88,3 +88,10 @@ com.android.tools.idea.wizard.DynamicWizardStepTest com.android.tools.idea.rendering.FlagManagerTest com.android.tools.idea.rendering.ResourceFolderRepositoryTest +[GRADLE_INTEGRATION_TESTS] +org.jetbrains.plugins.gradle.importing.* +org.jetbrains.plugins.gradle.compiler.* + +[MAVEN_INTEGRATION_TESTS] +org.jetbrains.idea.maven.importing.* +org.jetbrains.idea.maven.compiler.* From 8e47b5c6630a1fc114e4bf5081a7f897ff2eaf65 Mon Sep 17 00:00:00 2001 From: "Vladislav.Soroka" Date: Tue, 14 Jul 2015 15:40:49 +0300 Subject: [PATCH 12/21] IDEA-140550 gradle selective import support --- .../i18n/ExternalSystemBundle.properties | 4 +++- .../action/ExternalSystemToggleAction.java | 5 ++++- .../action/IgnoreExternalProjectAction.java | 22 ++++++++++++++----- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties b/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties index 86cc1e0171ce..bd6a05ce4668 100644 --- a/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties +++ b/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties @@ -47,7 +47,9 @@ action.attach.external.project.description=Attach {0} project to the current ide action.detach.external.project.text=Detach {0} project action.detach.external.project.description=Detach selected external project action.ignore.external.project.text=Ignore {0} project -action.ignore.external.project.description=Ignore selected external project +action.ignore.external.project.description=Ignore selected {0} project +action.unignore.external.project.text=Unignore {0} project +action.unignore.external.project.description=Unignore selected {0} project action.open.config.text=Open {0} config action.open.config.description=Allows to open project file of the linked {0} project at the editor diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/ExternalSystemToggleAction.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/ExternalSystemToggleAction.java index 2409fbc0cfdf..feba1985a095 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/ExternalSystemToggleAction.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/ExternalSystemToggleAction.java @@ -47,7 +47,7 @@ public abstract class ExternalSystemToggleAction extends ToggleAction implements } @Override - public final boolean isSelected(AnActionEvent e) { + public boolean isSelected(AnActionEvent e) { if (!isEnabled(e)) return false; return doIsSelected(e); } @@ -77,4 +77,7 @@ public abstract class ExternalSystemToggleAction extends ToggleAction implements protected void setText(AnActionEvent e, String message) { e.getPresentation().setText(message); } + protected void setDescription(AnActionEvent e, String message) { + e.getPresentation().setDescription(message); + } } diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/IgnoreExternalProjectAction.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/IgnoreExternalProjectAction.java index 32db13ba505a..b165cc1ea70d 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/IgnoreExternalProjectAction.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/IgnoreExternalProjectAction.java @@ -24,7 +24,6 @@ import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys; import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware; import com.intellij.openapi.externalSystem.model.project.ProjectData; -import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager; import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager; import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; @@ -48,15 +47,13 @@ public class IgnoreExternalProjectAction extends ExternalSystemToggleAction { private static final Logger LOG = Logger.getInstance(IgnoreExternalProjectAction.class); public IgnoreExternalProjectAction() { - setText(ExternalSystemBundle.message("action.ignore.external.project.text", "external")); - setDescription(ExternalSystemBundle.message("action.ignore.external.project.description")); + getTemplatePresentation().setText(ExternalSystemBundle.message("action.ignore.external.project.text", "external")); + getTemplatePresentation().setDescription(ExternalSystemBundle.message("action.ignore.external.project.description", "external")); } @Override public void setSelected(AnActionEvent e, boolean state) { final ProjectSystemId projectSystemId = getSystemId(e); - setText(e, ExternalSystemBundle.message("action.ignore.external.project.text", projectSystemId.getReadableName())); - final ExternalSystemNode projectNode = getProjectNode(e); if (projectNode == null || projectNode.getData() == null) return; @@ -88,6 +85,21 @@ public class IgnoreExternalProjectAction extends ExternalSystemToggleAction { }); } + @Override + public boolean isSelected(AnActionEvent e) { + boolean selected = super.isSelected(e); + final ProjectSystemId projectSystemId = getSystemId(e); + if (selected) { + setText(e, ExternalSystemBundle.message("action.unignore.external.project.text", projectSystemId.getReadableName())); + setDescription(e, ExternalSystemBundle.message("action.unignore.external.project.description", projectSystemId.getReadableName())); + } + else { + setText(e, ExternalSystemBundle.message("action.ignore.external.project.text", projectSystemId.getReadableName())); + setDescription(e, ExternalSystemBundle.message("action.ignore.external.project.description", projectSystemId.getReadableName())); + } + return selected; + } + @Override protected boolean isEnabled(AnActionEvent e) { if (!super.isEnabled(e)) return false; From c818fcfd85f9adbdba2573446aeb3266919e9f45 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Tue, 14 Jul 2015 15:34:02 +0300 Subject: [PATCH 13/21] =?UTF-8?q?IDEA-140851=20Keymap=20with=20=C3=A5?= =?UTF-8?q?=C3=A4=C3=B6=20characters=20doesn't=20get=20stored=20properly.?= =?UTF-8?q?=20(fix=20overloading=20issue)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform-impl/src/com/intellij/ui/KeyStrokeAdapter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/KeyStrokeAdapter.java b/platform/platform-impl/src/com/intellij/ui/KeyStrokeAdapter.java index 6f14ef93c1da..3492b7520977 100644 --- a/platform/platform-impl/src/com/intellij/ui/KeyStrokeAdapter.java +++ b/platform/platform-impl/src/com/intellij/ui/KeyStrokeAdapter.java @@ -107,7 +107,7 @@ public class KeyStrokeAdapter implements KeyListener { if (event != null && !event.isConsumed()) { int id = event.getID(); if (id == KeyEvent.KEY_TYPED) { - return extended ? null : getKeyStroke(event.getKeyChar(), event.getModifiers()); + return extended ? null : getKeyStroke(event.getKeyChar(), 0); } boolean released = id == KeyEvent.KEY_RELEASED; if (released || id == KeyEvent.KEY_PRESSED) { @@ -133,7 +133,7 @@ public class KeyStrokeAdapter implements KeyListener { * @return a key stroke or {@code null} if {@code ch} is undefined */ private static KeyStroke getKeyStroke(char ch, int modifiers) { - return KeyEvent.CHAR_UNDEFINED == ch ? null : KeyStroke.getKeyStroke(ch/*TODO:MAC, modifiers*/); + return KeyEvent.CHAR_UNDEFINED == ch ? null : KeyStroke.getKeyStroke(Character.valueOf(ch), modifiers); } /** From 6816ddabaeed7f972774f1994b060793520ae979 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Tue, 14 Jul 2015 15:49:24 +0300 Subject: [PATCH 14/21] =?UTF-8?q?IDEA-140851=20Keymap=20with=20=C3=A5?= =?UTF-8?q?=C3=A4=C3=B6=20characters=20doesn't=20get=20stored=20properly.?= =?UTF-8?q?=20(store=20hex=20prefix)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/platform-impl/src/com/intellij/ui/KeyStrokeAdapter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/platform-impl/src/com/intellij/ui/KeyStrokeAdapter.java b/platform/platform-impl/src/com/intellij/ui/KeyStrokeAdapter.java index 3492b7520977..4772113e2fe1 100644 --- a/platform/platform-impl/src/com/intellij/ui/KeyStrokeAdapter.java +++ b/platform/platform-impl/src/com/intellij/ui/KeyStrokeAdapter.java @@ -292,6 +292,7 @@ public class KeyStrokeAdapter implements KeyListener { append(sb, "released", stroke.isOnKeyRelease()); String name = LazyVirtualKeys.myCodeToName.get(code); if (name == null) { + sb.append('#'); name = Integer.toHexString(code); } return sb.append(name).toString(); From e4c76234c2a588166b837020c782659f6e7bb7e4 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 9 Jul 2015 13:58:06 +0300 Subject: [PATCH 15/21] allow to run all tests in directory ignoring module bounds (IDEA-142354) --- .../intellij/execution/junit/TestDirectory.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/junit/src/com/intellij/execution/junit/TestDirectory.java b/plugins/junit/src/com/intellij/execution/junit/TestDirectory.java index 74d67b575ef0..6ecda8613c4f 100644 --- a/plugins/junit/src/com/intellij/execution/junit/TestDirectory.java +++ b/plugins/junit/src/com/intellij/execution/junit/TestDirectory.java @@ -104,6 +104,16 @@ class TestDirectory extends TestPackage { } } + @Override + protected GlobalSearchScope filterScope(JUnitConfiguration.Data data) throws CantRunException { + return GlobalSearchScope.allScope(getConfiguration().getProject()); + } + + @Override + protected String getPackageName(JUnitConfiguration.Data data) throws CantRunException { + return ""; + } + @Override protected PsiPackage getPackage(JUnitConfiguration.Data data) throws CantRunException { final String dirName = data.getDirName(); @@ -115,11 +125,7 @@ class TestDirectory extends TestPackage { if (directory == null) { throw new CantRunException("Directory \'" + dirName + "\' is not found"); } - final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(directory); - if (aPackage == null) { - throw new CantRunException("Package not found in directory"); - } - return aPackage; + return null; } @Override From 1b47f5c85c99d0a39b107bab9e1b09ffdfb28cf0 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 14 Jul 2015 12:17:41 +0300 Subject: [PATCH 16/21] read action --- .../devkit/src/run/JUnitDevKitPatcher.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/plugins/devkit/src/run/JUnitDevKitPatcher.java b/plugins/devkit/src/run/JUnitDevKitPatcher.java index 4e47c4d6d80a..6d798ff44853 100644 --- a/plugins/devkit/src/run/JUnitDevKitPatcher.java +++ b/plugins/devkit/src/run/JUnitDevKitPatcher.java @@ -18,11 +18,14 @@ package org.jetbrains.idea.devkit.run; import com.intellij.execution.JUnitPatcher; import com.intellij.execution.configurations.JavaParameters; import com.intellij.execution.configurations.ParametersList; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.projectRoots.JavaSdkType; import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.io.FileUtil; import com.intellij.psi.JavaPsiFacade; +import com.intellij.psi.PsiClass; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.util.lang.UrlClassLoader; import org.jetbrains.annotations.NonNls; @@ -43,11 +46,20 @@ import java.io.IOException; public class JUnitDevKitPatcher extends JUnitPatcher{ public static final String JAVA_SYSTEM_CLASS_LOADER_PROPERTY = "java.system.class.loader"; - public void patchJavaParameters(@Nullable Module module, JavaParameters javaParameters) { - if (module != null && PsiUtil.isIdeaProject(module.getProject()) && - !javaParameters.getVMParametersList().hasParameter(JAVA_SYSTEM_CLASS_LOADER_PROPERTY) && - JavaPsiFacade.getInstance(module.getProject()).findClass(UrlClassLoader.class.getName(), GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module)) != null) { - javaParameters.getVMParametersList().add("-D" + JAVA_SYSTEM_CLASS_LOADER_PROPERTY + "=" + UrlClassLoader.class.getName()); + public void patchJavaParameters(@Nullable final Module module, JavaParameters javaParameters) { + if (module != null && PsiUtil.isIdeaProject(module.getProject()) && + !javaParameters.getVMParametersList().hasParameter(JAVA_SYSTEM_CLASS_LOADER_PROPERTY)) { + final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(module.getProject()); + final String qualifiedName = UrlClassLoader.class.getName(); + final PsiClass urlLoaderClass = ApplicationManager.getApplication().runReadAction(new Computable() { + @Override + public PsiClass compute() { + return psiFacade.findClass(qualifiedName, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module)); + } + }); + if (urlLoaderClass != null) { + javaParameters.getVMParametersList().add("-D" + JAVA_SYSTEM_CLASS_LOADER_PROPERTY + "=" + UrlClassLoader.class.getName()); + } } Sdk jdk = javaParameters.getJdk(); jdk = IdeaJdk.findIdeaJdk(jdk); From e5318d9e11862f031c394fa729762e1a3f2a57b6 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 14 Jul 2015 13:50:41 +0300 Subject: [PATCH 17/21] testng rerun failed tests: don't override existing methods (IDEA-142581) --- .../testng/model/TestNGTestObject.java | 4 +- .../configuration/DetectClassesToRunTest.java | 44 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/plugins/testng/src/com/theoryinpractice/testng/model/TestNGTestObject.java b/plugins/testng/src/com/theoryinpractice/testng/model/TestNGTestObject.java index 6de132a301ba..cd531a491223 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/model/TestNGTestObject.java +++ b/plugins/testng/src/com/theoryinpractice/testng/model/TestNGTestObject.java @@ -250,7 +250,9 @@ public abstract class TestNGTestObject { classes.put(psiClass, psiMethods); } for (PsiMethod method : methods) { - psiMethods.put(method, Collections.emptyList()); + if (!psiMethods.containsKey(method)) { + psiMethods.put(method, Collections.emptyList()); + } } } } diff --git a/plugins/testng/testSources/com/theoryinpractice/testng/configuration/DetectClassesToRunTest.java b/plugins/testng/testSources/com/theoryinpractice/testng/configuration/DetectClassesToRunTest.java index 3c8c6a02ca4f..aee1063b42c7 100644 --- a/plugins/testng/testSources/com/theoryinpractice/testng/configuration/DetectClassesToRunTest.java +++ b/plugins/testng/testSources/com/theoryinpractice/testng/configuration/DetectClassesToRunTest.java @@ -140,6 +140,50 @@ public class DetectClassesToRunTest extends LightCodeInsightFixtureTestCase { assertEquals(1, paramsToRerun.size()); assertContainsElements(paramsToRerun, "a"); } + + public void testRerunFailedParameterized() throws Exception { + final PsiClass aClass = + myFixture.addClass("package a; " + + "import org.testng.annotations.DataProvider;\n" + + "import org.testng.annotations.Test;\n" + + "\n" + + "import static org.testng.Assert.assertEquals;\n" + + "\n" + + "public class ATest {\n" + + "\n" + + " @DataProvider\n" + + " public Object[][] testData() {\n" + + " return new Object[][]{\n" + + " {1},\n" + + " {2},\n" + + " };\n" + + " }\n" + + "\n" + + " @Test(dataProvider = \"testData\")\n" + + " public void test(int in) {\n" + + " assertEquals(in, 0);\n" + + " }\n" + + "}\n"); + + final LinkedHashMap>> classes = new LinkedHashMap>>(); + classes.put(aClass, new HashMap>()); + final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(getProject()); + final SMTestProxy testProxy = new SMTestProxy("test", false, "java:test://a.ATest.test[0]"); + testProxy.setLocator(new JavaTestLocator()); + RerunFailedTestsAction.includeFailedTestWithDependencies(classes, projectScope, getProject(), testProxy); + + final SMTestProxy testProxy2 = new SMTestProxy("test", false, "java:test://a.ATest.test[1]"); + testProxy2.setLocator(new JavaTestLocator()); + RerunFailedTestsAction.includeFailedTestWithDependencies(classes, projectScope, getProject(), testProxy2); + + assertEquals(1, classes.size()); + final Map> params = classes.get(aClass); + final PsiMethod[] tests = aClass.findMethodsByName("test", false); + assertContainsElements(params.keySet(), tests); + final List paramsToRerun = params.get(tests[0]); + assertEquals(2, paramsToRerun.size()); + assertContainsElements(paramsToRerun, "0", "1"); + } private void doTestMethodConfiguration(PsiClass aClass, PsiMethod... expectedMethods) throws CantRunException { final TestNGConfiguration configuration = From e191c110ce3457e5d692904d4e2abe6f50d71509 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 14 Jul 2015 15:14:43 +0300 Subject: [PATCH 18/21] junit: parameterized with dots --- .../JUnitTreeByDescriptionHierarchyTest.java | 35 +++++++++++++++++++ .../intellij/junit4/JUnit4TestListener.java | 6 +++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java b/plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java index 1e49dcfbcdd8..1a28c62df9f9 100644 --- a/plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java +++ b/plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java @@ -188,6 +188,41 @@ public class JUnitTreeByDescriptionHierarchyTest { "##teamcity[testSuiteFinished name='|[0|]']\n"); } + @Test + public void testParameterizedClassWithParamsWithDots() throws Exception { + final String className = "a.TestA"; + final Description aTestClassDescription = Description.createSuiteDescription(className); + final ArrayList tests = new ArrayList(); + for (String paramName : new String[]{"[0: with - 1.1]", "[1: with - 2.1]"}) { + final Description param1 = Description.createSuiteDescription(paramName); + aTestClassDescription.addChild(param1); + final Description testDescription = Description.createTestDescription(className, "testName" + paramName); + tests.add(testDescription); + param1.addChild(testDescription); + } + doTest(aTestClassDescription, tests, + //tree + "##teamcity[suiteTreeStarted name='|[0: with - 1.1|]' locationHint='java:suite://a.TestA.|[0: with - 1.1|]']\n" + + "##teamcity[suiteTreeNode name='testName|[0: with - 1.1|]' locationHint='java:test://a.TestA.testName|[0: with - 1.1|]']\n" + + "##teamcity[suiteTreeEnded name='|[0: with - 1.1|]']\n" + + "##teamcity[suiteTreeStarted name='|[1: with - 2.1|]' locationHint='java:suite://a.TestA.|[1: with - 2.1|]']\n" + + "##teamcity[suiteTreeNode name='testName|[1: with - 2.1|]' locationHint='java:test://a.TestA.testName|[1: with - 2.1|]']\n" + + "##teamcity[suiteTreeEnded name='|[1: with - 2.1|]']\n", + //start + "##teamcity[enteredTheMatrix]\n" + + "##teamcity[rootName name = 'TestA' comment = 'a' location = 'java:suite://a.TestA']\n" + + "##teamcity[testSuiteStarted name='|[0: with - 1.1|]']\n" + + "##teamcity[testStarted name='testName|[0: with - 1.1|]' locationHint='java:test://a.TestA.testName|[0: with - 1.1|]']\n" + + "\n" + + "##teamcity[testFinished name='testName|[0: with - 1.1|]']\n" + + "##teamcity[testSuiteFinished name='|[0: with - 1.1|]']\n" + + "##teamcity[testSuiteStarted name='|[1: with - 2.1|]']\n" + + "##teamcity[testStarted name='testName|[1: with - 2.1|]' locationHint='java:test://a.TestA.testName|[1: with - 2.1|]']\n" + + "\n" + + "##teamcity[testFinished name='testName|[1: with - 2.1|]']\n" + + "##teamcity[testSuiteFinished name='|[1: with - 2.1|]']\n"); + } + @Test public void test2SuitesWithTheSameTest() throws Exception { final Description root = Description.createSuiteDescription("root"); diff --git a/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestListener.java b/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestListener.java index 0584bffdce88..d906a14d23cf 100644 --- a/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestListener.java +++ b/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestListener.java @@ -382,11 +382,15 @@ public class JUnit4TestListener extends RunListener { private static String getShortName(String fqName) { if (fqName == null) return null; - if (fqName.startsWith("[")) { + final int idx = fqName.indexOf("["); + if (idx == 0) { //param name return fqName; } int lastPointIdx = fqName.lastIndexOf('.'); + if (idx > 0 && fqName.endsWith("]")) { + lastPointIdx = fqName.substring(0, idx).lastIndexOf('.'); + } if (lastPointIdx >= 0) { return fqName.substring(lastPointIdx + 1); } From 2a0a8af6e31e4caa789881447f9450bc80b2483d Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 14 Jul 2015 16:21:28 +0300 Subject: [PATCH 19/21] junit: assumption/failure in before/beforeClass should be processed separately as beforeClass requires additional testStarted/testFinished when normal before already has that calls --- .../JUnitTreeByDescriptionHierarchyTest.java | 51 +++++++++++++++++++ .../intellij/junit4/JUnit4TestListener.java | 34 ++++--------- 2 files changed, 62 insertions(+), 23 deletions(-) diff --git a/plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java b/plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java index 1a28c62df9f9..e633fc1c6813 100644 --- a/plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java +++ b/plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java @@ -323,6 +323,57 @@ public class JUnitTreeByDescriptionHierarchyTest { "##teamcity[testFinished name='TestA.testName']\n" + "##teamcity[testSuiteFinished name='TestA']\n", StringUtil.convertLineSeparators(buf.toString())); } + + @Test + public void testSetupClassFailureForParameterizedClass() throws Exception { + final Description root = Description.createSuiteDescription("root"); + final Description testA = Description.createSuiteDescription("TestA"); + root.addChild(testA); + final Description paramDescription = Description.createSuiteDescription("param"); + testA.addChild(paramDescription); + final Description testName = Description.createTestDescription("TestA", "testName"); + paramDescription.addChild(testName); + + final StringBuffer buf = new StringBuffer(); + final JUnit4TestListener sender = createListener(buf); + sender.sendTree(root); + + Assert.assertEquals("output: " + buf, "##teamcity[suiteTreeStarted name='TestA' locationHint='java:suite://TestA']\n" + + "##teamcity[suiteTreeStarted name='param' locationHint='java:suite://param']\n" + + "##teamcity[suiteTreeNode name='TestA.testName' locationHint='java:test://TestA.testName']\n" + + "##teamcity[suiteTreeEnded name='param']\n" + + "##teamcity[suiteTreeEnded name='TestA']\n", StringUtil.convertLineSeparators(buf.toString())); + + buf.setLength(0); + + sender.testRunStarted(testA); + final Exception exception = new Exception(); + exception.setStackTrace(new StackTraceElement[0]); + sender.testAssumptionFailure(new Failure(testA, exception)); + sender.testRunFinished(new Result()); + + Assert.assertEquals("output: " + buf, "##teamcity[enteredTheMatrix]\n" + + "##teamcity[rootName name = 'root' location = 'java:suite://root']\n" + + "##teamcity[testSuiteStarted name='TestA']\n" + + "##teamcity[testSuiteStarted name='param']\n" + + "##teamcity[testStarted name='TestA.testName' locationHint='java:test://TestA.testName']\n" + + "##teamcity[testIgnored name='TestA.testName' details='java.lang.Exception|n' error='true' message='']\n" + + "\n" + + "##teamcity[testFinished name='TestA.testName']\n" + + "##teamcity[testSuiteFinished name='param']\n" + + "##teamcity[testSuiteFinished name='TestA']\n", StringUtil.convertLineSeparators(buf.toString())); + buf.setLength(0); + + //testStarted and testFinished are called by the framework + sender.testRunStarted(testA); + sender.testAssumptionFailure(new Failure(testName, exception)); + sender.testRunFinished(new Result()); + + Assert.assertEquals("output: " + buf, "##teamcity[enteredTheMatrix]\n" + + "##teamcity[rootName name = 'root' location = 'java:suite://root']\n" + + "##teamcity[testIgnored name='TestA.testName' details='java.lang.Exception|n' error='true' message='']\n", StringUtil.convertLineSeparators(buf.toString())); + + } @Test public void testSingleMethod() throws Exception { diff --git a/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestListener.java b/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestListener.java index d906a14d23cf..f5cea1061a84 100644 --- a/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestListener.java +++ b/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestListener.java @@ -141,16 +141,20 @@ public class JUnit4TestListener extends RunListener { } public void testFailure(Failure failure) throws Exception { - final Description description = failure.getDescription(); + testFailure(failure, failure.getDescription(), MapSerializerUtil.TEST_FAILED, true); + } + + private void testFailure(Failure failure, Description description, String messageName, boolean local) throws Exception { final String methodName = getFullMethodName(description); - //class setUp failed - if (methodName == null) { + if (methodName == null) { //class setUp failed for (Iterator iterator = description.getChildren().iterator(); iterator.hasNext(); ) { - testFailure(failure, MapSerializerUtil.TEST_FAILED, getFullMethodName((Description)iterator.next())); + testFailure(failure, (Description)iterator.next(), messageName, false); } } else { - testFailure(failure, MapSerializerUtil.TEST_FAILED, methodName); + if (!local) testStarted(description); + testFailure(failure, messageName, methodName); + if (!local) testFinished(description); } } @@ -185,17 +189,7 @@ public class JUnit4TestListener extends RunListener { public void testAssumptionFailure(Failure failure) { final Description description = failure.getDescription(); try { - final String methodName = getFullMethodName(description); - //class setUp failed - if (methodName == null) { - for (Iterator iterator = description.getChildren().iterator(); iterator.hasNext(); ) { - final Description testDescription = (Description)iterator.next(); - testAssumptionFailure(failure, testDescription, getFullMethodName(testDescription)); - } - } - else { - testAssumptionFailure(failure, description, methodName); - } + testFailure(failure, description, MapSerializerUtil.TEST_IGNORED, true); } catch (Exception ignore) {} } @@ -215,13 +209,7 @@ public class JUnit4TestListener extends RunListener { } return methodName; } - - private void testAssumptionFailure(Failure failure, Description testDescription, String name) throws Exception { - testStarted(testDescription); - testFailure(failure, MapSerializerUtil.TEST_IGNORED, name); - testFinished(testDescription); - } - + public synchronized void testIgnored(Description description) throws Exception { final String methodName = getFullMethodName(description); if (methodName == null) { From 6b47243311287a6af3db3a2c7192ed3e95905441 Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Tue, 14 Jul 2015 15:28:10 +0300 Subject: [PATCH 20/21] DRY: use same xml file detection --- .../codeInsight/editorActions/XmlSlashTypedHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlSlashTypedHandler.java b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlSlashTypedHandler.java index 9b48d490404a..f53c0f619a90 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlSlashTypedHandler.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlSlashTypedHandler.java @@ -74,7 +74,7 @@ public class XmlSlashTypedHandler extends TypedHandlerDelegate { @Override public Result charTyped(final char c, final Project project, @NotNull final Editor editor, @NotNull final PsiFile editedFile) { if (!WebEditorOptions.getInstance().isAutoCloseTag()) return Result.CONTINUE; - if ((editedFile.getLanguage() instanceof XMLLanguage || editedFile.getViewProvider().getBaseLanguage() instanceof XMLLanguage) && c == '/') { + if ((XmlGtTypedHandler.fileContainsXmlLanguage(editedFile)) && c == '/') { PsiDocumentManager.getInstance(project).commitAllDocuments(); PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); From 503ca3eb7a3771305c8470f52d5ff1e69411c4b2 Mon Sep 17 00:00:00 2001 From: Serega Vasiliev Date: Tue, 14 Jul 2015 15:26:29 +0200 Subject: [PATCH 21/21] started with Guice 4.0 support (moved pkgs/renamed) --- platform/funcTests/config/disabled_plugins.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/funcTests/config/disabled_plugins.txt b/platform/funcTests/config/disabled_plugins.txt index 64c25fd2d5e9..0422e739b22e 100644 --- a/platform/funcTests/config/disabled_plugins.txt +++ b/platform/funcTests/config/disabled_plugins.txt @@ -32,7 +32,7 @@ com.intellij.hibernate W3Validators CFML Support org.jetbrains.plugins.github -GuiceyIDEA +Guice org.intellij.groovy IdeaServerPlugin com.intellij.spring.webflow