From b35b43c0b60bbe76e91abd64488ecac278492389 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Fri, 10 Feb 2017 18:02:14 +0300 Subject: [PATCH 01/96] allow to run stuff before selecting --- .../impl/AbstractProjectViewPSIPane.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java index b268f54425d3..7db83f57afb1 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -255,14 +255,18 @@ public abstract class AbstractProjectViewPSIPane extends AbstractProjectViewPane @NotNull public ActionCallback selectCB(Object element, VirtualFile file, boolean requestFocus) { if (file != null) { - BaseProjectTreeBuilder builder = (BaseProjectTreeBuilder)getTreeBuilder(); - // actually, getInitialized().doWhenDone() should be called by builder internally - // this will be done in 2017 - return builder.getInitialized().doWhenDone(() -> builder.select(element, file, requestFocus)); + beforeSelect().doWhenDone(() -> ((BaseProjectTreeBuilder)getTreeBuilder()).select(element, file, requestFocus)); } return ActionCallback.DONE; } + @NotNull + public ActionCallback beforeSelect() { + // actually, getInitialized().doWhenDone() should be called by builder internally + // this will be done in 2017 + return getTreeBuilder().getInitialized(); + } + @NotNull protected BaseProjectTreeBuilder createBuilder(DefaultTreeModel treeModel) { return new ProjectTreeBuilder(myProject, myTree, treeModel, null, (ProjectAbstractTreeStructureBase)myTreeStructure) { From 64db04365182c267b87908a026fa75bd9a4ee649 Mon Sep 17 00:00:00 2001 From: "Anna.Kozlova" Date: Tue, 14 Feb 2017 11:05:26 +0100 Subject: [PATCH 02/96] smart pointers to ensure valid files during long move with language pushers which can influence dialect inside a file and thus the file view provider EA-93157 - PIEAE: PsiUtilCore.ensureValid --- .../copy/CopyFilesOrDirectoriesHandler.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesHandler.java b/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesHandler.java index ac914491fcc3..df04bc35708a 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesHandler.java +++ b/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesHandler.java @@ -44,6 +44,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; +import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -136,7 +137,10 @@ public class CopyFilesOrDirectoriesHandler extends CopyHandlerDelegateBase { return; } - copyImpl(elements, newName, targetDirectory, false, openInEditor); + SmartPointerManager manager = SmartPointerManager.getInstance(project); + copyImpl(Arrays.stream(elements) + .map(el -> manager.createSmartPsiElementPointer(el)) + .toArray(SmartPsiElementPointer[]::new), newName, targetDirectory, false, openInEditor); } } @@ -160,7 +164,10 @@ public class CopyFilesOrDirectoriesHandler extends CopyHandlerDelegateBase { CopyFilesOrDirectoriesDialog dialog = new CopyFilesOrDirectoriesDialog(elements, null, element.getProject(), true); if (dialog.showAndGet()) { String newName = dialog.getNewName(); - copyImpl(elements, newName, targetDirectory, true, true); + SmartPointerManager manager = SmartPointerManager.getInstance(element.getProject()); + copyImpl(Arrays.stream(elements) + .map(el -> manager.createSmartPsiElementPointer(el)) + .toArray(SmartPsiElementPointer[]::new), newName, targetDirectory, true, true); } } @@ -203,7 +210,7 @@ public class CopyFilesOrDirectoriesHandler extends CopyHandlerDelegateBase { * @param targetDirectory * @param openInEditor */ - private static void copyImpl(@NotNull final PsiElement[] elements, + private static void copyImpl(@NotNull final SmartPsiElementPointer[] elements, @Nullable final String newName, @NotNull final PsiDirectory targetDirectory, final boolean doClone, @@ -225,8 +232,10 @@ public class CopyFilesOrDirectoriesHandler extends CopyHandlerDelegateBase { try { PsiFile firstFile = null; final int[] choice = elements.length > 1 || elements[0] instanceof PsiDirectory ? new int[]{-1} : null; - for (PsiElement element : elements) { - PsiFile f = copyToDirectory((PsiFileSystemItem)element, newName, targetDirectory, choice, title); + for (SmartPsiElementPointer element : elements) { + PsiElement psiElement = element.getElement(); + if (psiElement == null) continue; + PsiFile f = copyToDirectory((PsiFileSystemItem)psiElement, newName, targetDirectory, choice, title); if (firstFile == null) { firstFile = f; } From 762545e08078d822fd8769cfacc17672ade899b3 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 14 Feb 2017 11:13:13 +0100 Subject: [PATCH 03/96] fix AA painting in Dimension component of UI Inspector --- .../intellij/internal/inspector/UiInspectorAction.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/internal/inspector/UiInspectorAction.java b/platform/platform-impl/src/com/intellij/internal/inspector/UiInspectorAction.java index a75588f1f303..efbe49b70559 100644 --- a/platform/platform-impl/src/com/intellij/internal/inspector/UiInspectorAction.java +++ b/platform/platform-impl/src/com/intellij/internal/inspector/UiInspectorAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ */ package com.intellij.internal.inspector; +import com.intellij.ide.ui.AntialiasingType; +import com.intellij.ide.ui.UISettings; import com.intellij.notification.Notification; import com.intellij.notification.NotificationType; import com.intellij.notification.Notifications; @@ -24,6 +26,7 @@ import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.roots.ui.configuration.actions.IconWithTextAction; import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.ui.StripeTable; import com.intellij.openapi.util.Disposer; @@ -563,6 +566,7 @@ public class UiInspectorAction extends ToggleAction implements DumbAware { @Override protected void paintComponent(final Graphics g) { Graphics2D g2d = (Graphics2D)g; + GraphicsConfig config = new GraphicsConfig(g).setAntialiasing(UISettings.getShadowInstance().getIdeAAType() != AntialiasingType.OFF); Rectangle bounds = getBounds(); g2d.setColor(getBackground()); @@ -599,6 +603,8 @@ public class UiInspectorAction extends ToggleAction implements DumbAware { g2d.drawRect(innerX - boxSize * 2, innerY - boxSize * 2, innerWidth + boxSize * 4, innerHeight + boxSize * 4); drawInsets(g2d, fm, "insets", myInsets, boxSize * 2, fontHeight, innerX, innerY, innerWidth, innerHeight); + + config.restore(); } private static void drawInsets(Graphics2D g2d, FontMetrics fm, String name, Insets insets, int offset, int fontHeight, int innerX, int innerY, int innerWidth, int innerHeight) { From 3742d424a1b81e00ad6b635153e14c3075615e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Tue, 14 Feb 2017 11:32:43 +0100 Subject: [PATCH 04/96] [plugin manager] PluginManager.handleComponentError log known plugin ID --- .../src/com/intellij/ide/plugins/PluginManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java index 64d0db639e2d..2df72babd5a9 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java @@ -246,7 +246,7 @@ public class PluginManager extends PluginManagerCore { } if (pluginId != null && !CORE_PLUGIN_ID.equals(pluginId.getIdString())) { - throw new StartupAbortedException(new PluginException(t, pluginId)); + throw new StartupAbortedException("Fatal error initializing plugin " + pluginId.getIdString(), new PluginException(t, pluginId)); } else { throw new StartupAbortedException("Fatal error initializing '" + componentClassName + "'", t); From 41cb76c77fe55f55e5804528755fe0281a185ced Mon Sep 17 00:00:00 2001 From: "Vladislav.Soroka" Date: Tue, 14 Feb 2017 13:56:18 +0300 Subject: [PATCH 05/96] maven: invoke super.tearDown() in finally block --- .../jetbrains/idea/maven/indices/MavenIndicesTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTest.java index 4953e74fc805..5cf8036d3df7 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTest.java @@ -53,8 +53,12 @@ public class MavenIndicesTest extends MavenIndicesTestCase { @Override protected void tearDown() throws Exception { - shutdownIndices(); - super.tearDown(); + try { + shutdownIndices(); + } + finally { + super.tearDown(); + } } private void initIndices() throws Exception { From 4247eeb3c017a1a60801d01d31aaaad637f77aeb Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 14 Feb 2017 11:56:43 +0100 Subject: [PATCH 06/96] [tests] checks mapping in .class mirror building test --- .../testSrc/com/intellij/psi/ClsMirrorBuildingTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java index 58259fb6a967..0abd8a4279bc 100644 --- a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -206,6 +206,8 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase { } assertEquals(expected, ClsFileImpl.decompile(file).toString()); + + ((ClsFileImpl)getPsiManager().findFile(file)).getMirror(); } private static boolean isInner(String name) throws IOException { From 1497fc8f74293b662a17624c387862ed6c3b3961 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 14 Feb 2017 11:57:51 +0100 Subject: [PATCH 07/96] [java] new module-info PSI - 'requires' statements may own a modifier list - 'transitive' modifier --- .../src/com/intellij/psi/PsiModifier.java | 5 +++-- .../intellij/psi/PsiRequiresStatement.java | 4 ++-- .../psi/impl/cache/ModifierFlags.java | 3 +++ .../psi/impl/compiled/ClsJavaModuleImpl.java | 11 ++++++----- .../compiled/ClsRequiresStatementImpl.java | 19 ++++++++++++++++++- .../psi/impl/source/PsiModifierListImpl.java | 1 + .../impl/source/PsiRequiresStatementImpl.java | 13 ++++++++++++- .../psi/impl/source/tree/ElementType.java | 6 ++++-- 8 files changed, 49 insertions(+), 13 deletions(-) diff --git a/java/java-psi-api/src/com/intellij/psi/PsiModifier.java b/java/java-psi-api/src/com/intellij/psi/PsiModifier.java index e442927406f1..629d35d116c6 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiModifier.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiModifier.java @@ -35,13 +35,14 @@ public interface PsiModifier { String VOLATILE = "volatile"; String DEFAULT = "default"; String OPEN = "open"; + String TRANSITIVE = "transitive"; String[] MODIFIERS = { - PUBLIC, PROTECTED, PRIVATE, STATIC, ABSTRACT, FINAL, NATIVE, SYNCHRONIZED, STRICTFP, TRANSIENT, VOLATILE, DEFAULT, OPEN + PUBLIC, PROTECTED, PRIVATE, STATIC, ABSTRACT, FINAL, NATIVE, SYNCHRONIZED, STRICTFP, TRANSIENT, VOLATILE, DEFAULT, OPEN, TRANSITIVE }; @MagicConstant(stringValues = { - PUBLIC, PROTECTED, PRIVATE, STATIC, ABSTRACT, FINAL, NATIVE, SYNCHRONIZED, STRICTFP, TRANSIENT, VOLATILE, DEFAULT, OPEN, PACKAGE_LOCAL + PUBLIC, PROTECTED, PRIVATE, STATIC, ABSTRACT, FINAL, NATIVE, SYNCHRONIZED, STRICTFP, TRANSIENT, VOLATILE, DEFAULT, OPEN, TRANSITIVE, PACKAGE_LOCAL }) @interface ModifierConstant { } } \ No newline at end of file diff --git a/java/java-psi-api/src/com/intellij/psi/PsiRequiresStatement.java b/java/java-psi-api/src/com/intellij/psi/PsiRequiresStatement.java index 41b703090e24..d58edc61ad70 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiRequiresStatement.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiRequiresStatement.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable; * * @since 2016.3 */ -public interface PsiRequiresStatement extends PsiElement { +public interface PsiRequiresStatement extends PsiModifierListOwner { PsiRequiresStatement[] EMPTY_ARRAY = new PsiRequiresStatement[0]; @Nullable PsiJavaModuleReferenceElement getReferenceElement(); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/cache/ModifierFlags.java b/java/java-psi-impl/src/com/intellij/psi/impl/cache/ModifierFlags.java index 159f4aa17424..2c225b41c2a6 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/cache/ModifierFlags.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/cache/ModifierFlags.java @@ -42,6 +42,7 @@ public final class ModifierFlags { public static final int STRICTFP_MASK = 0x0800; public static final int PACKAGE_LOCAL_MASK = 0x1000; public static final int OPEN_MASK = 0x2000; + public static final int TRANSITIVE_MASK = 0x4000; public static final TObjectIntHashMap NAME_TO_MODIFIER_FLAG_MAP = new TObjectIntHashMap(); public static final TIntObjectHashMap MODIFIER_FLAG_TO_NAME_MAP = new TIntObjectHashMap(); @@ -61,6 +62,7 @@ public final class ModifierFlags { NAME_TO_MODIFIER_FLAG_MAP.put(PsiModifier.STRICTFP, STRICTFP_MASK); NAME_TO_MODIFIER_FLAG_MAP.put(PsiModifier.PACKAGE_LOCAL, PACKAGE_LOCAL_MASK); NAME_TO_MODIFIER_FLAG_MAP.put(PsiModifier.OPEN, OPEN_MASK); + NAME_TO_MODIFIER_FLAG_MAP.put(PsiModifier.TRANSITIVE, TRANSITIVE_MASK); for (Object name : NAME_TO_MODIFIER_FLAG_MAP.keys()) { MODIFIER_FLAG_TO_NAME_MAP.put(NAME_TO_MODIFIER_FLAG_MAP.get((String)name), (String)name); @@ -79,6 +81,7 @@ public final class ModifierFlags { KEYWORD_TO_MODIFIER_FLAG_MAP.put(JavaTokenType.ABSTRACT_KEYWORD, ABSTRACT_MASK); KEYWORD_TO_MODIFIER_FLAG_MAP.put(JavaTokenType.STRICTFP_KEYWORD, STRICTFP_MASK); KEYWORD_TO_MODIFIER_FLAG_MAP.put(JavaTokenType.OPEN_KEYWORD, OPEN_MASK); + KEYWORD_TO_MODIFIER_FLAG_MAP.put(JavaTokenType.TRANSITIVE_KEYWORD, TRANSITIVE_MASK); } public static boolean hasModifierProperty(String name, int mask) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaModuleImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaModuleImpl.java index 3971d929bfbe..cd521cf28ab2 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaModuleImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaModuleImpl.java @@ -34,6 +34,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Collections; import static com.intellij.util.containers.ContainerUtil.newArrayList; +import static java.util.Arrays.asList; public class ClsJavaModuleImpl extends ClsRepositoryPsiElement implements PsiJavaModule { private PsiJavaModuleReferenceElement myReference; @@ -93,16 +94,16 @@ public class ClsJavaModuleImpl extends ClsRepositoryPsiElementtreeToPsiNotNull(element).getModifierList()); + } + + @Override + public PsiModifierList getModifierList() { + StubElement childStub = getStub().findChildStubByType(JavaStubElementTypes.MODIFIER_LIST); + return childStub != null ? childStub.getPsi() : null; + } + + @Override + public boolean hasModifierProperty(@NotNull String name) { + PsiModifierList modifierList = getModifierList(); + return modifierList != null && modifierList.hasModifierProperty(name); } @Override diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiModifierListImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiModifierListImpl.java index e819008d0010..e7da8743175e 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiModifierListImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiModifierListImpl.java @@ -61,6 +61,7 @@ public class PsiModifierListImpl extends JavaStubPsiElement NAME_TO_KEYWORD_TYPE_MAP.put(VOLATILE, JavaTokenType.VOLATILE_KEYWORD); NAME_TO_KEYWORD_TYPE_MAP.put(DEFAULT, JavaTokenType.DEFAULT_KEYWORD); NAME_TO_KEYWORD_TYPE_MAP.put(OPEN, JavaTokenType.OPEN_KEYWORD); + NAME_TO_KEYWORD_TYPE_MAP.put(TRANSITIVE, JavaTokenType.TRANSITIVE_KEYWORD); KEYWORD_TYPE_TO_NAME_MAP = ContainerUtil.newTroveMap(); for (String name : NAME_TO_KEYWORD_TYPE_MAP.keySet()) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiRequiresStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiRequiresStatementImpl.java index 5e4f6c4c9780..0a1d04aac566 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiRequiresStatementImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiRequiresStatementImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,6 +67,17 @@ public class PsiRequiresStatementImpl extends JavaStubPsiElement Date: Mon, 13 Feb 2017 15:57:21 +0300 Subject: [PATCH 08/96] read action to fix EA-96790 - assert: SharedImplUtil.findFileElement --- .../search/JavaDirectInheritorsSearcher.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java index 7b3ddd164e56..a1fafd56f62a 100644 --- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java +++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java @@ -62,10 +62,9 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor { ProgressManager.checkCanceled(); if (psiClass.isInterface()) { @@ -76,13 +75,17 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor parameters.getScope().intersectWith(info.getDirtyScope())); + useScope = ReadAction.compute(() -> baseClass.getUseScope().intersectWith(info.getDirtyScope())); } PsiClass[] cache = getOrCalculateDirectSubClasses(project, baseClass, useScope); From 306089db26c97ab5ac411394b1f268351bd37424 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 13 Feb 2017 17:12:35 +0300 Subject: [PATCH 09/96] use modality "any" to followup IDEA-CR-18167 --- .../src/com/intellij/openapi/editor/impl/EditorImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index b0e982271d5a..b6a0f60f50fd 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -1525,7 +1525,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi finally { updatingSize = false; } - }, __->isDisposed()); + }, ModalityState.any(), __->isDisposed()); } } From 7bb4088e1897c103fddcebf9606f801186903e04 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 13 Feb 2017 20:08:39 +0300 Subject: [PATCH 10/96] added tests for detect files inside .jar --- .../intellij/openapi/util/io/IoTestUtil.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/platform/util/testSrc/com/intellij/openapi/util/io/IoTestUtil.java b/platform/util/testSrc/com/intellij/openapi/util/io/IoTestUtil.java index 112caa1cb196..50d0e1d47661 100644 --- a/platform/util/testSrc/com/intellij/openapi/util/io/IoTestUtil.java +++ b/platform/util/testSrc/com/intellij/openapi/util/io/IoTestUtil.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.util.io; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.CharsetToolkit; @@ -26,6 +27,7 @@ import org.jetbrains.annotations.Nullable; import java.io.*; import java.nio.file.FileSystems; import java.nio.file.Files; +import java.util.Collection; import java.util.Locale; import java.util.Set; import java.util.jar.JarFile; @@ -201,11 +203,28 @@ public class IoTestUtil { } @NotNull - public static File createTestJar(@NotNull File jarFile, @NotNull String... data) { + public static File createTestJar(@NotNull File jarFile, @NotNull String... namesAndTexts) { try (ZipOutputStream stream = new ZipOutputStream(new FileOutputStream(jarFile))) { - for (int i = 0; i < data.length; i += 2) { - stream.putNextEntry(new ZipEntry(data[i])); - stream.write(data[i + 1].getBytes(CharsetToolkit.UTF8_CHARSET)); + for (int i = 0; i < namesAndTexts.length; i += 2) { + stream.putNextEntry(new ZipEntry(namesAndTexts[i])); + stream.write(namesAndTexts[i + 1].getBytes(CharsetToolkit.UTF8_CHARSET)); + stream.closeEntry(); + } + return jarFile; + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + @NotNull + public static File createTestJar(@NotNull File jarFile, @NotNull Collection> namesAndContents) { + try (ZipOutputStream stream = new ZipOutputStream(new FileOutputStream(jarFile))) { + for (Pair p : namesAndContents) { + String name = p.first; + byte[] content = p.second; + stream.putNextEntry(new ZipEntry(name)); + stream.write(content); stream.closeEntry(); } return jarFile; From 53dec997ed13343693cb3ad75a1dabeac0e90704 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 13 Feb 2017 20:41:59 +0300 Subject: [PATCH 11/96] check the project is disposed under the lock. When the project closes the queue is cleared under that same lock. --- .../com/intellij/psi/impl/DocumentCommitThread.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java index 7b219916d8b0..6d109c51695f 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java +++ b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java @@ -164,14 +164,14 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi PsiDocumentManager.getInstance(project).getLastCommittedText(document)); } - @NotNull - private CommitTask doQueue(@NotNull Project project, + private void doQueue(@NotNull Project project, @NotNull Document document, @NotNull List> oldFileNodes, @NotNull Object reason, @NotNull ModalityState currentModalityState, @NotNull CharSequence lastCommittedText) { synchronized (lock) { + if (!project.isInitialized()) return; // check the project is disposed under lock. CommitTask newTask = createNewTaskAndCancelSimilar(project, document, oldFileNodes, reason, currentModalityState, lastCommittedText); @@ -179,7 +179,6 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi log(project, "Queued", newTask, reason); wakeUpQueue(); - return newTask; } } @@ -556,10 +555,8 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi if (task.reason.equals(SYNC_COMMIT_REASON)) { throw new PsiInvalidElementAccessException(file, "File " + file + " invalidated during sync commit"); } - else { - commitAsynchronously(project, document, "File " + file + " invalidated during background commit; task: "+task, - task.myCreationModalityState); - } + commitAsynchronously(project, document, "File " + file + " invalidated during background commit; task: "+task, + task.myCreationModalityState); } } } From d62cbff1056b48931445e99d3e30c6d9bf8aed40 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 14 Feb 2017 14:15:06 +0300 Subject: [PATCH 12/96] cleanup --- .../util/AbstractProgressIndicatorExBase.java | 107 +++--------------- .../intellij/testFramework/VfsTestUtil.java | 6 +- .../intellij/openapi/vfs/CharsetToolkit.java | 2 +- 3 files changed, 21 insertions(+), 94 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorExBase.java b/platform/platform-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorExBase.java index 2c839151d572..24c8f58efbf5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorExBase.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorExBase.java @@ -30,55 +30,7 @@ import java.util.List; public class AbstractProgressIndicatorExBase extends AbstractProgressIndicatorBase implements ProgressIndicatorEx { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.progress.util.ProgressIndicatorBase"); - private static final IndicatorAction CHECK_CANCELED_ACTION = new IndicatorAction() { - @Override - public void execute(@NotNull ProgressIndicatorEx each) { - each.checkCanceled(); - } - }; - private static final IndicatorAction STOP_ACTION = new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.stop(); - } - }; - private static final IndicatorAction START_ACTION = new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.start(); - } - }; - private static final IndicatorAction CANCEL_ACTION = new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.cancel(); - } - }; - private static final IndicatorAction PUSH_ACTION = new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.pushState(); - } - }; - private static final IndicatorAction POP_ACTION = new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.popState(); - } - }; - private static final IndicatorAction STARTNC_ACTION = new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.startNonCancelableSection(); - } - }; - private static final IndicatorAction FINISHNC_ACTION = new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.finishNonCancelableSection(); - } - }; - protected final boolean myReusable; + private final boolean myReusable; private volatile boolean myModalityEntered; private volatile List myStateDelegates; private volatile WeakList myFinished; @@ -97,7 +49,7 @@ public class AbstractProgressIndicatorExBase extends AbstractProgressIndicatorBa public void start() { synchronized (this) { super.start(); - delegateRunningChange(START_ACTION); + delegateRunningChange(ProgressIndicator::start); } myWasStarted = true; @@ -127,7 +79,7 @@ public class AbstractProgressIndicatorExBase extends AbstractProgressIndicatorBa @Override public void stop() { super.stop(); - delegateRunningChange(STOP_ACTION); + delegateRunningChange(ProgressIndicator::stop); exitModality(); } @@ -147,12 +99,7 @@ public class AbstractProgressIndicatorExBase extends AbstractProgressIndicatorBa @Override public void cancel() { super.cancel(); - delegateRunningChange(CANCEL_ACTION); - } - - @Override - public boolean isCanceled() { - return super.isCanceled(); + delegateRunningChange(ProgressIndicator::cancel); } @Override @@ -168,12 +115,7 @@ public class AbstractProgressIndicatorExBase extends AbstractProgressIndicatorBa } if (!finished.addIfAbsent(task)) return; - delegateRunningChange(new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.finish(task); - } - }); + delegateRunningChange(each -> each.finish(task)); } @Override @@ -198,71 +140,56 @@ public class AbstractProgressIndicatorExBase extends AbstractProgressIndicatorBa public final void checkCanceled() { super.checkCanceled(); - delegate(CHECK_CANCELED_ACTION); + delegate(ProgressIndicator::checkCanceled); } @Override public void setText(final String text) { super.setText(text); - delegateProgressChange(new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.setText(text); - } - }); + delegateProgressChange(each -> each.setText(text)); } @Override public void setText2(final String text) { super.setText2(text); - delegateProgressChange(new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.setText2(text); - } - }); + delegateProgressChange(each -> each.setText2(text)); } @Override public void setFraction(final double fraction) { super.setFraction(fraction); - delegateProgressChange(new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.setFraction(fraction); - } - }); + delegateProgressChange(each -> each.setFraction(fraction)); } @Override public synchronized void pushState() { super.pushState(); - delegateProgressChange(PUSH_ACTION); + delegateProgressChange(ProgressIndicator::pushState); } @Override public synchronized void popState() { super.popState(); - delegateProgressChange(POP_ACTION); + delegateProgressChange(ProgressIndicator::popState); } @Override public void startNonCancelableSection() { super.startNonCancelableSection(); - delegateProgressChange(STARTNC_ACTION); + delegateProgressChange(ProgressIndicator::startNonCancelableSection); } @Override public void finishNonCancelableSection() { super.finishNonCancelableSection(); - delegateProgressChange(FINISHNC_ACTION); + delegateProgressChange(ProgressIndicator::finishNonCancelableSection); } @Override @@ -274,12 +201,7 @@ public class AbstractProgressIndicatorExBase extends AbstractProgressIndicatorBa public void setIndeterminate(final boolean indeterminate) { super.setIndeterminate(indeterminate); - delegateProgressChange(new IndicatorAction() { - @Override - public void execute(@NotNull final ProgressIndicatorEx each) { - each.setIndeterminate(indeterminate); - } - }); + delegateProgressChange(each -> each.setIndeterminate(indeterminate)); } @Override @@ -342,6 +264,7 @@ public class AbstractProgressIndicatorExBase extends AbstractProgressIndicatorBa return myWasStarted; } + @FunctionalInterface protected interface IndicatorAction { void execute(@NotNull ProgressIndicatorEx each); } diff --git a/platform/testFramework/src/com/intellij/testFramework/VfsTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/VfsTestUtil.java index 4bd39aadd7b3..0b8a698bc92b 100644 --- a/platform/testFramework/src/com/intellij/testFramework/VfsTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/VfsTestUtil.java @@ -46,18 +46,22 @@ public class VfsTestUtil { private VfsTestUtil() { } + @NotNull public static VirtualFile createFile(@NotNull VirtualFile root, @NotNull String relativePath) { return createFile(root, relativePath, ""); } + @NotNull public static VirtualFile createFile(@NotNull VirtualFile root, @NotNull String relativePath, @NotNull String text) { return createFileOrDir(root, relativePath, text, false); } + @NotNull public static VirtualFile createDir(@NotNull VirtualFile root, @NotNull String relativePath) { return createFileOrDir(root, relativePath, "", true); } + @NotNull private static VirtualFile createFileOrDir(VirtualFile root, String relativePath, String text, boolean dir) { try { return WriteAction.compute(() -> { @@ -107,7 +111,7 @@ public class VfsTestUtil { }); } - public static void overwriteTestData(String filePath, String actual) { + public static void overwriteTestData(@NotNull String filePath, @NotNull String actual) { try { FileUtil.writeToFile(new File(filePath), actual); } diff --git a/platform/util/src/com/intellij/openapi/vfs/CharsetToolkit.java b/platform/util/src/com/intellij/openapi/vfs/CharsetToolkit.java index 0797eb94bef5..e0bd880c61c2 100644 --- a/platform/util/src/com/intellij/openapi/vfs/CharsetToolkit.java +++ b/platform/util/src/com/intellij/openapi/vfs/CharsetToolkit.java @@ -88,7 +88,7 @@ public class CharsetToolkit { private final byte[] buffer; @NotNull private final Charset defaultCharset; - private boolean enforce8Bit = false; + private boolean enforce8Bit; public static final byte[] UTF8_BOM = {0xffffffef, 0xffffffbb, 0xffffffbf}; public static final byte[] UTF16LE_BOM = {-1, -2, }; From b88ce071fea4548e12e77b00f878b79dda4eb101 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 14 Feb 2017 14:15:26 +0300 Subject: [PATCH 13/96] detect encoding of large files inside .jar --- .../openapi/fileTypes/impl/FileTypeManagerImpl.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java index 97cc7197ae2c..6624e7004b4a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java @@ -756,11 +756,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent } private static boolean isDetectable(@NotNull final VirtualFile file) { - if (file.isDirectory() || !file.isValid() || file.is(VFileProperty.SPECIAL)) { - return false; - } - long length = file.getLength(); - if (length == 0 || length >= FileUtilRt.LARGE_FOR_CONTENT_LOADING) { + if (file.isDirectory() || !file.isValid() || file.is(VFileProperty.SPECIAL) || file.getLength() == 0) { // for empty file there is still hope its type will change return false; } From ca820a65341d4621e897cbbef46c575e12376408 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Tue, 14 Feb 2017 14:41:10 +0300 Subject: [PATCH 14/96] PY-3032 Surround action can't be invoked when first line of selection is a comment --- .../python/refactoring/PyRefactoringUtil.java | 35 +++++++++++++++---- .../testData/surround/SurroundCommentAtEnd.py | 2 ++ .../surround/SurroundCommentAtEnd_after.py | 3 ++ .../surround/SurroundCommentAtStart.py | 2 ++ .../surround/SurroundCommentAtStart_after.py | 3 ++ python/testData/surround/SurroundNewline.py | 3 ++ .../surround/SurroundNewline_after.py | 4 +++ .../jetbrains/python/PySurroundWithTest.java | 12 +++++++ 8 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 python/testData/surround/SurroundCommentAtEnd.py create mode 100644 python/testData/surround/SurroundCommentAtEnd_after.py create mode 100644 python/testData/surround/SurroundCommentAtStart.py create mode 100644 python/testData/surround/SurroundCommentAtStart_after.py create mode 100644 python/testData/surround/SurroundNewline.py create mode 100644 python/testData/surround/SurroundNewline_after.py diff --git a/python/src/com/jetbrains/python/refactoring/PyRefactoringUtil.java b/python/src/com/jetbrains/python/refactoring/PyRefactoringUtil.java index 1ecacabd1842..433305bfcde8 100644 --- a/python/src/com/jetbrains/python/refactoring/PyRefactoringUtil.java +++ b/python/src/com/jetbrains/python/refactoring/PyRefactoringUtil.java @@ -25,7 +25,6 @@ import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtilCore; import com.intellij.usageView.UsageInfo; -import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashSet; import com.jetbrains.python.PyNames; @@ -204,16 +203,35 @@ public class PyRefactoringUtil { @NotNull public static PsiElement[] findStatementsInRange(@NotNull final PsiFile file, int startOffset, int endOffset) { + ArrayList array = new ArrayList<>(); + PsiElement element1 = file.findElementAt(startOffset); PsiElement element2 = file.findElementAt(endOffset - 1); + PsiElement endComment = null; + + boolean startsWithWhitespace = false; + boolean endsWithWhitespace = false; if (element1 instanceof PsiWhiteSpace) { startOffset = element1.getTextRange().getEndOffset(); element1 = file.findElementAt(startOffset); + startsWithWhitespace = true; } if (element2 instanceof PsiWhiteSpace) { - endOffset = element2.getTextRange().getStartOffset(); - element2 = file.findElementAt(endOffset - 1); + element2 = PsiTreeUtil.skipSiblingsBackward(element2, PsiWhiteSpace.class); + endsWithWhitespace = true; } + while (element2 instanceof PsiComment) { + endComment = element2; + element2 = PsiTreeUtil.skipSiblingsBackward(element2, PsiWhiteSpace.class, PsiComment.class); + endsWithWhitespace = true; + } + + while (element1 instanceof PsiComment) { + array.add(element1); + element1 = PsiTreeUtil.skipSiblingsForward(element1, PsiWhiteSpace.class); + startsWithWhitespace = true; + } + if (element1 == null || element2 == null) { return PsiElement.EMPTY_ARRAY; } @@ -242,7 +260,7 @@ public class PyRefactoringUtil { element1 = element1.getParent(); } } - if (startOffset != element1.getTextRange().getStartOffset()) { + if (startOffset != element1.getTextRange().getStartOffset() && !startsWithWhitespace) { return PsiElement.EMPTY_ARRAY; } @@ -251,7 +269,7 @@ public class PyRefactoringUtil { element2 = element2.getParent(); } } - if (endOffset != element2.getTextRange().getEndOffset()) { + if (endOffset != element2.getTextRange().getEndOffset() && !endsWithWhitespace) { return PsiElement.EMPTY_ARRAY; } @@ -263,7 +281,7 @@ public class PyRefactoringUtil { } PsiElement[] children = parent.getChildren(); - ArrayList array = new ArrayList<>(); + boolean flag = false; for (PsiElement child : children) { if (child.equals(element1)) { @@ -277,6 +295,11 @@ public class PyRefactoringUtil { } } + while (endComment instanceof PsiComment) { + array.add(endComment); + endComment = PsiTreeUtil.skipSiblingsForward(endComment, PsiWhiteSpace.class); + } + for (PsiElement element : array) { if (!(element instanceof PyStatement || element instanceof PsiWhiteSpace || element instanceof PsiComment)) { return PsiElement.EMPTY_ARRAY; diff --git a/python/testData/surround/SurroundCommentAtEnd.py b/python/testData/surround/SurroundCommentAtEnd.py new file mode 100644 index 000000000000..ba1cd374efce --- /dev/null +++ b/python/testData/surround/SurroundCommentAtEnd.py @@ -0,0 +1,2 @@ +a = 1 +#comment line \ No newline at end of file diff --git a/python/testData/surround/SurroundCommentAtEnd_after.py b/python/testData/surround/SurroundCommentAtEnd_after.py new file mode 100644 index 000000000000..964b333ac905 --- /dev/null +++ b/python/testData/surround/SurroundCommentAtEnd_after.py @@ -0,0 +1,3 @@ +if True: + a = 1 + #comment line \ No newline at end of file diff --git a/python/testData/surround/SurroundCommentAtStart.py b/python/testData/surround/SurroundCommentAtStart.py new file mode 100644 index 000000000000..70f9ee427707 --- /dev/null +++ b/python/testData/surround/SurroundCommentAtStart.py @@ -0,0 +1,2 @@ +#comment line +a = 1 \ No newline at end of file diff --git a/python/testData/surround/SurroundCommentAtStart_after.py b/python/testData/surround/SurroundCommentAtStart_after.py new file mode 100644 index 000000000000..58b0d07e818e --- /dev/null +++ b/python/testData/surround/SurroundCommentAtStart_after.py @@ -0,0 +1,3 @@ +if True: + #comment line + a = 1 \ No newline at end of file diff --git a/python/testData/surround/SurroundNewline.py b/python/testData/surround/SurroundNewline.py new file mode 100644 index 000000000000..30f9fa7a6050 --- /dev/null +++ b/python/testData/surround/SurroundNewline.py @@ -0,0 +1,3 @@ +a = 1 + +a = 2 \ No newline at end of file diff --git a/python/testData/surround/SurroundNewline_after.py b/python/testData/surround/SurroundNewline_after.py new file mode 100644 index 000000000000..c07bad2792c8 --- /dev/null +++ b/python/testData/surround/SurroundNewline_after.py @@ -0,0 +1,4 @@ +if True: + a = 1 + +a = 2 \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PySurroundWithTest.java b/python/testSrc/com/jetbrains/python/PySurroundWithTest.java index af9e2e6ee2d3..8c1d7fb68540 100644 --- a/python/testSrc/com/jetbrains/python/PySurroundWithTest.java +++ b/python/testSrc/com/jetbrains/python/PySurroundWithTest.java @@ -83,6 +83,18 @@ public class PySurroundWithTest extends PyTestCase { doTest(surrounder); } + public void testSurroundCommentAtStart() throws Exception { + doTest(new PyWithIfSurrounder()); + } + + public void testSurroundCommentAtEnd() throws Exception { + doTest(new PyWithIfSurrounder()); + } + + public void testSurroundNewline() throws Exception { + doTest(new PyWithIfSurrounder()); + } + private void doTest(final Surrounder surrounder) throws Exception { String baseName = "/surround/" + getTestName(false); myFixture.configureByFile(baseName + ".py"); From 1061dc9adfe9911a741f6bbb7e28c85928a15444 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Tue, 14 Feb 2017 14:41:51 +0300 Subject: [PATCH 15/96] [groovy] decrease reference chain length (follow up IDEA-CR-18201) --- .../plugins/groovy/lang/GroovyStressPerformanceTest.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyStressPerformanceTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyStressPerformanceTest.groovy index 891a03467c27..93807db9bf3c 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyStressPerformanceTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyStressPerformanceTest.groovy @@ -538,9 +538,9 @@ class Node { def a = new Node() """ def data = [ - "(a${'.nn' * 1000}).nn", // (a.nn.nn ...).nn ... .nn - "a${'.nn()' * 500}.nn", // a.nn().nn() ... .nn().nn - "a${' += a' * 1000} += new Node()", // a += a += a ... += a += new Node() + "a${'.nn' * 500}.nn", // a.nn.nn ... .nn + "a${'.nn()' * 250}.nn", // a.nn() ... .nn().nn + "a${' += a' * 500} += new Node()", // a += a ... += a += new Node() ] for (expressionText in data) { def file = (GroovyFile)fixture.configureByText('_.groovy', header + expressionText) From a2c859265579a9def969c30edd28b9662ed34075 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Tue, 14 Feb 2017 14:55:11 +0300 Subject: [PATCH 16/96] IDEA-155088 Double click on tree's expand icon triggers double click listener - extra fix for watches --- .../xdebugger/impl/frame/XWatchesViewImpl.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java index 6b0674d04bf8..5f8b4c612779 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -135,7 +135,7 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget, ((event.getModifiers() & (InputEvent.SHIFT_MASK | InputEvent.ALT_MASK | InputEvent.CTRL_MASK | InputEvent.META_MASK)) !=0) ) { return false; } - boolean sameRow = isAboveSelectedItem(event, watchTree); + boolean sameRow = isAboveSelectedItem(event, watchTree, false); if (!sameRow || clickCount > 1) { editAlarm.cancelAllRequests(); return false; @@ -156,7 +156,7 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget, final ClickListener mouseEmptySpaceListener = new DoubleClickListener() { @Override protected boolean onDoubleClick(MouseEvent event) { - if (!isAboveSelectedItem(event, watchTree)) { + if (!isAboveSelectedItem(event, watchTree, true)) { myRootNode.addNewWatch(); return true; } @@ -204,9 +204,12 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget, super.dispose(); } - private static boolean isAboveSelectedItem(MouseEvent event, XDebuggerTree watchTree) { + private static boolean isAboveSelectedItem(MouseEvent event, XDebuggerTree watchTree, boolean fullWidth) { Rectangle bounds = watchTree.getRowBounds(watchTree.getLeadSelectionRow()); if (bounds != null) { + if (fullWidth) { + bounds.x = 0; + } bounds.width = watchTree.getWidth(); if (bounds.contains(event.getPoint())) { return true; From 9c4ae0b297be3f8b74b5249afe2cc7b5d40023fd Mon Sep 17 00:00:00 2001 From: "Anna.Kozlova" Date: Tue, 14 Feb 2017 13:00:29 +0100 Subject: [PATCH 17/96] run write action in refactorings under write action (IDEA-54664) --- .../refactoring/BaseRefactoringProcessor.java | 60 ++++++++++--------- .../util/resources/misc/registry.properties | 6 +- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java index 343051d96c9c..0e3b5264875f 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java +++ b/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java @@ -23,6 +23,8 @@ import com.intellij.ide.DataManager; import com.intellij.lang.Language; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ex.ApplicationManagerEx; +import com.intellij.openapi.application.impl.ApplicationImpl; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.command.UndoConfirmationPolicy; import com.intellij.openapi.command.undo.BasicUndoableAction; @@ -40,6 +42,7 @@ import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.EmptyRunnable; import com.intellij.openapi.util.Factory; import com.intellij.openapi.util.Ref; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.impl.status.StatusBarUtil; import com.intellij.psi.PsiDocumentManager; @@ -464,34 +467,38 @@ public abstract class BaseRefactoringProcessor implements Runnable { ProgressManager.getInstance().runProcessWithProgressSynchronously(prepareHelpersRunnable, "Prepare ...", false, myProject); - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - final String refactoringId = getRefactoringId(); + Runnable performRefactoringRunnable = () -> { + final String refactoringId = getRefactoringId(); + if (refactoringId != null) { + RefactoringEventData data = getBeforeData(); + if (data != null) { + data.addUsages(usageInfoSet); + } + myProject.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringStarted(refactoringId, data); + } + + try { if (refactoringId != null) { - RefactoringEventData data = getBeforeData(); - if (data != null) { - data.addUsages(usageInfoSet); - } - myProject.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringStarted(refactoringId, data); + UndoableAction action1 = new UndoRefactoringAction(myProject, refactoringId); + UndoManager.getInstance(myProject).undoableActionPerformed(action1); } - try { - if (refactoringId != null) { - UndoableAction action = new UndoRefactoringAction(myProject, refactoringId); - UndoManager.getInstance(myProject).undoableActionPerformed(action); - } - - performRefactoring(writableUsageInfos); - } - finally { - if (refactoringId != null) { - myProject.getMessageBus() - .syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringDone(refactoringId, getAfterData(writableUsageInfos)); - } + performRefactoring(writableUsageInfos); + } + finally { + if (refactoringId != null) { + myProject.getMessageBus() + .syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringDone(refactoringId, getAfterData(writableUsageInfos)); } } - }); + }; + ApplicationImpl app = (ApplicationImpl)ApplicationManagerEx.getApplicationEx(); + if (Registry.is("run.refactorings.under.progress")) { + app.runWriteActionWithProgressInDispatchThread(getCommandName(), myProject, null, null, indicator -> performRefactoringRunnable.run()); + } + else { + app.runWriteAction(performRefactoringRunnable); + } DumbService.getInstance(myProject).completeJustSubmittedTasks(); @@ -500,12 +507,7 @@ public abstract class BaseRefactoringProcessor implements Runnable { e.getKey().performOperation(myProject, e.getValue()); } myTransaction.commit(); - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - performPsiSpoilingRefactoring(); - } - }); + app.runWriteAction(() -> performPsiSpoilingRefactoring()); } finally { action.finish(); diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 28d2d6c0b748..932c07b512dc 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -466,6 +466,10 @@ core.pooled.threads=30 editor.dumb.mode.available=true editor.dumb.mode.available.description=Paint editor in buffer to avoid blinking during inplace refactorings + +run.refactorings.under.progress=true +run.refactorings.under.progress.description=Run refactorings write action under progress, not to freeze the UI during long operations + enable.animation.on.dialogs=false type.ahead.logging.enabled=false @@ -1002,7 +1006,7 @@ ide.new.editor.tabs.selection.description=New way to select an editor tab ide.new.editor.tabs.selection.color=439EB8 ide.new.editor.tabs.selection.color.description=Color to highlight selected editor tab javascript.unused.global.declarations.cached=false -javascript.unused.global.declarations.description=Allows caching of JavaScript unused property declarations; might contain threading issues, experimental +javascript.unused.global.declarations.cached.description=Allows caching of JavaScript unused property declarations; might contain threading issues, experimental php.register.class.references.in.strings=true php.register.class.references.in.strings.description=Enables extended class reference provider for php string literals. From 34045abb37b2b5369b3d22ff7a2fcf4911f7e7b4 Mon Sep 17 00:00:00 2001 From: Elizaveta Shashkova Date: Mon, 13 Feb 2017 20:19:03 +0300 Subject: [PATCH 18/96] Fix working with threads in frame evaluation debugger (PY-22450, PY-22454) We need to use old tracing function for suspending threads without breakpoint. Also sys.settrace() should be called inside a thread, that's why we pass this command as internal thread command. --- .../pydevd_frame_evaluator.c | 768 ++++++++++-------- .../pydevd_frame_evaluator.pyx | 6 +- .../pydevd_frame_tracing.py | 9 +- python/helpers/pydev/pydevd.py | 5 + python/testData/debug/test_two_threads.py | 11 +- .../env/python/PythonDebuggerTest.java | 8 +- 6 files changed, 471 insertions(+), 336 deletions(-) diff --git a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.c b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.c index faed4379451e..651d48fa407c 100644 --- a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.c +++ b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.c @@ -985,9 +985,12 @@ static const char __pyx_k_is_tracing[] = "is_tracing"; static const char __pyx_k_breakpoints[] = "breakpoints"; static const char __pyx_k_co_filename[] = "co_filename"; static const char __pyx_k_insert_code[] = "insert_code"; +static const char __pyx_k_pydev_state[] = "pydev_state"; +static const char __pyx_k_stop_reason[] = "stop_reason"; static const char __pyx_k_can_not_skip[] = "can_not_skip"; static const char __pyx_k_code_objects[] = "code_objects"; static const char __pyx_k_threading_py[] = "threading.py"; +static const char __pyx_k_STATE_SUSPEND[] = "STATE_SUSPEND"; static const char __pyx_k_currentThread[] = "currentThread"; static const char __pyx_k_get_file_type[] = "get_file_type"; static const char __pyx_k_weakrefset_py[] = "_weakrefset.py"; @@ -999,14 +1002,17 @@ static const char __pyx_k_additional_info[] = "additional_info"; static const char __pyx_k_frame_eval_func[] = "frame_eval_func"; static const char __pyx_k_stop_frame_eval[] = "stop_frame_eval"; static const char __pyx_k_pydevd_file_utils[] = "pydevd_file_utils"; +static const char __pyx_k_CMD_THREAD_SUSPEND[] = "CMD_THREAD_SUSPEND"; static const char __pyx_k_pydev_do_not_trace[] = "pydev_do_not_trace"; static const char __pyx_k_get_global_debugger[] = "get_global_debugger"; static const char __pyx_k_update_globals_dict[] = "update_globals_dict"; static const char __pyx_k_has_plugin_line_breaks[] = "has_plugin_line_breaks"; static const char __pyx_k_PyDBAdditionalThreadInfo[] = "PyDBAdditionalThreadInfo"; static const char __pyx_k_pydev_trace_code_wrapper[] = "pydev_trace_code_wrapper"; +static const char __pyx_k_process_internal_commands[] = "process_internal_commands"; static const char __pyx_k_pydevd_bundle_pydevd_comm[] = "_pydevd_bundle.pydevd_comm"; static const char __pyx_k_NORM_PATHS_AND_BASE_CONTAINER[] = "NORM_PATHS_AND_BASE_CONTAINER"; +static const char __pyx_k_pydevd_bundle_pydevd_constants[] = "_pydevd_bundle.pydevd_constants"; static const char __pyx_k_pydevd_frame_eval_pydevd_frame[] = "_pydevd_frame_eval.pydevd_frame_tracing"; static const char __pyx_k_get_abs_path_real_path_and_base[] = "get_abs_path_real_path_and_base_from_frame"; static const char __pyx_k_home_user_work_ultimate_communi[] = "/home/user/work/ultimate/community/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.pyx"; @@ -1019,9 +1025,11 @@ static const char __pyx_k_pydevd_additional_thread_info_re[] = "pydevd_additiona static const char __pyx_k_pydevd_frame_eval_pydevd_frame_2[] = "_pydevd_frame_eval.pydevd_frame_evaluator"; static PyObject *__pyx_n_s_AVOID_RECURSION; static PyObject *__pyx_n_s_AttributeError; +static PyObject *__pyx_n_s_CMD_THREAD_SUSPEND; static PyObject *__pyx_n_s_DONT_TRACE; static PyObject *__pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER; static PyObject *__pyx_n_s_PyDBAdditionalThreadInfo; +static PyObject *__pyx_n_s_STATE_SUSPEND; static PyObject *__pyx_n_s_SetTrace; static PyObject *__pyx_n_s_additional_info; static PyObject *__pyx_n_s_append; @@ -1047,12 +1055,15 @@ static PyObject *__pyx_n_s_insert_code; static PyObject *__pyx_n_s_is_tracing; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_plugin; +static PyObject *__pyx_n_s_process_internal_commands; static PyObject *__pyx_n_s_pydev_do_not_trace; static PyObject *__pyx_n_s_pydev_imps__pydev_saved_modules; +static PyObject *__pyx_n_s_pydev_state; static PyObject *__pyx_n_s_pydev_trace_code_wrapper; static PyObject *__pyx_kp_s_pydevd_additional_thread_info_re; static PyObject *__pyx_n_s_pydevd_bundle_pydevd_additional; static PyObject *__pyx_n_s_pydevd_bundle_pydevd_comm; +static PyObject *__pyx_n_s_pydevd_bundle_pydevd_constants; static PyObject *__pyx_n_s_pydevd_bundle_pydevd_dont_trace; static PyObject *__pyx_n_s_pydevd_file_utils; static PyObject *__pyx_n_s_pydevd_frame_eval_pydevd_frame; @@ -1061,6 +1072,7 @@ static PyObject *__pyx_n_s_pydevd_frame_eval_pydevd_modify; static PyObject *__pyx_n_s_set_trace_for_frame_and_parents; static PyObject *__pyx_n_s_state; static PyObject *__pyx_n_s_stop_frame_eval; +static PyObject *__pyx_n_s_stop_reason; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_threading; static PyObject *__pyx_kp_s_threading_py; @@ -1074,7 +1086,7 @@ static PyObject *__pyx_tuple__3; static PyObject *__pyx_codeobj__2; static PyObject *__pyx_codeobj__4; -/* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":18 +/* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":19 * get_file_type = DONT_TRACE.get * * cdef PyObject* get_bytecode_while_frame_eval(PyFrameObject *frame_obj, int exc): # <<<<<<<<<<<<<< @@ -1123,7 +1135,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec int __pyx_t_17; __Pyx_RefNannySetupContext("get_bytecode_while_frame_eval", 0); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":19 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":20 * * cdef PyObject* get_bytecode_while_frame_eval(PyFrameObject *frame_obj, int exc): * frame = frame_obj # <<<<<<<<<<<<<< @@ -1135,23 +1147,23 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_v_frame = __pyx_t_1; __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":20 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":21 * cdef PyObject* get_bytecode_while_frame_eval(PyFrameObject *frame_obj, int exc): * frame = frame_obj * cdef str filepath = frame.f_code.co_filename # <<<<<<<<<<<<<< * cdef bint skip_file = exc * */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_co_filename); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_co_filename); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 20, __pyx_L1_error) + if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 21, __pyx_L1_error) __pyx_v_filepath = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":21 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":22 * frame = frame_obj * cdef str filepath = frame.f_code.co_filename * cdef bint skip_file = exc # <<<<<<<<<<<<<< @@ -1160,22 +1172,22 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ __pyx_v_skip_file = __pyx_v_exc; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":23 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":24 * cdef bint skip_file = exc * * for file in AVOID_RECURSION: # <<<<<<<<<<<<<< * # we can't call any other function without this check, because we can get stack overflow * if filepath.endswith(file): */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_AVOID_RECURSION); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_AVOID_RECURSION); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { - __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 24, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { @@ -1183,17 +1195,17 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec if (likely(PyList_CheckExact(__pyx_t_1))) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 24, __pyx_L1_error) #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 24, __pyx_L1_error) #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } @@ -1203,7 +1215,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 23, __pyx_L1_error) + else __PYX_ERR(0, 24, __pyx_L1_error) } break; } @@ -1212,7 +1224,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_XDECREF_SET(__pyx_v_file, __pyx_t_2); __pyx_t_2 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":25 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":26 * for file in AVOID_RECURSION: * # we can't call any other function without this check, because we can get stack overflow * if filepath.endswith(file): # <<<<<<<<<<<<<< @@ -1221,12 +1233,12 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ if (unlikely(__pyx_v_filepath == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "endswith"); - __PYX_ERR(0, 25, __pyx_L1_error) + __PYX_ERR(0, 26, __pyx_L1_error) } - __pyx_t_5 = __Pyx_PyStr_Tailmatch(__pyx_v_filepath, __pyx_v_file, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 25, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyStr_Tailmatch(__pyx_v_filepath, __pyx_v_file, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 26, __pyx_L1_error) if ((__pyx_t_5 != 0)) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":26 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":27 * # we can't call any other function without this check, because we can get stack overflow * if filepath.endswith(file): * skip_file = True # <<<<<<<<<<<<<< @@ -1235,7 +1247,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ __pyx_v_skip_file = 1; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":27 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":28 * if filepath.endswith(file): * skip_file = True * break # <<<<<<<<<<<<<< @@ -1244,7 +1256,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ goto __pyx_L4_break; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":25 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":26 * for file in AVOID_RECURSION: * # we can't call any other function without this check, because we can get stack overflow * if filepath.endswith(file): # <<<<<<<<<<<<<< @@ -1253,7 +1265,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":23 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":24 * cdef bint skip_file = exc * * for file in AVOID_RECURSION: # <<<<<<<<<<<<<< @@ -1264,7 +1276,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_L4_break:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":29 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":30 * break * * if not skip_file: # <<<<<<<<<<<<<< @@ -1274,7 +1286,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_t_5 = ((!(__pyx_v_skip_file != 0)) != 0); if (__pyx_t_5) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":30 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":31 * * if not skip_file: * try: # <<<<<<<<<<<<<< @@ -1290,16 +1302,16 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_XGOTREF(__pyx_t_8); /*try:*/ { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":31 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":32 * if not skip_file: * try: * threading.currentThread() # <<<<<<<<<<<<<< * except: * skip_file = True */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_threading); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L7_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_threading); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_currentThread); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 31, __pyx_L7_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_currentThread); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 32, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; @@ -1313,16 +1325,16 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (__pyx_t_2) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L7_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L7_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L7_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L7_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":30 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":31 * * if not skip_file: * try: # <<<<<<<<<<<<<< @@ -1340,7 +1352,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":32 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":33 * try: * threading.currentThread() * except: # <<<<<<<<<<<<<< @@ -1349,12 +1361,12 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ /*except:*/ { __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_bytecode_while_frame_eval", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_9, &__pyx_t_2) < 0) __PYX_ERR(0, 32, __pyx_L9_except_error) + if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_9, &__pyx_t_2) < 0) __PYX_ERR(0, 33, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_9); __Pyx_GOTREF(__pyx_t_2); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":33 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":34 * threading.currentThread() * except: * skip_file = True # <<<<<<<<<<<<<< @@ -1369,7 +1381,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } __pyx_L9_except_error:; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":30 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":31 * * if not skip_file: * try: # <<<<<<<<<<<<<< @@ -1391,7 +1403,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_L14_try_end:; } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":29 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":30 * break * * if not skip_file: # <<<<<<<<<<<<<< @@ -1400,7 +1412,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":35 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":36 * skip_file = True * * if not skip_file: # <<<<<<<<<<<<<< @@ -1410,16 +1422,16 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_t_5 = ((!(__pyx_v_skip_file != 0)) != 0); if (__pyx_t_5) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":36 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":37 * * if not skip_file: * t = threading.currentThread() # <<<<<<<<<<<<<< * try: * additional_info = t.additional_info */ - __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_threading); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 36, __pyx_L1_error) + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_threading); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_currentThread); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_currentThread); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; @@ -1433,17 +1445,17 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (__pyx_t_9) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_t = __pyx_t_2; __pyx_t_2 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":37 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":38 * if not skip_file: * t = threading.currentThread() * try: # <<<<<<<<<<<<<< @@ -1459,19 +1471,19 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_XGOTREF(__pyx_t_6); /*try:*/ { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":38 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":39 * t = threading.currentThread() * try: * additional_info = t.additional_info # <<<<<<<<<<<<<< * if additional_info is None: * raise AttributeError() */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_additional_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L18_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_additional_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_additional_info = __pyx_t_2; __pyx_t_2 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":39 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":40 * try: * additional_info = t.additional_info * if additional_info is None: # <<<<<<<<<<<<<< @@ -1482,20 +1494,20 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_t_10 = (__pyx_t_5 != 0); if (__pyx_t_10) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":40 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":41 * additional_info = t.additional_info * if additional_info is None: * raise AttributeError() # <<<<<<<<<<<<<< * except: * additional_info = t.additional_info = PyDBAdditionalThreadInfo() */ - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_builtin_AttributeError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L18_error) + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_builtin_AttributeError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 41, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 40, __pyx_L18_error) + __PYX_ERR(0, 41, __pyx_L18_error) - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":39 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":40 * try: * additional_info = t.additional_info * if additional_info is None: # <<<<<<<<<<<<<< @@ -1504,7 +1516,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":37 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":38 * if not skip_file: * t = threading.currentThread() * try: # <<<<<<<<<<<<<< @@ -1522,7 +1534,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":41 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":42 * if additional_info is None: * raise AttributeError() * except: # <<<<<<<<<<<<<< @@ -1531,19 +1543,19 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ /*except:*/ { __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_bytecode_while_frame_eval", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_9) < 0) __PYX_ERR(0, 41, __pyx_L20_except_error) + if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_9) < 0) __PYX_ERR(0, 42, __pyx_L20_except_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_9); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":42 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":43 * raise AttributeError() * except: * additional_info = t.additional_info = PyDBAdditionalThreadInfo() # <<<<<<<<<<<<<< * * if additional_info.is_tracing or getattr(t, 'pydev_do_not_trace', None): */ - __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyDBAdditionalThreadInfo); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 42, __pyx_L20_except_error) + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_PyDBAdditionalThreadInfo); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 43, __pyx_L20_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { @@ -1556,16 +1568,16 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (__pyx_t_13) { - __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 42, __pyx_L20_except_error) + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 43, __pyx_L20_except_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else { - __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 42, __pyx_L20_except_error) + __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 43, __pyx_L20_except_error) } __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_INCREF(__pyx_t_11); __Pyx_XDECREF_SET(__pyx_v_additional_info, __pyx_t_11); - if (__Pyx_PyObject_SetAttrStr(__pyx_v_t, __pyx_n_s_additional_info, __pyx_t_11) < 0) __PYX_ERR(0, 42, __pyx_L20_except_error) + if (__Pyx_PyObject_SetAttrStr(__pyx_v_t, __pyx_n_s_additional_info, __pyx_t_11) < 0) __PYX_ERR(0, 43, __pyx_L20_except_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -1574,7 +1586,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } __pyx_L20_except_error:; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":37 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":38 * if not skip_file: * t = threading.currentThread() * try: # <<<<<<<<<<<<<< @@ -1596,31 +1608,31 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_L25_try_end:; } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":44 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":45 * additional_info = t.additional_info = PyDBAdditionalThreadInfo() * * if additional_info.is_tracing or getattr(t, 'pydev_do_not_trace', None): # <<<<<<<<<<<<<< * return _PyEval_EvalFrameDefault(frame_obj, exc) * */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_additional_info, __pyx_n_s_is_tracing); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 44, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_additional_info, __pyx_n_s_is_tracing); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 44, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (!__pyx_t_5) { } else { __pyx_t_10 = __pyx_t_5; goto __pyx_L30_bool_binop_done; } - __pyx_t_9 = __Pyx_GetAttr3(__pyx_v_t, __pyx_n_s_pydev_do_not_trace, Py_None); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 44, __pyx_L1_error) + __pyx_t_9 = __Pyx_GetAttr3(__pyx_v_t, __pyx_n_s_pydev_do_not_trace, Py_None); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 44, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = __pyx_t_5; __pyx_L30_bool_binop_done:; if (__pyx_t_10) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":45 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":46 * * if additional_info.is_tracing or getattr(t, 'pydev_do_not_trace', None): * return _PyEval_EvalFrameDefault(frame_obj, exc) # <<<<<<<<<<<<<< @@ -1630,7 +1642,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_r = _PyEval_EvalFrameDefault(__pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":44 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":45 * additional_info = t.additional_info = PyDBAdditionalThreadInfo() * * if additional_info.is_tracing or getattr(t, 'pydev_do_not_trace', None): # <<<<<<<<<<<<<< @@ -1639,16 +1651,16 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":47 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":48 * return _PyEval_EvalFrameDefault(frame_obj, exc) * * additional_info.is_tracing = True # <<<<<<<<<<<<<< * try: * abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[frame.f_code.co_filename] */ - if (__Pyx_PyObject_SetAttrStr(__pyx_v_additional_info, __pyx_n_s_is_tracing, Py_True) < 0) __PYX_ERR(0, 47, __pyx_L1_error) + if (__Pyx_PyObject_SetAttrStr(__pyx_v_additional_info, __pyx_n_s_is_tracing, Py_True) < 0) __PYX_ERR(0, 48, __pyx_L1_error) - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":48 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":49 * * additional_info.is_tracing = True * try: # <<<<<<<<<<<<<< @@ -1664,28 +1676,28 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_XGOTREF(__pyx_t_8); /*try:*/ { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":49 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":50 * additional_info.is_tracing = True * try: * abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[frame.f_code.co_filename] # <<<<<<<<<<<<<< * except: * abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(frame) */ - __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 49, __pyx_L32_error) + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 50, __pyx_L32_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L32_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L32_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_co_filename); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L32_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_co_filename); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L32_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_GetItem(__pyx_t_9, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L32_error) + __pyx_t_1 = PyObject_GetItem(__pyx_t_9, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L32_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_abs_path_real_path_and_base = __pyx_t_1; __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":48 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":49 * * additional_info.is_tracing = True * try: # <<<<<<<<<<<<<< @@ -1706,7 +1718,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":50 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":51 * try: * abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[frame.f_code.co_filename] * except: # <<<<<<<<<<<<<< @@ -1715,19 +1727,19 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ /*except:*/ { __Pyx_AddTraceback("_pydevd_frame_eval.pydevd_frame_evaluator.get_bytecode_while_frame_eval", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_9) < 0) __PYX_ERR(0, 50, __pyx_L34_except_error) + if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_9) < 0) __PYX_ERR(0, 51, __pyx_L34_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_9); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":51 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":52 * abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[frame.f_code.co_filename] * except: * abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(frame) # <<<<<<<<<<<<<< * * file_type = get_file_type(abs_path_real_path_and_base[-1]) #we don't want to debug anything related to pydevd */ - __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_abs_path_real_path_and_base); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 51, __pyx_L34_except_error) + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_abs_path_real_path_and_base); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 52, __pyx_L34_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { @@ -1740,13 +1752,13 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (!__pyx_t_13) { - __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_frame); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 51, __pyx_L34_except_error) + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_frame); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 52, __pyx_L34_except_error) __Pyx_GOTREF(__pyx_t_11); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_v_frame}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 51, __pyx_L34_except_error) + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 52, __pyx_L34_except_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_11); } else @@ -1754,19 +1766,19 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_v_frame}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 51, __pyx_L34_except_error) + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 52, __pyx_L34_except_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_11); } else #endif { - __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 51, __pyx_L34_except_error) + __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 52, __pyx_L34_except_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL; __Pyx_INCREF(__pyx_v_frame); __Pyx_GIVEREF(__pyx_v_frame); PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_v_frame); - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_14, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 51, __pyx_L34_except_error) + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_14, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 52, __pyx_L34_except_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } @@ -1781,7 +1793,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } __pyx_L34_except_error:; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":48 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":49 * * additional_info.is_tracing = True * try: # <<<<<<<<<<<<<< @@ -1803,16 +1815,16 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_L39_try_end:; } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":53 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":54 * abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(frame) * * file_type = get_file_type(abs_path_real_path_and_base[-1]) #we don't want to debug anything related to pydevd # <<<<<<<<<<<<<< * if file_type is not None: * additional_info.is_tracing = False */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_file_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_file_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_abs_path_real_path_and_base, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_abs_path_real_path_and_base, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { @@ -1825,14 +1837,14 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (!__pyx_t_11) { - __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_9); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_1}; - __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -1841,20 +1853,20 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_1}; - __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif { - __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL; __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } @@ -1863,7 +1875,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_v_file_type = __pyx_t_9; __pyx_t_9 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":54 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":55 * * file_type = get_file_type(abs_path_real_path_and_base[-1]) #we don't want to debug anything related to pydevd * if file_type is not None: # <<<<<<<<<<<<<< @@ -1874,16 +1886,16 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_t_5 = (__pyx_t_10 != 0); if (__pyx_t_5) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":55 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":56 * file_type = get_file_type(abs_path_real_path_and_base[-1]) #we don't want to debug anything related to pydevd * if file_type is not None: * additional_info.is_tracing = False # <<<<<<<<<<<<<< * return _PyEval_EvalFrameDefault(frame_obj, exc) * */ - if (__Pyx_PyObject_SetAttrStr(__pyx_v_additional_info, __pyx_n_s_is_tracing, Py_False) < 0) __PYX_ERR(0, 55, __pyx_L1_error) + if (__Pyx_PyObject_SetAttrStr(__pyx_v_additional_info, __pyx_n_s_is_tracing, Py_False) < 0) __PYX_ERR(0, 56, __pyx_L1_error) - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":56 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":57 * if file_type is not None: * additional_info.is_tracing = False * return _PyEval_EvalFrameDefault(frame_obj, exc) # <<<<<<<<<<<<<< @@ -1893,7 +1905,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_r = _PyEval_EvalFrameDefault(__pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":54 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":55 * * file_type = get_file_type(abs_path_real_path_and_base[-1]) #we don't want to debug anything related to pydevd * if file_type is not None: # <<<<<<<<<<<<<< @@ -1902,14 +1914,14 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":58 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":59 * return _PyEval_EvalFrameDefault(frame_obj, exc) * * main_debugger = get_global_debugger() # <<<<<<<<<<<<<< - * breakpoints = main_debugger.breakpoints.get(abs_path_real_path_and_base[1]) - * if breakpoints: + * if additional_info.pydev_state == STATE_SUSPEND and t.stop_reason == CMD_THREAD_SUSPEND: + * main_debugger.process_internal_commands() */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_global_debugger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_global_debugger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_12 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { @@ -1922,29 +1934,101 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (__pyx_t_12) { - __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 58, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else { - __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 58, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 59, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_main_debugger = __pyx_t_9; __pyx_t_9 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":59 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":60 * * main_debugger = get_global_debugger() + * if additional_info.pydev_state == STATE_SUSPEND and t.stop_reason == CMD_THREAD_SUSPEND: # <<<<<<<<<<<<<< + * main_debugger.process_internal_commands() + * + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_additional_info, __pyx_n_s_pydev_state); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_STATE_SUSPEND); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_12 = PyObject_RichCompare(__pyx_t_9, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + if (__pyx_t_10) { + } else { + __pyx_t_5 = __pyx_t_10; + goto __pyx_L44_bool_binop_done; + } + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_stop_reason); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_CMD_THREAD_SUSPEND); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_9 = PyObject_RichCompare(__pyx_t_12, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_5 = __pyx_t_10; + __pyx_L44_bool_binop_done:; + if (__pyx_t_5) { + + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":61 + * main_debugger = get_global_debugger() + * if additional_info.pydev_state == STATE_SUSPEND and t.stop_reason == CMD_THREAD_SUSPEND: + * main_debugger.process_internal_commands() # <<<<<<<<<<<<<< + * + * breakpoints = main_debugger.breakpoints.get(abs_path_real_path_and_base[1]) + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_process_internal_commands); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_12 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (__pyx_t_12) { + __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + } else { + __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 61, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":60 + * + * main_debugger = get_global_debugger() + * if additional_info.pydev_state == STATE_SUSPEND and t.stop_reason == CMD_THREAD_SUSPEND: # <<<<<<<<<<<<<< + * main_debugger.process_internal_commands() + * + */ + } + + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":63 + * main_debugger.process_internal_commands() + * * breakpoints = main_debugger.breakpoints.get(abs_path_real_path_and_base[1]) # <<<<<<<<<<<<<< * if breakpoints: * was_break = False */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_breakpoints); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_breakpoints); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_abs_path_real_path_and_base, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_abs_path_real_path_and_base, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) { @@ -1957,14 +2041,14 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (!__pyx_t_1) { - __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_9); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_2}; - __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -1973,20 +2057,20 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_2}; - __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { - __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __pyx_t_1 = NULL; __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_2); __pyx_t_2 = 0; - __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_11, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_11, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } @@ -1995,17 +2079,17 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_v_breakpoints = __pyx_t_9; __pyx_t_9 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":60 - * main_debugger = get_global_debugger() + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":64 + * * breakpoints = main_debugger.breakpoints.get(abs_path_real_path_and_base[1]) * if breakpoints: # <<<<<<<<<<<<<< * was_break = False * breakpoints_to_update = [] */ - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_breakpoints); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 60, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_breakpoints); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 64, __pyx_L1_error) if (__pyx_t_5) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":61 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":65 * breakpoints = main_debugger.breakpoints.get(abs_path_real_path_and_base[1]) * if breakpoints: * was_break = False # <<<<<<<<<<<<<< @@ -2014,40 +2098,40 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ __pyx_v_was_break = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":62 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":66 * if breakpoints: * was_break = False * breakpoints_to_update = [] # <<<<<<<<<<<<<< * code_object = frame.f_code * for offset, line in dis.findlinestarts(code_object): */ - __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 62, __pyx_L1_error) + __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 66, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_v_breakpoints_to_update = ((PyObject*)__pyx_t_9); __pyx_t_9 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":63 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":67 * was_break = False * breakpoints_to_update = [] * code_object = frame.f_code # <<<<<<<<<<<<<< * for offset, line in dis.findlinestarts(code_object): * if line in breakpoints: */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 63, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 67, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_v_code_object = __pyx_t_9; __pyx_t_9 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":64 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":68 * breakpoints_to_update = [] * code_object = frame.f_code * for offset, line in dis.findlinestarts(code_object): # <<<<<<<<<<<<<< * if line in breakpoints: * breakpoint = breakpoints[line] */ - __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_dis); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_dis); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_findlinestarts); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_findlinestarts); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = NULL; @@ -2061,13 +2145,13 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (!__pyx_t_12) { - __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_code_object); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_code_object); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_code_object}; - __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_9); } else @@ -2075,19 +2159,19 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_v_code_object}; - __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif { - __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_12); __pyx_t_12 = NULL; __Pyx_INCREF(__pyx_v_code_object); __Pyx_GIVEREF(__pyx_v_code_object); PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_code_object); - __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_2, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_2, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } @@ -2097,9 +2181,9 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_t_11 = __pyx_t_9; __Pyx_INCREF(__pyx_t_11); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { - __pyx_t_3 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_3 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_4 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_4 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 68, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; for (;;) { @@ -2107,17 +2191,17 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec if (likely(PyList_CheckExact(__pyx_t_11))) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_11)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_9 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_3); __Pyx_INCREF(__pyx_t_9); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_9 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_3); __Pyx_INCREF(__pyx_t_9); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 68, __pyx_L1_error) #else - __pyx_t_9 = PySequence_ITEM(__pyx_t_11, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_9 = PySequence_ITEM(__pyx_t_11, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #endif } else { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_11)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_3); __Pyx_INCREF(__pyx_t_9); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_3); __Pyx_INCREF(__pyx_t_9); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 68, __pyx_L1_error) #else - __pyx_t_9 = PySequence_ITEM(__pyx_t_11, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_9 = PySequence_ITEM(__pyx_t_11, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #endif } @@ -2127,7 +2211,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 64, __pyx_L1_error) + else __PYX_ERR(0, 68, __pyx_L1_error) } break; } @@ -2143,7 +2227,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 64, __pyx_L1_error) + __PYX_ERR(0, 68, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { @@ -2156,98 +2240,98 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_12); #else - __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); #endif __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { Py_ssize_t index = -1; - __pyx_t_1 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_1 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_15 = Py_TYPE(__pyx_t_1)->tp_iternext; - index = 0; __pyx_t_2 = __pyx_t_15(__pyx_t_1); if (unlikely(!__pyx_t_2)) goto __pyx_L46_unpacking_failed; + index = 0; __pyx_t_2 = __pyx_t_15(__pyx_t_1); if (unlikely(!__pyx_t_2)) goto __pyx_L49_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); - index = 1; __pyx_t_12 = __pyx_t_15(__pyx_t_1); if (unlikely(!__pyx_t_12)) goto __pyx_L46_unpacking_failed; + index = 1; __pyx_t_12 = __pyx_t_15(__pyx_t_1); if (unlikely(!__pyx_t_12)) goto __pyx_L49_unpacking_failed; __Pyx_GOTREF(__pyx_t_12); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_1), 2) < 0) __PYX_ERR(0, 64, __pyx_L1_error) + if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_1), 2) < 0) __PYX_ERR(0, 68, __pyx_L1_error) __pyx_t_15 = NULL; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L47_unpacking_done; - __pyx_L46_unpacking_failed:; + goto __pyx_L50_unpacking_done; + __pyx_L49_unpacking_failed:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_15 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 64, __pyx_L1_error) - __pyx_L47_unpacking_done:; + __PYX_ERR(0, 68, __pyx_L1_error) + __pyx_L50_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_offset, __pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v_line, __pyx_t_12); __pyx_t_12 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":65 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":69 * code_object = frame.f_code * for offset, line in dis.findlinestarts(code_object): * if line in breakpoints: # <<<<<<<<<<<<<< * breakpoint = breakpoints[line] * if code_object not in breakpoint.code_objects: */ - __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_v_line, __pyx_v_breakpoints, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 65, __pyx_L1_error) + __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_v_line, __pyx_v_breakpoints, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 69, __pyx_L1_error) __pyx_t_10 = (__pyx_t_5 != 0); if (__pyx_t_10) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":66 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":70 * for offset, line in dis.findlinestarts(code_object): * if line in breakpoints: * breakpoint = breakpoints[line] # <<<<<<<<<<<<<< * if code_object not in breakpoint.code_objects: * # This check is needed for generator functions, because after each yield the new frame is created */ - __pyx_t_9 = PyObject_GetItem(__pyx_v_breakpoints, __pyx_v_line); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 66, __pyx_L1_error) + __pyx_t_9 = PyObject_GetItem(__pyx_v_breakpoints, __pyx_v_line); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_breakpoint, __pyx_t_9); __pyx_t_9 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":67 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":71 * if line in breakpoints: * breakpoint = breakpoints[line] * if code_object not in breakpoint.code_objects: # <<<<<<<<<<<<<< * # This check is needed for generator functions, because after each yield the new frame is created * # but the former code object is used */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_breakpoint, __pyx_n_s_code_objects); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 67, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_breakpoint, __pyx_n_s_code_objects); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = (__Pyx_PySequence_ContainsTF(__pyx_v_code_object, __pyx_t_9, Py_NE)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 67, __pyx_L1_error) + __pyx_t_10 = (__Pyx_PySequence_ContainsTF(__pyx_v_code_object, __pyx_t_9, Py_NE)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_5 = (__pyx_t_10 != 0); if (__pyx_t_5) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":70 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":74 * # This check is needed for generator functions, because after each yield the new frame is created * # but the former code object is used * breakpoints_to_update.append(breakpoint) # <<<<<<<<<<<<<< * new_code = insert_code(frame.f_code, pydev_trace_code_wrapper.__code__, line) * Py_INCREF(new_code) */ - __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_breakpoints_to_update, __pyx_v_breakpoint); if (unlikely(__pyx_t_16 == -1)) __PYX_ERR(0, 70, __pyx_L1_error) + __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_breakpoints_to_update, __pyx_v_breakpoint); if (unlikely(__pyx_t_16 == -1)) __PYX_ERR(0, 74, __pyx_L1_error) - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":71 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":75 * # but the former code object is used * breakpoints_to_update.append(breakpoint) * new_code = insert_code(frame.f_code, pydev_trace_code_wrapper.__code__, line) # <<<<<<<<<<<<<< * Py_INCREF(new_code) * frame_obj.f_code = new_code */ - __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_insert_code); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_insert_code); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pydev_trace_code_wrapper); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pydev_trace_code_wrapper); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_code); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_code); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; @@ -2265,7 +2349,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_2, __pyx_t_14, __pyx_v_line}; - __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 3+__pyx_t_17); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 3+__pyx_t_17); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -2275,7 +2359,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_2, __pyx_t_14, __pyx_v_line}; - __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 3+__pyx_t_17); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 3+__pyx_t_17); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -2283,7 +2367,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } else #endif { - __pyx_t_13 = PyTuple_New(3+__pyx_t_17); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_13 = PyTuple_New(3+__pyx_t_17); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); if (__pyx_t_1) { __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_1); __pyx_t_1 = NULL; @@ -2297,7 +2381,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_17, __pyx_v_line); __pyx_t_2 = 0; __pyx_t_14 = 0; - __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } @@ -2305,7 +2389,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_XDECREF_SET(__pyx_v_new_code, __pyx_t_9); __pyx_t_9 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":72 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":76 * breakpoints_to_update.append(breakpoint) * new_code = insert_code(frame.f_code, pydev_trace_code_wrapper.__code__, line) * Py_INCREF(new_code) # <<<<<<<<<<<<<< @@ -2314,7 +2398,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ Py_INCREF(__pyx_v_new_code); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":73 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":77 * new_code = insert_code(frame.f_code, pydev_trace_code_wrapper.__code__, line) * Py_INCREF(new_code) * frame_obj.f_code = new_code # <<<<<<<<<<<<<< @@ -2323,7 +2407,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ __pyx_v_frame_obj->f_code = ((PyCodeObject *)__pyx_v_new_code); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":74 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":78 * Py_INCREF(new_code) * frame_obj.f_code = new_code * was_break = True # <<<<<<<<<<<<<< @@ -2332,7 +2416,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ __pyx_v_was_break = 1; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":67 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":71 * if line in breakpoints: * breakpoint = breakpoints[line] * if code_object not in breakpoint.code_objects: # <<<<<<<<<<<<<< @@ -2341,7 +2425,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":65 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":69 * code_object = frame.f_code * for offset, line in dis.findlinestarts(code_object): * if line in breakpoints: # <<<<<<<<<<<<<< @@ -2350,7 +2434,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":64 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":68 * breakpoints_to_update = [] * code_object = frame.f_code * for offset, line in dis.findlinestarts(code_object): # <<<<<<<<<<<<<< @@ -2360,7 +2444,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":75 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":79 * frame_obj.f_code = new_code * was_break = True * if was_break: # <<<<<<<<<<<<<< @@ -2370,16 +2454,16 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_t_5 = (__pyx_v_was_break != 0); if (__pyx_t_5) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":76 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":80 * was_break = True * if was_break: * update_globals_dict(frame.f_globals) # <<<<<<<<<<<<<< * for bp in breakpoints_to_update: * bp.code_objects.append(frame.f_code) */ - __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_update_globals_dict); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_update_globals_dict); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_globals); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_globals); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { @@ -2392,14 +2476,14 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (!__pyx_t_13) { - __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_11); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_12}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; @@ -2408,20 +2492,20 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_12}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif { - __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL; __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_12); __pyx_t_12 = 0; - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_14, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_14, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } @@ -2429,7 +2513,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":77 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":81 * if was_break: * update_globals_dict(frame.f_globals) * for bp in breakpoints_to_update: # <<<<<<<<<<<<<< @@ -2440,30 +2524,30 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec for (;;) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_11)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_9 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_3); __Pyx_INCREF(__pyx_t_9); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 77, __pyx_L1_error) + __pyx_t_9 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_3); __Pyx_INCREF(__pyx_t_9); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 81, __pyx_L1_error) #else - __pyx_t_9 = PySequence_ITEM(__pyx_t_11, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 77, __pyx_L1_error) + __pyx_t_9 = PySequence_ITEM(__pyx_t_11, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #endif __Pyx_XDECREF_SET(__pyx_v_bp, __pyx_t_9); __pyx_t_9 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":78 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":82 * update_globals_dict(frame.f_globals) * for bp in breakpoints_to_update: * bp.code_objects.append(frame.f_code) # <<<<<<<<<<<<<< * else: * if main_debugger.has_plugin_line_breaks: */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_bp, __pyx_n_s_code_objects); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 78, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_bp, __pyx_n_s_code_objects); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 78, __pyx_L1_error) + __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_f_code); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); - __pyx_t_16 = __Pyx_PyObject_Append(__pyx_t_9, __pyx_t_14); if (unlikely(__pyx_t_16 == -1)) __PYX_ERR(0, 78, __pyx_L1_error) + __pyx_t_16 = __Pyx_PyObject_Append(__pyx_t_9, __pyx_t_14); if (unlikely(__pyx_t_16 == -1)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":77 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":81 * if was_break: * update_globals_dict(frame.f_globals) * for bp in breakpoints_to_update: # <<<<<<<<<<<<<< @@ -2473,7 +2557,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":75 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":79 * frame_obj.f_code = new_code * was_break = True * if was_break: # <<<<<<<<<<<<<< @@ -2482,17 +2566,17 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":60 - * main_debugger = get_global_debugger() + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":64 + * * breakpoints = main_debugger.breakpoints.get(abs_path_real_path_and_base[1]) * if breakpoints: # <<<<<<<<<<<<<< * was_break = False * breakpoints_to_update = [] */ - goto __pyx_L43; + goto __pyx_L46; } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":80 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":84 * bp.code_objects.append(frame.f_code) * else: * if main_debugger.has_plugin_line_breaks: # <<<<<<<<<<<<<< @@ -2500,22 +2584,22 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec * if can_not_skip: */ /*else*/ { - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_has_plugin_line_breaks); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 80, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_has_plugin_line_breaks); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 80, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (__pyx_t_5) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":81 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":85 * else: * if main_debugger.has_plugin_line_breaks: * can_not_skip = main_debugger.plugin.can_not_skip(main_debugger, None, frame) # <<<<<<<<<<<<<< * if can_not_skip: * main_debugger.SetTrace(main_debugger.trace_dispatch) */ - __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_plugin); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 81, __pyx_L1_error) + __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_plugin); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_can_not_skip); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 81, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_can_not_skip); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = NULL; @@ -2533,7 +2617,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[4] = {__pyx_t_14, __pyx_v_main_debugger, Py_None, __pyx_v_frame}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_17, 3+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 81, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_17, 3+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_11); } else @@ -2541,13 +2625,13 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[4] = {__pyx_t_14, __pyx_v_main_debugger, Py_None, __pyx_v_frame}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_17, 3+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 81, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_17, 3+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_11); } else #endif { - __pyx_t_12 = PyTuple_New(3+__pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 81, __pyx_L1_error) + __pyx_t_12 = PyTuple_New(3+__pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (__pyx_t_14) { __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_14); __pyx_t_14 = NULL; @@ -2561,7 +2645,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_INCREF(__pyx_v_frame); __Pyx_GIVEREF(__pyx_v_frame); PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_17, __pyx_v_frame); - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 81, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } @@ -2569,26 +2653,26 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_v_can_not_skip = __pyx_t_11; __pyx_t_11 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":82 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":86 * if main_debugger.has_plugin_line_breaks: * can_not_skip = main_debugger.plugin.can_not_skip(main_debugger, None, frame) * if can_not_skip: # <<<<<<<<<<<<<< * main_debugger.SetTrace(main_debugger.trace_dispatch) * main_debugger.set_trace_for_frame_and_parents(frame) */ - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_can_not_skip); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 82, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_can_not_skip); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 86, __pyx_L1_error) if (__pyx_t_5) { - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":83 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":87 * can_not_skip = main_debugger.plugin.can_not_skip(main_debugger, None, frame) * if can_not_skip: * main_debugger.SetTrace(main_debugger.trace_dispatch) # <<<<<<<<<<<<<< * main_debugger.set_trace_for_frame_and_parents(frame) * */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_SetTrace); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_SetTrace); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_trace_dispatch); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_trace_dispatch); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_14 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { @@ -2601,14 +2685,14 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (!__pyx_t_14) { - __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_11); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_12}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; @@ -2617,20 +2701,20 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_12}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif { - __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); __pyx_t_14 = NULL; __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_12); __pyx_t_12 = 0; - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } @@ -2638,14 +2722,14 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":84 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":88 * if can_not_skip: * main_debugger.SetTrace(main_debugger.trace_dispatch) * main_debugger.set_trace_for_frame_and_parents(frame) # <<<<<<<<<<<<<< * * additional_info.is_tracing = False */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_set_trace_for_frame_and_parents); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_main_debugger, __pyx_n_s_set_trace_for_frame_and_parents); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_13 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { @@ -2658,13 +2742,13 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec } } if (!__pyx_t_13) { - __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_frame); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_frame); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_v_frame}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_11); } else @@ -2672,19 +2756,19 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_v_frame}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_11); } else #endif { - __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = NULL; __Pyx_INCREF(__pyx_v_frame); __Pyx_GIVEREF(__pyx_v_frame); PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_v_frame); - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } @@ -2692,7 +2776,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":82 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":86 * if main_debugger.has_plugin_line_breaks: * can_not_skip = main_debugger.plugin.can_not_skip(main_debugger, None, frame) * if can_not_skip: # <<<<<<<<<<<<<< @@ -2701,7 +2785,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":80 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":84 * bp.code_objects.append(frame.f_code) * else: * if main_debugger.has_plugin_line_breaks: # <<<<<<<<<<<<<< @@ -2710,18 +2794,18 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } } - __pyx_L43:; + __pyx_L46:; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":86 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":90 * main_debugger.set_trace_for_frame_and_parents(frame) * * additional_info.is_tracing = False # <<<<<<<<<<<<<< * return _PyEval_EvalFrameDefault(frame_obj, exc) * */ - if (__Pyx_PyObject_SetAttrStr(__pyx_v_additional_info, __pyx_n_s_is_tracing, Py_False) < 0) __PYX_ERR(0, 86, __pyx_L1_error) + if (__Pyx_PyObject_SetAttrStr(__pyx_v_additional_info, __pyx_n_s_is_tracing, Py_False) < 0) __PYX_ERR(0, 90, __pyx_L1_error) - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":35 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":36 * skip_file = True * * if not skip_file: # <<<<<<<<<<<<<< @@ -2730,7 +2814,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec */ } - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":87 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":91 * * additional_info.is_tracing = False * return _PyEval_EvalFrameDefault(frame_obj, exc) # <<<<<<<<<<<<<< @@ -2740,7 +2824,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec __pyx_r = _PyEval_EvalFrameDefault(__pyx_v_frame_obj, __pyx_v_exc); goto __pyx_L0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":18 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":19 * get_file_type = DONT_TRACE.get * * cdef PyObject* get_bytecode_while_frame_eval(PyFrameObject *frame_obj, int exc): # <<<<<<<<<<<<<< @@ -2781,7 +2865,7 @@ static PyObject *__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytec return __pyx_r; } -/* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":89 +/* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 * return _PyEval_EvalFrameDefault(frame_obj, exc) * * def frame_eval_func(): # <<<<<<<<<<<<<< @@ -2809,7 +2893,7 @@ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_frame_ev __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("frame_eval_func", 0); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":90 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":94 * * def frame_eval_func(): * cdef PyThreadState *state = PyThreadState_Get() # <<<<<<<<<<<<<< @@ -2818,7 +2902,7 @@ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_frame_ev */ __pyx_v_state = PyThreadState_Get(); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":91 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":95 * def frame_eval_func(): * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = get_bytecode_while_frame_eval # <<<<<<<<<<<<<< @@ -2827,7 +2911,7 @@ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_frame_ev */ __pyx_v_state->interp->eval_frame = __pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytecode_while_frame_eval; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":89 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 * return _PyEval_EvalFrameDefault(frame_obj, exc) * * def frame_eval_func(): # <<<<<<<<<<<<<< @@ -2842,7 +2926,7 @@ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_frame_ev return __pyx_r; } -/* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 +/* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":97 * state.interp.eval_frame = get_bytecode_while_frame_eval * * def stop_frame_eval(): # <<<<<<<<<<<<<< @@ -2870,7 +2954,7 @@ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_2stop_fr __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stop_frame_eval", 0); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":94 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":98 * * def stop_frame_eval(): * cdef PyThreadState *state = PyThreadState_Get() # <<<<<<<<<<<<<< @@ -2878,14 +2962,14 @@ static PyObject *__pyx_pf_18_pydevd_frame_eval_22pydevd_frame_evaluator_2stop_fr */ __pyx_v_state = PyThreadState_Get(); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":95 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":99 * def stop_frame_eval(): * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = _PyEval_EvalFrameDefault # <<<<<<<<<<<<<< */ __pyx_v_state->interp->eval_frame = _PyEval_EvalFrameDefault; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":97 * state.interp.eval_frame = get_bytecode_while_frame_eval * * def stop_frame_eval(): # <<<<<<<<<<<<<< @@ -2925,9 +3009,11 @@ static struct PyModuleDef __pyx_moduledef = { static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_AVOID_RECURSION, __pyx_k_AVOID_RECURSION, sizeof(__pyx_k_AVOID_RECURSION), 0, 0, 1, 1}, {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1}, + {&__pyx_n_s_CMD_THREAD_SUSPEND, __pyx_k_CMD_THREAD_SUSPEND, sizeof(__pyx_k_CMD_THREAD_SUSPEND), 0, 0, 1, 1}, {&__pyx_n_s_DONT_TRACE, __pyx_k_DONT_TRACE, sizeof(__pyx_k_DONT_TRACE), 0, 0, 1, 1}, {&__pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER, __pyx_k_NORM_PATHS_AND_BASE_CONTAINER, sizeof(__pyx_k_NORM_PATHS_AND_BASE_CONTAINER), 0, 0, 1, 1}, {&__pyx_n_s_PyDBAdditionalThreadInfo, __pyx_k_PyDBAdditionalThreadInfo, sizeof(__pyx_k_PyDBAdditionalThreadInfo), 0, 0, 1, 1}, + {&__pyx_n_s_STATE_SUSPEND, __pyx_k_STATE_SUSPEND, sizeof(__pyx_k_STATE_SUSPEND), 0, 0, 1, 1}, {&__pyx_n_s_SetTrace, __pyx_k_SetTrace, sizeof(__pyx_k_SetTrace), 0, 0, 1, 1}, {&__pyx_n_s_additional_info, __pyx_k_additional_info, sizeof(__pyx_k_additional_info), 0, 0, 1, 1}, {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1}, @@ -2953,12 +3039,15 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_is_tracing, __pyx_k_is_tracing, sizeof(__pyx_k_is_tracing), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_plugin, __pyx_k_plugin, sizeof(__pyx_k_plugin), 0, 0, 1, 1}, + {&__pyx_n_s_process_internal_commands, __pyx_k_process_internal_commands, sizeof(__pyx_k_process_internal_commands), 0, 0, 1, 1}, {&__pyx_n_s_pydev_do_not_trace, __pyx_k_pydev_do_not_trace, sizeof(__pyx_k_pydev_do_not_trace), 0, 0, 1, 1}, {&__pyx_n_s_pydev_imps__pydev_saved_modules, __pyx_k_pydev_imps__pydev_saved_modules, sizeof(__pyx_k_pydev_imps__pydev_saved_modules), 0, 0, 1, 1}, + {&__pyx_n_s_pydev_state, __pyx_k_pydev_state, sizeof(__pyx_k_pydev_state), 0, 0, 1, 1}, {&__pyx_n_s_pydev_trace_code_wrapper, __pyx_k_pydev_trace_code_wrapper, sizeof(__pyx_k_pydev_trace_code_wrapper), 0, 0, 1, 1}, {&__pyx_kp_s_pydevd_additional_thread_info_re, __pyx_k_pydevd_additional_thread_info_re, sizeof(__pyx_k_pydevd_additional_thread_info_re), 0, 0, 1, 0}, {&__pyx_n_s_pydevd_bundle_pydevd_additional, __pyx_k_pydevd_bundle_pydevd_additional, sizeof(__pyx_k_pydevd_bundle_pydevd_additional), 0, 0, 1, 1}, {&__pyx_n_s_pydevd_bundle_pydevd_comm, __pyx_k_pydevd_bundle_pydevd_comm, sizeof(__pyx_k_pydevd_bundle_pydevd_comm), 0, 0, 1, 1}, + {&__pyx_n_s_pydevd_bundle_pydevd_constants, __pyx_k_pydevd_bundle_pydevd_constants, sizeof(__pyx_k_pydevd_bundle_pydevd_constants), 0, 0, 1, 1}, {&__pyx_n_s_pydevd_bundle_pydevd_dont_trace, __pyx_k_pydevd_bundle_pydevd_dont_trace, sizeof(__pyx_k_pydevd_bundle_pydevd_dont_trace), 0, 0, 1, 1}, {&__pyx_n_s_pydevd_file_utils, __pyx_k_pydevd_file_utils, sizeof(__pyx_k_pydevd_file_utils), 0, 0, 1, 1}, {&__pyx_n_s_pydevd_frame_eval_pydevd_frame, __pyx_k_pydevd_frame_eval_pydevd_frame, sizeof(__pyx_k_pydevd_frame_eval_pydevd_frame), 0, 0, 1, 1}, @@ -2967,6 +3056,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_set_trace_for_frame_and_parents, __pyx_k_set_trace_for_frame_and_parents, sizeof(__pyx_k_set_trace_for_frame_and_parents), 0, 0, 1, 1}, {&__pyx_n_s_state, __pyx_k_state, sizeof(__pyx_k_state), 0, 0, 1, 1}, {&__pyx_n_s_stop_frame_eval, __pyx_k_stop_frame_eval, sizeof(__pyx_k_stop_frame_eval), 0, 0, 1, 1}, + {&__pyx_n_s_stop_reason, __pyx_k_stop_reason, sizeof(__pyx_k_stop_reason), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_threading, __pyx_k_threading, sizeof(__pyx_k_threading), 0, 0, 1, 1}, {&__pyx_kp_s_threading_py, __pyx_k_threading_py, sizeof(__pyx_k_threading_py), 0, 0, 1, 0}, @@ -2976,7 +3066,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 40, __pyx_L1_error) + __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 41, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; @@ -2986,29 +3076,29 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":89 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 * return _PyEval_EvalFrameDefault(frame_obj, exc) * * def frame_eval_func(): # <<<<<<<<<<<<<< * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = get_bytecode_while_frame_eval */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_n_s_state); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 89, __pyx_L1_error) + __pyx_tuple_ = PyTuple_Pack(1, __pyx_n_s_state); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 93, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); - __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_user_work_ultimate_communi, __pyx_n_s_frame_eval_func, 89, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 89, __pyx_L1_error) + __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_user_work_ultimate_communi, __pyx_n_s_frame_eval_func, 93, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 93, __pyx_L1_error) - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":97 * state.interp.eval_frame = get_bytecode_while_frame_eval * * def stop_frame_eval(): # <<<<<<<<<<<<<< * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = _PyEval_EvalFrameDefault */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_state); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 93, __pyx_L1_error) + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_state); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); - __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_user_work_ultimate_communi, __pyx_n_s_stop_frame_eval, 93, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 93, __pyx_L1_error) + __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_user_work_ultimate_communi, __pyx_n_s_stop_frame_eval, 97, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -3130,7 +3220,7 @@ PyMODINIT_FUNC PyInit_pydevd_frame_evaluator(void) * import dis * from _pydev_imps._pydev_saved_modules import threading # <<<<<<<<<<<<<< * from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo - * from _pydevd_bundle.pydevd_comm import get_global_debugger + * from _pydevd_bundle.pydevd_comm import get_global_debugger, CMD_THREAD_SUSPEND */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); @@ -3150,8 +3240,8 @@ PyMODINIT_FUNC PyInit_pydevd_frame_evaluator(void) * import dis * from _pydev_imps._pydev_saved_modules import threading * from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo # <<<<<<<<<<<<<< - * from _pydevd_bundle.pydevd_comm import get_global_debugger - * from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE + * from _pydevd_bundle.pydevd_comm import get_global_debugger, CMD_THREAD_SUSPEND + * from _pydevd_bundle.pydevd_constants import STATE_SUSPEND */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); @@ -3170,15 +3260,18 @@ PyMODINIT_FUNC PyInit_pydevd_frame_evaluator(void) /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":4 * from _pydev_imps._pydev_saved_modules import threading * from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo - * from _pydevd_bundle.pydevd_comm import get_global_debugger # <<<<<<<<<<<<<< + * from _pydevd_bundle.pydevd_comm import get_global_debugger, CMD_THREAD_SUSPEND # <<<<<<<<<<<<<< + * from _pydevd_bundle.pydevd_constants import STATE_SUSPEND * from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE - * from _pydevd_frame_eval.pydevd_frame_tracing import pydev_trace_code_wrapper, update_globals_dict */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) + __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_get_global_debugger); __Pyx_GIVEREF(__pyx_n_s_get_global_debugger); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_get_global_debugger); + __Pyx_INCREF(__pyx_n_s_CMD_THREAD_SUSPEND); + __Pyx_GIVEREF(__pyx_n_s_CMD_THREAD_SUSPEND); + PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_CMD_THREAD_SUSPEND); __pyx_t_2 = __Pyx_Import(__pyx_n_s_pydevd_bundle_pydevd_comm, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -3186,175 +3279,200 @@ PyMODINIT_FUNC PyInit_pydevd_frame_evaluator(void) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_global_debugger, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_CMD_THREAD_SUSPEND); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_CMD_THREAD_SUSPEND, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":5 * from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo - * from _pydevd_bundle.pydevd_comm import get_global_debugger - * from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE # <<<<<<<<<<<<<< + * from _pydevd_bundle.pydevd_comm import get_global_debugger, CMD_THREAD_SUSPEND + * from _pydevd_bundle.pydevd_constants import STATE_SUSPEND # <<<<<<<<<<<<<< + * from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE * from _pydevd_frame_eval.pydevd_frame_tracing import pydev_trace_code_wrapper, update_globals_dict - * from _pydevd_frame_eval.pydevd_modify_bytecode import insert_code */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_n_s_DONT_TRACE); - __Pyx_GIVEREF(__pyx_n_s_DONT_TRACE); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_DONT_TRACE); - __pyx_t_1 = __Pyx_Import(__pyx_n_s_pydevd_bundle_pydevd_dont_trace, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error) + __Pyx_INCREF(__pyx_n_s_STATE_SUSPEND); + __Pyx_GIVEREF(__pyx_n_s_STATE_SUSPEND); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_STATE_SUSPEND); + __pyx_t_1 = __Pyx_Import(__pyx_n_s_pydevd_bundle_pydevd_constants, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_DONT_TRACE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_STATE_SUSPEND); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_DONT_TRACE, __pyx_t_2) < 0) __PYX_ERR(0, 5, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_STATE_SUSPEND, __pyx_t_2) < 0) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":6 - * from _pydevd_bundle.pydevd_comm import get_global_debugger + * from _pydevd_bundle.pydevd_comm import get_global_debugger, CMD_THREAD_SUSPEND + * from _pydevd_bundle.pydevd_constants import STATE_SUSPEND + * from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE # <<<<<<<<<<<<<< + * from _pydevd_frame_eval.pydevd_frame_tracing import pydev_trace_code_wrapper, update_globals_dict + * from _pydevd_frame_eval.pydevd_modify_bytecode import insert_code + */ + __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_n_s_DONT_TRACE); + __Pyx_GIVEREF(__pyx_n_s_DONT_TRACE); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_DONT_TRACE); + __pyx_t_2 = __Pyx_Import(__pyx_n_s_pydevd_bundle_pydevd_dont_trace, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_DONT_TRACE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_DONT_TRACE, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":7 + * from _pydevd_bundle.pydevd_constants import STATE_SUSPEND * from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE * from _pydevd_frame_eval.pydevd_frame_tracing import pydev_trace_code_wrapper, update_globals_dict # <<<<<<<<<<<<<< * from _pydevd_frame_eval.pydevd_modify_bytecode import insert_code * from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame, NORM_PATHS_AND_BASE_CONTAINER */ - __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_pydev_trace_code_wrapper); __Pyx_GIVEREF(__pyx_n_s_pydev_trace_code_wrapper); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_pydev_trace_code_wrapper); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_pydev_trace_code_wrapper); __Pyx_INCREF(__pyx_n_s_update_globals_dict); __Pyx_GIVEREF(__pyx_n_s_update_globals_dict); - PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_update_globals_dict); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_pydevd_frame_eval_pydevd_frame, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_pydev_trace_code_wrapper); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) + PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_update_globals_dict); + __pyx_t_1 = __Pyx_Import(__pyx_n_s_pydevd_frame_eval_pydevd_frame, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_pydev_trace_code_wrapper, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_update_globals_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_update_globals_dict, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_pydev_trace_code_wrapper); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_pydev_trace_code_wrapper, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_update_globals_dict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_update_globals_dict, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":7 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":8 * from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE * from _pydevd_frame_eval.pydevd_frame_tracing import pydev_trace_code_wrapper, update_globals_dict * from _pydevd_frame_eval.pydevd_modify_bytecode import insert_code # <<<<<<<<<<<<<< * from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame, NORM_PATHS_AND_BASE_CONTAINER * */ - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_insert_code); __Pyx_GIVEREF(__pyx_n_s_insert_code); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_insert_code); - __pyx_t_1 = __Pyx_Import(__pyx_n_s_pydevd_frame_eval_pydevd_modify, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_insert_code); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_insert_code); + __pyx_t_2 = __Pyx_Import(__pyx_n_s_pydevd_frame_eval_pydevd_modify, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_insert_code, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_insert_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_insert_code, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":8 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":9 * from _pydevd_frame_eval.pydevd_frame_tracing import pydev_trace_code_wrapper, update_globals_dict * from _pydevd_frame_eval.pydevd_modify_bytecode import insert_code * from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame, NORM_PATHS_AND_BASE_CONTAINER # <<<<<<<<<<<<<< * * AVOID_RECURSION = [ */ - __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_get_abs_path_real_path_and_base); __Pyx_GIVEREF(__pyx_n_s_get_abs_path_real_path_and_base); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_get_abs_path_real_path_and_base); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_get_abs_path_real_path_and_base); __Pyx_INCREF(__pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); __Pyx_GIVEREF(__pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); - PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_pydevd_file_utils, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_get_abs_path_real_path_and_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) + PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); + __pyx_t_1 = __Pyx_Import(__pyx_n_s_pydevd_file_utils, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_abs_path_real_path_and_base, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_get_abs_path_real_path_and_base); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_abs_path_real_path_and_base, __pyx_t_2) < 0) __PYX_ERR(0, 9, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_NORM_PATHS_AND_BASE_CONTAINER, __pyx_t_2) < 0) __PYX_ERR(0, 9, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":10 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":11 * from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame, NORM_PATHS_AND_BASE_CONTAINER * * AVOID_RECURSION = [ # <<<<<<<<<<<<<< * 'pydevd_additional_thread_info_regular.py', * 'threading.py', */ - __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_kp_s_pydevd_additional_thread_info_re); __Pyx_GIVEREF(__pyx_kp_s_pydevd_additional_thread_info_re); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_kp_s_pydevd_additional_thread_info_re); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_kp_s_pydevd_additional_thread_info_re); __Pyx_INCREF(__pyx_kp_s_threading_py); __Pyx_GIVEREF(__pyx_kp_s_threading_py); - PyList_SET_ITEM(__pyx_t_2, 1, __pyx_kp_s_threading_py); + PyList_SET_ITEM(__pyx_t_1, 1, __pyx_kp_s_threading_py); __Pyx_INCREF(__pyx_kp_s_weakrefset_py); __Pyx_GIVEREF(__pyx_kp_s_weakrefset_py); - PyList_SET_ITEM(__pyx_t_2, 2, __pyx_kp_s_weakrefset_py); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_AVOID_RECURSION, __pyx_t_2) < 0) __PYX_ERR(0, 10, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + PyList_SET_ITEM(__pyx_t_1, 2, __pyx_kp_s_weakrefset_py); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_AVOID_RECURSION, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":16 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":17 * ] * * get_file_type = DONT_TRACE.get # <<<<<<<<<<<<<< * * cdef PyObject* get_bytecode_while_frame_eval(PyFrameObject *frame_obj, int exc): */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_DONT_TRACE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_DONT_TRACE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_file_type, __pyx_t_1) < 0) __PYX_ERR(0, 16, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_file_type, __pyx_t_2) < 0) __PYX_ERR(0, 17, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":89 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 * return _PyEval_EvalFrameDefault(frame_obj, exc) * * def frame_eval_func(): # <<<<<<<<<<<<<< * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = get_bytecode_while_frame_eval */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_1frame_eval_func, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_frame_eval_func, __pyx_t_1) < 0) __PYX_ERR(0, 89, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_1frame_eval_func, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_frame_eval_func, __pyx_t_2) < 0) __PYX_ERR(0, 93, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":93 + /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":97 * state.interp.eval_frame = get_bytecode_while_frame_eval * * def stop_frame_eval(): # <<<<<<<<<<<<<< * cdef PyThreadState *state = PyThreadState_Get() * state.interp.eval_frame = _PyEval_EvalFrameDefault */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_3stop_frame_eval, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_stop_frame_eval, __pyx_t_1) < 0) __PYX_ERR(0, 93, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_18_pydevd_frame_eval_22pydevd_frame_evaluator_3stop_frame_eval, NULL, __pyx_n_s_pydevd_frame_eval_pydevd_frame_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_stop_frame_eval, __pyx_t_2) < 0) __PYX_ERR(0, 97, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "_pydevd_frame_eval/pydevd_frame_evaluator.pyx":1 * import dis # <<<<<<<<<<<<<< * from _pydev_imps._pydev_saved_modules import threading * from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /*--- Wrapped vars code ---*/ diff --git a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.pyx b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.pyx index 4c7a9d468e69..bc8da6cdfefc 100644 --- a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.pyx +++ b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator.pyx @@ -1,7 +1,8 @@ import dis from _pydev_imps._pydev_saved_modules import threading from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo -from _pydevd_bundle.pydevd_comm import get_global_debugger +from _pydevd_bundle.pydevd_comm import get_global_debugger, CMD_THREAD_SUSPEND +from _pydevd_bundle.pydevd_constants import STATE_SUSPEND from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE from _pydevd_frame_eval.pydevd_frame_tracing import pydev_trace_code_wrapper, update_globals_dict from _pydevd_frame_eval.pydevd_modify_bytecode import insert_code @@ -56,6 +57,9 @@ cdef PyObject* get_bytecode_while_frame_eval(PyFrameObject *frame_obj, int exc): return _PyEval_EvalFrameDefault(frame_obj, exc) main_debugger = get_global_debugger() + if additional_info.pydev_state == STATE_SUSPEND and t.stop_reason == CMD_THREAD_SUSPEND: + main_debugger.process_internal_commands() + breakpoints = main_debugger.breakpoints.get(abs_path_real_path_and_base[1]) if breakpoints: was_break = False diff --git a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_tracing.py b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_tracing.py index 46ee91f9ce72..2cf662f63d59 100644 --- a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_tracing.py +++ b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_tracing.py @@ -12,10 +12,11 @@ def update_globals_dict(globals_dict): globals_dict.update(new_globals) -def handle_breakpoint(frame, info, global_debugger, breakpoint): +def handle_breakpoint(frame, thread, global_debugger, breakpoint): # ok, hit breakpoint, now, we have to discover if it is a conditional breakpoint new_frame = frame condition = breakpoint.condition + info = thread.additional_info if condition is not None: try: val = eval(condition, new_frame.f_globals, new_frame.f_locals) @@ -58,6 +59,10 @@ def handle_breakpoint(frame, info, global_debugger, breakpoint): finally: if val is not None: info.pydev_message = str(val) + + if breakpoint.suspend_policy == "ALL": + global_debugger.suspend_all_other_threads(thread) + return True @@ -94,7 +99,7 @@ def _pydev_stop_at_break(): except KeyError: pydev_log.debug("Couldn't find breakpoint in the file {} on line {}".format(frame.f_code.co_filename, line)) return - if breakpoint and handle_breakpoint(frame, t.additional_info, debugger, breakpoint): + if breakpoint and handle_breakpoint(frame, t, debugger, breakpoint): pydev_log.debug("Suspending at breakpoint in file: {} on line {}".format(frame.f_code.co_filename, line)) debugger.set_suspend(t, CMD_SET_BREAK) debugger.do_wait_suspend(t, frame, 'line', None) diff --git a/python/helpers/pydev/pydevd.py b/python/helpers/pydev/pydevd.py index bd390986603f..c9e990f64245 100644 --- a/python/helpers/pydev/pydevd.py +++ b/python/helpers/pydev/pydevd.py @@ -670,6 +670,11 @@ class PyDB: if stop_reason == CMD_SET_BREAK and self.suspend_on_breakpoint_exception: self._send_breakpoint_condition_exception(thread) + if self.frame_eval_func is not None and stop_reason == CMD_THREAD_SUSPEND: + thread_id = get_thread_id(thread) + int_cmd = InternalSetTracingThread(thread_id) + self.post_internal_command(int_cmd, thread_id) + def _send_breakpoint_condition_exception(self, thread): """If conditional breakpoint raises an exception during evaluation diff --git a/python/testData/debug/test_two_threads.py b/python/testData/debug/test_two_threads.py index 49d229678ec3..9d18dfb8fd4e 100644 --- a/python/testData/debug/test_two_threads.py +++ b/python/testData/debug/test_two_threads.py @@ -2,17 +2,20 @@ from threading import Thread from time import sleep +def print_with_pause(text, pause): + sleep(pause) + print(text) + + def fun1(n): while True: - sleep(0.01) - print("finished fun1()", n) + print_with_pause("Thread1", 0.1) def fun2(m): sleep(2) while True: - sleep(0.01) #breakpoint - print("finished fun2()", m) + print_with_pause("Thread2", 0.1) # breakpoint threads = [Thread(target=fun1, args=(24,), name="Thread1"), diff --git a/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java b/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java index 3f7a004aedb2..68a674c00ac6 100644 --- a/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java +++ b/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java @@ -1002,8 +1002,8 @@ public class PythonDebuggerTest extends PyEnvTestCase { @Override public void before() throws Exception { - toggleBreakpoint(getFilePath(getScriptName()), 12); - setBreakpointSuspendPolicy(getProject(), 12, SuspendPolicy.ALL); + toggleBreakpoint(getFilePath(getScriptName()), 17); + setBreakpointSuspendPolicy(getProject(), 17, SuspendPolicy.ALL); } @Override @@ -1056,8 +1056,8 @@ public class PythonDebuggerTest extends PyEnvTestCase { runPythonTest(new PyDebuggerTask("/debug", "test_two_threads.py") { @Override public void before() throws Exception { - toggleBreakpoint(getFilePath(getScriptName()), 12); - setBreakpointSuspendPolicy(getProject(), 12, SuspendPolicy.THREAD); + toggleBreakpoint(getFilePath(getScriptName()), 17); + setBreakpointSuspendPolicy(getProject(), 17, SuspendPolicy.THREAD); } @Override From 5aa12ad9ebd0c8ea372b5eed4ecdf279b7457ace Mon Sep 17 00:00:00 2001 From: Elizaveta Shashkova Date: Mon, 13 Feb 2017 20:45:58 +0300 Subject: [PATCH 19/96] Update windows binaries (PY-22450, PY-22454) --- ...frame_evaluator_win32_36_32.cp36-win32.pyd | Bin 47616 -> 49152 bytes ...e_evaluator_win32_36_64.cp36-win_amd64.pyd | Bin 54272 -> 55808 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator_win32_36_32.cp36-win32.pyd b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator_win32_36_32.cp36-win32.pyd index 1676601c7682cb089d5984e6ee84b30e92e42a80..6a7a125d21edc88d5ca9d4448c5e6f7782eb0dca 100644 GIT binary patch delta 23936 zcmeHvdt6ji_xBkb1a)vmVGtA*ZM>t-%$XZ=0~8bs6BO_FYeeRCC{1ioAfY3r9y2R5 zQ8OzmOP{nd!|+K=R5UA}^htZNI)oOMk6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8mP?ka2vZH4$fmGq ztc7*6S?ulX1h$Y}%09?ev0K>f>`wMgwub$X{e(TkUS)q}z&p@ z>n!U7*4M2mw*Iyewvo0ewxuE4O51kZPTQNdcWpJcTH7((8QXc=w>Ht%&7NlOhcNTo z$J+0-&$i!fzt{eNeS>|A{ffQ7QSRU!)sE*8PP-lZ93MH(IKFaRas28~JCmGl=iP{= z$DLc9uRFhV_IK5~zII)5U2*;F>gG;&4{(og+uS8exeM)azwaJ_YB$*D@s0OQ_O0^O z`cCgpgh0_{v6mFU}j?9 z4fnJ&bu{Tr-A%WcO5v34rdLdFnD&~!GG&<$m_Ik4M=@(Kx3?r(k}SO}w_0Xe=7lT^ zEG3pI%O5R&w!C2Z3>EGlmVa4(v9x2mvL=}L4{R*cZ_g29X`is$ES{O z9N#+{VW&RGy5UZzGc?Wlg7a_AOU{w5+g(#!i(DnHRjx-}Pf3Y&-POUJ)_Hri;}u7pBXkL2^Rpw~ zsdaXBra6bA6lFQbJEtLp?su+65IyPK)y0+W%5ZsH<6H%< z*{)L86Rs^NNpHFix=y&hbS1ibyN9@4?(y!s5N7YA_{4d3c=mfN-o@UP-b(Lg@AH^T z1n*Fv!#6hMyVEzzcdzeZ-&)_Fd~f*P_kHDS@EI|!j7Ip)^WW!x%74WFcmKeEIglAx zhH2*A!1q)SR?EMd+s-uDWWuaD6QTB&>6Gak(?3oBF?BKbMBd+L-eTTij<*c3SS%wg zYc1<7+bnNdYAlVGUoBqDFb}bZSl7Ss;H9%Q-#XL!mi0aBSxgPrtiM^`Ll}LI2{g?< z&%VUI*8aKuqJ5Af%YnJN3hzVWQp?ZVcV-~tIppy|uZ-GAt%b YjwRPZo7xNftoJ@sYrT3e4nH#g7eFhgR{#J2 diff --git a/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator_win32_36_64.cp36-win_amd64.pyd b/python/helpers/pydev/_pydevd_frame_eval/pydevd_frame_evaluator_win32_36_64.cp36-win_amd64.pyd index 82079b332da05aea5e45e2b446459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yM5W<~TItU+DkE5q(+~e!YEPBH z!@-wbXfBx8{VGF{;2rm#N*Ks8E=2kXZWS!!d^B5D<>&7b&Hn6NXEgq6)zhyIK{^>dqUO0j6cL;0w{gM+A;b=oP>os*3c;%oR*^Y{NxwqaJ9ucUuY|q7LmQ&;Be?+v0u&o!oeRo9kT^tbw zmkCvpgen7h?M_h}DRfDI`$YS15!MDh9s6PVOF9h4>2fzW0$Bo29 z%#!2MBy41_0s|0K%$=55BRgl{|R^& zw-QaLcLA>GDoO3ZGaqoN&4BO_g=K(ykx1A+z+)m$@S@1q0Ddp>1pgFyf;|!Zk;UnN zbuoy3kZ%MG>yGFMc>_VDbix75K*~hkmV?YVBohj`fUA-C*Z@``5mS13UuaY^9fU5?=n~^UBtfYi|a~Q6MHd{7E{GZj97{1(7#Nd1wo1GJ4942`J)a7P;a0Qp+LAw%E~$mamw z9SRGOZv>n^3>F|yA9<}sDn@<_pp=f`Kt2et0ckhkWMCaYdWZ7EC28^qNjiyq9-tu; z!~P-0e;G3BNkWBxq1*%{f<3a}!6(q=fc!v#Ji#*~QHMOiDx_TG3En^|M7|F2%TZ7a z`9{FyCQM1>3jx1GI!g6`F;g-A6(}T4#lI6msv#u6KGVSr`E5l1{=20e{_wBPjAY3}2Zb^+vu9@XhU*j>uPJB6AkW4-QBN z@^6uXK2V|04mD3O6=^N%364XmMm`U)5Gknq%=J;eKKoxg!rI-w8Cr4}@{gbzU}0I@ jzVv-2_RrflbzvyymMtsWSyondtgM3VIT(TPD&+qGjcZ{3 From 7340a915ca0133cb19ab31f51e2608d284788825 Mon Sep 17 00:00:00 2001 From: "Anna.Kozlova" Date: Tue, 14 Feb 2017 13:36:06 +0100 Subject: [PATCH 20/96] don't show information tooltip: other implementation (IDEA-CR-18014) --- .../codeInsight/daemon/impl/DaemonTooltipUtil.java | 2 -- .../daemon/impl/LocalInspectionsPass.java | 13 +++++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipUtil.java index 24b83c685eee..dc7a9ed89861 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipUtil.java @@ -18,7 +18,6 @@ package com.intellij.codeInsight.daemon.impl; import com.intellij.codeInsight.hint.TooltipController; import com.intellij.codeInsight.hint.TooltipGroup; -import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.editor.Editor; import com.intellij.ui.HintHint; import org.jetbrains.annotations.NotNull; @@ -46,7 +45,6 @@ public class DaemonTooltipUtil { public static void showInfoTooltip(@NotNull final HighlightInfo info, @NotNull Editor editor, final int defaultOffset, final int currentWidth, final boolean requestFocus) { if (info.getToolTip() == null) return; - if (HighlightSeverity.INFORMATION.equals(info.getSeverity())) return; Rectangle visibleArea = editor.getScrollingModel().getVisibleArea(); Point bestPoint = editor.logicalPositionToXY(editor.offsetToLogicalPosition(defaultOffset)); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java index f693233e86df..138064c40cd3 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java @@ -355,13 +355,22 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass .range(psiElement, textRange.getStartOffset(), textRange.getEndOffset()) .description(message) .severity(severity); - if (toolTip != null) b.escapedToolTip(toolTip); + boolean invisible = HighlightSeverity.INFORMATION.equals(severity); + if (toolTip != null && !invisible) b.escapedToolTip(toolTip); if (attributes != null) b.textAttributes(attributes); if (problemDescriptor.isAfterEndOfLine()) b.endOfLine(); if (isFileLevel) b.fileLevelAnnotation(); if (problemDescriptor.getProblemGroup() != null) b.problemGroup(problemDescriptor.getProblemGroup()); + if (!invisible) return b.create(); - return b.create(); + HighlightInfo info = b.createUnconditionally(); + for (HighlightInfoFilter filter : HighlightInfoFilter.EXTENSION_POINT_NAME.getExtensions()) { + if (!(filter instanceof HighlightInfoFilterImpl) && !filter.accept(info, myFile)) { + return null; + } + } + info.psiElement = psiElement; + return info; } private final Map ranges2markersCache = new THashMap<>(); From f171787aa37bb74b2b8ca93cfaa024b86c7101f8 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Tue, 14 Feb 2017 13:18:11 +0300 Subject: [PATCH 21/96] fix SearchEverywhere renderer according to WideSelectionListUI --- .../intellij/ide/actions/SearchEverywhereAction.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java index 1e9edb5cca3e..5cb8a77b4bd6 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java @@ -101,7 +101,6 @@ import com.intellij.psi.codeStyle.NameUtil; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.ui.*; import com.intellij.ui.awt.RelativePoint; -import com.intellij.ui.border.CustomLineBorder; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBScrollPane; @@ -124,6 +123,7 @@ import org.jetbrains.annotations.Nullable; import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.swing.*; +import javax.swing.border.Border; import javax.swing.event.DocumentEvent; import java.awt.*; import java.awt.event.*; @@ -152,6 +152,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA public static final int MAX_SEARCH_EVERYWHERE_HISTORY = 50; public static final int MAX_TOP_HIT = 15; private static final Logger LOG = Logger.getInstance("#" + SearchEverywhereAction.class.getName()); + private static final Border RENDERER_BORDER = JBUI.Borders.empty(0, 0, 2, 0); private SearchEverywhereAction.MyListRenderer myRenderer; MySearchTextField myPopupField; @@ -1099,14 +1100,17 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA cmp.setBackground(UIUtil.getListBackground(isSelected)); bg = cmp.getBackground(); } - myMainPanel.setBorder(new CustomLineBorder(bg, 0, 0, 2, 0)); String title = getModel().titleIndex.getTitle(index); myMainPanel.removeAll(); if (title != null) { myTitle.setText(title); myMainPanel.add(createTitle(" " + title), BorderLayout.NORTH); } - myMainPanel.add(cmp, BorderLayout.CENTER); + JPanel wrapped = new JPanel(new BorderLayout()); + wrapped.setBackground(bg); + wrapped.setBorder(RENDERER_BORDER); + wrapped.add(cmp, BorderLayout.CENTER); + myMainPanel.add(wrapped, BorderLayout.CENTER); if (cmp instanceof Accessible) { myMainPanel.setAccessible((Accessible)cmp); } From f02926b481c9165304f4bd89e7c17230443f791d Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Tue, 14 Feb 2017 15:48:19 +0300 Subject: [PATCH 22/96] swing.bufferPerWindow=true by default and do not use a custom repaint manager if possible --- bin/idea.properties | 7 +++++-- .../intellij/ide/BootstrapClassLoaderUtil.java | 1 - .../src/com/intellij/idea/IdeaApplication.java | 3 +-- platform/util/src/com/intellij/Patches.java | 6 ++++-- .../openapi/application/PathManager.java | 18 ------------------ .../src/com/intellij/util/ui/GraphicsUtil.java | 4 +--- 6 files changed, 11 insertions(+), 28 deletions(-) diff --git a/bin/idea.properties b/bin/idea.properties index cd6960d75f5c..47fe054b320a 100644 --- a/bin/idea.properties +++ b/bin/idea.properties @@ -80,9 +80,12 @@ sun.java2d.noddraw=true sun.java2d.d3d=false #--------------------------------------------------------------------- -# Workaround for slow scrolling in JDK6 +# Set swing.bufferPerWindow=false to workaround a slow scrolling in JDK6 (see IDEA-35883), +# But this may lead to performance degradation, because it disables a double buffering, +# which is needed to eliminate tearing on blit-accelerated scrolling and to restore +# a frame buffer content without the usual repainting, even when the EDT is blocked. #--------------------------------------------------------------------- -swing.bufferPerWindow=false +swing.bufferPerWindow=true #--------------------------------------------------------------------- # Removing this property may lead to editor performance degradation under X Window. diff --git a/platform/bootstrap/src/com/intellij/ide/BootstrapClassLoaderUtil.java b/platform/bootstrap/src/com/intellij/ide/BootstrapClassLoaderUtil.java index 0e84306e675f..72f186746272 100644 --- a/platform/bootstrap/src/com/intellij/ide/BootstrapClassLoaderUtil.java +++ b/platform/bootstrap/src/com/intellij/ide/BootstrapClassLoaderUtil.java @@ -50,7 +50,6 @@ public class BootstrapClassLoaderUtil extends ClassUtilCore { @NotNull public static ClassLoader initClassLoader(boolean updatePlugins) throws MalformedURLException { PathManager.loadProperties(); - PathManager.patchProperties(); Collection classpath = new LinkedHashSet(); addParentClasspath(classpath, false); diff --git a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java index 9ff02ff7a5a9..133890e04ebe 100644 --- a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java +++ b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java @@ -44,7 +44,6 @@ import com.intellij.ui.CustomProtocolHandler; import com.intellij.ui.Splash; import com.intellij.util.ArrayUtil; import com.intellij.util.IncorrectOperationException; -import com.intellij.util.SystemProperties; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -162,7 +161,7 @@ public class IdeaApplication { True double buffering is needed to eliminate tearing on blit-accelerated scrolling and to restore frame buffer content without the usual repainting, even when the EDT is blocked. */ - if (!SystemProperties.isTrueSmoothScrollingEnabled() && Patches.SUN_BUG_ID_6209673) { + if (Patches.REPAINT_MANAGER_LEAK) { RepaintManager.setCurrentManager(new IdeRepaintManager()); } diff --git a/platform/util/src/com/intellij/Patches.java b/platform/util/src/com/intellij/Patches.java index a16b212a355a..f59bd79170d5 100644 --- a/platform/util/src/com/intellij/Patches.java +++ b/platform/util/src/com/intellij/Patches.java @@ -40,12 +40,14 @@ public class Patches { public static final boolean SLOW_GETTING_CLIPBOARD_CONTENTS = SystemInfo.isUnix; /** - * See https://bugs.openjdk.java.net/browse/JDK-6209673. * Huge int[] leak through VolatileImages cached in RepaintManager whenever screen configuration changes. * For instance screen saver activates or computer goes hibernate. The problem still exists in 1.6 when two (or more) * monitors exists + * + *

http://bugs.openjdk.java.net/browse/JDK-6209673 + *

http://bugs.openjdk.java.net/browse/JDK-8041654 */ - public static final boolean SUN_BUG_ID_6209673 = true; + public static final boolean REPAINT_MANAGER_LEAK = !SystemInfo.isJavaVersionAtLeast("1.8.0_60"); /** * Desktop API support on X Window is limited to GNOME (and even there it may work incorrectly). diff --git a/platform/util/src/com/intellij/openapi/application/PathManager.java b/platform/util/src/com/intellij/openapi/application/PathManager.java index 5e2a8a2302b8..5832d69d04f0 100644 --- a/platform/util/src/com/intellij/openapi/application/PathManager.java +++ b/platform/util/src/com/intellij/openapi/application/PathManager.java @@ -384,24 +384,6 @@ public class PathManager { } } - /** - * Provides a way to tweak system properties as early as possible. - */ - public static void patchProperties() { - /* Setting swing.bufferPerWindow = false disables true double buffering (by definition), - by forcing BUFFER_STRATEGY_TYPE = BUFFER_STRATEGY_SPECIFIED_OFF in RepaintManager's static initializer. - - At the same time, https://youtrack.jetbrains.com/issue/IDEA-35883 seems to be now fixed. - - This matters only if we use the default RepaintManager and don't invoke JComponent.getGraphics() directly. - - True double buffering is needed to eliminate tearing on blit-accelerated scrolling and to restore - frame buffer content without the usual repainting, even when the EDT is blocked. */ - if (SystemProperties.isTrueSmoothScrollingEnabled()) { - System.setProperty("swing.bufferPerWindow", "true"); - } - } - private static String getCustomPropertiesFile() { String configPath = getCustomOptionsDirectory(); return configPath != null ? configPath + File.separator + PROPERTIES_FILE_NAME : null; diff --git a/platform/util/src/com/intellij/util/ui/GraphicsUtil.java b/platform/util/src/com/intellij/util/ui/GraphicsUtil.java index 5280c1cf3bb8..ac40641aeaa9 100644 --- a/platform/util/src/com/intellij/util/ui/GraphicsUtil.java +++ b/platform/util/src/com/intellij/util/ui/GraphicsUtil.java @@ -17,7 +17,6 @@ package com.intellij.util.ui; import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.util.MethodInvocator; -import com.intellij.util.SystemProperties; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -118,10 +117,9 @@ public class GraphicsUtil { * and don't forget to invoke {@link Graphics#dispose()} afterwards. * * @see JRootPane#disableTrueDoubleBuffering() - * @see JBViewport#isTrueDoubleBufferingAvailableFor(JComponent) */ public static Graphics safelyGetGraphics(Component c) { - return SystemProperties.isTrueSmoothScrollingEnabled() && ourSafelyGetGraphicsMethod.isAvailable() + return ourSafelyGetGraphicsMethod.isAvailable() ? (Graphics)ourSafelyGetGraphicsMethod.invoke(null, c) : c.getGraphics(); } From cb44cfee37903acd99a36bd053dd4196f9fcd094 Mon Sep 17 00:00:00 2001 From: "Liana.Bakradze" Date: Thu, 9 Feb 2017 13:58:15 +0300 Subject: [PATCH 23/96] PY-21412 Postfix .main triggers in comments --- .../jetbrains/python/codeInsight/postfix/PyPostfixUtils.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/src/com/jetbrains/python/codeInsight/postfix/PyPostfixUtils.java b/python/src/com/jetbrains/python/codeInsight/postfix/PyPostfixUtils.java index 73f9a41e7f17..164de6c08fa8 100644 --- a/python/src/com/jetbrains/python/codeInsight/postfix/PyPostfixUtils.java +++ b/python/src/com/jetbrains/python/codeInsight/postfix/PyPostfixUtils.java @@ -21,6 +21,7 @@ import com.intellij.codeInsight.template.postfix.templates.PostfixTemplatePsiInf import com.intellij.openapi.editor.Document; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Conditions; +import com.intellij.psi.PsiComment; import com.intellij.psi.PsiElement; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtilCore; @@ -99,6 +100,9 @@ public class PyPostfixUtils { @Override protected List getNonFilteredExpressions(@NotNull PsiElement context, @NotNull Document document, int offset) { PsiElement elementAtCaret = PsiUtilCore.getElementAtOffset(context.getContainingFile(), offset - 1); + if (elementAtCaret instanceof PsiComment) { + return Collections.emptyList(); + } while (elementAtCaret != null) { if (elementAtCaret instanceof PyStatement) { return Collections.singletonList(elementAtCaret); From 778c9cda7929fb9e97a2debd44a4104095b404bb Mon Sep 17 00:00:00 2001 From: "Liana.Bakradze" Date: Thu, 9 Feb 2017 14:00:16 +0300 Subject: [PATCH 24/96] remove explicit type arguments (PY-21412) --- .../python/codeInsight/postfix/PyPostfixUtils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/src/com/jetbrains/python/codeInsight/postfix/PyPostfixUtils.java b/python/src/com/jetbrains/python/codeInsight/postfix/PyPostfixUtils.java index 164de6c08fa8..082fa4fd5d52 100644 --- a/python/src/com/jetbrains/python/codeInsight/postfix/PyPostfixUtils.java +++ b/python/src/com/jetbrains/python/codeInsight/postfix/PyPostfixUtils.java @@ -77,11 +77,11 @@ public class PyPostfixUtils { } public static PostfixTemplateExpressionSelector selectorAllExpressionsWithCurrentOffset() { - return selectorAllExpressionsWithCurrentOffset(Conditions.alwaysTrue()); + return selectorAllExpressionsWithCurrentOffset(Conditions.alwaysTrue()); } public static PostfixTemplateExpressionSelector selectorTopmost() { - return selectorTopmost(Conditions.alwaysTrue()); + return selectorTopmost(Conditions.alwaysTrue()); } public static PostfixTemplateExpressionSelector selectorTopmost(Condition additionalFilter) { @@ -90,7 +90,7 @@ public class PyPostfixUtils { protected List getNonFilteredExpressions(@NotNull PsiElement context, @NotNull Document document, int offset) { PyExpressionStatement exprStatement = PsiTreeUtil.getNonStrictParentOfType(context, PyExpressionStatement.class); PyExpression expression = exprStatement != null ? PsiTreeUtil.getChildOfType(exprStatement, PyExpression.class) : null; - return ContainerUtil.createMaybeSingletonList(expression); + return ContainerUtil.createMaybeSingletonList(expression); } }; } From 30d2775737295bef1f2e9acae70d4fa23ee27ebf Mon Sep 17 00:00:00 2001 From: "Liana.Bakradze" Date: Tue, 14 Feb 2017 16:01:22 +0300 Subject: [PATCH 25/96] add test for main postfix template in comments --- python/testData/postfix/main/comment.py | 1 + python/testData/postfix/main/comment_after.py | 1 + .../jetbrains/python/postfix/PyMainPostfixTemplateTest.java | 4 ++++ 3 files changed, 6 insertions(+) create mode 100644 python/testData/postfix/main/comment.py create mode 100644 python/testData/postfix/main/comment_after.py diff --git a/python/testData/postfix/main/comment.py b/python/testData/postfix/main/comment.py new file mode 100644 index 000000000000..3de20ddc5eee --- /dev/null +++ b/python/testData/postfix/main/comment.py @@ -0,0 +1 @@ +print("I want to be inside main") #hello.main \ No newline at end of file diff --git a/python/testData/postfix/main/comment_after.py b/python/testData/postfix/main/comment_after.py new file mode 100644 index 000000000000..c74b41c9dab5 --- /dev/null +++ b/python/testData/postfix/main/comment_after.py @@ -0,0 +1 @@ +print("I want to be inside main") #hello.main \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/postfix/PyMainPostfixTemplateTest.java b/python/testSrc/com/jetbrains/python/postfix/PyMainPostfixTemplateTest.java index a7d199e5081c..09eae87d8c01 100644 --- a/python/testSrc/com/jetbrains/python/postfix/PyMainPostfixTemplateTest.java +++ b/python/testSrc/com/jetbrains/python/postfix/PyMainPostfixTemplateTest.java @@ -25,6 +25,10 @@ public class PyMainPostfixTemplateTest extends PyPostfixTemplateTestCase { doTest(); } + public void testComment() { + doTest(); + } + @Override protected String getTestDataDir() { return "main/"; From 568a32f3af2738e72f3235705b810c133bfd9acb Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Tue, 14 Feb 2017 16:07:52 +0300 Subject: [PATCH 26/96] PY-6398 Hide "Package successfully installed" notification when you start installing another package --- .../com/intellij/webcore/packaging/InstalledPackagesPanel.java | 1 + .../src/com/intellij/webcore/packaging/ManagePackagesDialog.java | 1 + 2 files changed, 2 insertions(+) diff --git a/platform/lang-impl/src/com/intellij/webcore/packaging/InstalledPackagesPanel.java b/platform/lang-impl/src/com/intellij/webcore/packaging/InstalledPackagesPanel.java index de1d102c51cb..148834789e93 100644 --- a/platform/lang-impl/src/com/intellij/webcore/packaging/InstalledPackagesPanel.java +++ b/platform/lang-impl/src/com/intellij/webcore/packaging/InstalledPackagesPanel.java @@ -152,6 +152,7 @@ public class InstalledPackagesPanel extends JPanel { new PackageManagementService.Listener() { @Override public void operationStarted(String packageName) { + myNotificationArea.hide(); myPackagesTable.setPaintBusy(true); } diff --git a/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java b/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java index 7b4b7dbce655..c5fd63f9a7c2 100644 --- a/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java +++ b/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java @@ -250,6 +250,7 @@ public class ManagePackagesDialog extends DialogWrapper { } private void handleInstallationStarted(String packageName) { + myNotificationArea.hide(); setDownloadStatus(true); myCurrentlyInstalling.add(packageName); if (myPackageListener != null) { From d363904bf92f8c6a981c9c4cea8458de60846d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Tue, 14 Feb 2017 15:00:52 +0100 Subject: [PATCH 27/96] [devkit] plugin.xml: add plugin@allow-bundled-update attribute --- plugins/devkit/src/dom/IdeaPlugin.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/devkit/src/dom/IdeaPlugin.java b/plugins/devkit/src/dom/IdeaPlugin.java index 3da0c73df278..bcbd35956435 100644 --- a/plugins/devkit/src/dom/IdeaPlugin.java +++ b/plugins/devkit/src/dom/IdeaPlugin.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,6 +56,9 @@ public interface IdeaPlugin extends DomElement { @NotNull GenericAttributeValue getUseIdeaClassloader(); + @NotNull + GenericAttributeValue getAllowBundledUpdate(); + @NotNull @Stubbed GenericDomValue getName(); From 9844a2ba44923c25f86e34dd03f6af55dae249b5 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Sat, 4 Feb 2017 20:14:46 +0300 Subject: [PATCH 28/96] diff: tests for UnifiedFragmentBuilder --- .../fragmented/UnifiedFragmentBuilderTest.kt | 402 +++++++++++++++--- 1 file changed, 342 insertions(+), 60 deletions(-) diff --git a/platform/diff-impl/tests/com/intellij/diff/tools/fragmented/UnifiedFragmentBuilderTest.kt b/platform/diff-impl/tests/com/intellij/diff/tools/fragmented/UnifiedFragmentBuilderTest.kt index f59a22baba1e..6503c4e82c43 100644 --- a/platform/diff-impl/tests/com/intellij/diff/tools/fragmented/UnifiedFragmentBuilderTest.kt +++ b/platform/diff-impl/tests/com/intellij/diff/tools/fragmented/UnifiedFragmentBuilderTest.kt @@ -17,83 +17,365 @@ package com.intellij.diff.tools.fragmented import com.intellij.diff.DiffTestCase import com.intellij.diff.comparison.ComparisonPolicy +import com.intellij.diff.comparison.iterables.DiffIterable +import com.intellij.diff.comparison.iterables.DiffIterableUtil +import com.intellij.diff.fragments.LineFragment +import com.intellij.diff.fragments.LineFragmentImpl import com.intellij.diff.util.LineRange +import com.intellij.diff.util.Range import com.intellij.diff.util.Side import com.intellij.openapi.editor.impl.DocumentImpl -import com.intellij.openapi.progress.DumbProgressIndicator +import junit.framework.TestCase +import java.util.* class UnifiedFragmentBuilderTest : DiffTestCase() { - fun testEquals() { - val builder = createBuilder("A\nB\nC", "A\nB\nC", Side.LEFT) + fun testSimple() { + Test("", "", + ".", + " ") + .run() - assertTrue(builder.isEqual) - assertEquals(builder.text.toString(), "A\nB\nC\n") - assertEmpty(builder.changedLines) - assertEmpty(builder.blocks) + Test("A_B_C", "A_B_C", + "A_B_C", + " _ _ ") + .run() + + // empty document has one line, so it's "modified" case (and not "deleted") + Test("A", "", + "A_.", + "L_R") + .run() + + Test("", "A", + "._A", + "L_R") + .run() + + Test("A_", "", + "A_.", + "L_ ") + .run() + + Test("A_", "B", + "A_._B", + "L_L_R") + .run() + + Test("B_", "B", + "B_.", + " _L") + .run() + + Test("_B", "B", + "._B", + "L_ ") + .run() + + Test("A_A", "B", + "A_A_B", + "L_L_R") + .run() + + Test("A_B_C_D", "A_D", + "A_B_C_D", + " _L_L_ ") + .run() + + Test("X_B_C", "A_B_C", + "X_A_B_C", + "L_R_ _ ") + .run() + + Test("A_B_C", "A_B_Y", + "A_B_C_Y", + " _ _L_R") + .run() + + Test("A_B_C_D_E_F", "A_X_C_D_Y_F", + "A_B_X_C_D_E_Y_F", + " _L_R_ _ _L_R_ ") + .run() + + Test("A_B_C_D_E_F", "A_B_X_C_D_F", + "A_B_X_C_D_E_F", + " _ _R_ _ _L_ ") + .run() + + Test("A_B_C_D_E_F", "A_B_X_Y_E_F", + "A_B_C_D_X_Y_E_F", + " _ _L_L_R_R_ _ ") + .run() + + Test("", "", + ".", + " ") + .changes() + .run() + + Test("A", "B", + "A_B", + "L_R") + .changes(mod(0, 0, 1, 1)) + .runLeft() + + Test("A", "B", + "A", + " ") + .changes() + .runLeft() + + Test("A", "B", + "B", + " ") + .changes() + .runRight() } - fun testWrongEndLineTypoBug() { - val builder = createBuilder("A\nB\nC\nD", "A\nD", Side.RIGHT) + fun testNonFair() { + Test("A_B", "", + "A_B", + " _ ") + .changes() + .runLeft() - assertFalse(builder.isEqual) - assertEquals(builder.text.toString(), "A\nB\nC\nD\n") - assertEquals(builder.changedLines, listOf(LineRange(1, 3))) + Test("A_B", "", + ".", + " ") + .changes() + .runRight() - assertEquals(builder.blocks.size, 1) - val block = builder.blocks[0] - assertEquals(block.line1, 1) - assertEquals(block.line2, 3) - assertEquals(block.range1.start, 1) - assertEquals(block.range1.end, 3) - assertEquals(block.range2.start, 3) - assertEquals(block.range2.end, 3) + Test("A_B", "A_._B", + "A_B", + " _ ") + .changes() + .runLeft() + + Test("A_B", "A_._B", + "A_._B", + " _ _ ") + .changes() + .runRight() + + Test("_._A_._", "X", + "._._A_X_._.", + " _ _L_R_ _ ") + .changes(mod(2, 0, 1, 1)) + .runLeft() + + Test("_._A_._", "X", + "A_X", + "L_R") + .changes(mod(2, 0, 1, 1)) + .runRight() + + Test("A_B_C_D", "X_BC_Y", + "A_X_BC_D_Y", + "L_R_ _L_R") + .changes(mod(0, 0, 1, 1), mod(3, 2, 1, 1)) + .runRight() + + Test("A_B_C_D", "A_BC_Y", + "A_BC_D_Y", + " _ _L_R") + .changes(mod(3, 2, 1, 1)) + .runRight() + + Test("AB_C_DE", "A_B_D_E", + "AB_C_DE", + " _L_ ") + .changes(del(1, 2, 1)) + .runLeft() + + Test("AB_C_DE", "A_B_D_E", + "A_B_C_D_E", + " _ _L_ _ ") + .changes(del(1, 2, 1)) + .runRight() + + Test("AB_DE", "A_B_C_D_E", + "AB_C_DE", + " _R_ ") + .changes(ins(1, 2, 1)) + .runLeft() + + Test("AB_DE", "A_B_C_D_E", + "A_B_C_D_E", + " _ _R_ _ ") + .changes(ins(1, 2, 1)) + .runRight() } - fun testFirstLineChange() { - val builder = createBuilder("X\nB\nC", "A\nB\nC", Side.RIGHT) + private inner class Test(val input1: String, val input2: String, + val result: String, + val lineMapping: String) { + private var customFragments: List? = null - assertFalse(builder.isEqual) - assertEquals(builder.text.toString(), "X\nA\nB\nC\n") - assertEquals(builder.changedLines, listOf(LineRange(0, 1), LineRange(1, 2))) + fun runLeft() { + doRun(Side.LEFT) + } - assertEquals(builder.blocks.size, 1) - val block = builder.blocks[0] - assertEquals(block.line1, 0) - assertEquals(block.line2, 2) - assertEquals(block.range1.start, 0) - assertEquals(block.range1.end, 1) - assertEquals(block.range2.start, 1) - assertEquals(block.range2.end, 2) + fun runRight() { + doRun(Side.RIGHT) + } + + fun run() { + doRun(Side.LEFT, Side.RIGHT) + } + + private fun doRun(vararg sides: Side) { + sides.forEach { side -> + assert(result.length == lineMapping.length) + + val text1 = processText(input1) + val text2 = processText(input2) + + val fragments = if (customFragments != null) customFragments!! + else MANAGER.compareLines(text1, text2, ComparisonPolicy.DEFAULT, INDICATOR) + + val builder = UnifiedFragmentBuilder(fragments, DocumentImpl(text1), DocumentImpl(text2), side) + builder.exec() + + + val lineCount1 = input1.count({ it == '_' }) + 1 + val lineCount2 = input2.count({ it == '_' }) + 1 + val resultLineCount = result.count({ it == '_' }) + 1 + val lineIterable = DiffIterableUtil.create(fragments.map { Range(it.startLine1, it.endLine1, it.startLine2, it.endLine2) }, + lineCount1, lineCount2) + + val expectedText = processText(result) + val actualText = processActualText(builder) + + val expectedMapping = processExpectedLineMapping(lineMapping) + val actualMapping = processActualLineMapping(builder.blocks, resultLineCount) + + val expectedChangedLines = processExpectedChangedLines(lineMapping) + val actualChangedLines = processActualChangedLines(builder.changedLines) + + val expectedMappedLines1 = processExpectedMappedLines(lineIterable, Side.LEFT) + val expectedMappedLines2 = processExpectedMappedLines(lineIterable, Side.RIGHT) + val actualMappedLines1 = processActualMappedLines(builder.convertor1, resultLineCount) + val actualMappedLines2 = processActualMappedLines(builder.convertor2, resultLineCount) + + assertEquals(expectedText, actualText) + assertEquals(expectedMapping, actualMapping) + assertEquals(expectedChangedLines, actualChangedLines) + + if (customFragments == null) { + assertEquals(expectedMappedLines1, actualMappedLines1) + assertEquals(expectedMappedLines2, actualMappedLines2) + } + } + } + + fun changes(vararg ranges: Range): Test { + customFragments = ranges.map { + LineFragmentImpl(it.start1, it.end1, it.start2, it.end2, + -1, -1, -1, -1) + } + return this + } + + private fun processText(text: String): String { + return text.filterNot { it == '.' }.replace('_', '\n') + } + + private fun processActualText(builder: UnifiedFragmentBuilder): String { + return builder.text.toString().removeSuffix("\n") + } + + private fun processExpectedLineMapping(lineMapping: String): LineMapping { + val leftSet = BitSet() + val rightSet = BitSet() + val unchangedSet = BitSet() + + lineMapping.split('_').forEachIndexed { index, line -> + if (!line.isEmpty()) { + val left = line.all { it == 'L' } + val right = line.all { it == 'R' } + val unchanged = line.all { it == ' ' } + + if (left) leftSet.set(index) + else if (right) rightSet.set(index) + else if (unchanged) unchangedSet.set(index) + else TestCase.fail() + } + } + + return LineMapping(leftSet, rightSet, unchangedSet) + } + + private fun processActualLineMapping(blocks: List, lineCount: Int): LineMapping { + val leftSet = BitSet() + val rightSet = BitSet() + val unchangedSet = BitSet() + + blocks.forEach { + leftSet.set(it.range1.start, it.range1.end) + rightSet.set(it.range2.start, it.range2.end) + } + + unchangedSet.set(0, lineCount) + unchangedSet.andNot(leftSet) + unchangedSet.andNot(rightSet) + + return LineMapping(leftSet, rightSet, unchangedSet) + } + + private fun processExpectedChangedLines(lineMapping: String): BitSet { + val expectedMapping = processExpectedLineMapping(lineMapping) + val result = BitSet() + result.or(expectedMapping.left) + result.or(expectedMapping.right) + return result + } + + private fun processActualChangedLines(changedRanges: List): BitSet { + val result = BitSet() + changedRanges.forEach { + result.set(it.start, it.end) + } + return result + } + + private fun processExpectedMappedLines(iterable: DiffIterable, side: Side): BitSet { + val result = BitSet() + DiffIterableUtil.iterateAll(iterable).forEach { pair -> + val range = pair.first + val start = side.select(range.start1, range.start2) + val end = side.select(range.end1, range.end2) + result.set(start, end) + } + return result + } + + private fun processActualMappedLines(convertor: LineNumberConvertor, lineCount: Int): BitSet { + val result = BitSet() + for (i in -5..lineCount + 5) { + val line = convertor.convert(i) + if (line != -1) { + if (result[line]) TestCase.fail() + result.set(line) + } + } + return result + } } - fun testDeletion() { - val builder = createBuilder("A\n", "", Side.LEFT) - - assertFalse(builder.isEqual) - assertEquals(builder.text.toString(), "A\n\n") - assertEquals(builder.changedLines, listOf(LineRange(0, 1))) - - assertEquals(builder.blocks.size, 1) - val block = builder.blocks[0] - assertEquals(block.line1, 0) - assertEquals(block.line2, 1) - assertEquals(block.range1.start, 0) - assertEquals(block.range1.end, 1) - assertEquals(block.range2.start, 1) - assertEquals(block.range2.end, 1) + private fun mod(line1: Int, line2: Int, count1: Int, count2: Int): Range { + assert(count1 != 0) + assert(count2 != 0) + return Range(line1, line1 + count1, line2, line2 + count2) } - - private fun createBuilder(text1: String, text2: String, side: Side): UnifiedFragmentBuilder { - val document1 = DocumentImpl(text1) - val document2 = DocumentImpl(text2) - - val fragments = MANAGER.compareLinesInner(document1.charsSequence, document2.charsSequence, - ComparisonPolicy.DEFAULT, DumbProgressIndicator.INSTANCE) - - val builder = UnifiedFragmentBuilder(fragments, document1, document2, side) - builder.exec() - - return builder + private fun del(line1: Int, line2: Int, count1: Int): Range { + assert(count1 != 0) + return Range(line1, line1 + count1, line2, line2) } + + private fun ins(line1: Int, line2: Int, count2: Int): Range { + assert(count2 != 0) + return Range(line1, line1, line2, line2 + count2) + } + + private data class LineMapping(val left: BitSet, val right: BitSet, val unchanged: BitSet) } From 8754155e856bc71d637d21e8ff0d9d9980278786 Mon Sep 17 00:00:00 2001 From: Pavel Dolgov Date: Mon, 13 Feb 2017 17:29:45 +0300 Subject: [PATCH 29/96] Java: Added priorities in the completion list for arguments of getAnnotation() and getConstructor() (IDEA-167250) --- .../JavaReflectionCompletionContributor.java | 77 +++++++++++-------- .../impl/JavaReflectionReferenceUtil.java | 7 ++ .../reflectionParameters/Annotation.java | 1 - .../Annotation_after.java | 1 - .../DeclaredAnnotation_after.java | 2 +- .../reflectionParameters/Imports.java | 6 ++ .../reflectionParameters/Imports_after.java | 8 ++ .../InheritedAnnotation.java | 1 - .../InheritedAnnotation_after.java | 1 - .../InheritedDeclaredAnnotation_after.java | 2 +- .../reflectionParameters/Variable.java | 8 ++ .../reflectionParameters/Variable_after.java | 8 ++ .../JavaReflectionParametersCompletionTest.kt | 58 ++++++++++---- 13 files changed, 127 insertions(+), 53 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/completion/reflectionParameters/Imports.java create mode 100644 java/java-tests/testData/codeInsight/completion/reflectionParameters/Imports_after.java create mode 100644 java/java-tests/testData/codeInsight/completion/reflectionParameters/Variable.java create mode 100644 java/java-tests/testData/codeInsight/completion/reflectionParameters/Variable_after.java diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionCompletionContributor.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionCompletionContributor.java index e6fe72862af0..cec56769bd53 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionCompletionContributor.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionCompletionContributor.java @@ -19,6 +19,7 @@ import com.intellij.codeInsight.AnnotationUtil; import com.intellij.codeInsight.completion.*; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementBuilder; +import com.intellij.codeInsight.lookup.LookupValueWithPriority; import com.intellij.openapi.util.TextRange; import com.intellij.patterns.ElementPattern; import com.intellij.patterns.PatternCondition; @@ -27,11 +28,11 @@ import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtilCore; import com.intellij.util.ProcessingContext; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import java.util.Arrays; -import java.util.stream.Collectors; +import java.util.Set; +import java.util.function.BiConsumer; import static com.intellij.codeInsight.completion.JavaCompletionContributor.isInJavaContext; import static com.intellij.patterns.PsiJavaPatterns.*; @@ -42,18 +43,27 @@ import static com.intellij.psi.impl.source.resolve.reference.impl.JavaReflection * @author Pavel.Dolgov */ public class JavaReflectionCompletionContributor extends CompletionContributor { + private static final String CONSTRUCTOR = "getConstructor"; + private static final String DECLARED_CONSTRUCTOR = "getDeclaredConstructor"; + private static final String ANNOTATION = "getAnnotation"; + private static final String DECLARED_ANNOTATION = "getDeclaredAnnotation"; + private static final String ANNOTATIONS_BY_TYPE = "getAnnotationsByType"; + private static final String DECLARED_ANNOTATIONS_BY_TYPE = "getDeclaredAnnotationsByType"; + private static final String ANNOTATED_ELEMENT = "java.lang.reflect.AnnotatedElement"; + private static final Set DECLARED_NAMES = + ContainerUtil.immutableSet(DECLARED_CONSTRUCTOR, DECLARED_ANNOTATION, DECLARED_ANNOTATIONS_BY_TYPE); private static final ElementPattern CONSTRUCTOR_ARGUMENTS = psiElement(PsiExpressionList.class) .withParent(psiExpression().methodCall( psiMethod() - .withName("getConstructor", "getDeclaredConstructor") + .withName(CONSTRUCTOR, DECLARED_CONSTRUCTOR) .definedInClass(CommonClassNames.JAVA_LANG_CLASS))); private static final ElementPattern ANNOTATION_ARGUMENTS = psiElement(PsiExpressionList.class) .withParent(psiExpression().methodCall( psiMethod() - .withName("getAnnotation", "getDeclaredAnnotation", "getAnnotationsByType", "getDeclaredAnnotationsByType") - .with(new MethodDefinedInInterfacePatternCondition("java.lang.reflect.AnnotatedElement")))); + .withName(ANNOTATION, DECLARED_ANNOTATION, ANNOTATIONS_BY_TYPE, DECLARED_ANNOTATIONS_BY_TYPE) + .with(new MethodDefinedInInterfacePatternCondition(ANNOTATED_ELEMENT)))); private static final ElementPattern BEGINNING_OF_CONSTRUCTOR_ARGUMENTS = beginningOfArguments(CONSTRUCTOR_ARGUMENTS); @@ -79,28 +89,32 @@ public class JavaReflectionCompletionContributor extends CompletionContributor { } if (BEGINNING_OF_ANNOTATION_ARGUMENTS.accepts(position)) { - PsiClass psiClass = getQualifierClass(position); - if (psiClass != null) { - addAnnotationClasses(psiClass, result); - } + addVariants(position, (psiClass, isDeclared) -> addAnnotationClasses(psiClass, isDeclared, result)); //TODO handle annotations on fields and methods } - if (BEGINNING_OF_CONSTRUCTOR_ARGUMENTS.accepts(position)) { - PsiClass psiClass = getQualifierClass(position); + else if (BEGINNING_OF_CONSTRUCTOR_ARGUMENTS.accepts(position)) { + addVariants(position, (psiClass, isDeclared) -> addConstructorParameterTypes(psiClass, isDeclared, result)); + } + } + + private static void addVariants(PsiElement position, BiConsumer variantAdder) { + PsiMethodCallExpression methodCall = PsiTreeUtil.getParentOfType(position, PsiMethodCallExpression.class); + if (methodCall != null) { + PsiClass psiClass = getReflectiveClass(methodCall.getMethodExpression().getQualifierExpression()); if (psiClass != null) { - addConstructorParameterTypes(psiClass, result); + String methodName = methodCall.getMethodExpression().getReferenceName(); + if (methodName != null) { + variantAdder.accept(psiClass, DECLARED_NAMES.contains(methodName)); + } } } } - @Nullable - private static PsiClass getQualifierClass(@Nullable PsiElement position) { - PsiMethodCallExpression methodCall = PsiTreeUtil.getParentOfType(position, PsiMethodCallExpression.class); - return methodCall != null ? getReflectiveClass(methodCall.getMethodExpression().getQualifierExpression()) : null; - } + private static void addAnnotationClasses(@NotNull PsiClass psiClass, boolean isDeclared, @NotNull CompletionResultSet result) { + Set declaredAnnotations = + isDeclared ? ContainerUtil.set(AnnotationUtil.getAllAnnotations(psiClass, false, null, false)) : null; - private static void addAnnotationClasses(@NotNull PsiModifierListOwner annotationsOwner, @NotNull CompletionResultSet result) { - PsiAnnotation[] annotations = AnnotationUtil.getAllAnnotations(annotationsOwner, true, null); + PsiAnnotation[] annotations = AnnotationUtil.getAllAnnotations(psiClass, true, null, false); for (PsiAnnotation annotation : annotations) { PsiJavaCodeReferenceElement referenceElement = annotation.getNameReferenceElement(); if (referenceElement != null) { @@ -112,6 +126,9 @@ public class JavaReflectionCompletionContributor extends CompletionContributor { LookupElement lookupElement = LookupElementBuilder.createWithIcon(annotationClass) .withPresentableText(className + ".class") .withInsertHandler(JavaReflectionCompletionContributor::handleAnnotationClassInsertion); + if (isDeclared) { + lookupElement = withPriority(lookupElement, declaredAnnotations.contains(annotation)); + } result.addElement(lookupElement); } } @@ -119,26 +136,22 @@ public class JavaReflectionCompletionContributor extends CompletionContributor { } } - private static void addConstructorParameterTypes(@NotNull PsiClass psiClass, @NotNull CompletionResultSet result) { + private static void addConstructorParameterTypes(@NotNull PsiClass psiClass, boolean isDeclared, @NotNull CompletionResultSet result) { PsiMethod[] constructors = psiClass.getConstructors(); - if (constructors.length != 0) { - for (PsiMethod constructor : constructors) { - String parameterTypesText = Arrays.stream(constructor.getParameterList().getParameters()) - .map(p -> p.getType().getCanonicalText()) - .collect(Collectors.joining(",", constructor.getName() + "(", ")")); - - LookupElement lookupElement = LookupElementBuilder.createWithIcon(constructor) - .withPresentableText(parameterTypesText) - .withInsertHandler(JavaReflectionCompletionContributor::handleConstructorSignatureInsertion); - result.addElement(lookupElement); + for (PsiMethod constructor : constructors) { + LookupElement lookupElement = JavaLookupElementBuilder.forMethod(constructor, PsiSubstitutor.EMPTY) + .withInsertHandler(JavaReflectionCompletionContributor::handleConstructorSignatureInsertion); + if (isDeclared) { + lookupElement = withPriority(lookupElement, isPublic(constructor)); } + result.addElement(lookupElement); } } private static void handleAnnotationClassInsertion(@NotNull InsertionContext context, @NotNull LookupElement item) { Object object = item.getObject(); if (object instanceof PsiClass) { - String className = ((PsiClass)object).getName(); + String className = ((PsiClass)object).getQualifiedName(); if (className != null) { handleParametersInsertion(context, className + ".class"); } diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionReferenceUtil.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionReferenceUtil.java index 3860543111a7..4a8775f9f7d7 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionReferenceUtil.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionReferenceUtil.java @@ -16,6 +16,8 @@ package com.intellij.psi.impl.source.resolve.reference.impl; import com.intellij.codeInsight.completion.InsertionContext; +import com.intellij.codeInsight.completion.PrioritizedLookupElement; +import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.RecursionGuard; import com.intellij.openapi.util.RecursionManager; @@ -175,4 +177,9 @@ class JavaReflectionReferenceUtil { JavaCodeStyleManager.getInstance(context.getProject()).shortenClassReferences(methodCall.getArgumentList()); } } + + @NotNull + static LookupElement withPriority(LookupElement lookupElement, boolean hasPriority) { + return PrioritizedLookupElement.withPriority(lookupElement, hasPriority ? 0 : -1); + } } diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/Annotation.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Annotation.java index fa54541138af..22d4427b7860 100644 --- a/java/java-tests/testData/codeInsight/completion/reflectionParameters/Annotation.java +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Annotation.java @@ -1,7 +1,6 @@ import foo.bar.*; class Main { void foo() throws ReflectiveOperationException { - Class aType = Baz.class; Test.class.getAnnotation(); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/Annotation_after.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Annotation_after.java index b18777005dcd..11d8436d32cd 100644 --- a/java/java-tests/testData/codeInsight/completion/reflectionParameters/Annotation_after.java +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Annotation_after.java @@ -1,7 +1,6 @@ import foo.bar.*; class Main { void foo() throws ReflectiveOperationException { - Class aType = Baz.class; Test.class.getAnnotation(Bar.class); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/DeclaredAnnotation_after.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/DeclaredAnnotation_after.java index 441e07f2117d..9b1e0e8aa8e5 100644 --- a/java/java-tests/testData/codeInsight/completion/reflectionParameters/DeclaredAnnotation_after.java +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/DeclaredAnnotation_after.java @@ -1,6 +1,6 @@ import foo.bar.*; class Main { void foo() throws ReflectiveOperationException { - Test.class.getDeclaredAnnotation(Bar.class); + Test.class.getDeclaredAnnotation(Foo.class); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/Imports.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Imports.java new file mode 100644 index 000000000000..20a7645c15ba --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Imports.java @@ -0,0 +1,6 @@ +import foo.bar.*; +class Main { + void foo() throws ReflectiveOperationException { + More.class.getAnnotation(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/Imports_after.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Imports_after.java new file mode 100644 index 000000000000..33ede903277a --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Imports_after.java @@ -0,0 +1,8 @@ +import foo.bar.*; +import foo.baz.Baz; + +class Main { + void foo() throws ReflectiveOperationException { + More.class.getAnnotation(Baz.class); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedAnnotation.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedAnnotation.java index fa54541138af..22d4427b7860 100644 --- a/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedAnnotation.java +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedAnnotation.java @@ -1,7 +1,6 @@ import foo.bar.*; class Main { void foo() throws ReflectiveOperationException { - Class aType = Baz.class; Test.class.getAnnotation(); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedAnnotation_after.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedAnnotation_after.java index 02cdb98460a2..e2f62c2634b1 100644 --- a/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedAnnotation_after.java +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedAnnotation_after.java @@ -1,7 +1,6 @@ import foo.bar.*; class Main { void foo() throws ReflectiveOperationException { - Class aType = Baz.class; Test.class.getAnnotation(Foo.class); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedDeclaredAnnotation_after.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedDeclaredAnnotation_after.java index 9b1e0e8aa8e5..441e07f2117d 100644 --- a/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedDeclaredAnnotation_after.java +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/InheritedDeclaredAnnotation_after.java @@ -1,6 +1,6 @@ import foo.bar.*; class Main { void foo() throws ReflectiveOperationException { - Test.class.getDeclaredAnnotation(Foo.class); + Test.class.getDeclaredAnnotation(Bar.class); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/Variable.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Variable.java new file mode 100644 index 000000000000..b85dc5238482 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Variable.java @@ -0,0 +1,8 @@ +import foo.bar.*; +import foo.baz.Baz; +class Main { + void foo() throws ReflectiveOperationException { + Class aType = Baz.class; + Test.class.getAnnotation(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionParameters/Variable_after.java b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Variable_after.java new file mode 100644 index 000000000000..fdd7410ec6ad --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionParameters/Variable_after.java @@ -0,0 +1,8 @@ +import foo.bar.*; +import foo.baz.Baz; +class Main { + void foo() throws ReflectiveOperationException { + Class aType = Baz.class; + Test.class.getAnnotation(aType); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionParametersCompletionTest.kt b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionParametersCompletionTest.kt index ad561a743d22..f9c0bc2273bb 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionParametersCompletionTest.kt +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionParametersCompletionTest.kt @@ -31,7 +31,9 @@ package com.intellij.codeInsight.completion import com.intellij.JavaTestUtil +import com.intellij.codeInsight.lookup.LookupElement import com.intellij.codeInsight.lookup.LookupElementPresentation +import com.intellij.psi.PsiMethod import com.intellij.testFramework.LightProjectDescriptor /** @@ -42,26 +44,36 @@ class JavaReflectionParametersCompletionTest : LightFixtureCompletionTestCase() override fun getProjectDescriptor(): LightProjectDescriptor = com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase.JAVA_8 - fun testAnnotation() = doTest(0, "Bar.class", "Foo.class", "aType") + fun testAnnotation() = doTest(0, "Bar.class", "Foo.class") - fun testInheritedAnnotation() = doTest(1, "Bar.class", "Foo.class", "aType") + fun testInheritedAnnotation() = doTest(1, "Bar.class", "Foo.class") - fun testDeclaredAnnotation() = doTest(0, "Bar.class", "Foo.class") + fun testDeclaredAnnotation() = doTest(0, "Foo.class", "Bar.class") - fun testInheritedDeclaredAnnotation() = doTest(1, "Bar.class", "Foo.class") + fun testInheritedDeclaredAnnotation() = doTest(1, "Foo.class", "Bar.class") fun testAnnotationsByType() = doTest(0, "Bar.class", "Foo.class") - fun testDeclaredAnnotationsByType() = doTest(1, "Bar.class", "Foo.class") + fun testDeclaredAnnotationsByType() = doTest(0, "Foo.class", "Bar.class") fun testConstructor() { addConstructors() - doTest(2, "Construct()", "Construct(int)", "Construct(int,java.lang.String)", "Construct(java.lang.String)") + doTest(3, "Construct()", "Construct(int n)", "Construct(java.lang.String s)", "Construct(int n,java.lang.String s)") } fun testDeclaredConstructor() { addConstructors() - doTest(0, "Construct()", "Construct(int)", "Construct(int,java.lang.String)", "Construct(java.lang.String)") + doTest(0, "Construct()", "Construct(int n,java.lang.String s)", "Construct(int n)", "Construct(java.lang.String s)") + } + + fun testImports() { + addMoreClasses() + doTest(1, "Bar.class", "Baz.class") + } + + fun testVariable() { + addMoreClasses() + doTest(2, "Bar.class", "Foo.class", "aType") } private fun doTest(index: Int, vararg expected: String) { @@ -69,11 +81,7 @@ class JavaReflectionParametersCompletionTest : LightFixtureCompletionTestCase() configureByFile(getTestName(false) + ".java") val lookupItems = lookup.items - val texts = lookupItems.subList(0, Math.min(lookupItems.size, expected.size)).map { - val presentation = LookupElementPresentation() - it?.renderElement(presentation) - presentation.itemText ?: "" - } + val texts = lookupItemTexts(lookupItems, expected.size) assertOrderedEquals(texts, *expected) selectItem(lookupItems[index]) myFixture.checkResultByFile(getTestName(false) + "_after.java") @@ -82,9 +90,13 @@ class JavaReflectionParametersCompletionTest : LightFixtureCompletionTestCase() private fun addClasses() { myFixture.addClass("package foo.bar; public @interface Foo {}") myFixture.addClass("package foo.bar; public @interface Bar {}") - myFixture.addClass("package foo.bar; public @interface Baz {}") - myFixture.addClass("package foo.bar; @Foo class Parent {}") - myFixture.addClass("package foo.bar; @Bar class Test extends Parent {}") + myFixture.addClass("package foo.bar; @Bar class Parent {}") + myFixture.addClass("package foo.bar; @Foo class Test extends Parent {}") + } + + private fun addMoreClasses() { + myFixture.addClass("package foo.baz; public @interface Baz {}") + myFixture.addClass("package foo.bar; @foo.baz.Baz class More extends Parent {}") } private fun addConstructors() { @@ -96,4 +108,20 @@ public class Construct { public Construct() {} }""") } + } +fun lookupItemTexts(lookupItems: List, maxSize: Int): List = + lookupItems.subList(0, Math.min(lookupItems.size, maxSize)).map { + val obj = it?.`object` + when (obj) { + is PsiMethod -> { + obj.name + obj.parameterList.parameters.map { it.type.canonicalText + " " + it.name } + .joinToString(",", prefix = "(", postfix = ")") + } + else -> { + val presentation = LookupElementPresentation() + it?.renderElement(presentation) + presentation.itemText ?: "" + } + } + } From e4ec230e5db3ca1ca24dbd37df6300665edcbcb3 Mon Sep 17 00:00:00 2001 From: Pavel Dolgov Date: Tue, 14 Feb 2017 12:59:06 +0300 Subject: [PATCH 30/96] Java: Added priorities in the completion list for arguments of getField() and getMethod() (IDEA-167250) --- .../impl/JavaLangClassMemberReference.java | 37 +++++++++---- .../JavaReflectionCompletionContributor.java | 1 - .../impl/JavaReflectionReferenceUtil.java | 4 +- .../completion/reflection/DeclaredField.java | 2 +- .../reflection/DeclaredField_after.java | 2 +- .../completion/reflection/DeclaredMethod.java | 2 +- .../reflection/DeclaredMethod2.java | 2 +- .../reflection/DeclaredMethod2_after.java | 4 +- .../reflection/DeclaredMethod_after.java | 2 +- .../reflection/ForNameDeclaredField.java | 2 +- .../ForNameDeclaredField_after.java | 4 +- .../reflection/ForNameDeclaredMethod.java | 2 +- .../ForNameDeclaredMethod_after.java | 2 +- .../completion/reflection/HasConstructor.java | 17 ++++++ .../reflection/HasConstructor_after.java | 17 ++++++ .../JavaLangObjectMethods.java | 9 ++++ .../JavaLangObjectMethods_after.java | 9 ++++ .../JavaLangObjectOwnMethods.java | 5 ++ .../JavaLangObjectOwnMethods_after.java | 5 ++ .../reflectionOverload/OverloadMethods.java | 17 ++++++ .../OverloadMethods_after.java | 17 ++++++ .../JavaReflectionCompletionOverloadTest.kt | 53 +++++++++++++++++++ .../JavaReflectionCompletionTest.java | 19 ++++--- 23 files changed, 203 insertions(+), 31 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/completion/reflection/HasConstructor.java create mode 100644 java/java-tests/testData/codeInsight/completion/reflection/HasConstructor_after.java create mode 100644 java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectMethods.java create mode 100644 java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectMethods_after.java create mode 100644 java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectOwnMethods.java create mode 100644 java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectOwnMethods_after.java create mode 100644 java/java-tests/testData/codeInsight/completion/reflectionOverload/OverloadMethods.java create mode 100644 java/java-tests/testData/codeInsight/completion/reflectionOverload/OverloadMethods_after.java create mode 100644 java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionOverloadTest.kt diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaLangClassMemberReference.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaLangClassMemberReference.java index a5b849bd7e56..2e658a640d66 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaLangClassMemberReference.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaLangClassMemberReference.java @@ -18,8 +18,8 @@ package com.intellij.psi.impl.source.resolve.reference.impl; import com.intellij.codeInsight.completion.InsertHandler; import com.intellij.codeInsight.completion.InsertionContext; import com.intellij.codeInsight.completion.JavaLookupElementBuilder; +import com.intellij.codeInsight.completion.PrioritizedLookupElement; import com.intellij.codeInsight.lookup.LookupElement; -import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtilCore; @@ -29,6 +29,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Arrays; +import java.util.Comparator; import static com.intellij.psi.impl.source.resolve.reference.impl.JavaReflectionReferenceUtil.*; @@ -71,7 +72,7 @@ public class JavaLangClassMemberReference extends PsiReferenceBase isRegularMethod(method) && isReachable(method, psiClass)); + return ContainerUtil.find(methods, method -> isRegularMethod(method) && isPotentiallyAccessible(method, psiClass)); } } } @@ -115,21 +116,30 @@ public class JavaLangClassMemberReference extends PsiReferenceBase lookupField(field)) + .toArray(); case FIELD: - return ContainerUtil.filter(psiClass.getAllFields(), field -> isReachable(field, psiClass)).toArray(); + return Arrays.stream(psiClass.getAllFields()) + .filter(field -> isPotentiallyAccessible(field, psiClass)) + .sorted(Comparator.comparingInt((PsiField field) -> isPublic(field) ? 0 : 1).thenComparing(PsiField::getName)) + .map(field -> withPriority(lookupField(field), isPublic(field))) + .toArray(); case DECLARED_METHOD: return Arrays.stream(psiClass.getMethods()) .filter(method -> isRegularMethod(method)) - .map(this::lookupMethod) + .sorted(Comparator.comparing(PsiMethod::getName)) + .map(method -> lookupMethod(method)) .toArray(); case METHOD: return Arrays.stream(psiClass.getAllMethods()) - .filter(method -> isRegularMethod(method) && isReachable(method, psiClass) && !isJavaLangObject(method.getContainingClass())) - .map(this::lookupMethod) + .filter(method -> isRegularMethod(method) && isPotentiallyAccessible(method, psiClass)) + .sorted(Comparator.comparingInt((PsiMethod method) -> getMethodSortOrder(method)).thenComparing(PsiMethod::getName)) + .map(method -> PrioritizedLookupElement.withPriority(lookupMethod(method), -getMethodSortOrder(method))) .toArray(); } } @@ -137,8 +147,17 @@ public class JavaLangClassMemberReference extends PsiReferenceBase false") - static boolean isReachable(PsiMember member, PsiClass psiClass) { + static boolean isPotentiallyAccessible(PsiMember member, PsiClass psiClass) { return member != null && (member.getContainingClass() == psiClass || isPublic(member)); } @@ -180,6 +180,6 @@ class JavaReflectionReferenceUtil { @NotNull static LookupElement withPriority(LookupElement lookupElement, boolean hasPriority) { - return PrioritizedLookupElement.withPriority(lookupElement, hasPriority ? 0 : -1); + return PrioritizedLookupElement.withPriority(lookupElement, hasPriority ? 1 : -1); } } diff --git a/java/java-tests/testData/codeInsight/completion/reflection/DeclaredField.java b/java/java-tests/testData/codeInsight/completion/reflection/DeclaredField.java index 88111a4f7a1e..c7cbf25a1247 100644 --- a/java/java-tests/testData/codeInsight/completion/reflection/DeclaredField.java +++ b/java/java-tests/testData/codeInsight/completion/reflection/DeclaredField.java @@ -22,5 +22,5 @@ class DeclaredField { class Test { public int num; public int num2; - int num3; + int num1; } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflection/DeclaredField_after.java b/java/java-tests/testData/codeInsight/completion/reflection/DeclaredField_after.java index 924c8f05deca..dc2f27b3cf93 100644 --- a/java/java-tests/testData/codeInsight/completion/reflection/DeclaredField_after.java +++ b/java/java-tests/testData/codeInsight/completion/reflection/DeclaredField_after.java @@ -22,5 +22,5 @@ class DeclaredField { class Test { public int num; public int num2; - int num3; + int num1; } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflection/DeclaredMethod.java b/java/java-tests/testData/codeInsight/completion/reflection/DeclaredMethod.java index 5abc4c462133..975bade6d231 100644 --- a/java/java-tests/testData/codeInsight/completion/reflection/DeclaredMethod.java +++ b/java/java-tests/testData/codeInsight/completion/reflection/DeclaredMethod.java @@ -22,7 +22,7 @@ class DecalredMethod { class Test { public void method(){} public void method2(A a, B b){} - public void method3(){} + void method1(){} } class A {} diff --git a/java/java-tests/testData/codeInsight/completion/reflection/DeclaredMethod2.java b/java/java-tests/testData/codeInsight/completion/reflection/DeclaredMethod2.java index 7c63f9b3fb11..f915e81485d1 100644 --- a/java/java-tests/testData/codeInsight/completion/reflection/DeclaredMethod2.java +++ b/java/java-tests/testData/codeInsight/completion/reflection/DeclaredMethod2.java @@ -22,7 +22,7 @@ class DecalredMethod2 { class Test { void method(){} void method2(A a, B b){} - void method3(){} + void method1(){} } class A {} diff --git a/java/java-tests/testData/codeInsight/completion/reflection/DeclaredMethod2_after.java b/java/java-tests/testData/codeInsight/completion/reflection/DeclaredMethod2_after.java index f9d56a003ff2..c21cc6536ed4 100644 --- a/java/java-tests/testData/codeInsight/completion/reflection/DeclaredMethod2_after.java +++ b/java/java-tests/testData/codeInsight/completion/reflection/DeclaredMethod2_after.java @@ -15,14 +15,14 @@ */ class DecalredMethod2 { void foo() { - Test.class.getDeclaredMethod("method3"); + Test.class.getDeclaredMethod("method1"); } } class Test { void method(){} void method2(A a, B b){} - void method3(){} + void method1(){} } class A {} diff --git a/java/java-tests/testData/codeInsight/completion/reflection/DeclaredMethod_after.java b/java/java-tests/testData/codeInsight/completion/reflection/DeclaredMethod_after.java index c6c0d5bce7d3..dd7db3075de0 100644 --- a/java/java-tests/testData/codeInsight/completion/reflection/DeclaredMethod_after.java +++ b/java/java-tests/testData/codeInsight/completion/reflection/DeclaredMethod_after.java @@ -22,7 +22,7 @@ class DecalredMethod { class Test { public void method(){} public void method2(A a, B b){} - public void method3(){} + void method1(){} } class A {} diff --git a/java/java-tests/testData/codeInsight/completion/reflection/ForNameDeclaredField.java b/java/java-tests/testData/codeInsight/completion/reflection/ForNameDeclaredField.java index b8111aba4c72..927f3a567ebf 100644 --- a/java/java-tests/testData/codeInsight/completion/reflection/ForNameDeclaredField.java +++ b/java/java-tests/testData/codeInsight/completion/reflection/ForNameDeclaredField.java @@ -22,5 +22,5 @@ class ForNameDeclaredField { class Test { public int num; public int num2; - int num3; + int num1; } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflection/ForNameDeclaredField_after.java b/java/java-tests/testData/codeInsight/completion/reflection/ForNameDeclaredField_after.java index b6224c1fbb4c..616dc81b0b5f 100644 --- a/java/java-tests/testData/codeInsight/completion/reflection/ForNameDeclaredField_after.java +++ b/java/java-tests/testData/codeInsight/completion/reflection/ForNameDeclaredField_after.java @@ -15,12 +15,12 @@ */ class ForNameDeclaredField { void foo() { - Class.forName("Test").getDeclaredField("num3"); + Class.forName("Test").getDeclaredField("num1"); } } class Test { public int num; public int num2; - int num3; + int num1; } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflection/ForNameDeclaredMethod.java b/java/java-tests/testData/codeInsight/completion/reflection/ForNameDeclaredMethod.java index 9f2d2aeec438..584aee2e2bdb 100644 --- a/java/java-tests/testData/codeInsight/completion/reflection/ForNameDeclaredMethod.java +++ b/java/java-tests/testData/codeInsight/completion/reflection/ForNameDeclaredMethod.java @@ -22,7 +22,7 @@ class ForNameDeclaredMethod { class Test { public void method(){} public void method2(A a, B b){} - void method3(){} + void method1(){} } class A {} diff --git a/java/java-tests/testData/codeInsight/completion/reflection/ForNameDeclaredMethod_after.java b/java/java-tests/testData/codeInsight/completion/reflection/ForNameDeclaredMethod_after.java index ff165cfc6ac4..a744c9c0baa2 100644 --- a/java/java-tests/testData/codeInsight/completion/reflection/ForNameDeclaredMethod_after.java +++ b/java/java-tests/testData/codeInsight/completion/reflection/ForNameDeclaredMethod_after.java @@ -22,7 +22,7 @@ class ForNameDeclaredMethod { class Test { public void method(){} public void method2(A a, B b){} - void method3(){} + void method1(){} } class A {} diff --git a/java/java-tests/testData/codeInsight/completion/reflection/HasConstructor.java b/java/java-tests/testData/codeInsight/completion/reflection/HasConstructor.java new file mode 100644 index 000000000000..9f6c9209badd --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflection/HasConstructor.java @@ -0,0 +1,17 @@ +class HasConstructor { + void foo() { + Test.class.getMethod(""); + } +} + +class Test { + public Test() {} + Test(int n) {} + public void method(){} + public void method2(A a, B b){} + void method1(){} +} + +class A {} +class B {} +class C {} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflection/HasConstructor_after.java b/java/java-tests/testData/codeInsight/completion/reflection/HasConstructor_after.java new file mode 100644 index 000000000000..63ab44953f48 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflection/HasConstructor_after.java @@ -0,0 +1,17 @@ +class HasConstructor { + void foo() { + Test.class.getMethod("method1"); + } +} + +class Test { + public Test() {} + Test(int n) {} + public void method(){} + public void method2(A a, B b){} + void method1(){} +} + +class A {} +class B {} +class C {} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectMethods.java b/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectMethods.java new file mode 100644 index 000000000000..4c73e541bb03 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectMethods.java @@ -0,0 +1,9 @@ +class Main { + void foo() { + Test.class.getMethod(""); + } +} + +class Test { + public void method(){} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectMethods_after.java b/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectMethods_after.java new file mode 100644 index 000000000000..fe138e3d1018 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectMethods_after.java @@ -0,0 +1,9 @@ +class Main { + void foo() { + Test.class.getMethod("notifyAll"); + } +} + +class Test { + public void method(){} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectOwnMethods.java b/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectOwnMethods.java new file mode 100644 index 000000000000..7fde3dd7de4e --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectOwnMethods.java @@ -0,0 +1,5 @@ +class Main { + void foo() { + Object.class.getMethod(""); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectOwnMethods_after.java b/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectOwnMethods_after.java new file mode 100644 index 000000000000..50cb8701f7a1 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionOverload/JavaLangObjectOwnMethods_after.java @@ -0,0 +1,5 @@ +class Main { + void foo() { + Object.class.getMethod("wait", long.class); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionOverload/OverloadMethods.java b/java/java-tests/testData/codeInsight/completion/reflectionOverload/OverloadMethods.java new file mode 100644 index 000000000000..5af0ceb54e60 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionOverload/OverloadMethods.java @@ -0,0 +1,17 @@ +class Main { + void foo() { + Test.class.getMethod(""); + } +} + +class Test { + public Test() {} + Test(int n) {} + public void method(){} + void method(A a, B b){} + public void method(C c){} +} + +class A {} +class B {} +class C {} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/reflectionOverload/OverloadMethods_after.java b/java/java-tests/testData/codeInsight/completion/reflectionOverload/OverloadMethods_after.java new file mode 100644 index 000000000000..11aec53c2962 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/reflectionOverload/OverloadMethods_after.java @@ -0,0 +1,17 @@ +class Main { + void foo() { + Test.class.getMethod("method", A.class, B.class); + } +} + +class Test { + public Test() {} + Test(int n) {} + public void method(){} + void method(A a, B b){} + public void method(C c){} +} + +class A {} +class B {} +class C {} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionOverloadTest.kt b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionOverloadTest.kt new file mode 100644 index 000000000000..f1084f2ed35b --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionOverloadTest.kt @@ -0,0 +1,53 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.completion + +import com.intellij.JavaTestUtil + +/** + * @author Pavel.Dolgov + */ +class JavaReflectionCompletionOverloadTest : LightFixtureCompletionTestCase() { + + override fun getBasePath() = JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/completion/reflectionOverload/" + + fun testOverloadMethods() = doTest(2, "method()", "method(C c)", "method(A a,B b)") + + fun testJavaLangObjectMethods() = doTest(6, + "method()", + "equals(java.lang.Object obj)", "hashCode()", "toString()", + "getClass()", "notify()", "notifyAll()", + "wait()", "wait(long timeout)", "wait(long timeout,int nanos)" + ) + + fun testJavaLangObjectOwnMethods() = doTest(9, + "clone()", "equals(java.lang.Object obj)", "hashCode()", + "toString()", "finalize()", "getClass()", + "notify()", "notifyAll()", + "wait()", "wait(long timeout)", "wait(long timeout,int nanos)", + "registerNatives()") + + + private fun doTest(index: Int, vararg expected: String) { + configureByFile(getTestName(false) + ".java") + + val lookupItems = lookup.items + val texts = lookupItemTexts(lookupItems, expected.size) + assertOrderedEquals(texts, *expected) + if (index >= 0) selectItem(lookupItems[index]) + myFixture.checkResultByFile(getTestName(false) + "_after.java") + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java index c9fe7b8c6c2b..1695dc736f28 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java @@ -34,15 +34,15 @@ public class JavaReflectionCompletionTest extends LightFixtureCompletionTestCase } public void testDeclaredField() throws Exception { - doTest(1, "num", "num2", "num3"); + doTest(2, "num", "num1", "num2"); } public void testDeclaredMethod() throws Exception { - doTest(1, "method", "method2", "method3"); + doTest(2, "method", "method1", "method2"); } public void testDeclaredMethod2() throws Exception { - doTest(2, "method", "method2", "method3"); + doTest(1, "method", "method1", "method2"); } public void testMethod() throws Exception { @@ -50,7 +50,7 @@ public class JavaReflectionCompletionTest extends LightFixtureCompletionTestCase } public void testForNameDeclaredMethod() throws Exception { - doTest(1, "method", "method2", "method3"); + doTest(2, "method", "method1", "method2"); } public void testForNameMethod() throws Exception { @@ -62,7 +62,7 @@ public class JavaReflectionCompletionTest extends LightFixtureCompletionTestCase } public void testForNameDeclaredField() throws Exception { - doTest(2, "num", "num2", "num3"); + doTest(1, "num", "num1", "num2"); } public void testVarargMethod() throws Exception { @@ -135,7 +135,7 @@ public class JavaReflectionCompletionTest extends LightFixtureCompletionTestCase } public void testConstantGetClassField() throws Exception { - doTest(1, "num", "num2", "num3"); + doTest(2, "num", "num3", "num2"); } public void testExpressionGetClassField() throws Exception { @@ -165,9 +165,14 @@ public class JavaReflectionCompletionTest extends LightFixtureCompletionTestCase doTest(0, "PublicClass"); } + public void testHasConstructor() { + doTest(2, "method", "method2", "method1"); + } + + private void doTest(int index, String... expected) { configureByFile(getTestName(false) + ".java"); - assertStringItems(expected); + assertFirstStringItems(expected); if (index >= 0) selectItem(getLookup().getItems().get(index)); myFixture.checkResultByFile(getTestName(false) + "_after.java"); } From 3ca24e934a9028d708bd03572e9ff9be62589028 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Tue, 14 Feb 2017 17:14:15 +0300 Subject: [PATCH 31/96] properties files: optimize RBE construction for huge bundles IDEA-168122 --- ...ResourceBundlePropertiesUpdateManager.java | 94 ++++++++++++++----- 1 file changed, 71 insertions(+), 23 deletions(-) diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertiesUpdateManager.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertiesUpdateManager.java index 546de727e953..45e1aec1018a 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertiesUpdateManager.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertiesUpdateManager.java @@ -26,16 +26,19 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Pair; import com.intellij.pom.PomTarget; import com.intellij.pom.PomTargetPsiElement; -import com.intellij.psi.PsiComment; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiWhiteSpace; import com.intellij.psi.codeStyle.CodeStyleManager; import com.intellij.util.IncorrectOperationException; +import com.intellij.util.SmartList; +import com.intellij.util.containers.FactoryMap; +import com.intellij.util.containers.IntArrayList; import com.intellij.util.graph.*; +import gnu.trove.THashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; +import java.util.stream.Collectors; /** * @author Dmitry Batkovich @@ -166,18 +169,16 @@ public class ResourceBundlePropertiesUpdateManager { @Nullable private static Pair, Boolean> keysOrder(final ResourceBundle resourceBundle) { + final List propertiesOrders = + resourceBundle.getPropertiesFiles().stream().map(PropertiesOrder::new).collect(Collectors.toList()); + final boolean[] isAlphaSorted = new boolean[]{true}; final Graph generator = GraphGenerator.generate(CachingSemiGraph.cache(new InboundSemiGraph() { @Override public Collection getNodes() { final Set nodes = new LinkedHashSet<>(); - for (PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) { - for (IProperty property : propertiesFile.getProperties()) { - final String key = property.getKey(); - if (key != null) { - nodes.add(key); - } - } + for (PropertiesOrder order : propertiesOrders) { + nodes.addAll(order.myKeys); } return nodes; } @@ -185,23 +186,16 @@ public class ResourceBundlePropertiesUpdateManager { @Override public Iterator getIn(String n) { final Collection siblings = new LinkedHashSet<>(); - for (PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) { - for (IProperty property : propertiesFile.findPropertiesByKey(n)) { - PsiElement sibling = property.getPsiElement().getNextSibling(); - while (sibling instanceof PsiWhiteSpace || sibling instanceof PsiComment) { - sibling = sibling.getNextSibling(); - } - if (sibling instanceof IProperty) { - final String key = ((IProperty)sibling).getKey(); - if (key != null) { - if (isAlphaSorted[0] && String.CASE_INSENSITIVE_ORDER.compare(n, key) > 0) { - isAlphaSorted[0] = false; - } - siblings.add(key); - } + + for (PropertiesOrder order : propertiesOrders) { + for (String nextKey : order.getNext(n)) { + if (isAlphaSorted[0] && String.CASE_INSENSITIVE_ORDER.compare(n, nextKey) > 0) { + isAlphaSorted[0] = false; } + siblings.add(nextKey); } } + return siblings.iterator(); } })); @@ -230,4 +224,58 @@ public class ResourceBundlePropertiesUpdateManager { public boolean isSorted() { return myOrdered; } + + private static class PropertiesOrder { + List myKeys; + Map myKeyIndices; + + public PropertiesOrder(@NotNull PropertiesFile file) { + final List properties = file.getProperties(); + myKeys = new ArrayList<>(properties.size()); + myKeyIndices = new FactoryMap() { + + @Override + protected Map createMap() { + return new THashMap<>(properties.size()); + } + + @NotNull + @Override + protected IntArrayList create(String key) { + return new IntArrayList(1); + } + }; + + int index = 0; + for (IProperty property : properties) { + final String key = property.getKey(); + if (key != null) { + myKeys.add(key); + myKeyIndices.get(key).add(index); + } + index++; + } + } + + @NotNull + public List getNext(@NotNull String key) { + List nextProperties = null; + if (myKeyIndices.containsKey(key)) { + final IntArrayList indices = myKeyIndices.get(key); + for (int i = 0; i < indices.size(); i++) { + final int searchIdx = indices.getQuick(i) + 1; + if (searchIdx < myKeys.size()) { + final String nextProperty = myKeys.get(searchIdx); + if (nextProperty != null) { + if (nextProperties == null) { + nextProperties = new SmartList<>(); + } + nextProperties.add(nextProperty); + } + } + } + } + return nextProperties == null ? Collections.emptyList() : nextProperties; + } + } } From 9f061386f29fea4b2c31b0b66fbd0ef195674a13 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 14 Feb 2017 17:10:08 +0300 Subject: [PATCH 32/96] cleanup --- .../intellij/spellchecker/SpellCheckerSeveritiesProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spellchecker/src/com/intellij/spellchecker/SpellCheckerSeveritiesProvider.java b/spellchecker/src/com/intellij/spellchecker/SpellCheckerSeveritiesProvider.java index d349a8344a97..dc54574907b6 100644 --- a/spellchecker/src/com/intellij/spellchecker/SpellCheckerSeveritiesProvider.java +++ b/spellchecker/src/com/intellij/spellchecker/SpellCheckerSeveritiesProvider.java @@ -50,7 +50,7 @@ public class SpellCheckerSeveritiesProvider extends SeveritiesProvider { return AllIcons.General.InspectionsTypos; } } - return Collections.singletonList(new T(TYPO, TYPO_KEY)); + return Collections.singletonList(new T(TYPO, TYPO_KEY)); } @Override From cacf2657e3dd08836ef1799f297dde54a62cc7b6 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 14 Feb 2017 17:12:35 +0300 Subject: [PATCH 33/96] RequiredAttributesInspection extracted from XmlHighlightVisitor --- .../src/META-INF/XmlPlugin.xml | 2 +- .../impl/analysis/XmlHighlightVisitor.java | 126 +-------------- ...dHtmlTagOrAttributeToCustomsIntention.java | 21 +-- .../RequiredAttributesInspectionBase.java | 153 ++++++++++++++++-- 4 files changed, 160 insertions(+), 142 deletions(-) diff --git a/platform/platform-resources/src/META-INF/XmlPlugin.xml b/platform/platform-resources/src/META-INF/XmlPlugin.xml index f6b3a3a9f471..4d447a1a75b6 100644 --- a/platform/platform-resources/src/META-INF/XmlPlugin.xml +++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml @@ -440,7 +440,7 @@ bundle="messages.XmlBundle" key="html.inspections.check.valid.script.tag" groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name" implementationClass="com.intellij.xml.util.CheckValidXmlInScriptBodyInspection"/> - diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java b/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java index abd712e7ef7d..8738034db0cc 100644 --- a/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java +++ b/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java @@ -16,18 +16,18 @@ package com.intellij.codeInsight.daemon.impl.analysis; import com.intellij.BundleBase; -import com.intellij.codeInsight.daemon.*; +import com.intellij.codeInsight.daemon.EmptyResolveMessageProvider; +import com.intellij.codeInsight.daemon.IdeValidationHost; +import com.intellij.codeInsight.daemon.Validator; +import com.intellij.codeInsight.daemon.XmlErrorMessages; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; import com.intellij.codeInsight.daemon.impl.HighlightVisitor; -import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixActionRegistrarImpl; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.quickfix.UnresolvedReferenceQuickFixProvider; import com.intellij.codeInspection.*; -import com.intellij.codeInspection.htmlInspections.RequiredAttributesInspectionBase; -import com.intellij.codeInspection.htmlInspections.XmlEntitiesInspection; import com.intellij.lang.ASTNode; import com.intellij.lang.dtd.DTDLanguage; import com.intellij.lang.injection.InjectedLanguageManager; @@ -38,8 +38,6 @@ import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.UserDataCache; -import com.intellij.profile.codeInspection.InspectionProfileManager; -import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.psi.*; import com.intellij.psi.html.HtmlTag; import com.intellij.psi.impl.source.SourceTreeToPsiMap; @@ -52,16 +50,11 @@ import com.intellij.psi.xml.*; import com.intellij.xml.*; import com.intellij.xml.impl.schema.AnyXmlElementDescriptor; import com.intellij.xml.util.AnchorReference; -import com.intellij.xml.util.HtmlUtil; import com.intellij.xml.util.XmlTagUtil; import com.intellij.xml.util.XmlUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.HashSet; -import java.util.Set; -import java.util.StringTokenizer; - /** * @author Mike */ @@ -104,9 +97,8 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV private void addElementsForTag(XmlTag tag, @NotNull String localizedMessage, - HighlightInfoType type, - IntentionAction quickFixAction) { - addElementsForTagWithManyQuickFixes(tag, localizedMessage, type, quickFixAction); + HighlightInfoType type) { + addElementsForTagWithManyQuickFixes(tag, localizedMessage, type, (IntentionAction)null); } private void addElementsForTagWithManyQuickFixes(XmlTag tag, @@ -265,8 +257,7 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV addElementsForTag( tag, XmlErrorMessages.message("element.is.not.allowed.here", name), - getTagProblemInfoType(tag), - null + getTagProblemInfoType(tag) ); return; } @@ -284,118 +275,17 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV elementDescriptor = tag.getDescriptor(); if (elementDescriptor == null) { - addElementsForTag(tag, XmlErrorMessages.message("element.must.be.declared", name), HighlightInfoType.WRONG_REF, null); + addElementsForTag(tag, XmlErrorMessages.message("element.must.be.declared", name), HighlightInfoType.WRONG_REF); return; } } - if (!(elementDescriptor instanceof XmlHighlightingAwareElementDescriptor) || - ((XmlHighlightingAwareElementDescriptor)elementDescriptor).shouldCheckRequiredAttributes()) { - checkRequiredAttributes(tag, name, elementDescriptor); - } - if (elementDescriptor instanceof Validator) { //noinspection unchecked ((Validator)elementDescriptor).validate(tag,this); } } - private void checkRequiredAttributes(XmlTag tag, String name, XmlElementDescriptor elementDescriptor) { - XmlAttributeDescriptor[] attributeDescriptors = elementDescriptor.getAttributesDescriptors(tag); - Set requiredAttributes = null; - - for (XmlAttributeDescriptor attribute : attributeDescriptors) { - if (attribute != null && attribute.isRequired()) { - if (requiredAttributes == null) { - requiredAttributes = new HashSet<>(); - } - requiredAttributes.add(attribute.getName(tag)); - } - } - - if (requiredAttributes != null) { - for (final String attrName : requiredAttributes) { - if (!hasAttribute(tag, attrName) && - !XmlExtension.getExtension(tag.getContainingFile()).isRequiredAttributeImplicitlyPresent(tag, attrName)) { - - IntentionAction insertRequiredAttributeIntention = XmlQuickFixFactory.getInstance().insertRequiredAttributeFix(tag, attrName); - final String localizedMessage = XmlErrorMessages.message("element.doesnt.have.required.attribute", name, attrName); - final InspectionProfile profile = InspectionProfileManager.getInstance(tag.getProject()).getCurrentProfile(); - RequiredAttributesInspectionBase inspection = - (RequiredAttributesInspectionBase)profile.getUnwrappedTool(XmlEntitiesInspection.REQUIRED_ATTRIBUTES_SHORT_NAME, tag); - if (inspection != null) { - reportOneTagProblem( - tag, - attrName, - localizedMessage, - insertRequiredAttributeIntention, - HighlightDisplayKey.find(XmlEntitiesInspection.REQUIRED_ATTRIBUTES_SHORT_NAME), - inspection, - RequiredAttributesInspectionBase.getIntentionAction(attrName) - ); - } - } - } - } - } - - private static boolean hasAttribute(XmlTag tag, String attrName) { - final XmlAttribute attribute = tag.getAttribute(attrName); - if (attribute == null) return false; - if (attribute.getValueElement() != null) return true; - if (!(tag instanceof HtmlTag)) return false; - final XmlAttributeDescriptor descriptor = attribute.getDescriptor(); - return descriptor != null && HtmlUtil.isBooleanAttribute(descriptor, tag); - } - - private void reportOneTagProblem(final XmlTag tag, - final String name, - @NotNull String localizedMessage, - final IntentionAction basicIntention, - final HighlightDisplayKey key, - final XmlEntitiesInspection inspection, - final IntentionAction addAttributeFix) { - boolean htmlTag = false; - - if (tag instanceof HtmlTag) { - htmlTag = true; - if(isAdditionallyDeclared(inspection.getAdditionalEntries(), name)) return; - } - - final InspectionProfile profile = InspectionProjectProfileManager.getInstance(tag.getProject()).getCurrentProfile(); - if (htmlTag && profile.isToolEnabled(key, tag)) { - addElementsForTagWithManyQuickFixes( - tag, - localizedMessage, - isInjectedWithoutValidation(tag) ? - HighlightInfoType.INFORMATION : - SeverityRegistrar.getSeverityRegistrar(tag.getProject()).getHighlightInfoTypeBySeverity(profile.getErrorLevel(key, tag).getSeverity()), - addAttributeFix, - basicIntention); - } else if (!htmlTag) { - addElementsForTag( - tag, - localizedMessage, - HighlightInfoType.ERROR, - basicIntention - ); - } - } - - private static boolean isAdditionallyDeclared(final String additional, String name) { - name = name.toLowerCase(); - if (!additional.contains(name)) return false; - - StringTokenizer tokenizer = new StringTokenizer(additional, ", "); - while (tokenizer.hasMoreTokens()) { - if (name.equals(tokenizer.nextToken())) { - return true; - } - } - - return false; - } - private static HighlightInfoType getTagProblemInfoType(XmlTag tag) { if (tag instanceof HtmlTag && XmlUtil.HTML_URI.equals(tag.getNamespace())) { if (isInjectedWithoutValidation(tag)) return HighlightInfoType.INFORMATION; diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/AddHtmlTagOrAttributeToCustomsIntention.java b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/AddHtmlTagOrAttributeToCustomsIntention.java index 2e4190451bce..86df279caac0 100644 --- a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/AddHtmlTagOrAttributeToCustomsIntention.java +++ b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/AddHtmlTagOrAttributeToCustomsIntention.java @@ -16,22 +16,20 @@ package com.intellij.codeInspection.htmlInspections; -import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInspection.InspectionProfile; import com.intellij.codeInspection.InspectionProfileEntry; -import com.intellij.openapi.editor.Editor; +import com.intellij.codeInspection.LocalQuickFix; +import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.profile.codeInspection.InspectionProjectProfileManager; -import com.intellij.psi.PsiFile; -import com.intellij.util.IncorrectOperationException; import com.intellij.xml.XmlBundle; import org.jetbrains.annotations.NotNull; /** * @author Maxim.Mossienko */ -public class AddHtmlTagOrAttributeToCustomsIntention implements IntentionAction { +public class AddHtmlTagOrAttributeToCustomsIntention implements LocalQuickFix { private final String myName; private final String myText; private final Key myInspectionKey; @@ -42,9 +40,9 @@ public class AddHtmlTagOrAttributeToCustomsIntention implements IntentionAction myText = text; } - @Override @NotNull - public String getText() { + @Override + public String getName() { return myText; } @@ -55,14 +53,9 @@ public class AddHtmlTagOrAttributeToCustomsIntention implements IntentionAction } @Override - public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { - return true; - } - - @Override - public void invoke(@NotNull Project project, Editor editor, final PsiFile file) throws IncorrectOperationException { + public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile(); - profile.modifyToolSettings(myInspectionKey, file, entry -> { + profile.modifyToolSettings(myInspectionKey, descriptor.getPsiElement().getContainingFile(), entry -> { XmlEntitiesInspection xmlEntitiesInspection = (XmlEntitiesInspection) entry; xmlEntitiesInspection.addEntry(myName); }); diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/RequiredAttributesInspectionBase.java b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/RequiredAttributesInspectionBase.java index c2db291cfeb1..a9410ed55ec2 100644 --- a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/RequiredAttributesInspectionBase.java +++ b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/RequiredAttributesInspectionBase.java @@ -15,20 +15,33 @@ */ package com.intellij.codeInspection.htmlInspections; -import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.codeInspection.InspectionProfileEntry; -import com.intellij.codeInspection.InspectionsBundle; -import com.intellij.codeInspection.XmlInspectionGroupNames; -import com.intellij.codeInspection.XmlSuppressableInspectionTool; -import com.intellij.codeInspection.ex.UnfairLocalInspectionTool; +import com.intellij.codeInsight.daemon.XmlErrorMessages; +import com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightingAwareElementDescriptor; +import com.intellij.codeInspection.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Key; +import com.intellij.psi.html.HtmlTag; +import com.intellij.psi.xml.XmlAttribute; +import com.intellij.psi.xml.XmlTag; +import com.intellij.psi.xml.XmlToken; +import com.intellij.xml.XmlAttributeDescriptor; import com.intellij.xml.XmlBundle; +import com.intellij.xml.XmlElementDescriptor; +import com.intellij.xml.XmlExtension; +import com.intellij.xml.impl.schema.AnyXmlElementDescriptor; +import com.intellij.xml.util.HtmlUtil; +import com.intellij.xml.util.XmlTagUtil; +import com.intellij.xml.util.XmlUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -public class RequiredAttributesInspectionBase extends XmlSuppressableInspectionTool - implements XmlEntitiesInspection, UnfairLocalInspectionTool { +import java.util.HashSet; +import java.util.Set; +import java.util.StringTokenizer; + +import static com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitor.isInjectedWithoutValidation; + +public class RequiredAttributesInspectionBase extends HtmlLocalInspectionTool implements XmlEntitiesInspection { @NonNls public static final Key SHORT_NAME_KEY = Key.create(REQUIRED_ATTRIBUTES_SHORT_NAME); protected static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.htmlInspections.RequiredAttributesInspection"); public String myAdditionalRequiredHtmlAttributes = ""; @@ -77,7 +90,129 @@ public class RequiredAttributesInspectionBase extends XmlSuppressableInspectionT return true; } - public static IntentionAction getIntentionAction(String name) { + public static LocalQuickFix getIntentionAction(String name) { return new AddHtmlTagOrAttributeToCustomsIntention(SHORT_NAME_KEY, name, XmlBundle.message("add.optional.html.attribute", name)); } + + @Override + protected void checkTag(@NotNull XmlTag tag, @NotNull ProblemsHolder holder, boolean isOnTheFly) { + + String name = tag.getName(); + XmlElementDescriptor elementDescriptor = XmlUtil.getDescriptorFromContext(tag); + if (elementDescriptor instanceof AnyXmlElementDescriptor || elementDescriptor == null) { + elementDescriptor = tag.getDescriptor(); + } + + if (elementDescriptor == null) return; + if ((elementDescriptor instanceof XmlHighlightingAwareElementDescriptor) && + !((XmlHighlightingAwareElementDescriptor)elementDescriptor).shouldCheckRequiredAttributes()) { + return; + } + + XmlAttributeDescriptor[] attributeDescriptors = elementDescriptor.getAttributesDescriptors(tag); + Set requiredAttributes = null; + + for (XmlAttributeDescriptor attribute : attributeDescriptors) { + if (attribute != null && attribute.isRequired()) { + if (requiredAttributes == null) { + requiredAttributes = new HashSet<>(); + } + requiredAttributes.add(attribute.getName(tag)); + } + } + + if (requiredAttributes != null) { + for (final String attrName : requiredAttributes) { + if (!hasAttribute(tag, attrName) && + !XmlExtension.getExtension(tag.getContainingFile()).isRequiredAttributeImplicitlyPresent(tag, attrName)) { + + LocalQuickFix insertRequiredAttributeIntention = XmlQuickFixFactory.getInstance().insertRequiredAttributeFix(tag, attrName); + final String localizedMessage = XmlErrorMessages.message("element.doesnt.have.required.attribute", name, attrName); + reportOneTagProblem( + tag, + attrName, + localizedMessage, + insertRequiredAttributeIntention, + holder, + getIntentionAction(attrName) + ); + } + } + } + } + + private static boolean hasAttribute(XmlTag tag, String attrName) { + final XmlAttribute attribute = tag.getAttribute(attrName); + if (attribute == null) return false; + if (attribute.getValueElement() != null) return true; + if (!(tag instanceof HtmlTag)) return false; + final XmlAttributeDescriptor descriptor = attribute.getDescriptor(); + return descriptor != null && HtmlUtil.isBooleanAttribute(descriptor, tag); + } + + private void reportOneTagProblem(final XmlTag tag, + final String name, + @NotNull String localizedMessage, + final LocalQuickFix basicIntention, + ProblemsHolder holder, + final LocalQuickFix addAttributeFix) { + boolean htmlTag = false; + + if (tag instanceof HtmlTag) { + htmlTag = true; + if(isAdditionallyDeclared(getAdditionalEntries(), name)) return; + } + + if (htmlTag) { + addElementsForTag( + tag, + localizedMessage, + isInjectedWithoutValidation(tag) ? ProblemHighlightType.INFORMATION : ProblemHighlightType.GENERIC_ERROR_OR_WARNING, + holder, + addAttributeFix, + basicIntention); + } + else { + addElementsForTag( + tag, + localizedMessage, + ProblemHighlightType.ERROR, + holder, + basicIntention + ); + } + } + + private static void addElementsForTag(XmlTag tag, + String message, + ProblemHighlightType error, + ProblemsHolder holder, + LocalQuickFix... fixes) { + registerProblem(message, error, holder, XmlTagUtil.getStartTagNameElement(tag), fixes); + registerProblem(message, error, holder, XmlTagUtil.getEndTagNameElement(tag), fixes); + } + + private static void registerProblem(String message, + ProblemHighlightType error, + ProblemsHolder holder, + XmlToken start, + LocalQuickFix[] fixes) { + if (start != null) { + holder.registerProblem(start, message, error, fixes); + } + } + + private static boolean isAdditionallyDeclared(final String additional, String name) { + name = name.toLowerCase(); + if (!additional.contains(name)) return false; + + StringTokenizer tokenizer = new StringTokenizer(additional, ", "); + while (tokenizer.hasMoreTokens()) { + if (name.equals(tokenizer.nextToken())) { + return true; + } + } + + return false; + } } From 0a8a19a99509923a18d70221e5a2adfe3381cd9c Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Tue, 14 Feb 2017 17:21:28 +0300 Subject: [PATCH 34/96] fixed text drawing under search matches --- .../src/com/intellij/ui/SimpleColoredComponent.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java index 120f8a30dc71..0b0066a7f814 100644 --- a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java +++ b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java @@ -852,7 +852,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible, Co } if (attributes.isSearchMatch()) { - searchMatches.add(new Object[]{(int)offset, (int)(offset + fragmentWidth), textBaseline, myFragments.get(i), g.getFont(), attributes}); + searchMatches.add(new Object[]{offset, offset + fragmentWidth, (float)textBaseline, myFragments.get(i), g.getFont(), attributes}); } offset = endOffset; @@ -870,12 +870,12 @@ public class SimpleColoredComponent extends JComponent implements Accessible, Co // draw search matches after all for (final Object[] info : searchMatches) { - Integer x1 = (Integer)info[0]; - Integer x2 = (Integer)info[1]; - UIUtil.drawSearchMatch(g, x1, x2, getHeight()); + float x1 = (float)info[0]; + float x2 = (float)info[1]; + UIUtil.drawSearchMatch(g, (int)x1, (int)x2, getHeight()); g.setFont((Font)info[4]); - Integer baseline = (Integer)info[2]; + float baseline = (float)info[2]; String text = (String)info[3]; if (shouldDrawMacShadow()) { g.setColor(SHADOW_COLOR); @@ -886,7 +886,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible, Co g.drawString(text, x1, baseline); if (((SimpleTextAttributes)info[5]).isStrikeout()) { - EffectPainter.STRIKE_THROUGH.paint(g, x1, baseline, x2 - x1, getCharHeight(g), g.getFont()); + EffectPainter.STRIKE_THROUGH.paint(g, (int)x1, (int)baseline, (int)(x2 - x1), getCharHeight(g), g.getFont()); } } return (int)offset; From 4095963446437d899a80fe90f34811629c1a1eec Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 14 Feb 2017 15:25:33 +0100 Subject: [PATCH 35/96] Cleanup (formatting) --- .../impl/compiled/ClsModifierListImpl.java | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsModifierListImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsModifierListImpl.java index 03e7013f1d7c..3d86d1b581bb 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsModifierListImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsModifierListImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,12 +24,10 @@ import com.intellij.psi.impl.source.SourceTreeToPsiMap; import com.intellij.psi.impl.source.tree.JavaElementType; import com.intellij.psi.impl.source.tree.TreeElement; import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -@SuppressWarnings("ForLoopReplaceableByForEach") public class ClsModifierListImpl extends ClsRepositoryPsiElement implements PsiModifierList { - public ClsModifierListImpl(final PsiModifierListStub stub) { + public ClsModifierListImpl(PsiModifierListStub stub) { super(stub); } @@ -78,29 +76,29 @@ public class ClsModifierListImpl extends ClsRepositoryPsiElement Date: Tue, 14 Feb 2017 17:30:09 +0300 Subject: [PATCH 36/96] properties: cleanup (replace with forEach) --- .../rename/RenamePropertyProcessor.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/properties/src/com/intellij/lang/properties/refactoring/rename/RenamePropertyProcessor.java b/plugins/properties/src/com/intellij/lang/properties/refactoring/rename/RenamePropertyProcessor.java index e42b52d0d24b..7078958d5986 100644 --- a/plugins/properties/src/com/intellij/lang/properties/refactoring/rename/RenamePropertyProcessor.java +++ b/plugins/properties/src/com/intellij/lang/properties/refactoring/rename/RenamePropertyProcessor.java @@ -48,13 +48,13 @@ public class RenamePropertyProcessor extends RenamePsiElementProcessor { final Map allRenamesCopy = new LinkedHashMap<>(allRenames); allRenames.clear(); - for (final Map.Entry e : allRenamesCopy.entrySet()) { - final IProperty property = PropertiesImplUtil.getProperty(e.getKey()); + allRenamesCopy.forEach((key, value) -> { + final IProperty property = PropertiesImplUtil.getProperty(key); final List properties = PropertiesUtil.findAllProperties(resourceBundle, property.getUnescapedKey()); for (final IProperty toRename : properties) { - allRenames.put(toRename.getPsiElement(), e.getValue()); + allRenames.put(toRename.getPsiElement(), value); } - } + }); } @Override @@ -62,18 +62,18 @@ public class RenamePropertyProcessor extends RenamePsiElementProcessor { final String newName, Map allRenames, List result) { - for (final Map.Entry e: allRenames.entrySet()) { - for (IProperty property : ((PropertiesFile)e.getKey().getContainingFile()).getProperties()) { - if (Comparing.strEqual(e.getValue(), property.getKey())) { - result.add(new UnresolvableCollisionUsageInfo(property.getPsiElement(), e.getKey()) { + allRenames.forEach((key, value) -> { + for (IProperty property : ((PropertiesFile)key.getContainingFile()).getProperties()) { + if (Comparing.strEqual(value, property.getKey())) { + result.add(new UnresolvableCollisionUsageInfo(property.getPsiElement(), key) { @Override public String getDescription() { - return "New property name \'" + e.getValue() + "\' hides existing property"; + return "New property name \'" + value + "\' hides existing property"; } }); } } - } + }); } @Override From 298ccc490130d58d353b837d0484942664b819cc Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Tue, 14 Feb 2017 15:32:59 +0100 Subject: [PATCH 37/96] Fix usages of broken PythonSdkType.getSdk method, which didn't take in account a Python facet configuration. --- .../newProject/steps/PythonBaseProjectGenerator.java | 2 +- .../userSkeletons/PyUserSkeletonsUtil.java | 2 +- .../PyUnresolvedReferencesInspection.java | 2 +- .../python/psi/resolve/PyResolveImportUtil.kt | 2 +- python/src/com/jetbrains/python/sdk/PySdkUtil.java | 2 +- .../src/com/jetbrains/python/sdk/PythonSdkType.java | 12 +++++++----- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/python/python-community-configure/src/com/jetbrains/python/newProject/steps/PythonBaseProjectGenerator.java b/python/python-community-configure/src/com/jetbrains/python/newProject/steps/PythonBaseProjectGenerator.java index d2c9d565e367..e3db007e52fc 100644 --- a/python/python-community-configure/src/com/jetbrains/python/newProject/steps/PythonBaseProjectGenerator.java +++ b/python/python-community-configure/src/com/jetbrains/python/newProject/steps/PythonBaseProjectGenerator.java @@ -74,7 +74,7 @@ public class PythonBaseProjectGenerator extends PythonProjectGenerator 0) { val absoluteName = containingName.append(name) - val sdk = PythonSdkType.getSdk(footholdFile) ?: return emptyList() + val sdk = PythonSdkType.findPythonSdk(footholdFile) ?: return emptyList() val skeletonsVirtualFile = PySdkUtil.findSkeletonsDir(sdk) ?: return emptyList() val skeletonsDir = context.psiManager.findDirectory(skeletonsVirtualFile) return resolveModuleAt(absoluteName, skeletonsDir, context) diff --git a/python/src/com/jetbrains/python/sdk/PySdkUtil.java b/python/src/com/jetbrains/python/sdk/PySdkUtil.java index 0c362badc0c8..48210bbd82e7 100644 --- a/python/src/com/jetbrains/python/sdk/PySdkUtil.java +++ b/python/src/com/jetbrains/python/sdk/PySdkUtil.java @@ -199,7 +199,7 @@ public class PySdkUtil { if (file != null) { final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile != null) { - final Sdk sdk = PythonSdkType.getSdk(element); + final Sdk sdk = PythonSdkType.findPythonSdk(element); if (sdk != null) { final VirtualFile skeletonsDir = findSkeletonsDir(sdk); if (skeletonsDir != null && VfsUtilCore.isAncestor(skeletonsDir, virtualFile, false)) { diff --git a/python/src/com/jetbrains/python/sdk/PythonSdkType.java b/python/src/com/jetbrains/python/sdk/PythonSdkType.java index ad437e20a644..173e4c8861d8 100644 --- a/python/src/com/jetbrains/python/sdk/PythonSdkType.java +++ b/python/src/com/jetbrains/python/sdk/PythonSdkType.java @@ -692,6 +692,11 @@ public final class PythonSdkType extends SdkType { return null; } + @Nullable + public static Sdk findPythonSdk(@NotNull final PsiElement element) { + return findPythonSdk(ModuleUtilCore.findModuleForPsiElement(element)); + } + @Nullable public static Sdk findSdkByPath(@Nullable String path) { if (path != null) { @@ -901,13 +906,10 @@ public final class PythonSdkType extends SdkType { return false; } + @Deprecated @Nullable public static Sdk getSdk(@NotNull final PsiElement element) { - Module module = ModuleUtilCore.findModuleForPsiElement(element); - if (module == null) { - return null; - } - return ModuleRootManager.getInstance(module).getSdk(); + return findPythonSdk(element); } @NotNull From b85b368afbad3da4edea96f5619ae46b74e2a45a Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Tue, 14 Feb 2017 17:50:16 +0300 Subject: [PATCH 38/96] use non-opaque scroll bar by default --- .../src/com/intellij/ui/components/DefaultScrollBarUI.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/platform-api/src/com/intellij/ui/components/DefaultScrollBarUI.java b/platform/platform-api/src/com/intellij/ui/components/DefaultScrollBarUI.java index 465082ebd351..234f9d607255 100644 --- a/platform/platform-api/src/com/intellij/ui/components/DefaultScrollBarUI.java +++ b/platform/platform-api/src/com/intellij/ui/components/DefaultScrollBarUI.java @@ -195,6 +195,7 @@ class DefaultScrollBarUI extends ScrollBarUI { myScrollBar = (JScrollBar)c; ScrollColorProducer.setBackground(c); ScrollColorProducer.setForeground(c); + myScrollBar.setOpaque(false); myScrollBar.setFocusable(false); myScrollBar.addMouseListener(myListener); myScrollBar.addMouseMotionListener(myListener); From 7e0d0fe1accc98e92d290a974b90c2aad150485a Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Tue, 14 Feb 2017 14:09:32 +0000 Subject: [PATCH 39/96] Move ComboBoxTableCellRenderer from util to platform-impl There is no need to store this class in util, and there are no external usages. --- .../src/com/intellij}/ui/ComboBoxTableCellRenderer.java | 4 ++-- .../cvsAdd/ui/AddMultipleFilesOptionsDialog.java | 2 +- plugins/git4idea/src/git4idea/rebase/GitRebaseEditor.java | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) rename platform/{util/src/com/intellij/util => platform-impl/src/com/intellij}/ui/ComboBoxTableCellRenderer.java (97%) diff --git a/platform/util/src/com/intellij/util/ui/ComboBoxTableCellRenderer.java b/platform/platform-impl/src/com/intellij/ui/ComboBoxTableCellRenderer.java similarity index 97% rename from platform/util/src/com/intellij/util/ui/ComboBoxTableCellRenderer.java rename to platform/platform-impl/src/com/intellij/ui/ComboBoxTableCellRenderer.java index 858dc92b5fe9..4ae37bfa94a3 100644 --- a/platform/util/src/com/intellij/util/ui/ComboBoxTableCellRenderer.java +++ b/platform/platform-impl/src/com/intellij/ui/ComboBoxTableCellRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.util.ui; +package com.intellij.ui; import com.intellij.openapi.diagnostic.LogUtil; import com.intellij.openapi.diagnostic.Logger; diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsAdd/ui/AddMultipleFilesOptionsDialog.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsAdd/ui/AddMultipleFilesOptionsDialog.java index c60efc426099..dc3f342c4c47 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsAdd/ui/AddMultipleFilesOptionsDialog.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsAdd/ui/AddMultipleFilesOptionsDialog.java @@ -33,7 +33,7 @@ import com.intellij.ui.treeStructure.treetable.TreeTable; import com.intellij.ui.treeStructure.treetable.TreeTableModel; import com.intellij.ui.treeStructure.treetable.TreeTableTree; import com.intellij.util.ui.ColumnInfo; -import com.intellij.util.ui.ComboBoxTableCellRenderer; +import com.intellij.ui.ComboBoxTableCellRenderer; import com.intellij.util.ui.table.ComboBoxTableCellEditor; import com.intellij.util.ui.tree.TreeUtil; import org.netbeans.lib.cvsclient.command.KeywordSubstitution; diff --git a/plugins/git4idea/src/git4idea/rebase/GitRebaseEditor.java b/plugins/git4idea/src/git4idea/rebase/GitRebaseEditor.java index c556621e433f..6d881754d0a9 100644 --- a/plugins/git4idea/src/git4idea/rebase/GitRebaseEditor.java +++ b/plugins/git4idea/src/git4idea/rebase/GitRebaseEditor.java @@ -35,7 +35,6 @@ import com.intellij.util.ArrayUtil; import com.intellij.util.ListWithSelection; import com.intellij.util.PairFunction; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.ui.ComboBoxTableCellRenderer; import com.intellij.util.ui.EditableModel; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; From a78644886b7b8c1ff7592c1b826e47bb43ce7d96 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Tue, 14 Feb 2017 14:11:42 +0000 Subject: [PATCH 40/96] Use ComboBox instead of deprecated JComboBox --- .../src/com/intellij/ui/ComboBoxTableCellRenderer.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/ComboBoxTableCellRenderer.java b/platform/platform-impl/src/com/intellij/ui/ComboBoxTableCellRenderer.java index 4ae37bfa94a3..0f2117af9ecc 100644 --- a/platform/platform-impl/src/com/intellij/ui/ComboBoxTableCellRenderer.java +++ b/platform/platform-impl/src/com/intellij/ui/ComboBoxTableCellRenderer.java @@ -17,13 +17,15 @@ package com.intellij.ui; import com.intellij.openapi.diagnostic.LogUtil; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.ui.ComboBox; import com.intellij.util.ListWithSelection; +import com.intellij.util.ui.JBUI; import javax.swing.*; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableCellRenderer; import java.awt.*; -import java.util.Arrays; +import java.util.Collections; public class ComboBoxTableCellRenderer extends JPanel implements TableCellRenderer { public static final TableCellRenderer INSTANCE = new ComboBoxTableCellRenderer(); @@ -35,7 +37,7 @@ public class ComboBoxTableCellRenderer extends JPanel implements TableCellRender @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (isSelected) { - value = new ListWithSelection(Arrays.asList(value)); + value = new ListWithSelection<>(Collections.singletonList(value)); return INSTANCE.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); @@ -44,12 +46,12 @@ public class ComboBoxTableCellRenderer extends JPanel implements TableCellRender private static final Logger LOG = Logger.getInstance("#com.intellij.util.ui.ComboBoxTableCellRenderer"); - private final JComboBox myCombo = new JComboBox(); + private final JComboBox myCombo = new ComboBox(); private ComboBoxTableCellRenderer() { super(new GridBagLayout()); add(myCombo, - new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); + new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, JBUI.emptyInsets(), 0, 0)); } @Override From 3781b61200a191c1019de8aa6e8fac1e2456ac93 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Wed, 8 Feb 2017 16:26:27 +0300 Subject: [PATCH 41/96] diff: listen for settings changes Fix issue with wrong selected option being displayed on toolbar, if it was changed from another diff viewer that shares TextDiffSettings. --- .../intellij/diff/merge/TextMergeViewer.java | 1 + .../tools/fragmented/UnifiedDiffViewer.java | 2 +- .../diff/tools/simple/SimpleDiffViewer.java | 2 +- .../tools/simple/SimpleOnesideDiffViewer.java | 2 +- .../simple/SimpleThreesideDiffViewer.java | 2 +- .../tools/util/base/TextDiffSettingsHolder.kt | 23 ++++++++++++-- .../tools/util/base/TextDiffViewerUtil.java | 8 ----- .../util/text/SimpleTextDiffProvider.java | 30 ++++++++++-------- .../text/SimpleThreesideTextDiffProvider.java | 6 ++-- .../util/text/SmartTextDiffProvider.java | 20 +++++++----- .../tools/util/text/TextDiffProviderBase.java | 31 +++++++++++++++---- .../text/TwosideTextDiffProviderBase.java | 4 ++- .../src/com/intellij/diff/util/DiffUtil.java | 18 ++++++----- 13 files changed, 97 insertions(+), 52 deletions(-) diff --git a/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java b/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java index 0ff6b9d52750..2fbbf26dd7b8 100644 --- a/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java @@ -204,6 +204,7 @@ public class TextMergeViewer implements MergeTool.MergeViewer { myTextDiffProvider = new TextDiffProviderBase(getTextSettings(), myInnerDiffWorker::onSettingsChanged, + this, ar(IgnorePolicy.DEFAULT), ar(HighlightPolicy.BY_LINE, HighlightPolicy.BY_WORD)); diff --git a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffViewer.java index e349a8d24e94..6ec2a2249e20 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffViewer.java @@ -122,7 +122,7 @@ public class UnifiedDiffViewer extends ListenerDiffViewerBase { myEditorSettingsAction = new SetEditorSettingsAction(getTextSettings(), getEditors()); myEditorSettingsAction.applyDefaults(); - myTextDiffProvider = DiffUtil.createNoIgnoreTextDiffProvider(getProject(), getRequest(), getTextSettings(), this::rediff); + myTextDiffProvider = DiffUtil.createNoIgnoreTextDiffProvider(getProject(), getRequest(), getTextSettings(), this::rediff, this); new MyOpenInEditorWithMouseAction().install(getEditors()); diff --git a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java index 957d5645f9cc..defe89e10024 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java @@ -80,7 +80,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { myModifierProvider = new ModifierProvider(); - myTextDiffProvider = DiffUtil.createTextDiffProvider(getProject(), getRequest(), getTextSettings(), this::rediff); + myTextDiffProvider = DiffUtil.createTextDiffProvider(getProject(), getRequest(), getTextSettings(), this::rediff, this); DiffUtil.registerAction(new ReplaceSelectedChangesAction(Side.LEFT, true), myPanel); DiffUtil.registerAction(new AppendSelectedChangesAction(Side.LEFT, true), myPanel); diff --git a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleOnesideDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleOnesideDiffViewer.java index c71919ade10d..c5e898b4c2e9 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleOnesideDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleOnesideDiffViewer.java @@ -56,7 +56,7 @@ public class SimpleOnesideDiffViewer extends OnesideTextDiffViewer { public SimpleOnesideDiffViewer(@NotNull DiffContext context, @NotNull DiffRequest request) { super(context, (ContentDiffRequest)request); - myTextDiffProvider = DiffUtil.createTextDiffProvider(getProject(), getRequest(), getTextSettings(), this::rediff); + myTextDiffProvider = DiffUtil.createTextDiffProvider(getProject(), getRequest(), getTextSettings(), this::rediff, this); } @Override diff --git a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java index c56f9631da6e..8b96b57d2f5d 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleThreesideDiffViewer.java @@ -49,7 +49,7 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewerEx { public SimpleThreesideDiffViewer(@NotNull DiffContext context, @NotNull DiffRequest request) { super(context, (ContentDiffRequest)request); - myTextDiffProvider = new SimpleThreesideTextDiffProvider(getTextSettings(), this::rediff); + myTextDiffProvider = new SimpleThreesideTextDiffProvider(getTextSettings(), this::rediff, this); } @NotNull diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffSettingsHolder.kt b/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffSettingsHolder.kt index 5c1a3d347322..e73fb380730a 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffSettingsHolder.kt +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffSettingsHolder.kt @@ -17,12 +17,15 @@ package com.intellij.diff.tools.util.base import com.intellij.diff.util.DiffPlaces import com.intellij.diff.util.DiffUtil +import com.intellij.openapi.Disposable import com.intellij.openapi.components.PersistentStateComponent import com.intellij.openapi.components.State import com.intellij.openapi.components.Storage import com.intellij.openapi.components.service import com.intellij.openapi.util.Key +import com.intellij.util.EventDispatcher import com.intellij.util.xmlb.annotations.MapAnnotation +import com.intellij.util.xmlb.annotations.Transient import java.util.* @State( @@ -61,12 +64,19 @@ class TextDiffSettingsHolder : PersistentStateComponent = EventDispatcher.create(TextDiffSettings.Listener::class.java) + } class TextDiffSettings internal constructor(private val SHARED_SETTINGS: SharedSettings, private val PLACE_SETTINGS: PlaceSettings) { constructor() : this(SharedSettings(), PlaceSettings()) + fun addListener(listener: Listener, disposable: Disposable) { + PLACE_SETTINGS.eventDispatcher.addListener(listener, disposable) + } + // Presentation settings var isEnableSyncScroll: Boolean @@ -77,11 +87,13 @@ class TextDiffSettingsHolder : PersistentStateComponent().getSettings(place) } + + interface Listener : EventListener { + fun highlightPolicyChanged() {} + fun ignorePolicyChanged() {} + } } fun getSettings(place: String?): TextDiffSettings { diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffViewerUtil.java b/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffViewerUtil.java index 75a29ea24570..afbb66c661fd 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffViewerUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffViewerUtil.java @@ -261,14 +261,11 @@ public class TextDiffViewerUtil { public static class HighlightPolicySettingAction extends EnumPolicySettingAction { @NotNull protected final TextDiffSettings mySettings; - @NotNull private final Runnable myRediffRunnable; public HighlightPolicySettingAction(@NotNull TextDiffSettings settings, - @NotNull Runnable rediff, @NotNull HighlightPolicy... policies) { super(policies); mySettings = settings; - myRediffRunnable = rediff; } @Override @@ -276,7 +273,6 @@ public class TextDiffViewerUtil { if (getValue() == option) return; UsageTrigger.trigger("diff.TextDiffSettings.HighlightPolicy." + option.name()); mySettings.setHighlightPolicy(option); - myRediffRunnable.run(); } @NotNull @@ -306,14 +302,11 @@ public class TextDiffViewerUtil { public static class IgnorePolicySettingAction extends EnumPolicySettingAction { @NotNull protected final TextDiffSettings mySettings; - @NotNull private final Runnable myRediffRunnable; public IgnorePolicySettingAction(@NotNull TextDiffSettings settings, - @NotNull Runnable rediff, @NotNull IgnorePolicy... policies) { super(policies); mySettings = settings; - myRediffRunnable = rediff; } @Override @@ -321,7 +314,6 @@ public class TextDiffViewerUtil { if (getValue() == option) return; UsageTrigger.trigger("diff.TextDiffSettings.IgnorePolicy." + option.name()); mySettings.setIgnorePolicy(option); - myRediffRunnable.run(); } @NotNull diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/text/SimpleTextDiffProvider.java b/platform/diff-impl/src/com/intellij/diff/tools/util/text/SimpleTextDiffProvider.java index 0935043c9372..96c00f7d1572 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/text/SimpleTextDiffProvider.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/text/SimpleTextDiffProvider.java @@ -21,7 +21,8 @@ import com.intellij.diff.fragments.LineFragment; import com.intellij.diff.tools.util.base.HighlightPolicy; import com.intellij.diff.tools.util.base.IgnorePolicy; import com.intellij.diff.tools.util.base.TextDiffSettingsHolder.TextDiffSettings; -import com.intellij.diff.util.DiffUserDataKeysEx; +import com.intellij.diff.util.DiffUserDataKeysEx.DiffComputer; +import com.intellij.openapi.Disposable; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; @@ -32,7 +33,7 @@ import static com.intellij.diff.tools.util.base.HighlightPolicy.*; import static com.intellij.diff.tools.util.base.IgnorePolicy.*; public class SimpleTextDiffProvider extends TwosideTextDiffProviderBase implements TwosideTextDiffProvider { - static final DiffUserDataKeysEx.DiffComputer DEFAULT_COMPUTER = (text1, text2, policy, innerChanges, indicator) -> { + static final DiffComputer DEFAULT_COMPUTER = (text1, text2, policy, innerChanges, indicator) -> { if (innerChanges) { return ComparisonManager.getInstance().compareLinesInner(text1, text2, policy, indicator); } @@ -44,25 +45,28 @@ public class SimpleTextDiffProvider extends TwosideTextDiffProviderBase implemen private static final IgnorePolicy[] IGNORE_POLICIES = {DEFAULT, TRIM_WHITESPACES, IGNORE_WHITESPACES, IGNORE_WHITESPACES_CHUNKS}; private static final HighlightPolicy[] HIGHLIGHT_POLICIES = {BY_LINE, BY_WORD, BY_WORD_SPLIT, DO_NOT_HIGHLIGHT}; - @NotNull private final DiffUserDataKeysEx.DiffComputer myDiffComputer; + @NotNull private final DiffComputer myDiffComputer; public SimpleTextDiffProvider(@NotNull TextDiffSettings settings, - @NotNull Runnable rediff) { - this(settings, rediff, DEFAULT_COMPUTER); + @NotNull Runnable rediff, + @NotNull Disposable disposable) { + this(settings, rediff, disposable, DEFAULT_COMPUTER); } public SimpleTextDiffProvider(@NotNull TextDiffSettings settings, @NotNull Runnable rediff, - @NotNull DiffUserDataKeysEx.DiffComputer diffComputer) { - this(settings, rediff, diffComputer, IGNORE_POLICIES, HIGHLIGHT_POLICIES); + @NotNull Disposable disposable, + @NotNull DiffComputer diffComputer) { + this(settings, rediff, disposable, diffComputer, IGNORE_POLICIES, HIGHLIGHT_POLICIES); } private SimpleTextDiffProvider(@NotNull TextDiffSettings settings, @NotNull Runnable rediff, - @NotNull DiffUserDataKeysEx.DiffComputer diffComputer, + @NotNull Disposable disposable, + @NotNull DiffComputer diffComputer, @NotNull IgnorePolicy[] ignorePolicies, @NotNull HighlightPolicy[] highlightPolicies) { - super(settings, rediff, ignorePolicies, highlightPolicies); + super(settings, rediff, disposable, ignorePolicies, highlightPolicies); myDiffComputer = diffComputer; } @@ -79,12 +83,12 @@ public class SimpleTextDiffProvider extends TwosideTextDiffProviderBase implemen public static class NoIgnore extends SimpleTextDiffProvider implements TwosideTextDiffProvider.NoIgnore { - public NoIgnore(@NotNull TextDiffSettings settings, @NotNull Runnable rediff) { - this(settings, rediff, DEFAULT_COMPUTER); + public NoIgnore(@NotNull TextDiffSettings settings, @NotNull Runnable rediff, @NotNull Disposable disposable) { + this(settings, rediff, disposable, DEFAULT_COMPUTER); } - public NoIgnore(@NotNull TextDiffSettings settings, @NotNull Runnable rediff, @NotNull DiffUserDataKeysEx.DiffComputer diffComputer) { - super(settings, rediff, diffComputer, IGNORE_POLICIES, ArrayUtil.remove(HIGHLIGHT_POLICIES, DO_NOT_HIGHLIGHT)); + public NoIgnore(@NotNull TextDiffSettings settings, @NotNull Runnable rediff, @NotNull Disposable disposable, @NotNull DiffComputer diffComputer) { + super(settings, rediff, disposable, diffComputer, IGNORE_POLICIES, ArrayUtil.remove(HIGHLIGHT_POLICIES, DO_NOT_HIGHLIGHT)); } @NotNull diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/text/SimpleThreesideTextDiffProvider.java b/platform/diff-impl/src/com/intellij/diff/tools/util/text/SimpleThreesideTextDiffProvider.java index 9033bd4e875b..3fffcdc1e4e6 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/text/SimpleThreesideTextDiffProvider.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/text/SimpleThreesideTextDiffProvider.java @@ -24,6 +24,7 @@ import com.intellij.diff.tools.util.base.TextDiffSettingsHolder.TextDiffSettings import com.intellij.diff.util.DiffUtil; import com.intellij.diff.util.MergeConflictType; import com.intellij.diff.util.ThreeSide; +import com.intellij.openapi.Disposable; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; @@ -40,8 +41,9 @@ public class SimpleThreesideTextDiffProvider extends TextDiffProviderBase { private static final HighlightPolicy[] HIGHLIGHT_POLICIES = {BY_LINE, BY_WORD}; public SimpleThreesideTextDiffProvider(@NotNull TextDiffSettings settings, - @NotNull Runnable rediff) { - super(settings, rediff, IGNORE_POLICIES, HIGHLIGHT_POLICIES); + @NotNull Runnable rediff, + @NotNull Disposable disposable) { + super(settings, rediff, disposable, IGNORE_POLICIES, HIGHLIGHT_POLICIES); } @NotNull diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/text/SmartTextDiffProvider.java b/platform/diff-impl/src/com/intellij/diff/tools/util/text/SmartTextDiffProvider.java index 44fd83b3a3ae..eb53db9c76ca 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/text/SmartTextDiffProvider.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/text/SmartTextDiffProvider.java @@ -25,6 +25,7 @@ import com.intellij.diff.tools.util.base.HighlightPolicy; import com.intellij.diff.tools.util.base.IgnorePolicy; import com.intellij.diff.tools.util.base.TextDiffSettingsHolder.TextDiffSettings; import com.intellij.diff.util.Side; +import com.intellij.openapi.Disposable; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; @@ -51,24 +52,26 @@ public class SmartTextDiffProvider extends TwosideTextDiffProviderBase implement public static TwosideTextDiffProvider create(@Nullable Project project, @NotNull ContentDiffRequest request, @NotNull TextDiffSettings settings, - @NotNull Runnable rediff) { + @NotNull Runnable rediff, + @NotNull Disposable disposable) { DiffContent content1 = Side.LEFT.select(request.getContents()); DiffContent content2 = Side.RIGHT.select(request.getContents()); DiffIgnoredRangeProvider ignoredRangeProvider = getIgnoredRangeProvider(project, content1, content2); if (ignoredRangeProvider == null) return null; - return new SmartTextDiffProvider(project, content1, content2, settings, rediff, ignoredRangeProvider); + return new SmartTextDiffProvider(project, content1, content2, settings, rediff, disposable, ignoredRangeProvider); } @Nullable public static TwosideTextDiffProvider.NoIgnore createNoIgnore(@Nullable Project project, @NotNull ContentDiffRequest request, @NotNull TextDiffSettings settings, - @NotNull Runnable rediff) { + @NotNull Runnable rediff, + @NotNull Disposable disposable) { DiffContent content1 = Side.LEFT.select(request.getContents()); DiffContent content2 = Side.RIGHT.select(request.getContents()); DiffIgnoredRangeProvider ignoredRangeProvider = getIgnoredRangeProvider(project, content1, content2); if (ignoredRangeProvider == null) return null; - return new SmartTextDiffProvider.NoIgnore(project, content1, content2, settings, rediff, ignoredRangeProvider); + return new SmartTextDiffProvider.NoIgnore(project, content1, content2, settings, rediff, disposable, ignoredRangeProvider); } private SmartTextDiffProvider(@Nullable Project project, @@ -76,8 +79,9 @@ public class SmartTextDiffProvider extends TwosideTextDiffProviderBase implement @NotNull DiffContent content2, @NotNull TextDiffSettings settings, @NotNull Runnable rediff, + @NotNull Disposable disposable, @NotNull DiffIgnoredRangeProvider ignoredRangeProvider) { - this(project, content1, content2, settings, rediff, ignoredRangeProvider, IGNORE_POLICIES, HIGHLIGHT_POLICIES); + this(project, content1, content2, settings, rediff, disposable, ignoredRangeProvider, IGNORE_POLICIES, HIGHLIGHT_POLICIES); } private SmartTextDiffProvider(@Nullable Project project, @@ -85,10 +89,11 @@ public class SmartTextDiffProvider extends TwosideTextDiffProviderBase implement @NotNull DiffContent content2, @NotNull TextDiffSettings settings, @NotNull Runnable rediff, + @NotNull Disposable disposable, @NotNull DiffIgnoredRangeProvider ignoredRangeProvider, @NotNull IgnorePolicy[] ignorePolicies, @NotNull HighlightPolicy[] highlightPolicies) { - super(settings, rediff, ignorePolicies, highlightPolicies); + super(settings, rediff, disposable, ignorePolicies, highlightPolicies); myProject = project; myContent1 = content1; myContent2 = content2; @@ -151,8 +156,9 @@ public class SmartTextDiffProvider extends TwosideTextDiffProviderBase implement @NotNull DiffContent content2, @NotNull TextDiffSettings settings, @NotNull Runnable rediff, + @NotNull Disposable disposable, @NotNull DiffIgnoredRangeProvider ignoredRangeProvider) { - super(project, content1, content2, settings, rediff, ignoredRangeProvider, + super(project, content1, content2, settings, rediff, disposable, ignoredRangeProvider, IGNORE_POLICIES, ArrayUtil.remove(HIGHLIGHT_POLICIES, DO_NOT_HIGHLIGHT)); } diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/text/TextDiffProviderBase.java b/platform/diff-impl/src/com/intellij/diff/tools/util/text/TextDiffProviderBase.java index b694652d147b..4fb4596ef62b 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/text/TextDiffProviderBase.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/text/TextDiffProviderBase.java @@ -20,6 +20,7 @@ import com.intellij.diff.tools.util.base.IgnorePolicy; import com.intellij.diff.tools.util.base.TextDiffSettingsHolder.TextDiffSettings; import com.intellij.diff.tools.util.base.TextDiffViewerUtil.HighlightPolicySettingAction; import com.intellij.diff.tools.util.base.TextDiffViewerUtil.IgnorePolicySettingAction; +import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.Separator; import org.jetbrains.annotations.NotNull; @@ -36,10 +37,12 @@ public class TextDiffProviderBase implements TextDiffProvider { public TextDiffProviderBase(@NotNull TextDiffSettings settings, @NotNull Runnable rediff, + @NotNull Disposable disposable, @NotNull IgnorePolicy[] ignorePolicies, @NotNull HighlightPolicy[] highlightPolicies) { - myIgnorePolicySettingAction = new MyIgnorePolicySettingAction(settings, rediff, ignorePolicies); - myHighlightPolicySettingAction = new MyHighlightPolicySettingAction(settings, rediff, highlightPolicies); + myIgnorePolicySettingAction = new MyIgnorePolicySettingAction(settings, ignorePolicies); + myHighlightPolicySettingAction = new MyHighlightPolicySettingAction(settings, highlightPolicies); + settings.addListener(new MyListener(rediff), disposable); } @NotNull @@ -86,9 +89,8 @@ public class TextDiffProviderBase implements TextDiffProvider { private class MyIgnorePolicySettingAction extends IgnorePolicySettingAction { public MyIgnorePolicySettingAction(@NotNull TextDiffSettings settings, - @NotNull Runnable rediff, @NotNull IgnorePolicy[] ignorePolicies) { - super(settings, rediff, ignorePolicies); + super(settings, ignorePolicies); } @NotNull @@ -100,9 +102,8 @@ public class TextDiffProviderBase implements TextDiffProvider { private class MyHighlightPolicySettingAction extends HighlightPolicySettingAction { public MyHighlightPolicySettingAction(@NotNull TextDiffSettings settings, - @NotNull Runnable rediff, @NotNull HighlightPolicy[] highlightPolicies) { - super(settings, rediff, highlightPolicies); + super(settings, highlightPolicies); } @NotNull @@ -111,4 +112,22 @@ public class TextDiffProviderBase implements TextDiffProvider { return notNullize(TextDiffProviderBase.this.getText(option), super.getText(option)); } } + + private static class MyListener implements TextDiffSettings.Listener { + @NotNull private final Runnable myRediff; + + public MyListener(@NotNull Runnable rediff) { + myRediff = rediff; + } + + @Override + public void highlightPolicyChanged() { + myRediff.run(); + } + + @Override + public void ignorePolicyChanged() { + myRediff.run(); + } + } } diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/text/TwosideTextDiffProviderBase.java b/platform/diff-impl/src/com/intellij/diff/tools/util/text/TwosideTextDiffProviderBase.java index c774f0879845..c43e3628a354 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/text/TwosideTextDiffProviderBase.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/text/TwosideTextDiffProviderBase.java @@ -21,6 +21,7 @@ import com.intellij.diff.fragments.LineFragment; import com.intellij.diff.tools.util.base.HighlightPolicy; import com.intellij.diff.tools.util.base.IgnorePolicy; import com.intellij.diff.tools.util.base.TextDiffSettingsHolder.TextDiffSettings; +import com.intellij.openapi.Disposable; import com.intellij.openapi.progress.ProgressIndicator; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -30,9 +31,10 @@ import java.util.List; abstract class TwosideTextDiffProviderBase extends TextDiffProviderBase implements TwosideTextDiffProvider { protected TwosideTextDiffProviderBase(@NotNull TextDiffSettings settings, @NotNull Runnable rediff, + @NotNull Disposable disposable, @NotNull IgnorePolicy[] ignorePolicies, @NotNull HighlightPolicy[] highlightPolicies) { - super(settings, rediff, ignorePolicies, highlightPolicies); + super(settings, rediff, disposable, ignorePolicies, highlightPolicies); } @Nullable diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java b/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java index 511a71fcc67f..4420b55e645c 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java @@ -600,28 +600,30 @@ public class DiffUtil { public static TwosideTextDiffProvider createTextDiffProvider(@Nullable Project project, @NotNull ContentDiffRequest request, @NotNull TextDiffSettings settings, - @NotNull Runnable rediff) { + @NotNull Runnable rediff, + @NotNull Disposable disposable) { DiffUserDataKeysEx.DiffComputer diffComputer = request.getUserData(DiffUserDataKeysEx.CUSTOM_DIFF_COMPUTER); - if (diffComputer != null) return new SimpleTextDiffProvider(settings, rediff, diffComputer); + if (diffComputer != null) return new SimpleTextDiffProvider(settings, rediff, disposable, diffComputer); - TwosideTextDiffProvider smartProvider = SmartTextDiffProvider.create(project, request, settings, rediff); + TwosideTextDiffProvider smartProvider = SmartTextDiffProvider.create(project, request, settings, rediff, disposable); if (smartProvider != null) return smartProvider; - return new SimpleTextDiffProvider(settings, rediff); + return new SimpleTextDiffProvider(settings, rediff, disposable); } @NotNull public static TwosideTextDiffProvider.NoIgnore createNoIgnoreTextDiffProvider(@Nullable Project project, @NotNull ContentDiffRequest request, @NotNull TextDiffSettings settings, - @NotNull Runnable rediff) { + @NotNull Runnable rediff, + @NotNull Disposable disposable) { DiffUserDataKeysEx.DiffComputer diffComputer = request.getUserData(DiffUserDataKeysEx.CUSTOM_DIFF_COMPUTER); - if (diffComputer != null) return new SimpleTextDiffProvider.NoIgnore(settings, rediff, diffComputer); + if (diffComputer != null) return new SimpleTextDiffProvider.NoIgnore(settings, rediff, disposable, diffComputer); - TwosideTextDiffProvider.NoIgnore smartProvider = SmartTextDiffProvider.createNoIgnore(project, request, settings, rediff); + TwosideTextDiffProvider.NoIgnore smartProvider = SmartTextDiffProvider.createNoIgnore(project, request, settings, rediff, disposable); if (smartProvider != null) return smartProvider; - return new SimpleTextDiffProvider.NoIgnore(settings, rediff); + return new SimpleTextDiffProvider.NoIgnore(settings, rediff, disposable); } @Nullable From fc9e05cffad2ccd2a77eef0092e46904c23de164 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sat, 11 Feb 2017 10:42:25 +0000 Subject: [PATCH 42/96] git tests: clear fields after other tasks in tear down Otherwise the project can't be teared down correctly, and dumpToStdOut also doesn't work. --- .../testSrc/com/intellij/vcs/test/VcsPlatformTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/vcs-tests/testSrc/com/intellij/vcs/test/VcsPlatformTest.kt b/platform/vcs-tests/testSrc/com/intellij/vcs/test/VcsPlatformTest.kt index 8633198dd3ba..20572182b148 100644 --- a/platform/vcs-tests/testSrc/com/intellij/vcs/test/VcsPlatformTest.kt +++ b/platform/vcs-tests/testSrc/com/intellij/vcs/test/VcsPlatformTest.kt @@ -73,9 +73,9 @@ abstract class VcsPlatformTest : PlatformTestCase() { override fun tearDown() { RunAll().append(ThrowableRunnable { waitForPendingTasks() }).append(ThrowableRunnable - { clearFields(this) }).append(ThrowableRunnable { runInEdtAndWait { super@VcsPlatformTest.tearDown() }}).append(ThrowableRunnable - { if (myAssertionsInTestDetected) TestLoggerFactory.dumpLogToStdout(myTestStartedIndicator) }) + { if (myAssertionsInTestDetected) TestLoggerFactory.dumpLogToStdout(myTestStartedIndicator) }).append(ThrowableRunnable + { clearFields(this) }) .run() } From 5dbdc6831468399b3df098862f9a2a2099b2add3 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sat, 11 Feb 2017 10:53:56 +0000 Subject: [PATCH 43/96] git tests: update repo info after gitignore commit --- .../git4idea/branch/GitBranchWorkerTest.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/plugins/git4idea/tests/git4idea/branch/GitBranchWorkerTest.kt b/plugins/git4idea/tests/git4idea/branch/GitBranchWorkerTest.kt index 81a2ae75f211..45afe94eba7e 100644 --- a/plugins/git4idea/tests/git4idea/branch/GitBranchWorkerTest.kt +++ b/plugins/git4idea/tests/git4idea/branch/GitBranchWorkerTest.kt @@ -24,7 +24,7 @@ import com.intellij.openapi.util.Ref import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.vcs.Executor -import com.intellij.openapi.vcs.Executor.cat +import com.intellij.openapi.vcs.Executor.* import com.intellij.openapi.vcs.changes.Change import com.intellij.openapi.vfs.VirtualFile import com.intellij.testFramework.runInEdtAndWait @@ -55,7 +55,7 @@ class GitBranchWorkerTest : GitPlatformTest() { public override fun setUp() { super.setUp() - Executor.cd(myProjectRoot) + cd(myProjectRoot) val community = Executor.mkdir("community") val contrib = Executor.mkdir("contrib") @@ -64,10 +64,11 @@ class GitBranchWorkerTest : GitPlatformTest() { myContrib = createRepository(contrib.path) myRepositories = Arrays.asList(myUltimate, myCommunity, myContrib) - Executor.cd(myProjectRoot) - Executor.touch(".gitignore", "community\ncontrib") + cd(myProjectRoot) + touch(".gitignore", "community\ncontrib") git("add .gitignore") git("commit -m gitignore") + myUltimate.update() } fun test_create_new_branch_without_problems() { @@ -473,7 +474,7 @@ class GitBranchWorkerTest : GitPlatformTest() { fun test_rollback_of_checkout_branch_as_new_branch_should_delete_branches() { branchWithCommit(myRepositories, "feature") - Executor.touch("feature.txt", "feature_content") + touch("feature.txt", "feature_content") git("add feature.txt") git("commit -m feature_changes") git("checkout master") @@ -597,7 +598,7 @@ class GitBranchWorkerTest : GitPlatformTest() { git("push -u origin $feature") // create a commit and merge it to master, but not to feature's upstream - Executor.touch("feature.txt", "feature content") + touch("feature.txt", "feature content") git("add feature.txt") git("commit -m feature_branch") git("checkout master") @@ -759,7 +760,7 @@ class GitBranchWorkerTest : GitPlatformTest() { fun test_checkout_in_detached_head() { cd(myCommunity) - Executor.touch("file.txt", "some content") + touch("file.txt", "some content") add("file.txt") commit("msg") git(myCommunity, "checkout HEAD^") @@ -903,7 +904,7 @@ class GitBranchWorkerTest : GitPlatformTest() { } cd(unmergedRepo) git("checkout todelete") - Executor.touch("afile.txt", "content") + touch("afile.txt", "content") git("add afile.txt") git("commit -m unmerged_commit") git("checkout master") From 5332f00a8d4dca1dd9a59d3dff5d722d0f174de6 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 10 Feb 2017 18:29:36 +0000 Subject: [PATCH 44/96] Allow to create Git branch without checking it out Add a checkbox to the branch creation dialog. Fixes IDEA-149886 --- .../src/com/intellij/openapi/ui/Messages.java | 2 +- .../actions/GitCreateNewBranchAction.java | 13 ++- .../src/git4idea/branch/GitBranchUtil.java | 14 ++-- .../src/git4idea/branch/GitBranchWorker.java | 6 ++ .../src/git4idea/branch/GitBrancher.java | 12 ++- .../src/git4idea/branch/GitBrancherImpl.java | 10 +++ .../branch/GitCreateBranchOperation.kt | 78 +++++++++++++++++ .../src/git4idea/branch/GitNewBranchDialog.kt | 48 +++++++++++ .../ui/branch/GitBranchPopupActions.java | 17 +++- .../git4idea/branch/GitBranchWorkerTest.kt | 84 ++++++++----------- 10 files changed, 220 insertions(+), 64 deletions(-) create mode 100644 plugins/git4idea/src/git4idea/branch/GitCreateBranchOperation.kt create mode 100644 plugins/git4idea/src/git4idea/branch/GitNewBranchDialog.kt diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index cd643eb17a29..9cf532cfbc84 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -1688,7 +1688,7 @@ public class Messages { } } - protected static class InputDialog extends MessageDialog { + public static class InputDialog extends MessageDialog { protected JTextComponent myField; private final InputValidator myValidator; diff --git a/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.java b/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.java index 02c4ae83c878..8dae1031d3cd 100644 --- a/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.java +++ b/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.java @@ -18,22 +18,29 @@ package git4idea.actions; import com.intellij.openapi.project.Project; import com.intellij.vcs.log.Hash; import git4idea.branch.GitBrancher; +import git4idea.branch.GitNewBranchOptions; import git4idea.repo.GitRepository; import org.jetbrains.annotations.NotNull; import static git4idea.branch.GitBranchUtil.getNewBranchNameFromUser; import static java.util.Collections.singleton; import static java.util.Collections.singletonList; +import static java.util.Collections.singletonMap; public class GitCreateNewBranchAction extends GitLogSingleCommitAction { @Override protected void actionPerformed(@NotNull GitRepository repository, @NotNull Hash commit) { Project project = repository.getProject(); - String name = getNewBranchNameFromUser(project, singleton(repository), "Checkout New Branch From " + commit.toShortString()); - if (name != null) { + GitNewBranchOptions options = getNewBranchNameFromUser(project, singleton(repository), "Checkout New Branch From " + commit.toShortString()); + if (options != null) { GitBrancher brancher = GitBrancher.getInstance(project); - brancher.checkoutNewBranchStartingFrom(name, commit.asString(), singletonList(repository), null); + if (options.shouldCheckout()) { + brancher.checkoutNewBranchStartingFrom(options.getName(), commit.asString(), singletonList(repository), null); + } + else { + brancher.createBranch(options.getName(), singletonMap(repository, commit.asString())); + } } } } diff --git a/plugins/git4idea/src/git4idea/branch/GitBranchUtil.java b/plugins/git4idea/src/git4idea/branch/GitBranchUtil.java index d90678ec1fb6..4792c378bc51 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBranchUtil.java +++ b/plugins/git4idea/src/git4idea/branch/GitBranchUtil.java @@ -21,7 +21,6 @@ import com.google.common.collect.Collections2; import com.intellij.dvcs.DvcsUtil; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.CharsetToolkit; @@ -260,13 +259,16 @@ public class GitBranchUtil { } /** - * Shows a message dialog to enter the name of new branch. - * @return name of new branch or {@code null} if user has cancelled the dialog. + *

Shows a message dialog to enter the name of new branch.

+ *

Optionally allows to not checkout this branch, and just create it.

+ * + * @return the name of the new branch and whether it should be checked out, or {@code null} if user has cancelled the dialog. */ @Nullable - public static String getNewBranchNameFromUser(@NotNull Project project, @NotNull Collection repositories, @NotNull String dialogTitle) { - return Messages.showInputDialog(project, "New branch name:", dialogTitle, null, "", - GitNewBranchNameValidator.newInstance(repositories)); + public static GitNewBranchOptions getNewBranchNameFromUser(@NotNull Project project, + @NotNull Collection repositories, + @NotNull String dialogTitle) { + return new GitNewBranchDialog(project, dialogTitle, GitNewBranchNameValidator.newInstance(repositories)).showAndGetOptions(); } /** diff --git a/plugins/git4idea/src/git4idea/branch/GitBranchWorker.java b/plugins/git4idea/src/git4idea/branch/GitBranchWorker.java index b7d14ea9f283..2d6676b941be 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBranchWorker.java +++ b/plugins/git4idea/src/git4idea/branch/GitBranchWorker.java @@ -38,6 +38,7 @@ import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.List; +import java.util.Map; /** * Executes the logic of git branch operations. @@ -75,6 +76,11 @@ public final class GitBranchWorker { } } + public void createBranch(@NotNull String name, @NotNull Map startPoints) { + updateInfo(startPoints.keySet()); + new GitCreateBranchOperation(myProject, myGit, myUiHandler, name, startPoints).execute(); + } + public void createNewTag(@NotNull final String name, @NotNull final String reference, @NotNull final List repositories) { for (GitRepository repository : repositories) { myGit.createNewTag(repository, name, null, reference); diff --git a/plugins/git4idea/src/git4idea/branch/GitBrancher.java b/plugins/git4idea/src/git4idea/branch/GitBrancher.java index 6a2ca1b58e3b..645012bc4e71 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBrancher.java +++ b/plugins/git4idea/src/git4idea/branch/GitBrancher.java @@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; +import java.util.Map; /** *

Executes various operations on Git branches: checkout, create new branch, merge, delete, compare.

@@ -29,7 +30,7 @@ import java.util.List; *

It also takes care of analyzing results and notifying the user.

*

All operations can be called for multiple repositories at once.

* - * @author Kirill Likhodedov + * @see GitBranchWorker */ public interface GitBrancher { static GitBrancher getInstance(@NotNull Project project) { @@ -48,6 +49,15 @@ public interface GitBrancher { */ void checkoutNewBranch(@NotNull String name, @NotNull List repositories); + /** + * Creates new branch without checking it out. + * + * @param name name of the new branch. + * @param startPoints position (commit hash) where the branch should be created, for each repository. + * Such position can be indicated by any valid Git reference (commit hash, branch name, etc.) + */ + void createBranch(@NotNull String name, @NotNull Map startPoints); + /** *

Creates new tag on the selected reference.

* diff --git a/plugins/git4idea/src/git4idea/branch/GitBrancherImpl.java b/plugins/git4idea/src/git4idea/branch/GitBrancherImpl.java index e05cac19eacf..4cb70e43d800 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBrancherImpl.java +++ b/plugins/git4idea/src/git4idea/branch/GitBrancherImpl.java @@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; +import java.util.Map; /** * @author Kirill Likhodedov @@ -55,6 +56,15 @@ class GitBrancherImpl implements GitBrancher { return new GitBranchWorker(myProject, myGit, new GitBranchUiHandlerImpl(myProject, myGit, indicator)); } + @Override + public void createBranch(@NotNull String name, @NotNull Map startPoints) { + new CommonBackgroundTask(myProject, "Creating branch " + name, null) { + @Override public void execute(@NotNull ProgressIndicator indicator) { + newWorker(indicator).createBranch(name, startPoints); + } + }.runInBackground(); + } + @Override public void createNewTag(@NotNull final String name, @NotNull final String reference, @NotNull final List repositories, @Nullable Runnable callInAwtLater) { diff --git a/plugins/git4idea/src/git4idea/branch/GitCreateBranchOperation.kt b/plugins/git4idea/src/git4idea/branch/GitCreateBranchOperation.kt new file mode 100644 index 000000000000..08ce58d07e2a --- /dev/null +++ b/plugins/git4idea/src/git4idea/branch/GitCreateBranchOperation.kt @@ -0,0 +1,78 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package git4idea.branch + +import com.intellij.openapi.project.Project +import com.intellij.openapi.vcs.VcsNotifier +import git4idea.commands.Git +import git4idea.commands.GitCompoundResult +import git4idea.repo.GitRepository + +internal class GitCreateBranchOperation( + project: Project, + git: Git, + uiHandler: GitBranchUiHandler, + private val branchName: String, + private val startPoints: Map) : GitBranchOperation(project, git, uiHandler, startPoints.keys) { + + public override fun execute() { + var fatalErrorHappened = false + while (hasMoreRepositories() && !fatalErrorHappened) { + val repository = next() + val result = myGit.branchCreate(repository, branchName, startPoints[repository]!!) + + if (result.success()) { + repository.update() + markSuccessful(repository) + } + else { + fatalError("Couldn't create new branch $branchName", result.errorOutputAsJoinedString) + fatalErrorHappened = true + } + } + + if (!fatalErrorHappened) { + notifySuccess() + updateRecentBranch() + } + } + + override fun rollback() { + val repositories = successfulRepositories + val deleteResult = GitCompoundResult(myProject) + for (repository in repositories) { + deleteResult.append(repository, myGit.branchDelete(repository, branchName, false)) + repository.update() + } + + val vcsNotifier = VcsNotifier.getInstance(myProject) + if (deleteResult.totalSuccess()) { + vcsNotifier.notifySuccess("Rollback successful", "Deleted $branchName") + } + else { + vcsNotifier.notifyError("Error during rollback", deleteResult.errorOutputWithReposIndication) + } + } + + override fun getSuccessMessage() = "Branch $branchName was created" + + override fun getRollbackProposal() = """ + However the branch was created in the following ${repositories()}:
+ ${successfulRepositoriesJoined()}
+ You may rollback (delete $branchName) not to let branches diverge.""".trimIndent() + + override fun getOperationName() = "create branch" +} diff --git a/plugins/git4idea/src/git4idea/branch/GitNewBranchDialog.kt b/plugins/git4idea/src/git4idea/branch/GitNewBranchDialog.kt new file mode 100644 index 000000000000..045d7801b642 --- /dev/null +++ b/plugins/git4idea/src/git4idea/branch/GitNewBranchDialog.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package git4idea.branch + +import com.intellij.openapi.project.Project +import com.intellij.openapi.ui.Messages +import com.intellij.ui.components.JBCheckBox +import com.intellij.util.ui.JBUI +import com.intellij.util.ui.UIUtil.DEFAULT_HGAP +import com.intellij.util.ui.UIUtil.DEFAULT_VGAP +import git4idea.validators.GitNewBranchNameValidator +import java.awt.BorderLayout +import java.awt.event.KeyEvent +import javax.swing.JComponent + +internal data class GitNewBranchOptions(val name: String, @get:JvmName("shouldCheckout") val checkout: Boolean) + +internal class GitNewBranchDialog(project: Project, dialogTitle: String, validator: GitNewBranchNameValidator) : + Messages.InputDialog(project, "New branch name:", dialogTitle, null, "", validator) { + + private lateinit var checkoutCheckbox : JBCheckBox + + fun showAndGetOptions(): GitNewBranchOptions? { + return if (showAndGet()) GitNewBranchOptions(inputString!!.trim(), checkoutCheckbox.isSelected) else null + } + + override fun createCenterPanel(): JComponent? { + checkoutCheckbox = JBCheckBox("Checkout branch", true) + checkoutCheckbox.mnemonic = KeyEvent.VK_C + + val panel = JBUI.Panels.simplePanel(DEFAULT_HGAP, DEFAULT_VGAP) + panel.add(checkoutCheckbox, BorderLayout.WEST) + return panel + } +} diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java index bce8008ea8fe..30d91d851c22 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java +++ b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java @@ -29,8 +29,10 @@ import com.intellij.openapi.ui.Messages; import com.intellij.util.containers.ContainerUtil; import git4idea.branch.GitBranchUtil; import git4idea.branch.GitBrancher; +import git4idea.branch.GitNewBranchOptions; import git4idea.repo.GitRepository; import git4idea.validators.GitNewBranchNameValidator; +import one.util.streamex.StreamEx; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,6 +42,7 @@ import java.util.List; import static com.intellij.dvcs.ui.BranchActionGroupPopup.wrapWithMoreActionIfNeeded; import static com.intellij.dvcs.ui.BranchActionUtil.*; import static git4idea.GitStatisticsCollectorKt.reportUsage; +import static git4idea.GitUtil.HEAD; import static git4idea.branch.GitBranchType.LOCAL; import static git4idea.branch.GitBranchType.REMOTE; import static java.util.stream.Collectors.toList; @@ -100,11 +103,17 @@ class GitBranchPopupActions { @Override public void actionPerformed(AnActionEvent e) { - final String name = GitBranchUtil.getNewBranchNameFromUser(myProject, myRepositories, "Create New Branch"); - if (name != null) { + GitNewBranchOptions options = GitBranchUtil.getNewBranchNameFromUser(myProject, myRepositories, "Create New Branch"); + if (options != null) { GitBrancher brancher = GitBrancher.getInstance(myProject); - brancher.checkoutNewBranch(name, myRepositories); - reportUsage("git.branch.create.new"); + if (options.shouldCheckout()) { + reportUsage("git.branch.create.new"); + brancher.checkoutNewBranch(options.getName(), myRepositories); + } + else { + reportUsage("git.branch.create.new.nocheckout"); + brancher.createBranch(options.getName(), StreamEx.of(myRepositories).toMap(position -> HEAD)); + } } } } diff --git a/plugins/git4idea/tests/git4idea/branch/GitBranchWorkerTest.kt b/plugins/git4idea/tests/git4idea/branch/GitBranchWorkerTest.kt index 45afe94eba7e..3dfaffa161c3 100644 --- a/plugins/git4idea/tests/git4idea/branch/GitBranchWorkerTest.kt +++ b/plugins/git4idea/tests/git4idea/branch/GitBranchWorkerTest.kt @@ -23,7 +23,6 @@ import com.intellij.openapi.ui.DialogWrapper import com.intellij.openapi.util.Ref import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.text.StringUtil -import com.intellij.openapi.vcs.Executor import com.intellij.openapi.vcs.Executor.* import com.intellij.openapi.vcs.changes.Change import com.intellij.openapi.vfs.VirtualFile @@ -56,13 +55,13 @@ class GitBranchWorkerTest : GitPlatformTest() { super.setUp() cd(myProjectRoot) - val community = Executor.mkdir("community") - val contrib = Executor.mkdir("contrib") + val community = mkdir("community") + val contrib = mkdir("contrib") myUltimate = createRepository(myProjectPath) myCommunity = createRepository(community.path) myContrib = createRepository(contrib.path) - myRepositories = Arrays.asList(myUltimate, myCommunity, myContrib) + myRepositories = listOf(myUltimate, myCommunity, myContrib) cd(myProjectRoot) touch(".gitignore", "community\ncontrib") @@ -75,8 +74,22 @@ class GitBranchWorkerTest : GitPlatformTest() { checkoutNewBranch("feature", TestUiHandler()) assertCurrentBranch("feature") - assertEquals("Notification about successful branch creation is incorrect", - "Branch " + bcode("feature") + " was created", myVcsNotifier.lastNotification.content) + assertSuccessfulNotification("Branch ${bcode("feature")} was created") + } + + fun `test create new branch without checkout not at HEAD`() { + val hashMap = myRepositories.map { it to it.currentRevision!! }.toMap() + myRepositories.forEach { cd(it); tac("f.txt") } + + GitBranchWorker(myProject, myGit, TestUiHandler()).createBranch("feature", myRepositories.map{ it to "HEAD^" }.toMap()) + + assertCurrentBranch("master") + myRepositories.forEach { + val branch = it.branches.findLocalBranch("feature") + assertNotNull("Branch not created in $it", branch) + assertEquals("Branch feature created at wrong point", hashMap[it], it.branches.getHash(branch!!)!!.asString()) + } + assertSuccessfulNotification("Branch ${bcode("feature")} was created") } fun test_create_new_branch_with_unmerged_files_in_first_repo_should_show_notification() { @@ -177,9 +190,7 @@ class GitBranchWorkerTest : GitPlatformTest() { unmergedFiles(myCommunity) checkoutBranch("feature", object : TestUiHandler() { - override fun showUnmergedFilesMessageWithRollback(operationName: String, rollbackProposal: String): Boolean { - return true - } + override fun showUnmergedFilesMessageWithRollback(operationName: String, rollbackProposal: String) = true }) assertCurrentBranch("master") @@ -190,9 +201,7 @@ class GitBranchWorkerTest : GitPlatformTest() { unmergedFiles(myCommunity) checkoutBranch("feature", object : TestUiHandler() { - override fun showUnmergedFilesMessageWithRollback(operationName: String, rollbackProposal: String): Boolean { - return false - } + override fun showUnmergedFilesMessageWithRollback(operationName: String, rollbackProposal: String) = false }) assertCurrentBranch(myUltimate, "feature") @@ -206,8 +215,7 @@ class GitBranchWorkerTest : GitPlatformTest() { checkoutRevision("feature", TestUiHandler()) assertDetachedState("feature") - assertEquals("Notification about successful branch checkout is incorrect", "Checked out " + bcode("feature"), - myVcsNotifier.lastNotification.content) + assertSuccessfulNotification("Checked out ${bcode("feature")}") } fun test_checkout_revision_checkout_ref_with_complete_success() { @@ -216,8 +224,7 @@ class GitBranchWorkerTest : GitPlatformTest() { checkoutRevision("feature~1", TestUiHandler()) assertDetachedState("master") - assertEquals("Notification about successful branch checkout is incorrect", "Checked out " + bcode("feature~1"), - myVcsNotifier.lastNotification.content) + assertSuccessfulNotification("Checked out ${bcode("feature~1")}") } fun test_checkout_revision_checkout_ref_with_complete_failure() { @@ -227,13 +234,11 @@ class GitBranchWorkerTest : GitPlatformTest() { assertCurrentBranch("master") assertCurrentRevision("master") - assertEquals("Notification about successful branch checkout is incorrect", - "Revision not found in project, community and contrib", - myVcsNotifier.lastNotification.content) + assertSuccessfulNotification("Revision not found in project, community and contrib") } fun test_checkout_revision_checkout_ref_with_partial_success() { - branchWithCommit(ContainerUtil.list(myCommunity, myContrib), "feature") + branchWithCommit(listOf(myCommunity, myContrib), "feature") checkoutRevision("feature", TestUiHandler()) @@ -241,10 +246,8 @@ class GitBranchWorkerTest : GitPlatformTest() { assertDetachedState(myCommunity, "feature") assertDetachedState(myContrib, "feature") - assertEquals("Notification about successful branch checkout is incorrect", - "Checked out " + bcode("feature") + " in community and contrib" + "
" + - "Revision not found in project" + "
Rollback", - myVcsNotifier.lastNotification.content) + assertSuccessfulNotification("Checked out ${bcode("feature")} in community and contrib
" + + "Revision not found in project
Rollback") } fun test_checkout_with_untracked_files_overwritten_by_checkout_in_first_repo_should_show_notification() { @@ -369,13 +372,8 @@ class GitBranchWorkerTest : GitPlatformTest() { private fun agree_to_smart_operation(operation: String, expectedSuccessMessage: String): List { val localChanges = prepareLocalChangesOverwrittenBy(myUltimate) - - val handler = TestUiHandler() - checkoutOrMerge(operation, "feature", handler) - - assertNotNull("No success notification was shown", myVcsNotifier.lastNotification) - assertEquals("Success message is incorrect", expectedSuccessMessage, myVcsNotifier.lastNotification.content) - + checkoutOrMerge(operation, "feature", TestUiHandler()) + assertSuccessfulNotification(expectedSuccessMessage) return localChanges } @@ -407,9 +405,7 @@ class GitBranchWorkerTest : GitPlatformTest() { changes: List, paths: Collection, operation: String, - forceButton: String?): Int { - return GitSmartOperationDialog.CANCEL_EXIT_CODE - } + forceButton: String?) = GitSmartOperationDialog.CANCEL_EXIT_CODE }) assertNull("Notification was unexpectedly shown:" + myVcsNotifier.lastNotification, myVcsNotifier.lastNotification) @@ -436,9 +432,7 @@ class GitBranchWorkerTest : GitPlatformTest() { changes: List, paths: Collection, operation: String, - forceButton: String?): Int { - return GitSmartOperationDialog.CANCEL_EXIT_CODE - } + forceButton: String?) = GitSmartOperationDialog.CANCEL_EXIT_CODE override fun notifyErrorWithRollbackProposal(title: String, message: String, @@ -460,15 +454,11 @@ class GitBranchWorkerTest : GitPlatformTest() { changes: List, paths: Collection, operation: String, - forceButton: String?): Int { - return GitSmartOperationDialog.FORCE_EXIT_CODE - } + forceButton: String?) = GitSmartOperationDialog.FORCE_EXIT_CODE }) brancher.checkoutNewBranchStartingFrom("new_branch", "feature", myRepositories) - assertEquals("Notification about successful branch creation is incorrect", - "Checked out new branch new_branch from feature", - myVcsNotifier.lastNotification.content) + assertSuccessfulNotification("Checked out new branch new_branch from feature") assertCurrentBranch("new_branch") } @@ -547,9 +537,7 @@ class GitBranchWorkerTest : GitPlatformTest() { override fun showBranchIsNotFullyMergedDialog(project: Project, history: Map>, baseBranches: Map, - removedBranch: String): Boolean { - return true - } + removedBranch: String) = true }) assertBranchDeleted("todelete") } @@ -639,9 +627,7 @@ class GitBranchWorkerTest : GitPlatformTest() { mergeBranch("master2", TestUiHandler()) - assertNotNull("Success message wasn't shown", myVcsNotifier.lastNotification) - assertEquals("Success message is incorrect", - "Merged " + bcode("master2") + " to " + bcode("master") + "
Delete master2", + assertSuccessfulNotification("Merged " + bcode("master2") + " to " + bcode("master") + "
Delete master2", myVcsNotifier.lastNotification.content) assertFile(myUltimate, "branch_file.txt", "branch content") assertFile(myCommunity, "branch_file.txt", "branch content") From 2e5ad2c5a922a08d6af2d8d368f7d66afa1e7346 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sun, 12 Feb 2017 16:29:54 +0000 Subject: [PATCH 45/96] Rename to Kotlin --- ...{GitCreateNewBranchAction.java => GitCreateNewBranchAction.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename plugins/git4idea/src/git4idea/actions/{GitCreateNewBranchAction.java => GitCreateNewBranchAction.kt} (100%) diff --git a/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.java b/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt similarity index 100% rename from plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.java rename to plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt From 8ad7d251b7c82a38d83eab1fa6aca9a1d08f7565 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sun, 12 Feb 2017 16:32:43 +0000 Subject: [PATCH 46/96] Convert to Kotlin --- .../actions/GitCreateNewBranchAction.kt | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt b/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt index 8dae1031d3cd..6d08d34a9025 100644 --- a/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt +++ b/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt @@ -13,33 +13,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package git4idea.actions; +package git4idea.actions -import com.intellij.openapi.project.Project; -import com.intellij.vcs.log.Hash; -import git4idea.branch.GitBrancher; -import git4idea.branch.GitNewBranchOptions; -import git4idea.repo.GitRepository; -import org.jetbrains.annotations.NotNull; +import com.intellij.vcs.log.Hash +import git4idea.branch.GitBranchUtil.getNewBranchNameFromUser +import git4idea.branch.GitBrancher +import git4idea.repo.GitRepository -import static git4idea.branch.GitBranchUtil.getNewBranchNameFromUser; -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static java.util.Collections.singletonMap; +class GitCreateNewBranchAction : GitLogSingleCommitAction() { -public class GitCreateNewBranchAction extends GitLogSingleCommitAction { - - @Override - protected void actionPerformed(@NotNull GitRepository repository, @NotNull Hash commit) { - Project project = repository.getProject(); - GitNewBranchOptions options = getNewBranchNameFromUser(project, singleton(repository), "Checkout New Branch From " + commit.toShortString()); + override fun actionPerformed(repository: GitRepository, commit: Hash) { + val project = repository.project + val options = getNewBranchNameFromUser(project, setOf(repository), "Checkout New Branch From " + commit.toShortString()) if (options != null) { - GitBrancher brancher = GitBrancher.getInstance(project); - if (options.shouldCheckout()) { - brancher.checkoutNewBranchStartingFrom(options.getName(), commit.asString(), singletonList(repository), null); + val brancher = GitBrancher.getInstance(project) + if (options.checkout) { + brancher.checkoutNewBranchStartingFrom(options.name, commit.asString(), listOf(repository), null) } else { - brancher.createBranch(options.getName(), singletonMap(repository, commit.asString())); + brancher.createBranch(options.name, mapOf(repository to commit.asString())); } } } From 47248016910d1efd3dd0978473a538ab8e30a690 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sun, 12 Feb 2017 17:23:38 +0000 Subject: [PATCH 47/96] Make "Create new branch" action available not only from the log If the log is in data context, create new branch at the selected commit. Otherwise, create branch at HEAD in the guessed root or in all roots. Fix for IDEA-164512 --- .../actions/GitCreateNewBranchAction.kt | 89 ++++++++++++++++++- 1 file changed, 85 insertions(+), 4 deletions(-) diff --git a/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt b/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt index 6d08d34a9025..e98c97057f01 100644 --- a/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt +++ b/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt @@ -15,23 +15,104 @@ */ package git4idea.actions +import com.intellij.dvcs.DvcsUtil.guessVcsRoot +import com.intellij.dvcs.branch.DvcsSyncSettings.Value.SYNC +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.actionSystem.CommonDataKeys.VIRTUAL_FILE +import com.intellij.openapi.project.DumbAwareAction +import com.intellij.openapi.project.Project import com.intellij.vcs.log.Hash +import com.intellij.vcs.log.VcsLogDataKeys +import git4idea.GitUtil.HEAD +import git4idea.GitUtil.getRepositoryManager import git4idea.branch.GitBranchUtil.getNewBranchNameFromUser import git4idea.branch.GitBrancher +import git4idea.config.GitVcsSettings import git4idea.repo.GitRepository -class GitCreateNewBranchAction : GitLogSingleCommitAction() { +internal class GitCreateNewBranchAction : DumbAwareAction() { - override fun actionPerformed(repository: GitRepository, commit: Hash) { + override fun actionPerformed(e: AnActionEvent) { + val data = collectData(e) + when (data) { + is Data.WithCommit -> createBranchStartingFrom(data.repository, data.hash) + is Data.NoCommit -> createBranch(data.project, data.repositories) + } + } + + override fun update(e: AnActionEvent) { + super.update(e) + val data = collectData(e) + when (data) { + is Data.Invisible -> e.presentation.isEnabledAndVisible = false + is Data.Disabled -> { + e.presentation.isVisible = true + e.presentation.isEnabled = false + } + else -> e.presentation.isEnabledAndVisible = true + } + } + + private sealed class Data { + class Invisible : Data() + class Disabled : Data() + class WithCommit(val repository: GitRepository, val hash: Hash) : Data() + class NoCommit(val project: Project, val repositories: List) : Data() + } + + private fun collectData(e: AnActionEvent): Data { + val project = e.project ?: return Data.Invisible() + val manager = getRepositoryManager(project) + + val log = e.getData(VcsLogDataKeys.VCS_LOG) + if (log != null) { + val commits = log.selectedCommits + if (commits.isEmpty()) return Data.Invisible() + if (commits.size > 1) return Data.Disabled() + val commit = commits.first() + val repository = manager.getRepositoryForRoot(commit.root) + if (repository != null) { + return Data.WithCommit(repository, commit.hash) + } + } + + val repositories = + if (manager.moreThanOneRoot()) { + if (GitVcsSettings.getInstance(project).syncSetting == SYNC) manager.repositories + else { + val repository = manager.getRepositoryForRoot(guessVcsRoot(project, e.getData(VIRTUAL_FILE))) + repository?.let { listOf(repository) } + } + } + else listOf(manager.repositories.first()) + + if (repositories == null || repositories.any { it.isFresh }) return Data.Invisible() + return Data.NoCommit(project, repositories) + } + + fun createBranch(project: Project, repositories: List) { + val options = getNewBranchNameFromUser(project, repositories, "Create New Branch") + if (options != null) { + val brancher = GitBrancher.getInstance(project) + if (options.checkout) { + brancher.checkoutNewBranch(options.name, repositories) + } + else { + brancher.createBranch(options.name, repositories.map { it to HEAD }.toMap()) + } + } + } + + fun createBranchStartingFrom(repository: GitRepository, commit: Hash) { val project = repository.project - val options = getNewBranchNameFromUser(project, setOf(repository), "Checkout New Branch From " + commit.toShortString()) + val options = getNewBranchNameFromUser(project, setOf(repository), "Create New Branch From ${commit.toShortString()}") if (options != null) { val brancher = GitBrancher.getInstance(project) if (options.checkout) { brancher.checkoutNewBranchStartingFrom(options.name, commit.asString(), listOf(repository), null) } else { - brancher.createBranch(options.name, mapOf(repository to commit.asString())); + brancher.createBranch(options.name, mapOf(repository to commit.asString())) } } } From ee9f01b53e128b2755d60e2ce56b11f77682c756 Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Tue, 14 Feb 2017 17:15:35 +0300 Subject: [PATCH 48/96] [vcs]: BranchPopup - reword collapsed text if no favorites in the group --- .../com/intellij/dvcs/ui/BranchActionGroupPopup.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java b/platform/dvcs-impl/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java index 839575e63556..f19f6432ad9b 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java @@ -393,14 +393,18 @@ public class BranchActionGroupPopup extends FlatSpeedSearchPopup { @NotNull private final String myToCollapseText; @NotNull private final String myToExpandText; - public MoreAction(@NotNull Project project, int numberOfHiddenNodes, @Nullable String settingName, boolean defaultExpandValue) { + public MoreAction(@NotNull Project project, + int numberOfHiddenNodes, + @Nullable String settingName, + boolean defaultExpandValue, + boolean hasFavorites) { super(); myProject = project; mySettingName = settingName; myDefaultExpandValue = defaultExpandValue; assert numberOfHiddenNodes > 0; myToExpandText = "Show " + numberOfHiddenNodes + " More..."; - myToCollapseText = "Show Only Favorites"; + myToCollapseText = "Show " + (hasFavorites ? "Only Favorites" : "Less"); setExpanded( settingName != null ? PropertiesComponent.getInstance(project).getBoolean(settingName, defaultExpandValue) : defaultExpandValue); } @@ -466,7 +470,9 @@ public class BranchActionGroupPopup extends FlatSpeedSearchPopup { @NotNull DefaultActionGroup parentGroup, @NotNull List actionList, int maxIndex, @Nullable String settingName, boolean defaultExpandValue) { if (actionList.size() > maxIndex) { - MoreAction moreAction = new MoreAction(project, actionList.size() - maxIndex, settingName, defaultExpandValue); + boolean hasFavorites = + actionList.stream().anyMatch(action -> action instanceof BranchActionGroup && ((BranchActionGroup)action).isFavorite()); + MoreAction moreAction = new MoreAction(project, actionList.size() - maxIndex, settingName, defaultExpandValue, hasFavorites); for (int i = 0; i < actionList.size(); i++) { parentGroup.add(i < maxIndex ? actionList.get(i) : new HideableActionGroup(actionList.get(i), moreAction)); } From c77ad145cf4366c0231b2b97d3348312c5ba0748 Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Tue, 14 Feb 2017 17:17:40 +0300 Subject: [PATCH 49/96] [vcs]: Branch popup - save Repositories expanded state (IDEA-168143) --- plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java index 7db0a6cc5a76..76eb67b19bfe 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java +++ b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java @@ -53,6 +53,7 @@ class GitBranchPopup extends DvcsBranchPopup { private static final String DIMENSION_SERVICE_KEY = "Git.Branch.Popup"; static final String SHOW_ALL_LOCALS_KEY = "Git.Branch.Popup.ShowAllLocals"; static final String SHOW_ALL_REMOTES_KEY = "Git.Branch.Popup.ShowAllRemotes"; + static final String SHOW_ALL_REPOSITORIES = "Git.Branch.Popup.ShowAllRepositories"; /** * @param currentRepository Current repository, which means the repository of the currently open or selected file. @@ -154,7 +155,8 @@ class GitBranchPopup extends DvcsBranchPopup { .map(repo -> new RootAction<>(repo, highlightCurrentRepo() ? myCurrentRepository : null, new GitBranchPopupActions(repo.getProject(), repo).createActions(), GitBranchUtil.getDisplayableBranchText(repo))).collect(toList()); - wrapWithMoreActionIfNeeded(myProject, popupGroup, rootActions, rootActions.size() > MAX_NUM ? DEFAULT_NUM : MAX_NUM, null); + wrapWithMoreActionIfNeeded(myProject, popupGroup, rootActions, rootActions.size() > MAX_NUM ? DEFAULT_NUM : MAX_NUM, + SHOW_ALL_REPOSITORIES); return popupGroup; } From 8badcc8f56fa121f5e31d1f0247c94cccfce6ce6 Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Tue, 14 Feb 2017 18:23:56 +0300 Subject: [PATCH 50/96] [push]: cleanUp - rename classes and methods; update javadoc --- .../intellij/dvcs/push/PrePushHandler.java | 4 ++-- .../intellij/dvcs/push/PushController.java | 22 +++++++++---------- .../push/{PushDetail.java => PushInfo.java} | 15 ++++++------- 3 files changed, 20 insertions(+), 21 deletions(-) rename platform/dvcs-impl/src/com/intellij/dvcs/push/{PushDetail.java => PushInfo.java} (69%) diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/PrePushHandler.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/PrePushHandler.java index b0096db7675b..cf8ec8494de0 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/PrePushHandler.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/PrePushHandler.java @@ -59,7 +59,7 @@ public interface PrePushHandler { String getPresentableName(); /** - * Check synchronously if the push operation should be performed or canceled for specified {@link PushDetail}s + * Check synchronously if the push operation should be performed or canceled for specified {@link PushInfo}s *

* Note: it is permissible for a handler to show it's own modal dialogs with specifying * the supplied {@code indicator}'s {@link ProgressIndicator#getModalityState() modality} state. @@ -70,6 +70,6 @@ public interface PrePushHandler { */ @CalledInAny @NotNull - Result handle(@NotNull List pushDetails, @NotNull ProgressIndicator indicator); + Result handle(@NotNull List pushDetails, @NotNull ProgressIndicator indicator); } diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java index c651e6cee30d..5f503e634cdc 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java @@ -524,7 +524,7 @@ public class PushController implements Disposable { @CalledInAny public PrePushHandler.Result executeHandlers(@NotNull ProgressIndicator indicator) throws ProcessCanceledException, HandlerException { if (myHandlers.isEmpty()) return PrePushHandler.Result.OK; - List pushDetails = preparePushDetails(); + List pushDetails = preparePushDetails(); StepsProgressIndicator stepsIndicator = new StepsProgressIndicator(indicator, myHandlers.size()); stepsIndicator.setIndeterminate(false); stepsIndicator.setFraction(0); @@ -588,8 +588,8 @@ public class PushController implements Disposable { } @NotNull - private List preparePushDetails() { - List allDetails = ContainerUtil.newArrayList(); + private List preparePushDetails() { + List allDetails = ContainerUtil.newArrayList(); Collection> repoModels = getSelectedRepoNode(); for (MyRepoModel model : repoModels) { @@ -608,7 +608,7 @@ public class PushController implements Disposable { //sort commits in the time-ascending order Collections.reverse(loadedCommits); - allDetails.add(new PushDetailImpl(model.getRepository(), pushSpec, loadedCommits)); + allDetails.add(new PushInfoImpl(model.getRepository(), pushSpec, loadedCommits)); } return Collections.unmodifiableList(allDetails); } @@ -736,15 +736,15 @@ public class PushController implements Disposable { }) ? commonTarget : null; } - private static class PushDetailImpl implements PushDetail { + private static class PushInfoImpl implements PushInfo { private final Repository myRepository; private final PushSpec myPushSpec; private final List myCommits; - private PushDetailImpl(@NotNull Repository repository, - @NotNull PushSpec spec, - @NotNull List commits) { + private PushInfoImpl(@NotNull Repository repository, + @NotNull PushSpec spec, + @NotNull List commits) { myRepository = repository; myPushSpec = spec; myCommits = commits; @@ -752,19 +752,19 @@ public class PushController implements Disposable { @NotNull @Override - public Repository repository() { + public Repository getRepository() { return myRepository; } @NotNull @Override - public PushSpec pushSpec() { + public PushSpec getPushSpec() { return myPushSpec; } @NotNull @Override - public List commits() { + public List getCommits() { return myCommits; } } diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/PushDetail.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/PushInfo.java similarity index 69% rename from platform/dvcs-impl/src/com/intellij/dvcs/push/PushDetail.java rename to platform/dvcs-impl/src/com/intellij/dvcs/push/PushInfo.java index 471c08b9cf1e..4eef6cf480eb 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/PushDetail.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/PushInfo.java @@ -22,28 +22,27 @@ import org.jetbrains.annotations.NotNull; import java.util.List; /** - * Upcoming push information holder + * Upcoming push information holder for one repository */ -public interface PushDetail { +public interface PushInfo { /** * Repository of the push source */ @NotNull - Repository repository(); + Repository getRepository(); /** - * For a {@link #repository()} specifies what would be pushed and where + * Specifies what would be pushed and where for this repository * * @return push specification */ @NotNull - PushSpec pushSpec(); + PushSpec getPushSpec(); /** * Returns list of commits to be pushed. - * a.e. result of `git log source..target` for updated git branches; empty list for newly created branches. - * Commits should be ordered by commit time (ex: committer time for git); + * Commits are ordered so that the most recent come last, e.g. as in the output of git log source..target but in reverse order */ @NotNull - List commits(); + List getCommits(); } From 07b27a76a9863333b974c7d7b095c6e601a2bd3e Mon Sep 17 00:00:00 2001 From: Vladislav Rassokhin Date: Tue, 14 Feb 2017 18:38:48 +0300 Subject: [PATCH 51/96] Improve MagicConstantInspection in case of two constants sources --- .../MagicConstantInspection.java | 52 ++++++++------ .../inspection/magic/simple/expected.xml | 68 +++++++++---------- .../inspection/magic/simple/src/X.java | 21 +++--- 3 files changed, 77 insertions(+), 64 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicConstantInspection.java b/java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicConstantInspection.java index 07e430afcb76..15c64e2d345f 100644 --- a/java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicConstantInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicConstantInspection.java @@ -45,6 +45,7 @@ import com.intellij.psi.search.LocalSearchScope; import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.*; import com.intellij.slicer.*; +import com.intellij.util.ArrayUtil; import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.indexing.FileBasedIndex; @@ -325,42 +326,51 @@ public class MagicConstantInspection extends BaseJavaLocalInspectionTool { private static AllowedValues getAllowedValuesFromMagic(@NotNull PsiType type, @NotNull PsiAnnotation magic, @NotNull PsiManager manager) { - PsiAnnotationMemberValue[] allowedValues; - final boolean canBeOred; + PsiAnnotationMemberValue[] allowedValues = PsiAnnotationMemberValue.EMPTY_ARRAY; + boolean values = false, flags = false; if (TypeConversionUtil.getTypeRank(type) <= TypeConversionUtil.LONG_RANK) { PsiAnnotationMemberValue intValues = magic.findAttributeValue("intValues"); - allowedValues = intValues instanceof PsiArrayInitializerMemberValue ? ((PsiArrayInitializerMemberValue)intValues).getInitializers() : PsiAnnotationMemberValue.EMPTY_ARRAY; - if (allowedValues.length == 0) { - PsiAnnotationMemberValue orValue = magic.findAttributeValue("flags"); - allowedValues = orValue instanceof PsiArrayInitializerMemberValue ? ((PsiArrayInitializerMemberValue)orValue).getInitializers() : PsiAnnotationMemberValue.EMPTY_ARRAY; - canBeOred = true; + if (intValues instanceof PsiArrayInitializerMemberValue) { + allowedValues = ((PsiArrayInitializerMemberValue)intValues).getInitializers(); + values = true; } else { - canBeOred = false; + PsiAnnotationMemberValue orValue = magic.findAttributeValue("flags"); + if (orValue instanceof PsiArrayInitializerMemberValue) { + allowedValues = ((PsiArrayInitializerMemberValue)orValue).getInitializers(); + flags = true; + } } } else if (type.equals(PsiType.getJavaLangString(manager, GlobalSearchScope.allScope(manager.getProject())))) { PsiAnnotationMemberValue strValuesAttr = magic.findAttributeValue("stringValues"); - allowedValues = strValuesAttr instanceof PsiArrayInitializerMemberValue ? ((PsiArrayInitializerMemberValue)strValuesAttr).getInitializers() : PsiAnnotationMemberValue.EMPTY_ARRAY; - canBeOred = false; + if (strValuesAttr instanceof PsiArrayInitializerMemberValue) { + allowedValues = ((PsiArrayInitializerMemberValue)strValuesAttr).getInitializers(); + values = true; + } } else { return null; //other types not supported } - if (allowedValues.length != 0) { - return new AllowedValues(allowedValues, canBeOred); + // Also there're could be valuesFromClass of flagsFromClass + PsiAnnotationMemberValue[] valuesFromClass = readFromClass("valuesFromClass", magic, type, manager); + if (valuesFromClass != null) { + allowedValues = ArrayUtil.mergeArrays(allowedValues, valuesFromClass, PsiAnnotationMemberValue.ARRAY_FACTORY); + values = true; } - - // last resort: try valuesFromClass - PsiAnnotationMemberValue[] values = readFromClass("valuesFromClass", magic, type, manager); - boolean ored = false; - if (values == null) { - values = readFromClass("flagsFromClass", magic, type, manager); - ored = true; + PsiAnnotationMemberValue[] flagsFromClass = readFromClass("flagsFromClass", magic, type, manager); + if (flagsFromClass != null) { + allowedValues = ArrayUtil.mergeArrays(allowedValues, flagsFromClass, PsiAnnotationMemberValue.ARRAY_FACTORY); + flags = true; } - if (values == null) return null; - return new AllowedValues(values, ored); + if (allowedValues.length == 0) { + return null; + } + if (values && flags) { + // Combination of 'flags' and 'values', that's weird TODO: Log? + } + return new AllowedValues(allowedValues, flags); } private static PsiAnnotationMemberValue[] readFromClass(@NonNls @NotNull String attributeName, diff --git a/java/java-tests/testData/inspection/magic/simple/expected.xml b/java/java-tests/testData/inspection/magic/simple/expected.xml index 062b3aa7245c..b54c2f926aab 100644 --- a/java/java-tests/testData/inspection/magic/simple/expected.xml +++ b/java/java-tests/testData/inspection/magic/simple/expected.xml @@ -14,7 +14,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -26,7 +26,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -38,7 +38,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -50,7 +50,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -62,7 +62,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -74,7 +74,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -86,7 +86,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -98,7 +98,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -110,7 +110,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -122,7 +122,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -134,7 +134,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -146,7 +146,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -158,7 +158,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -170,7 +170,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -178,7 +178,7 @@ X.java 81 magic constant - Should be one of: Const.X, Const.Y, Const.Z or their combination + Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination @@ -189,7 +189,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z or their combination + Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination @@ -201,7 +201,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -213,7 +213,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z or their combination + Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination @@ -225,7 +225,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z or their combination + Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination @@ -237,7 +237,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z or their combination + Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination @@ -249,7 +249,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z or their combination + Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination @@ -257,14 +257,14 @@ X.java 118 magic constant - Should be one of: Const.X, Const.Y, Const.Z or their combination + Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination X.java 119 magic constant - Should be one of: Const.X, Const.Y, Const.Z or their combination + Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination @@ -276,7 +276,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z or their combination + Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination @@ -288,7 +288,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z or their combination + Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination @@ -300,7 +300,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z or their combination + Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination @@ -312,7 +312,7 @@ magic constant - Should be one of: Const.X, Const.Y, Const.Z or their combination + Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination @@ -322,7 +322,7 @@ X.java 173 magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -331,7 +331,7 @@ X.java 174 magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -340,7 +340,7 @@ X.java 175 magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -349,7 +349,7 @@ X.java 177 magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -357,7 +357,7 @@ X.java 178 magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -366,7 +366,7 @@ X.java 179 magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z @@ -375,7 +375,7 @@ X.java 180 magic constant - Should be one of: Const.X, Const.Y, Const.Z + Should be one of: Const2.I, Const.X, Const.Y, Const.Z diff --git a/java/java-tests/testData/inspection/magic/simple/src/X.java b/java/java-tests/testData/inspection/magic/simple/src/X.java index 043a4037e241..21a95e66a51d 100644 --- a/java/java-tests/testData/inspection/magic/simple/src/X.java +++ b/java/java-tests/testData/inspection/magic/simple/src/X.java @@ -24,7 +24,7 @@ class Const { } public class X { - void f(@MagicConstant(intValues={Const.X, Const.Y, Const.Z}) int x) { + void f(@MagicConstant(intValues={Const.X, Const.Y, Const.Z, Const2.I}) int x) { /////////// BAD f(0); f(1); @@ -50,7 +50,7 @@ public class X { f2(x); } - void f2(@MagicConstant(valuesFromClass =Const.class) int x) { + void f2(@MagicConstant(valuesFromClass =Const.class, intValues={Const2.I}) int x) { /////////// BAD f2(0); f2(1); @@ -61,11 +61,11 @@ public class X { x = 2; assert x != 1; } - ////////////// GOOD f2(Const.X); f2(Const.Y); - f2(Const.Z); + f2(Const.Z); + f2(Const2.I); int i2 = this == null ? Const.X : Const.Y; f2(i2); if (x == Const.X) { @@ -76,7 +76,7 @@ public class X { f(x); } - void f3(@MagicConstant(flags ={Const.X, Const.Y, Const.Z}) int x) { + void f3(@MagicConstant(flags ={Const.X, Const.Y, Const.Z, Const2.I}) int x) { /////////// BAD f3(2); f3(1); @@ -113,7 +113,7 @@ public class X { f4(x); } - void f4(@MagicConstant(flagsFromClass =Const.class) int x) { + void f4(@MagicConstant(flagsFromClass =Const.class, flags={Const2.I}) int x) { /////////// BAD f4(-3); f4(1); @@ -128,8 +128,8 @@ public class X { ////////////// GOOD f4(Const.X); f4(Const.Y); - f4(Const.Z); - + f4(Const.Z); + f4(Const2.I); int i2 = this == null ? Const.X : Const.Y; f4(i2); int ix = Const.X | Const.Y; @@ -152,7 +152,7 @@ public class X { class Alias { - @MagicConstant(intValues={Const.X, Const.Y, Const.Z}) + @MagicConstant(intValues={Const.X, Const.Y, Const.Z, Const2.I}) @interface IntEnum{} void f(@IntEnum int x) { @@ -268,3 +268,6 @@ public class X { font(0); } } +class Const2 { + public static final int I = 0x10; +} From ed56e863373eccf8d1d39fcb21bc23a79d8e0657 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 14 Feb 2017 11:35:03 +0100 Subject: [PATCH 52/96] rename writeParent -> write --- .../daemon/InspectionProfileConvertor.java | 4 ++-- .../src/FileBasedStorage.kt | 4 ++-- .../src/ProjectStoreImpl.kt | 2 +- .../configuration-store-impl/src/StateMap.kt | 2 +- .../ui/actions/ExportHTMLAction.java | 8 +++---- .../header/InspectionToolsConfigurable.java | 4 ++-- .../src/com/intellij/util/jdom.kt | 2 +- .../com/intellij/openapi/util/JDOMUtil.java | 21 +++++++++++-------- 8 files changed, 25 insertions(+), 22 deletions(-) diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java index 1bd194384199..39ce82ed0bb4 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -106,7 +106,7 @@ public class InspectionProfileConvertor { try { Element root = JDOMUtil.load(files[0]); if (root.getAttributeValue(VERSION_ATT) == null){ - JDOMUtil.writeParent(root, new FileOutputStream(new File(profileDirectory, OLD_DEFAUL_PROFILE + XML_EXTENSION)), "\n"); + JDOMUtil.write(root, new FileOutputStream(new File(profileDirectory, OLD_DEFAUL_PROFILE + XML_EXTENSION)), "\n"); FileUtil.delete(files[0]); } } diff --git a/platform/configuration-store-impl/src/FileBasedStorage.kt b/platform/configuration-store-impl/src/FileBasedStorage.kt index 74db699aa40d..3b562538312a 100644 --- a/platform/configuration-store-impl/src/FileBasedStorage.kt +++ b/platform/configuration-store-impl/src/FileBasedStorage.kt @@ -242,7 +242,7 @@ private fun doWrite(requestor: Any, file: VirtualFile, content: Any, lineSeparat out.write(lineSeparator.separatorBytes) } if (content is Element) { - JDOMUtil.writeParent(content, out, lineSeparator.separatorString) + JDOMUtil.write(content, out, lineSeparator.separatorString) } else { (content as BufferExposingByteArrayOutputStream).writeTo(out) @@ -253,7 +253,7 @@ private fun doWrite(requestor: Any, file: VirtualFile, content: Any, lineSeparat internal fun Parent.toBufferExposingByteArray(lineSeparator: String = "\n"): BufferExposingByteArrayOutputStream { val out = BufferExposingByteArrayOutputStream(512) - JDOMUtil.writeParent(this, out, lineSeparator) + JDOMUtil.write(this, out, lineSeparator) return out } diff --git a/platform/configuration-store-impl/src/ProjectStoreImpl.kt b/platform/configuration-store-impl/src/ProjectStoreImpl.kt index b29e01341be0..93ecc2836170 100644 --- a/platform/configuration-store-impl/src/ProjectStoreImpl.kt +++ b/platform/configuration-store-impl/src/ProjectStoreImpl.kt @@ -129,7 +129,7 @@ abstract class ProjectStoreBase(override final val project: ProjectImpl) : Compo wrapper.addContent(profile) val path = Paths.get(storageManager.expandMacro(PROJECT_CONFIG_DIR), if (isInspection) "inspectionProfiles" else "copyright", "${FileUtil.sanitizeFileName(schemeName, true)}.xml") - JDOMUtil.writeParent(wrapper, path.outputStream(), "\n") + JDOMUtil.write(wrapper, path.outputStream(), "\n") } } diff --git a/platform/configuration-store-impl/src/StateMap.kt b/platform/configuration-store-impl/src/StateMap.kt index c89569b3d6af..3804b0f14bd1 100644 --- a/platform/configuration-store-impl/src/StateMap.kt +++ b/platform/configuration-store-impl/src/StateMap.kt @@ -58,7 +58,7 @@ fun getNewByteIfDiffers(key: String, newState: Any, oldState: ByteArray): ByteAr val logChangedComponents = SystemProperties.getBooleanProperty("idea.log.changed.components", false) if (ApplicationManager.getApplication().isUnitTestMode || logChangedComponents ) { - fun stateToString(state: Any) = JDOMUtil.writeParent(state as? Element ?: unarchiveState(state as ByteArray), "\n") + fun stateToString(state: Any) = JDOMUtil.write(state as? Element ?: unarchiveState(state as ByteArray), "\n") val before = stateToString(oldState) val after = stateToString(newState) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ExportHTMLAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ExportHTMLAction.java index fa5374f4d1ec..e834de735305 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ExportHTMLAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ExportHTMLAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -172,9 +172,9 @@ public class ExportHTMLAction extends AnAction implements DumbAware { if (profileName != null) { element.setAttribute(InspectionApplication.PROFILE, profileName); } - JDOMUtil.writeParent(element, - new File(outputDirectoryName, InspectionApplication.DESCRIPTIONS + InspectionApplication.XML_EXTENSION), - CodeStyleSettingsManager.getSettings(null).getLineSeparator()); + JDOMUtil.write(element, + new File(outputDirectoryName, InspectionApplication.DESCRIPTIONS + InspectionApplication.XML_EXTENSION), + CodeStyleSettingsManager.getSettings(null).getLineSeparator()); } catch (IOException e) { ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog(myView, e.getMessage())); diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java index 08e7d145d831..2053e9978e73 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -368,7 +368,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable return; } - JDOMUtil.writeParent(element, file, "\n"); + JDOMUtil.write(element, file, "\n"); } catch (IOException e1) { LOG.error(e1); diff --git a/platform/projectModel-impl/src/com/intellij/util/jdom.kt b/platform/projectModel-impl/src/com/intellij/util/jdom.kt index 1e33e22ae541..28a3a4479006 100644 --- a/platform/projectModel-impl/src/com/intellij/util/jdom.kt +++ b/platform/projectModel-impl/src/com/intellij/util/jdom.kt @@ -101,7 +101,7 @@ fun Element.remove(name: String, transform: (child: Element) -> T): List fun Element.toByteArray(): ByteArray { val out = BufferExposingByteArrayOutputStream(512) - JDOMUtil.writeParent(this, out, "\n") + JDOMUtil.write(this, out, "\n") return out.toByteArray() } diff --git a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java index aa46e792ca73..c2980e8bda4b 100644 --- a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java +++ b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java @@ -43,7 +43,10 @@ import org.xml.sax.XMLReader; import java.io.*; import java.lang.ref.SoftReference; import java.net.URL; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; /** * @author mike @@ -362,13 +365,13 @@ public class JDOMUtil { } public static void writeDocument(@NotNull Document document, @NotNull File file, String lineSeparator) throws IOException { - writeParent(document, file, lineSeparator); + write(document, file, lineSeparator); } - public static void writeParent(@NotNull Parent element, @NotNull File file, String lineSeparator) throws IOException { + public static void write(@NotNull Parent element, @NotNull File file, @NotNull String lineSeparator) throws IOException { OutputStream stream = new BufferedOutputStream(new FileOutputStream(file)); try { - writeParent(element, stream, lineSeparator); + write(element, stream, lineSeparator); } finally { stream.close(); @@ -376,10 +379,10 @@ public class JDOMUtil { } public static void writeDocument(@NotNull Document document, @NotNull OutputStream stream, String lineSeparator) throws IOException { - writeParent(document, stream, lineSeparator); + write(document, stream, lineSeparator); } - public static void writeParent(@NotNull Parent element, @NotNull OutputStream stream, @NotNull String lineSeparator) throws IOException { + public static void write(@NotNull Parent element, @NotNull OutputStream stream, @NotNull String lineSeparator) throws IOException { OutputStreamWriter writer = new OutputStreamWriter(stream, CharsetToolkit.UTF8_CHARSET); try { if (element instanceof Document) { @@ -416,10 +419,10 @@ public class JDOMUtil { } @NotNull - public static String writeParent(Parent element, String lineSeparator) { + public static String write(Parent element, String lineSeparator) { try { final StringWriter writer = new StringWriter(); - writeParent(element, writer, lineSeparator); + write(element, writer, lineSeparator); return writer.toString(); } catch (IOException e) { @@ -427,7 +430,7 @@ public class JDOMUtil { } } - public static void writeParent(Parent element, Writer writer, String lineSeparator) throws IOException { + public static void write(Parent element, Writer writer, String lineSeparator) throws IOException { if (element instanceof Element) { writeElement((Element) element, writer, lineSeparator); } else if (element instanceof Document) { From be2945cbdd2a8cb0cbc312c66a265a6f03c10f0d Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 14 Feb 2017 13:38:22 +0100 Subject: [PATCH 53/96] cleanup (default interface methods, path) --- .../settings/CaptureConfigurable.java | 2 +- .../PluginsAdvertiser.java | 5 +- .../src/com/intellij/util/jdom.kt | 20 ++++-- .../com/intellij/openapi/util/JDOMUtil.java | 7 +++ .../maven/indices/MavenIndicesManager.java | 44 +++++++------ .../indices/MavenProjectIndicesManager.java | 13 ++-- .../navigator/MavenProjectsNavigator.java | 12 +--- .../maven/project/MavenProjectsManager.java | 40 +++++++----- .../idea/maven/project/MavenProjectsTree.java | 63 ++++++------------- .../maven/tasks/MavenShortcutsManager.java | 5 +- .../utils/MavenEditorTabTitleUpdater.java | 4 +- .../idea/maven/utils/MavenRehighlighter.java | 4 +- .../jetbrains/idea/maven/utils/MavenUtil.java | 8 ++- .../dom/MavenDomWithIndicesTestCase.java | 4 +- ...nExtensionCompletionAndResolutionTest.java | 4 +- ...avenPluginCompletionAndResolutionTest.java | 5 +- .../indices/MavenIndicesManagerTest.java | 22 ++++--- .../indices/MavenIndicesTestFixture.java | 17 +++-- .../MavenProjectIndicesManagerTest.java | 18 +++--- .../idea/maven/indices/MavenSearcherTest.java | 28 +++++---- .../importing/MavenProjectsManagerTest.java | 10 +-- .../MavenProjectsTreeIgnoresTest.java | 7 +-- .../MavenProjectsTreeReadingTest.java | 13 ++-- 23 files changed, 182 insertions(+), 173 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java b/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java index 1c4823bbdd4f..771900896656 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java @@ -173,7 +173,7 @@ public class CaptureConfigurable implements SearchableConfigurable { } }); try { - JDOMUtil.writeDocument(new Document(rootElement), wrapper.getFile(), "\n"); + JDOMUtil.write(rootElement, wrapper.getFile()); } catch (Exception ex) { final String msg = ex.getLocalizedMessage(); diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginsAdvertiser.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginsAdvertiser.java index 3003f665547e..1892e1bf9f8e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginsAdvertiser.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginsAdvertiser.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,6 @@ import com.intellij.util.io.HttpRequests; import com.intellij.util.xmlb.XmlSerializer; import com.intellij.util.xmlb.annotations.MapAnnotation; import com.intellij.util.xmlb.annotations.Tag; -import org.jdom.Document; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -179,7 +178,7 @@ public class PluginsAdvertiser implements StartupActivity { if (!plugins.isFile()) { FileUtil.ensureCanCreateFile(plugins); } - JDOMUtil.writeDocument(new Document(XmlSerializer.serialize(new KnownExtensions(extensions))), plugins, "\n"); + JDOMUtil.write(XmlSerializer.serialize(new KnownExtensions(extensions)), plugins); } public static void openDownloadPage() { diff --git a/platform/projectModel-impl/src/com/intellij/util/jdom.kt b/platform/projectModel-impl/src/com/intellij/util/jdom.kt index 28a3a4479006..4512e75e29a2 100644 --- a/platform/projectModel-impl/src/com/intellij/util/jdom.kt +++ b/platform/projectModel-impl/src/com/intellij/util/jdom.kt @@ -18,21 +18,22 @@ package com.intellij.util import com.intellij.openapi.util.JDOMUtil import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream import com.intellij.reference.SoftReference +import com.intellij.util.io.inputStream +import com.intellij.util.io.outputStream import com.intellij.util.text.CharSequenceReader import com.sun.org.apache.xerces.internal.impl.Constants import org.apache.xerces.util.SecurityManager import org.jdom.Document import org.jdom.Element +import org.jdom.JDOMException +import org.jdom.Parent import org.jdom.filter.ElementFilter import org.jdom.input.SAXBuilder import org.jdom.input.SAXHandler import org.xml.sax.EntityResolver import org.xml.sax.InputSource import org.xml.sax.XMLReader -import java.io.CharArrayReader -import java.io.InputStream -import java.io.Reader -import java.nio.file.Files +import java.io.* import java.nio.file.Path private val cachedSaxBuilder = ThreadLocal>() @@ -57,13 +58,22 @@ private fun getSaxBuilder(): SAXBuilder { return saxBuilder } +@JvmOverloads +@Throws(IOException::class) +fun write(element: Parent, file: Path, lineSeparator: String = "\n") { + BufferedOutputStream(file.outputStream()).use { + JDOMUtil.write(element, it, lineSeparator) + } +} + fun loadElement(chars: CharSequence) = loadElement(CharSequenceReader(chars)) fun loadElement(reader: Reader): Element = loadDocument(reader).detachRootElement() fun loadElement(stream: InputStream): Element = loadDocument(stream.reader()).detachRootElement() -fun loadElement(path: Path): Element = loadDocument(Files.newInputStream(path).bufferedReader()).detachRootElement() +@Throws(IOException::class, JDOMException::class) +fun loadElement(path: Path): Element = loadDocument(path.inputStream().bufferedReader()).detachRootElement() private fun loadDocument(reader: Reader): Document = reader.use { getSaxBuilder().build(it) } diff --git a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java index c2980e8bda4b..f6abf74ce2cc 100644 --- a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java +++ b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java @@ -16,6 +16,7 @@ package com.intellij.openapi.util; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.util.ArrayUtil; @@ -368,7 +369,13 @@ public class JDOMUtil { write(document, file, lineSeparator); } + public static void write(@NotNull Parent element, @NotNull File file) throws IOException { + write(element, file, "\n"); + } + public static void write(@NotNull Parent element, @NotNull File file, @NotNull String lineSeparator) throws IOException { + FileUtil.createParentDirs(file); + OutputStream stream = new BufferedOutputStream(new FileOutputStream(file)); try { write(element, stream, lineSeparator); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenIndicesManager.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenIndicesManager.java index 2a0003242acc..780a8c147fa3 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenIndicesManager.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenIndicesManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,12 +24,11 @@ import com.intellij.openapi.progress.BackgroundTaskQueue; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.JdomKt; +import com.intellij.util.io.PathKt; import gnu.trove.THashSet; -import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; import org.jetbrains.annotations.NotNull; @@ -44,6 +43,7 @@ import org.jetbrains.idea.maven.utils.*; import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.*; public class MavenIndicesManager implements Disposable { @@ -62,7 +62,7 @@ public class MavenIndicesManager implements Disposable { IDLE, WAITING, UPDATING } - private volatile File myTestIndicesDir; + private volatile Path myTestIndicesDir; private volatile MavenIndexerWrapper myIndexer; private volatile MavenIndices myIndices; @@ -79,7 +79,7 @@ public class MavenIndicesManager implements Disposable { } @TestOnly - public void setTestIndexDir(File indicesDir) { + public void setTestIndexDir(Path indicesDir) { myTestIndicesDir = indicesDir; } @@ -98,13 +98,15 @@ public class MavenIndicesManager implements Disposable { myIndexer = MavenServerManager.getInstance().createIndexer(); myDownloadListener = new MavenServerDownloadListener() { + @Override public void artifactDownloaded(File file, String relativePath) { addArtifact(file, relativePath); } }; MavenServerManager.getInstance().addDownloadListener(myDownloadListener); - myIndices = new MavenIndices(myIndexer, getIndicesDir(), new MavenIndex.IndexListener() { + myIndices = new MavenIndices(myIndexer, getIndicesDir().toFile(), new MavenIndex.IndexListener() { + @Override public void indexIsBroken(MavenIndex index) { scheduleUpdate(null, Collections.singletonList(index), false); } @@ -113,16 +115,18 @@ public class MavenIndicesManager implements Disposable { loadUserArchetypes(); } - private File getIndicesDir() { + @NotNull + private Path getIndicesDir() { return myTestIndicesDir == null ? MavenUtil.getPluginSystemDir("Indices") : myTestIndicesDir; } + @Override public void dispose() { doShutdown(); if (ApplicationManager.getApplication().isUnitTestMode()) { - FileUtil.delete(getIndicesDir()); + PathKt.delete(getIndicesDir()); } } @@ -226,6 +230,7 @@ public class MavenIndicesManager implements Disposable { } if (toSchedule.isEmpty()) return; myUpdatingQueue.run(new Task.Backgroundable(projectOrNull, IndicesBundle.message("maven.indices.updating"), true) { + @Override public void run(@NotNull ProgressIndicator indicator) { try { doUpdateIndices(projectOrNull, toSchedule, fullUpdate, new MavenProgressIndicator(indicator)); @@ -257,7 +262,7 @@ public class MavenIndicesManager implements Disposable { } try { - getIndicesObject().updateOrRepair(each, fullUpdate, fullUpdate ? getMavenSettings(projectOrNull, indicator) : null, indicator); + MavenIndices.updateOrRepair(each, fullUpdate, fullUpdate ? getMavenSettings(projectOrNull, indicator) : null, indicator); if (projectOrNull != null) { MavenRehighlighter.rehighlight(projectOrNull); } @@ -332,15 +337,15 @@ public class MavenIndicesManager implements Disposable { private void loadUserArchetypes() { try { - File file = getUserArchetypesFile(); - if (!file.exists()) return; - - Element root = JDOMUtil.load(file); + Path file = getUserArchetypesFile(); + if (!PathKt.exists(file)) { + return; + } // Store artifact to set to remove duplicate created by old IDEA (https://youtrack.jetbrains.com/issue/IDEA-72105) Collection result = new LinkedHashSet<>(); - List children = root.getChildren(ELEMENT_ARCHETYPE); + List children = JdomKt.loadElement(file).getChildren(ELEMENT_ARCHETYPE); for (int i = children.size() - 1; i >= 0; i--) { Element each = children.get(i); @@ -385,16 +390,15 @@ public class MavenIndicesManager implements Disposable { root.addContent(childElement); } try { - File file = getUserArchetypesFile(); - file.getParentFile().mkdirs(); - JDOMUtil.writeDocument(new Document(root), file, "\n"); + JdomKt.write(root, getUserArchetypesFile()); } catch (IOException e) { MavenLog.LOG.warn(e); } } - private File getUserArchetypesFile() { - return new File(getIndicesDir(), "UserArchetypes.xml"); + @NotNull + private Path getUserArchetypesFile() { + return getIndicesDir().resolve("UserArchetypes.xml"); } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenProjectIndicesManager.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenProjectIndicesManager.java index 729ad07c61dc..602ae4f36485 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenProjectIndicesManager.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenProjectIndicesManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,19 +70,13 @@ public class MavenProjectIndicesManager extends MavenSimpleProjectComponent { } getMavenProjectManager().addManagerListener(new MavenProjectsManager.Listener() { + @Override public void activated() { scheduleUpdateIndicesList(); } - - public void projectsScheduled() { - } - - @Override - public void importAndResolveScheduled() { - } }); - getMavenProjectManager().addProjectsTreeListener(new MavenProjectsTree.ListenerAdapter() { + getMavenProjectManager().addProjectsTreeListener(new MavenProjectsTree.Listener() { @Override public void projectsUpdated(List> updated, List deleted) { scheduleUpdateIndicesList(); @@ -102,6 +96,7 @@ public class MavenProjectIndicesManager extends MavenSimpleProjectComponent { public void scheduleUpdateIndicesList(@Nullable final Consumer> consumer) { myUpdateQueue.queue(new Update(MavenProjectIndicesManager.this) { + @Override public void run() { Set> remoteRepositoriesIdsAndUrls; File localRepository; diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigator.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigator.java index 33c38e9975c4..c669e4207d65 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigator.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -379,20 +379,12 @@ public class MavenProjectsNavigator extends MavenSimpleProjectComponent implemen scheduleStructureRequest(() -> myStructure.update()); } - private class MyProjectsListener extends MavenProjectsTree.ListenerAdapter implements MavenProjectsManager.Listener { + private class MyProjectsListener implements MavenProjectsManager.Listener, MavenProjectsTree.Listener { @Override public void activated() { scheduleStructureUpdate(); } - @Override - public void projectsScheduled() { - } - - @Override - public void importAndResolveScheduled() { - } - @Override public void projectsIgnoredStateChanged(final List ignored, final List unignored, boolean fromImport) { scheduleStructureRequest(() -> myStructure.updateIgnored(ContainerUtil.concat(ignored, unignored))); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java index 60d0daf189ef..3f4190baa4f3 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,6 @@ import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.*; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VfsUtilCore; @@ -51,6 +50,7 @@ import com.intellij.util.EventDispatcher; import com.intellij.util.NullableConsumer; import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.io.PathKt; import com.intellij.util.ui.update.Update; import gnu.trove.THashMap; import gnu.trove.THashSet; @@ -69,6 +69,7 @@ import org.jetbrains.idea.maven.utils.*; import javax.swing.event.HyperlinkEvent; import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.ReentrantLock; @@ -306,9 +307,9 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent private void initProjectsTree(boolean tryToLoadExisting) { if (tryToLoadExisting) { - File file = getProjectsTreeFile(); + Path file = getProjectsTreeFile(); try { - if (file.exists()) { + if (PathKt.exists(file)) { myProjectsTree = MavenProjectsTree.read(myProject, file); } } @@ -353,11 +354,12 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent } } - private File getProjectsTreeFile() { - return new File(getProjectsTreesDir(), myProject.getLocationHash() + "/tree.dat"); + private Path getProjectsTreeFile() { + return getProjectsTreesDir().resolve(myProject.getLocationHash()).resolve("tree.dat"); } - private static File getProjectsTreesDir() { + @NotNull + private static Path getProjectsTreesDir() { return MavenUtil.getPluginSystemDir("Projects"); } @@ -385,6 +387,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent private void listenForSettingsChanges() { getImportingSettings().addListener(new MavenImportingSettings.Listener() { + @Override public void autoImportChanged() { if (myProject.isDisposed()) return; @@ -393,10 +396,12 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent } } + @Override public void createModuleGroupsChanged() { scheduleImportSettings(true); } + @Override public void createModuleForAggregatorsChanged() { scheduleImportSettings(); } @@ -404,7 +409,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent } private void listenForProjectsTreeChanges() { - myProjectsTree.addListener(new MavenProjectsTree.ListenerAdapter() { + myProjectsTree.addListener(new MavenProjectsTree.Listener() { @Override public void projectsIgnoredStateChanged(List ignored, List unignored, boolean fromImport) { if (!fromImport) scheduleImport(); @@ -528,7 +533,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent mySaveQueue.flush(); if (isUnitTestMode()) { - FileUtil.delete(getProjectsTreesDir()); + PathKt.delete(getProjectsTreesDir()); } } finally { initLock.unlock(); @@ -701,10 +706,12 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent @Nullable public MavenProject findProject(@NotNull Module module) { VirtualFile f = findPomFile(module, new MavenModelsProvider() { + @Override public Module[] getModules() { throw new UnsupportedOperationException(); } + @Override public VirtualFile[] getContentRoots(Module module) { return ModuleRootManager.getInstance(module).getContentRoots(); } @@ -804,9 +811,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent public Set getRemoteRepositories() { Set result = new THashSet<>(); for (MavenProject each : getProjects()) { - for (MavenRemoteRepository eachRepository : each.getRemoteRepositories()) { - result.add(eachRepository); - } + result.addAll(each.getRemoteRepositories()); } return result; } @@ -989,6 +994,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent private Promise> scheduleImport() { final AsyncPromise> result = new AsyncPromise<>(); runWhenFullyOpen(() -> myImportingQueue.queue(new Update(MavenProjectsManager.this) { + @Override public void run() { result.setResult(importProjects()); } @@ -1178,6 +1184,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent } else { MavenUtil.runInBackground(myProject, ProjectBundle.message("maven.project.importing"), false, new MavenTask() { + @Override public void run(MavenProgressIndicator indicator) throws MavenProcessCanceledException { r.run(); } @@ -1257,10 +1264,13 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent } public interface Listener { - void activated(); + default void activated() { + } - void projectsScheduled(); + default void projectsScheduled() { + } - void importAndResolveScheduled(); + default void importAndResolveScheduled() { + } } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java index 5dacbbd09732..eff041bf6562 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import com.intellij.util.containers.ArrayListSet; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; import com.intellij.util.containers.Stack; +import com.intellij.util.io.PathKt; import gnu.trove.THashSet; import gnu.trove.TObjectHashingStrategy; import org.jdom.Element; @@ -48,6 +49,7 @@ import org.jetbrains.idea.maven.server.NativeMavenProjectHolder; import org.jetbrains.idea.maven.utils.*; import java.io.*; +import java.nio.file.Path; import java.util.*; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -88,6 +90,7 @@ public class MavenProjectsTree { private final Project myProject; private final MavenProjectReaderProjectLocator myProjectLocator = new MavenProjectReaderProjectLocator() { + @Override public VirtualFile findProjectFile(MavenId coordinates) { MavenProject project = findProject(coordinates); return project == null ? null : project.getFile(); @@ -99,11 +102,10 @@ public class MavenProjectsTree { } @Nullable - public static MavenProjectsTree read(Project project, File file) throws IOException { + public static MavenProjectsTree read(Project project, Path file) throws IOException { MavenProjectsTree result = new MavenProjectsTree(project); - DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file))); - try { + try (DataInputStream in = new DataInputStream(new BufferedInputStream(PathKt.inputStream(file)))) { try { if (!STORAGE_VERSION.equals(in.readUTF())) return null; result.myManagedFilesPaths = readCollection(in, new LinkedHashSet<>()); @@ -115,16 +117,13 @@ public class MavenProjectsTree { } catch (IOException e) { in.close(); - file.delete(); + PathKt.delete(file); throw e; } catch (Throwable e) { throw new IOException(e); } } - finally { - in.close(); - } return result; } @@ -165,13 +164,11 @@ public class MavenProjectsTree { return result; } - public void save(File file) throws IOException { + public void save(@NotNull Path file) throws IOException { synchronized (myStateLock) { readLock(); try { - file.getParentFile().mkdirs(); - DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file))); - try { + try (DataOutputStream out = new DataOutputStream(new BufferedOutputStream(PathKt.outputStream(file)))) { out.writeUTF(STORAGE_VERSION); writeCollection(out, myManagedFilesPaths); writeCollection(out, myIgnoredFilesPaths); @@ -180,9 +177,6 @@ public class MavenProjectsTree { writeCollection(out, myExplicitProfiles.getDisabledProfiles()); writeProjectsRecursively(out, myRootProjects); } - finally { - out.close(); - } } finally { readUnlock(); @@ -373,8 +367,8 @@ public class MavenProjectsTree { } } - private void updateExplicitProfiles(Collection explicitProfiles, Collection temporarilyRemovedExplicitProfiles, - Collection available) { + private static void updateExplicitProfiles(Collection explicitProfiles, Collection temporarilyRemovedExplicitProfiles, + Collection available) { Collection removedProfiles = new THashSet<>(explicitProfiles); removedProfiles.removeAll(available); temporarilyRemovedExplicitProfiles.addAll(removedProfiles); @@ -1357,6 +1351,7 @@ public class MavenProjectsTree { console, process, new EmbedderTask() { + @Override public void run(MavenEmbedderWrapper embedder) throws MavenProcessCanceledException { process.checkCanceled(); process.setText(ProjectBundle.message("maven.updating.folders.pom", mavenProject.getDisplayName())); @@ -1656,48 +1651,30 @@ public class MavenProjectsTree { } public interface Listener extends EventListener { - void profilesChanged(); - - void projectsIgnoredStateChanged(List ignored, List unignored, boolean fromImport); - - void projectsUpdated(List> updated, List deleted); - - void projectResolved(Pair projectWithChanges, - @Nullable NativeMavenProjectHolder nativeMavenProject); - - void pluginsResolved(MavenProject project); - - void foldersResolved(Pair projectWithChanges); - - void artifactsDownloaded(MavenProject project); - } - - public static class ListenerAdapter implements Listener { - public void profilesChanged() { + default void profilesChanged() { } - public void projectsIgnoredStateChanged(List ignored, List unignored, boolean fromImport) { + default void projectsIgnoredStateChanged(List ignored, List unignored, boolean fromImport) { } - public void projectsUpdated(List> updated, List deleted) { + default void projectsUpdated(List> updated, List deleted) { } - public void projectResolved(Pair projectWithChanges, - @Nullable NativeMavenProjectHolder nativeMavenProject) { + default void projectResolved(Pair projectWithChanges, + @Nullable NativeMavenProjectHolder nativeMavenProject) { } - public void pluginsResolved(MavenProject project) { + default void pluginsResolved(MavenProject project) { } - public void foldersResolved(Pair projectWithChanges) { + default void foldersResolved(Pair projectWithChanges) { } - public void artifactsDownloaded(MavenProject project) { + default void artifactsDownloaded(MavenProject project) { } } private static class MavenCoordinateHashCodeStrategy implements TObjectHashingStrategy { - @Override public int computeHashCode(MavenCoordinate object) { String artifactId = object.getArtifactId(); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/MavenShortcutsManager.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/MavenShortcutsManager.java index c65ba7aaabb9..4c07fa1a6e51 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/MavenShortcutsManager.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/MavenShortcutsManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ import com.intellij.openapi.project.DumbAwareRunnable; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.update.MergingUpdateQueue; import com.intellij.util.ui.update.Update; @@ -188,7 +187,7 @@ public class MavenShortcutsManager extends MavenSimpleProjectComponent implement } } - private class MyProjectsTreeListener extends MavenProjectsTree.ListenerAdapter implements MavenProjectsManager.Listener { + private class MyProjectsTreeListener implements MavenProjectsManager.Listener, MavenProjectsTree.Listener { private final Map mySheduledProjects = new THashMap<>(); private final MergingUpdateQueue myUpdateQueue = new MavenMergingUpdateQueue(getComponentName() + ": Keymap Update", 500, true, myProject); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenEditorTabTitleUpdater.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenEditorTabTitleUpdater.java index 9fc34de11a22..c460cae86032 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenEditorTabTitleUpdater.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenEditorTabTitleUpdater.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ public class MavenEditorTabTitleUpdater extends MavenSimpleProjectComponent { public void initComponent() { if (!isNormalProject()) return; - MavenProjectsManager.getInstance(myProject).addProjectsTreeListener(new MavenProjectsTree.ListenerAdapter() { + MavenProjectsManager.getInstance(myProject).addProjectsTreeListener(new MavenProjectsTree.Listener() { @Override public void projectsUpdated(List> updated, List deleted) { updateTabName(MavenUtil.collectFirsts(updated)); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenRehighlighter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenRehighlighter.java index b071905a5736..8f7681b62945 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenRehighlighter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenRehighlighter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,7 +69,7 @@ public class MavenRehighlighter { } }); - mavenProjectManager.addProjectsTreeListener(new MavenProjectsTree.ListenerAdapter() { + mavenProjectManager.addProjectsTreeListener(new MavenProjectsTree.Listener() { @Override public void projectsUpdated(List> updated, List deleted) { for (Pair each : updated) { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java index 656913d24787..b31097ab33d5 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,6 +80,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.nio.file.Paths; import java.util.*; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -220,9 +221,10 @@ public class MavenUtil { Notifications.Bus.notify(new Notification(MAVEN_NOTIFICATION_GROUP, title, e.getMessage(), NotificationType.ERROR), project); } - public static File getPluginSystemDir(String folder) { + @NotNull + public static java.nio.file.Path getPluginSystemDir(@NotNull String folder) { // PathManager.getSystemPath() may return relative path - return new File(PathManager.getSystemPath(), "Maven" + "/" + folder).getAbsoluteFile(); + return Paths.get(PathManager.getSystemPath()).toAbsolutePath().resolve("Maven").resolve(folder); } public static File getBaseDir(@NotNull VirtualFile file) { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomWithIndicesTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomWithIndicesTestCase.java index 0bc6355d34d5..09ac71f8c070 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomWithIndicesTestCase.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomWithIndicesTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ public abstract class MavenDomWithIndicesTestCase extends MavenDomTestCase { } protected MavenIndicesTestFixture createIndicesFixture() { - return new MavenIndicesTestFixture(myDir, myProject); + return new MavenIndicesTestFixture(myDir.toPath(), myProject); } @Override diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenExtensionCompletionAndResolutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenExtensionCompletionAndResolutionTest.java index 59944dd44371..96679839f600 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenExtensionCompletionAndResolutionTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenExtensionCompletionAndResolutionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ import java.util.List; public class MavenExtensionCompletionAndResolutionTest extends MavenDomWithIndicesTestCase { @Override protected MavenIndicesTestFixture createIndicesFixture() { - return new MavenIndicesTestFixture(myDir, myProject, "plugins"); + return new MavenIndicesTestFixture(myDir.toPath(), myProject, "plugins"); } @Override diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.java index a18f9c4a7d8e..de68e2d36d45 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package org.jetbrains.idea.maven.dom; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; import com.intellij.psi.xml.XmlTag; @@ -29,7 +28,7 @@ import java.util.List; public class MavenPluginCompletionAndResolutionTest extends MavenDomWithIndicesTestCase { @Override protected MavenIndicesTestFixture createIndicesFixture() { - return new MavenIndicesTestFixture(myDir, myProject, "plugins"); + return new MavenIndicesTestFixture(myDir.toPath(), myProject, "plugins"); } @Override diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesManagerTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesManagerTest.java index a9f32184ee0f..0ab997624182 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesManagerTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,15 +33,19 @@ public class MavenIndicesManagerTest extends MavenIndicesTestCase { @Override protected void setUp() throws Exception { super.setUp(); - myIndicesFixture = new MavenIndicesTestFixture(myDir, myProject); + myIndicesFixture = new MavenIndicesTestFixture(myDir.toPath(), myProject); myIndicesFixture.setUp(); MavenServerManager.getInstance().setUseMaven2(true); } @Override protected void tearDown() throws Exception { - myIndicesFixture.tearDown(); - super.tearDown(); + try { + myIndicesFixture.tearDown(); + } + finally { + super.tearDown(); + } } public void testEnsuringLocalRepositoryIndex() throws Exception { @@ -51,17 +55,17 @@ public class MavenIndicesManagerTest extends MavenIndicesTestCase { File dir4 = myIndicesFixture.getRepositoryHelper().getTestData("dir/bar"); List indices1 = myIndicesFixture.getIndicesManager().ensureIndicesExist(myProject, dir1, - Collections.>emptyList()); + Collections.emptyList()); assertEquals(1, indices1.size()); assertTrue(myIndicesFixture.getIndicesManager().getIndices().contains(indices1.get(0))); assertEquals(indices1, myIndicesFixture.getIndicesManager().ensureIndicesExist(myProject, dir2, - Collections.>emptyList())); + Collections.emptyList())); assertEquals(indices1, myIndicesFixture.getIndicesManager().ensureIndicesExist(myProject, dir3, - Collections.>emptyList())); + Collections.emptyList())); List indices2 = myIndicesFixture.getIndicesManager().ensureIndicesExist(myProject, dir4, - Collections.>emptyList()); + Collections.emptyList()); assertFalse(indices1.get(0).equals(indices2.get(0))); } @@ -87,7 +91,7 @@ public class MavenIndicesManagerTest extends MavenIndicesTestCase { public void testIndexedArchetypes() throws Exception { myIndicesFixture.getRepositoryHelper().addTestData("archetypes"); myIndicesFixture.getIndicesManager().ensureIndicesExist(myProject, myIndicesFixture.getRepositoryHelper().getTestData("archetypes"), - Collections.>emptyList()); + Collections.emptyList()); assertArchetypeExists("org.apache.maven.archetypes:maven-archetype-foobar:1.0"); } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTestFixture.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTestFixture.java index c7aa0c542300..bfe9a2ac6f91 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTestFixture.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTestFixture.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,10 @@ import org.jetbrains.idea.maven.server.MavenServerManager; import java.io.File; import java.io.IOException; +import java.nio.file.Path; public class MavenIndicesTestFixture { - private File myDir; + private Path myDir; private Project myProject; private String myLocalRepoDir; private String[] myExtraRepoDirs; @@ -33,11 +34,15 @@ public class MavenIndicesTestFixture { private MavenCustomRepositoryHelper myRepositoryHelper; private MavenProjectIndicesManager myIndicesManager; - public MavenIndicesTestFixture(File dir, Project project) { + public MavenIndicesTestFixture(Path dir, Project project) { this(dir, project, "local1", "local2"); } - public MavenIndicesTestFixture(File dir, Project project, String localRepoDir, String... extraRepoDirs) { + public MavenIndicesTestFixture(File dir, Project project) { + this(dir.toPath(), project); + } + + public MavenIndicesTestFixture(Path dir, Project project, String localRepoDir, String... extraRepoDirs) { myDir = dir; myProject = project; myLocalRepoDir = localRepoDir; @@ -45,7 +50,7 @@ public class MavenIndicesTestFixture { } public void setUp() throws Exception { - myRepositoryHelper = new MavenCustomRepositoryHelper(myDir, ArrayUtil.append(myExtraRepoDirs, myLocalRepoDir)); + myRepositoryHelper = new MavenCustomRepositoryHelper(myDir.toFile(), ArrayUtil.append(myExtraRepoDirs, myLocalRepoDir)); for (String each : myExtraRepoDirs) { addToRepository(each); @@ -54,7 +59,7 @@ public class MavenIndicesTestFixture { MavenProjectsManager.getInstance(myProject).getGeneralSettings().setLocalRepository( myRepositoryHelper.getTestDataPath(myLocalRepoDir)); - getIndicesManager().setTestIndexDir(new File(myDir, "MavenIndices")); + getIndicesManager().setTestIndexDir(myDir.resolve("MavenIndices")); myIndicesManager = MavenProjectIndicesManager.getInstance(myProject); myIndicesManager.doInit(); } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenProjectIndicesManagerTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenProjectIndicesManagerTest.java index 67fb844f7a3c..42cd87f9b7f1 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenProjectIndicesManagerTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenProjectIndicesManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,14 +23,18 @@ public class MavenProjectIndicesManagerTest extends MavenIndicesTestCase { @Override protected void setUp() throws Exception { super.setUp(); - myIndicesFixture = new MavenIndicesTestFixture(myDir, myProject); + myIndicesFixture = new MavenIndicesTestFixture(myDir.toPath(), myProject); myIndicesFixture.setUp(); } @Override protected void tearDown() throws Exception { - myIndicesFixture.tearDown(); - super.tearDown(); + try { + myIndicesFixture.tearDown(); + } + finally { + super.tearDown(); + } } public void testAutomaticallyAddAndUpdateLocalRepository() throws Exception { @@ -78,7 +82,7 @@ public class MavenProjectIndicesManagerTest extends MavenIndicesTestCase { public void testUpdatingIndexUsingMirrors() throws Exception { myIndicesFixture.tearDown(); - myIndicesFixture = new MavenIndicesTestFixture(myDir, myProject, "local2", "remote_mirror"); + myIndicesFixture = new MavenIndicesTestFixture(myDir.toPath(), myProject, "local2", "remote_mirror"); myIndicesFixture.setUp(); updateSettingsXmlFully("" + @@ -127,7 +131,7 @@ public class MavenProjectIndicesManagerTest extends MavenIndicesTestCase { assertUnorderedElementsAreEqual(myIndicesFixture.getProjectIndicesManager().getGroupIds(), "test", "jmock", "junit"); myIndicesFixture.tearDown(); - myIndicesFixture = new MavenIndicesTestFixture(myDir, myProject, "local2", "remote_mirror"); + myIndicesFixture = new MavenIndicesTestFixture(myDir.toPath(), myProject, "local2", "remote_mirror"); myIndicesFixture.setUp(); updateSettingsXmlFully("" + @@ -147,7 +151,7 @@ public class MavenProjectIndicesManagerTest extends MavenIndicesTestCase { public void testCheckingLocalRepositoryForAbsentIndices() throws Exception { myIndicesFixture.tearDown(); - myIndicesFixture = new MavenIndicesTestFixture(myDir, myProject, "local2"); + myIndicesFixture = new MavenIndicesTestFixture(myDir.toPath(), myProject, "local2"); myIndicesFixture.setUp(); myIndicesFixture.addToRepository("local1"); diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenSearcherTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenSearcherTest.java index 48b8b6bfa3cb..032a7000eabd 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenSearcherTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenSearcherTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,14 +26,18 @@ public class MavenSearcherTest extends MavenIndicesTestCase { @Override protected void setUp() throws Exception { super.setUp(); - myIndicesFixture = new MavenIndicesTestFixture(myDir, myProject); + myIndicesFixture = new MavenIndicesTestFixture(myDir.toPath(), myProject); myIndicesFixture.setUp(); } @Override protected void tearDown() throws Exception { - myIndicesFixture.tearDown(); - super.tearDown(); + try { + myIndicesFixture.tearDown(); + } + finally { + super.tearDown(); + } } public void testClassSearch() throws Exception { @@ -117,12 +121,12 @@ public class MavenSearcherTest extends MavenIndicesTestCase { private List getClassSearchResults(String pattern) { List actualArtifacts = new ArrayList<>(); for (MavenClassSearchResult eachResult : new MavenClassSearcher().search(myProject, pattern, 100)) { - String s = eachResult.className + "(" + eachResult.packageName + ")"; + StringBuilder s = new StringBuilder(eachResult.className + "(" + eachResult.packageName + ")"); for (MavenArtifactInfo eachVersion : eachResult.versions) { - if (s.length() > 0) s += " "; - s += eachVersion.getGroupId() + ":" + eachVersion.getArtifactId()+ ":" + eachVersion.getVersion(); + if (s.length() > 0) s.append(" "); + s.append(eachVersion.getGroupId()).append(":").append(eachVersion.getArtifactId()).append(":").append(eachVersion.getVersion()); } - actualArtifacts.add(s); + actualArtifacts.add(s.toString()); } return actualArtifacts; } @@ -130,12 +134,12 @@ public class MavenSearcherTest extends MavenIndicesTestCase { private void assertArtifactSearchResults(String pattern, String... expected) { List actual = new ArrayList<>(); for (MavenArtifactSearchResult eachResult : new MavenArtifactSearcher(true).search(myProject, pattern, 100)) { - String s = ""; + StringBuilder s = new StringBuilder(); for (MavenArtifactInfo eachVersion : eachResult.versions) { - if (s.length() > 0) s += " "; - s += eachVersion.getGroupId() + ":" + eachVersion.getArtifactId()+ ":" + eachVersion.getVersion(); + if (s.length() > 0) s.append(" "); + s.append(eachVersion.getGroupId()).append(":").append(eachVersion.getArtifactId()).append(":").append(eachVersion.getVersion()); } - actual.add(s); + actual.add(s.toString()); } assertOrderedElementsAreEqual(actual, expected); } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsManagerTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsManagerTest.java index 850f6114689e..5c43b33fdb9e 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsManagerTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -864,7 +864,7 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase { public void testDoNotScheduleResolveOfInvalidProjectsDeleted() throws Exception { final boolean[] called = new boolean[1]; - myProjectsManager.addProjectsTreeListener(new MavenProjectsTree.ListenerAdapter() { + myProjectsManager.addProjectsTreeListener(new MavenProjectsTree.Listener() { @Override public void projectResolved(Pair projectWithChanges, NativeMavenProjectHolder nativeMavenProject) { @@ -1086,14 +1086,14 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase { final StringBuilder log = new StringBuilder(); myProjectsManager.performScheduledImportInTests(); - myProjectsManager.addProjectsTreeListener(new MavenProjectsTree.ListenerAdapter() { + myProjectsManager.addProjectsTreeListener(new MavenProjectsTree.Listener() { @Override public void projectsUpdated(List> updated, List deleted) { for (Pair each : updated) { - log.append("updated: " + each.first.getDisplayName() + " "); + log.append("updated: ").append(each.first.getDisplayName()).append(" "); } for (MavenProject each : deleted) { - log.append("deleted: " + each.getDisplayName() + " "); + log.append("deleted: ").append(each.getDisplayName()).append(" "); } } }); diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeIgnoresTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeIgnoresTest.java index 09d1dace13d3..b75bf2b3bfba 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeIgnoresTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeIgnoresTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package org.jetbrains.idea.maven.project.importing; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.Function; import org.jetbrains.idea.maven.project.MavenProject; import org.jetbrains.idea.maven.project.MavenProjectsTree; @@ -61,7 +60,7 @@ public class MavenProjectsTreeIgnoresTest extends MavenProjectsTreeTestCase { assertEquals("ignored: m1 ", myLog); myLog = ""; - myTree.setIgnoredFilesPatterns(Collections.emptyList()); + myTree.setIgnoredFilesPatterns(Collections.emptyList()); assertEquals("unignored: m1 ", myLog); myLog = ""; @@ -78,7 +77,7 @@ public class MavenProjectsTreeIgnoresTest extends MavenProjectsTreeTestCase { assertEquals("", myLog); } - private class MyLoggingListener extends MavenProjectsTree.ListenerAdapter { + private class MyLoggingListener implements MavenProjectsTree.Listener { @Override public void projectsIgnoredStateChanged(List ignored, List unignored, boolean fromImport) { if (!ignored.isEmpty()) myLog += "ignored: " + format(ignored) + " "; diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeReadingTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeReadingTest.java index 2221aa191ed5..5cb4f020e02b 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeReadingTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeReadingTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.PlatformTestUtil; -import com.intellij.util.Function; import org.jetbrains.idea.maven.model.MavenExplicitProfiles; import org.jetbrains.idea.maven.project.MavenEmbeddersManager; import org.jetbrains.idea.maven.project.MavenProject; @@ -31,7 +30,7 @@ import org.jetbrains.idea.maven.server.MavenServerManager; import org.jetbrains.idea.maven.server.NativeMavenProjectHolder; import org.jetbrains.idea.maven.utils.MavenUtil; -import java.io.File; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -624,7 +623,7 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase { MavenEmbeddersManager embeddersManager = new MavenEmbeddersManager(myProject); final List nativeProject = new ArrayList<>(); try { - myTree.addListener(new MavenProjectsTree.ListenerAdapter() { + myTree.addListener(new MavenProjectsTree.Listener() { @Override public void projectResolved(Pair projectWithChanges, NativeMavenProjectHolder nativeMavenProject) { @@ -674,7 +673,7 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase { MavenEmbeddersManager embeddersManager = new MavenEmbeddersManager(myProject); try { final NativeMavenProjectHolder[] nativeProject = new NativeMavenProjectHolder[1]; - myTree.addListener(new MavenProjectsTree.ListenerAdapter() { + myTree.addListener(new MavenProjectsTree.Listener() { @Override public void projectResolved(Pair projectWithChanges, NativeMavenProjectHolder nativeMavenProject) { @@ -1867,7 +1866,7 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase { embeddersManager.releaseInTests(); } - File f = new File(myDir, "tree.dat"); + Path f = myDir.toPath().resolve("tree.dat"); myTree.save(f); MavenProjectsTree read = MavenProjectsTree.read(myProject, f); @@ -2239,7 +2238,7 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase { PlatformTestUtil.assertPathsEqual(pathFromBasedir("my-target/test-classes"), project.getTestOutputDirectory()); } - private static class MyLoggingListener extends MavenProjectsTree.ListenerAdapter { + private static class MyLoggingListener implements MavenProjectsTree.Listener { String log = ""; @Override From 03cc8a3a0f56406154eccb0f1f3d1c0c61747b5a Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 14 Feb 2017 14:53:49 +0100 Subject: [PATCH 54/96] cleanup (prefer to use loadElement) --- .../src/com/intellij/util/jdom.kt | 4 ++-- .../testFramework/assertions/JdomAssert.kt | 18 ++++++++++++---- .../com/intellij/openapi/util/JDOMUtil.java | 5 ----- .../edu/learning/StudySerializationUtils.java | 2 ++ python/educational-core/student/student.iml | 1 + .../edu/learning/StudyMigrationTest.java | 21 ++++++++++--------- 6 files changed, 30 insertions(+), 21 deletions(-) diff --git a/platform/projectModel-impl/src/com/intellij/util/jdom.kt b/platform/projectModel-impl/src/com/intellij/util/jdom.kt index 4512e75e29a2..bf1b8bea2a06 100644 --- a/platform/projectModel-impl/src/com/intellij/util/jdom.kt +++ b/platform/projectModel-impl/src/com/intellij/util/jdom.kt @@ -60,9 +60,9 @@ private fun getSaxBuilder(): SAXBuilder { @JvmOverloads @Throws(IOException::class) -fun write(element: Parent, file: Path, lineSeparator: String = "\n") { +fun Parent.write(file: Path, lineSeparator: String = "\n") { BufferedOutputStream(file.outputStream()).use { - JDOMUtil.write(element, it, lineSeparator) + JDOMUtil.write(this, it, lineSeparator) } } diff --git a/platform/testFramework/extensions/src/com/intellij/testFramework/assertions/JdomAssert.kt b/platform/testFramework/extensions/src/com/intellij/testFramework/assertions/JdomAssert.kt index 8ed846eadb7e..57d0c3555463 100644 --- a/platform/testFramework/extensions/src/com/intellij/testFramework/assertions/JdomAssert.kt +++ b/platform/testFramework/extensions/src/com/intellij/testFramework/assertions/JdomAssert.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,11 +16,15 @@ package com.intellij.testFramework.assertions import com.intellij.openapi.util.JDOMUtil +import com.intellij.openapi.util.text.StringUtilRt +import com.intellij.rt.execution.junit.FileComparisonFailure +import com.intellij.util.io.readText import com.intellij.util.isEmpty +import com.intellij.util.loadElement import org.assertj.core.api.AbstractAssert import org.assertj.core.internal.Objects import org.jdom.Element -import java.io.File +import java.nio.file.Path class JdomAssert(actual: Element?) : AbstractAssert(actual, JdomAssert::class.java) { fun isEmpty(): JdomAssert { @@ -33,8 +37,14 @@ class JdomAssert(actual: Element?) : AbstractAssert(actual return this } - fun isEqualTo(file: File): JdomAssert { - return isEqualTo(file.readText()) + fun isEqualTo(file: Path): JdomAssert { + isNotNull + + val expected = loadElement(file) + if (!JDOMUtil.areElementsEqual(actual, expected)) { + throw FileComparisonFailure(null, StringUtilRt.convertLineSeparators(file.readText()), JDOMUtil.writeElement(actual!!), file.toString()) + } + return this } fun isEqualTo(element: Element): JdomAssert { diff --git a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java index f6abf74ce2cc..30eba329bd41 100644 --- a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java +++ b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java @@ -257,11 +257,6 @@ public class JDOMUtil { return a1.getName().equals(a2.getName()) && a1.getValue().equals(a2.getValue()); } - @NotNull - public static Document loadDocument(char[] chars, int length) throws IOException, JDOMException { - return getSaxBuilder().build(new CharArrayReader(chars, 0, length)); - } - private static SAXBuilder getSaxBuilder() { SoftReference reference = ourSaxBuilder.get(); SAXBuilder saxBuilder = com.intellij.reference.SoftReference.dereference(reference); diff --git a/python/educational-core/student/src/com/jetbrains/edu/learning/StudySerializationUtils.java b/python/educational-core/student/src/com/jetbrains/edu/learning/StudySerializationUtils.java index 0163a3b895a4..6701b6bd4f6b 100644 --- a/python/educational-core/student/src/com/jetbrains/edu/learning/StudySerializationUtils.java +++ b/python/educational-core/student/src/com/jetbrains/edu/learning/StudySerializationUtils.java @@ -20,6 +20,7 @@ import com.jetbrains.edu.learning.stepic.StepicWrappers; import org.jdom.Attribute; import org.jdom.Element; import org.jdom.output.XMLOutputter; +import org.jetbrains.annotations.NotNull; import java.io.File; import java.lang.reflect.Type; @@ -208,6 +209,7 @@ public class StudySerializationUtils { return state; } + @NotNull public static Element convertToForthVersion(Element state) throws StudyUnrecognizedFormatException { Element taskManagerElement = state.getChild(MAIN_ELEMENT); Element courseElement = getChildWithName(taskManagerElement, COURSE).getChild(COURSE_TITLED); diff --git a/python/educational-core/student/student.iml b/python/educational-core/student/student.iml index 74bb142082e8..054fd550f453 100644 --- a/python/educational-core/student/student.iml +++ b/python/educational-core/student/student.iml @@ -36,5 +36,6 @@ + \ No newline at end of file diff --git a/python/educational-core/student/testSrc/com/jetbrains/edu/learning/StudyMigrationTest.java b/python/educational-core/student/testSrc/com/jetbrains/edu/learning/StudyMigrationTest.java index 2d21fd58ed8d..34f7846b804d 100644 --- a/python/educational-core/student/testSrc/com/jetbrains/edu/learning/StudyMigrationTest.java +++ b/python/educational-core/student/testSrc/com/jetbrains/edu/learning/StudyMigrationTest.java @@ -1,26 +1,27 @@ package com.jetbrains.edu.learning; -import com.intellij.openapi.util.JDOMUtil; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.testFramework.PlatformTestUtil; +import com.intellij.util.JdomKt; import org.jdom.Element; import org.jdom.JDOMException; +import org.jetbrains.annotations.NotNull; import org.junit.Test; -import java.io.File; import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static com.intellij.testFramework.assertions.Assertions.assertThat; public class StudyMigrationTest { - @Test public void testFromThirdToForth() throws JDOMException, IOException, StudySerializationUtils.StudyUnrecognizedFormatException { - Element element = JDOMUtil.load(new File(FileUtil.join(getTestDataPath(), "3.xml"))); - Element actual = StudySerializationUtils.Xml.convertToForthVersion(element); - Element expected = JDOMUtil.load(new File(FileUtil.join(getTestDataPath()), "4.xml")); - PlatformTestUtil.assertElementsEqual(expected, actual); + Element element = JdomKt.loadElement(getTestDataPath().resolve("3.xml")); + assertThat(StudySerializationUtils.Xml.convertToForthVersion(element)).isEqualTo(getTestDataPath().resolve("4.xml")); } - protected String getTestDataPath() { - return FileUtil.join(PlatformTestUtil.getCommunityPath(), "python/educational-core/student/testData/migration"); + @NotNull + protected Path getTestDataPath() { + return Paths.get(PlatformTestUtil.getCommunityPath(), "python/educational-core/student/testData/migration"); } } From fcb94abe9c50394852b9ffda38a584855cfdd917 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 14 Feb 2017 15:06:34 +0100 Subject: [PATCH 55/96] cleanup (use JdomKt.write --- .../daemon/InspectionProfileConvertor.java | 17 +++++++++-------- .../InspectionProfileLoadUtil.java | 6 +++--- .../intellij/internal/DumpIntentionsAction.java | 16 +++++++--------- .../intelliLang/InjectionsSettingsUI.java | 7 ++----- ...eResourceCompilerConfigurationGenerator.java | 10 +++++----- ...nResourceCompilerConfigurationGenerator.java | 11 +++++------ 6 files changed, 31 insertions(+), 36 deletions(-) diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java index 39ce82ed0bb4..7b5444ed5916 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java @@ -20,17 +20,19 @@ import com.intellij.codeInspection.ex.InspectionProfileImpl; import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.io.FileUtil; import com.intellij.profile.codeInspection.InspectionProfileManager; +import com.intellij.util.JdomKt; +import com.intellij.util.io.PathKt; import org.jdom.Element; import org.jdom.JDOMException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; @@ -93,20 +95,19 @@ public class InspectionProfileConvertor { } private static void renameOldDefaultsProfile() { - String directoryPath = PathManager.getConfigPath() + File.separator + InspectionProfileManager.INSPECTION_DIR; - File profileDirectory = new File(directoryPath); - if (!profileDirectory.exists()) { + Path directoryPath = Paths.get(PathManager.getConfigPath(), InspectionProfileManager.INSPECTION_DIR); + if (!PathKt.exists(directoryPath)) { return; } - File[] files = profileDirectory.listFiles(pathname -> pathname.getPath().endsWith(File.separator + DEFAULT_XML)); + File[] files = directoryPath.toFile().listFiles(pathname -> pathname.getPath().endsWith(File.separator + DEFAULT_XML)); if (files == null || files.length != 1 || !files[0].isFile() || files[0].length() == 0) { return; } try { - Element root = JDOMUtil.load(files[0]); + Element root = JdomKt.loadElement(files[0].toPath()); if (root.getAttributeValue(VERSION_ATT) == null){ - JDOMUtil.write(root, new FileOutputStream(new File(profileDirectory, OLD_DEFAUL_PROFILE + XML_EXTENSION)), "\n"); + JdomKt.write(root, directoryPath.resolve(OLD_DEFAUL_PROFILE + XML_EXTENSION)); FileUtil.delete(files[0]); } } diff --git a/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileLoadUtil.java b/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileLoadUtil.java index 96c240864f61..ac0a6a02788b 100644 --- a/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileLoadUtil.java +++ b/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileLoadUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ package com.intellij.profile.codeInspection; import com.intellij.codeInspection.ex.InspectionProfileImpl; import com.intellij.codeInspection.ex.InspectionToolRegistrar; import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.util.JdomKt; import org.jdom.Element; import org.jdom.JDOMException; import org.jetbrains.annotations.NotNull; @@ -46,7 +46,7 @@ public class InspectionProfileLoadUtil { public static InspectionProfileImpl load(@NotNull File file, @NotNull InspectionToolRegistrar registrar, @NotNull InspectionProfileManager profileManager) throws JDOMException, IOException, InvalidDataException { - Element element = JDOMUtil.load(file); + Element element = JdomKt.loadElement(file.getPath()); InspectionProfileImpl profile = new InspectionProfileImpl(getProfileName(file, element), registrar, (BaseInspectionProfileManager)profileManager); final Element profileElement = element.getChild("profile"); diff --git a/platform/lang-impl/src/com/intellij/internal/DumpIntentionsAction.java b/platform/lang-impl/src/com/intellij/internal/DumpIntentionsAction.java index d3408b33cae9..146203e41f00 100644 --- a/platform/lang-impl/src/com/intellij/internal/DumpIntentionsAction.java +++ b/platform/lang-impl/src/com/intellij/internal/DumpIntentionsAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,15 +25,13 @@ import com.intellij.codeInsight.intention.impl.config.IntentionManagerSettings; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; -import com.intellij.openapi.util.JDOMUtil; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.VfsUtil; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.project.DumbAware; -import org.jdom.Document; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.VfsUtilCore; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.JdomKt; import org.jdom.Element; import java.io.File; @@ -53,7 +51,7 @@ public class DumpIntentionsAction extends AnAction implements DumbAware { FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFolderDescriptor(), e.getData(CommonDataKeys.PROJECT), null); if (file != null) { final List list = IntentionManagerSettings.getInstance().getMetaData(); - final File root = VfsUtil.virtualToIoFile(file); + final File root = VfsUtilCore.virtualToIoFile(file); Element el = new Element("root"); Map categoryMap = new HashMap<>(); for (IntentionActionMetaData metaData : list) { @@ -73,7 +71,7 @@ public class DumpIntentionsAction extends AnAction implements DumbAware { } try { - JDOMUtil.writeDocument(new Document(el), new File(root, "intentions.xml"), "\n"); + JdomKt.write(el, root.toPath().resolve("intentions.xml")); } catch (IOException e1) { e1.printStackTrace(); diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java index d23c70974bf0..71c99aee23e1 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/InjectionsSettingsUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,6 @@ import com.intellij.openapi.ui.SplitterProportionsData; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Factory; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.NullableFactory; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -59,7 +58,6 @@ import org.intellij.plugins.intelliLang.inject.InjectorUtils; import org.intellij.plugins.intelliLang.inject.LanguageInjectionSupport; import org.intellij.plugins.intelliLang.inject.config.BaseInjection; import org.intellij.plugins.intelliLang.inject.config.InjectionPlace; -import org.jdom.Document; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -291,9 +289,8 @@ public class InjectionsSettingsUI extends SearchableConfigurable.Parent.Abstract if (wrapper == null) return; final Configuration configuration = new Configuration(); configuration.setInjections(injections); - final Document document = new Document(configuration.getState()); try { - JDOMUtil.writeDocument(document, wrapper.getFile(), "\n"); + JdomKt.write(configuration.getState(), wrapper.getFile().toPath()); } catch (IOException ex) { final String msg = ex.getLocalizedMessage(); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java index 14abae3cb9e5..5d41af3777cb 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,11 +35,11 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.util.ArrayUtil; import com.intellij.util.Function; +import com.intellij.util.JdomKt; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.FactoryMap; import com.intellij.util.xmlb.XmlSerializer; import gnu.trove.THashMap; -import org.jdom.Document; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -127,8 +127,8 @@ public class GradleResourceCompilerConfigurationGenerator { // update with newly generated configuration projectConfig.moduleConfigurations.putAll(affectedGradleModuleConfigurations); - final Document document = new Document(new Element("gradle-project-configuration")); - XmlSerializer.serializeInto(projectConfig, document.getRootElement()); + final Element element = new Element("gradle-project-configuration"); + XmlSerializer.serializeInto(projectConfig, element); final boolean finalConfigurationUpdateRequired = configurationUpdateRequired; buildManager.runCommand(() -> { if (finalConfigurationUpdateRequired) { @@ -136,7 +136,7 @@ public class GradleResourceCompilerConfigurationGenerator { } FileUtil.createIfDoesntExist(gradleConfigFile); try { - JDOMUtil.writeDocument(document, gradleConfigFile, "\n"); + JdomKt.write(element, gradleConfigFile.toPath()); myModulesConfigurationHash.putAll(affectedConfigurationHash); } catch (IOException e) { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java index 63b73b8185cb..71c5a93818fd 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.*; import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.StreamUtil; import com.intellij.openapi.util.text.StringUtil; @@ -33,9 +32,9 @@ import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.JdomKt; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.XmlSerializer; -import org.jdom.Document; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -189,13 +188,13 @@ public class MavenResourceCompilerConfigurationGenerator { addNonMavenResources(projectConfig); - final Document document = new Document(new Element("maven-project-configuration")); - XmlSerializer.serializeInto(projectConfig, document.getRootElement()); + final Element element = new Element("maven-project-configuration"); + XmlSerializer.serializeInto(projectConfig, element); buildManager.runCommand(() -> { buildManager.clearState(myProject); FileUtil.createIfDoesntExist(mavenConfigFile); try { - JDOMUtil.writeDocument(document, mavenConfigFile, "\n"); + JdomKt.write(element, mavenConfigFile.toPath()); DataOutputStream crcOutput = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(crcFile))); try { From 4272d059e9f9b6119f01f05eb1992bf3e2434ef2 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 14 Feb 2017 15:08:35 +0100 Subject: [PATCH 56/96] remove unused getContent --- platform/util/src/com/intellij/openapi/util/JDOMUtil.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java index 30eba329bd41..f2bf55a00880 100644 --- a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java +++ b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java @@ -141,12 +141,6 @@ public class JDOMUtil { return i * 31 + s.hashCode(); } - @NotNull - public static Content[] getContent(@NotNull Element m) { - List list = m.getContent(); - return list.toArray(new Content[list.size()]); - } - @NotNull public static Element[] getElements(@NotNull Element m) { List list = m.getChildren(); From bba5d764970064b9c11fb66f443c594557826076 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 14 Feb 2017 15:13:27 +0100 Subject: [PATCH 57/96] hide addContent --- .../com/intellij/openapi/util/JDOMUtil.java | 18 ++++-------------- .../com/intellij/util/xmlb/BeanBinding.java | 3 +-- .../src/com/intellij/util/xmlb/Binding.java | 15 +++++++++++++++ .../intellij/util/xmlb/OptionTagBinding.java | 3 +-- .../src/com/intellij/util/xmlb/TagBinding.java | 3 +-- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java index f2bf55a00880..74fee33f3ab9 100644 --- a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java +++ b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java @@ -141,26 +141,16 @@ public class JDOMUtil { return i * 31 + s.hashCode(); } + /** + * @deprecated Use Element.getChildren() directly + */ @NotNull + @Deprecated public static Element[] getElements(@NotNull Element m) { List list = m.getChildren(); return list.toArray(new Element[list.size()]); } - public static void addContent(@NotNull final Element targetElement, final Object node) { - if (node instanceof Content) { - Content content = (Content)node; - targetElement.addContent(content); - } - else if (node instanceof List) { - //noinspection unchecked - targetElement.addContent((List)node); - } - else { - throw new IllegalArgumentException("Wrong node: " + node); - } - } - public static void internElement(@NotNull Element element, @NotNull StringInterner interner) { element.setName(interner.intern(element.getName())); diff --git a/platform/util/src/com/intellij/util/xmlb/BeanBinding.java b/platform/util/src/com/intellij/util/xmlb/BeanBinding.java index 198495e07d6f..c3af16cf06ff 100644 --- a/platform/util/src/com/intellij/util/xmlb/BeanBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/BeanBinding.java @@ -16,7 +16,6 @@ package com.intellij.util.xmlb; import com.intellij.openapi.util.Couple; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.ReflectionUtil; @@ -121,7 +120,7 @@ public class BeanBinding extends NotNullDeserializeBinding { element.setAttribute((org.jdom.Attribute)node); } else { - JDOMUtil.addContent(element, node); + addContent(element, node); } } } diff --git a/platform/util/src/com/intellij/util/xmlb/Binding.java b/platform/util/src/com/intellij/util/xmlb/Binding.java index 0d186d2a98a3..f5255ad05009 100644 --- a/platform/util/src/com/intellij/util/xmlb/Binding.java +++ b/platform/util/src/com/intellij/util/xmlb/Binding.java @@ -16,6 +16,7 @@ package com.intellij.util.xmlb; import com.intellij.openapi.diagnostic.Logger; +import org.jdom.Content; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -66,4 +67,18 @@ public abstract class Binding { } public abstract Object deserializeUnsafe(Object context, @NotNull Element element); + + protected static void addContent(@NotNull final Element targetElement, final Object node) { + if (node instanceof Content) { + Content content = (Content)node; + targetElement.addContent(content); + } + else if (node instanceof List) { + //noinspection unchecked + targetElement.addContent((List)node); + } + else { + throw new IllegalArgumentException("Wrong node: " + node); + } + } } diff --git a/platform/util/src/com/intellij/util/xmlb/OptionTagBinding.java b/platform/util/src/com/intellij/util/xmlb/OptionTagBinding.java index 06068650ac2f..c2675ca573be 100644 --- a/platform/util/src/com/intellij/util/xmlb/OptionTagBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/OptionTagBinding.java @@ -15,7 +15,6 @@ */ package com.intellij.util.xmlb; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.xmlb.annotations.OptionTag; import org.jdom.Attribute; @@ -75,7 +74,7 @@ class OptionTagBinding extends BasePrimitiveBinding { else { Object node = myBinding.serialize(value, targetElement, filter); if (node != null && targetElement != node) { - JDOMUtil.addContent(targetElement, node); + addContent(targetElement, node); } } } diff --git a/platform/util/src/com/intellij/util/xmlb/TagBinding.java b/platform/util/src/com/intellij/util/xmlb/TagBinding.java index dd0af3a8cd31..658df4d3f18d 100644 --- a/platform/util/src/com/intellij/util/xmlb/TagBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/TagBinding.java @@ -15,7 +15,6 @@ */ package com.intellij.util.xmlb; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.util.xmlb.annotations.Tag; import org.jdom.Element; import org.jdom.Text; @@ -49,7 +48,7 @@ class TagBinding extends BasePrimitiveBinding implements MultiNodeBinding { else { Object node = myBinding.serialize(value, serialized, filter); if (node != null && node != serialized) { - JDOMUtil.addContent(serialized, node); + addContent(serialized, node); } } return serialized; From 1929da8a2277fa3ba369ed3d4e7e1d520c9403fc Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 14 Feb 2017 16:39:47 +0100 Subject: [PATCH 58/96] deprecate loadDocument --- .../templates/RemoteTemplatesFactory.java | 5 ++--- .../javadoc/LightJavadocGeneratorTest.kt | 8 ++++---- .../template/LiveTemplateTest.groovy | 9 +++++---- .../ex/InspectionProfileTest.java | 18 ++++++++--------- .../execution/impl/RunConfigurableTest.java | 6 +++--- .../wm/impl/HiddenSidebarButtonTest.java | 6 +++--- .../run/JavaPathMacroCollectorTest.groovy | 7 +++---- .../src/FileBasedStorage.kt | 3 ++- .../testSrc/xml/XmlSerializerTest.kt | 2 +- .../templates/LocalArchivedTemplate.java | 12 +++++------ .../impl/ShowUpdateInfoDialogAction.java | 9 ++++----- .../openapi/editor/colors/impl/Option.java | 6 +++--- .../openapi/fileTypes/impl/FileTypesTest.java | 8 ++++---- .../projectModel-api/projectModel-api.iml | 1 + .../src/com/intellij/util/io/path.kt | 0 .../src/com/intellij/util/jdom.kt | 1 + .../projectModel-impl/projectModel-impl.iml | 1 - .../fixtures/MessagesFixture.java | 8 +++----- .../com/intellij/openapi/util/JDOMUtil.java | 6 +++++- .../idea/eclipse/EclipseClasspathTest.java | 6 +++--- .../idea/eclipse/EclipseEmlTest.java | 4 ++-- .../idea/eclipse/EclipseImlTest.java | 6 +++--- .../junit/JUnitConfigurationTest.java | 14 ++++++------- .../SaveFormAsTemplateHandler.java | 20 ++++++++----------- 24 files changed, 81 insertions(+), 85 deletions(-) rename platform/{projectModel-impl => projectModel-api}/src/com/intellij/util/io/path.kt (100%) rename platform/{projectModel-impl => projectModel-api}/src/com/intellij/util/jdom.kt (98%) diff --git a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java index c52c72a16bb2..4bfa06a48a46 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java +++ b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ import com.intellij.openapi.extensions.PluginId; import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.module.ModuleTypeManager; import com.intellij.openapi.util.ClearableLazyValue; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.platform.ProjectTemplate; import com.intellij.platform.ProjectTemplatesFactory; import com.intellij.util.ArrayUtil; @@ -95,7 +94,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory { @NotNull @TestOnly public static MultiMap createFromText(@NotNull String value) throws IOException, JDOMException { - return create(JDOMUtil.loadDocument(value).getRootElement()); + return create(JdomKt.loadElement(value)); } @NotNull diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/LightJavadocGeneratorTest.kt b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/LightJavadocGeneratorTest.kt index 090876763d60..a8902bb467f9 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/LightJavadocGeneratorTest.kt +++ b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/LightJavadocGeneratorTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,11 +15,11 @@ */ package com.intellij.codeInsight.javadoc -import com.intellij.openapi.util.JDOMUtil import com.intellij.psi.PsiJavaFile -import com.intellij.testFramework.assertions.Assertions.assertThat import com.intellij.testFramework.LightProjectDescriptor +import com.intellij.testFramework.assertions.Assertions.assertThat import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase +import com.intellij.util.loadElement class LightJavadocGeneratorTest : LightCodeInsightFixtureTestCase() { override fun getProjectDescriptor(): LightProjectDescriptor = JAVA_9 @@ -45,7 +45,7 @@ class LightJavadocGeneratorTest : LightCodeInsightFixtureTestCase() { val file = myFixture.configureByText("module-info.java", text) val module = (file as PsiJavaFile).moduleDeclaration!! val docInfo = JavaDocInfoGeneratorFactory.create(project, module).generateDocInfo(null)!! - val body = JDOMUtil.loadDocument(docInfo).rootElement.getChild("body") + val body = loadElement(docInfo).getChild("body") assertThat(body).isEqualTo(expected) } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy index e46bca927635..e711200ee90f 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy @@ -35,6 +35,7 @@ import com.intellij.psi.codeStyle.CommonCodeStyleSettings import com.intellij.testFramework.LightPlatformCodeInsightTestCase import com.intellij.testFramework.fixtures.CodeInsightTestUtil import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase +import com.intellij.util.JdomKt import com.intellij.util.containers.ContainerUtil import com.intellij.util.ui.UIUtil import org.jdom.Element @@ -658,11 +659,11 @@ class Outer { } void testDontSaveDefaultContexts() { - def defElement = JDOMUtil.loadDocument('''\ + def defElement = JdomKt.loadElement('''\ ''').rootElement +''') def defContext = new TemplateContext() defContext.readTemplateContext(defElement) @@ -695,10 +696,10 @@ class Outer { } void "test adding new context to Other"() { - def defElement = JDOMUtil.loadDocument('''\ + def defElement = JdomKt.loadElement('''\ ''').rootElement +''') def context = new TemplateContext() context.readTemplateContext(defElement) diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java index 2a4c24924f3a..90a8700beaeb 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -117,7 +117,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { } public void testConvertOldProfile() throws Exception { - Element element = JDOMUtil.loadDocument("\n" + + Element element = JdomKt.loadElement("\n" + " ").getRootElement(); + ""); InspectionProfileImpl profile = createProfile(); profile.readExternal(element); profile.getModifiableModel().commit(); @@ -296,7 +296,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { InspectionToolsConfigurable.importInspectionProfile(toImportElement, getApplicationProfileManager(), getProject(), null); //check merged - Element mergedElement = JDOMUtil.loadDocument(mergedText).getRootElement(); + Element mergedElement = JdomKt.loadElement(mergedText); profile = createProfile(new InspectionProfileImpl("foo")); profile.readExternal(mergedElement); profile.getModifiableModel().commit(); @@ -307,7 +307,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { public void testStoredMemberVisibility() throws Exception { InspectionProfileImpl profile = createProfile(new InspectionProfileImpl("foo")); - profile.readExternal(JDOMUtil.loadDocument("\n" + + profile.readExternal(JdomKt.loadElement("\n" + " \n" + " \n" + - "").getRootElement()); + "")); profile.modifyProfile(it -> { InspectionToolWrapper toolWrapper = it.getInspectionTool("unused", getProject()); UnusedDeclarationInspectionBase tool = (UnusedDeclarationInspectionBase)toolWrapper.getTool(); @@ -481,7 +481,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { } private static void checkMergedNoChanges(String initialText) throws Exception { - final Element element = JDOMUtil.loadDocument(initialText).getRootElement(); + final Element element = JdomKt.loadElement(initialText); InspectionProfileImpl profile = createProfile(new InspectionProfileImpl("foo")); profile.readExternal(element); profile.getModifiableModel().commit(); @@ -615,13 +615,13 @@ public class InspectionProfileTest extends LightIdeaTestCase { public void testInspectionInitializationForSerialization() throws Exception { InspectionProfileImpl foo = new InspectionProfileImpl("foo"); - foo.readExternal(JDOMUtil.loadDocument("\n" + + foo.readExternal(JdomKt.loadElement("\n" + " ").getRootElement()); + "")); foo.initInspectionTools(getProject()); assertEquals(1, countInitializedTools(foo)); } diff --git a/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java b/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java index d00b71835a4e..bf7050ac2884 100644 --- a/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java +++ b/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,11 +21,11 @@ import com.intellij.execution.configurations.UnknownConfigurationType; import com.intellij.execution.junit.JUnitConfigurationType; import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Trinity; import com.intellij.testFramework.LightIdeaTestCase; import com.intellij.ui.RowsDnDSupport; import com.intellij.ui.treeStructure.Tree; +import com.intellij.util.JdomKt; import org.jdom.Element; import javax.swing.tree.DefaultMutableTreeNode; @@ -66,7 +66,7 @@ public class RunConfigurableTest extends LightIdeaTestCase { @Override protected void setUp() throws Exception { super.setUp(); - myConfigurable = new MockRunConfigurable(createRunManager(JDOMUtil.loadDocument(FOLDERS_CONFIGURATION).getRootElement())); + myConfigurable = new MockRunConfigurable(createRunManager(JdomKt.loadElement(FOLDERS_CONFIGURATION))); myTree = myConfigurable.myTree; myRoot = myConfigurable.myRoot; myModel = myConfigurable.myTreeModel; diff --git a/java/java-tests/testSrc/com/intellij/openapi/wm/impl/HiddenSidebarButtonTest.java b/java/java-tests/testSrc/com/intellij/openapi/wm/impl/HiddenSidebarButtonTest.java index 5a01dfbfd7e1..dc052f954581 100644 --- a/java/java-tests/testSrc/com/intellij/openapi/wm/impl/HiddenSidebarButtonTest.java +++ b/java/java-tests/testSrc/com/intellij/openapi/wm/impl/HiddenSidebarButtonTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,10 +16,10 @@ package com.intellij.openapi.wm.impl; import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.wm.ToolWindowEP; import com.intellij.openapi.wm.ToolWindowId; import com.intellij.usageView.impl.UsageViewManagerImpl; +import com.intellij.util.JdomKt; import java.util.Arrays; @@ -41,7 +41,7 @@ public class HiddenSidebarButtonTest extends ToolWindowManagerTestCase { public void testHiddenButton() throws Exception { DesktopLayout layout = myManager.getLayout(); - layout.readExternal(JDOMUtil.loadDocument(LAYOUT).getRootElement()); + layout.readExternal(JdomKt.loadElement(LAYOUT)); for (String ID : IDS) { assertFalse(layout.isToolWindowRegistered(ID)); assertTrue(layout.isToolWindowUnregistered(ID)); diff --git a/java/java-tests/testSrc/com/intellij/run/JavaPathMacroCollectorTest.groovy b/java/java-tests/testSrc/com/intellij/run/JavaPathMacroCollectorTest.groovy index 2dfdfa16e5c1..fff924767a09 100644 --- a/java/java-tests/testSrc/com/intellij/run/JavaPathMacroCollectorTest.groovy +++ b/java/java-tests/testSrc/com/intellij/run/JavaPathMacroCollectorTest.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ package com.intellij.run import com.intellij.application.options.PathMacrosCollector -import com.intellij.openapi.util.JDOMUtil import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase +import com.intellij.util.JdomKt class JavaPathMacroCollectorTest extends LightCodeInsightFixtureTestCase { void testJunitConfiguration() { @@ -56,8 +56,7 @@ class JavaPathMacroCollectorTest extends LightCodeInsightFixtureTestCase { ''' - def element = JDOMUtil.loadDocument(text).rootElement - assert PathMacrosCollector.getMacroNames(element).empty + assert PathMacrosCollector.getMacroNames(JdomKt.loadElement(text)).empty } } diff --git a/platform/configuration-store-impl/src/FileBasedStorage.kt b/platform/configuration-store-impl/src/FileBasedStorage.kt index 3b562538312a..a47c1c32608f 100644 --- a/platform/configuration-store-impl/src/FileBasedStorage.kt +++ b/platform/configuration-store-impl/src/FileBasedStorage.kt @@ -132,7 +132,8 @@ open class FileBasedStorage(file: Path, else { val charBuffer = StandardCharsets.UTF_8.decode(ByteBuffer.wrap(file.contentsToByteArray())) lineSeparator = detectLineSeparators(charBuffer, if (isUseXmlProlog) null else LineSeparator.LF) - return JDOMUtil.loadDocument(charBuffer).detachRootElement() + @Suppress("DEPRECATION") + return loadElement(charBuffer) } return null } diff --git a/platform/configuration-store-impl/testSrc/xml/XmlSerializerTest.kt b/platform/configuration-store-impl/testSrc/xml/XmlSerializerTest.kt index b825be8c8370..dd39eec7e98e 100644 --- a/platform/configuration-store-impl/testSrc/xml/XmlSerializerTest.kt +++ b/platform/configuration-store-impl/testSrc/xml/XmlSerializerTest.kt @@ -634,7 +634,7 @@ internal class XmlSerializerTest { private fun checkSmartSerialization(bean: Bean2, serialized: String) { val serializer = SmartSerializer() - serializer.readExternal(bean, JDOMUtil.loadDocument(serialized).rootElement) + serializer.readExternal(bean, JDOMUtil.load(serialized)) val serializedState = Element("Bean2") serializer.writeExternal(bean, serializedState) assertThat(JDOMUtil.writeElement(serializedState)).isEqualTo(serialized) diff --git a/platform/lang-impl/src/com/intellij/platform/templates/LocalArchivedTemplate.java b/platform/lang-impl/src/com/intellij/platform/templates/LocalArchivedTemplate.java index a0b231cb1f5a..cbf85904fbd5 100644 --- a/platform/lang-impl/src/com/intellij/platform/templates/LocalArchivedTemplate.java +++ b/platform/lang-impl/src/com/intellij/platform/templates/LocalArchivedTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,12 +21,11 @@ import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.module.ModuleTypeManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.IconLoader; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.StreamUtil; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.VirtualFile; -import org.jdom.Document; +import com.intellij.util.JdomKt; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -67,7 +66,7 @@ public class LocalArchivedTemplate extends ArchivedProjectTemplate { String s = readEntry(TEMPLATE_DESCRIPTOR); if (s != null) { try { - Element templateElement = JDOMUtil.loadDocument(s).getRootElement(); + Element templateElement = JdomKt.loadElement(s); populateFromElement(templateElement); String iconPath = templateElement.getChildText("icon-path"); if (iconPath != null) { @@ -82,7 +81,7 @@ public class LocalArchivedTemplate extends ArchivedProjectTemplate { String meta = readEntry(META_TEMPLATE_DESCRIPTOR_PATH); if (meta != null) { try { - Element templateElement = JDOMUtil.loadDocument(meta).getRootElement(); + Element templateElement = JdomKt.loadElement(meta); String unencoded = templateElement.getAttributeValue(UNENCODED_ATTRIBUTE); if (unencoded != null) { myEscaped = !Boolean.valueOf(unencoded); @@ -171,8 +170,7 @@ public class LocalArchivedTemplate extends ArchivedProjectTemplate { String iml = template.readEntry(".iml"); if (iml == null) return ModuleType.EMPTY; try { - Document document = JDOMUtil.loadDocument(iml); - String type = document.getRootElement().getAttributeValue(Module.ELEMENT_TYPE); + String type = JdomKt.loadElement(iml).getAttributeValue(Module.ELEMENT_TYPE); return ModuleTypeManager.getInstance().findByID(type); } catch (Exception e) { diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/ShowUpdateInfoDialogAction.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/ShowUpdateInfoDialogAction.java index d813d34d191b..0e16b1d193f6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/ShowUpdateInfoDialogAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/ShowUpdateInfoDialogAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ package com.intellij.openapi.updateSettings.impl; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.application.ApplicationInfo; -import com.intellij.openapi.util.JDOMUtil; +import com.intellij.util.JdomKt; import java.util.Collections; @@ -32,11 +32,10 @@ public class ShowUpdateInfoDialogAction extends AnAction { public void actionPerformed(AnActionEvent e) { try { myShowBigData = ! myShowBigData; - UpdateChannel channel = new UpdateChannel(JDOMUtil.loadDocument(getXML(myShowBigData)).getRootElement()); + UpdateChannel channel = new UpdateChannel(JdomKt.loadElement(getXML(myShowBigData))); BuildInfo newBuild = channel.getBuilds().get(0); PatchInfo patchInfo = new PatchInfo( - JDOMUtil.loadDocument("") - .getRootElement()); + JdomKt.loadElement("")); new UpdateInfoDialog(channel, newBuild, patchInfo, true, UpdateSettings.getInstance().canUseSecureConnection(), Collections.emptyList(), Collections.emptyList()).show(); } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/Option.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/Option.java index f2f55ad8d3e9..546c64f1c325 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/Option.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/Option.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ package com.intellij.openapi.editor.colors.impl; -import com.intellij.openapi.util.JDOMUtil; +import com.intellij.util.JdomKt; import org.jdom.Element; import org.jetbrains.annotations.NotNull; @@ -67,6 +67,6 @@ final class Option { static Element element(Object object) throws Exception { String xml = object == null ? null : object.toString(); System.out.println(xml); - return xml == null ? null : JDOMUtil.loadDocument(xml).getRootElement(); + return xml == null ? null : JdomKt.loadElement(xml); } } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java index b3c3519c0e94..c7b0e54b247f 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,6 @@ import com.intellij.openapi.fileEditor.impl.LoadTextUtil; import com.intellij.openapi.fileTypes.*; import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx; import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.util.io.ByteSequence; @@ -48,6 +47,7 @@ import com.intellij.psi.impl.PsiManagerEx; import com.intellij.testFramework.PlatformTestCase; import com.intellij.testFramework.PlatformTestUtil; import com.intellij.testFramework.VfsTestUtil; +import com.intellij.util.JdomKt; import com.intellij.util.PatternUtil; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; @@ -504,12 +504,12 @@ public class FileTypesTest extends PlatformTestCase { myFileTypeManager.initStandardFileTypes(); myFileTypeManager.initComponent(); - Element element = JDOMUtil.loadDocument( + Element element = JdomKt.loadElement( "\n" + " \n" + " \n" + " \n" + - "").getRootElement(); + ""); myFileTypeManager.loadState(element); myFileTypeManager.initComponent(); diff --git a/platform/projectModel-api/projectModel-api.iml b/platform/projectModel-api/projectModel-api.iml index 9ae795864733..ecbad134ebbe 100644 --- a/platform/projectModel-api/projectModel-api.iml +++ b/platform/projectModel-api/projectModel-api.iml @@ -10,5 +10,6 @@ + \ No newline at end of file diff --git a/platform/projectModel-impl/src/com/intellij/util/io/path.kt b/platform/projectModel-api/src/com/intellij/util/io/path.kt similarity index 100% rename from platform/projectModel-impl/src/com/intellij/util/io/path.kt rename to platform/projectModel-api/src/com/intellij/util/io/path.kt diff --git a/platform/projectModel-impl/src/com/intellij/util/jdom.kt b/platform/projectModel-api/src/com/intellij/util/jdom.kt similarity index 98% rename from platform/projectModel-impl/src/com/intellij/util/jdom.kt rename to platform/projectModel-api/src/com/intellij/util/jdom.kt index bf1b8bea2a06..016502e77c4d 100644 --- a/platform/projectModel-impl/src/com/intellij/util/jdom.kt +++ b/platform/projectModel-api/src/com/intellij/util/jdom.kt @@ -66,6 +66,7 @@ fun Parent.write(file: Path, lineSeparator: String = "\n") { } } +@Throws(IOException::class, JDOMException::class) fun loadElement(chars: CharSequence) = loadElement(CharSequenceReader(chars)) fun loadElement(reader: Reader): Element = loadDocument(reader).detachRootElement() diff --git a/platform/projectModel-impl/projectModel-impl.iml b/platform/projectModel-impl/projectModel-impl.iml index 9c361c7c6638..30368b2eb8a0 100644 --- a/platform/projectModel-impl/projectModel-impl.iml +++ b/platform/projectModel-impl/projectModel-impl.iml @@ -14,6 +14,5 @@ - \ No newline at end of file diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/MessagesFixture.java b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/MessagesFixture.java index ca890a8621a4..994d1b8bcd8e 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/MessagesFixture.java +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/MessagesFixture.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,12 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.text.StringUtil; import com.intellij.testGuiFramework.framework.GuiTestUtil; import com.intellij.ui.messages.SheetController; +import com.intellij.util.JdomKt; import org.fest.swing.core.GenericTypeMatcher; import org.fest.swing.core.Robot; import org.fest.swing.exception.WaitTimedOutError; import org.fest.swing.fixture.ContainerFixture; import org.fest.swing.fixture.JPanelFixture; -import org.jdom.Document; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -33,7 +33,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; -import static com.intellij.openapi.util.JDOMUtil.loadDocument; import static org.fest.assertions.Assertions.assertThat; import static org.fest.reflect.core.Reflection.field; import static org.junit.Assert.assertNotNull; @@ -212,8 +211,7 @@ public class MessagesFixture { @Nullable private static String getHtmlBody(@NotNull String html) { try { - Document document = loadDocument(html); - Element rootElement = document.getRootElement(); + Element rootElement = JdomKt.loadElement(html); String sheetTitle = rootElement.getChild("body").getText(); return sheetTitle.replace("\n", "").trim(); } diff --git a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java index 74fee33f3ab9..b2aa347b9088 100644 --- a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java +++ b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java @@ -183,7 +183,7 @@ public class JDOMUtil { return result; } - public static void appendLegalized(@NotNull StringBuilder sb, char each) { + private static void appendLegalized(@NotNull StringBuilder sb, char each) { if (each == '<' || each == '>') { sb.append(each == '<' ? "<" : ">"); } @@ -270,7 +270,11 @@ public class JDOMUtil { return saxBuilder; } + /** + * @deprecated Use load + */ @NotNull + @Deprecated public static Document loadDocument(@NotNull CharSequence seq) throws IOException, JDOMException { return loadDocument(new CharSequenceReader(seq)); } diff --git a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseClasspathTest.java b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseClasspathTest.java index 4e445469d5c6..a16326a7fa35 100644 --- a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseClasspathTest.java +++ b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseClasspathTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -79,7 +79,7 @@ public class EclipseClasspathTest extends IdeaTestCase { if (!SystemInfo.isWindows) { fileText = fileText.replaceAll(EclipseXml.FILE_PROTOCOL + "/", EclipseXml.FILE_PROTOCOL); } - final Element classpathElement = JDOMUtil.loadDocument(fileText).getRootElement(); + final Element classpathElement = JDOMUtil.load(fileText); final Module module = WriteCommandAction.runWriteCommandAction(null, (Computable)() -> { String imlPath = path + "/" + EclipseProjectFinder.findProjectName(path) + ModuleManagerImpl.IML_EXTENSION; @@ -108,7 +108,7 @@ public class EclipseClasspathTest extends IdeaTestCase { fileText1 = fileText1.replaceAll(EclipseXml.FILE_PROTOCOL + "/", EclipseXml.FILE_PROTOCOL); } - Element classpathElement1 = JDOMUtil.loadDocument(fileText1).getRootElement(); + Element classpathElement1 = JDOMUtil.load(fileText1); ModuleRootModel model = ModuleRootManager.getInstance(module); Element resultClasspathElement = new EclipseClasspathWriter().writeClasspath(classpathElement1, model); diff --git a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseEmlTest.java b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseEmlTest.java index a64c3abe7c6f..00fc065724e6 100644 --- a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseEmlTest.java +++ b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseEmlTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,7 +95,7 @@ public class EclipseEmlTest extends IdeaTestCase { final File emlFile = new File(path, module.getName() + EclipseXml.IDEA_SETTINGS_POSTFIX); Assert.assertTrue(resulted.replaceAll(StringUtil.escapeToRegexp(module.getProject().getBaseDir().getPath()), "\\$ROOT\\$"), - JDOMUtil.areElementsEqual(root, JDOMUtil.loadDocument(FileUtil.loadFile(emlFile)).getRootElement())); + JDOMUtil.areElementsEqual(root, JDOMUtil.load(emlFile))); } private static void replaceRoot(String path, final String child, final Project project) throws IOException, JDOMException { diff --git a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImlTest.java b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImlTest.java index 7427e6f32811..b7dd0043223a 100644 --- a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImlTest.java +++ b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImlTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,12 +35,12 @@ import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.impl.ModuleRootManagerImpl; import com.intellij.openapi.util.Computable; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.IdeaTestCase; +import com.intellij.util.JdomKt; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.idea.eclipse.conversion.EclipseClasspathReader; @@ -79,7 +79,7 @@ public class EclipseImlTest extends IdeaTestCase { } String communityLib = FileUtil.toSystemIndependentName(PathManagerEx.findFileUnderCommunityHome("lib").getAbsolutePath()); fileText = fileText.replaceAll("\\$" + JUNIT + "\\$", communityLib); - final Element classpathElement = JDOMUtil.loadDocument(fileText).getRootElement(); + final Element classpathElement = JdomKt.loadElement(fileText); final Module module = WriteCommandAction.runWriteCommandAction(null, (Computable)() -> ModuleManager.getInstance(project) .newModule(new File(path) + File.separator + EclipseProjectFinder .findProjectName(path) + ModuleManagerImpl.IML_EXTENSION, StdModuleTypes.JAVA.getId())); diff --git a/plugins/junit/test/com/intellij/execution/junit/JUnitConfigurationTest.java b/plugins/junit/test/com/intellij/execution/junit/JUnitConfigurationTest.java index 6913d966eac0..6c8acc849552 100644 --- a/plugins/junit/test/com/intellij/execution/junit/JUnitConfigurationTest.java +++ b/plugins/junit/test/com/intellij/execution/junit/JUnitConfigurationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ package com.intellij.execution.junit; import com.intellij.execution.testframework.TestSearchScope; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.testFramework.LightPlatformTestCase; +import com.intellij.util.JdomKt; import org.jdom.Element; public class JUnitConfigurationTest extends LightPlatformTestCase { @@ -27,11 +27,11 @@ public class JUnitConfigurationTest extends LightPlatformTestCase { JUnitConfiguration foo = new JUnitConfiguration("foo", getProject(), JUnitConfigurationType.getInstance().getConfigurationFactories()[0]); Element element = - JDOMUtil.loadDocument("\n" + - " \n" + - " ").getRootElement(); + JdomKt.loadElement("\n" + + " \n" + + " "); foo.readExternal(element); assertEquals(TestSearchScope.MODULE_WITH_DEPENDENCIES, foo.getPersistentData().getScope()); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/fileTemplate/SaveFormAsTemplateHandler.java b/plugins/ui-designer/src/com/intellij/uiDesigner/fileTemplate/SaveFormAsTemplateHandler.java index 75d5fb25466e..7bff07ecbb79 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/fileTemplate/SaveFormAsTemplateHandler.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/fileTemplate/SaveFormAsTemplateHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package com.intellij.uiDesigner.fileTemplate; +import com.intellij.ide.actions.SaveFileAsTemplateHandler; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.util.JDOMUtil; import com.intellij.psi.PsiFile; @@ -22,16 +23,15 @@ import com.intellij.psi.codeStyle.CodeStyleSettingsManager; import com.intellij.uiDesigner.UIFormXmlConstants; import com.intellij.uiDesigner.compiler.Utils; import com.intellij.uiDesigner.lw.LwRootContainer; -import com.intellij.ide.actions.SaveFileAsTemplateHandler; +import com.intellij.util.JdomKt; import org.jdom.Attribute; -import org.jdom.Document; - -import java.io.CharArrayWriter; +import org.jdom.Element; /** * @author yole */ public class SaveFormAsTemplateHandler implements SaveFileAsTemplateHandler { + @Override public String getTemplateText(final PsiFile file, final String fileText, final String nameWithoutExtension) { if (StdFileTypes.GUI_DESIGNER_FORM.equals(file.getFileType())) { LwRootContainer rootContainer = null; @@ -42,15 +42,11 @@ public class SaveFormAsTemplateHandler implements SaveFileAsTemplateHandler { } if (rootContainer != null && rootContainer.getClassToBind() != null) { try { - Document document = JDOMUtil.loadDocument(fileText); + Element document = JdomKt.loadElement(fileText); - Attribute attribute = document.getRootElement().getAttribute(UIFormXmlConstants.ATTRIBUTE_BIND_TO_CLASS); + Attribute attribute = document.getAttribute(UIFormXmlConstants.ATTRIBUTE_BIND_TO_CLASS); attribute.detach(); - - CharArrayWriter writer = new CharArrayWriter(); - JDOMUtil.writeDocument(document, writer, CodeStyleSettingsManager.getSettings(file.getProject()).getLineSeparator()); - - return writer.toString(); + return JDOMUtil.write(document, CodeStyleSettingsManager.getSettings(file.getProject()).getLineSeparator()); } catch (Exception ignored) { } From d8fc73471472ce83bce605fe2d0d06a697693614 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Tue, 14 Feb 2017 18:44:10 +0300 Subject: [PATCH 59/96] IDEA-163334 Memory leak in jdi code - workaround for normal process finish --- .../debugger/jdi/VirtualMachineProxyImpl.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java b/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java index 3830212254e7..f1efc8458f4a 100644 --- a/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -383,14 +383,15 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy { catch (UnsupportedOperationException e) { LOG.info(e); } - - if (Patches.JDK_BUG_EVENT_CONTROLLER_LEAK) { - // Memory leak workaround, see IDEA-163334 - TargetVM target = ReflectionUtil.getField(myVirtualMachine.getClass(), myVirtualMachine, TargetVM.class, "target"); - if (target != null) { - Thread controller = ReflectionUtil.getField(target.getClass(), target, Thread.class, "eventController"); - if (controller != null) { - controller.stop(); + finally { + if (Patches.JDK_BUG_EVENT_CONTROLLER_LEAK) { + // Memory leak workaround, see IDEA-163334 + TargetVM target = ReflectionUtil.getField(myVirtualMachine.getClass(), myVirtualMachine, TargetVM.class, "target"); + if (target != null) { + Thread controller = ReflectionUtil.getField(target.getClass(), target, Thread.class, "eventController"); + if (controller != null) { + controller.stop(); + } } } } From 205599d2c534386a47b93916ce506ad595319888 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 14 Feb 2017 16:48:55 +0100 Subject: [PATCH 60/96] deprecate loadDocument --- .../testFramework/FileEditorManagerTestCase.java | 8 +++----- .../src/com/intellij/testFramework/PlatformTestUtil.java | 2 +- .../intellij/tasks/context/WorkingContextManager.java | 9 +++------ .../tasks-core/src/com/intellij/tasks/impl/TaskUtil.java | 5 +++-- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/FileEditorManagerTestCase.java b/platform/testFramework/src/com/intellij/testFramework/FileEditorManagerTestCase.java index 732cf900ccca..f4f4c726d185 100644 --- a/platform/testFramework/src/com/intellij/testFramework/FileEditorManagerTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/FileEditorManagerTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,14 +23,13 @@ import com.intellij.openapi.fileEditor.ex.FileEditorProviderManager; import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl; import com.intellij.openapi.fileEditor.impl.FileEditorProviderManagerImpl; import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import com.intellij.ui.docking.DockContainer; import com.intellij.ui.docking.DockManager; +import com.intellij.util.JdomKt; import com.intellij.util.ui.UIUtil; -import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; import org.jetbrains.annotations.NotNull; @@ -94,8 +93,7 @@ public abstract class FileEditorManagerTestCase extends LightPlatformCodeInsight } protected void openFiles(@NotNull String femSerialisedText) throws IOException, JDOMException, InterruptedException, ExecutionException { - Document document = JDOMUtil.loadDocument(femSerialisedText); - Element rootElement = document.getRootElement(); + Element rootElement = JdomKt.loadElement(femSerialisedText); ExpandMacroToPathMap map = new ExpandMacroToPathMap(); map.addMacroExpand(PathMacroUtil.PROJECT_DIR_MACRO_NAME, getTestDataPath()); map.substitute(rootElement, true, true); diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java index 78646ed91768..38ac565fe041 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java @@ -847,7 +847,7 @@ public class PlatformTestUtil { public static void assertElementEquals(final String expected, final Element actual) { try { - assertElementsEqual(JDOMUtil.loadDocument(expected).getRootElement(), actual); + assertElementsEqual(JdomKt.loadElement(expected), actual); } catch (IOException | JDOMException e) { throw new AssertionError(e); diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/context/WorkingContextManager.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/context/WorkingContextManager.java index 729f81a774ef..652eb706ce8d 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/context/WorkingContextManager.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/context/WorkingContextManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,17 +25,16 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.tasks.Task; +import com.intellij.util.JdomKt; import com.intellij.util.NullableFunction; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.io.zip.JBZipEntry; import com.intellij.util.io.zip.JBZipFile; -import org.jdom.Document; import org.jdom.Element; import org.jdom.output.XMLOutputter; import org.jetbrains.annotations.NonNls; @@ -183,9 +182,7 @@ public class WorkingContextManager { JBZipEntry entry = archive.getEntry(StringUtil.startsWithChar(entryName, '/') ? entryName : "/" + entryName); if (entry != null) { byte[] bytes = entry.getData(); - Document document = JDOMUtil.loadDocument(new String(bytes)); - Element rootElement = document.getRootElement(); - loadContext(rootElement); + loadContext(JdomKt.loadElement(new String(bytes))); return true; } } diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskUtil.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskUtil.java index 74bc704393ed..e50ca861b170 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskUtil.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.tasks.Task; import com.intellij.tasks.TaskRepository; import com.intellij.tasks.impl.httpclient.TaskResponseUtil; +import com.intellij.util.JdomKt; import com.intellij.util.text.DateFormatUtil; import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.HttpMethod; @@ -205,7 +206,7 @@ public class TaskUtil { public static void prettyFormatXmlToLog(@NotNull Logger logger, @NotNull String xml) { if (logger.isDebugEnabled()) { try { - logger.debug("\n" + JDOMUtil.createOutputter("\n").outputString(JDOMUtil.loadDocument(xml))); + logger.debug("\n" + JDOMUtil.createOutputter("\n").outputString(JdomKt.loadElement(xml))); } catch (Exception e) { logger.debug(e); From d09a2e9e5ed8cf1a0d4a10b1aa882d3f595475f0 Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Tue, 14 Feb 2017 18:58:54 +0300 Subject: [PATCH 61/96] IDEA-168091 NPE at javax.swing.plaf.basic.BasicProgressBarUI.uninstallUI --- platform/util/src/com/intellij/util/ui/UIUtil.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 96ada003559e..02fc2a06b7a4 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -2399,6 +2399,7 @@ public class UIUtil { public void run() { if (isToDispose(progress)) { progress.getUI().uninstallUI(progress); + ReflectionUtil.resetField(progress, "ui"); progress.putClientProperty("isDisposed", Boolean.TRUE); } } From c0bd98bc6ebc6bacfb7f485a60e06312aeeef6d8 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 14 Feb 2017 17:02:06 +0100 Subject: [PATCH 62/96] Cleanup (formatting) --- .../intellij/psi/impl/java/stubs/ClsStubPsiFactory.java | 2 +- .../intellij/psi/impl/java/stubs/SourceStubPsiFactory.java | 7 +++---- .../com/intellij/psi/impl/java/stubs/StubPsiFactory.java | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/ClsStubPsiFactory.java b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/ClsStubPsiFactory.java index 7d2c736428c2..2849838d4ad1 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/ClsStubPsiFactory.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/ClsStubPsiFactory.java @@ -18,7 +18,7 @@ package com.intellij.psi.impl.java.stubs; import com.intellij.psi.*; import com.intellij.psi.impl.compiled.*; -/* +/** * @author max */ public class ClsStubPsiFactory extends StubPsiFactory { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/SourceStubPsiFactory.java b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/SourceStubPsiFactory.java index dc3c480170f6..752087caa7d6 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/SourceStubPsiFactory.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/SourceStubPsiFactory.java @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * @author max - */ package com.intellij.psi.impl.java.stubs; import com.intellij.psi.*; import com.intellij.psi.impl.source.*; import com.intellij.psi.impl.source.tree.java.*; +/** + * @author max + */ public class SourceStubPsiFactory extends StubPsiFactory { public static final SourceStubPsiFactory INSTANCE = new SourceStubPsiFactory(); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/StubPsiFactory.java b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/StubPsiFactory.java index a3349489d50f..92636ddb4cb7 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/StubPsiFactory.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/StubPsiFactory.java @@ -17,7 +17,7 @@ package com.intellij.psi.impl.java.stubs; import com.intellij.psi.*; -/* +/** * @author max */ public abstract class StubPsiFactory { From bb03983d9a5cb3012bff0fbe03ac40ac0180d008 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 14 Feb 2017 16:59:26 +0100 Subject: [PATCH 63/96] make loadDocument(@NotNull Reader reader) private --- .../intellij/jarFinder/SourceSearcher.java | 28 ++++++++++++++----- .../src/com/intellij/util/jdom.kt | 2 ++ .../com/intellij/openapi/util/JDOMUtil.java | 2 +- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/java/java-impl/src/com/intellij/jarFinder/SourceSearcher.java b/java/java-impl/src/com/intellij/jarFinder/SourceSearcher.java index 3533f1a4bb21..4279ec53191f 100644 --- a/java/java-impl/src/com/intellij/jarFinder/SourceSearcher.java +++ b/java/java-impl/src/com/intellij/jarFinder/SourceSearcher.java @@ -1,13 +1,27 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.jarFinder; import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.util.JDOMUtil; -import com.intellij.openapi.util.io.StreamUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.JdomKt; import com.intellij.util.io.HttpRequests; -import org.jdom.Document; +import org.jdom.Element; import org.jdom.JDOMException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -52,14 +66,14 @@ public abstract class SourceSearcher { } @NotNull - protected static Document readDocumentCancelable(final ProgressIndicator indicator, String url) throws IOException { + protected static Element readDocumentCancelable(final ProgressIndicator indicator, String url) throws IOException { return HttpRequests.request(url) .accept("application/xml") - .connect(new HttpRequests.RequestProcessor() { + .connect(new HttpRequests.RequestProcessor() { @Override - public Document process(@NotNull HttpRequests.Request request) throws IOException { + public Element process(@NotNull HttpRequests.Request request) throws IOException { try { - return JDOMUtil.loadDocument(request.getReader(indicator)); + return JdomKt.loadElement(request.getReader(indicator)); } catch (JDOMException e) { throw new IOException(e); diff --git a/platform/projectModel-api/src/com/intellij/util/jdom.kt b/platform/projectModel-api/src/com/intellij/util/jdom.kt index 016502e77c4d..e6dc40efd875 100644 --- a/platform/projectModel-api/src/com/intellij/util/jdom.kt +++ b/platform/projectModel-api/src/com/intellij/util/jdom.kt @@ -69,8 +69,10 @@ fun Parent.write(file: Path, lineSeparator: String = "\n") { @Throws(IOException::class, JDOMException::class) fun loadElement(chars: CharSequence) = loadElement(CharSequenceReader(chars)) +@Throws(IOException::class, JDOMException::class) fun loadElement(reader: Reader): Element = loadDocument(reader).detachRootElement() +@Throws(IOException::class, JDOMException::class) fun loadElement(stream: InputStream): Element = loadDocument(stream.reader()).detachRootElement() @Throws(IOException::class, JDOMException::class) diff --git a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java index b2aa347b9088..18639c249bf7 100644 --- a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java +++ b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java @@ -285,7 +285,7 @@ public class JDOMUtil { } @NotNull - public static Document loadDocument(@NotNull Reader reader) throws IOException, JDOMException { + private static Document loadDocument(@NotNull Reader reader) throws IOException, JDOMException { try { return getSaxBuilder().build(reader); } From 392798f3c91aa726fd85c4180080b71f702e4e99 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 14 Feb 2017 17:12:28 +0100 Subject: [PATCH 64/96] prefer write --- .../ui/header/InspectionToolsConfigurable.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java index 2053e9978e73..3f7dc519af2e 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java @@ -41,7 +41,6 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMUtil; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.profile.codeInspection.BaseInspectionProfileManager; @@ -51,6 +50,7 @@ import com.intellij.profile.codeInspection.ui.ErrorsConfigurable; import com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel; import com.intellij.ui.IdeBorderFactory; import com.intellij.util.Alarm; +import com.intellij.util.JdomKt; import com.intellij.util.SmartList; import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; @@ -62,8 +62,10 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; -import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.*; import java.util.List; import java.util.regex.Matcher; @@ -361,14 +363,14 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable InspectionProfileImpl profile = getSelectedObject(); LOG.assertTrue(true); Element element = profile.writeScheme(false); - File file = new File(FileUtil.toSystemDependentName(dir.getPath()), sanitizeFileName(profile.getName()) + ".xml"); - if (file.isFile() && + Path file = Paths.get(dir.getPath(), sanitizeFileName(profile.getName()) + ".xml"); + if (Files.isRegularFile(file.toAbsolutePath()) && Messages.showOkCancelDialog(wholePanel, "File \'" + file + "\' already exist. Do you want to overwrite it?", "Warning", Messages.getQuestionIcon()) != Messages.OK) { return; } - JDOMUtil.write(element, file, "\n"); + JdomKt.write(element, file); } catch (IOException e1) { LOG.error(e1); From e5b4db935783c79caf2fd33fb73419b05d2b352f Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Wed, 2 Nov 2016 15:12:53 +0300 Subject: [PATCH 65/96] PY-13159 Fixed: "Type checker" failed to determine property type Support abc.abstractproperty while processing class decorated properties --- .../com/jetbrains/python/psi/impl/PyClassImpl.java | 3 ++- python/testSrc/com/jetbrains/python/PyTypeTest.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java b/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java index 92b824775901..4fe2715fd4ed 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java @@ -764,7 +764,8 @@ public class PyClassImpl extends PyBaseElementImpl implements PyCla decoName = knownName; } } - if (PyNames.PROPERTY.equals(decoName)) { + if (PyNames.PROPERTY.equals(decoName) || + qname.equals(PyKnownDecoratorUtil.KnownDecorator.ABC_ABSTRACTPROPERTY.getQualifiedName())) { getter = new Maybe<>(method); } else if (useAdvancedSyntax && qname.matches(decoratorName, PyNames.GETTER)) { diff --git a/python/testSrc/com/jetbrains/python/PyTypeTest.java b/python/testSrc/com/jetbrains/python/PyTypeTest.java index 7574e831071f..1e709aec7799 100644 --- a/python/testSrc/com/jetbrains/python/PyTypeTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypeTest.java @@ -1461,6 +1461,17 @@ public class PyTypeTest extends PyTestCase { "expr = float.fromhex(\"0.5\")"); } + // PY-13159 + public void testAbsAbstractProperty() { + doTest("str", + "import abc\n" + + "class D:\n" + + " @abc.abstractproperty\n" + + " def foo(self):\n" + + " return 'foo'\n" + + "expr = D().foo"); + } + // PY-20409 public void testGetFromDictWithDefaultNoneValue() { doTest("Any", From 6d223ec43cf27d708ba262a4e5c8198af24aaa2a Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Wed, 2 Nov 2016 15:20:25 +0300 Subject: [PATCH 66/96] Highlight abc.abcstractproperty decorator as deprecated in Pythons >= 3.3 --- .../inspections/PyDeprecationInspection.java | 35 ++++++++++++++++--- .../deprecation/abcAbstractProperty.py | 7 ++++ .../jetbrains/python/PyDeprecationTest.java | 14 +++++++- 3 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 python/testData/deprecation/abcAbstractProperty.py diff --git a/python/src/com/jetbrains/python/inspections/PyDeprecationInspection.java b/python/src/com/jetbrains/python/inspections/PyDeprecationInspection.java index 1c28413a740c..c03861b0331e 100644 --- a/python/src/com/jetbrains/python/inspections/PyDeprecationInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyDeprecationInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,13 +21,16 @@ import com.intellij.codeInspection.ProblemsHolder; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; -import com.intellij.psi.PsiPolyVariantReference; import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.psi.util.QualifiedName; import com.jetbrains.python.psi.*; +import com.jetbrains.python.psi.PyKnownDecoratorUtil.KnownDecorator; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Arrays; + /** * @author yole */ @@ -59,9 +62,7 @@ public class PyDeprecationInspection extends PyInspection { final PyExpression exceptClass = exceptPart.getExceptClass(); if (exceptClass != null && "ImportError".equals(exceptClass.getText())) return; } - final PsiPolyVariantReference reference = node.getReference(getResolveContext()); - if (reference == null) return; - final PsiElement resolveResult = reference.resolve(); + final PsiElement resolveResult = node.getReference(getResolveContext()).resolve(); final PyFromImportStatement importStatement = PsiTreeUtil.getParentOfType(node, PyFromImportStatement.class); if (importStatement != null) { final PsiElement element = importStatement.resolveImportSource(); @@ -79,5 +80,29 @@ public class PyDeprecationInspection extends PyInspection { registerProblem(nameElement == null ? node : nameElement.getPsi(), deprecationMessage, ProblemHighlightType.LIKE_DEPRECATED); } } + + @Override + public void visitPyFunction(PyFunction node) { + super.visitPyFunction(node); + + final PyDecoratorList decoratorList = node.getDecoratorList(); + if (LanguageLevel.forElement(node).isAtLeast(LanguageLevel.PYTHON33) && decoratorList != null) { + Arrays + .stream(decoratorList.getDecorators()) + .filter(decorator -> KnownDecorator.ABC_ABSTRACTPROPERTY.getQualifiedName().equals(decorator.getQualifiedName())) + .forEach( + decorator -> { + final QualifiedName abcAbsPropertyQName = KnownDecorator.ABC_ABSTRACTPROPERTY.getQualifiedName(); + final QualifiedName propertyQName = KnownDecorator.PROPERTY.getQualifiedName(); + final QualifiedName abcAbsMethodQName = KnownDecorator.ABC_ABSTRACTMETHOD.getQualifiedName(); + + final String message = "'" + abcAbsPropertyQName + "' is deprecated since Python 3.3. " + + "Use '" + propertyQName + "' with '" + abcAbsMethodQName + "' instead."; + + registerProblem(decorator, message, ProblemHighlightType.LIKE_DEPRECATED); + } + ); + } + } } } diff --git a/python/testData/deprecation/abcAbstractProperty.py b/python/testData/deprecation/abcAbstractProperty.py new file mode 100644 index 000000000000..341c23e24f96 --- /dev/null +++ b/python/testData/deprecation/abcAbstractProperty.py @@ -0,0 +1,7 @@ +import abc + + +class A(metaclass=abc.ABCMeta): + @abc.abstractproperty + def prop(self): + pass \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyDeprecationTest.java b/python/testSrc/com/jetbrains/python/PyDeprecationTest.java index 595a8bd9f462..7f88073d0cc0 100644 --- a/python/testSrc/com/jetbrains/python/PyDeprecationTest.java +++ b/python/testSrc/com/jetbrains/python/PyDeprecationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package com.jetbrains.python; import com.intellij.testFramework.PlatformTestUtil; import com.jetbrains.python.fixtures.PyTestCase; import com.jetbrains.python.inspections.PyDeprecationInspection; +import com.jetbrains.python.psi.LanguageLevel; import com.jetbrains.python.psi.PyFile; import com.jetbrains.python.psi.PyFunction; @@ -77,6 +78,17 @@ public class PyDeprecationTest extends PyTestCase { myFixture.checkHighlighting(true, false, false); } + public void testAbsAbstractProperty() { + runWithLanguageLevel( + LanguageLevel.PYTHON33, + () -> { + myFixture.enableInspections(PyDeprecationInspection.class); + myFixture.configureByFile("deprecation/abcAbstractProperty.py"); + myFixture.checkHighlighting(true, false, false); + } + ); + } + public void testFileStub() { myFixture.configureByFile("deprecation/deprecatedModule.py"); PyFile file = (PyFile)myFixture.getFile(); From c55d28bc8bdca46ab003e71baea95d86931b8878 Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Wed, 2 Nov 2016 15:31:06 +0300 Subject: [PATCH 67/96] PY-20322 Fixed: False positive warnings about abstract property Use PyKnownDecoratorUtil to check if the specified decorator is one of the known decorators --- .../inspections/PyDeprecationInspection.java | 2 +- .../python/psi/PyKnownDecoratorUtil.java | 54 +++++++++++-------- .../python/psi/impl/PyClassImpl.java | 4 +- python/testData/MockSdk2.7/Lib/abc.py | 4 ++ .../deprecation/abcAbstractProperty.py | 27 ++++++++++ .../abcAbstractProperty.py | 15 ++++++ .../PyPropertyDefinitionInspection26/test.py | 5 +- .../PyPropertyDefinitionInspection33/test.py | 7 ++- .../com/jetbrains/python/PyTypeTest.java | 21 ++++++++ .../PyPropertyAccessInspectionTest.java | 5 ++ 10 files changed, 116 insertions(+), 28 deletions(-) create mode 100644 python/testData/inspections/PyPropertyAccessInspection/abcAbstractProperty.py diff --git a/python/src/com/jetbrains/python/inspections/PyDeprecationInspection.java b/python/src/com/jetbrains/python/inspections/PyDeprecationInspection.java index c03861b0331e..b755f3114455 100644 --- a/python/src/com/jetbrains/python/inspections/PyDeprecationInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyDeprecationInspection.java @@ -89,7 +89,7 @@ public class PyDeprecationInspection extends PyInspection { if (LanguageLevel.forElement(node).isAtLeast(LanguageLevel.PYTHON33) && decoratorList != null) { Arrays .stream(decoratorList.getDecorators()) - .filter(decorator -> KnownDecorator.ABC_ABSTRACTPROPERTY.getQualifiedName().equals(decorator.getQualifiedName())) + .filter(decorator -> PyKnownDecoratorUtil.asKnownDecorator(decorator, myTypeEvalContext) == KnownDecorator.ABC_ABSTRACTPROPERTY) .forEach( decorator -> { final QualifiedName abcAbsPropertyQName = KnownDecorator.ABC_ABSTRACTPROPERTY.getQualifiedName(); diff --git a/python/src/com/jetbrains/python/psi/PyKnownDecoratorUtil.java b/python/src/com/jetbrains/python/psi/PyKnownDecoratorUtil.java index 583c41c53777..5dcfc3381df2 100644 --- a/python/src/com/jetbrains/python/psi/PyKnownDecoratorUtil.java +++ b/python/src/com/jetbrains/python/psi/PyKnownDecoratorUtil.java @@ -22,6 +22,7 @@ import com.intellij.psi.util.QualifiedName; import com.intellij.util.containers.Convertor; import com.jetbrains.python.PyNames; import com.jetbrains.python.psi.types.TypeEvalContext; +import one.util.streamex.StreamEx; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -123,34 +124,41 @@ public class PyKnownDecoratorUtil { if (decoratorList == null) { return Collections.emptyList(); } - final List result = new ArrayList<>(); - final boolean allowResolve = context.maySwitchToAST((PsiElement)element); - for (PyDecorator decorator : decoratorList.getDecorators()) { - final QualifiedName qualifiedName = decorator.getQualifiedName(); - if (qualifiedName == null) { - continue; + + return StreamEx + .of(decoratorList.getDecorators()) + .map(decorator -> asKnownDecorator(decorator, context)) + .nonNull() + .toList(); + } + + @Nullable + public static KnownDecorator asKnownDecorator(@NotNull PyDecorator decorator, @NotNull TypeEvalContext context) { + final QualifiedName qualifiedName = decorator.getQualifiedName(); + if (qualifiedName == null) { + return null; + } + + if (context.maySwitchToAST(decorator)) { + PyQualifiedNameOwner resolved = as(resolveDecorator(decorator), PyQualifiedNameOwner.class); + if (resolved instanceof PyFunction && PyNames.INIT.equals(resolved.getName())) { + resolved = ((PyFunction)resolved).getContainingClass(); } - final KnownDecorator knownDecorator = ourByShortName.get(qualifiedName.getLastComponent()); - if (knownDecorator != null) { - if (allowResolve) { - PyQualifiedNameOwner resolved = as(resolveDecorator(decorator), PyQualifiedNameOwner.class); - if (resolved instanceof PyFunction && PyNames.INIT.equals(resolved.getName())) { - resolved = ((PyFunction)resolved).getContainingClass(); - } - if (resolved != null && resolved.getQualifiedName() != null) { - final QualifiedName resolvedName = QualifiedName.fromDottedString(resolved.getQualifiedName()); - if (resolvedName.equals(knownDecorator.getQualifiedName())) { - result.add(knownDecorator); - } - } - } - else { - result.add(knownDecorator); + if (resolved != null && resolved.getQualifiedName() != null) { + final QualifiedName resolvedName = QualifiedName.fromDottedString(resolved.getQualifiedName()); + final KnownDecorator knownDecorator = ourByShortName.get(resolvedName.getLastComponent()); + + if (knownDecorator != null && resolvedName.equals(knownDecorator.getQualifiedName())) { + return knownDecorator; } } } - return result; + else { + return ourByShortName.get(qualifiedName.getLastComponent()); + } + + return null; } @Nullable diff --git a/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java b/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java index 4fe2715fd4ed..65b454ac57b5 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java @@ -765,7 +765,9 @@ public class PyClassImpl extends PyBaseElementImpl implements PyCla } } if (PyNames.PROPERTY.equals(decoName) || - qname.equals(PyKnownDecoratorUtil.KnownDecorator.ABC_ABSTRACTPROPERTY.getQualifiedName())) { + ArrayUtil.contains(PyKnownDecoratorUtil.asKnownDecorator(deco, TypeEvalContext.codeInsightFallback(getProject())), + PyKnownDecoratorUtil.KnownDecorator.ABC_ABSTRACTPROPERTY, + PyKnownDecoratorUtil.KnownDecorator.PROPERTY)) { getter = new Maybe<>(method); } else if (useAdvancedSyntax && qname.matches(decoratorName, PyNames.GETTER)) { diff --git a/python/testData/MockSdk2.7/Lib/abc.py b/python/testData/MockSdk2.7/Lib/abc.py index ef4f2f69e838..ec9311814a02 100644 --- a/python/testData/MockSdk2.7/Lib/abc.py +++ b/python/testData/MockSdk2.7/Lib/abc.py @@ -5,4 +5,8 @@ class ABCMeta: def abstractmethod(foo): + pass + + +def abstractproperty(foo): pass \ No newline at end of file diff --git a/python/testData/deprecation/abcAbstractProperty.py b/python/testData/deprecation/abcAbstractProperty.py index 341c23e24f96..f6511c793149 100644 --- a/python/testData/deprecation/abcAbstractProperty.py +++ b/python/testData/deprecation/abcAbstractProperty.py @@ -3,5 +3,32 @@ import abc class A(metaclass=abc.ABCMeta): @abc.abstractproperty + def prop(self): + pass + + +from abc import abstractproperty + + +class B(metaclass=abc.ABCMeta): + @abstractproperty + def prop(self): + pass + + +from abc import abstractproperty as ap + + +class C(metaclass=abc.ABCMeta): + @ap + def prop(self): + pass + + +import abc as foo + + +class D(metaclass=abc.ABCMeta): + @foo.abstractproperty def prop(self): pass \ No newline at end of file diff --git a/python/testData/inspections/PyPropertyAccessInspection/abcAbstractProperty.py b/python/testData/inspections/PyPropertyAccessInspection/abcAbstractProperty.py new file mode 100644 index 000000000000..a22163306c00 --- /dev/null +++ b/python/testData/inspections/PyPropertyAccessInspection/abcAbstractProperty.py @@ -0,0 +1,15 @@ +from abc import ABCMeta, abstractproperty + +class Upper(object): + __metaclass__ = ABCMeta + + @abstractproperty + def prop(self): + pass + + @prop.setter + def prop(self, prop): + pass + + def foo(self): + print self.prop \ No newline at end of file diff --git a/python/testData/inspections/PyPropertyDefinitionInspection26/test.py b/python/testData/inspections/PyPropertyDefinitionInspection26/test.py index 6dd8927c9788..0d7736ab126d 100644 --- a/python/testData/inspections/PyPropertyDefinitionInspection26/test.py +++ b/python/testData/inspections/PyPropertyDefinitionInspection26/test.py @@ -1,3 +1,6 @@ +import abc + + class A(object): def __init__(self): self._x = 1 @@ -65,7 +68,7 @@ class A(object): foo2 = property(get_foo2) @property - @abstractproperty + @abc.abstractproperty def abstract_property(self): pass diff --git a/python/testData/inspections/PyPropertyDefinitionInspection33/test.py b/python/testData/inspections/PyPropertyDefinitionInspection33/test.py index c34fd36671f4..aaf904a94de4 100644 --- a/python/testData/inspections/PyPropertyDefinitionInspection33/test.py +++ b/python/testData/inspections/PyPropertyDefinitionInspection33/test.py @@ -1,14 +1,17 @@ +import abc + + class A: @property def normal_property(self): pass @property - @abstractproperty + @abc.abstractproperty def abstract_property1(self): pass @property - @abstractmethod + @abc.abstractmethod def abstract_property2(self): pass diff --git a/python/testSrc/com/jetbrains/python/PyTypeTest.java b/python/testSrc/com/jetbrains/python/PyTypeTest.java index 1e709aec7799..2f51068c9194 100644 --- a/python/testSrc/com/jetbrains/python/PyTypeTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypeTest.java @@ -1472,6 +1472,27 @@ public class PyTypeTest extends PyTestCase { "expr = D().foo"); } + public void testAbsAbstractPropertyWithFrom() { + doTest("str", + "from abc import abstractproperty\n" + + "class D:\n" + + " @abstractproperty\n" + + " def foo(self):\n" + + " return 'foo'\n" + + "expr = D().foo"); + } + + // TODO: enable this test when properties will be calculated with TypeEvalContext + public void ignoredTestAbsAbstractPropertyWithAs() { + doTest("str", + "from abc import abstractproperty as ap\n" + + "class D:\n" + + " @ap\n" + + " def foo(self):\n" + + " return 'foo'\n" + + "expr = D().foo"); + } + // PY-20409 public void testGetFromDictWithDefaultNoneValue() { doTest("Any", diff --git a/python/testSrc/com/jetbrains/python/inspections/PyPropertyAccessInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyPropertyAccessInspectionTest.java index 67848c045703..ac0a77e5aeb7 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyPropertyAccessInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyPropertyAccessInspectionTest.java @@ -31,6 +31,11 @@ public class PyPropertyAccessInspectionTest extends PyTestCase { doTest(); } + // PY-20322 + public void testAbcAbstractProperty() { + doTest(); + } + private void doTest() { setLanguageLevel(LanguageLevel.PYTHON26); myFixture.configureByFile("inspections/PyPropertyAccessInspection/" + getTestName(true) + ".py"); From ebc316287b274436b8c7cf4a289fcf1ddf87dc1c Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Tue, 14 Feb 2017 19:14:34 +0300 Subject: [PATCH 68/96] Support more property decorators from third-party libraries --- .../python/psi/PyKnownDecoratorUtil.java | 18 ++++++++++++++++-- .../jetbrains/python/psi/impl/PyClassImpl.java | 4 +--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/python/src/com/jetbrains/python/psi/PyKnownDecoratorUtil.java b/python/src/com/jetbrains/python/psi/PyKnownDecoratorUtil.java index 5dcfc3381df2..92039a77ec2b 100644 --- a/python/src/com/jetbrains/python/psi/PyKnownDecoratorUtil.java +++ b/python/src/com/jetbrains/python/psi/PyKnownDecoratorUtil.java @@ -76,7 +76,11 @@ public class PyKnownDecoratorUtil { TYPING_OVERLOAD("typing.overload"), - REPRLIB_RECURSIVE_REPR("reprlib.recursive_repr"); + REPRLIB_RECURSIVE_REPR("reprlib.recursive_repr"), + + PYRAMID_DECORATOR_REIFY("pyramid.decorator.reify"), + DJANGO_UTILS_FUNCTIONAL_CACHED_PROPERTY("django.utils.functional.cached_property"), + KOMBU_UTILS_CACHED_PROPERTY("kombu.utils.cached_property"); private final QualifiedName myQualifiedName; @@ -102,6 +106,12 @@ public class PyKnownDecoratorUtil { ABC_ABSTRACTSTATICMETHOD, ABC_ABSTRACTCLASSMETHOD); + private static final Set PROPERTY_DECORATORS = EnumSet.of(PROPERTY, + ABC_ABSTRACTPROPERTY, + PYRAMID_DECORATOR_REIFY, + DJANGO_UTILS_FUNCTIONAL_CACHED_PROPERTY, + KOMBU_UTILS_CACHED_PROPERTY); + private static final Map ourByShortName = newMapFromValues(Iterators.forArray(values()), new Convertor() { @Override @@ -111,7 +121,7 @@ public class PyKnownDecoratorUtil { }); /** - * Map decorators of element to {@link com.jetbrains.python.psi.PyKnownDecoratorUtil.KnownDecorator}. + * Map decorators of element to {@link PyKnownDecoratorUtil.KnownDecorator}. * * @param element decoratable element to check * @param context type evaluation context. If it doesn't allow switch to AST, decorators will be compared by the text of the last component @@ -220,6 +230,10 @@ public class PyKnownDecoratorUtil { return !knownDecorators.isEmpty(); } + public static boolean isPropertyDecorator(@NotNull PyDecorator decorator, @NotNull TypeEvalContext context) { + return PROPERTY_DECORATORS.contains(asKnownDecorator(decorator, context)); + } + private static boolean allDecoratorsAreKnown(@NotNull PyDecoratable element, @NotNull List decorators) { final PyDecoratorList decoratorList = element.getDecoratorList(); return decoratorList == null ? decorators.isEmpty() : decoratorList.getDecorators().length == decorators.size(); diff --git a/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java b/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java index 65b454ac57b5..1a93811238bd 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java @@ -765,9 +765,7 @@ public class PyClassImpl extends PyBaseElementImpl implements PyCla } } if (PyNames.PROPERTY.equals(decoName) || - ArrayUtil.contains(PyKnownDecoratorUtil.asKnownDecorator(deco, TypeEvalContext.codeInsightFallback(getProject())), - PyKnownDecoratorUtil.KnownDecorator.ABC_ABSTRACTPROPERTY, - PyKnownDecoratorUtil.KnownDecorator.PROPERTY)) { + PyKnownDecoratorUtil.isPropertyDecorator(deco, TypeEvalContext.codeInsightFallback(getProject()))) { getter = new Maybe<>(method); } else if (useAdvancedSyntax && qname.matches(decoratorName, PyNames.GETTER)) { From 2fa8ef7f332f2da8efc845f31ec76d092a1b01d9 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Tue, 14 Feb 2017 19:05:04 +0300 Subject: [PATCH 69/96] @NotNull --- .../groovy/extensions/GroovyNamedArgumentProvider.java | 4 ++-- .../groovy/lang/GroovyConstructorNamedArgumentProvider.java | 4 ++-- .../groovy/lang/GroovyMethodReturnNamedArgumentProvider.java | 4 ++-- .../groovy/lang/GroovySourceCodeNamedArgumentProvider.java | 4 ++-- .../swingBuilder/SwingBuilderNamedArgumentProvider.java | 4 ++-- .../plugins/groovy/lang/GroovyMapAttributeTest.groovy | 3 ++- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyNamedArgumentProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyNamedArgumentProvider.java index 74ffc3018459..5de93a543bc7 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyNamedArgumentProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyNamedArgumentProvider.java @@ -45,7 +45,7 @@ public abstract class GroovyNamedArgumentProvider { @Nullable PsiElement resolve, @Nullable String argumentName, boolean forCompletion, - Map result) { + @NotNull Map result) { // no op } @@ -54,7 +54,7 @@ public abstract class GroovyNamedArgumentProvider { @Nullable GroovyResolveResult resolveResult, @Nullable String argumentName, boolean forCompletion, - Map result) { + @NotNull Map result) { getNamedArguments(call, resolve, argumentName, forCompletion, result); } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyConstructorNamedArgumentProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyConstructorNamedArgumentProvider.java index b9274369878c..63ff008a57c0 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyConstructorNamedArgumentProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyConstructorNamedArgumentProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ public class GroovyConstructorNamedArgumentProvider extends GroovyNamedArgumentP @Nullable PsiElement resolve, @Nullable String argumentName, boolean forCompletion, - Map result) { + @NotNull Map result) { if (!(call instanceof GrNewExpression)) return; if (resolve != null) { diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyMethodReturnNamedArgumentProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyMethodReturnNamedArgumentProvider.java index a0303f512ba2..4ac81a535306 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyMethodReturnNamedArgumentProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyMethodReturnNamedArgumentProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ public class GroovyMethodReturnNamedArgumentProvider extends GroovyNamedArgument @Nullable PsiElement resolve, @Nullable String argumentName, boolean forCompletion, - Map result) { + @NotNull Map result) { if (!forCompletion || !(resolve instanceof PsiMethod)) return; PsiType returnType = ((PsiMethod)resolve).getReturnType(); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovySourceCodeNamedArgumentProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovySourceCodeNamedArgumentProvider.java index 9bf95b799931..acd27ea278b2 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovySourceCodeNamedArgumentProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovySourceCodeNamedArgumentProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ public class GroovySourceCodeNamedArgumentProvider extends GroovyNamedArgumentPr @Nullable PsiElement resolve, @Nullable String argumentName, boolean forCompletion, - Map result) { + @NotNull Map result) { if (resolve instanceof GrMethod) { result.putAll(((GrMethod)resolve).getNamedParameters()); } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNamedArgumentProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNamedArgumentProvider.java index ab4117abd2e6..a6a402d99f31 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNamedArgumentProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNamedArgumentProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ public class SwingBuilderNamedArgumentProvider extends GroovyNamedArgumentProvid @Nullable PsiElement resolve, @Nullable String argumentName, boolean forCompletion, - Map result) { + @NotNull Map result) { PsiType returnType = resolve == null ? null : ((PsiMethod)resolve).getReturnType(); PsiClass aClass = PsiTypesUtil.getPsiClass(returnType); if (aClass == null) return; diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyMapAttributeTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyMapAttributeTest.groovy index 4af6105d6621..ad758ebdaf08 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyMapAttributeTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyMapAttributeTest.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -469,6 +469,7 @@ class Test { private doTestCompletionWithinMap(String text, String text2 = null) { PlatformTestUtil.registerExtension GroovyNamedArgumentProvider.EP_NAME, new GroovyNamedArgumentProvider() { + @NotNull @Override Map getNamedArguments(@NotNull GrListOrMap literal) { ['foo': NamedArgumentDescriptor.SIMPLE_NORMAL, 'bar': NamedArgumentDescriptor.SIMPLE_NORMAL] From 23b7c6406383ba11480f49c19ebacd8f4c0326de Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Tue, 14 Feb 2017 19:25:41 +0300 Subject: [PATCH 70/96] [groovy] update named argument provider API --- .../GroovyNamedArgumentProvider.java | 20 ++++++++++++++++--- ...roovyConstructorNamedArgumentProvider.java | 7 ++++--- ...oovyMethodReturnNamedArgumentProvider.java | 4 +++- ...GroovySourceCodeNamedArgumentProvider.java | 4 +++- .../SwingBuilderNamedArgumentProvider.java | 4 +++- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyNamedArgumentProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyNamedArgumentProvider.java index 5de93a543bc7..396f0e1ca13c 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyNamedArgumentProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyNamedArgumentProvider.java @@ -41,6 +41,8 @@ public abstract class GroovyNamedArgumentProvider { public static final ExtensionPointName EP_NAME = ExtensionPointName.create("org.intellij.groovy.namedArgumentProvider"); + @SuppressWarnings("unused") + @Deprecated public void getNamedArguments(@NotNull GrCall call, @Nullable PsiElement resolve, @Nullable String argumentName, @@ -49,15 +51,27 @@ public abstract class GroovyNamedArgumentProvider { // no op } + @SuppressWarnings("unused") + @Deprecated public void getNamedArguments(@NotNull GrCall call, @Nullable PsiElement resolve, @Nullable GroovyResolveResult resolveResult, @Nullable String argumentName, boolean forCompletion, @NotNull Map result) { + //noinspection deprecation getNamedArguments(call, resolve, argumentName, forCompletion, result); } + public void getNamedArguments(@NotNull GrCall call, + @NotNull GroovyResolveResult resolveResult, + @Nullable String argumentName, + boolean forCompletion, + @NotNull Map result) { + //noinspection deprecation + getNamedArguments(call, resolveResult.getElement(), resolveResult, argumentName, forCompletion, result); + } + @NotNull public Map getNamedArguments(@NotNull GrListOrMap literal) { return Collections.emptyMap(); @@ -84,7 +98,7 @@ public abstract class GroovyNamedArgumentProvider { if (callVariants.length == 0 || PsiUtil.isSingleBindingVariant(callVariants)) { for (GroovyNamedArgumentProvider namedArgumentProvider : EP_NAME.getExtensions()) { - namedArgumentProvider.getNamedArguments(call, null, null, argumentName, forCompletion, namedArguments); + namedArgumentProvider.getNamedArguments(call, GroovyResolveResult.EMPTY_RESULT, argumentName, forCompletion, namedArguments); } } else { @@ -105,7 +119,7 @@ public abstract class GroovyNamedArgumentProvider { if (methodInfo.getNamedArguments() != null || methodInfo.isNamedArgumentProviderDefined()) { if (methodInfo.isApplicable(method)) { if (methodInfo.isNamedArgumentProviderDefined()) { - methodInfo.getNamedArgProvider().getNamedArguments(call, element, result, argumentName, forCompletion, namedArguments); + methodInfo.getNamedArgProvider().getNamedArguments(call, result, argumentName, forCompletion, namedArguments); } if (methodInfo.getNamedArguments() != null) { namedArguments.putAll(methodInfo.getNamedArguments()); @@ -116,7 +130,7 @@ public abstract class GroovyNamedArgumentProvider { } for (GroovyNamedArgumentProvider namedArgumentProvider : EP_NAME.getExtensions()) { - namedArgumentProvider.getNamedArguments(call, element, result, argumentName, forCompletion, namedArguments); + namedArgumentProvider.getNamedArguments(call, result, argumentName, forCompletion, namedArguments); } if (element instanceof GrVariable && diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyConstructorNamedArgumentProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyConstructorNamedArgumentProvider.java index 63ff008a57c0..e970aafba57e 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyConstructorNamedArgumentProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyConstructorNamedArgumentProvider.java @@ -53,11 +53,12 @@ public class GroovyConstructorNamedArgumentProvider extends GroovyNamedArgumentP @Override public void getNamedArguments(@NotNull GrCall call, - @Nullable PsiElement resolve, + @NotNull GroovyResolveResult resolveResult, @Nullable String argumentName, boolean forCompletion, @NotNull Map result) { if (!(call instanceof GrNewExpression)) return; + PsiElement resolve = resolveResult.getElement(); if (resolve != null) { if (!(resolve instanceof PsiMethod)) return; @@ -75,8 +76,8 @@ public class GroovyConstructorNamedArgumentProvider extends GroovyNamedArgumentP return; } - for (GroovyResolveResult resolveResult : newCall.multiResolveClass()) { - PsiElement element = resolveResult.getElement(); + for (GroovyResolveResult newResult : newCall.multiResolveClass()) { + PsiElement element = newResult.getElement(); if (!(element instanceof PsiClass)) continue; PsiClass aClass = (PsiClass)element; diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyMethodReturnNamedArgumentProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyMethodReturnNamedArgumentProvider.java index 4ac81a535306..939b38f55ae8 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyMethodReturnNamedArgumentProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyMethodReturnNamedArgumentProvider.java @@ -23,6 +23,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.extensions.GroovyNamedArgumentProvider; import org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor; +import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCall; import java.util.HashMap; @@ -34,10 +35,11 @@ import java.util.Map; public class GroovyMethodReturnNamedArgumentProvider extends GroovyNamedArgumentProvider { @Override public void getNamedArguments(@NotNull GrCall call, - @Nullable PsiElement resolve, + @NotNull GroovyResolveResult resolveResult, @Nullable String argumentName, boolean forCompletion, @NotNull Map result) { + PsiElement resolve = resolveResult.getElement(); if (!forCompletion || !(resolve instanceof PsiMethod)) return; PsiType returnType = ((PsiMethod)resolve).getReturnType(); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovySourceCodeNamedArgumentProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovySourceCodeNamedArgumentProvider.java index acd27ea278b2..24e01bf0d62a 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovySourceCodeNamedArgumentProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovySourceCodeNamedArgumentProvider.java @@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.extensions.GroovyNamedArgumentProvider; import org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor; +import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrNamedArgumentSearchVisitor; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable; @@ -34,10 +35,11 @@ import java.util.Map; public class GroovySourceCodeNamedArgumentProvider extends GroovyNamedArgumentProvider { @Override public void getNamedArguments(@NotNull GrCall call, - @Nullable PsiElement resolve, + @NotNull GroovyResolveResult resolveResult, @Nullable String argumentName, boolean forCompletion, @NotNull Map result) { + PsiElement resolve = resolveResult.getElement(); if (resolve instanceof GrMethod) { result.putAll(((GrMethod)resolve).getNamedParameters()); } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNamedArgumentProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNamedArgumentProvider.java index a6a402d99f31..9c7d023251fd 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNamedArgumentProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNamedArgumentProvider.java @@ -24,6 +24,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.extensions.GroovyNamedArgumentProvider; import org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor; import org.jetbrains.plugins.groovy.extensions.impl.TypeCondition; +import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCall; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames; @@ -39,10 +40,11 @@ public class SwingBuilderNamedArgumentProvider extends GroovyNamedArgumentProvid @Override public void getNamedArguments(@NotNull GrCall call, - @Nullable PsiElement resolve, + @NotNull GroovyResolveResult resolveResult, @Nullable String argumentName, boolean forCompletion, @NotNull Map result) { + PsiElement resolve = resolveResult.getElement(); PsiType returnType = resolve == null ? null : ((PsiMethod)resolve).getReturnType(); PsiClass aClass = PsiTypesUtil.getPsiClass(returnType); if (aClass == null) return; From 78f173cfb7dc5e7e25ca342be78792b7f17378fc Mon Sep 17 00:00:00 2001 From: Vladislav Rassokhin Date: Tue, 14 Feb 2017 20:10:08 +0300 Subject: [PATCH 71/96] IDEA-CR-18229 Improve MagicConstantInspection in case of two constants sources: * Reverted origin test, add new test case * Throw exception if both 'flags' and 'values' used. * Fix tests: `PsiAnnotation#findAttributeValue` may return default values, ignore them --- .../MagicConstantInspection.java | 28 +++++-- .../magic/manyConstantSources/expected.xml | 79 ++++++++++++++++++ .../magic/manyConstantSources/src/X.java | 82 +++++++++++++++++++ .../inspection/magic/simple/expected.xml | 68 +++++++-------- .../inspection/magic/simple/src/X.java | 21 ++--- .../MagicConstantInspectionTest.java | 2 + 6 files changed, 225 insertions(+), 55 deletions(-) create mode 100644 java/java-tests/testData/inspection/magic/manyConstantSources/expected.xml create mode 100644 java/java-tests/testData/inspection/magic/manyConstantSources/src/X.java diff --git a/java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicConstantInspection.java b/java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicConstantInspection.java index 15c64e2d345f..0a666ff45051 100644 --- a/java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicConstantInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicConstantInspection.java @@ -46,6 +46,7 @@ import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.*; import com.intellij.slicer.*; import com.intellij.util.ArrayUtil; +import com.intellij.util.IncorrectOperationException; import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.indexing.FileBasedIndex; @@ -331,29 +332,37 @@ public class MagicConstantInspection extends BaseJavaLocalInspectionTool { if (TypeConversionUtil.getTypeRank(type) <= TypeConversionUtil.LONG_RANK) { PsiAnnotationMemberValue intValues = magic.findAttributeValue("intValues"); if (intValues instanceof PsiArrayInitializerMemberValue) { - allowedValues = ((PsiArrayInitializerMemberValue)intValues).getInitializers(); - values = true; + final PsiAnnotationMemberValue[] initializers = ((PsiArrayInitializerMemberValue)intValues).getInitializers(); + if (initializers.length != 0) { + allowedValues = initializers; + values = true; + } } - else { + if (!values) { PsiAnnotationMemberValue orValue = magic.findAttributeValue("flags"); if (orValue instanceof PsiArrayInitializerMemberValue) { - allowedValues = ((PsiArrayInitializerMemberValue)orValue).getInitializers(); - flags = true; + final PsiAnnotationMemberValue[] initializers = ((PsiArrayInitializerMemberValue)orValue).getInitializers(); + if (initializers.length != 0) { + allowedValues = initializers; + flags = true; + } } } } else if (type.equals(PsiType.getJavaLangString(manager, GlobalSearchScope.allScope(manager.getProject())))) { PsiAnnotationMemberValue strValuesAttr = magic.findAttributeValue("stringValues"); if (strValuesAttr instanceof PsiArrayInitializerMemberValue) { - allowedValues = ((PsiArrayInitializerMemberValue)strValuesAttr).getInitializers(); - values = true; + final PsiAnnotationMemberValue[] initializers = ((PsiArrayInitializerMemberValue)strValuesAttr).getInitializers(); + if (initializers.length != 0) { + allowedValues = initializers; + values = true; + } } } else { return null; //other types not supported } - // Also there're could be valuesFromClass of flagsFromClass PsiAnnotationMemberValue[] valuesFromClass = readFromClass("valuesFromClass", magic, type, manager); if (valuesFromClass != null) { allowedValues = ArrayUtil.mergeArrays(allowedValues, valuesFromClass, PsiAnnotationMemberValue.ARRAY_FACTORY); @@ -368,7 +377,8 @@ public class MagicConstantInspection extends BaseJavaLocalInspectionTool { return null; } if (values && flags) { - // Combination of 'flags' and 'values', that's weird TODO: Log? + throw new IncorrectOperationException( + "Misconfiguration of @MagicConstant annotation: 'flags' and 'values' shouldn't be used at the same time"); } return new AllowedValues(allowedValues, flags); } diff --git a/java/java-tests/testData/inspection/magic/manyConstantSources/expected.xml b/java/java-tests/testData/inspection/magic/manyConstantSources/expected.xml new file mode 100644 index 000000000000..acae8fed90c2 --- /dev/null +++ b/java/java-tests/testData/inspection/magic/manyConstantSources/expected.xml @@ -0,0 +1,79 @@ + + + + X.java + 31 + magic constant + Should be one of: Const1.X, Const2.I + + + X.java + 32 + magic constant + Should be one of: Const1.X, Const2.I + + + X.java + 33 + magic constant + Should be one of: Const1.X, Const2.I + + + + X.java + 44 + magic constant + Should be one of: Const2.I, Const1.X + + + X.java + 45 + magic constant + Should be one of: Const2.I, Const1.X + + + X.java + 46 + magic constant + Should be one of: Const2.I, Const1.X + + + + X.java + 57 + magic constant + Should be one of: Const1.X, Const2.I or their combination + + + X.java + 58 + magic constant + Should be one of: Const1.X, Const2.I or their combination + + + X.java + 59 + magic constant + Should be one of: Const1.X, Const2.I + + + X.java + 61 + magic constant + Should be one of: Const1.X, Const2.I or their combination + + + + X.java + 72 + magic constant + Should be one of: Const2.I, Const1.X or their combination + + + X.java + 73 + magic constant + Should be one of: Const2.I, Const1.X or their combination + + + diff --git a/java/java-tests/testData/inspection/magic/manyConstantSources/src/X.java b/java/java-tests/testData/inspection/magic/manyConstantSources/src/X.java new file mode 100644 index 000000000000..950683a5e24d --- /dev/null +++ b/java/java-tests/testData/inspection/magic/manyConstantSources/src/X.java @@ -0,0 +1,82 @@ +/* + * Copyright 2000-2011 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. + */ + +import org.intellij.lang.annotations.MagicConstant; + +class Const1 { + public static final int X = 1; +} + +class Const2 { + public static final int I = 4; +} + +public class X { + + void f(@MagicConstant(intValues = {Const1.X, Const2.I}) int x) { + /////////// BAD + f(0); + f(1); + f(Const1.X | Const2.I); + + ////////////// GOOD + f(Const1.X); + f(Const2.I); + + f2(x); + } + + void f2(@MagicConstant(valuesFromClass = Const1.class, intValues = {Const2.I}) int x) { + /////////// BAD + f2(0); + f2(1); + f2(Const1.X | Const2.I); + + ////////////// GOOD + f2(Const1.X); + f2(Const2.I); + + f(x); + } + + void f3(@MagicConstant(flags = {Const1.X, Const2.I}) int x) { + /////////// BAD + f3(2); + f3(1); + f(Const1.X | Const2.I); + int i = Const1.X | 4; + f3(i); + + ////////////// GOOD + f3(Const1.X); + f3(Const2.I); + + f4(x); + } + + void f4(@MagicConstant(flagsFromClass = Const1.class, flags = {Const2.I}) int x) { + /////////// BAD + f4(-3); + f4(1); + + ////////////// GOOD + f4(Const1.X); + f4(Const2.I); + f4(Const1.X | Const2.I); + + f3(x); + } +} diff --git a/java/java-tests/testData/inspection/magic/simple/expected.xml b/java/java-tests/testData/inspection/magic/simple/expected.xml index b54c2f926aab..062b3aa7245c 100644 --- a/java/java-tests/testData/inspection/magic/simple/expected.xml +++ b/java/java-tests/testData/inspection/magic/simple/expected.xml @@ -14,7 +14,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -26,7 +26,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -38,7 +38,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -50,7 +50,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -62,7 +62,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -74,7 +74,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -86,7 +86,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -98,7 +98,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -110,7 +110,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -122,7 +122,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -134,7 +134,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -146,7 +146,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -158,7 +158,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -170,7 +170,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -178,7 +178,7 @@ X.java 81 magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination + Should be one of: Const.X, Const.Y, Const.Z or their combination @@ -189,7 +189,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination + Should be one of: Const.X, Const.Y, Const.Z or their combination @@ -201,7 +201,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -213,7 +213,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination + Should be one of: Const.X, Const.Y, Const.Z or their combination @@ -225,7 +225,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination + Should be one of: Const.X, Const.Y, Const.Z or their combination @@ -237,7 +237,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination + Should be one of: Const.X, Const.Y, Const.Z or their combination @@ -249,7 +249,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination + Should be one of: Const.X, Const.Y, Const.Z or their combination @@ -257,14 +257,14 @@ X.java 118 magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination + Should be one of: Const.X, Const.Y, Const.Z or their combination X.java 119 magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination + Should be one of: Const.X, Const.Y, Const.Z or their combination @@ -276,7 +276,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination + Should be one of: Const.X, Const.Y, Const.Z or their combination @@ -288,7 +288,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination + Should be one of: Const.X, Const.Y, Const.Z or their combination @@ -300,7 +300,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination + Should be one of: Const.X, Const.Y, Const.Z or their combination @@ -312,7 +312,7 @@ magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z or their combination + Should be one of: Const.X, Const.Y, Const.Z or their combination @@ -322,7 +322,7 @@ X.java 173 magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -331,7 +331,7 @@ X.java 174 magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -340,7 +340,7 @@ X.java 175 magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -349,7 +349,7 @@ X.java 177 magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -357,7 +357,7 @@ X.java 178 magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -366,7 +366,7 @@ X.java 179 magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z @@ -375,7 +375,7 @@ X.java 180 magic constant - Should be one of: Const2.I, Const.X, Const.Y, Const.Z + Should be one of: Const.X, Const.Y, Const.Z diff --git a/java/java-tests/testData/inspection/magic/simple/src/X.java b/java/java-tests/testData/inspection/magic/simple/src/X.java index 21a95e66a51d..043a4037e241 100644 --- a/java/java-tests/testData/inspection/magic/simple/src/X.java +++ b/java/java-tests/testData/inspection/magic/simple/src/X.java @@ -24,7 +24,7 @@ class Const { } public class X { - void f(@MagicConstant(intValues={Const.X, Const.Y, Const.Z, Const2.I}) int x) { + void f(@MagicConstant(intValues={Const.X, Const.Y, Const.Z}) int x) { /////////// BAD f(0); f(1); @@ -50,7 +50,7 @@ public class X { f2(x); } - void f2(@MagicConstant(valuesFromClass =Const.class, intValues={Const2.I}) int x) { + void f2(@MagicConstant(valuesFromClass =Const.class) int x) { /////////// BAD f2(0); f2(1); @@ -61,11 +61,11 @@ public class X { x = 2; assert x != 1; } + ////////////// GOOD f2(Const.X); f2(Const.Y); - f2(Const.Z); - f2(Const2.I); + f2(Const.Z); int i2 = this == null ? Const.X : Const.Y; f2(i2); if (x == Const.X) { @@ -76,7 +76,7 @@ public class X { f(x); } - void f3(@MagicConstant(flags ={Const.X, Const.Y, Const.Z, Const2.I}) int x) { + void f3(@MagicConstant(flags ={Const.X, Const.Y, Const.Z}) int x) { /////////// BAD f3(2); f3(1); @@ -113,7 +113,7 @@ public class X { f4(x); } - void f4(@MagicConstant(flagsFromClass =Const.class, flags={Const2.I}) int x) { + void f4(@MagicConstant(flagsFromClass =Const.class) int x) { /////////// BAD f4(-3); f4(1); @@ -128,8 +128,8 @@ public class X { ////////////// GOOD f4(Const.X); f4(Const.Y); - f4(Const.Z); - f4(Const2.I); + f4(Const.Z); + int i2 = this == null ? Const.X : Const.Y; f4(i2); int ix = Const.X | Const.Y; @@ -152,7 +152,7 @@ public class X { class Alias { - @MagicConstant(intValues={Const.X, Const.Y, Const.Z, Const2.I}) + @MagicConstant(intValues={Const.X, Const.Y, Const.Z}) @interface IntEnum{} void f(@IntEnum int x) { @@ -268,6 +268,3 @@ public class X { font(0); } } -class Const2 { - public static final int I = 0x10; -} diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java index 3c28371a74c2..fcf45f01e189 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java @@ -92,6 +92,8 @@ public class MagicConstantInspectionTest extends InspectionTestCase { } public void testSimple() throws Exception { doTest(); } + + public void testManyConstantSources() throws Exception { doTest(); } // test that the optimisation for not loading AST works public void testWithLibrary() throws Exception { doTest(); } } From 2b674bf37e9521e102aa4b73b6e86b9ec9cfaa48 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 14 Feb 2017 18:17:47 +0100 Subject: [PATCH 72/96] add isEqualTo(file: File) --- .../src/com/intellij/testFramework/assertions/JdomAssert.kt | 4 ++++ .../org/jetbrains/idea/eclipse/EclipseImlTest.java | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/testFramework/extensions/src/com/intellij/testFramework/assertions/JdomAssert.kt b/platform/testFramework/extensions/src/com/intellij/testFramework/assertions/JdomAssert.kt index 57d0c3555463..868864789e4b 100644 --- a/platform/testFramework/extensions/src/com/intellij/testFramework/assertions/JdomAssert.kt +++ b/platform/testFramework/extensions/src/com/intellij/testFramework/assertions/JdomAssert.kt @@ -24,6 +24,7 @@ import com.intellij.util.loadElement import org.assertj.core.api.AbstractAssert import org.assertj.core.internal.Objects import org.jdom.Element +import java.io.File import java.nio.file.Path class JdomAssert(actual: Element?) : AbstractAssert(actual, JdomAssert::class.java) { @@ -37,6 +38,9 @@ class JdomAssert(actual: Element?) : AbstractAssert(actual return this } + @Deprecated("isEqualTo(file: Path)", ReplaceWith("isEqualTo(file.toPath())")) + fun isEqualTo(file: File) = isEqualTo(file.toPath()) + fun isEqualTo(file: Path): JdomAssert { isNotNull diff --git a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImlTest.java b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImlTest.java index b7dd0043223a..a7bf065cf8b2 100644 --- a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImlTest.java +++ b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImlTest.java @@ -46,6 +46,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.idea.eclipse.conversion.EclipseClasspathReader; import java.io.File; +import java.nio.file.Paths; import static com.intellij.testFramework.assertions.Assertions.assertThat; @@ -97,7 +98,7 @@ public class EclipseImlTest extends IdeaTestCase { PathMacroManager.getInstance(project).collapsePaths(actualImlElement); PathMacros.getInstance().removeMacro(JUNIT); - assertThat(actualImlElement).isEqualTo(new File(project.getBaseDir().getPath() + "/expected", "expected.iml")); + assertThat(actualImlElement).isEqualTo(Paths.get(project.getBaseDir().getPath(), "expected", "expected.iml")); } public void testWorkspaceOnly() throws Exception { From 4f451170157e3a6be5591e6ffaafff3d280a679c Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 14 Feb 2017 18:18:35 +0100 Subject: [PATCH 73/96] really search for private class inheritors outside the current file (IDEA-167877) --- .../navigation/GotoImplementationHandlerTest.java | 12 ++++++++++++ .../psi/search/searches/DefinitionsScopedSearch.java | 11 ++++++----- .../codeInsight/TargetElementEvaluatorEx2.java | 4 ++++ .../com/intellij/codeInsight/TargetElementUtil.java | 5 ++++- .../intellij/codeInsight/TargetElementUtilBase.java | 3 +++ 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java b/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java index 5beb72020985..bf3a0ba2b971 100644 --- a/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java +++ b/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java @@ -282,6 +282,18 @@ public class GotoImplementationHandlerTest extends JavaCodeInsightFixtureTestCas assertEquals(1, impls.length); } + public void testPrivateClassInheritors() { + PsiFile file = myFixture.addFileToProject("Foo.java", + "class C {\n" + + " private static class Private {}\n" + + " public static class Public extends Private {}" + + "}"); + myFixture.addClass("class Inheritor extends C.Public {}"); + myFixture.configureFromExistingVirtualFile(file.getVirtualFile()); + + assertSize(2, getTargets(file)); + } + private PsiElement[] getTargets(PsiFile file) { GotoTargetHandler.GotoData gotoData = CodeInsightTestUtil.gotoImplementation(myFixture.getEditor(), file); assertNotNull(gotoData); diff --git a/platform/indexing-api/src/com/intellij/psi/search/searches/DefinitionsScopedSearch.java b/platform/indexing-api/src/com/intellij/psi/search/searches/DefinitionsScopedSearch.java index 03cfe5540943..500c000a9cd9 100644 --- a/platform/indexing-api/src/com/intellij/psi/search/searches/DefinitionsScopedSearch.java +++ b/platform/indexing-api/src/com/intellij/psi/search/searches/DefinitionsScopedSearch.java @@ -17,9 +17,11 @@ package com.intellij.psi.search.searches; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.util.Computable; import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; import com.intellij.psi.search.PsiSearchHelper; import com.intellij.psi.search.SearchScope; import com.intellij.util.Processor; @@ -98,11 +100,10 @@ public class DefinitionsScopedSearch extends ExtensibleQueryFactory() { - @Override - public SearchScope compute() { - return myScope.intersectWith(PsiSearchHelper.SERVICE.getInstance(myElement.getProject()).getUseScope(myElement)); - } + return ReadAction.compute(() -> { + PsiFile file = myElement.getContainingFile(); + return myScope.intersectWith( + PsiSearchHelper.SERVICE.getInstance(myElement.getProject()).getUseScope(file != null ? file : myElement)); }); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/TargetElementEvaluatorEx2.java b/platform/lang-impl/src/com/intellij/codeInsight/TargetElementEvaluatorEx2.java index fda13bfafdef..f5811d484907 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/TargetElementEvaluatorEx2.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/TargetElementEvaluatorEx2.java @@ -88,6 +88,10 @@ public abstract class TargetElementEvaluatorEx2 implements TargetElementEvaluato return true; } + /** + * @return a scope where element's implementations (Goto/Show Implementations) should be searched. + * If null is returned, default (module-with-dependents) scope will be used. + */ @Nullable public SearchScope getSearchScope(Editor editor, @NotNull PsiElement element) { return null; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/TargetElementUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/TargetElementUtil.java index cd70174abbe2..5cb5fefd70bd 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/TargetElementUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/TargetElementUtil.java @@ -457,7 +457,10 @@ public class TargetElementUtil extends TargetElementUtilBase { public SearchScope getSearchScope(Editor editor, @NotNull PsiElement element) { TargetElementEvaluatorEx2 evaluator = getElementEvaluatorsEx2(element.getLanguage()); SearchScope result = evaluator != null ? evaluator.getSearchScope(editor, element) : null; - return result != null ? result : PsiSearchHelper.SERVICE.getInstance(element.getProject()).getUseScope(element); + if (result != null) return result; + + PsiFile file = element.getContainingFile(); + return PsiSearchHelper.SERVICE.getInstance(element.getProject()).getUseScope(file != null ? file : element); } protected final LanguageExtension targetElementEvaluator = diff --git a/platform/lang-impl/src/com/intellij/codeInsight/TargetElementUtilBase.java b/platform/lang-impl/src/com/intellij/codeInsight/TargetElementUtilBase.java index 578c684ccd4f..ed9fb72e507b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/TargetElementUtilBase.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/TargetElementUtilBase.java @@ -96,6 +96,9 @@ public abstract class TargetElementUtilBase { public abstract boolean acceptImplementationForReference(@Nullable PsiReference reference, @Nullable PsiElement element); + /** + * @return a scope where element's implementations (Goto/Show Implementations) should be searched + */ @NotNull public abstract SearchScope getSearchScope(Editor editor, @NotNull PsiElement element); } From f4e3de89a324167e93a5c97be5d98b24f7dd19bc Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Tue, 14 Feb 2017 17:20:17 +0000 Subject: [PATCH 74/96] Hide the create branch action if there are no Git repositories Follow-up to 4724801 --- .../git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt b/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt index e98c97057f01..7663e516d961 100644 --- a/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt +++ b/plugins/git4idea/src/git4idea/actions/GitCreateNewBranchAction.kt @@ -63,6 +63,7 @@ internal class GitCreateNewBranchAction : DumbAwareAction() { private fun collectData(e: AnActionEvent): Data { val project = e.project ?: return Data.Invisible() val manager = getRepositoryManager(project) + if (manager.repositories.isEmpty()) return Data.Invisible() val log = e.getData(VcsLogDataKeys.VCS_LOG) if (log != null) { From 36114e49b8c558ff215d04ce031c76a72d36c1a9 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Tue, 14 Feb 2017 20:33:56 +0300 Subject: [PATCH 75/96] [groovy] add docs for DependentResolver --- .../plugins/groovy/lang/resolve/DependentResolver.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/DependentResolver.kt b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/DependentResolver.kt index 8f061d7316b3..79604ea9d8d8 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/DependentResolver.kt +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/DependentResolver.kt @@ -22,7 +22,16 @@ import com.intellij.psi.impl.source.resolve.ResolveCache abstract class DependentResolver : ResolveCache.PolyVariantResolver { companion object { - private val resolvingDependencies = ThreadLocal.withInitial> { mutableSetOf() } + /** + * Given: resolve was called on a reference a.r1.r2...rN. + * Its dependencies: a, a.r1, a.r1.r2, ... , a.r1.r2...rN-1. + * We resolve dependencies in a loop. + * Assume currently resolving dependency is a.r1.r2...rK, K < N. + * By the time it is being processed all its dependencies are already resolved and the resolve results are stored in a list, + * so we do not need to collect/resolve its dependencies again. + * This field is needed to memoize currently resolving dependencies. + */ + private val resolvingDependencies = ThreadLocal.withInitial { mutableSetOf() } } override final fun resolve(ref: T, incomplete: Boolean): Array { From ad19e40e603923e96a53c8cd793f994f0bb9dc15 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Tue, 14 Feb 2017 20:15:39 +0300 Subject: [PATCH 76/96] always add/remove a loading layer to improve scrolling performance --- .../intellij/openapi/ui/LoadingDecorator.java | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java b/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java index 1713920d1f26..20efec02a10d 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java @@ -20,7 +20,6 @@ import com.intellij.openapi.util.Disposer; import com.intellij.ui.components.JBLayeredPane; import com.intellij.ui.components.panels.NonOpaquePanel; import com.intellij.util.Alarm; -import com.intellij.util.SystemProperties; import com.intellij.util.ui.Animator; import com.intellij.util.ui.AsyncProcessIcon; import com.intellij.util.ui.UIUtil; @@ -75,27 +74,18 @@ public class LoadingDecorator { myPane.add(content, JLayeredPane.DEFAULT_LAYER, 0); - if (!SystemProperties.isTrueSmoothScrollingEnabled()) { - myPane.add(myLoadingLayer, JLayeredPane.DRAG_LAYER, 1); - } Disposer.register(parent, myLoadingLayer.myProgress); } + /** + * Removes a loading layer to restore a blit-accelerated scrolling. + */ private void hideLoadingLayer() { - if (SystemProperties.isTrueSmoothScrollingEnabled()) { - myPane.remove(myLoadingLayer); - } + myPane.remove(myLoadingLayer); myLoadingLayer.setVisible(false); } - public void setLoadingLayerVisible(boolean visible, boolean takeSnapshot) { - if (SystemProperties.isTrueSmoothScrollingEnabled() && visible) { - setLoadingLayerPresent(); - } - myLoadingLayer.setVisible(visible, takeSnapshot); - } - /* Placing the invisible layer on top of JViewport suppresses blit-accelerated scrolling as JViewport.canUseWindowBlitter() doesn't take component's visibility into account. @@ -103,8 +93,8 @@ public class LoadingDecorator { Blit-acceleration copies as much of the rendered area as possible and then repaints only newly exposed region. This helps to improve scrolling performance and to reduce CPU usage (especially if drawing is compute-intensive). */ - private void setLoadingLayerPresent() { - if (myPane.getComponentCount() < 2) { + private void addLoadingLayerOnDemand() { + if (myPane != myLoadingLayer.getParent()) { myPane.add(myLoadingLayer, JLayeredPane.DRAG_LAYER, 1); } } @@ -145,7 +135,8 @@ public class LoadingDecorator { } protected void _startLoading(final boolean takeSnapshot) { - setLoadingLayerVisible(true, takeSnapshot); + addLoadingLayerOnDemand(); + myLoadingLayer.setVisible(true, takeSnapshot); } public void stopLoading() { @@ -154,7 +145,7 @@ public class LoadingDecorator { if (!isLoading()) return; - setLoadingLayerVisible(false, false); + myLoadingLayer.setVisible(false, false); } From 516915849582294bc3073a8b5c6da808f1a6cf05 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Tue, 14 Feb 2017 20:53:32 +0300 Subject: [PATCH 77/96] IDEA-168119 Structural Search dialog can change it's width to be unusable (because of long Status: text) set minimum size for label in status bar to prevent dialog resizing --- .../com/intellij/structuralsearch/plugin/ui/SearchDialog.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java index 21e435fe3c9f..e46bceba3957 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java @@ -565,6 +565,7 @@ public class SearchDialog extends DialogWrapper { statusPanel.add(super.createSouthPanel(), BorderLayout.NORTH); statusPanel.add(statusText = new JLabel(SSRBundle.message("status.message")), BorderLayout.WEST); statusPanel.add(status = new JLabel(), BorderLayout.CENTER); + status.setMinimumSize(new Dimension(0, 0)); return statusPanel; } From bced1d70d9910412a9fccc97c048186fb7b3df85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Tue, 14 Feb 2017 19:31:45 +0100 Subject: [PATCH 78/96] [maven] add FacetImporter.isDisableFacetAutodetection --- .../idea/maven/importing/FacetImporter.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/FacetImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/FacetImporter.java index 262e8fa42559..42df462cf151 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/FacetImporter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/FacetImporter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -90,7 +90,20 @@ public abstract class FacetImporter Date: Tue, 14 Feb 2017 19:32:09 +0100 Subject: [PATCH 79/96] assert command name NotNull --- .../com/intellij/refactoring/BaseRefactoringProcessor.java | 1 + .../src/com/intellij/openapi/ui/impl/HeadlessDialog.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java index 0e3b5264875f..23c49f40a720 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java +++ b/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java @@ -152,6 +152,7 @@ public abstract class BaseRefactoringProcessor implements Runnable { */ protected abstract void performRefactoring(@NotNull UsageInfo[] usages); + @NotNull protected abstract String getCommandName(); protected void doRun() { diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/impl/HeadlessDialog.java b/platform/platform-impl/src/com/intellij/openapi/ui/impl/HeadlessDialog.java index 6065e057c54d..420a78a6e15d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/impl/HeadlessDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/impl/HeadlessDialog.java @@ -33,6 +33,7 @@ import java.awt.event.MouseMotionListener; @SuppressWarnings("ConstantConditions") class HeadlessDialog implements AbstractDialog { @NotNull private final DialogWrapper myWrapper; + private String myTitle; HeadlessDialog(@NotNull DialogWrapper wrapper) { myWrapper = wrapper; @@ -113,7 +114,7 @@ class HeadlessDialog implements AbstractDialog { @Override public String getTitle() { - return null; + return myTitle; } @Override @@ -141,6 +142,7 @@ class HeadlessDialog implements AbstractDialog { @Override public void setTitle(String title) { + myTitle = title; } @Override From f7c2d3b4b0c33eeb5350b9a86091bc504d5a8dcd Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Tue, 14 Feb 2017 21:36:11 +0300 Subject: [PATCH 80/96] Use children of 'Choose run configuration' popup and Run action group in the same way + adjust run Choose run configuration popup title --- .../actions/BaseRunConfigurationAction.java | 13 +++++++++---- .../src/messages/ExecutionBundle.properties | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/actions/BaseRunConfigurationAction.java b/platform/lang-impl/src/com/intellij/execution/actions/BaseRunConfigurationAction.java index 121515c68f71..ebba0dbe0364 100644 --- a/platform/lang-impl/src/com/intellij/execution/actions/BaseRunConfigurationAction.java +++ b/platform/lang-impl/src/com/intellij/execution/actions/BaseRunConfigurationAction.java @@ -70,9 +70,7 @@ public abstract class BaseRunConfigurationAction extends ActionGroup { for (final ConfigurationFromContext fromContext : producers) { final ConfigurationType configurationType = fromContext.getConfigurationType(); final RunConfiguration configuration = fromContext.getConfiguration(); - final String actionName = configuration instanceof LocatableConfiguration - ? StringUtil.unquoteString(suggestRunActionName((LocatableConfiguration)configuration)) - : configurationType.getDisplayName(); + final String actionName = childActionName(configurationType, configuration); final AnAction anAction = new AnAction(actionName, configurationType.getDisplayName(), configuration.getIcon()) { @Override public void actionPerformed(AnActionEvent e) { @@ -140,7 +138,7 @@ public abstract class BaseRunConfigurationAction extends ActionGroup { @Override @NotNull public String getTextFor(final ConfigurationFromContext producer) { - return StringUtil.notNullize(producer.getConfiguration().getName(), producer.getConfigurationType().getDisplayName()); + return childActionName(producer.getConfigurationType(), producer.getConfiguration()); } @Override @@ -220,6 +218,13 @@ public abstract class BaseRunConfigurationAction extends ActionGroup { return ProgramRunnerUtil.shortenName(configuration.getName(), 0); } + @NotNull + private static String childActionName(ConfigurationType configurationType, RunConfiguration configuration) { + return configuration instanceof LocatableConfiguration + ? StringUtil.unquoteString(suggestRunActionName((LocatableConfiguration)configuration)) + : configurationType.getDisplayName(); + } + protected abstract void updatePresentation(Presentation presentation, @NotNull String actionText, ConfigurationContext context); } diff --git a/platform/platform-resources-en/src/messages/ExecutionBundle.properties b/platform/platform-resources-en/src/messages/ExecutionBundle.properties index 7cfeb2274f00..6e0c80d82a16 100644 --- a/platform/platform-resources-en/src/messages/ExecutionBundle.properties +++ b/platform/platform-resources-en/src/messages/ExecutionBundle.properties @@ -332,7 +332,7 @@ environment.variables.system.dialog.title=System Environment environment.variables.component.title=&Environment variables down.the.stack.trace=Down the stack trace up.the.stack.trace=Up the stack trace -configuration.action.chooser.title=Choose configuration type to run +configuration.action.chooser.title=Choose configuration to run env.vars.checkbox.title=&Include parent environment variables env.vars.show.system=Show From fc3f0bb09d1c73130e163f5d80c4b37bb60ac93d Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Tue, 14 Feb 2017 18:14:46 +0700 Subject: [PATCH 81/96] SimplifyStreamApiCallChainsInspection: convert IntStream.range(0, Math.min(limit, arr.length)).map(idx -> arr[idx]) to Arrays.stream(arr).limit(limit) and so on --- ...SimplifyStreamApiCallChainsInspection.java | 59 +++++++++++++++---- .../streamApiMigration/afterRangeLimited.java | 14 +++++ .../beforeRangeLimited.java | 18 ++++++ .../siyeh/ig/psiutils/ExpressionUtils.java | 25 ++++++++ 4 files changed, 105 insertions(+), 11 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterRangeLimited.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeRangeLimited.java diff --git a/java/java-impl/src/com/intellij/codeInspection/SimplifyStreamApiCallChainsInspection.java b/java/java-impl/src/com/intellij/codeInspection/SimplifyStreamApiCallChainsInspection.java index 3ffc8f82676b..9d1d57972700 100644 --- a/java/java-impl/src/com/intellij/codeInspection/SimplifyStreamApiCallChainsInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/SimplifyStreamApiCallChainsInspection.java @@ -890,6 +890,10 @@ public class SimplifyStreamApiCallChainsInspection extends BaseJavaBatchLocalIns .parameterCount(1); private static final CallMatcher INT_STREAM_RANGE = CallMatcher.staticCall(CommonClassNames.JAVA_UTIL_STREAM_INT_STREAM, "range").parameterTypes("int", "int"); + private static final CallMatcher MIN_INT = + CallMatcher.anyOf( + CallMatcher.staticCall(CommonClassNames.JAVA_LANG_MATH, "min").parameterTypes("int", "int"), + CallMatcher.staticCall(CommonClassNames.JAVA_LANG_INTEGER, "min").parameterTypes("int", "int")); private final String myName; @@ -913,8 +917,10 @@ public class SimplifyStreamApiCallChainsInspection extends BaseJavaBatchLocalIns public PsiElement simplify(PsiMethodCallExpression mapToObjCall) { Project project = mapToObjCall.getProject(); PsiExpression mapper = ArrayUtil.getFirstElement(mapToObjCall.getArgumentList().getExpressions()); - IndexedContainer container = extractContainer(getQualifierMethodCall(mapToObjCall), mapper); - if (container == null) return null; + LimitedContainer limitedContainer = extractContainer(getQualifierMethodCall(mapToObjCall), mapper); + if (limitedContainer == null) return null; + IndexedContainer container = limitedContainer.myContainer; + PsiExpression limit = limitedContainer.myLimit; PsiExpression containerQualifier = container.getQualifier(); PsiType type = containerQualifier.getType(); PsiType elementType = container.getElementType(); @@ -929,6 +935,9 @@ public class SimplifyStreamApiCallChainsInspection extends BaseJavaBatchLocalIns } PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); CommentTracker ct = new CommentTracker(); + if (limit != null) { + replacement += ".limit(" + ct.text(limit) + ")"; + } if (mapper instanceof PsiMethodReferenceExpression) { mapper = LambdaRefactoringUtil.convertMethodReferenceToLambda((PsiMethodReferenceExpression)mapper, false, true); } @@ -975,22 +984,39 @@ public class SimplifyStreamApiCallChainsInspection extends BaseJavaBatchLocalIns static CallHandler handler() { return CallHandler.of(INT_STREAM_MAP, call -> { PsiExpression mapper = call.getArgumentList().getExpressions()[0]; - IndexedContainer container = extractContainer(getQualifierMethodCall(call), mapper); - if (container == null) return null; - return new ReplaceWithElementIterationFix(container, call.getMethodExpression().getReferenceName()); + LimitedContainer limitedContainer = extractContainer(getQualifierMethodCall(call), mapper); + if (limitedContainer == null) return null; + return new ReplaceWithElementIterationFix(limitedContainer.myContainer, call.getMethodExpression().getReferenceName()); }); } @Contract("null, _ -> null") - private static IndexedContainer extractContainer(PsiMethodCallExpression qualifierCall, PsiExpression mapper) { + private static LimitedContainer extractContainer(PsiMethodCallExpression qualifierCall, PsiExpression mapper) { if (!INT_STREAM_RANGE.test(qualifierCall)) return null; PsiExpression[] rangeArgs = qualifierCall.getArgumentList().getExpressions(); if (!ExpressionUtils.isZero(rangeArgs[0])) return null; - PsiExpression bound = rangeArgs[1]; + PsiExpression bound = ExpressionUtils.resolveExpression(rangeArgs[1]); IndexedContainer container = IndexedContainer.fromLengthExpression(bound); - if (container == null || !StreamApiUtil.isSupportedStreamElement(container.getElementType())) return null; + PsiExpression limit = null; + if (container == null) { + if(bound instanceof PsiMethodCallExpression && MIN_INT.test((PsiMethodCallExpression)bound)) { + PsiExpression[] args = ((PsiMethodCallExpression)bound).getArgumentList().getExpressions(); + container = IndexedContainer.fromLengthExpression(args[0]); + if(container != null) { + limit = args[1]; + } else { + container = IndexedContainer.fromLengthExpression(args[1]); + if(container != null) { + limit = args[0]; + } + } + } + if(container == null) return null; + } + if (!StreamApiUtil.isSupportedStreamElement(container.getElementType())) return null; + LimitedContainer limitedContainer = new LimitedContainer(container, limit); if (mapper instanceof PsiMethodReferenceExpression && container.isGetMethodReference((PsiMethodReferenceExpression)mapper)) { - return container; + return limitedContainer; } if (mapper instanceof PsiLambdaExpression) { PsiLambdaExpression lambda = (PsiLambdaExpression)mapper; @@ -1001,12 +1027,23 @@ public class SimplifyStreamApiCallChainsInspection extends BaseJavaBatchLocalIns if (body == null) return null; Collection refs = ReferencesSearch.search(indexParameter, new LocalSearchScope(body)).findAll(); if (!refs.isEmpty() && - refs.stream().allMatch(ref -> container.extractGetExpressionFromIndex(tryCast(ref, PsiExpression.class)) != null)) { - return container; + refs.stream() + .allMatch(ref -> limitedContainer.myContainer.extractGetExpressionFromIndex(tryCast(ref, PsiExpression.class)) != null)) { + return limitedContainer; } } return null; } + + static class LimitedContainer { + @NotNull final IndexedContainer myContainer; + @Nullable final PsiExpression myLimit; + + LimitedContainer(@NotNull IndexedContainer container, @Nullable PsiExpression limit) { + myContainer = container; + myLimit = limit; + } + } } private static class RemoveBooleanIdentityFix implements CallChainSimplification { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterRangeLimited.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterRangeLimited.java new file mode 100644 index 000000000000..7509256ce897 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterRangeLimited.java @@ -0,0 +1,14 @@ +// "Replace with collect" "true" + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class Test { + public List test(String[] data) { + int top = Math.min(10, data.length); + List result = Arrays.stream(data).limit(10).map(String::trim).filter(item -> !item.isEmpty()).collect(Collectors.toList()); + return result; + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeRangeLimited.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeRangeLimited.java new file mode 100644 index 000000000000..d1676c8ef6ef --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeRangeLimited.java @@ -0,0 +1,18 @@ +// "Replace with collect" "true" + +import java.util.ArrayList; +import java.util.List; + +public class Test { + public List test(String[] data) { + int top = Math.min(10, data.length); + List result = new ArrayList<>(); + for(int i=0; i null") + @Nullable + public static PsiExpression resolveExpression(@Nullable PsiExpression expression) { + expression = PsiUtil.skipParenthesizedExprDown(expression); + if (expression instanceof PsiReferenceExpression) { + PsiReferenceExpression reference = (PsiReferenceExpression)expression; + PsiLocalVariable variable = ObjectUtils.tryCast(reference.resolve(), PsiLocalVariable.class); + if (variable != null) { + PsiExpression initializer = variable.getInitializer(); + if (initializer != null && ReferencesSearch.search(variable).forEach(ref -> ref == reference)) { + return initializer; + } + } + } + return expression; + } } \ No newline at end of file From 024c0831ac7cf23f293aaa5e51490e4cb1c6e264 Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Wed, 15 Feb 2017 11:43:50 +0700 Subject: [PATCH 82/96] IDEA-168203 StreamApiMigration: accept more standard collection constructors --- .../streamMigration/CollectMigration.java | 12 +- .../afterCollectCustomConstructor.java | 52 +++++++++ .../beforeCollectCustomConstructor.java | 103 ++++++++++++++++++ .../siyeh/ig/psiutils/ConstructionUtils.java | 66 +++++++++-- 4 files changed, 221 insertions(+), 12 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectCustomConstructor.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectCustomConstructor.java diff --git a/java/java-impl/src/com/intellij/codeInspection/streamMigration/CollectMigration.java b/java/java-impl/src/com/intellij/codeInspection/streamMigration/CollectMigration.java index 0b137baf7981..e50668d03df5 100644 --- a/java/java-impl/src/com/intellij/codeInspection/streamMigration/CollectMigration.java +++ b/java/java-impl/src/com/intellij/codeInspection/streamMigration/CollectMigration.java @@ -106,7 +106,8 @@ class CollectMigration extends BaseStreamApiMigration { return initializerClass != null && varClass != null && CommonClassNames.JAVA_UTIL_HASH_MAP.equals(initializerClass.getQualifiedName()) && - CommonClassNames.JAVA_UTIL_MAP.equals(varClass.getQualifiedName()); + CommonClassNames.JAVA_UTIL_MAP.equals(varClass.getQualifiedName()) && + !ConstructionUtils.isCustomizedEmptyCollectionInitializer(initializer); } @Nullable @@ -315,13 +316,14 @@ class CollectMigration extends BaseStreamApiMigration { PsiClassType rawVarType = type instanceof PsiClassType ? ((PsiClassType)type).rawType() : null; if (rawType != null && rawVarType != null && rawType.equalsToText(CommonClassNames.JAVA_UTIL_ARRAY_LIST) && - (rawVarType.equalsToText(CommonClassNames.JAVA_UTIL_LIST) || rawVarType.equalsToText(CommonClassNames.JAVA_UTIL_COLLECTION))) { + (rawVarType.equalsToText(CommonClassNames.JAVA_UTIL_LIST) || rawVarType.equalsToText(CommonClassNames.JAVA_UTIL_COLLECTION)) && + !ConstructionUtils.isCustomizedEmptyCollectionInitializer(initializer)) { collector = "toList()"; } else if (rawType != null && rawVarType != null && rawType.equalsToText(CommonClassNames.JAVA_UTIL_HASH_SET) && - (rawVarType.equalsToText(CommonClassNames.JAVA_UTIL_SET) || - rawVarType.equalsToText(CommonClassNames.JAVA_UTIL_COLLECTION))) { + (rawVarType.equalsToText(CommonClassNames.JAVA_UTIL_SET) || rawVarType.equalsToText(CommonClassNames.JAVA_UTIL_COLLECTION)) && + !ConstructionUtils.isCustomizedEmptyCollectionInitializer(initializer)) { collector = "toSet()"; } else { @@ -331,7 +333,7 @@ class CollectMigration extends BaseStreamApiMigration { PsiExpressionList argumentList = ((PsiNewExpression)copy).getArgumentList(); if (argumentList != null) { PsiExpression arg = ArrayUtil.getFirstElement(argumentList.getExpressions()); - if (arg != null) { + if (arg != null && !(arg.getType() instanceof PsiPrimitiveType)) { arg.delete(); } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectCustomConstructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectCustomConstructor.java new file mode 100644 index 000000000000..ac0b5bcf3f96 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectCustomConstructor.java @@ -0,0 +1,52 @@ +// "Fix all 'Loop can be collapsed with Stream API' problems in file" "true" + +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +public class Test { + void testList(List input) { + List result = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toCollection(() -> new ArrayList<>(10))); + System.out.println(result); + + ArrayList result2 = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toCollection(() -> new ArrayList<>(20))); + System.out.println(result2); + + // Non-empty + ArrayList result3 = new ArrayList<>(input); + input.stream().filter(s -> !s.isEmpty()).forEach(result3::add); + System.out.println(result3); + } + + void testSet(List input) { + Set result = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toCollection(() -> new HashSet<>(10))); + System.out.println(result); + + Collection result2 = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toCollection(() -> new LinkedHashSet<>(20, 0.8f))); + System.out.println(result2); + + // Non-empty + AbstractSet result3 = new HashSet<>(input); + input.stream().filter(s -> !s.isEmpty()).forEach(result3::add); + System.out.println(result3); + + Collection result4 = input.stream().filter(s -> !s.isEmpty()).map(TimeUnit::valueOf).collect(Collectors.toCollection(() -> EnumSet.noneOf(TimeUnit.class))); + System.out.println(result4); + } + + void testMap(List input) { + Map result = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toMap(String::length, s -> s, (a, b) -> b, () -> new HashMap<>(10))); + System.out.println(result); + + Map result2 = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toMap(String::length, s -> s, (a, b) -> b, () -> new HashMap<>(10, 0.8f))); + System.out.println(result2); + + EnumMap result3 = input.stream().filter(s -> !s.isEmpty()).collect(Collectors.toMap(TimeUnit::valueOf, s -> s, (a, b) -> b, () -> new EnumMap<>(TimeUnit.class))); + System.out.println(result3); + + // Non-empty + EnumMap result4 = new EnumMap<>(result3); + input.stream().filter(s -> !s.isEmpty()).forEach(s -> result4.put(TimeUnit.valueOf(s), s)); + System.out.println(result4); + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectCustomConstructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectCustomConstructor.java new file mode 100644 index 000000000000..503747e9d353 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectCustomConstructor.java @@ -0,0 +1,103 @@ +// "Fix all 'Loop can be collapsed with Stream API' problems in file" "true" + +import java.util.*; +import java.util.concurrent.TimeUnit; + +public class Test { + void testList(List input) { + List result = new ArrayList<>(10); + for (String s : input) { + if (!s.isEmpty()) { + result.add(s); + } + } + System.out.println(result); + + ArrayList result2 = new ArrayList<>(20); + for (String s : input) { + if (!s.isEmpty()) { + result2.add(s); + } + } + System.out.println(result2); + + // Non-empty + ArrayList result3 = new ArrayList<>(input); + for (String s : input) { + if (!s.isEmpty()) { + result3.add(s); + } + } + System.out.println(result3); + } + + void testSet(List input) { + Set result = new HashSet<>(10); + for (String s : input) { + if (!s.isEmpty()) { + result.add(s); + } + } + System.out.println(result); + + Collection result2 = new LinkedHashSet<>(20, 0.8f); + for (String s : input) { + if (!s.isEmpty()) { + result2.add(s); + } + } + System.out.println(result2); + + // Non-empty + AbstractSet result3 = new HashSet<>(input); + for (String s : input) { + if (!s.isEmpty()) { + result3.add(s); + } + } + System.out.println(result3); + + Collection result4 = EnumSet.noneOf(TimeUnit.class); + for (String s : input) { + if (!s.isEmpty()) { + result4.add(TimeUnit.valueOf(s)); + } + } + System.out.println(result4); + } + + void testMap(List input) { + Map result = new HashMap<>(10); + for (String s : input) { + if (!s.isEmpty()) { + result.put(s.length(), s); + } + } + System.out.println(result); + + Map result2 = new HashMap<>(10, 0.8f); + for (String s : input) { + if (!s.isEmpty()) { + result2.put(s.length(), s); + } + } + System.out.println(result2); + + EnumMap result3 = new EnumMap<>(TimeUnit.class); + for (String s : input) { + if (!s.isEmpty()) { + result3.put(TimeUnit.valueOf(s), s); + } + } + System.out.println(result3); + + // Non-empty + EnumMap result4 = new EnumMap<>(result3); + for (String s : input) { + if (!s.isEmpty()) { + result4.put(TimeUnit.valueOf(s), s); + } + } + System.out.println(result4); + } +} diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ConstructionUtils.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ConstructionUtils.java index 1c6d3d20034f..a1e6ac5a74d6 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ConstructionUtils.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ConstructionUtils.java @@ -17,13 +17,24 @@ package com.siyeh.ig.psiutils; import com.intellij.psi.*; import com.intellij.psi.util.PsiUtil; +import com.intellij.util.containers.ContainerUtil; +import com.siyeh.ig.callMatcher.CallMatcher; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Nullable; +import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Stream; + /** * @author Tagir Valeev */ public class ConstructionUtils { + private static final Set GUAVA_UTILITY_CLASSES = + ContainerUtil.set("com.google.common.collect.Maps", "com.google.common.collect.Lists", "com.google.common.collect.Sets"); + private static final CallMatcher ENUM_SET_NONE_OF = + CallMatcher.staticCall("java.util.EnumSet", "noneOf").parameterCount(1); + /** * Checks that given expression initializes empty StringBuilder or StringBuffer (either with explicit default capacity or not) * @@ -79,10 +90,11 @@ public class ConstructionUtils { expression = PsiUtil.skipParenthesizedExprDown(expression); if (expression instanceof PsiNewExpression) { PsiExpressionList argumentList = ((PsiNewExpression)expression).getArgumentList(); - if (argumentList == null || argumentList.getExpressions().length != 0) return false; - PsiType type = expression.getType(); - return com.intellij.psi.util.InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_COLLECTION) || - com.intellij.psi.util.InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP); + if (argumentList != null && argumentList.getExpressions().length == 0) { + PsiType type = expression.getType(); + return com.intellij.psi.util.InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_COLLECTION) || + com.intellij.psi.util.InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP); + } } if (expression instanceof PsiMethodCallExpression) { PsiMethodCallExpression call = (PsiMethodCallExpression)expression; @@ -94,15 +106,55 @@ public class ConstructionUtils { PsiClass aClass = method.getContainingClass(); if(aClass != null) { String qualifiedName = aClass.getQualifiedName(); - if("com.google.common.collect.Maps".equals(qualifiedName) || - "com.google.common.collect.Lists".equals(qualifiedName) || - "com.google.common.collect.Sets".equals(qualifiedName)) { + if (GUAVA_UTILITY_CLASSES.contains(qualifiedName)) { return true; } } } } } + return isCustomizedEmptyCollectionInitializer(expression); + } + + /** + * Checks that given expression initializes empty Collection or Map with custom initial capacity or load factor + * + * @param expression expression to check + * @return true if the expression is the empty Collection or Map initializer with custom initial capacity or load factor + */ + @Contract("null -> false") + public static boolean isCustomizedEmptyCollectionInitializer(PsiExpression expression) { + expression = PsiUtil.skipParenthesizedExprDown(expression); + if (expression instanceof PsiNewExpression) { + PsiExpressionList argumentList = ((PsiNewExpression)expression).getArgumentList(); + if (argumentList == null || argumentList.getExpressions().length == 0) return false; + PsiMethod constructor = ((PsiNewExpression)expression).resolveConstructor(); + if (constructor == null) return false; + PsiClass aClass = constructor.getContainingClass(); + if (aClass == null || aClass.getQualifiedName() == null || !aClass.getQualifiedName().startsWith("java.util.")) return false; + Predicate allowedParameterType = t -> t instanceof PsiPrimitiveType || + (t instanceof PsiClassType && + ((PsiClassType)t).rawType().equalsToText(CommonClassNames.JAVA_LANG_CLASS)); + return Stream.of(constructor.getParameterList().getParameters()).map(PsiParameter::getType).allMatch(allowedParameterType); + } + if (expression instanceof PsiMethodCallExpression) { + PsiMethodCallExpression call = (PsiMethodCallExpression)expression; + if (ENUM_SET_NONE_OF.test(call)) return true; + String name = call.getMethodExpression().getReferenceName(); + PsiExpressionList argumentList = call.getArgumentList(); + if (name != null && name.startsWith("new") && argumentList.getExpressions().length > 0) { + PsiMethod method = call.resolveMethod(); + if (method != null && method.getParameterList().getParametersCount() > 0) { + PsiClass aClass = method.getContainingClass(); + if (aClass != null) { + String qualifiedName = aClass.getQualifiedName(); + if (GUAVA_UTILITY_CLASSES.contains(qualifiedName)) { + return Stream.of(method.getParameterList().getParameters()).allMatch(p -> p.getType() instanceof PsiPrimitiveType); + } + } + } + } + } return false; } From d0ebe3d211f76c24d04b1d9aa486a54635f83daf Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Wed, 15 Feb 2017 14:09:47 +0700 Subject: [PATCH 83/96] DfaMemoryStateImpl now does not track nested stack-top closures: responsibility is moved to DataFlowRunner (IDEA-CR-18166) --- .../dataFlow/DataFlowRunner.java | 28 +++++++++++++++---- .../dataFlow/DfaMemoryStateImpl.java | 10 ------- .../dataFlow/StandardInstructionVisitor.java | 2 +- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowRunner.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowRunner.java index aa08cf6ebede..3f8943eb0cbf 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowRunner.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowRunner.java @@ -49,6 +49,9 @@ public class DataFlowRunner { private Instruction[] myInstructions; private final MultiMap myNestedClosures = new MultiMap<>(); + // Closures which were registered for previous instruction and can be queried by visitor + // to adjust them somehow + private final List myStackTopClosures = new ArrayList<>(); @NotNull private final DfaValueFactory myValueFactory; private final boolean myShouldCheckLimitTime; @@ -90,6 +93,10 @@ public class DataFlowRunner { return Collections.singletonList(createMemoryState()); } + List getStackTopClosures() { + return new ArrayList<>(myStackTopClosures); + } + @NotNull public final RunnerResult analyzeMethod(@NotNull PsiElement psiBlock, @NotNull InstructionVisitor visitor) { Collection initialStates = createInitialStates(psiBlock, visitor); @@ -109,6 +116,7 @@ public class DataFlowRunner { int endOffset = flow.getInstructionCount(); myInstructions = flow.getInstructions(); myNestedClosures.clear(); + myStackTopClosures.clear(); Set joinInstructions = ContainerUtil.newHashSet(); for (int index = 0; index < myInstructions.length; index++) { @@ -270,6 +278,9 @@ public class DataFlowRunner { @NotNull protected DfaInstructionState[] acceptInstruction(@NotNull InstructionVisitor visitor, @NotNull DfaInstructionState instructionState) { Instruction instruction = instructionState.getInstruction(); + DfaInstructionState[] states = instruction.accept(this, instructionState.getMemoryState(), visitor); + + myStackTopClosures.clear(); PsiElement closure = DfaUtil.getClosureInside(instruction); if (closure instanceof PsiClass) { registerNestedClosures(instructionState, (PsiClass)closure); @@ -277,7 +288,7 @@ public class DataFlowRunner { registerNestedClosures(instructionState, (PsiLambdaExpression)closure); } - return instruction.accept(this, instructionState.getMemoryState(), visitor); + return states; } private void registerNestedClosures(@NotNull DfaInstructionState instructionState, @NotNull PsiClass nestedClass) { @@ -285,14 +296,14 @@ public class DataFlowRunner { for (PsiMethod method : nestedClass.getMethods()) { PsiCodeBlock body = method.getBody(); if (body != null) { - myNestedClosures.putValue(body, state.createClosureState()); + myNestedClosures.putValue(body, createClosureState(state)); } } for (PsiClassInitializer initializer : nestedClass.getInitializers()) { - myNestedClosures.putValue(initializer.getBody(), state.createClosureState()); + myNestedClosures.putValue(initializer.getBody(), createClosureState(state)); } for (PsiField field : nestedClass.getFields()) { - myNestedClosures.putValue(field, state.createClosureState()); + myNestedClosures.putValue(field, createClosureState(state)); } } @@ -300,10 +311,17 @@ public class DataFlowRunner { DfaMemoryState state = instructionState.getMemoryState(); PsiElement body = expr.getBody(); if (body != null) { - myNestedClosures.putValue(body, state.createClosureState()); + myNestedClosures.putValue(body, createClosureState(state)); } } + @NotNull + private DfaMemoryState createClosureState(DfaMemoryState state) { + DfaMemoryState closureState = state.createClosureState(); + myStackTopClosures.add(closureState); + return closureState; + } + @NotNull protected DfaMemoryState createMemoryState() { return new DfaMemoryStateImpl(myValueFactory); diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java index e34694d07798..1d94c9949f35 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java @@ -53,8 +53,6 @@ public class DfaMemoryStateImpl implements DfaMemoryState { // dfa value id -> indices in myEqClasses list of the classes which contain the id (or wrapped) private final TIntObjectHashMap myIdToEqClassesIndices; private final Stack myStack; - // Closures which correspond to the stack top (do not track other closures for now) - private final List myStackTopClosures = new ArrayList<>(); private final TLongHashSet myDistinctClasses; private final LinkedHashMap myVariableStates; private final Map myDefaultVariableStates; @@ -118,14 +116,9 @@ public class DfaMemoryStateImpl implements DfaMemoryState { copy.flushDependencies(value); } copy.emptyStack(); - myStackTopClosures.add(copy); return copy; } - List getStackTopClosures() { - return new ArrayList<>(myStackTopClosures); - } - public boolean equals(Object obj) { if (obj == this) return true; if (!(obj instanceof DfaMemoryStateImpl)) return false; @@ -241,7 +234,6 @@ public class DfaMemoryStateImpl implements DfaMemoryState { @Override public DfaValue pop() { myCachedHash = null; - myStackTopClosures.clear(); return myStack.pop(); } @@ -253,14 +245,12 @@ public class DfaMemoryStateImpl implements DfaMemoryState { @Override public void push(@NotNull DfaValue value) { myCachedHash = null; - myStackTopClosures.clear(); myStack.push(value); } @Override public void emptyStack() { myCachedHash = null; - myStackTopClosures.clear(); while (!myStack.isEmpty() && !(myStack.peek() instanceof DfaControlTransferValue)) { myStack.pop(); } diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java index 6d0130b73580..9b4e2984cdec 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StandardInstructionVisitor.java @@ -229,7 +229,7 @@ public class StandardInstructionVisitor extends InstructionVisitor { if (methodName == null || !OPTIONAL_METHOD_NAMES.contains(methodName)) return Collections.emptyList(); PsiMethod method = call.resolveMethod(); if (method == null || !TypeUtils.isOptional(method.getContainingClass())) return Collections.emptyList(); - List closures = ((DfaMemoryStateImpl)memState).getStackTopClosures(); + List closures = runner.getStackTopClosures(); DfaValue[] argValues = popCallArguments(instruction, runner, memState); final DfaValue qualifier = popQualifier(instruction, runner, memState); switch (methodName) { From 8e2201d4bdea7b4b85370f895436bd9e77897f85 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 14 Feb 2017 12:28:56 +0100 Subject: [PATCH 84/96] more diagnostics when LaterInvocatorTest.setUp fails --- .../intellij/openapi/application/impl/LaterInvocatorTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaterInvocatorTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaterInvocatorTest.java index cdf4f4b21ede..43dcdf8e0e8f 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaterInvocatorTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaterInvocatorTest.java @@ -96,7 +96,7 @@ public class LaterInvocatorTest extends PlatformTestCase { } }); if (exception[0] != null) throw exception[0]; - UIUtil.invokeAndWaitIfNeeded((Runnable)() -> TestCase.assertFalse("Can't run test", LaterInvocator.isInModalContext())); + UIUtil.invokeAndWaitIfNeeded((Runnable)() -> TestCase.assertFalse("Can't run test " + ModalityState.current(), LaterInvocator.isInModalContext())); flushSwingQueue(); } From db759ac07946a5b809180dd52b9b01fa1915b2ed Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 14 Feb 2017 22:53:26 +0100 Subject: [PATCH 85/96] a more straightforward DomSaxParserTest.ensureParsed --- .../tests/com/intellij/util/xml/DomSaxParserTest.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomSaxParserTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomSaxParserTest.java index e9ab73077873..1d54400b1cd4 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomSaxParserTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomSaxParserTest.java @@ -16,15 +16,11 @@ package com.intellij.util.xml; import com.intellij.lang.xml.XMLLanguage; -import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiFileFactory; import com.intellij.psi.xml.XmlFile; import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import org.jetbrains.annotations.Nullable; -import org.xml.sax.SAXException; - -import java.io.IOException; /** * @author peter @@ -79,8 +75,9 @@ public class DomSaxParserTest extends LightPlatformCodeInsightFixtureTestCase { assertData("?xmlmas8v6708986> Date: Tue, 14 Feb 2017 21:08:25 +0300 Subject: [PATCH 86/96] build scripts: honor excludes when checking that there is only one plugin.xml file in a plugin Python plugin includes several plugin modules but exclude their plugin.xml files via moduleExcludes in the plugin layout. --- .../build/impl/DistributionJARsBuilder.groovy | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy index e92d457a1b83..c9fbf392074b 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy @@ -18,6 +18,7 @@ package org.jetbrains.intellij.build.impl import com.intellij.openapi.util.MultiValuesMap import com.intellij.openapi.util.io.FileUtil import org.apache.tools.ant.types.FileSet +import org.apache.tools.ant.types.resources.FileProvider import org.jetbrains.intellij.build.BuildContext import org.jetbrains.intellij.build.BuildOptions import org.jetbrains.intellij.build.BuildTasks @@ -293,27 +294,31 @@ class DistributionJARsBuilder { def enabledModulesSet = buildContext.productProperties.productLayout.enabledPluginModules pluginsToInclude.each { plugin -> def actualModuleJars = plugin.getActualModules(enabledModulesSet) - checkOutputOfPluginModules(plugin.mainModule, actualModuleJars.values()) + checkOutputOfPluginModules(plugin.mainModule, actualModuleJars.values(), plugin.moduleExcludes) buildByLayout(layoutBuilder, plugin, "$targetDirectory/$plugin.directoryName", actualModuleJars) } } - private void checkOutputOfPluginModules(String mainPluginModule, Collection moduleNames) { - def modulesWithPluginXml = moduleNames.findAll { containsFileInOutput(it, "META-INF/plugin.xml") } + private void checkOutputOfPluginModules(String mainPluginModule, Collection moduleNames, MultiValuesMap moduleExcludes) { + def modulesWithPluginXml = moduleNames.findAll { containsFileInOutput(it, "META-INF/plugin.xml", moduleExcludes.get(it)) } if (modulesWithPluginXml.size() > 1) { buildContext.messages.error("Multiple modules (${modulesWithPluginXml.join(", ")}) from '$mainPluginModule' plugin contain plugin.xml files so the plugin won't work properly") } moduleNames.each { - if (containsFileInOutput(it, "com/intellij/uiDesigner/core/GridLayoutManager.class")) { + if (containsFileInOutput(it, "com/intellij/uiDesigner/core/GridLayoutManager.class", moduleExcludes.get(it))) { buildContext.messages.error("Runtime classes of GUI designer must not be packaged to '$mainPluginModule' plugin, because they are included into a platform JAR. " + "Make sure that 'Automatically copy form runtime classes to the output directory' is disabled in Settings | Editor | GUI Designer.") } } } - private boolean containsFileInOutput(String moduleName, String filePath) { - return new File(buildContext.projectBuilder.getModuleOutput(buildContext.findRequiredModule(moduleName), false), filePath).exists() + private boolean containsFileInOutput(String moduleName, String filePath, Collection excludes) { + def moduleOutput = new File(buildContext.projectBuilder.getModuleOutput(buildContext.findRequiredModule(moduleName), false)) + def fileInOutput = new File(moduleOutput, filePath) + return fileInOutput.exists() && (excludes == null || excludes.every { + createFileSet(it, moduleOutput).iterator().every { !(it instanceof FileProvider && FileUtil.filesEqual(it.file, fileInOutput))} + }) } private void buildByLayout(LayoutBuilder layoutBuilder, BaseLayout layout, String targetDirectory, MultiValuesMap moduleJars) { @@ -419,22 +424,26 @@ class DistributionJARsBuilder { moduleExcludes.entrySet().each { entry -> String module = entry.key entry.value.each { pattern -> - def fileSet = new FileSet() - fileSet.setProject(buildContext.ant.antProject) def moduleOutput = new File(buildContext.projectBuilder.getModuleOutput(buildContext.findRequiredModule(module), false)) if (!moduleOutput.exists()) { buildContext.messages.error("There are excludes defined for module '$module', but the module wasn't compiled; " + "most probably it means that '$module' isn't include into the product distribution so it makes no sense to define excludes for it.") } - fileSet.setDir(moduleOutput) - fileSet.createInclude().setName(pattern) - if (fileSet.size() == 0) { + if (createFileSet(pattern, moduleOutput).size() == 0) { buildContext.messages.error("Incorrect exludes for module '$module': nothing matches to $pattern in the module output") } } } } + private FileSet createFileSet(String pattern, File baseDir) { + def fileSet = new FileSet() + fileSet.setProject(buildContext.ant.antProject) + fileSet.setDir(baseDir) + fileSet.createInclude().setName(pattern) + return fileSet + } + static String basePath(BuildContext buildContext, String moduleName) { JpsPathUtil.urlToPath(buildContext.findRequiredModule(moduleName).contentRootsList.urls.first()) } From f0e316905e01fef4be5ad8e3f099531083148ae2 Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 14 Feb 2017 21:09:58 +0300 Subject: [PATCH 87/96] fixed typo in javadoc --- .../intellij/build/impl/DistributionJARsBuilder.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy index c9fbf392074b..f1c136aa5ffd 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy @@ -33,7 +33,7 @@ import org.jetbrains.jps.util.JpsPathUtil /** * Assembles output of modules to platform JARs (in {@link org.jetbrains.intellij.build.BuildPaths#distAll distAll}/lib directory), - * bunlded plugins' JARs (in {@link org.jetbrains.intellij.build.BuildPaths#distAll distAll}/plugins directory) and zip archives with + * bundled plugins' JARs (in {@link org.jetbrains.intellij.build.BuildPaths#distAll distAll}/plugins directory) and zip archives with * non-bundled plugins (in {@link org.jetbrains.intellij.build.BuildPaths#artifacts artifacts}/plugins directory). * * @author nik From 82ab213331946061fb84739d5b7a429ed4097a3c Mon Sep 17 00:00:00 2001 From: irengrig Date: Wed, 15 Feb 2017 10:12:12 +0100 Subject: [PATCH 88/96] WEB-25435 JSON Schema: referenced schemas should be treated as one for the validated file call invoke later with write action inside with file types change event in proper modality & condition --- .../jsonSchema/JsonSchemaMappingsProjectConfiguration.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsProjectConfiguration.java b/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsProjectConfiguration.java index b8ec30df259d..6c2ccaf41c06 100644 --- a/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsProjectConfiguration.java +++ b/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsProjectConfiguration.java @@ -1,9 +1,11 @@ package com.jetbrains.jsonSchema; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.components.*; import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Condition; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.xmlb.annotations.Transient; import org.jetbrains.annotations.NotNull; @@ -74,7 +76,7 @@ public class JsonSchemaMappingsProjectConfiguration extends JsonSchemaMappingsCo private void recalculateSchemaFiles() { ApplicationManager.getApplication().invokeLater(() -> { ApplicationManager.getApplication().runWriteAction(() -> FileTypeManagerEx.getInstanceEx().fireFileTypesChanged()); - }, o -> !myProject.isDisposed()); + }, ModalityState.NON_MODAL, myProject == null ? Condition.FALSE : myProject.getDisposed()); mySchemaFiles.clear(); if (myProject == null || myProject.getBaseDir() == null) return; From 20c985bb4de736b70e73ff4af155a53a057592c7 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Wed, 15 Feb 2017 12:33:12 +0300 Subject: [PATCH 89/96] [groovy] collect method info for original method if current is a mirror This change allows to add method infos for trait methods. --- .../plugins/groovy/extensions/GroovyMethodInfo.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java index 39e71c86ea88..c6b53496e4e5 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,10 +24,10 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall; +import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyNamesUtil; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder; import org.jetbrains.plugins.groovy.lang.resolve.ClosureMissingMethodContributor; -import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyNamesUtil; import org.jetbrains.plugins.groovy.util.FixedValuesReferenceProvider; import java.lang.reflect.Modifier; @@ -126,6 +126,13 @@ public class GroovyMethodInfo { if (methodKind instanceof String) { lightMethodInfos = getInfos(LIGHT_METHOD_INFOS, (String)methodKind, method); } + + if (method instanceof PsiMirrorElement) { + PsiElement prototype = ((PsiMirrorElement)method).getPrototype(); + if (prototype instanceof PsiMethod) { + method = (PsiMethod)prototype; + } + } List methodInfos = null; From ea307a27612b5d2946fcce756c12f89c82a6e35a Mon Sep 17 00:00:00 2001 From: "Vladislav.Soroka" Date: Wed, 15 Feb 2017 12:38:57 +0300 Subject: [PATCH 90/96] EA-96535 - NPE: UseDistributionWithSourcesNotificationProvider.showUseDistributionWithSourcesTip --- .../UseDistributionWithSourcesNotificationProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java index dada1a19dea8..5e44418d11f1 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java @@ -157,7 +157,7 @@ public class UseDistributionWithSourcesNotificationProvider extends EditorNotifi String distributionUri = wrapperConfiguration.getDistribution().toString(); try { String host = new URI(distributionUri).getHost(); - return host.endsWith("gradle.org") && !GRADLE_SRC_DISTRIBUTION_PATTERN.matcher(distributionUri).matches(); + return host != null && host.endsWith("gradle.org") && !GRADLE_SRC_DISTRIBUTION_PATTERN.matcher(distributionUri).matches(); } catch (URISyntaxException ignore) { } From 86b4323f51ac9b490debef6b39b631bed8020ae8 Mon Sep 17 00:00:00 2001 From: "alexey.afanasiev" Date: Wed, 15 Feb 2017 12:49:26 +0300 Subject: [PATCH 91/96] IDEA-166411 Twig plugin freezes on .groovy.twig files --- .../groovy/formatter/blocks/GroovyBlockGenerator.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlockGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlockGenerator.java index 301eaf6f5600..d54618609dbe 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlockGenerator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlockGenerator.java @@ -617,20 +617,20 @@ public class GroovyBlockGenerator { ArrayList childList = new ArrayList<>(); PsiFile groovyFile = psi.getContainingFile().getViewProvider().getPsi(GroovyLanguage.INSTANCE); if (groovyFile instanceof GroovyFileBase) { - addChildNodes(groovyFile, childList, range); + addChildNodes(groovyFile, childList, range, psi); } return childList.toArray(new ASTNode[childList.size()]); } return node.getChildren(null); } - private static void addChildNodes(PsiElement elem, ArrayList childNodes, TextRange range) { + private static void addChildNodes(PsiElement elem, ArrayList childNodes, TextRange range, PsiElement root) { ASTNode node = elem.getNode(); - if (range.contains(elem.getTextRange()) && node != null) { + if (range.contains(elem.getTextRange()) && node != null && elem != root) { childNodes.add(node); } else { for (PsiElement child : elem.getChildren()) { - addChildNodes(child, childNodes, range); + addChildNodes(child, childNodes, range, root); } } From 0273eab1196751916f09c63ec01e51312e75c339 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 15 Feb 2017 11:04:31 +0100 Subject: [PATCH 92/96] Cleanup (warnings) --- .../codeInspection/javaDoc/JavadocHtmlLintAnnotator.kt | 6 ++---- .../codeInspection/javaDoc/JavadocHtmlLintInspection.kt | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavadocHtmlLintAnnotator.kt b/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavadocHtmlLintAnnotator.kt index 8c534ddaef10..ba5c2402d4a4 100644 --- a/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavadocHtmlLintAnnotator.kt +++ b/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavadocHtmlLintAnnotator.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,9 +46,7 @@ import com.intellij.psi.util.PsiTreeUtil import com.sun.tools.doclint.DocLint import java.io.File -class JavadocHtmlLintAnnotator() : - ExternalAnnotator() { - +class JavadocHtmlLintAnnotator : ExternalAnnotator() { data class Info(val file: PsiFile) data class Anno(val row: Int, val col: Int, val error: Boolean, val message: String) data class Result(val annotations: List) diff --git a/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavadocHtmlLintInspection.kt b/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavadocHtmlLintInspection.kt index a174ec94b592..c722bde3d2d8 100644 --- a/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavadocHtmlLintInspection.kt +++ b/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavadocHtmlLintInspection.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,5 +25,5 @@ class JavadocHtmlLintInspection : LocalInspectionTool(), ExternalAnnotatorBatchI val SHORT_NAME = "JavadocHtmlLint" } - override fun getBatchSuppressActions(element: PsiElement?) = SuppressQuickFix.EMPTY_ARRAY + override fun getBatchSuppressActions(element: PsiElement?): Array = SuppressQuickFix.EMPTY_ARRAY } \ No newline at end of file From cb82cb180fb2f38f368712cb0fada2a577c19bc0 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Wed, 15 Feb 2017 13:14:17 +0300 Subject: [PATCH 93/96] IDEA-168069 Join Lines throws array index out of bonds on an empty file --- .../intellij/codeInsight/editorActions/JoinLinesHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/JoinLinesHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/JoinLinesHandler.java index a541b4c1e030..9c92e968866c 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/JoinLinesHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/JoinLinesHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -142,6 +142,8 @@ public class JoinLinesHandler extends EditorActionHandler { @NotNull PsiFile psiFile, int startLine, Ref caretRestoreOffset) { + if (startLine >= doc.getLineCount() - 1) return; + docManager.doPostponedOperationsAndUnblockDocument(doc); docManager.commitDocument(doc); CharSequence text = doc.getCharsSequence(); From 8e0ee65e7702fadd594144ee6949ce21cc67429e Mon Sep 17 00:00:00 2001 From: Dmitriy Smirnov Date: Wed, 15 Feb 2017 10:46:55 +0000 Subject: [PATCH 94/96] Improve wording in the "Do you want to add to VCS..." messages I do not _say_ "No", but _choose_ it IDEA-131099 --- plugins/git4idea/src/git4idea/i18n/GitBundle.properties | 4 ++-- .../resources/org/zmlx/hg4idea/HgVcsMessages.properties | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/git4idea/src/git4idea/i18n/GitBundle.properties b/plugins/git4idea/src/git4idea/i18n/GitBundle.properties index d5524281af8b..3be3897da313 100644 --- a/plugins/git4idea/src/git4idea/i18n/GitBundle.properties +++ b/plugins/git4idea/src/git4idea/i18n/GitBundle.properties @@ -450,11 +450,11 @@ util.remote.renderer.none=None util.remote.renderer.normal={0}({1}) util.remote.renderer.self=Current repository vcs.unable.to.run.git=Unable to run git: {0} ({1}) -vfs.listener.add.single.prompt=Do you want to add the following file to Git?\n{0}\n\nIf you say No, you can still add it later manually. +vfs.listener.add.single.prompt=Do you want to add the following file to Git?\n{0}\n\nIf you choose No, you can still add it later manually. vfs.listener.add.single.title=Add File to Git vfs.listener.add.title=Add Files to Git vfs.listener.checking.ignored=Checking for ignored files -vfs.listener.delete.single.prompt=Do you want to delete the following file from Git?\n{0}\n\nIf you say No, you can still delete it later manually. +vfs.listener.delete.single.prompt=Do you want to delete the following file from Git?\n{0}\n\nIf you choose No, you can still delete it later manually. vfs.listener.delete.single.title=Delete File from Git vfs.listener.delete.title=Delete Files from Git diff --git a/plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties b/plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties index caafa202b9e9..83e2e3bfe968 100644 --- a/plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties +++ b/plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties @@ -24,7 +24,7 @@ hg4idea.commit=Commit hg4idea.add.title=Add files to Mercurial hg4idea.add.single.title=Add file to Mercurial -hg4idea.add.body=Do you want to add the following file to Mercurial?\n{0}\n\nIf you say NO, you can still add it later manually. +hg4idea.add.body=Do you want to add the following file to Mercurial?\n{0}\n\nIf you choose NO, you can still add it later manually. hg4idea.add.progress=Adding files to Mercurial hg4idea.clone.title=Clone Mercurial Repository @@ -91,7 +91,7 @@ hg4idea.push.branch=&Branch\: hg4idea.push.force=&Force push hg4idea.remove.single.title=Remove file from Mercurial -hg4idea.remove.single.body=Do you want to remove the following file from Mercurial?\n{0}\n\nIf you say NO, you can still remove it later manually. +hg4idea.remove.single.body=Do you want to remove the following file from Mercurial?\n{0}\n\nIf you choose NO, you can still remove it later manually. hg4idea.remove.multiple.title=Remove files from Mercurial hg4idea.remove.progress=Removing files from the VCS... From fa5b649764e296d96417a4dc95bb2c1abf89ea7d Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 15 Feb 2017 11:55:28 +0100 Subject: [PATCH 95/96] resolve less references during groovy import optimization --- .../plugins/groovy/lang/psi/util/GroovyImportUtil.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyImportUtil.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyImportUtil.java index dd9d861a0e05..4f4308b55701 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyImportUtil.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyImportUtil.java @@ -27,6 +27,7 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor; import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement; +import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.packaging.GrPackageDefinition; import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement; import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyImportHelper; import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; @@ -54,13 +55,17 @@ public class GroovyImportUtil { file.accept(new PsiRecursiveElementWalkingVisitor() { @Override public void visitElement(PsiElement element) { - super.visitElement(element); + if (!(element instanceof GrImportStatement) && !(element instanceof GrPackageDefinition)) { + super.visitElement(element); + } if (element instanceof GrReferenceElement) { visitRefElement((GrReferenceElement)element); } } private void visitRefElement(GrReferenceElement refElement) { + if (refElement.isQualified()) return; + final String refName = refElement.getReferenceName(); if ("super".equals(refName)) return; From 0a4c6567302892bb8c3ff38fc04d11b5b2cbc424 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 15 Feb 2017 13:59:48 +0300 Subject: [PATCH 96/96] RequiredAttributesInspection extracted from XmlHighlightVisitor --- .../htmlInspections/HtmlLocalInspectionTool.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/HtmlLocalInspectionTool.java b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/HtmlLocalInspectionTool.java index 97d95a41c9ac..d9dbac6c19c2 100644 --- a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/HtmlLocalInspectionTool.java +++ b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/HtmlLocalInspectionTool.java @@ -24,6 +24,7 @@ import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.PsiWhiteSpace; import com.intellij.psi.XmlElementVisitor; import com.intellij.psi.templateLanguages.OuterLanguageElement; +import com.intellij.psi.tree.IElementType; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlTag; import com.intellij.psi.xml.XmlToken; @@ -61,7 +62,8 @@ public abstract class HtmlLocalInspectionTool extends XmlSuppressableInspectionT public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) { return new XmlElementVisitor() { @Override public void visitXmlToken(final XmlToken token) { - if (token.getTokenType() == XmlTokenType.XML_NAME) { + IElementType tokenType = token.getTokenType(); + if (tokenType == XmlTokenType.XML_NAME || tokenType == XmlTokenType.XML_TAG_NAME) { PsiElement element = token.getPrevSibling(); while(element instanceof PsiWhiteSpace) element = element.getPrevSibling();