From fcc06c29fa43773d1ae7e0c77bef72a17e67e0c6 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Thu, 6 Nov 2014 12:09:21 +0100 Subject: [PATCH 01/16] Array to xml refactored. --- python/helpers/pydev/pydev_console_utils.py | 15 +++++++ python/helpers/pydev/pydevd_comm.py | 45 +-------------------- python/helpers/pydev/pydevd_vars.py | 44 ++++++++++++++++++++ 3 files changed, 60 insertions(+), 44 deletions(-) diff --git a/python/helpers/pydev/pydev_console_utils.py b/python/helpers/pydev/pydev_console_utils.py index 6e532183b0d1..f519db6d191f 100644 --- a/python/helpers/pydev/pydev_console_utils.py +++ b/python/helpers/pydev/pydev_console_utils.py @@ -385,6 +385,21 @@ class BaseInterpreterInterface: return xml + def getArray(self, attr): + xml = "" + valDict = pydevd_vars.resolveVar(self.getNamespace(), attributes) + if valDict is None: + valDict = {} + + keys = valDict.keys() + + for k in keys: + xml += pydevd_vars.varToXML(valDict[k], to_string(k)) + + xml += "" + + return xml + def changeVariable(self, attr, value): def do_change_variable(): Exec('%s=%s' % (attr, value), self.getNamespace(), self.getNamespace()) diff --git a/python/helpers/pydev/pydevd_comm.py b/python/helpers/pydev/pydevd_comm.py index d26c965c88bd..5727b2d8f790 100644 --- a/python/helpers/pydev/pydevd_comm.py +++ b/python/helpers/pydev/pydevd_comm.py @@ -968,8 +968,6 @@ class InternalGetVariable(InternalThreadCommand): #======================================================================================================================= from pydevd_vars import getVariable -MAXIMUM_ARRAY_SIZE = 300 - class InternalGetArray(InternalThreadCommand): def __init__(self, seq, roffset, coffset, rows, cols, format, thread_id, frame_id, scope, attrs): self.sequence = seq @@ -988,50 +986,9 @@ class InternalGetArray(InternalThreadCommand): try: var = getVariable(self.thread_id, self.frame_id, 'EXPRESSION', self.attrs) - rows = min(self.rows, MAXIMUM_ARRAY_SIZE) - cols = min(self.cols, MAXIMUM_ARRAY_SIZE) - - if self.rows == 1 and self.cols == 1: - rows = 1 - cols = 1 - elif self.rows == 1 or self.cols == 1: - is_row = True if (self.rows == 1) else False - pure_1d = False if (len(var) == 1) else True - - if not pure_1d: - var = var[0] - - if is_row: - var = var[self.coffset:] - cols = min(cols, len(var)) - else: - var = var[self.roffset:] - rows = min(rows, len(var)) - else: - var = var[self.roffset:, self.coffset:] - rows = min(rows, len(var)) - cols = min(cols, len(var[0])) - xml = "" - xml += "" % (self.name, rows, cols) - for row in range(rows): - xml += "" % to_string(row) - for col in range(cols): - value = var - name = '%s[%s][%s]' % (self.name, row, col) - if self.rows == 1 or self.cols == 1: - if self.rows == 1 and self.cols == 1: - value = var - name = '%s' % self.name - else: - dim = col if (self.rows == 1) else row - value = var[dim] - name = '%s[%s]' % (self.name, dim) - else: - value = var[row][col] - value = self.format % value - xml += pydevd_vars.varToXML(value, name) + xml += pydevd_vars.array_to_xml(var, self.roffset, self.coffset, self.rows, self.cols, self.format) xml += "" cmd = dbg.cmdFactory.makeGetArrayMessage(self.sequence, xml) diff --git a/python/helpers/pydev/pydevd_vars.py b/python/helpers/pydev/pydevd_vars.py index b2df11eb410e..56c350034969 100644 --- a/python/helpers/pydev/pydevd_vars.py +++ b/python/helpers/pydev/pydevd_vars.py @@ -19,6 +19,7 @@ import _pydev_threading as threading import traceback import pydevd_save_locals from pydev_imports import Exec, quote, execfile +from pydevd_utils import to_string try: import types @@ -387,6 +388,49 @@ def changeAttrExpression(thread_id, frame_id, attr, expression, dbg): except Exception: traceback.print_exc() +MAXIMUM_ARRAY_SIZE = 300 + +def array_to_xml(array, roffset, coffset, rows, cols, format): + xml = "" + rows = min(rows, MAXIMUM_ARRAY_SIZE) + cols = min(cols, MAXIMUM_ARRAY_SIZE) + if rows == 1 and cols == 1: + rows = 1 + cols = 1 + elif rows == 1 or cols == 1: + is_row = True if (rows == 1) else False + pure_1d = False if (len(array) == 1) else True + + if not pure_1d: + array = array[0] + + if is_row: + array = array[coffset:] + cols = min(cols, len(array)) + else: + array = array[roffset:] + rows = min(rows, len(array)) + else: + array = array[roffset:, coffset:] + rows = min(rows, len(array)) + cols = min(cols, len(array[0])) + xml += "" % (rows, cols) + for row in range(rows): + xml += "" % to_string(row) + for col in range(cols): + value = array + if rows == 1 or cols == 1: + if rows == 1 and cols == 1: + value = array + else: + dim = col if (rows == 1) else row + value = array[dim] + else: + value = array[row][col] + value = format % value + xml += varToXML(value, '') + return xml + From 94fe193eb99cdec8c4197058883f8afa2e442484 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Thu, 6 Nov 2014 14:26:18 +0300 Subject: [PATCH 02/16] fixed PY-14284 IPython Notebook: shortcuts scope should depend on the focus for non-code cells --- python/ipnb/resources/META-INF/plugin.xml | 8 ++++---- .../ipnb/editor/panels/IpnbFilePanel.java | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/python/ipnb/resources/META-INF/plugin.xml b/python/ipnb/resources/META-INF/plugin.xml index ff23491042f9..180d2057386f 100644 --- a/python/ipnb/resources/META-INF/plugin.xml +++ b/python/ipnb/resources/META-INF/plugin.xml @@ -45,10 +45,10 @@ - - - - + + + + diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/IpnbFilePanel.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/IpnbFilePanel.java index 4d55d679e15e..a21ab2b9aedb 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/IpnbFilePanel.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/panels/IpnbFilePanel.java @@ -22,6 +22,7 @@ import org.jetbrains.plugins.ipnb.format.cells.output.IpnbOutputCell; import javax.swing.*; import java.awt.*; +import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -285,6 +286,22 @@ public class IpnbFilePanel extends JPanel implements Scrollable, DataProvider { } } } + else if (e.getKeyCode() == KeyEvent.VK_DELETE) { + if (!mySelectedCell.isEditing()) + deleteCell(mySelectedCell); + } + else if (e.getKeyCode() == KeyEvent.VK_X && e.getModifiers() == InputEvent.CTRL_MASK) { + if (!mySelectedCell.isEditing()) + cutCell(); + } + else if (e.getKeyCode() == KeyEvent.VK_C && e.getModifiers() == InputEvent.CTRL_MASK) { + if (!mySelectedCell.isEditing()) + copyCell(); + } + else if (e.getKeyCode() == KeyEvent.VK_V && e.getModifiers() == InputEvent.CTRL_MASK) { + if (!mySelectedCell.isEditing()) + pasteCell(); + } else { getParent().dispatchEvent(e); } From c719bad4a9e1a38adf70e00ecf6a01ef46d55f13 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Thu, 6 Nov 2014 14:40:19 +0300 Subject: [PATCH 03/16] fixed PY-14300 IPython Notebook: not able to start server on Windows: ipython server runner is not found --- .../configuration/IpnbConnectionManager.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConnectionManager.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConnectionManager.java index 411b9cc04a49..808673efaba2 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConnectionManager.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/configuration/IpnbConnectionManager.java @@ -1,5 +1,6 @@ package org.jetbrains.plugins.ipnb.configuration; +import com.google.common.collect.ImmutableMap; import com.intellij.execution.ExecutionException; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.process.KillableColoredProcessHandler; @@ -20,6 +21,7 @@ import com.intellij.openapi.ui.popup.BalloonBuilder; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.jetbrains.python.PythonHelpersLocator; import com.jetbrains.python.sdk.PythonSdkType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -102,7 +104,7 @@ public final class IpnbConnectionManager implements ProjectComponent { long time = System.currentTimeMillis() - startTime; while (time < 5000) { final String line = reader.readLine(); - if (line.contains("The IPython Notebook is running")) { + if (line != null && line.contains("The IPython Notebook is running")) { break; } time = System.currentTimeMillis() - startTime; @@ -185,16 +187,11 @@ public final class IpnbConnectionManager implements ProjectComponent { showWarning(fileEditor, "Please check Python Interpreter in Settings->Python Interpreter"); return false; } - final VirtualFile directory = sdk.getHomeDirectory(); - if (directory == null) return false; - final VirtualFile ipython = directory.getParent().findChild("ipython"); - if (ipython == null) { - showWarning(fileEditor, "Could not find Ipython Notebook in selected interpreter"); - return false; - } + final Map env = ImmutableMap.of("PYCHARM_EP_DIST", "ipython", "PYCHARM_EP_NAME", "ipython"); try { - final GeneralCommandLine commandLine = new GeneralCommandLine(ipython.getPath(), "notebook", "--no-browser"). - withWorkDirectory(myProject.getBasePath()); + final String ipython = PythonHelpersLocator.getHelperPath("pycharm/pycharm_load_entry_point.py"); + final GeneralCommandLine commandLine = new GeneralCommandLine(sdk.getHomePath(), ipython, "notebook", "--no-browser"). + withWorkDirectory(myProject.getBasePath()).withEnvironment(env); myProcessHandler = new KillableColoredProcessHandler(commandLine); From 620be4e708f45272099f099ae03bbd55fafd67fb Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 4 Nov 2014 15:41:45 +0100 Subject: [PATCH 04/16] use JBColor functions to avoid colors caching (cherry picked from commit 0bd6ff0f93b5ba0f5525f04674b944495e140bfb) --- .../util/src/com/intellij/util/ui/UIUtil.java | 101 ++++++++++-------- 1 file changed, 56 insertions(+), 45 deletions(-) diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 47f5990554a3..893eb1d636b3 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -680,11 +680,11 @@ public class UIUtil { } public static Color getLabelBackground() { - return UIManager.getColor("Label.background"); + return getColor("Label.background"); } public static Color getLabelForeground() { - return UIManager.getColor("Label.foreground"); + return getColor("Label.foreground"); } public static Color getLabelDisabledForeground() { @@ -734,11 +734,11 @@ public class UIUtil { } public static Color getTableHeaderBackground() { - return UIManager.getColor("TableHeader.background"); + return getColor("TableHeader.background"); } public static Color getTreeTextForeground() { - return UIManager.getColor("Tree.textForeground"); + return getColor("Tree.textForeground"); } public static Color getTreeSelectionBackground() { @@ -748,23 +748,22 @@ public class UIUtil { color = UIManager.getColor("nimbusSelectionBackground"); if (color != null) return color; } - return UIManager.getColor("Tree.selectionBackground"); + return getColor("Tree.selectionBackground"); } public static Color getTreeTextBackground() { - return UIManager.getColor("Tree.textBackground"); + return getColor("Tree.textBackground"); } public static Color getListSelectionForeground() { - final Color color = UIManager.getColor("List.selectionForeground"); - if (color == null) { + if (isUnderNimbusLookAndFeel()) { return UIManager.getColor("List[Selected].textForeground"); // Nimbus } - return color; + return getColor("List.selectionForeground"); } public static Color getFieldForegroundColor() { - return UIManager.getColor("field.foreground"); + return getColor("field.foreground"); } public static Color getTableSelectionBackground() { @@ -774,11 +773,23 @@ public class UIUtil { color = UIManager.getColor("nimbusSelectionBackground"); if (color != null) return color; } - return UIManager.getColor("Table.selectionBackground"); + return getColor("Table.selectionBackground"); } public static Color getActiveTextColor() { - return UIManager.getColor("textActiveText"); + return getColor("textActiveText"); + } + + @NotNull + private static Color getColor(final String property) { + return new JBColor(new NotNullProducer() { + @NotNull + @Override + public Color produce() { + final Color color = UIManager.getColor(property); + return color == null ? Gray.TRANSPARENT : color; + } + }); } public static Color getInactiveTextColor() { @@ -798,7 +809,7 @@ public class UIUtil { } public static Color getInactiveTextFieldBackgroundColor() { - return UIManager.getColor("TextField.inactiveBackground"); + return getColor("TextField.inactiveBackground"); } public static Font getTreeFont() { @@ -810,7 +821,7 @@ public class UIUtil { } public static Color getTreeSelectionForeground() { - return UIManager.getColor("Tree.selectionForeground"); + return getColor("Tree.selectionForeground"); } /** @@ -829,7 +840,7 @@ public class UIUtil { } public static Color getTreeSelectionBorderColor() { - return UIManager.getColor("Tree.selectionBorderColor"); + return getColor("Tree.selectionBorderColor"); } public static int getTreeRightChildIndent() { @@ -841,23 +852,23 @@ public class UIUtil { } public static Color getToolTipBackground() { - return UIManager.getColor("ToolTip.background"); + return getColor("ToolTip.background"); } public static Color getToolTipForeground() { - return UIManager.getColor("ToolTip.foreground"); + return getColor("ToolTip.foreground"); } public static Color getComboBoxDisabledForeground() { - return UIManager.getColor("ComboBox.disabledForeground"); + return getColor("ComboBox.disabledForeground"); } public static Color getComboBoxDisabledBackground() { - return UIManager.getColor("ComboBox.disabledBackground"); + return getColor("ComboBox.disabledBackground"); } public static Color getButtonSelectColor() { - return UIManager.getColor("Button.select"); + return getColor("Button.select"); } public static Integer getPropertyMaxGutterIconWidth(final String propertyPrefix) { @@ -865,7 +876,7 @@ public class UIUtil { } public static Color getMenuItemDisabledForeground() { - return UIManager.getColor("MenuItem.disabledForeground"); + return getColor("MenuItem.disabledForeground"); } public static Object getMenuItemDisabledForegroundObject() { @@ -882,7 +893,7 @@ public class UIUtil { public static Color getTableBackground() { // Under GTK+ L&F "Table.background" often has main panel color, which looks ugly - return isUnderGTKLookAndFeel() ? getTreeTextBackground() : UIManager.getColor("Table.background"); + return isUnderGTKLookAndFeel() ? getTreeTextBackground() : getColor("Table.background"); } public static Color getTableBackground(final boolean isSelected) { @@ -893,11 +904,11 @@ public class UIUtil { if (isUnderNimbusLookAndFeel()) { return UIManager.getColor("Table[Enabled+Selected].textForeground"); } - return UIManager.getColor("Table.selectionForeground"); + return getColor("Table.selectionForeground"); } public static Color getTableForeground() { - return UIManager.getColor("Table.foreground"); + return getColor("Table.foreground"); } public static Color getTableForeground(final boolean isSelected) { @@ -905,7 +916,7 @@ public class UIUtil { } public static Color getTableGridColor() { - return UIManager.getColor("Table.gridColor"); + return getColor("Table.gridColor"); } public static Color getListBackground() { @@ -915,7 +926,7 @@ public class UIUtil { return new Color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); } // Under GTK+ L&F "Table.background" often has main panel color, which looks ugly - return isUnderGTKLookAndFeel() ? getTreeTextBackground() : UIManager.getColor("List.background"); + return isUnderGTKLookAndFeel() ? getTreeTextBackground() : getColor("List.background"); } public static Color getListBackground(boolean isSelected) { @@ -923,7 +934,7 @@ public class UIUtil { } public static Color getListForeground() { - return UIManager.getColor("List.foreground"); + return getColor("List.foreground"); } public static Color getListForeground(boolean isSelected) { @@ -931,26 +942,26 @@ public class UIUtil { } public static Color getPanelBackground() { - return UIManager.getColor("Panel.background"); + return getColor("Panel.background"); } public static Color getTreeBackground() { - return UIManager.getColor("Tree.background"); + return getColor("Tree.background"); } public static Color getTreeForeground() { - return UIManager.getColor("Tree.foreground"); + return getColor("Tree.foreground"); } public static Color getTableFocusCellBackground() { - return UIManager.getColor(TABLE_FOCUS_CELL_BACKGROUND_PROPERTY); + return getColor(TABLE_FOCUS_CELL_BACKGROUND_PROPERTY); } public static Color getListSelectionBackground() { if (isUnderNimbusLookAndFeel()) { return UIManager.getColor("List[Selected].textBackground"); // Nimbus } - return UIManager.getColor("List.selectionBackground"); + return getColor("List.selectionBackground"); } public static Color getListUnfocusedSelectionBackground() { @@ -967,11 +978,11 @@ public class UIUtil { } public static Color getTextFieldForeground() { - return UIManager.getColor("TextField.foreground"); + return getColor("TextField.foreground"); } public static Color getTextFieldBackground() { - return isUnderGTKLookAndFeel() ? UIManager.getColor("EditorPane.background") : UIManager.getColor("TextField.background"); + return isUnderGTKLookAndFeel() ? UIManager.getColor("EditorPane.background") : getColor("TextField.background"); } public static Font getButtonFont() { @@ -983,7 +994,7 @@ public class UIUtil { } public static Color getTabbedPaneBackground() { - return UIManager.getColor("TabbedPane.background"); + return getColor("TabbedPane.background"); } public static void setSliderIsFilled(final JSlider slider, final boolean value) { @@ -991,11 +1002,11 @@ public class UIUtil { } public static Color getLabelTextForeground() { - return UIManager.getColor("Label.textForeground"); + return getColor("Label.textForeground"); } public static Color getControlColor() { - return UIManager.getColor("control"); + return getColor("control"); } public static Font getOptionPaneMessageFont() { @@ -1007,19 +1018,19 @@ public class UIUtil { } public static Color getSeparatorForeground() { - return UIManager.getColor("Separator.foreground"); + return getColor("Separator.foreground"); } public static Color getSeparatorBackground() { - return UIManager.getColor("Separator.background"); + return getColor("Separator.background"); } public static Color getSeparatorShadow() { - return UIManager.getColor("Separator.shadow"); + return getColor("Separator.shadow"); } public static Color getSeparatorHighlight() { - return UIManager.getColor("Separator.highlight"); + return getColor("Separator.highlight"); } public static Color getSeparatorColorUnderNimbus() { @@ -1054,7 +1065,7 @@ public class UIUtil { } public static Color getTableFocusCellForeground() { - return UIManager.getColor("Table.focusCellForeground"); + return getColor("Table.focusCellForeground"); } /** @@ -1149,15 +1160,15 @@ public class UIUtil { } public static Color getWindowColor() { - return UIManager.getColor("window"); + return getColor("window"); } public static Color getTextAreaForeground() { - return UIManager.getColor("TextArea.foreground"); + return getColor("TextArea.foreground"); } public static Color getOptionPaneBackground() { - return UIManager.getColor("OptionPane.background"); + return getColor("OptionPane.background"); } @SuppressWarnings({"HardCodedStringLiteral"}) From 2910486ed9250d2bd375a129aee74201be890dcc Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 4 Nov 2014 15:42:15 +0100 Subject: [PATCH 05/16] avoid double wrapping to JBColor (cherry picked from commit ec1e6584688a71954b52788ec584618a4ea3146d) --- platform/util/src/com/intellij/ui/JBColor.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/platform/util/src/com/intellij/ui/JBColor.java b/platform/util/src/com/intellij/ui/JBColor.java index 3669e725610d..cd204b3c00d8 100644 --- a/platform/util/src/com/intellij/ui/JBColor.java +++ b/platform/util/src/com/intellij/ui/JBColor.java @@ -250,23 +250,11 @@ public class JBColor extends Color { public static final Color CYAN = cyan; public static Color foreground() { - return new JBColor(new NotNullProducer() { - @NotNull - @Override - public Color produce() { - return UIUtil.getLabelForeground(); - } - }); + return UIUtil.getLabelForeground(); } public static Color background() { - return new JBColor(new NotNullProducer() { - @NotNull - @Override - public Color produce() { - return UIUtil.getListBackground(); - } - }); + return UIUtil.getListBackground(); } public static Color border() { From 051b7fbb9541277d142f1c58c534f397d206bafd Mon Sep 17 00:00:00 2001 From: "Vladislav.Soroka" Date: Thu, 6 Nov 2014 15:51:47 +0400 Subject: [PATCH 06/16] gradle: honor gradle dependency classifier IDEA-127178 IDEA sets up incorrect classpath, when Gradle artifact is included multiple times with different classifiers --- .../test/ExternalSystemTestCase.java | 47 +++++++++++++++++-- .../BaseGradleProjectResolverExtension.java | 14 ++++++ .../GradleDependenciesImportingTest.java | 33 +++++++++++++ 3 files changed, 91 insertions(+), 3 deletions(-) diff --git a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalSystemTestCase.java b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalSystemTestCase.java index 312a95844cf3..b4d45ef03ec8 100644 --- a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalSystemTestCase.java +++ b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalSystemTestCase.java @@ -23,7 +23,8 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.Result; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.command.WriteCommandAction; -import com.intellij.openapi.compiler.*; +import com.intellij.openapi.compiler.CompileScope; +import com.intellij.openapi.compiler.CompilerMessage; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.module.ModuleType; @@ -32,8 +33,12 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl; import com.intellij.openapi.roots.ModuleRootModificationUtil; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.io.ByteSequence; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; +import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; @@ -50,12 +55,15 @@ import org.junit.After; import org.junit.Before; import java.awt.*; -import java.io.File; -import java.io.IOException; +import java.io.*; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.*; import java.util.List; +import java.util.jar.Attributes; +import java.util.jar.JarEntry; +import java.util.jar.JarOutputStream; +import java.util.jar.Manifest; /** * @author Vladislav.Soroka @@ -337,6 +345,39 @@ public abstract class ExternalSystemTestCase extends UsefulTestCase { return LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f); } + @NotNull + protected VirtualFile createProjectJarSubFile(String relativePath, Pair... contentEntries) throws IOException { + assertTrue("Use 'jar' extension for JAR files: '" + relativePath + "'", FileUtilRt.extensionEquals(relativePath, "jar")); + File f = new File(getProjectPath(), relativePath); + FileUtil.ensureExists(f.getParentFile()); + FileUtil.ensureCanCreateFile(f); + final boolean created = f.createNewFile(); + if (!created) { + throw new AssertionError("Unable to create the project sub file: " + f.getAbsolutePath()); + } + + Manifest manifest = new Manifest(); + manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); + JarOutputStream target = new JarOutputStream(new FileOutputStream(f), manifest); + for (Pair contentEntry : contentEntries) { + addJarEntry(contentEntry.first.getBytes(), contentEntry.second, target); + } + target.close(); + + final VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f); + assertNotNull(virtualFile); + final VirtualFile jarFile = JarFileSystem.getInstance().getJarRootForLocalFile(virtualFile); + assertNotNull(jarFile); + return jarFile; + } + + private static void addJarEntry(byte[] bytes, String path, JarOutputStream target) throws IOException { + JarEntry entry = new JarEntry(path.replace("\\", "/")); + target.putNextEntry(entry); + target.write(bytes); + target.close(); + } + protected VirtualFile createProjectSubFile(String relativePath, String content) throws IOException { VirtualFile file = createProjectSubFile(relativePath); setFileContent(file, content, false); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java index f72df5528590..715fcd7d133d 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java @@ -68,6 +68,8 @@ import java.io.FilenameFilter; import java.io.IOException; import java.net.URL; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * {@link BaseGradleProjectResolverExtension} provides base implementation of Gradle project resolver. @@ -651,6 +653,18 @@ public class BaseGradleProjectResolverExtension implements GradleProjectResolver else { level = LibraryLevel.PROJECT; libraryName = String.format("%s:%s:%s", moduleVersion.getGroup(), moduleVersion.getName(), moduleVersion.getVersion()); + if (binaryPath.isFile()) { + String libraryFileName = FileUtil.getNameWithoutExtension(binaryPath); + final String mavenLibraryFileName = String.format("%s-%s", moduleVersion.getName(), moduleVersion.getVersion()); + if (!mavenLibraryFileName.equals(libraryFileName)) { + Pattern pattern = Pattern.compile(moduleVersion.getName() + "-" + moduleVersion.getVersion() + "-(.*)"); + Matcher matcher = pattern.matcher(libraryFileName); + if (matcher.matches()) { + final String classifier = matcher.group(1); + libraryName += (":" + classifier); + } + } + } } final LibraryData library = new LibraryData(GradleConstants.SYSTEM_ID, libraryName, unresolved); diff --git a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleDependenciesImportingTest.java b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleDependenciesImportingTest.java index 41bcbeffc8b5..393f93e97f08 100644 --- a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleDependenciesImportingTest.java +++ b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleDependenciesImportingTest.java @@ -16,6 +16,7 @@ package org.jetbrains.plugins.gradle.importing; import com.intellij.openapi.roots.DependencyScope; +import com.intellij.openapi.vfs.VirtualFile; import org.gradle.util.GradleVersion; import org.junit.Test; @@ -60,4 +61,36 @@ public class GradleDependenciesImportingTest extends GradleImportingTestCase { assertModuleLibDepScope("project", "Gradle: org.hamcrest:hamcrest-core:1.3", DependencyScope.TEST); assertModuleLibDepScope("project", "Gradle: junit:junit:4.11", DependencyScope.TEST); } + + @Test + public void testDependencyWithDifferentClassifiers() throws Exception { + final VirtualFile depJar = createProjectJarSubFile("lib/dep/dep/1.0/dep-1.0.jar"); + final VirtualFile depTestsJar = createProjectJarSubFile("lib/dep/dep/1.0/dep-1.0-tests.jar"); + + importProject( + "allprojects {\n" + + " apply plugin: 'java'\n" + + " sourceCompatibility = 1.5\n" + + " version = '1.0'\n" + + "\n" + + " repositories {\n" + + " mavenCentral()\n" + + " maven{ url file('lib') }\n" + + " }\n" + + "}\n" + + "\n" + + "dependencies {\n" + + " compile 'dep:dep:1.0'\n" + + " testCompile 'dep:dep:1.0:tests'\n" + + "}" + ); + + assertModules("project"); + + assertModuleLibDep("project", "Gradle: dep:dep:1.0", depJar.getUrl()); + assertModuleLibDepScope("project", "Gradle: dep:dep:1.0", DependencyScope.COMPILE); + + assertModuleLibDep("project", "Gradle: dep:dep:1.0:tests", depTestsJar.getUrl()); + assertModuleLibDepScope("project", "Gradle: dep:dep:1.0:tests", DependencyScope.TEST); + } } From 51b6a7117c11f197d8b2fd4d277b4a7e91d1584f Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Thu, 6 Nov 2014 13:34:52 +0100 Subject: [PATCH 07/16] Array viewer for console variables (PY-14182). --- python/helpers/pydev/pydev_console_utils.py | 19 ++- python/helpers/pydev/pydevconsole.py | 2 + python/helpers/pydev/pydevd_vars.py | 78 +++++------ .../python/debugger/PyFrameAccessor.java | 2 +- .../console/PydevConsoleCommunication.java | 37 +++++- .../debugger/array/AsyncArrayTableModel.java | 9 +- .../debugger/array/NumpyArrayTable.java | 123 ++++++++---------- 7 files changed, 147 insertions(+), 123 deletions(-) diff --git a/python/helpers/pydev/pydev_console_utils.py b/python/helpers/pydev/pydev_console_utils.py index f519db6d191f..2980873cd323 100644 --- a/python/helpers/pydev/pydev_console_utils.py +++ b/python/helpers/pydev/pydev_console_utils.py @@ -385,16 +385,21 @@ class BaseInterpreterInterface: return xml - def getArray(self, attr): + def getArray(self, attr, roffset, coffset, rows, cols, format): xml = "" - valDict = pydevd_vars.resolveVar(self.getNamespace(), attributes) - if valDict is None: - valDict = {} + array = pydevd_vars.evalInContext(attr, self.getNamespace(), self.getNamespace()) - keys = valDict.keys() + xml += pydevd_vars.array_to_xml(array, roffset, coffset, rows, cols, format) - for k in keys: - xml += pydevd_vars.varToXML(valDict[k], to_string(k)) + xml += "" + + return xml + + def evaluate(self, expression): + xml = "" + result = pydevd_vars.evalInContext(expression, self.getNamespace(), self.getNamespace()) + + xml += pydevd_vars.varToXML(result, expression) xml += "" diff --git a/python/helpers/pydev/pydevconsole.py b/python/helpers/pydev/pydevconsole.py index f48f975f703f..19c6c944bea2 100644 --- a/python/helpers/pydev/pydevconsole.py +++ b/python/helpers/pydev/pydevconsole.py @@ -293,6 +293,8 @@ def start_server(host, port, interpreter): server.register_function(handshake) server.register_function(interpreter.connectToDebugger) server.register_function(interpreter.hello) + server.register_function(interpreter.getArray) + server.register_function(interpreter.evaluate) # Functions for GUI main loop integration server.register_function(interpreter.enableGui) diff --git a/python/helpers/pydev/pydevd_vars.py b/python/helpers/pydev/pydevd_vars.py index 56c350034969..d9e1d28c37c5 100644 --- a/python/helpers/pydev/pydevd_vars.py +++ b/python/helpers/pydev/pydevd_vars.py @@ -277,6 +277,43 @@ def customOperation(thread_id, frame_id, scope, attrs, style, code_or_file, oper traceback.print_exc() +def evalInContext(expression, globals, locals): + result = None + try: + result = eval(expression, globals, locals) + except Exception: + s = StringIO() + traceback.print_exc(file=s) + result = s.getvalue() + + try: + try: + etype, value, tb = sys.exc_info() + result = value + finally: + etype = value = tb = None + except: + pass + + result = ExceptionOnEvaluate(result) + + # Ok, we have the initial error message, but let's see if we're dealing with a name mangling error... + try: + if '__' in expression: + # Try to handle '__' name mangling... + split = expression.split('.') + curr = locals.get(split[0]) + for entry in split[1:]: + if entry.startswith('__') and not hasattr(curr, entry): + entry = '_%s%s' % (curr.__class__.__name__, entry) + curr = getattr(curr, entry) + + result = curr + except: + pass + return result + + def evaluateExpression(thread_id, frame_id, expression, doExec): '''returns the result of the evaluated expression @param doExec: determines if we should do an exec or an eval @@ -285,9 +322,6 @@ def evaluateExpression(thread_id, frame_id, expression, doExec): if frame is None: return - expression = str(expression.replace('@LINE@', '\n')) - - #Not using frame.f_globals because of https://sourceforge.net/tracker2/?func=detail&aid=2541355&group_id=85796&atid=577329 #(Names not resolved in generator expression in method) #See message: http://mail.python.org/pipermail/python-list/2009-January/526522.html @@ -296,6 +330,7 @@ def evaluateExpression(thread_id, frame_id, expression, doExec): updated_globals.update(frame.f_locals) #locals later because it has precedence over the actual globals try: + expression = str(expression.replace('@LINE@', '\n')) if doExec: try: @@ -312,42 +347,7 @@ def evaluateExpression(thread_id, frame_id, expression, doExec): return else: - result = None - try: - result = eval(expression, updated_globals, frame.f_locals) - except Exception: - s = StringIO() - traceback.print_exc(file=s) - result = s.getvalue() - - try: - try: - etype, value, tb = sys.exc_info() - result = value - finally: - etype = value = tb = None - except: - pass - - result = ExceptionOnEvaluate(result) - - # Ok, we have the initial error message, but let's see if we're dealing with a name mangling error... - try: - if '__' in expression: - # Try to handle '__' name mangling... - split = expression.split('.') - curr = frame.f_locals.get(split[0]) - for entry in split[1:]: - if entry.startswith('__') and not hasattr(curr, entry): - entry = '_%s%s' % (curr.__class__.__name__, entry) - curr = getattr(curr, entry) - - result = curr - except: - pass - - - return result + return evalInContext(expression, updated_globals, frame.f_locals) finally: #Should not be kept alive if an exception happens and this frame is kept in the stack. del updated_globals diff --git a/python/pydevSrc/com/jetbrains/python/debugger/PyFrameAccessor.java b/python/pydevSrc/com/jetbrains/python/debugger/PyFrameAccessor.java index 7ce55d3f2031..e4f68b797571 100644 --- a/python/pydevSrc/com/jetbrains/python/debugger/PyFrameAccessor.java +++ b/python/pydevSrc/com/jetbrains/python/debugger/PyFrameAccessor.java @@ -21,5 +21,5 @@ public interface PyFrameAccessor { @Nullable PyReferrersLoader getReferrersLoader(); - Object[][] getArrayItems(PyDebugValue var, int colOffset, int rowOffset, int rows, int cols, String format) throws PyDebuggerException; + Object[][] getArrayItems(PyDebugValue var, int rowOffset, int colOffset, int rows, int cols, String format) throws PyDebuggerException; } diff --git a/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java b/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java index d756e198765e..c27cfbe0ca0a 100644 --- a/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java +++ b/python/src/com/jetbrains/python/console/PydevConsoleCommunication.java @@ -63,6 +63,8 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl private static final String CONNECT_TO_DEBUGGER = "connectToDebugger"; private static final String HANDSHAKE = "handshake"; private static final String CLOSE = "close"; + private static final String EVALUATE = "evaluate"; + private static final String GET_ARRAY = "getArray"; /** * XML-RPC client for sending messages to the server. @@ -461,7 +463,21 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl @Override public PyDebugValue evaluate(String expression, boolean execute, boolean doTrunc) throws PyDebuggerException { - return null; //To change body of implemented methods use File | Settings | File Templates. + if (myClient != null) { + try { + Object ret = myClient.execute(EVALUATE, new Object[]{expression}); + if (ret instanceof String) { + return ProtocolParser.parseValue((String)ret, this); + } + else { + checkError(ret); + } + } + catch (Exception e) { + throw new PyDebuggerException("Evaluate in console failed", e); + } + } + return null; } @Nullable @@ -532,8 +548,23 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl } @Override - public Object[][] getArrayItems(PyDebugValue var, int colOffset, int rowOffset, int rows, int cols, String format) { - return new Object[][]{new Object[]{1, 2}, new Object[]{3, 4}}; + public Object[][] getArrayItems(PyDebugValue var, int rowOffset, int colOffset, int rows, int cols, String format) + throws PyDebuggerException { + if (myClient != null) { + try { + Object ret = myClient.execute(GET_ARRAY, new Object[]{var.getName(), rowOffset, colOffset, rows, cols, format}); + if (ret instanceof String) { + return ProtocolParser.parseArrayValues((String)ret, this); + } + else { + checkError(ret); + } + } + catch (Exception e) { + throw new PyDebuggerException("Evaluate in console failed", e); + } + } + return null; } /** diff --git a/python/src/com/jetbrains/python/debugger/array/AsyncArrayTableModel.java b/python/src/com/jetbrains/python/debugger/array/AsyncArrayTableModel.java index 97316d821925..278bde5f3eb7 100644 --- a/python/src/com/jetbrains/python/debugger/array/AsyncArrayTableModel.java +++ b/python/src/com/jetbrains/python/debugger/array/AsyncArrayTableModel.java @@ -56,8 +56,8 @@ public class AsyncArrayTableModel extends AbstractTableModel { @Override public Object[][] call() throws Exception { return value.getFrameAccessor() - .getArrayItems(slicedValue, key.first, key.second, Math.min(CHUNK_COL_SIZE, getRowCount() - key.first), - Math.min(CHUNK_ROW_SIZE, getColumnCount() - key.second), + .getArrayItems(slicedValue, key.first, key.second, Math.min(CHUNK_ROW_SIZE, getRowCount() - key.first), + Math.min(CHUNK_COL_SIZE, getColumnCount() - key.second), myProvider.getFormat()); } }); @@ -99,10 +99,11 @@ public class AsyncArrayTableModel extends AbstractTableModel { if (r < chunk.get().length) { if (c < chunk.get()[r].length) { - return myProvider.correctStringValue((String)chunk.get()[r][c]); + return myProvider.correctStringValue(chunk.get()[r][c]); } } - } else { + } + else { chunk.addListener(new Runnable() { @Override public void run() { diff --git a/python/src/com/jetbrains/python/debugger/array/NumpyArrayTable.java b/python/src/com/jetbrains/python/debugger/array/NumpyArrayTable.java index a169fc3d6521..d8e5a9ad0821 100644 --- a/python/src/com/jetbrains/python/debugger/array/NumpyArrayTable.java +++ b/python/src/com/jetbrains/python/debugger/array/NumpyArrayTable.java @@ -22,11 +22,14 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.RangeMarker; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; +import com.intellij.util.Consumer; import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.evaluation.XDebuggerEvaluator; import com.intellij.xdebugger.frame.XValue; import com.jetbrains.python.debugger.PyDebugValue; import com.jetbrains.python.debugger.PyDebuggerEvaluator; +import com.jetbrains.python.debugger.PyDebuggerException; +import com.jetbrains.python.debugger.PyFrameAccessor; import org.jetbrains.annotations.NotNull; import javax.management.InvalidAttributeValueException; @@ -197,8 +200,8 @@ public class NumpyArrayTable { return myValue; } - public PyDebuggerEvaluator getEvaluator() { - return myEvaluator; + public PyFrameAccessor getEvaluator() { + return myValue.getFrameAccessor(); } public void init() { @@ -244,10 +247,10 @@ public class NumpyArrayTable { } private void fillColorRange(@NotNull final Runnable returnToMain) { - XDebuggerEvaluator.XEvaluationCallback callback = new XDebuggerEvaluator.XEvaluationCallback() { + Consumer callback = new Consumer() { @Override - public void evaluated(@NotNull XValue result) { - String rawValue = ((PyDebugValue)result).getValue(); + public void consume(@NotNull PyDebugValue result) { + String rawValue = result.getValue(); double min; double max; String minValue = rawValue.substring(1, rawValue.indexOf(",")); @@ -271,11 +274,6 @@ public class NumpyArrayTable { myTableCellRenderer.setMax(max); returnToMain.run(); } - - @Override - public void errorOccurred(@NotNull String errorMessage) { - showError(errorMessage); - } }; if (getMaxRow(myShape) * getMaxColumn(myShape) > HUGE_ARRAY_SIZE) { @@ -284,7 +282,13 @@ public class NumpyArrayTable { } String evalTypeCommand = "[" + getNodeName() + ".min(), " + getNodeName() + ".max()]"; - getEvaluator().evaluate(evalTypeCommand, callback, null); + try { + PyDebugValue value = getEvaluator().evaluate(evalTypeCommand, true, false); + callback.consume(value); + } + catch (PyDebuggerException e) { + showError(e.getMessage()); + } } public String getDefaultPresentation() { @@ -341,42 +345,27 @@ public class NumpyArrayTable { } private void fillType(@NotNull final Runnable returnToMain) { - XDebuggerEvaluator.XEvaluationCallback callback = new XDebuggerEvaluator.XEvaluationCallback() { - @Override - public void evaluated(@NotNull XValue result) { - setDtypeKind(((PyDebugValue)result).getValue()); - returnToMain.run(); - } - - @Override - public void errorOccurred(@NotNull String errorMessage) { - showError(errorMessage); - } - }; String evalTypeCommand = getNodeName() + ".dtype.kind"; - getEvaluator().evaluate(evalTypeCommand, callback, null); + try { + PyDebugValue value = getEvaluator().evaluate(evalTypeCommand, true, false); + setDtypeKind(value.getValue()); + returnToMain.run(); + } + catch (PyDebuggerException e) { + showError(e.getMessage()); + } } private void fillShape(@NotNull final Runnable returnToMain) { - XDebuggerEvaluator.XEvaluationCallback callback = new XDebuggerEvaluator.XEvaluationCallback() { - @Override - public void evaluated(@NotNull XValue result) { - try { - setShape(parseShape(((PyDebugValue)result).getValue())); - returnToMain.run(); - } - catch (InvalidAttributeValueException e) { - errorOccurred(e.getMessage()); - } - } - - @Override - public void errorOccurred(@NotNull String errorMessage) { - showError(errorMessage); - } - }; String evalShapeCommand = getEvalShapeCommand(getNodeName()); - getEvaluator().evaluate(evalShapeCommand, callback, null); + try { + PyDebugValue value = getEvaluator().evaluate(evalShapeCommand, true, false); + setShape(parseShape(value.getValue())); + returnToMain.run(); + } + catch (Exception e) { + showError(e.getMessage()); + } } private int[] parseShape(String value) throws InvalidAttributeValueException { @@ -542,14 +531,20 @@ public class NumpyArrayTable { }; } - public String correctStringValue(@NotNull String value) { - String corrected = value; - if (isNumeric()) { - if (value.startsWith("\'") || value.startsWith("\"")) { - corrected = value.substring(1, value.length() - 1); + public String correctStringValue(@NotNull Object value) { + if (value instanceof String) { + String corrected = (String)value; + if (isNumeric()) { + if (corrected.startsWith("\'") || corrected.startsWith("\"")) { + corrected = corrected.substring(1, corrected.length() - 1); + } } + return corrected; } - return corrected; + else if (value instanceof Integer) { + return Integer.toString((Integer)value); + } + return value.toString(); } public void setDtypeKind(String dtype) { @@ -611,28 +606,18 @@ public class NumpyArrayTable { private void doReslice(final String newSlice, int[] shape) { if (shape == null) { - XDebuggerEvaluator.XEvaluationCallback callback = new XDebuggerEvaluator.XEvaluationCallback() { - @Override - public void evaluated(@NotNull XValue result) { - try { - int[] shape = parseShape(((PyDebugValue)result).getValue()); - if (!is2DShape(shape)) { - errorOccurred("Incorrect slice shape " + ((PyDebugValue)result).getValue() + "."); - } - doReslice(newSlice, shape); - } - catch (InvalidAttributeValueException e) { - errorOccurred(e.getMessage()); - } - } - - @Override - public void errorOccurred(@NotNull String errorMessage) { - showError(errorMessage); - } - }; String evalShapeCommand = getEvalShapeCommand(newSlice); - getEvaluator().evaluate(evalShapeCommand, callback, null); + try { + PyDebugValue result = getEvaluator().evaluate(evalShapeCommand, true, false); + shape = parseShape(((PyDebugValue)result).getValue()); + if (!is2DShape(shape)) { + showError("Incorrect slice shape " + ((PyDebugValue)result).getValue() + "."); + } + doReslice(newSlice, shape); + } + catch (Exception e) { + showError(e.getMessage()); + } return; } From 2e8e4a3a1d482d60918bab9fee63c8c5591cac03 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Thu, 6 Nov 2014 13:25:05 +0100 Subject: [PATCH 08/16] safely close output-to-target registry --- .../incremental/storage/BuildDataManager.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java index 5c2bd7887605..f7e6dda1307e 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java @@ -246,20 +246,24 @@ public class BuildDataManager implements StorageOwner { finally { try { closeSourceToOutputStorages(); - myOutputToTargetRegistry.close(); } finally { try { - closeStorage(mySrcToFormMap); + myOutputToTargetRegistry.close(); } finally { - final Mappings mappings = myMappings; - if (mappings != null) { - try { - mappings.close(); - } - catch (BuildDataCorruptedException e) { - throw e.getCause(); + try { + closeStorage(mySrcToFormMap); + } + finally { + final Mappings mappings = myMappings; + if (mappings != null) { + try { + mappings.close(); + } + catch (BuildDataCorruptedException e) { + throw e.getCause(); + } } } } From 197a04127938fd6ad028f6037a39affe5003707e Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Thu, 6 Nov 2014 13:45:20 +0100 Subject: [PATCH 09/16] Fix eval. --- .../python/debugger/array/NumpyArrayTable.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/python/src/com/jetbrains/python/debugger/array/NumpyArrayTable.java b/python/src/com/jetbrains/python/debugger/array/NumpyArrayTable.java index d8e5a9ad0821..97f7190e99ea 100644 --- a/python/src/com/jetbrains/python/debugger/array/NumpyArrayTable.java +++ b/python/src/com/jetbrains/python/debugger/array/NumpyArrayTable.java @@ -283,7 +283,7 @@ public class NumpyArrayTable { String evalTypeCommand = "[" + getNodeName() + ".min(), " + getNodeName() + ".max()]"; try { - PyDebugValue value = getEvaluator().evaluate(evalTypeCommand, true, false); + PyDebugValue value = getEvaluator().evaluate(evalTypeCommand, false, false); callback.consume(value); } catch (PyDebuggerException e) { @@ -347,7 +347,7 @@ public class NumpyArrayTable { private void fillType(@NotNull final Runnable returnToMain) { String evalTypeCommand = getNodeName() + ".dtype.kind"; try { - PyDebugValue value = getEvaluator().evaluate(evalTypeCommand, true, false); + PyDebugValue value = getEvaluator().evaluate(evalTypeCommand, false, false); setDtypeKind(value.getValue()); returnToMain.run(); } @@ -359,7 +359,7 @@ public class NumpyArrayTable { private void fillShape(@NotNull final Runnable returnToMain) { String evalShapeCommand = getEvalShapeCommand(getNodeName()); try { - PyDebugValue value = getEvaluator().evaluate(evalShapeCommand, true, false); + PyDebugValue value = getEvaluator().evaluate(evalShapeCommand, false, false); setShape(parseShape(value.getValue())); returnToMain.run(); } @@ -369,7 +369,12 @@ public class NumpyArrayTable { } private int[] parseShape(String value) throws InvalidAttributeValueException { - String shape = value.substring(0, value.indexOf('#')); + int index = value.indexOf('#'); + if (index == -1) { + LOG.error("Wrong shape format: " + value); + return new int[]{0, 0}; + } + String shape = value.substring(0, index); if (shape.equals("()")) { return new int[]{1, 1}; } @@ -608,7 +613,7 @@ public class NumpyArrayTable { if (shape == null) { String evalShapeCommand = getEvalShapeCommand(newSlice); try { - PyDebugValue result = getEvaluator().evaluate(evalShapeCommand, true, false); + PyDebugValue result = getEvaluator().evaluate(evalShapeCommand, false, false); shape = parseShape(((PyDebugValue)result).getValue()); if (!is2DShape(shape)) { showError("Incorrect slice shape " + ((PyDebugValue)result).getValue() + "."); From 6ff880772fc85d6112fb6bcae2e971d49762200c Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Thu, 6 Nov 2014 13:54:11 +0100 Subject: [PATCH 10/16] Fix NPE. --- .../python/debugger/array/NumpyArrayTable.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/python/src/com/jetbrains/python/debugger/array/NumpyArrayTable.java b/python/src/com/jetbrains/python/debugger/array/NumpyArrayTable.java index 97f7190e99ea..230e8c058974 100644 --- a/python/src/com/jetbrains/python/debugger/array/NumpyArrayTable.java +++ b/python/src/com/jetbrains/python/debugger/array/NumpyArrayTable.java @@ -167,11 +167,7 @@ public class NumpyArrayTable { } private void initSliceFieldActions() { - if (myComponent.getSliceTextField().getEditor() == null) { - LOG.error("Null editor in slice field."); - return; - } - myComponent.getSliceTextField().getEditor().getContentComponent().addKeyListener(new KeyAdapter() { + myComponent.getSliceTextField().addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { @@ -182,11 +178,7 @@ public class NumpyArrayTable { } private void initFormatFieldActions() { - if (myComponent.getFormatTextField().getEditor() == null) { - LOG.error("Null editor in format field."); - return; - } - myComponent.getFormatTextField().getEditor().getContentComponent().addKeyListener(new KeyAdapter() { + myComponent.getFormatTextField().addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { From 28d265f41679eefb00c9aa7a0b36ac8865589b17 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Thu, 6 Nov 2014 15:59:44 +0300 Subject: [PATCH 11/16] fixed PY-14273 Exception while opening ipython notebook --- .../ipnb/src/org/jetbrains/plugins/ipnb/format/IpnbParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/format/IpnbParser.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/format/IpnbParser.java index 059704b9edfc..f94dacce6577 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/format/IpnbParser.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/format/IpnbParser.java @@ -89,7 +89,7 @@ public class IpnbParser { } public static class IpnbFileRaw { - Map metadata = new HashMap(); + Map metadata = new HashMap(); int nbformat = 3; int nbformat_minor; IpnbWorksheet[] worksheets; From 393824df911ad6832010c5613c62fa1711761712 Mon Sep 17 00:00:00 2001 From: "Vladislav.Soroka" Date: Wed, 5 Nov 2014 13:38:47 +0400 Subject: [PATCH 12/16] gradle: ide-gradle resource compiler should honor inheritOutputDirs setting IDEA-132188 Separation of IDE compilation output and output of build tool (Gradle) seems broken (cherry picked from commit 1ce9fd7) --- ...leResourceCompilerConfigurationGenerator.java | 16 +++++++++++++--- .../execution/GradleOrderEnumeratorHandler.java | 5 +++-- 2 files changed, 16 insertions(+), 5 deletions(-) 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 52188f1fcb73..4d7daa373819 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java @@ -118,9 +118,6 @@ public class GradleResourceCompilerConfigurationGenerator { continue; } - final CompilerModuleExtension compilerModuleExtension = CompilerModuleExtension.getInstance(module); - assert compilerModuleExtension != null; - GradleModuleResourceConfiguration resourceConfig = new GradleModuleResourceConfiguration(); resourceConfig.id = new ModuleVersion(externalProject.getGroup(), externalProject.getName(), externalProject.getVersion()); resourceConfig.directory = FileUtil.toSystemIndependentName(externalProject.getProjectDir().getPath()); @@ -131,6 +128,19 @@ public class GradleResourceCompilerConfigurationGenerator { final ExternalSourceSet testSourcesSet = externalProject.getSourceSets().get("test"); addResources(resourceConfig.testResources, testSourcesSet, ExternalSystemSourceType.TEST_RESOURCE); + final CompilerModuleExtension compilerModuleExtension = CompilerModuleExtension.getInstance(module); + if(compilerModuleExtension != null && compilerModuleExtension.isCompilerOutputPathInherited()) { + String outputPath = VfsUtilCore.urlToPath(compilerModuleExtension.getCompilerOutputUrl()); + for (ResourceRootConfiguration resource : resourceConfig.resources) { + resource.targetPath = outputPath; + } + + String testOutputPath = VfsUtilCore.urlToPath(compilerModuleExtension.getCompilerOutputUrlForTests()); + for (ResourceRootConfiguration resource : resourceConfig.testResources) { + resource.targetPath = testOutputPath; + } + } + projectConfig.moduleConfigurations.put(module.getName(), resourceConfig); } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/GradleOrderEnumeratorHandler.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/GradleOrderEnumeratorHandler.java index ef4686409991..8e9e69eac1ff 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/GradleOrderEnumeratorHandler.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/GradleOrderEnumeratorHandler.java @@ -15,7 +15,6 @@ */ package org.jetbrains.plugins.gradle.execution; -import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ex.ApplicationEx; import com.intellij.openapi.components.ServiceManager; @@ -27,9 +26,9 @@ import com.intellij.openapi.externalSystem.model.project.ExternalSystemSourceTyp import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager; import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; import com.intellij.openapi.externalSystem.util.ExternalSystemConstants; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.CompilerModuleExtension; import com.intellij.openapi.roots.ModuleRootModel; import com.intellij.openapi.roots.OrderEnumerationHandler; import com.intellij.openapi.roots.OrderRootType; @@ -54,6 +53,8 @@ public class GradleOrderEnumeratorHandler extends OrderEnumerationHandler { @Override public boolean isApplicable(@NotNull Module module) { + CompilerModuleExtension compilerModuleExtension = CompilerModuleExtension.getInstance(module); + if (compilerModuleExtension != null && compilerModuleExtension.isCompilerOutputPathInherited()) return false; return ExternalSystemApiUtil.isExternalSystemAwareModule(GradleConstants.SYSTEM_ID, module); } From 1232d9e230fcd164284612dce09391d9d1092868 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 6 Nov 2014 14:28:45 +0100 Subject: [PATCH 13/16] Cleanup (warnings; typos; formatting) --- .../jps/model/java/impl/JavaSdkUtil.java | 9 +-- .../openapi/projectRoots/JdkUtil.java | 63 ++++++++----------- .../projectRoot/ProjectSdksModel.java | 30 +++++---- .../intellij/ide/actions/OpenFileAction.java | 6 +- 4 files changed, 49 insertions(+), 59 deletions(-) diff --git a/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaSdkUtil.java b/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaSdkUtil.java index 64ee02b8b9b3..07a344928368 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaSdkUtil.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaSdkUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.jetbrains.jps.model.java.impl; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; @@ -30,11 +31,11 @@ import java.util.Set; * @author nik */ public class JavaSdkUtil { - public static List getJdkClassesRoots(File home, boolean isJre) { + @NotNull + public static List getJdkClassesRoots(@NotNull File home, boolean isJre) { FileFilter jarFileFilter = new FileFilter() { @Override - @SuppressWarnings({"HardCodedStringLiteral"}) - public boolean accept(File f) { + public boolean accept(@NotNull File f) { return !f.isDirectory() && f.getName().endsWith(".jar"); } }; diff --git a/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java b/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java index 337909b318e5..5772c4c1e19c 100644 --- a/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java +++ b/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ import com.intellij.execution.configurations.SimpleJavaParameters; import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtilRt; import com.intellij.openapi.vfs.CharsetToolkit; @@ -61,16 +60,10 @@ public class JdkUtil { VirtualFile homeDirectory = jdk.getHomeDirectory(); if (homeDirectory == null) return null; - VirtualFile rtJar = homeDirectory.findFileByRelativePath("jre/lib/rt.jar"); - if (rtJar == null) { - rtJar = homeDirectory.findFileByRelativePath("lib/rt.jar"); - } - if (rtJar == null) { - rtJar = homeDirectory.findFileByRelativePath("jre/lib/vm.jar"); // for IBM jdk - } - if (rtJar == null) { - rtJar = homeDirectory.findFileByRelativePath("../Classes/classes.jar"); // for mac - } + VirtualFile rtJar = homeDirectory.findFileByRelativePath("jre/lib/rt.jar"); // JDK + if (rtJar == null) rtJar = homeDirectory.findFileByRelativePath("lib/rt.jar"); // JRE + if (rtJar == null) rtJar = homeDirectory.findFileByRelativePath("jre/lib/vm.jar"); // IBM JDK + if (rtJar == null) rtJar = homeDirectory.findFileByRelativePath("../Classes/classes.jar"); // Apple JDK if (rtJar == null) { String versionString = jdk.getVersionString(); @@ -107,17 +100,16 @@ public class JdkUtil { return null; } - public static boolean checkForJdk(final File homePath) { + public static boolean checkForJdk(@NotNull File homePath) { File binPath = new File(homePath.getAbsolutePath() + File.separator + "bin"); if (!binPath.exists()) return false; FileFilter fileFilter = new FileFilter() { @Override - @SuppressWarnings({"HardCodedStringLiteral"}) - public boolean accept(File f) { + public boolean accept(@NotNull File f) { if (f.isDirectory()) return false; - return Comparing.strEqual(FileUtil.getNameWithoutExtension(f), "javac") || - Comparing.strEqual(FileUtil.getNameWithoutExtension(f), "javah"); + String name = FileUtil.getNameWithoutExtension(f); + return "javac".equals(name) || "javah".equals(name); } }; File[] children = binPath.listFiles(fileFilter); @@ -126,16 +118,15 @@ public class JdkUtil { checkForRuntime(homePath.getAbsolutePath()); } - public static boolean checkForJre(String homePath) { + public static boolean checkForJre(@NotNull String homePath) { homePath = new File(FileUtil.toSystemDependentName(homePath)).getAbsolutePath(); File binPath = new File(homePath + File.separator + "bin"); if (!binPath.exists()) return false; FileFilter fileFilter = new FileFilter() { @Override - @SuppressWarnings({"HardCodedStringLiteral"}) - public boolean accept(File f) { - return !f.isDirectory() && Comparing.strEqual(FileUtil.getNameWithoutExtension(f), "java"); + public boolean accept(@NotNull File f) { + return !f.isDirectory() && "java".equals(FileUtil.getNameWithoutExtension(f)); } }; File[] children = binPath.listFiles(fileFilter); @@ -144,12 +135,12 @@ public class JdkUtil { checkForRuntime(homePath); } - public static boolean checkForRuntime(final String homePath) { - return new File(new File(new File(homePath, "jre"), "lib"), "rt.jar").exists() || - new File(new File(homePath, "lib"), "rt.jar").exists() || - new File(new File(new File(homePath, ".."), "Classes"), "classes.jar").exists() || // Apple JDK - new File(new File(new File(homePath, "jre"), "lib"), "vm.jar").exists() || // IBM JDK - new File(homePath, "classes").isDirectory(); // custom build + public static boolean checkForRuntime(@NotNull String homePath) { + return new File(homePath, "jre/lib/rt.jar").exists() || // JDK + new File(homePath, "lib/rt.jar").exists() || // JRE + new File(homePath, "../Classes/classes.jar").exists() || // Apple JDK + new File(homePath, "jre/lib/vm.jar").exists() || // IBM JDK + new File(homePath, "classes").isDirectory(); // custom build } public static GeneralCommandLine setupJVMCommandLine(final String exePath, @@ -258,7 +249,7 @@ public class JdkUtil { commandLine.addParameters(javaParameters.getProgramParametersList().getList()); - commandLine.setWorkDirectory(javaParameters.getWorkingDirectory()); + commandLine.withWorkDirectory(javaParameters.getWorkingDirectory()); return commandLine; } @@ -275,24 +266,24 @@ public class JdkUtil { } private static void appendEncoding(SimpleJavaParameters javaParameters, GeneralCommandLine commandLine, ParametersList parametersList) { - // Value of -Dfile.encoding and charset of GeneralCommandLine should be in sync in order process's input and output be correctly handled. + // Value of file.encoding and charset of GeneralCommandLine should be in sync in order process's input and output be correctly handled. String encoding = parametersList.getPropertyValue("file.encoding"); if (encoding == null) { Charset charset = javaParameters.getCharset(); if (charset == null) charset = EncodingManager.getInstance().getDefaultCharset(); if (charset == null) charset = CharsetToolkit.getDefaultSystemCharset(); - commandLine.addParameter("-Dfile.encoding=" + charset.name()); - commandLine.setCharset(charset); + if (charset != null) { + commandLine.addParameter("-Dfile.encoding=" + charset.name()); + commandLine.withCharset(charset); + } } else { try { Charset charset = Charset.forName(encoding); - commandLine.setCharset(charset); - } - catch (UnsupportedCharsetException ignore) { - } - catch (IllegalCharsetNameException ignore) { + commandLine.withCharset(charset); } + catch (UnsupportedCharsetException ignore) { } + catch (IllegalCharsetNameException ignore) { } } } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ProjectSdksModel.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ProjectSdksModel.java index 87df147a745f..1ccbeadddeb8 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ProjectSdksModel.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ProjectSdksModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.intellij.openapi.roots.ui.configuration.projectRoot; import com.intellij.openapi.actionSystem.AnAction; @@ -36,14 +35,15 @@ import com.intellij.openapi.util.Condition; import com.intellij.util.ArrayUtilRt; import com.intellij.util.Consumer; import com.intellij.util.EventDispatcher; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.*; /** - * User: anna - * Date: 05-Jun-2006 + * @author anna + * @since 05-Jun-2006 */ public class ProjectSdksModel implements SdkModel { private static final Logger LOG = Logger.getInstance("com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel"); @@ -116,7 +116,7 @@ public class ProjectSdksModel implements SdkModel { return myProjectSdks; } - public boolean isModified(){ + public boolean isModified() { return myModified; } @@ -201,7 +201,7 @@ public class ProjectSdksModel implements SdkModel { final SdkAdditionalData sdkAdditionalData = currItem.getSdkAdditionalData(); if (sdkAdditionalData instanceof ValidatableSdkAdditionalData) { try { - ((ValidatableSdkAdditionalData) sdkAdditionalData).checkValid(this); + ((ValidatableSdkAdditionalData)sdkAdditionalData).checkValid(this); } catch (ConfigurationException e) { if (rootConfigurable != null) { @@ -249,14 +249,12 @@ public class ProjectSdksModel implements SdkModel { final SdkType[] types = SdkType.getAllTypes(); for (final SdkType type : types) { if (filter != null && !filter.value(type)) continue; - final AnAction addAction = new DumbAwareAction(type.getPresentableName(), - null, - type.getIconForAddAction()) { - @Override - public void actionPerformed(AnActionEvent e) { - doAdd(parent, type, updateTree); - } - }; + final AnAction addAction = new DumbAwareAction(type.getPresentableName(), null, type.getIconForAddAction()) { + @Override + public void actionPerformed(@NotNull AnActionEvent e) { + doAdd(parent, type, updateTree); + } + }; group.add(addAction); } } @@ -290,8 +288,8 @@ public class ProjectSdksModel implements SdkModel { if (!sdkType.setupSdkPaths(newJdk, this)) return; if (newJdk.getVersionString() == null) { - Messages.showMessageDialog(ProjectBundle.message("sdk.java.corrupt.error", home), - ProjectBundle.message("sdk.java.corrupt.title"), Messages.getErrorIcon()); + String message = ProjectBundle.message("sdk.java.corrupt.error", home); + Messages.showMessageDialog(message, ProjectBundle.message("sdk.java.corrupt.title"), Messages.getErrorIcon()); } doAdd(newJdk, callback); diff --git a/platform/platform-impl/src/com/intellij/ide/actions/OpenFileAction.java b/platform/platform-impl/src/com/intellij/ide/actions/OpenFileAction.java index 55d4474787a4..5dc35db167f2 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/OpenFileAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/OpenFileAction.java @@ -49,7 +49,7 @@ import java.util.List; public class OpenFileAction extends AnAction implements DumbAware { @Override - public void actionPerformed(AnActionEvent e) { + public void actionPerformed(@NotNull AnActionEvent e) { final Project project = e.getProject(); final boolean showFiles = project != null || PlatformProjectOpenProcessor.getInstanceIfItExists() != null; final FileChooserDescriptor descriptor = showFiles ? new ProjectOrFileChooserDescriptor() : new ProjectOnlyFileChooserDescriptor(); @@ -141,7 +141,7 @@ public class OpenFileAction extends AnAction implements DumbAware { } } - // vanilla OpenProjectFileChooserDescriptor only accepts project files; this on is overridden to accept any files + // vanilla OpenProjectFileChooserDescriptor only accepts project files; this one is overridden to accept any files private static class ProjectOrFileChooserDescriptor extends OpenProjectFileChooserDescriptor { private final FileChooserDescriptor myStandardDescriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(); @@ -157,7 +157,7 @@ public class OpenFileAction extends AnAction implements DumbAware { @Override public boolean isFileSelectable(VirtualFile file) { - return file.isDirectory() ? super.isFileSelectable(file) : myStandardDescriptor.isFileSelectable(file); + return file.isDirectory() ? super.isFileSelectable(file) : myStandardDescriptor.isFileSelectable(file); } @Override From c4a5dcfdfc4deecd05f5e4ecd31d810ce0fdc87b Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Thu, 6 Nov 2014 14:46:41 +0100 Subject: [PATCH 14/16] Revert method rename for compatibility. --- .../com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java | 4 ++-- .../xdebugger/impl/ui/XDebuggerExpressionComboBox.java | 2 +- .../intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java | 2 +- .../jetbrains/python/debugger/array/ArrayTableCellEditor.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java index 05d56161bade..4d7d65fff3c5 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java @@ -142,7 +142,7 @@ public abstract class XDebuggerEditorBase { public abstract JComponent getComponent(); - protected abstract void setEditorText(XExpression text); + protected abstract void doSetText(XExpression text); public void setExpression(@Nullable XExpression text) { if (text == null) { @@ -174,7 +174,7 @@ public abstract class XDebuggerEditorBase { myChooseFactory.setDisabledIcon(IconLoader.getDisabledIcon(icon)); } - setEditorText(text); + doSetText(text); } @Nullable diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionComboBox.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionComboBox.java index eaff436919db..3039d2acda7f 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionComboBox.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionComboBox.java @@ -128,7 +128,7 @@ public class XDebuggerExpressionComboBox extends XDebuggerEditorBase { } @Override - protected void setEditorText(XExpression text) { + protected void doSetText(XExpression text) { if (myComboBox.getItemCount() > 0) { myComboBox.setSelectedIndex(0); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java index 386bca17e856..b2222ce556c5 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java @@ -69,7 +69,7 @@ public class XDebuggerMultilineEditor extends XDebuggerEditorBase { } @Override - protected void setEditorText(XExpression text) { + protected void doSetText(XExpression text) { myExpression = text; Language language = text.getLanguage(); FileType fileType = language != null ? language.getAssociatedFileType() : getEditorsProvider().getFileType(); diff --git a/python/src/com/jetbrains/python/debugger/array/ArrayTableCellEditor.java b/python/src/com/jetbrains/python/debugger/array/ArrayTableCellEditor.java index 6095d1d0047d..05ba00ebd17a 100644 --- a/python/src/com/jetbrains/python/debugger/array/ArrayTableCellEditor.java +++ b/python/src/com/jetbrains/python/debugger/array/ArrayTableCellEditor.java @@ -143,7 +143,7 @@ public class ArrayTableCellEditor extends AbstractCellEditor implements TableCel } @Override - protected void setEditorText(XExpression text) { + protected void doSetText(XExpression text) { myEditorTextField.setText(text.getExpression()); } From 660d0e796bee12d2037d094683882fe63e1461b8 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Thu, 6 Nov 2014 14:30:42 +0100 Subject: [PATCH 15/16] extra care for possible NPE during matching PsiClass implementations with null qname --- .../structuralsearch/impl/matcher/JavaMatchingVisitor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/JavaMatchingVisitor.java b/java/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/JavaMatchingVisitor.java index e963ec91c2fc..a540080d95d9 100644 --- a/java/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/JavaMatchingVisitor.java +++ b/java/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/JavaMatchingVisitor.java @@ -420,7 +420,7 @@ public class JavaMatchingVisitor extends JavaElementVisitor { (elements2 != null) ? elements2.getReferenceElements() : PsiElement.EMPTY_ARRAY ); } - + private boolean compareClasses(final PsiClass clazz, final PsiClass clazz2) { final PsiClass saveClazz = this.myClazz; final MatchContext.MatchedElementsListener oldListener = myMatchingVisitor.getMatchContext().getMatchedElementsListener(); @@ -838,6 +838,7 @@ public class JavaMatchingVisitor extends JavaElementVisitor { String text2; if (el2 instanceof PsiClass) { text2 = ((PsiClass)el2).getQualifiedName(); + if (text2 == null) text2 = el2.getText(); } else { text2 = el2.getText(); } From 14bf4ccd40a11e92f8add17cf981107e58c18b5e Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Thu, 6 Nov 2014 16:57:57 +0300 Subject: [PATCH 16/16] speed up python class rename (restricted search scope for __init__) --- .../python/refactoring/rename/RenamePyClassProcessor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/refactoring/rename/RenamePyClassProcessor.java b/python/src/com/jetbrains/python/refactoring/rename/RenamePyClassProcessor.java index b4917dd0767c..3f11c0505ee5 100644 --- a/python/src/com/jetbrains/python/refactoring/rename/RenamePyClassProcessor.java +++ b/python/src/com/jetbrains/python/refactoring/rename/RenamePyClassProcessor.java @@ -17,6 +17,7 @@ package com.jetbrains.python.refactoring.rename; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; +import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.util.Processor; import com.jetbrains.python.PyNames; @@ -67,7 +68,7 @@ public class RenamePyClassProcessor extends RenamePyElementProcessor { if (initMethod != null) { final List allRefs = Collections.synchronizedList(new ArrayList()); allRefs.addAll(super.findReferences(element)); - ReferencesSearch.search(initMethod).forEach(new Processor() { + ReferencesSearch.search(initMethod, GlobalSearchScope.projectScope(element.getProject())).forEach(new Processor() { @Override public boolean process(PsiReference psiReference) { if (psiReference.getCanonicalText().equals(((PyClass)element).getName())) {