From 1303117a282098c770444db9ab26b1e3f5f9eee1 Mon Sep 17 00:00:00 2001 From: Anton Lobov Date: Fri, 23 Mar 2018 11:37:10 +0100 Subject: [PATCH 1/9] WEB-31653 JSON Schema completion: incorrect handling of a string with only one quote --- .../impl/JsonSchemaCompletionContributor.java | 24 +++++++++++++++++-- .../impl/JsonBySchemaHeavyCompletionTest.java | 4 ++++ ...tIncompleteNameWithDefaultStringValue.json | 3 +++ ...pleteNameWithDefaultStringValue_after.json | 3 +++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 json/tests/testData/jsonSchema/completion/insertPropertyName/testIncompleteNameWithDefaultStringValue.json create mode 100644 json/tests/testData/jsonSchema/completion/insertPropertyName/testIncompleteNameWithDefaultStringValue_after.json diff --git a/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaCompletionContributor.java b/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaCompletionContributor.java index ec9d1448b800..bb8d2ef82105 100644 --- a/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaCompletionContributor.java +++ b/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaCompletionContributor.java @@ -7,7 +7,9 @@ import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.ide.DataManager; import com.intellij.internal.statistic.UsageTrigger; +import com.intellij.json.psi.JsonProperty; import com.intellij.json.psi.JsonStringLiteral; +import com.intellij.json.psi.JsonValue; import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Editor; @@ -20,7 +22,9 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; +import com.intellij.psi.TokenType; import com.intellij.psi.codeStyle.CodeStyleManager; +import com.intellij.psi.impl.source.tree.LeafPsiElement; import com.intellij.psi.util.PsiUtilCore; import com.intellij.util.Consumer; import com.intellij.util.ObjectUtils; @@ -322,13 +326,14 @@ public class JsonSchemaCompletionContributor extends CompletionContributor { }; } - private boolean handleInsideQuotesInsertion(InsertionContext context, Editor editor, boolean hasValue) { + private boolean handleInsideQuotesInsertion(@NotNull InsertionContext context, @NotNull Editor editor, boolean hasValue) { if (myInsideStringLiteral) { int offset = editor.getCaretModel().getOffset(); PsiElement element = context.getFile().findElementAt(offset); int tailOffset = context.getTailOffset(); int guessEndOffset = tailOffset + 1; - if (element != null) { + if (element instanceof LeafPsiElement) { + if (handleIncompleteString(editor, element)) return false; int endOffset = element.getTextRange().getEndOffset(); if (endOffset > tailOffset) { context.getDocument().deleteString(tailOffset, endOffset - 1); @@ -342,6 +347,21 @@ public class JsonSchemaCompletionContributor extends CompletionContributor { return false; } + private static boolean handleIncompleteString(@NotNull Editor editor, @NotNull PsiElement element) { + if (((LeafPsiElement)element).getElementType() == TokenType.WHITE_SPACE) { + PsiElement prevSibling = element.getPrevSibling(); + if (prevSibling instanceof JsonProperty) { + JsonValue nameElement = ((JsonProperty)prevSibling).getNameElement(); + if (!nameElement.getText().endsWith("\"")) { + editor.getCaretModel().moveToOffset(nameElement.getTextRange().getEndOffset()); + EditorModificationUtil.insertStringAtCaret(editor, "\"", false, true, 1); + return true; + } + } + } + return false; + } + @Nullable private static JsonSchemaType detectType(List values) { JsonSchemaType type = null; diff --git a/json/tests/test/com/jetbrains/jsonSchema/impl/JsonBySchemaHeavyCompletionTest.java b/json/tests/test/com/jetbrains/jsonSchema/impl/JsonBySchemaHeavyCompletionTest.java index 7a8c338ec237..318946e31c27 100644 --- a/json/tests/test/com/jetbrains/jsonSchema/impl/JsonBySchemaHeavyCompletionTest.java +++ b/json/tests/test/com/jetbrains/jsonSchema/impl/JsonBySchemaHeavyCompletionTest.java @@ -55,6 +55,10 @@ public class JsonBySchemaHeavyCompletionTest extends JsonSchemaHeavyAbstractTest baseInsertTest("insertPropertyName", "testNameWithDefaultStringValue"); } + public void testIncompleteNameWithDefaultStringValue() throws Exception { + baseInsertTest("insertPropertyName", "testIncompleteNameWithDefaultStringValue"); + } + public void testInsertNameWithDefaultIntegerValue() throws Exception { baseInsertTest("insertPropertyName", "testNameWithDefaultIntegerValue"); } diff --git a/json/tests/testData/jsonSchema/completion/insertPropertyName/testIncompleteNameWithDefaultStringValue.json b/json/tests/testData/jsonSchema/completion/insertPropertyName/testIncompleteNameWithDefaultStringValue.json new file mode 100644 index 000000000000..0bd663f27e50 --- /dev/null +++ b/json/tests/testData/jsonSchema/completion/insertPropertyName/testIncompleteNameWithDefaultStringValue.json @@ -0,0 +1,3 @@ +{ + "withStringDefault +} diff --git a/json/tests/testData/jsonSchema/completion/insertPropertyName/testIncompleteNameWithDefaultStringValue_after.json b/json/tests/testData/jsonSchema/completion/insertPropertyName/testIncompleteNameWithDefaultStringValue_after.json new file mode 100644 index 000000000000..423b39bbb715 --- /dev/null +++ b/json/tests/testData/jsonSchema/completion/insertPropertyName/testIncompleteNameWithDefaultStringValue_after.json @@ -0,0 +1,3 @@ +{ + "withStringDefaultValue": "stringDefault" +} From 6d35cff3aec0a9b7c4a9bb0e708de21cea2483da Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Fri, 23 Mar 2018 13:49:02 +0300 Subject: [PATCH 2/9] keep problems scope and VCS scopes together --- .../com/intellij/psi/search/scope/ProblemsScope.java | 12 ++++++++++++ .../packageDependencies/DefaultScopesProvider.java | 1 - .../src/META-INF/LangExtensions.xml | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/platform/analysis-api/src/com/intellij/psi/search/scope/ProblemsScope.java b/platform/analysis-api/src/com/intellij/psi/search/scope/ProblemsScope.java index 0266d1200bd9..85b74fbe85a1 100644 --- a/platform/analysis-api/src/com/intellij/psi/search/scope/ProblemsScope.java +++ b/platform/analysis-api/src/com/intellij/psi/search/scope/ProblemsScope.java @@ -6,10 +6,14 @@ import com.intellij.ide.IdeBundle; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.problems.WolfTheProblemSolver; +import com.intellij.psi.search.scope.packageSet.CustomScopesProvider; import com.intellij.psi.search.scope.packageSet.NamedScope; import com.intellij.psi.search.scope.packageSet.FilteredPackageSet; import org.jetbrains.annotations.NotNull; +import java.util.Collections; +import java.util.List; + /** * @author Sergey Malenkov */ @@ -26,4 +30,12 @@ public final class ProblemsScope extends NamedScope { } }); } + + public static final class Provider implements CustomScopesProvider { + @NotNull + @Override + public List getCustomScopes() { + return Collections.singletonList(INSTANCE); + } + } } diff --git a/platform/lang-impl/src/com/intellij/packageDependencies/DefaultScopesProvider.java b/platform/lang-impl/src/com/intellij/packageDependencies/DefaultScopesProvider.java index 64539c3c4245..8f76db83e2a9 100644 --- a/platform/lang-impl/src/com/intellij/packageDependencies/DefaultScopesProvider.java +++ b/platform/lang-impl/src/com/intellij/packageDependencies/DefaultScopesProvider.java @@ -31,7 +31,6 @@ public class DefaultScopesProvider extends CustomScopesProviderEx { public DefaultScopesProvider(@NotNull Project project) { myProject = project; myScopes = Arrays.asList(ProjectFilesScope.INSTANCE, - ProblemsScope.INSTANCE, getAllScope(), NonProjectFilesScope.INSTANCE, new ScratchesNamedScope()); diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index 93dca12c70bb..96c8202a69e9 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -486,6 +486,7 @@ + From 7d666d15857da6a2735a5a3747dcbceb475f1eac Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Fri, 23 Mar 2018 15:06:54 +0300 Subject: [PATCH 3/9] [followup] Add SAXSVGDocumentFactory forwarding class for batik --- .idea/libraries/batik.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.idea/libraries/batik.xml b/.idea/libraries/batik.xml index f07ae3953e93..1ff43d3d695c 100644 --- a/.idea/libraries/batik.xml +++ b/.idea/libraries/batik.xml @@ -3,7 +3,7 @@ - + From bf30925e3eed88ac53b96822ebc0654e2a47f42d Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Fri, 23 Mar 2018 15:36:54 +0300 Subject: [PATCH 4/9] IDEA-187611: basic icons support int the scope chooser combobox --- .../psi/search/GlobalSearchScopesCore.java | 23 +++++++----------- .../search/DelegatingGlobalSearchScope.java | 24 +++++++------------ .../com/intellij/psi/search/SearchScope.java | 24 +++++++------------ .../util/scopeChooser/ScopeChooserCombo.java | 18 +++----------- 4 files changed, 29 insertions(+), 60 deletions(-) diff --git a/platform/analysis-api/src/com/intellij/psi/search/GlobalSearchScopesCore.java b/platform/analysis-api/src/com/intellij/psi/search/GlobalSearchScopesCore.java index ad76e96d4d5a..18b768fe6684 100644 --- a/platform/analysis-api/src/com/intellij/psi/search/GlobalSearchScopesCore.java +++ b/platform/analysis-api/src/com/intellij/psi/search/GlobalSearchScopesCore.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.psi.search; import com.intellij.openapi.module.Module; @@ -35,6 +21,7 @@ import com.intellij.util.containers.ContainerUtil; import java.util.HashSet; import org.jetbrains.annotations.NotNull; +import javax.swing.Icon; import java.util.Collection; import java.util.Collections; import java.util.Objects; @@ -108,6 +95,12 @@ public class GlobalSearchScopesCore { return mySet.getName(); } + @NotNull + @Override + public Icon getDisplayIcon() { + return mySet.getIcon(); + } + @NotNull @Override public Project getProject() { diff --git a/platform/core-api/src/com/intellij/psi/search/DelegatingGlobalSearchScope.java b/platform/core-api/src/com/intellij/psi/search/DelegatingGlobalSearchScope.java index 89179044fa4b..cc869338ffaa 100644 --- a/platform/core-api/src/com/intellij/psi/search/DelegatingGlobalSearchScope.java +++ b/platform/core-api/src/com/intellij/psi/search/DelegatingGlobalSearchScope.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.psi.search; import com.intellij.openapi.module.Module; @@ -20,7 +6,9 @@ import com.intellij.openapi.module.UnloadedModuleDescription; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import javax.swing.Icon; import java.util.Arrays; import java.util.Collection; @@ -82,6 +70,12 @@ public class DelegatingGlobalSearchScope extends GlobalSearchScope { return myBaseScope.getDisplayName(); } + @Nullable + @Override + public Icon getDisplayIcon() { + return myBaseScope.getDisplayIcon(); + } + @Override public String toString() { return getClass().getName() + "[" + myBaseScope + "]"; diff --git a/platform/core-api/src/com/intellij/psi/search/SearchScope.java b/platform/core-api/src/com/intellij/psi/search/SearchScope.java index 84229fdc7869..3db3178d5e13 100644 --- a/platform/core-api/src/com/intellij/psi/search/SearchScope.java +++ b/platform/core-api/src/com/intellij/psi/search/SearchScope.java @@ -1,23 +1,12 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.psi.search; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiBundle; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.Icon; public abstract class SearchScope { private static int hashCodeCounter; @@ -40,6 +29,11 @@ public abstract class SearchScope { return PsiBundle.message("search.scope.unknown"); } + @Nullable + public Icon getDisplayIcon() { + return null; + } + @NotNull public abstract SearchScope intersectWith(@NotNull SearchScope scope2); @NotNull public abstract SearchScope union(@NotNull SearchScope scope); diff --git a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java index 349dda546ca8..e026bf83ab56 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java +++ b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.util.scopeChooser; import com.intellij.ide.DataManager; @@ -289,6 +275,8 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo private static class ScopeDescriptionWithDelimiterRenderer extends ListCellRendererWrapper { @Override public void customize(JList list, ScopeDescriptor value, int index, boolean selected, boolean hasFocus) { + SearchScope scope = value.getScope(); + setIcon(scope == null ? null : scope.getDisplayIcon()); setText(value.getDisplay()); if (value instanceof ScopeSeparator) { setSeparator(); From 68ada9973d7182dbf0af86b8f1ad7071f44b220b Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Fri, 23 Mar 2018 15:46:31 +0300 Subject: [PATCH 5/9] merge show discovered tests action --- .../actions/ShowDiscoveredTestsAction.java | 65 +++++++++++++++- .../ShowDiscoveredTestsFromChangesAction.java | 77 ------------------- resources/src/META-INF/JavaIdePlugin.xml | 2 - 3 files changed, 63 insertions(+), 81 deletions(-) delete mode 100644 java/execution/impl/src/com/intellij/execution/testDiscovery/actions/ShowDiscoveredTestsFromChangesAction.java diff --git a/java/execution/impl/src/com/intellij/execution/testDiscovery/actions/ShowDiscoveredTestsAction.java b/java/execution/impl/src/com/intellij/execution/testDiscovery/actions/ShowDiscoveredTestsAction.java index 81549e9f4c29..a2900ea22af9 100644 --- a/java/execution/impl/src/com/intellij/execution/testDiscovery/actions/ShowDiscoveredTestsAction.java +++ b/java/execution/impl/src/com/intellij/execution/testDiscovery/actions/ShowDiscoveredTestsAction.java @@ -1,6 +1,7 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.execution.testDiscovery.actions; +import com.intellij.codeInsight.actions.FormatChangedTextUtil; import com.intellij.execution.ExecutionException; import com.intellij.execution.Executor; import com.intellij.execution.JavaTestConfigurationBase; @@ -17,12 +18,15 @@ import com.intellij.find.FindUtil; import com.intellij.find.actions.CompositeActiveComponent; import com.intellij.icons.AllIcons; import com.intellij.ide.DataManager; +import com.intellij.lang.Language; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.impl.ActionButton; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ReadAction; +import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; @@ -32,10 +36,14 @@ import com.intellij.openapi.util.Couple; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.registry.Registry; +import com.intellij.openapi.vcs.VcsDataKeys; +import com.intellij.openapi.vcs.changes.Change; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.ClassUtil; import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.psi.util.PsiUtilCore; +import com.intellij.uast.UastMetaLanguage; import com.intellij.ui.ActiveComponent; import com.intellij.usages.UsageView; import com.intellij.util.ArrayUtil; @@ -47,14 +55,18 @@ import com.intellij.util.ui.tree.TreeModelAdapter; import one.util.streamex.StreamEx; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.uast.UFile; import org.jetbrains.uast.UMethod; import org.jetbrains.uast.UastContextKt; +import org.jetbrains.uast.visitor.AbstractUastVisitor; import javax.swing.*; import javax.swing.event.TreeModelEvent; import javax.swing.tree.TreeModel; import java.awt.event.ActionEvent; +import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; import static com.intellij.openapi.actionSystem.CommonDataKeys.EDITOR; @@ -65,7 +77,10 @@ public class ShowDiscoveredTestsAction extends AnAction { @Override public void update(AnActionEvent e) { - e.getPresentation().setEnabledAndVisible(isEnabledForProject(e) && findMethodAtCaret(e) != null); + e.getPresentation().setEnabledAndVisible( + isEnabledForProject(e) && + (findMethodAtCaret(e) != null || e.getData(VcsDataKeys.CHANGES) != null) + ); } @Override @@ -74,8 +89,16 @@ public class ShowDiscoveredTestsAction extends AnAction { assert project != null; PsiMethod method = findMethodAtCaret(e); - assert method != null; + if (method != null) { + showDiscoveredTestsByPsi(e, project, method); + } + else { + showDiscoveredTestsByChanges(e); + } + } + + private static void showDiscoveredTestsByPsi(AnActionEvent e, Project project, PsiMethod method) { Couple couple = getMethodQualifiedName(method); PsiClass c = method.getContainingClass(); String fqn = couple != null ? couple.first : null; @@ -88,6 +111,44 @@ public class ShowDiscoveredTestsAction extends AnAction { showDiscoveredTests(project, dataContext, methodPresentationName, method); } + private static void showDiscoveredTestsByChanges(AnActionEvent e) { + Change[] changes = e.getRequiredData(VcsDataKeys.CHANGES); + Project project = e.getProject(); + assert project != null; + UastMetaLanguage jvmLanguage = Language.findInstance(UastMetaLanguage.class); + + List methods = FormatChangedTextUtil.getInstance().getChangedElements(project, changes, file -> { + PsiFile psiFile = PsiUtilCore.getPsiFile(project, file); + if (!jvmLanguage.matchesLanguage(psiFile.getLanguage())) { + return null; + } + Document document = FileDocumentManager.getInstance().getDocument(file); + if (document == null) return null; + UFile uFile = UastContextKt.toUElement(psiFile, UFile.class); + if (uFile == null) return null; + + PsiDocumentManager.getInstance(project).commitDocument(document); + List physicalMethods = new ArrayList<>(); + uFile.accept(new AbstractUastVisitor() { + @Override + public boolean visitMethod(@NotNull UMethod node) { + physicalMethods.add(node.getSourcePsi()); + return true; + } + }); + + return physicalMethods; + }); + + PsiMethod[] asJavaMethods = methods + .stream() + .map(m -> ObjectUtils.tryCast(Objects.requireNonNull(UastContextKt.toUElement(m)).getJavaPsi(), PsiMethod.class)) + .filter(Objects::nonNull) + .toArray(PsiMethod.ARRAY_FACTORY::create); + FeatureUsageTracker.getInstance().triggerFeatureUsed("test.discovery.selected.changes"); + showDiscoveredTests(project, e.getDataContext(), "Selected Changes", asJavaMethods); + } + static boolean isEnabledForProject(AnActionEvent e) { return (Registry.is(TestDiscoveryExtension.TEST_DISCOVERY_REGISTRY_KEY) || ApplicationManager.getApplication().isInternal()) && e.getProject() != null; } diff --git a/java/execution/impl/src/com/intellij/execution/testDiscovery/actions/ShowDiscoveredTestsFromChangesAction.java b/java/execution/impl/src/com/intellij/execution/testDiscovery/actions/ShowDiscoveredTestsFromChangesAction.java deleted file mode 100644 index dc4de79ebedc..000000000000 --- a/java/execution/impl/src/com/intellij/execution/testDiscovery/actions/ShowDiscoveredTestsFromChangesAction.java +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -package com.intellij.execution.testDiscovery.actions; - -import com.intellij.codeInsight.actions.FormatChangedTextUtil; -import com.intellij.featureStatistics.FeatureUsageTracker; -import com.intellij.lang.Language; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vcs.VcsDataKeys; -import com.intellij.openapi.vcs.changes.Change; -import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiMethod; -import com.intellij.psi.util.PsiUtilCore; -import com.intellij.uast.UastMetaLanguage; -import com.intellij.util.ObjectUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.uast.UFile; -import org.jetbrains.uast.UMethod; -import org.jetbrains.uast.UastContextKt; -import org.jetbrains.uast.visitor.AbstractUastVisitor; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -public class ShowDiscoveredTestsFromChangesAction extends AnAction { - @Override - public void update(AnActionEvent e) { - e.getPresentation().setEnabledAndVisible(ShowDiscoveredTestsAction.isEnabledForProject(e) && e.getData(VcsDataKeys.CHANGES) != null); - } - - @Override - public void actionPerformed(AnActionEvent e) { - Change[] changes = e.getRequiredData(VcsDataKeys.CHANGES); - Project project = e.getProject(); - assert project != null; - UastMetaLanguage jvmLanguage = Language.findInstance(UastMetaLanguage.class); - - - List methods = FormatChangedTextUtil.getInstance().getChangedElements(project, changes, file -> { - PsiFile psiFile = PsiUtilCore.getPsiFile(project, file); - if (!jvmLanguage.matchesLanguage(psiFile.getLanguage())) { - return null; - } - Document document = FileDocumentManager.getInstance().getDocument(file); - if (document == null) return null; - UFile uFile = UastContextKt.toUElement(psiFile, UFile.class); - if (uFile == null) return null; - - - PsiDocumentManager.getInstance(project).commitDocument(document); - List physicalMethods = new ArrayList<>(); - uFile.accept(new AbstractUastVisitor() { - @Override - public boolean visitMethod(@NotNull UMethod node) { - physicalMethods.add(node.getSourcePsi()); - return true; - } - }); - - return physicalMethods; - }); - - PsiMethod[] asJavaMethods = methods - .stream() - .map(m -> ObjectUtils.tryCast(Objects.requireNonNull(UastContextKt.toUElement(m)).getJavaPsi(), PsiMethod.class)) - .filter(Objects::nonNull) - .toArray(PsiMethod.ARRAY_FACTORY::create); - FeatureUsageTracker.getInstance().triggerFeatureUsed("test.discovery.selected.changes"); - ShowDiscoveredTestsAction.showDiscoveredTests(project, e.getDataContext(), "Selected Changes", asJavaMethods); - } -} diff --git a/resources/src/META-INF/JavaIdePlugin.xml b/resources/src/META-INF/JavaIdePlugin.xml index 84869b3ee2df..898d58c8b898 100644 --- a/resources/src/META-INF/JavaIdePlugin.xml +++ b/resources/src/META-INF/JavaIdePlugin.xml @@ -403,8 +403,6 @@ - - From 15345b87f623dee89c10b0cbe2908416d288a53a Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Fri, 23 Mar 2018 16:12:19 +0300 Subject: [PATCH 6/9] allow selection in unfocused component --- .../codeInsight/documentation/DocumentationComponent.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java index 64ce16e561fe..0a688dcc14ec 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java @@ -328,6 +328,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr // Note: Making the caret visible is merely for convenience myEditorPane.getCaret().setVisible(true); } + myEditorPane.getCaret().setSelectionVisible(true); myEditorPane.setBackground(EditorColorsUtil.getGlobalOrDefaultColor(COLOR_KEY)); HTMLEditorKit editorKit = new UIUtil.JBHtmlEditorKit(true) { @Override From 1c3b5e2b74b398d2b9d53167767d1c58fe78d412 Mon Sep 17 00:00:00 2001 From: Sergey Karashevich Date: Fri, 23 Mar 2018 16:08:04 +0300 Subject: [PATCH 7/9] [gui-test] fix test naming --- .../tests/community/focus/KeyMapSettingsTestFocusTest.kt | 2 +- .../tests/community/focus/SearchEverywhereFocusTest.kt | 2 +- .../testGuiFramework/tests/community/focus/TypeAheadTest.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/KeyMapSettingsTestFocusTest.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/KeyMapSettingsTestFocusTest.kt index b694b165d5fa..2feed1f85a72 100644 --- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/KeyMapSettingsTestFocusTest.kt +++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/KeyMapSettingsTestFocusTest.kt @@ -19,7 +19,7 @@ import java.awt.Container class KeyMapSettingsTestFocusTest : GuiTestCase() { @Test - fun testInlineVariableFocus() { + fun testKeyMapSettingsTestFocus() { CommunityProjectCreator.createCommandLineProject() Pause.pause(1000) ideFrame { diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/SearchEverywhereFocusTest.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/SearchEverywhereFocusTest.kt index 5db741b8b614..e171d4b23b06 100644 --- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/SearchEverywhereFocusTest.kt +++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/SearchEverywhereFocusTest.kt @@ -23,7 +23,7 @@ class SearchEverywhereFocusTest : GuiTestCase() { private val searchWindowLabelText = "Search Everywhere:" @Test - fun testGoToClassFocus() { + fun testSearchEverywhereFocus() { CommunityProjectCreator.createCommandLineProject() Pause.pause(1000) ideFrame { diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/TypeAheadTest.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/TypeAheadTest.kt index 64de40220533..fd9e02d8403d 100644 --- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/TypeAheadTest.kt +++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/TypeAheadTest.kt @@ -14,7 +14,7 @@ import org.junit.Test class TypeAheadTest : GuiTestCase() { @Test - fun testProjectCreate() { + fun testTypeAhead() { CommunityProjectCreator.createCommandLineProject("type-ahead-problem") ideFrame { waitForBackgroundTasksToFinish() From 8510a628b52706ce344807885604591d91b0ba1c Mon Sep 17 00:00:00 2001 From: "Vladislav.Soroka" Date: Fri, 23 Mar 2018 16:17:10 +0300 Subject: [PATCH 8/9] IDEA-188265 Gradle options menu broken --- .../AbstractExternalProjectSettingsControl.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectSettingsControl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectSettingsControl.java index 5e362523a433..0e4ec51d3c55 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectSettingsControl.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectSettingsControl.java @@ -56,6 +56,9 @@ public abstract class AbstractExternalProjectSettingsControl Date: Fri, 23 Mar 2018 16:22:52 +0300 Subject: [PATCH 9/9] [gui-test] fix assertion order of actual and expected texts --- .../tests/community/focus/GoToClassFocusTest.kt | 2 +- .../tests/community/focus/GoToClassTwiceFocusTest.kt | 2 +- .../tests/community/focus/SearchEverywhereFocusTest.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/GoToClassFocusTest.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/GoToClassFocusTest.kt index 6bc6149aaff1..62b4b57eae7a 100644 --- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/GoToClassFocusTest.kt +++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/GoToClassFocusTest.kt @@ -86,7 +86,7 @@ class GoToClassFocusTest : GuiTestCase() { } with(guiTestCase) { val textfield = textfield("", searchWindow, guiTestCase.defaultTimeout) - Assert.assertEquals(textfield.target().text, typedString) + Assert.assertEquals(typedString, textfield.target().text) } } diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/GoToClassTwiceFocusTest.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/GoToClassTwiceFocusTest.kt index dc9530492d32..627a1d220a5b 100644 --- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/GoToClassTwiceFocusTest.kt +++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/GoToClassTwiceFocusTest.kt @@ -91,7 +91,7 @@ class GoToClassTwiceFocusTest : GuiTestCase() { } with(guiTestCase) { val textfield = textfield("", searchWindow, guiTestCase.defaultTimeout) - Assert.assertEquals(textfield.target().text, typedString) + Assert.assertEquals(typedString, textfield.target().text) } } diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/SearchEverywhereFocusTest.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/SearchEverywhereFocusTest.kt index e171d4b23b06..10434c9327a5 100644 --- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/SearchEverywhereFocusTest.kt +++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/SearchEverywhereFocusTest.kt @@ -55,7 +55,7 @@ class SearchEverywhereFocusTest : GuiTestCase() { private fun GuiTestCase.checkTextInSearchWindow(searchWindow: Container, expectedText: String) { with(this) { val textfield = textfield("", searchWindow, this.defaultTimeout) - Assert.assertEquals(textfield.target().text, expectedText) + Assert.assertEquals(expectedText, textfield.target().text) } }