From cd7200cb602a039975e7d11aea1f650b3aa2152d Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 18 Jun 2014 12:04:44 +0400 Subject: [PATCH 01/48] fixed PY-13286 Create New Project: missing arrow button in more settings --- .../src/com/intellij/ui/HideableDecorator.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/HideableDecorator.java b/platform/platform-impl/src/com/intellij/ui/HideableDecorator.java index e34f03ce6d93..b19d02ff67c2 100644 --- a/platform/platform-impl/src/com/intellij/ui/HideableDecorator.java +++ b/platform/platform-impl/src/com/intellij/ui/HideableDecorator.java @@ -53,6 +53,7 @@ public class HideableDecorator { }; myPanel.add(myTitledSeparator, BorderLayout.NORTH); myTitledSeparator.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + updateIcon(); myTitledSeparator.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { @@ -66,6 +67,12 @@ public class HideableDecorator { }); } + private void updateIcon() { + final Icon icon = myOn ? AllIcons.General.SplitDown : AllIcons.General.SplitRight; + myTitledSeparator.getLabel().setIcon(icon); + myTitledSeparator.getLabel().setDisabledIcon(IconLoader.getTransparentIcon(icon, 0.5f)); + } + public void setContentComponent(@Nullable JComponent content) { if (content == null && myContent != null) { myPanel.remove(myContent); @@ -101,8 +108,7 @@ public class HideableDecorator { protected void on() { myOn = true; - myTitledSeparator.getLabel().setIcon(AllIcons.General.SplitDown); - myTitledSeparator.getLabel().setDisabledIcon(IconLoader.getTransparentIcon(AllIcons.General.SplitDown, 0.5f)); + updateIcon(); myTitledSeparator.getLabel().setIconTextGap(5); if (myContent != null) { myContent.setVisible(true); @@ -114,8 +120,7 @@ public class HideableDecorator { protected void off() { myOn = false; - myTitledSeparator.getLabel().setIcon(AllIcons.General.SplitRight); - myTitledSeparator.getLabel().setDisabledIcon(IconLoader.getTransparentIcon(AllIcons.General.SplitRight, 0.5f)); + updateIcon(); if (myContent != null) { myContent.setVisible(false); myPreviousContentSize = myContent.getSize(); From 6cdf7e47e4bc2164c3e9dbecc4265a8690c43433 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 18 Jun 2014 14:09:14 +0400 Subject: [PATCH 02/48] moved plugin-specific project types to the different step --- platform/icons/src/nodes/pluginLogo.png | Bin 0 -> 945 bytes .../util/src/com/intellij/icons/AllIcons.java | 1 + .../newProject/PyCharmNewProjectDialog.java | 2 +- .../actions/AbstractProjectSettingsStep.java | 17 +++++--- .../actions/PluginSpecificProjectsStep.java | 37 ++++++++++++++++++ .../actions/PyCharmNewProjectStep.java | 12 +++++- 6 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 platform/icons/src/nodes/pluginLogo.png create mode 100644 python/ide/src/com/jetbrains/python/newProject/actions/PluginSpecificProjectsStep.java diff --git a/platform/icons/src/nodes/pluginLogo.png b/platform/icons/src/nodes/pluginLogo.png new file mode 100644 index 0000000000000000000000000000000000000000..83604cc023edb80f571ebc7c897c9486f6924b73 GIT binary patch literal 945 zcmV;i15W&jP)5G>QmxifRxHZ!OB zS=m)ycA=#rx|yw9rk3fIi=!u|a{H)F;JjVU|$ z%rzPfp-=oSSQUWIB57{-^#i2)#zE3sDqFIfQnm{)XP}@}0T`>#NU-S>$Uu2Kv1nyb z+!r?lpE-R(h0q+7``bM*^-!f7u2zsiLlUv-;)sQbTLi>5EP4(id3kxh%(bkZm=O)o zSri@7rXFSGN<% z@Lff|6Qa%oVgV3auy`7ec^fU4V1N#FR8Uv3)ZC|yB`;8aYB+Q!nT*sNqY&kztV~!L z`GUPlv5C)IR1>0jEaI90&#wI{7>xHn=ju?uiw1!2r*$Mepe? zjr~f^N6o2Zyg}*IJEWcip{L(j5OX$zVk4_3Jj?|FVBiGzlpM0yDiWMgPc)t&AMR(8 z$(Bqq(Uk5DqJj-!VdS%bh;Z$WP|Oq!MYzTKrU``<_Ju<<_ zXY3}$dT$ex7XVE+Ko=UjcN~TpE9U$Vs!C2dW?ok*!bJgK)P@Y`5C5PGJ77Xn&js*+ z0Hg;*tIFVnFt{P&rvVWr7@$`Z6Z$K9@8*0EA6r#MHw2v@fcVUY;4Q&WRq_3}81M-TJ;>Iqj?dej!|26g%h& zHFLCNsSr>d{zapO0MtT@P|2`4HPX?XF)I|n4M9r>fG6mqb-qqb{s2ZG;!+73F>+D_ z1kD%#8W4Sms6#0W;3Nxxs(7qkDF_15FJod}M$LmnpNd%k;ZOkwLJbHhAm)8VjbUX) zYnSne`E0)2z>y+Gun96KG&=|&h@VLXTDGNQI(Se?eV;6J(-z+e}&z&7MS%)7G` zkc$Zx?&n1O9SVakLQ9Y?&;S=$=5!k-v-)BUdqxBbK;nwl2JPk!rho(dx3}Y;HNA87 T9j1|-00000NkvXXu0mjfZ4IOr literal 0 HcmV?d00001 diff --git a/platform/util/src/com/intellij/icons/AllIcons.java b/platform/util/src/com/intellij/icons/AllIcons.java index 3f2ca2612e2f..142fd651655d 100644 --- a/platform/util/src/com/intellij/icons/AllIcons.java +++ b/platform/util/src/com/intellij/icons/AllIcons.java @@ -836,6 +836,7 @@ public class AllIcons { public static final Icon PinToolWindow = IconLoader.getIcon("/nodes/pinToolWindow.png"); // 13x13 public static final Icon Plugin = IconLoader.getIcon("/nodes/plugin.png"); // 16x16 public static final Icon PluginJB = IconLoader.getIcon("/nodes/pluginJB.png"); // 16x16 + public static final Icon PluginLogo = IconLoader.getIcon("/nodes/pluginLogo.png"); // 32x32 public static final Icon Pluginnotinstalled = IconLoader.getIcon("/nodes/pluginnotinstalled.png"); // 16x16 public static final Icon Pluginobsolete = IconLoader.getIcon("/nodes/pluginobsolete.png"); // 16x16 public static final Icon PluginRestart = IconLoader.getIcon("/nodes/pluginRestart.png"); // 16x16 diff --git a/python/ide/src/com/jetbrains/python/newProject/PyCharmNewProjectDialog.java b/python/ide/src/com/jetbrains/python/newProject/PyCharmNewProjectDialog.java index 61e7ecb0fdc9..30d07cac0073 100644 --- a/python/ide/src/com/jetbrains/python/newProject/PyCharmNewProjectDialog.java +++ b/python/ide/src/com/jetbrains/python/newProject/PyCharmNewProjectDialog.java @@ -53,7 +53,7 @@ public class PyCharmNewProjectDialog extends DialogWrapper { @Override public Dimension getMinimumSize() { - return new Dimension(800, 500); + return new Dimension(650, 350); } }; } diff --git a/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java b/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java index f276ccd6648f..9f8169e3c986 100644 --- a/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java +++ b/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java @@ -24,6 +24,7 @@ import com.intellij.platform.DirectoryProjectGenerator; import com.intellij.platform.WebProjectGenerator; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.JBColor; +import com.intellij.ui.components.JBScrollPane; import com.intellij.util.NullableConsumer; import com.intellij.util.ui.CenteredIcon; import com.jetbrains.python.PythonSdkChooserCombo; @@ -103,14 +104,20 @@ abstract public class AbstractProjectSettingsStep extends AbstractActionWithPane @Override public JPanel createPanel() { final JPanel mainPanel = new JPanel(new BorderLayout()); - mainPanel.setPreferredSize(new Dimension(mainPanel.getPreferredSize().width, 450)); + final JPanel scrollPanel = new JPanel(new BorderLayout()); + + mainPanel.setPreferredSize(new Dimension(mainPanel.getPreferredSize().width, 300)); final JPanel panel = createBasePanel(); - mainPanel.add(panel, BorderLayout.NORTH); - + scrollPanel.add(panel, BorderLayout.NORTH); final JPanel advancedSettings = createAdvancedSettings(); - if (advancedSettings != null) - mainPanel.add(advancedSettings, BorderLayout.CENTER); + if (advancedSettings != null) { + scrollPanel.add(advancedSettings, BorderLayout.CENTER); + } + final JBScrollPane scrollPane = new JBScrollPane(scrollPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, + ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + scrollPane.setBorder(null); + mainPanel.add(scrollPane, BorderLayout.CENTER); final JPanel bottomPanel = new JPanel(new BorderLayout()); myCreateButton = new Button(myCreateAction, myCreateAction.getTemplatePresentation()); diff --git a/python/ide/src/com/jetbrains/python/newProject/actions/PluginSpecificProjectsStep.java b/python/ide/src/com/jetbrains/python/newProject/actions/PluginSpecificProjectsStep.java new file mode 100644 index 000000000000..a0c5f6e52fbf --- /dev/null +++ b/python/ide/src/com/jetbrains/python/newProject/actions/PluginSpecificProjectsStep.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2013 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.jetbrains.python.newProject.actions; + +import com.intellij.icons.AllIcons; +import com.intellij.openapi.actionSystem.DefaultActionGroup; +import com.intellij.openapi.project.DumbAware; +import com.intellij.platform.DirectoryProjectGenerator; +import com.intellij.util.NullableConsumer; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public class PluginSpecificProjectsStep extends DefaultActionGroup implements DumbAware { + + public PluginSpecificProjectsStep(@NotNull final NullableConsumer callback, + @NotNull final List projectGenerators) { + super("Plugin-specific", true); + getTemplatePresentation().setIcon(AllIcons.Nodes.PluginLogo); + for (DirectoryProjectGenerator generator : projectGenerators) { + add(new ProjectSpecificAction(callback, generator)); + } + } +} diff --git a/python/ide/src/com/jetbrains/python/newProject/actions/PyCharmNewProjectStep.java b/python/ide/src/com/jetbrains/python/newProject/actions/PyCharmNewProjectStep.java index acdb46cc7d07..b6134ed5f070 100644 --- a/python/ide/src/com/jetbrains/python/newProject/actions/PyCharmNewProjectStep.java +++ b/python/ide/src/com/jetbrains/python/newProject/actions/PyCharmNewProjectStep.java @@ -15,6 +15,7 @@ */ package com.jetbrains.python.newProject.actions; +import com.google.common.collect.Lists; import com.intellij.ide.GeneralSettings; import com.intellij.ide.util.projectWizard.WebProjectTemplate; import com.intellij.internal.statistic.UsageTrigger; @@ -172,8 +173,17 @@ public class PyCharmNewProjectStep extends DefaultActionGroup implements DumbAwa return o1.getName().compareTo(o2.getName()); } }); + + List pluginSpecificGenerators = Lists.newArrayList(); for (DirectoryProjectGenerator generator : generators) { - add(new ProjectSpecificAction(callback, generator)); + if (generator instanceof PythonProjectGenerator) + add(new ProjectSpecificAction(callback, generator)); + else + pluginSpecificGenerators.add(generator); + } + + if (!pluginSpecificGenerators.isEmpty()) { + add(new PluginSpecificProjectsStep(callback, pluginSpecificGenerators)); } } From 8a3b6014d448edc6e63e691a6b52b01736af3710 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Wed, 18 Jun 2014 15:59:05 +0400 Subject: [PATCH 03/48] tune editor notification panel: add a small gear and get rid of a bulb [^berdnikova] --- .../intention/impl/FileLevelIntentionComponent.java | 11 ++++++++--- .../src/com/intellij/ui/EditorNotificationPanel.java | 11 +++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/FileLevelIntentionComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/FileLevelIntentionComponent.java index 6af5890fd4b9..f806287e8076 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/FileLevelIntentionComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/FileLevelIntentionComponent.java @@ -26,12 +26,14 @@ import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.JBPopupFactory; +import com.intellij.openapi.ui.popup.ListPopup; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiFile; import com.intellij.ui.ClickListener; import com.intellij.ui.EditorNotificationPanel; import com.intellij.ui.LightColors; +import com.intellij.ui.awt.RelativePoint; import org.jetbrains.annotations.NotNull; import java.awt.*; @@ -73,7 +75,7 @@ public class FileLevelIntentionComponent extends EditorNotificationPanel { } myLabel.setText(description); - myLabel.setIcon(SeverityRegistrar.getSeverityRegistrar(project).compare(severity, HighlightSeverity.ERROR) >= 0 ? AllIcons.Actions.QuickfixBulb : AllIcons.Actions.IntentionBulb); + myGearLabel.setIcon(AllIcons.General.Gear); new ClickListener() { @Override @@ -86,10 +88,13 @@ public class FileLevelIntentionComponent extends EditorNotificationPanel { step = step.getSubStep(actionWithTextCaching, null); } } - JBPopupFactory.getInstance().createListPopup(step).showUnderneathOf(myLabel); + ListPopup popup = JBPopupFactory.getInstance().createListPopup(step); + Dimension dimension = popup.getContent().getPreferredSize(); + Point at = new Point(-dimension.width + myGearLabel.getWidth(), FileLevelIntentionComponent.this.getHeight()); + popup.show(new RelativePoint(e.getComponent(), at)); return true; } - }.installOn(myLabel); + }.installOn(myGearLabel); } @Override diff --git a/platform/platform-api/src/com/intellij/ui/EditorNotificationPanel.java b/platform/platform-api/src/com/intellij/ui/EditorNotificationPanel.java index deb1f0545b74..2872a4592c01 100644 --- a/platform/platform-api/src/com/intellij/ui/EditorNotificationPanel.java +++ b/platform/platform-api/src/com/intellij/ui/EditorNotificationPanel.java @@ -36,11 +36,12 @@ import java.awt.*; */ public class EditorNotificationPanel extends JPanel { protected final JLabel myLabel = new JLabel(); + protected final JLabel myGearLabel = new JLabel(); protected final JPanel myLinksPanel; public EditorNotificationPanel() { super(new BorderLayout()); - setBorder(BorderFactory.createEmptyBorder(1, 15, 1, 15)); + setBorder(BorderFactory.createEmptyBorder(1, 10, 1, 10)); setPreferredSize(new Dimension(-1, 24)); @@ -48,7 +49,13 @@ public class EditorNotificationPanel extends JPanel { myLinksPanel = new JPanel(new FlowLayout()); myLinksPanel.setBackground(getBackground()); - add(myLinksPanel, BorderLayout.EAST); + + JPanel panel = new JPanel(new BorderLayout()); + panel.setBackground(getBackground()); + myGearLabel.setBorder(IdeBorderFactory.createEmptyBorder(0, 3, 0, 0)); + panel.add(myLinksPanel, BorderLayout.WEST); + panel.add(myGearLabel, BorderLayout.EAST); + add(panel, BorderLayout.EAST); } public void setText(String text) { From 963caa759a5fa7421909afc0272b8d4251f5e0fb Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 18 Jun 2014 13:33:22 +0200 Subject: [PATCH 04/48] inconsistent property ends inspection: SIOOBE on empty property value --- .../InconsistentPropertiesEndsInspectionProvider.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/inconsistentResourceBundle/InconsistentPropertiesEndsInspectionProvider.java b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/inconsistentResourceBundle/InconsistentPropertiesEndsInspectionProvider.java index ff1e8b6c1daf..9b5b96a035f3 100644 --- a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/inconsistentResourceBundle/InconsistentPropertiesEndsInspectionProvider.java +++ b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/inconsistentResourceBundle/InconsistentPropertiesEndsInspectionProvider.java @@ -19,6 +19,7 @@ import com.intellij.codeInspection.*; import com.intellij.codeInspection.reference.RefManager; import com.intellij.lang.properties.IProperty; import com.intellij.lang.properties.psi.PropertiesFile; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; import com.intellij.util.containers.BidirectionalMap; import com.intellij.util.containers.ContainerUtil; @@ -65,7 +66,7 @@ public class InconsistentPropertiesEndsInspectionProvider implements Inconsisten final IProperty property = file.findPropertyByKey(commonKey); assert property != null; final String propertyValue = property.getValue(); - if (propertyValue == null) { + if (StringUtil.isEmptyOrSpaces(propertyValue)) { continue; } final char lastChar = propertyValue.charAt(propertyValue.length() - 1); From 051bc986686002062599d9e10be9f5f67bae8f99 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 18 Jun 2014 14:01:30 +0200 Subject: [PATCH 05/48] ensure all modules in scope are initialized on graph built; write/read locks in case global inspections would run in parallel (EA-57418 - CME: THashIterator.nextIndex) --- .../reference/RefManagerImpl.java | 38 +++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java index c417f72e5b34..c5936df5f005 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java @@ -39,6 +39,7 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.extensions.ExtensionPoint; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectUtilCore; import com.intellij.openapi.util.Computable; @@ -294,7 +295,14 @@ public class RefManagerImpl extends RefManager { public void findAllDeclarations() { if (!myDeclarationsFound) { long before = System.currentTimeMillis(); - getScope().accept(myProjectIterator); + final AnalysisScope scope = getScope(); + scope.accept(myProjectIterator); + for (Module module : ModuleManager.getInstance(getProject()).getModules()) { + //init all ref modules in scope + if (scope.containsModule(module)) { + getRefModule(module); + } + } myDeclarationsFound = true; LOG.info("Total duration of processing project usages:" + (System.currentTimeMillis() - before)); @@ -559,15 +567,31 @@ public class RefManagerImpl extends RefManager { if (module == null) { return null; } - if (myModules == null) { - myModules = new THashMap(); + myLock.readLock().lock(); + try { + if (myModules != null) { + RefModule refModule = myModules.get(module); + if (refModule != null) { + return refModule; + } + } } - RefModule refModule = myModules.get(module); - if (refModule == null) { - refModule = new RefModuleImpl(module, this); + finally { + myLock.readLock().unlock(); + } + + myLock.writeLock().lock(); + try { + if (myModules == null) { + myModules = new THashMap(); + } + final RefModule refModule = new RefModuleImpl(module, this); myModules.put(module, refModule); + return refModule; + } + finally { + myLock.writeLock().unlock(); } - return refModule; } @Override From e8e9d6b6518e483e8c8fad61b4fe398ee16a14e3 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Wed, 18 Jun 2014 12:20:27 +0200 Subject: [PATCH 06/48] make IG test light --- .../TypeParameterExtendsFinalClass.java | 6 ++--- .../expected.xml | 23 ------------------- ...ameterExtendsFinalClassInspectionTest.java | 17 ++++++++++---- 3 files changed, 16 insertions(+), 30 deletions(-) delete mode 100644 plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/type_parameter_extends_final_class/expected.xml diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/type_parameter_extends_final_class/TypeParameterExtendsFinalClass.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/type_parameter_extends_final_class/TypeParameterExtendsFinalClass.java index 422b1dd3b2d2..38b2432d9932 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/type_parameter_extends_final_class/TypeParameterExtendsFinalClass.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/type_parameter_extends_final_class/TypeParameterExtendsFinalClass.java @@ -3,11 +3,11 @@ package com.siyeh.igtest.inheritance.type_parameter_extends_final_class; import java.util.*; -public class TypeParameterExtendsFinalClass {} +public class TypeParameterExtendsFinalClass<T extends String> {} final class Usee {} class User { - List list; + List<? extends Usee> list; List l; } abstract class MyList implements List { @@ -16,7 +16,7 @@ abstract class MyList implements List { return false; } } -abstract class SampleMap implements Map { +abstract class SampleMap<T extends String> implements Map { public void putAll(final Map m) { final Set> entries = m.entrySet(); diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/type_parameter_extends_final_class/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/type_parameter_extends_final_class/expected.xml deleted file mode 100644 index df1d975903b3..000000000000 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/type_parameter_extends_final_class/expected.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - TypeParameterExtendsFinalClass.java - 6 - Type parameter extends final class - Type parameter <code>T</code> extends final class 'String' #loc - - - - TypeParameterExtendsFinalClass.java - 10 - Type parameter extends final class - Wildcard type argument <code>?</code> extends final class 'Usee' #loc - - - - TypeParameterExtendsFinalClass.java - 19 - Type parameter extends final class - Type parameter <code>T</code> extends 'final' class 'String' #loc - - \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/TypeParameterExtendsFinalClassInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/TypeParameterExtendsFinalClassInspectionTest.java index e6c3a53604db..b6f386459466 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/TypeParameterExtendsFinalClassInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/TypeParameterExtendsFinalClassInspectionTest.java @@ -1,10 +1,19 @@ package com.siyeh.ig.inheritance; -import com.siyeh.ig.IGInspectionTestCase; +import com.intellij.codeInspection.InspectionProfileEntry; +import com.siyeh.ig.LightInspectionTestCase; -public class TypeParameterExtendsFinalClassInspectionTest extends IGInspectionTestCase { +/** + * @author bas + */ +public class TypeParameterExtendsFinalClassInspectionTest extends LightInspectionTestCase { - public void test() throws Exception { - doTest("com/siyeh/igtest/inheritance/type_parameter_extends_final_class", new TypeParameterExtendsFinalClassInspection()); + public void testTypeParameterExtendsFinalClass() throws Exception { + doTest(); + } + + @Override + protected InspectionProfileEntry getInspection() { + return new TypeParameterExtendsFinalClassInspection(); } } From 4e41cf92e19d71489d1b405a3dbc46d625b2c184 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Wed, 18 Jun 2014 14:08:24 +0200 Subject: [PATCH 07/48] make "Type parameter extends final class" inspection not complain when the final class takes a wildcard parameter and language level < 1.8 (IDEA-125637) --- ...eParameterExtendsFinalClassInspection.java | 20 ++++++++++++++++++- .../TypeParameterExtendsFinalClass.java | 4 ++++ ...ameterExtendsFinalClassInspectionTest.java | 7 +++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/TypeParameterExtendsFinalClassInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/TypeParameterExtendsFinalClassInspection.java index 9992f57f39dd..033f4ddd41f9 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/TypeParameterExtendsFinalClassInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/TypeParameterExtendsFinalClassInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 Bas Leijdekkers + * Copyright 2006-2014 Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project; import com.intellij.psi.*; import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.psi.util.PsiUtil; import com.intellij.psi.util.TypeConversionUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.util.Query; @@ -123,6 +124,9 @@ public class TypeParameterExtendsFinalClassInspection extends BaseInspection { @Override public void visitTypeParameter(PsiTypeParameter classParameter) { super.visitTypeParameter(classParameter); + if (!PsiUtil.isLanguageLevel5OrHigher(classParameter)) { + return; + } final PsiClassType[] extendsListTypes = classParameter.getExtendsListTypes(); if (extendsListTypes.length < 1) { return; @@ -140,6 +144,9 @@ public class TypeParameterExtendsFinalClassInspection extends BaseInspection { @Override public void visitTypeElement(PsiTypeElement typeElement) { + if (!PsiUtil.isLanguageLevel5OrHigher(typeElement)) { + return; + } super.visitTypeElement(typeElement); final PsiType type = typeElement.getType(); if (!(type instanceof PsiWildcardType)) { @@ -155,6 +162,17 @@ public class TypeParameterExtendsFinalClassInspection extends BaseInspection { if (aClass == null || !aClass.hasModifierProperty(PsiModifier.FINAL)) { return; } + if (aClass.hasTypeParameters() && !PsiUtil.isLanguageLevel8OrHigher(typeElement)) { + final PsiType[] parameters = classType.getParameters(); + if (parameters.length == 0) { + return; + } + for (PsiType parameter : parameters) { + if (parameter instanceof PsiWildcardType) { + return; + } + } + } if (!shouldReport(typeElement)) { return; } diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/type_parameter_extends_final_class/TypeParameterExtendsFinalClass.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/type_parameter_extends_final_class/TypeParameterExtendsFinalClass.java index 38b2432d9932..b92b7bfcdb5e 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/type_parameter_extends_final_class/TypeParameterExtendsFinalClass.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/type_parameter_extends_final_class/TypeParameterExtendsFinalClass.java @@ -9,6 +9,10 @@ final class Usee {} class User { List<? extends Usee> list; List l; + private static final Collection ourStopSearch = Collections.singleton(String.class); + Collection<? extends FieldIdentifier> a = Collections.singleton(new FieldIdentifier()); + Collection> b = Collections.singleton(new FieldIdentifier()); + static final class FieldIdentifier {} } abstract class MyList implements List { @Override diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/TypeParameterExtendsFinalClassInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/TypeParameterExtendsFinalClassInspectionTest.java index b6f386459466..94eca51f9b18 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/TypeParameterExtendsFinalClassInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/TypeParameterExtendsFinalClassInspectionTest.java @@ -1,7 +1,9 @@ package com.siyeh.ig.inheritance; import com.intellij.codeInspection.InspectionProfileEntry; +import com.intellij.testFramework.LightProjectDescriptor; import com.siyeh.ig.LightInspectionTestCase; +import org.jetbrains.annotations.NotNull; /** * @author bas @@ -16,4 +18,9 @@ public class TypeParameterExtendsFinalClassInspectionTest extends LightInspectio protected InspectionProfileEntry getInspection() { return new TypeParameterExtendsFinalClassInspection(); } + + @NotNull + protected LightProjectDescriptor getProjectDescriptor() { + return JAVA_1_7; + } } From c38a65bc5cc44b1a2af1c753a46f234b82607fcf Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Wed, 18 Jun 2014 14:27:32 +0200 Subject: [PATCH 08/48] Fix "Replace type parameter with actual class" quickfix when class has type parameter --- ...eParameterExtendsFinalClassInspection.java | 18 ++++------ .../FinalClassWithTypeParameter.after.java | 5 +++ .../FinalClassWithTypeParameter.java | 5 +++ ...TypeParameterExtendsFinalClassFixTest.java | 36 +++++++++++++++++++ 4 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igfixes/inheritance/type_parameter_extends_final_class/FinalClassWithTypeParameter.after.java create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igfixes/inheritance/type_parameter_extends_final_class/FinalClassWithTypeParameter.java create mode 100644 plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/inheritance/TypeParameterExtendsFinalClassFixTest.java diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/TypeParameterExtendsFinalClassInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/TypeParameterExtendsFinalClassInspection.java index 033f4ddd41f9..132193f02451 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/TypeParameterExtendsFinalClassInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/TypeParameterExtendsFinalClassInspection.java @@ -80,7 +80,8 @@ public class TypeParameterExtendsFinalClassInspection extends BaseInspection { final PsiElement parent = element.getParent(); if (parent instanceof PsiTypeParameter) { final PsiTypeParameter typeParameter = (PsiTypeParameter)parent; - replaceTypeParameterAndReferencesWithType(typeParameter); + replaceTypeParameterUsagesWithType(typeParameter); + typeParameter.delete(); } else if (parent instanceof PsiTypeElement) { final PsiTypeElement typeElement = (PsiTypeElement)parent; @@ -92,25 +93,18 @@ public class TypeParameterExtendsFinalClassInspection extends BaseInspection { } } - private static void replaceTypeParameterAndReferencesWithType(PsiTypeParameter typeParameter) { - final PsiReferenceList extendsList = typeParameter.getExtendsList(); - final PsiClassType[] referenceElements = extendsList.getReferencedTypes(); - if (referenceElements.length < 1) { - return; - } - final PsiClass finalClass = referenceElements[0].resolve(); - if (finalClass == null) { + private static void replaceTypeParameterUsagesWithType(PsiTypeParameter typeParameter) { + final PsiClassType[] types = typeParameter.getExtendsList().getReferencedTypes(); + if (types.length < 1) { return; } final Project project = typeParameter.getProject(); - final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); - final PsiJavaCodeReferenceElement classReference = factory.createClassReferenceElement(finalClass); + final PsiJavaCodeReferenceElement classReference = JavaPsiFacade.getElementFactory(project).createReferenceElementByType(types[0]); final Query query = ReferencesSearch.search(typeParameter, typeParameter.getUseScope()); for (PsiReference reference : query) { final PsiElement referenceElement = reference.getElement(); referenceElement.replace(classReference); } - typeParameter.delete(); } } diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/inheritance/type_parameter_extends_final_class/FinalClassWithTypeParameter.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inheritance/type_parameter_extends_final_class/FinalClassWithTypeParameter.after.java new file mode 100644 index 000000000000..ade4b5cadaae --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inheritance/type_parameter_extends_final_class/FinalClassWithTypeParameter.after.java @@ -0,0 +1,5 @@ +class FinalClassWithTypeParamer { + + A t; +} +final class A {} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/inheritance/type_parameter_extends_final_class/FinalClassWithTypeParameter.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inheritance/type_parameter_extends_final_class/FinalClassWithTypeParameter.java new file mode 100644 index 000000000000..cd905b7b5def --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inheritance/type_parameter_extends_final_class/FinalClassWithTypeParameter.java @@ -0,0 +1,5 @@ +class FinalClassWithTypeParamer extends A> { + + T t; +} +final class A {} \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/inheritance/TypeParameterExtendsFinalClassFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/inheritance/TypeParameterExtendsFinalClassFixTest.java new file mode 100644 index 000000000000..77fea4770ca1 --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/inheritance/TypeParameterExtendsFinalClassFixTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.siyeh.ig.fixes.inheritance; + +import com.siyeh.InspectionGadgetsBundle; +import com.siyeh.ig.IGQuickFixesTestCase; +import com.siyeh.ig.inheritance.TypeParameterExtendsFinalClassInspection; + +/** + * @author Bas Leijdekkers + */ +public class TypeParameterExtendsFinalClassFixTest extends IGQuickFixesTestCase { + + public void testFinalClassWithTypeParameter() { doTest(); } + + @Override + protected void setUp() throws Exception { + super.setUp(); + myFixture.enableInspections(new TypeParameterExtendsFinalClassInspection()); + myRelativePath = "inheritance/type_parameter_extends_final_class"; + myDefaultHint = InspectionGadgetsBundle.message("type.parameter.extends.final.class.quickfix"); + } +} From 7a66862cf9a37063c1d178938c1cc683afaebd1d Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Wed, 18 Jun 2014 14:38:17 +0200 Subject: [PATCH 09/48] 'readAction in headless mode' change reverted --- .../com/intellij/openapi/application/impl/ApplicationImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java index 308d5dbb1835..c6d108c2aa96 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java @@ -1049,6 +1049,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App @Override public void assertReadAccessAllowed() { + if (myHeadlessMode) return; if (!isReadAccessAllowed()) { LOG.error( "Read access is allowed from event dispatch thread or inside read-action only" + From ccd36e3b29bc3ef74d6a0ff7a2838625745e4ccd Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 18 Jun 2014 14:23:06 +0200 Subject: [PATCH 10/48] exclude non editor passes again to prevent NPE (java.lang.NullPointerException: null keys not supported at gnu.trove.THashMap.put(THashMap.java:162) at com.intellij.util.containers.MultiMap.putValue(MultiMap.java:93)) --- .../intellij/codeInsight/daemon/impl/PassExecutorService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PassExecutorService.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PassExecutorService.java index 12f04344aa09..4ae10647a17e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PassExecutorService.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PassExecutorService.java @@ -127,7 +127,9 @@ public class PassExecutorService implements Disposable { TextEditorHighlightingPass textEditorHighlightingPass = convertToTextHighlightingPass(pass, document, nextPassId, prevId); document = textEditorHighlightingPass.getDocument(); documentBoundPasses.putValue(fileEditor, textEditorHighlightingPass); - documentToEditors.putValue(document, fileEditor); + if (document != null) { + documentToEditors.putValue(document, fileEditor); + } prevId = textEditorHighlightingPass.getId(); } } From d38f95c0cbf728a82a8a8c0292fcabad3b8f9be6 Mon Sep 17 00:00:00 2001 From: "Vladislav.Soroka" Date: Wed, 18 Jun 2014 17:07:31 +0400 Subject: [PATCH 11/48] Gradle: fix build classpath resolve when 'classpath' configuration is in not unresolved state already --- .../ModelBuildScriptClasspathBuilderImpl.java | 53 +-- .../internal/ConfigurationDelegate.java | 318 ------------------ 2 files changed, 31 insertions(+), 340 deletions(-) delete mode 100644 plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/internal/ConfigurationDelegate.java diff --git a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/ModelBuildScriptClasspathBuilderImpl.java b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/ModelBuildScriptClasspathBuilderImpl.java index 71fcdeb482c4..64a3805223d7 100644 --- a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/ModelBuildScriptClasspathBuilderImpl.java +++ b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/ModelBuildScriptClasspathBuilderImpl.java @@ -17,9 +17,10 @@ package org.jetbrains.plugins.gradle.tooling.builder; import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.ResolutionStrategy; +import org.gradle.api.artifacts.ConfigurationContainer; import org.gradle.plugins.ide.idea.IdeaPlugin; import org.gradle.plugins.ide.idea.model.Dependency; +import org.gradle.plugins.ide.idea.model.IdeaModule; import org.gradle.plugins.ide.idea.model.ModuleLibrary; import org.gradle.plugins.ide.idea.model.Path; import org.gradle.util.GradleVersion; @@ -31,7 +32,6 @@ import org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder; import org.jetbrains.plugins.gradle.tooling.ModelBuilderService; import org.jetbrains.plugins.gradle.tooling.internal.BuildScriptClasspathModelImpl; import org.jetbrains.plugins.gradle.tooling.internal.ClasspathEntryModelImpl; -import org.jetbrains.plugins.gradle.tooling.internal.ConfigurationDelegate; import java.io.File; import java.util.*; @@ -43,6 +43,10 @@ import java.util.concurrent.ConcurrentHashMap; */ public class ModelBuildScriptClasspathBuilderImpl implements ModelBuilderService { + private static final String COMPILE_SCOPE = "COMPILE"; + private static final String PLUS_CONFIGURATION = "plus"; + private static final String MINUS_CONFIGURATION = "minus"; + private static final String CLASSPATH_CONFIGURATION_NAME = "classpath"; private final Map cache = new ConcurrentHashMap(); @Override @@ -72,44 +76,49 @@ public class ModelBuildScriptClasspathBuilderImpl implements ModelBuilderService } } } - Configuration configuration = project.getBuildscript().getConfigurations().findByName("classpath"); - if (configuration == null) return null; + Configuration classpathConfiguration = project.getBuildscript().getConfigurations().findByName(CLASSPATH_CONFIGURATION_NAME); + if (classpathConfiguration == null) return null; - final ResolutionStrategy resolutionStrategy = configuration.getResolutionStrategy(); - configuration = new ConfigurationDelegate(configuration.copy()) { - @Override - public ResolutionStrategy getResolutionStrategy() { - return resolutionStrategy; - } - }; + final Configuration configuration; + final IdeaModule ideaModule = ideaPlugin.getModel().getModule(); + final ConfigurationContainer configurations = ideaModule.getProject().getConfigurations(); + + if (classpathConfiguration.getState() == Configuration.State.UNRESOLVED) { + configuration = classpathConfiguration; + configurations.add(configuration); + } + else { + configuration = configurations.maybeCreate(UUID.randomUUID().toString()); + configuration.getDependencies().addAll(classpathConfiguration.getAllDependencies()); + configuration.getArtifacts().addAll(classpathConfiguration.getAllArtifacts()); + } Collection plusConfigurations = Collections.singletonList(configuration); final Map>> scopes = - new HashMap>>(ideaPlugin.getModel().getModule().getScopes()); + new HashMap>>(ideaModule.getScopes()); Map>> buildScriptScope = new HashMap>>(); Map> plusConfiguration = new HashMap>(); - plusConfiguration.put("plus", plusConfigurations); - if (scopes.get("COMPILE") != null) { - plusConfiguration.put("minus", scopes.get("COMPILE").get("plus")); + plusConfiguration.put(PLUS_CONFIGURATION, plusConfigurations); + if (scopes.get(COMPILE_SCOPE) != null) { + plusConfiguration.put(MINUS_CONFIGURATION, scopes.get(COMPILE_SCOPE).get(PLUS_CONFIGURATION)); } - buildScriptScope.put("COMPILE", plusConfiguration); - ideaPlugin.getModel().getModule().setScopes(buildScriptScope); - ideaPlugin.getModel().getModule().getProject().getConfigurations().add(configuration); - final Set buildScriptDependencies = ideaPlugin.getModel().getModule().resolveDependencies(); + buildScriptScope.put(COMPILE_SCOPE, plusConfiguration); + ideaModule.setScopes(buildScriptScope); + final Set buildScriptDependencies = ideaModule.resolveDependencies(); for (Dependency dependency : buildScriptDependencies) { if (dependency instanceof ModuleLibrary) { ModuleLibrary moduleLibrary = (ModuleLibrary)dependency; - if ("COMPILE".equals(moduleLibrary.getScope())) { + if (COMPILE_SCOPE.equals(moduleLibrary.getScope())) { buildScriptClasspath.add(new ClasspathEntryModelImpl( convert(moduleLibrary.getClasses()), convert(moduleLibrary.getSources()), convert(moduleLibrary.getJavadoc()))); } } } - ideaPlugin.getModel().getModule().setScopes(scopes); - ideaPlugin.getModel().getModule().getProject().getConfigurations().remove(configuration); + ideaModule.setScopes(scopes); + configurations.remove(configuration); } cache.put(project.getPath(), buildScriptClasspath); diff --git a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/internal/ConfigurationDelegate.java b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/internal/ConfigurationDelegate.java deleted file mode 100644 index 39c087f48e91..000000000000 --- a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/internal/ConfigurationDelegate.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.plugins.gradle.tooling.internal; - -import groovy.lang.Closure; -import org.gradle.api.artifacts.*; -import org.gradle.api.file.FileCollection; -import org.gradle.api.file.FileTree; -import org.gradle.api.specs.Spec; -import org.gradle.api.tasks.StopExecutionException; -import org.gradle.api.tasks.TaskDependency; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -/** - * @author Vladislav.Soroka - * @since 5/28/2014 - */ -public class ConfigurationDelegate implements Configuration { - @NotNull - private final Configuration delegate; - - public ConfigurationDelegate(@NotNull Configuration configuration) { - delegate = configuration; - } - - @Override - public ResolutionStrategy getResolutionStrategy() { - return delegate.getResolutionStrategy(); - } - - @Override - public Configuration resolutionStrategy(Closure closure) { - return delegate.resolutionStrategy(closure); - } - - @Override - public State getState() { - return delegate.getState(); - } - - @Override - public String getName() { - return delegate.getName(); - } - - @Override - public boolean isVisible() { - return delegate.isVisible(); - } - - @Override - public Configuration setVisible(boolean visible) { - return delegate.setVisible(visible); - } - - @Override - public Set getExtendsFrom() { - return delegate.getExtendsFrom(); - } - - @Override - public Configuration setExtendsFrom(Set superConfigs) { - return delegate.setExtendsFrom(superConfigs); - } - - @Override - public Configuration extendsFrom(Configuration... superConfigs) { - return delegate.extendsFrom(superConfigs); - } - - @Override - public boolean isTransitive() { - return delegate.isTransitive(); - } - - @Override - public Configuration setTransitive(boolean t) { - return delegate.setTransitive(t); - } - - @Override - public String getDescription() { - return delegate.getDescription(); - } - - @Override - public Configuration setDescription(String description) { - return delegate.setDescription(description); - } - - @Override - public Set getHierarchy() { - return delegate.getHierarchy(); - } - - @Override - public Set resolve() { - return delegate.resolve(); - } - - @Override - public Set files(Closure dependencySpecClosure) { - return delegate.files(dependencySpecClosure); - } - - @Override - public Set files(Spec dependencySpec) { - return delegate.files(dependencySpec); - } - - @Override - public Set files(Dependency... dependencies) { - return delegate.files(dependencies); - } - - @Override - public FileCollection fileCollection(Spec dependencySpec) { - return delegate.fileCollection(dependencySpec); - } - - @Override - public FileCollection fileCollection(Closure dependencySpecClosure) { - return delegate.fileCollection(dependencySpecClosure); - } - - @Override - public FileCollection fileCollection(Dependency... dependencies) { - return delegate.fileCollection(dependencies); - } - - @Override - public ResolvedConfiguration getResolvedConfiguration() { - return delegate.getResolvedConfiguration(); - } - - @Override - public String getUploadTaskName() { - return delegate.getUploadTaskName(); - } - - @Override - public TaskDependency getBuildDependencies() { - return delegate.getBuildDependencies(); - } - - @Override - public TaskDependency getTaskDependencyFromProjectDependency(boolean useDependedOn, String taskName) { - return delegate.getTaskDependencyFromProjectDependency(useDependedOn, taskName); - } - - @Override - public DependencySet getDependencies() { - return delegate.getDependencies(); - } - - @Override - public DependencySet getAllDependencies() { - return delegate.getAllDependencies(); - } - - @Override - public PublishArtifactSet getArtifacts() { - return delegate.getArtifacts(); - } - - @Override - public PublishArtifactSet getAllArtifacts() { - return delegate.getAllArtifacts(); - } - - @Override - public Set getExcludeRules() { - return delegate.getExcludeRules(); - } - - @Override - public Configuration exclude(Map excludeProperties) { - return delegate.exclude(excludeProperties); - } - - @Override - public Set getAll() { - return delegate.getAll(); - } - - @Override - public ResolvableDependencies getIncoming() { - return delegate.getIncoming(); - } - - @Override - public Configuration copy() { - return delegate.copy(); - } - - @Override - public Configuration copyRecursive() { - return delegate.copyRecursive(); - } - - @Override - public Configuration copy(Spec dependencySpec) { - return delegate.copy(dependencySpec); - } - - @Override - public Configuration copyRecursive(Spec dependencySpec) { - return delegate.copyRecursive(dependencySpec); - } - - @Override - public Configuration copy(Closure dependencySpec) { - return delegate.copy(dependencySpec); - } - - @Override - public Configuration copyRecursive(Closure dependencySpec) { - return delegate.copyRecursive(dependencySpec); - } - - @Override - public File getSingleFile() throws IllegalStateException { - return delegate.getSingleFile(); - } - - @Override - public Set getFiles() { - return delegate.getFiles(); - } - - @Override - public boolean contains(File file) { - return delegate.contains(file); - } - - @Override - public String getAsPath() { - return delegate.getAsPath(); - } - - @Override - public FileCollection plus(FileCollection collection) { - return delegate.plus(collection); - } - - @Override - public FileCollection minus(FileCollection collection) { - return delegate.minus(collection); - } - - @Override - public FileCollection filter(Closure filterClosure) { - return delegate.filter(filterClosure); - } - - @Override - public FileCollection filter(Spec filterSpec) { - return delegate.filter(filterSpec); - } - - @Override - public Object asType(Class type) throws UnsupportedOperationException { - return delegate.asType(type); - } - - @Override - public FileCollection add(FileCollection collection) throws UnsupportedOperationException { - return delegate.add(collection); - } - - @Override - public boolean isEmpty() { - return delegate.isEmpty(); - } - - @Override - public FileCollection stopExecutionIfEmpty() throws StopExecutionException { - return delegate.stopExecutionIfEmpty(); - } - - @Override - public FileTree getAsFileTree() { - return delegate.getAsFileTree(); - } - - @Override - public void addToAntBuilder(Object builder, String nodeName, AntType type) { - delegate.addToAntBuilder(builder, nodeName, type); - } - - @Override - public Object addToAntBuilder(Object builder, String nodeName) { - return delegate.addToAntBuilder(builder, nodeName); - } - - @Override - public Iterator iterator() { - return delegate.iterator(); - } -} From 170ee1cd5ca9a0887f6179e52a840c66a25f67ef Mon Sep 17 00:00:00 2001 From: "Vladislav.Soroka" Date: Wed, 18 Jun 2014 17:14:43 +0400 Subject: [PATCH 12/48] External system: serialization fix for out-of-process mode --- .../openapi/externalSystem/model/project/ContentRootData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ContentRootData.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ContentRootData.java index 88ccc0cc3a24..fd4d198ab00b 100644 --- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ContentRootData.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ContentRootData.java @@ -146,7 +146,7 @@ public class ContentRootData extends AbstractExternalEntityData { } } - private static final class SourceRootComparator implements Comparator { + private static final class SourceRootComparator implements Comparator, Serializable { private static final SourceRootComparator INSTANCE = new SourceRootComparator(); @Override From a5fcd9a7ad3912ff4f1781d0655819968e9b5ece Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 18 Jun 2014 17:28:46 +0400 Subject: [PATCH 13/48] fixed PY-13281 Create New Project: remove web2py template engine from web projects creation options --- .../python/templateLanguages/TemplateLanguagePanel.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateLanguagePanel.java b/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateLanguagePanel.java index 5f6091b06e7f..1ba12176218c 100644 --- a/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateLanguagePanel.java +++ b/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateLanguagePanel.java @@ -30,7 +30,8 @@ public class TemplateLanguagePanel extends JPanel { "Select template folder", null, descriptor); List templateConfigurations = TemplatesService.getAllTemplateLanguages(); for (String configuration : templateConfigurations) { - myTemplateLanguage.addItem(configuration); + if (!configuration.equals(TemplatesService.WEB2PY)) + myTemplateLanguage.addItem(configuration); } } From 29571ad685a42175d0a963f6202e9033e6e31f93 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 18 Jun 2014 17:46:45 +0400 Subject: [PATCH 14/48] set 'test' scope for TestNG library --- plugins/devkit/devkit.iml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/devkit/devkit.iml b/plugins/devkit/devkit.iml index 72329902a0e5..62aa16567062 100644 --- a/plugins/devkit/devkit.iml +++ b/plugins/devkit/devkit.iml @@ -21,7 +21,7 @@ - + From 2f53c15af59b9ba01f9bd13bfc5157dd45405631 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 18 Jun 2014 17:59:03 +0400 Subject: [PATCH 15/48] fixed PY-13279 Create New Project: install related template packages when selecting template language --- .../jetbrains/python/templateLanguages/TemplatesService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/openapi/src/com/jetbrains/python/templateLanguages/TemplatesService.java b/python/openapi/src/com/jetbrains/python/templateLanguages/TemplatesService.java index 3c701926ede6..a9487881fb51 100644 --- a/python/openapi/src/com/jetbrains/python/templateLanguages/TemplatesService.java +++ b/python/openapi/src/com/jetbrains/python/templateLanguages/TemplatesService.java @@ -18,8 +18,10 @@ package com.jetbrains.python.templateLanguages; import com.intellij.lang.Language; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleServiceManager; +import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.containers.ContainerUtil; +import com.jetbrains.python.packaging.PyPackageManager; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -67,5 +69,7 @@ public abstract class TemplatesService { public abstract void setTemplateFileTypes(List fileTypes); public abstract void generateTemplates(@NotNull final TemplateSettingsHolder settings, VirtualFile baseDir); + public abstract void installTemplateEngine(@NotNull final TemplateSettingsHolder settings, @NotNull final PyPackageManager packageManager, + @NotNull final Project project); } From 6a5377e1c8fb4150b910ef5ddf4306fbf029f3df Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 18 Jun 2014 17:58:49 +0400 Subject: [PATCH 16/48] place temp file inside extra directory --- .../jetbrains/idea/eclipse/EclipseImportWizardTest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImportWizardTest.java b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImportWizardTest.java index bbf0d4acfa67..112d61e3eeb8 100644 --- a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImportWizardTest.java +++ b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseImportWizardTest.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. @@ -62,7 +62,10 @@ public class EclipseImportWizardTest extends ProjectWizardTestCase { } public void testImportingFromTwoProviders() throws Exception { - File file = createTempFile("Foo.java", "class Foo {}"); + File dir = createTempDirectory(); + File file = new File(dir, "Foo.java"); + FileUtil.writeToFile(file, "class Foo {}"); + System.out.println("file = " + file); Module module = importProjectFrom(file.getParent(), null, new ImportFromSourcesProvider(), new EclipseProjectImportProvider(new EclipseImportBuilder())); VirtualFile[] sourceRoots = ModuleRootManager.getInstance(module).getSourceRoots(); From 934a53e53ffc822af86fee59dd0e05c338a9cd04 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 18 Jun 2014 16:04:02 +0200 Subject: [PATCH 17/48] restart indexing on root change, cancel on project disposing (IDEA-96277, IDEA-115651, some "already disposed" exceptions) --- .../openapi/project/DumbModeTask.java | 6 +- .../intellij/openapi/project/DumbService.java | 4 +- .../com/intellij/mock/MockDumbService.java | 7 +- .../impl/PushedFilePropertiesUpdater.java | 13 ++- .../FileBasedIndexProjectHandler.java | 14 ++- .../util/indexing/UnindexedFilesUpdater.java | 10 ++ .../openapi/project/DumbServiceImpl.java | 93 +++++++++++++++---- 7 files changed, 122 insertions(+), 25 deletions(-) diff --git a/platform/core-api/src/com/intellij/openapi/project/DumbModeTask.java b/platform/core-api/src/com/intellij/openapi/project/DumbModeTask.java index 360e7626669b..56fab1229f48 100644 --- a/platform/core-api/src/com/intellij/openapi/project/DumbModeTask.java +++ b/platform/core-api/src/com/intellij/openapi/project/DumbModeTask.java @@ -15,14 +15,18 @@ */ package com.intellij.openapi.project; +import com.intellij.openapi.Disposable; import com.intellij.openapi.progress.ProgressIndicator; import org.jetbrains.annotations.NotNull; /** * @author peter */ -public abstract class DumbModeTask { +public abstract class DumbModeTask implements Disposable { public abstract void performInDumbMode(@NotNull ProgressIndicator indicator); + @Override + public void dispose() { + } } diff --git a/platform/core-api/src/com/intellij/openapi/project/DumbService.java b/platform/core-api/src/com/intellij/openapi/project/DumbService.java index a690091518e9..ad5c36a5d3e2 100644 --- a/platform/core-api/src/com/intellij/openapi/project/DumbService.java +++ b/platform/core-api/src/com/intellij/openapi/project/DumbService.java @@ -176,7 +176,9 @@ public abstract class DumbService { return new ArrayList(collection); } - public abstract void queueTask(DumbModeTask task); + public abstract void queueTask(@NotNull DumbModeTask task); + + public abstract void cancelTask(@NotNull DumbModeTask task); public abstract JComponent wrapGently(@NotNull JComponent dumbUnawareContent, @NotNull Disposable parentDisposable); diff --git a/platform/core-impl/src/com/intellij/mock/MockDumbService.java b/platform/core-impl/src/com/intellij/mock/MockDumbService.java index fa922fbe21ba..1e1179cc5ee8 100644 --- a/platform/core-impl/src/com/intellij/mock/MockDumbService.java +++ b/platform/core-impl/src/com/intellij/mock/MockDumbService.java @@ -21,6 +21,7 @@ import com.intellij.openapi.progress.EmptyProgressIndicator; import com.intellij.openapi.project.DumbModeTask; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Disposer; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -50,10 +51,14 @@ public class MockDumbService extends DumbService { } @Override - public void queueTask(DumbModeTask task) { + public void queueTask(@NotNull DumbModeTask task) { task.performInDumbMode(new EmptyProgressIndicator()); + Disposer.dispose(task); } + @Override + public void cancelTask(@NotNull DumbModeTask task) { } + @Override public JComponent wrapGently(@NotNull JComponent dumbUnawareContent, @NotNull Disposable parentDisposable) { throw new UnsupportedOperationException(); diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdater.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdater.java index 1247b582b10e..b1959c2ae74c 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdater.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdater.java @@ -164,14 +164,21 @@ public class PushedFilePropertiesUpdater { }); } - private void queueTask(Runnable task) { - myTasks.offer(task); - DumbService.getInstance(myProject).queueTask(new DumbModeTask() { + private void queueTask(Runnable action) { + myTasks.offer(action); + final DumbModeTask task = new DumbModeTask() { @Override public void performInDumbMode(@NotNull ProgressIndicator indicator) { performPushTasks(); } + }; + myProject.getMessageBus().connect(task).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { + @Override + public void rootsChanged(ModuleRootEvent event) { + DumbService.getInstance(myProject).cancelTask(task); + } }); + DumbService.getInstance(myProject).queueTask(task); } private void performPushTasks() { diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java index 2ece1842ecac..9a5c46a99983 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java @@ -19,6 +19,7 @@ */ package com.intellij.util.indexing; +import com.intellij.ProjectTopics; import com.intellij.ide.IdeBundle; import com.intellij.ide.caches.FileContent; import com.intellij.ide.startup.StartupManagerEx; @@ -29,6 +30,8 @@ import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.*; import com.intellij.openapi.roots.ContentIterator; +import com.intellij.openapi.roots.ModuleRootAdapter; +import com.intellij.openapi.roots.ModuleRootEvent; import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.roots.ex.ProjectRootManagerEx; import com.intellij.openapi.roots.impl.ProjectRootManagerComponent; @@ -128,7 +131,7 @@ public class FileBasedIndexProjectHandler extends AbstractProjectComponent imple @Override public void disposeComponent() { - // done mostly for tests. In real life this is noop, because the set was removed on project closing + // done mostly for tests. In real life this is no-op, because the set was removed on project closing myIndex.removeIndexableSet(this); } @@ -140,7 +143,7 @@ public class FileBasedIndexProjectHandler extends AbstractProjectComponent imple return null; } - return new DumbModeTask() { + final DumbModeTask task = new DumbModeTask() { @Override public void performInDumbMode(@NotNull ProgressIndicator indicator) { final Collection files = index.getFilesToUpdate(project); @@ -149,6 +152,13 @@ public class FileBasedIndexProjectHandler extends AbstractProjectComponent imple reindexRefreshedFiles(indicator, files, project, index); } }; + project.getMessageBus().connect(task).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { + @Override + public void rootsChanged(ModuleRootEvent event) { + DumbService.getInstance(project).cancelTask(task); + } + }); + return task; } private static void reindexRefreshedFiles(ProgressIndicator indicator, diff --git a/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesUpdater.java b/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesUpdater.java index 8647b951407e..f500e5bc10e2 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesUpdater.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesUpdater.java @@ -15,6 +15,7 @@ */ package com.intellij.util.indexing; +import com.intellij.ProjectTopics; import com.intellij.ide.IdeBundle; import com.intellij.ide.caches.FileContent; import com.intellij.ide.startup.impl.StartupManagerImpl; @@ -24,8 +25,11 @@ import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.CacheUpdateRunner; import com.intellij.openapi.project.DumbModeTask; +import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.CollectingContentIterator; +import com.intellij.openapi.roots.ModuleRootAdapter; +import com.intellij.openapi.roots.ModuleRootEvent; import com.intellij.openapi.roots.impl.PushedFilePropertiesUpdater; import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.vfs.VirtualFile; @@ -48,6 +52,12 @@ public class UnindexedFilesUpdater extends DumbModeTask { public UnindexedFilesUpdater(final Project project, boolean onStartup) { myProject = project; myOnStartup = onStartup; + project.getMessageBus().connect(this).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { + @Override + public void rootsChanged(ModuleRootEvent event) { + DumbService.getInstance(project).cancelTask(UnindexedFilesUpdater.this); + } + }); } private void updateUnindexedFiles(ProgressIndicator indicator) { diff --git a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java index b72a7e0cc70e..f3e7da762f91 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java @@ -17,7 +17,6 @@ package com.intellij.openapi.project; import com.intellij.ide.IdeBundle; import com.intellij.ide.caches.CacheUpdater; -import com.intellij.ide.util.DelegatingProgressIndicator; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; @@ -28,6 +27,7 @@ import com.intellij.openapi.progress.*; import com.intellij.openapi.progress.util.ProgressIndicatorBase; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.util.Computable; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.ShutDownTracker; import com.intellij.openapi.wm.AppIconScheme; @@ -37,9 +37,9 @@ import com.intellij.openapi.wm.ex.ProgressIndicatorEx; import com.intellij.openapi.wm.ex.StatusBarEx; import com.intellij.ui.AppIcon; import com.intellij.util.concurrency.Semaphore; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.Queue; import com.intellij.util.io.storage.HeavyProcessLatch; -import com.intellij.util.messages.MessageBus; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,28 +48,55 @@ import org.jetbrains.annotations.TestOnly; import javax.swing.*; import java.util.ArrayList; import java.util.Collection; +import java.util.Map; -public class DumbServiceImpl extends DumbService { +public class DumbServiceImpl extends DumbService implements Disposable { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.project.DumbServiceImpl"); private volatile boolean myDumb = false; private final DumbModeListener myPublisher; private final Queue myUpdatesQueue = new Queue(5); + + /** + * Per-task progress indicators. Modified from EDT only. + * The task is removed from this map after it's finished or when the project is disposed. + */ + private final Map myProgresses = ContainerUtil.newConcurrentMap(); + private final Queue myRunWhenSmartQueue = new Queue(5); private final Project myProject; + public DumbServiceImpl(Project project) { + myProject = project; + myPublisher = project.getMessageBus().syncPublisher(DUMB_MODE); + } + @SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass"}) public static DumbServiceImpl getInstance(@NotNull Project project) { return (DumbServiceImpl)DumbService.getInstance(project); } @Override - public void queueTask(final DumbModeTask task) { + public void queueTask(@NotNull final DumbModeTask task) { scheduleCacheUpdate(task, true); } - public DumbServiceImpl(Project project, MessageBus bus) { - myProject = project; - myPublisher = bus.syncPublisher(DUMB_MODE); + @Override + public void cancelTask(@NotNull DumbModeTask task) { + ProgressIndicatorEx indicator = myProgresses.get(task); + if (indicator != null) { + indicator.cancel(); + } + } + + @Override + public void dispose() { + ApplicationManager.getApplication().assertIsDispatchThread(); + myUpdatesQueue.clear(); + myRunWhenSmartQueue.clear(); + for (DumbModeTask task : new ArrayList(myProgresses.keySet())) { + cancelTask(task); + Disposer.dispose(task); + } } @Override @@ -134,6 +161,7 @@ public class DumbServiceImpl extends DumbService { if (indicator != null) { indicator.popState(); } + Disposer.dispose(task); } return; } @@ -145,6 +173,14 @@ public class DumbServiceImpl extends DumbService { return; } myUpdatesQueue.addLast(task); + myProgresses.put(task, new ProgressIndicatorBase()); + Disposer.register(task, new Disposable() { + @Override + public void dispose() { + application.assertIsDispatchThread(); + myProgresses.remove(task); + } + }); // ok to test and set the flag like this, because the change is always done from dispatch thread if (!myDumb) { // always change dumb status inside write action. @@ -294,14 +330,12 @@ public class DumbServiceImpl extends DumbService { ((ProgressIndicatorEx)indicator).addStateDelegate(new AppIconProgress()); } - final ProgressIndicator proxy = new DelegatingProgressIndicator(indicator); - final ShutDownTracker shutdownTracker = ShutDownTracker.getInstance(); final Thread self = Thread.currentThread(); try { HeavyProcessLatch.INSTANCE.processStarted(); shutdownTracker.registerStopperThread(self); - runTasks(proxy); + runTasks(indicator); } catch (RuntimeException e) { LOG.error(e); @@ -313,16 +347,26 @@ public class DumbServiceImpl extends DumbService { } } - private void runTasks(ProgressIndicator indicator) { + private void runTasks(ProgressIndicator visibleIndicator) { + DumbModeTask prevTask = null; while (true) { - DumbModeTask task = getNextTask(); + DumbModeTask task = getNextTask(prevTask); if (task == null) break; try { if (ApplicationManager.getApplication().isInternal()) LOG.info("Running dumb mode task: " + task); + + final ProgressIndicatorEx indicator = myProgresses.get(task); + assert indicator != null; indicator.checkCanceled(); + + if (visibleIndicator instanceof ProgressIndicatorEx) { + indicator.addStateDelegate((ProgressIndicatorEx)visibleIndicator); + } + indicator.setIndeterminate(true); indicator.setText(IdeBundle.message("progress.indexing.scanning")); + task.performInDumbMode(indicator); } catch (ProcessCanceledException ignored) { @@ -330,6 +374,7 @@ public class DumbServiceImpl extends DumbService { catch (Throwable unexpected) { LOG.error(unexpected); } + prevTask = task; } } @@ -337,16 +382,30 @@ public class DumbServiceImpl extends DumbService { } @Nullable - private DumbModeTask getNextTask() { + private DumbModeTask getNextTask(@Nullable final DumbModeTask prevTask) { final Ref nextTask = Ref.create(); UIUtil.invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { if (myProject.isDisposed()) return; - if (myUpdatesQueue.isEmpty()) { - updateFinished(); - } else { - nextTask.set(myUpdatesQueue.pullFirst()); + if (prevTask != null) { + Disposer.dispose(prevTask); + } + + while (true) { + if (myUpdatesQueue.isEmpty()) { + updateFinished(); + return; + } + + DumbModeTask queuedTask = myUpdatesQueue.pullFirst(); + if (myProgresses.get(queuedTask).isCanceled()) { + Disposer.dispose(queuedTask); + continue; + } + + nextTask.set(queuedTask); + return; } } }); From 135ed8924983a8cd665f8f1f3ccdd14cd9b3cf97 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 18 Jun 2014 16:04:44 +0200 Subject: [PATCH 18/48] restore Find Jar working with malformed html (use nekohtml) --- java/java-impl/java-impl.iml | 9 +++++++ .../com/intellij/jarFinder/FindJarFix.java | 24 ++++--------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/java/java-impl/java-impl.iml b/java/java-impl/java-impl.iml index f9eca174d12c..187f6db5d385 100644 --- a/java/java-impl/java-impl.iml +++ b/java/java-impl/java-impl.iml @@ -55,6 +55,15 @@ + + + + + + + + + diff --git a/java/java-impl/src/com/intellij/jarFinder/FindJarFix.java b/java/java-impl/src/com/intellij/jarFinder/FindJarFix.java index 688788ae3c16..ee203e34deac 100644 --- a/java/java-impl/src/com/intellij/jarFinder/FindJarFix.java +++ b/java/java-impl/src/com/intellij/jarFinder/FindJarFix.java @@ -31,7 +31,7 @@ import com.intellij.util.NotNullFunction; import com.intellij.util.PlatformIcons; import com.intellij.util.download.DownloadableFileDescription; import com.intellij.util.download.DownloadableFileService; -import org.apache.xerces.parsers.DOMParser; +import org.cyberneko.html.parsers.DOMParser; import org.jetbrains.annotations.NotNull; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; @@ -40,11 +40,8 @@ import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import javax.swing.*; -import javax.xml.parsers.DocumentBuilderFactory; import java.io.File; import java.io.IOException; -import java.io.InputStream; -import java.net.URL; import java.util.*; /** @@ -129,22 +126,9 @@ public abstract class FindJarFix implements IntentionActio final Runnable runnable = new Runnable() { public void run() { try { - Document doc; - - DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); - builderFactory.setExpandEntityReferences(false); - builderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); - - URL url = new URL(CLASS_ROOT_URL + fqn.replace('.', '/') + CLASS_PAGE_EXT); - - InputStream stream = url.openStream(); - try { - doc = builderFactory.newDocumentBuilder().parse(stream); - } - finally { - stream.close(); - } - + final DOMParser parser = new DOMParser(); + parser.parse(CLASS_ROOT_URL + fqn.replace('.', '/') + CLASS_PAGE_EXT); + final Document doc = parser.getDocument(); if (doc != null) { final NodeList links = doc.getElementsByTagName(LINK_TAG_NAME); for (int i = 0; i < links.getLength(); i++) { From 4cd759d7d8dc6d8547f313c967e46d30042bb78a Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 18 Jun 2014 16:12:59 +0200 Subject: [PATCH 19/48] changed file reindexing need not be canceled on root change --- .../indexing/FileBasedIndexProjectHandler.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java index 9a5c46a99983..2ece1842ecac 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java @@ -19,7 +19,6 @@ */ package com.intellij.util.indexing; -import com.intellij.ProjectTopics; import com.intellij.ide.IdeBundle; import com.intellij.ide.caches.FileContent; import com.intellij.ide.startup.StartupManagerEx; @@ -30,8 +29,6 @@ import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.*; import com.intellij.openapi.roots.ContentIterator; -import com.intellij.openapi.roots.ModuleRootAdapter; -import com.intellij.openapi.roots.ModuleRootEvent; import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.roots.ex.ProjectRootManagerEx; import com.intellij.openapi.roots.impl.ProjectRootManagerComponent; @@ -131,7 +128,7 @@ public class FileBasedIndexProjectHandler extends AbstractProjectComponent imple @Override public void disposeComponent() { - // done mostly for tests. In real life this is no-op, because the set was removed on project closing + // done mostly for tests. In real life this is noop, because the set was removed on project closing myIndex.removeIndexableSet(this); } @@ -143,7 +140,7 @@ public class FileBasedIndexProjectHandler extends AbstractProjectComponent imple return null; } - final DumbModeTask task = new DumbModeTask() { + return new DumbModeTask() { @Override public void performInDumbMode(@NotNull ProgressIndicator indicator) { final Collection files = index.getFilesToUpdate(project); @@ -152,13 +149,6 @@ public class FileBasedIndexProjectHandler extends AbstractProjectComponent imple reindexRefreshedFiles(indicator, files, project, index); } }; - project.getMessageBus().connect(task).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { - @Override - public void rootsChanged(ModuleRootEvent event) { - DumbService.getInstance(project).cancelTask(task); - } - }); - return task; } private static void reindexRefreshedFiles(ProgressIndicator indicator, From 60ea246219480e5e08c5cc3240f5196497a13079 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Wed, 18 Jun 2014 16:12:38 +0200 Subject: [PATCH 20/48] refactor to allow redefine colors by checkbox state (enabled/selected) --- .../ui/laf/darcula/ui/DarculaCheckBoxUI.java | 95 +++++++++++-------- 1 file changed, 57 insertions(+), 38 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaCheckBoxUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaCheckBoxUI.java index b1b1d582df4c..58c6a8bae0d2 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaCheckBoxUI.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaCheckBoxUI.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. @@ -74,9 +74,11 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI { g.fillRect(0, 0, size.width, size.height); } - if (b.isSelected() && b.getSelectedIcon() != null) { + final boolean selected = b.isSelected(); + final boolean enabled = b.isEnabled(); + if (selected && b.getSelectedIcon() != null) { b.getSelectedIcon().paintIcon(b, g, iconRect.x + 4, iconRect.y + 2); - } else if (!b.isSelected() && b.getIcon() != null) { + } else if (!selected && b.getIcon() != null) { b.getIcon().paintIcon(b, g, iconRect.x + 4, iconRect.y + 2); } else { final int x = iconRect.x + 3; @@ -98,15 +100,18 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI { final boolean armed = b.getModel().isArmed(); if (c.hasFocus()) { - g.setPaint(UIUtil.getGradientPaint(w/2, 1, getFocusedBackgroundColor1(armed), w/2, h, getFocusedBackgroundColor2(armed))); - g.fillRoundRect(0, 0, w - 2, h - 2, 4, 4); + g.setPaint(UIUtil.getGradientPaint(w/2, 1, getFocusedBackgroundColor1(armed, selected), w/2, h, getFocusedBackgroundColor2(armed, selected))); + g.fillRoundRect(0, 0, w, h, 4, 4); DarculaUIUtil.paintFocusRing(g, 1, 1, w - 2, h - 2); } else { - g.setPaint(UIUtil.getGradientPaint(w / 2, 1, getBackgroundColor1(), w / 2, h, getBackgroundColor2())); - g.fillRoundRect(0, 0, w, h - 1 , 4, 4); + g.setPaint(UIUtil.getGradientPaint(w / 2, 1, getBackgroundColor1(enabled, selected), w / 2, h, getBackgroundColor2(enabled, + selected))); + g.fillRoundRect(0, 0, w, h , 4, 4); - g.setPaint(UIUtil.getGradientPaint(w / 2, 1, getBorderColor1(b.isEnabled()), w / 2, h, getBorderColor2(b.isEnabled()))); + final Color borderColor1 = getBorderColor1(enabled, selected); + final Color borderColor2 = getBorderColor2(enabled, selected); + g.setPaint(UIUtil.getGradientPaint(w / 2, 1, borderColor1, w / 2, h, borderColor2)); g.drawRoundRect(0, (UIUtil.isUnderDarcula() ? 1 : 0), w, h - 1, 4, 4); g.setPaint(getInactiveFillColor()); @@ -114,14 +119,7 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI { } if (b.getModel().isSelected()) { - g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); - g.setStroke(new BasicStroke(1 *2.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); - g.setPaint(getShadowColor(b.isEnabled())); - g.drawLine(4, 7, 7, 11); - g.drawLine(7, 11, w, 2); - g.setPaint(getCheckSignColor(b.isEnabled())); - g.drawLine(4, 5, 7, 9); - g.drawLine(7, 9, w, 0); + paintCheckSign(g, enabled, w, h); } g.translate(-x, -y); config.restore(); @@ -142,46 +140,57 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI { } } + protected void paintCheckSign(Graphics2D g, boolean enabled, int w, int h) { + g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); + g.setStroke(new BasicStroke(1 *2.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); + g.setPaint(getShadowColor(enabled, true)); + g.drawLine(4, 7, 7, 11); + g.drawLine(7, 11, w, 2); + g.setPaint(getCheckSignColor(enabled, true)); + g.drawLine(4, 5, 7, 9); + g.drawLine(7, 9, w, 0); + } + protected Color getInactiveFillColor() { return getColor("inactiveFillColor", Gray._40.withAlpha(180)); } - protected Color getBorderColor1(boolean enabled) { - return enabled ? getColor("borderColor1", Gray._120.withAlpha(0x5a)) - : getColor("disabledBorderColor1", Gray._120.withAlpha(90)); + protected Color getBorderColor1(boolean enabled, boolean selected) { + return enabled ? getColor("borderColor1", Gray._120.withAlpha(0x5a), selected) + : getColor("disabledBorderColor1", Gray._120.withAlpha(90), selected); } - protected Color getBorderColor2(boolean enabled) { - return enabled ? getColor("borderColor2", Gray._105.withAlpha(90)) - : getColor("disabledBorderColor2", Gray._105.withAlpha(90)); + protected Color getBorderColor2(boolean enabled, boolean selected) { + return enabled ? getColor("borderColor2", Gray._105.withAlpha(90), selected) + : getColor("disabledBorderColor2", Gray._105.withAlpha(90), selected); } - protected Color getBackgroundColor1() { - return getColor("backgroundColor1", Gray._110); + protected Color getBackgroundColor1(boolean enabled, boolean selected) { + return getColor("backgroundColor1", Gray._110, selected); } - protected Color getBackgroundColor2() { - return getColor("backgroundColor2", Gray._95); + protected Color getBackgroundColor2(boolean enabled, boolean selected) { + return getColor("backgroundColor2", Gray._95, selected); } - protected Color getCheckSignColor(boolean enabled) { - return enabled ? getColor("checkSignColor", Gray._170) - : getColor("checkSignColorDisabled", Gray._120); + protected Color getCheckSignColor(boolean enabled, boolean selected) { + return enabled ? getColor("checkSignColor", Gray._170, selected) + : getColor("checkSignColorDisabled", Gray._120, selected); } - protected Color getShadowColor(boolean enabled) { - return enabled ? getColor("shadowColor", Gray._30) - : getColor("shadowColorDisabled", Gray._60); + protected Color getShadowColor(boolean enabled, boolean selected) { + return enabled ? getColor("shadowColor", Gray._30, selected) + : getColor("shadowColorDisabled", Gray._60, selected); } - protected Color getFocusedBackgroundColor1(boolean armed) { - return armed ? getColor("focusedArmed.backgroundColor1", Gray._100) - : getColor("focused.backgroundColor1", Gray._120); + protected Color getFocusedBackgroundColor1(boolean armed, boolean selected) { + return armed ? getColor("focusedArmed.backgroundColor1", Gray._100, selected) + : getColor("focused.backgroundColor1", Gray._120, selected); } - protected Color getFocusedBackgroundColor2(boolean armed) { - return armed ? getColor("focusedArmed.backgroundColor2", Gray._55) - : getColor("focused.backgroundColor2", Gray._75); + protected Color getFocusedBackgroundColor2(boolean armed, boolean selected) { + return armed ? getColor("focusedArmed.backgroundColor2", Gray._55, selected) + : getColor("focused.backgroundColor2", Gray._75, selected); } protected static Color getColor(String shortPropertyName, Color defaultValue) { @@ -189,6 +198,16 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI { return color == null ? defaultValue : color; } + protected static Color getColor(String shortPropertyName, Color defaultValue, boolean selected) { + if (selected) { + final Color color = getColor(shortPropertyName + ".selected", null); + if (color != null) { + return color; + } + } + return getColor(shortPropertyName, defaultValue); + } + @Override public Icon getDefaultIcon() { return new IconUIResource(EmptyIcon.create(20)); From 7ab5b06f3d0161b2d533da97ae2d919f7e949953 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Wed, 18 Jun 2014 16:13:25 +0200 Subject: [PATCH 21/48] make selected checkbox blue --- .../com/intellij/ide/ui/laf/intellijlaf.properties | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf.properties b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf.properties index 5cfb19b01d43..f721abfdb92b 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf.properties +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf.properties @@ -88,23 +88,33 @@ ProgressBar.foreground=808080 FormattedTextField.background=ffffff -CheckBoxUI=com.intellij.ide.ui.laf.darcula.ui.DarculaCheckBoxUI +CheckBoxUI=com.intellij.ide.ui.laf.intellij.IntelliJCheckBoxUI CheckBox.border=com.intellij.ide.ui.laf.darcula.ui.DarculaCheckBoxBorder CheckBox.darcula.inactiveFillColor=00000000 CheckBox.darcula.borderColor1=444444 +CheckBox.darcula.borderColor1.selected=2C90FB CheckBox.darcula.borderColor2=444444 +CheckBox.darcula.borderColor2.selected=2C90FB CheckBox.darcula.disabledBorderColor1=969696 CheckBox.darcula.disabledBorderColor2=969696 CheckBox.darcula.backgroundColor1=ffffff +CheckBox.darcula.backgroundColor1.selected=3B98FB CheckBox.darcula.backgroundColor2=ffffff +CheckBox.darcula.backgroundColor2.selected=3B98FB CheckBox.darcula.checkSignColor=444444 +CheckBox.darcula.checkSignColor.selected=ffffff CheckBox.darcula.checkSignColorDisabled=999999 CheckBox.darcula.shadowColor=55555530 +CheckBox.darcula.shadowColor.selected=1D7BDD CheckBox.darcula.shadowColorDisabled=eeeeee CheckBox.darcula.focusedArmed.backgroundColor1=ffffff +CheckBox.darcula.focusedArmed.backgroundColor1.selected=3B98FB CheckBox.darcula.focusedArmed.backgroundColor2=ffffff +CheckBox.darcula.focusedArmed.backgroundColor2.selected=3B98FB CheckBox.darcula.focused.backgroundColor1=eeeeee +CheckBox.darcula.focused.backgroundColor1.selected=3B98FB CheckBox.darcula.focused.backgroundColor2=eeeeee +CheckBox.darcula.focused.backgroundColor2.selected=3B98FB ComboBoxUI=com.intellij.ide.ui.laf.darcula.ui.DarculaComboBoxUI ComboBox.disabledBackground=e8e8e8 From a383d1c539c88aa5fa73f2b6b676243010d909eb Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Wed, 18 Jun 2014 16:14:02 +0200 Subject: [PATCH 22/48] custom checkbox sign for IntelliJ laf --- .../ui/laf/intellij/IntelliJCheckBoxUI.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/IntelliJCheckBoxUI.java diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/IntelliJCheckBoxUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/IntelliJCheckBoxUI.java new file mode 100644 index 000000000000..e7333db456a9 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/IntelliJCheckBoxUI.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ide.ui.laf.intellij; + +import com.intellij.ide.ui.laf.darcula.ui.DarculaCheckBoxUI; + +import javax.swing.*; +import javax.swing.plaf.ComponentUI; +import java.awt.*; + +/** + * @author Konstantin Bulenkov + */ +public class IntelliJCheckBoxUI extends DarculaCheckBoxUI { + + @SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"}) + public static ComponentUI createUI(JComponent c) { + return new IntelliJCheckBoxUI(); + } + + @Override + protected void paintCheckSign(Graphics2D g, boolean enabled, int w, int h) { + g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); + g.setStroke(new BasicStroke(1 *2.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); + + g.setPaint(getShadowColor(enabled, true)); + g.drawLine(5, 9, 7, 11); + g.drawLine(7, 11, w-3, 5); + g.setPaint(getCheckSignColor(enabled, true)); + g.drawLine(5, 7, 7, 9); + g.drawLine(7, 9, w-3, 3); + } +} From 6a10a836c89de9b55129533d70c377ebcc556afa Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 18 Jun 2014 16:27:43 +0200 Subject: [PATCH 23/48] tolerate null-ranged elements (EA-57384 - NPE: BlockSupportImpl.sendBeforeChildrenChangeEvent) --- .../com/intellij/psi/impl/source/text/BlockSupportImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java b/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java index e9d2badbdb83..0e997aef7109 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java @@ -315,7 +315,8 @@ public class BlockSupportImpl extends BlockSupport { PsiTreeChangeEventImpl event = new PsiTreeChangeEventImpl(manager); event.setParent(scope); event.setFile(scope.getContainingFile()); - event.setOffset(scope.getTextRange().getStartOffset()); + TextRange range = scope.getTextRange(); + event.setOffset(range == null ? 0 : range.getStartOffset()); event.setOldLength(scope.getTextLength()); // the "generic" event is being sent on every PSI change. It does not carry any specific info except the fact that "something has changed" event.setGenericChange(isGenericChange); From 0ecc21e24244bdb2ce0cf10e924af90a4fabb46a Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Wed, 18 Jun 2014 18:47:42 +0400 Subject: [PATCH 24/48] support foreach evaluation in debugger --- .../expression/EvaluatorBuilderImpl.java | 61 +++++++----- .../expression/ForStatementEvaluator.java | 86 +++++++---------- .../expression/ForStatementEvaluatorBase.java | 96 +++++++++++++++++++ .../expression/ForeachStatementEvaluator.java | 72 ++++++++++++++ 4 files changed, 237 insertions(+), 78 deletions(-) create mode 100644 java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluatorBase.java create mode 100644 java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForeachStatementEvaluator.java diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java index d6975e6d021a..04ec0eb23fb3 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java @@ -220,31 +220,11 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder { @Override public void visitForStatement(PsiForStatement statement) { - PsiStatement initializer = statement.getInitialization(); - Evaluator initializerEvaluator = null; - if(initializer != null){ - initializer.accept(this); - initializerEvaluator = myResult; - } - - PsiExpression condition = statement.getCondition(); - Evaluator conditionEvaluator = null; - if(condition != null) { - condition.accept(this); - conditionEvaluator = myResult; - } - - PsiStatement update = statement.getUpdate(); - Evaluator updateEvaluator = null; - if(update != null){ - update.accept(this); - updateEvaluator = myResult; - } - - PsiStatement body = statement.getBody(); - if(body == null) return; - body.accept(this); - Evaluator bodyEvaluator = myResult; + Evaluator initializerEvaluator = accept(statement.getInitialization()); + Evaluator conditionEvaluator = accept(statement.getCondition()); + Evaluator updateEvaluator = accept(statement.getUpdate()); + Evaluator bodyEvaluator = accept(statement.getBody()); + if (bodyEvaluator == null) return; String label = null; if(statement.getParent() instanceof PsiLabeledStatement) { @@ -253,6 +233,37 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder { myResult = new ForStatementEvaluator(initializerEvaluator, conditionEvaluator, updateEvaluator, bodyEvaluator, label); } + @Override + public void visitForeachStatement(PsiForeachStatement statement) { + try { + String iterationParameterName = statement.getIterationParameter().getName(); + myCurrentFragmentEvaluator.setInitialValue(iterationParameterName, null); + SyntheticVariableEvaluator iterationParameterEvaluator = new SyntheticVariableEvaluator(myCurrentFragmentEvaluator, iterationParameterName); + + Evaluator iteratedValueEvaluator = accept(statement.getIteratedValue()); + Evaluator bodyEvaluator = accept(statement.getBody()); + if (bodyEvaluator == null) return; + + String label = null; + if(statement.getParent() instanceof PsiLabeledStatement) { + label = ((PsiLabeledStatement)statement.getParent()).getLabelIdentifier().getText(); + } + myResult = new ForeachStatementEvaluator(iterationParameterEvaluator, iteratedValueEvaluator, bodyEvaluator, label); + } + catch (EvaluateException e) { + throw new EvaluateRuntimeException(e); + } + } + + @Nullable + private Evaluator accept(@Nullable PsiElement element) { + if (element == null) { + return null; + } + element.accept(this); + return myResult; + } + @Override public void visitIfStatement(PsiIfStatement statement) { PsiStatement thenBranch = statement.getThenBranch(); diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluator.java index ff35ef7fe1dd..5914c878086e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluator.java @@ -16,87 +16,67 @@ package com.intellij.debugger.engine.evaluation.expression; import com.intellij.debugger.engine.evaluation.EvaluateException; -import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil; import com.intellij.debugger.engine.evaluation.EvaluationContextImpl; -import com.intellij.openapi.util.Comparing; -import com.sun.jdi.BooleanValue; /** * @author lex */ -public class ForStatementEvaluator implements Evaluator { +public class ForStatementEvaluator extends ForStatementEvaluatorBase { private final Evaluator myInitializationEvaluator; private final Evaluator myConditionEvaluator; private final Evaluator myUpdateEvaluator; private final Evaluator myBodyEvaluator; private Modifier myModifier; - private final String myLabelName; public ForStatementEvaluator(Evaluator initializationEvaluator, Evaluator conditionEvaluator, Evaluator updateEvaluator, Evaluator bodyEvaluator, String labelName) { - myInitializationEvaluator = new DisableGC(initializationEvaluator); - myConditionEvaluator = new DisableGC(conditionEvaluator); - myUpdateEvaluator = new DisableGC(updateEvaluator); - myBodyEvaluator = new DisableGC(bodyEvaluator); - myLabelName = labelName; + super(labelName); + myInitializationEvaluator = initializationEvaluator != null ? new DisableGC(initializationEvaluator) : null; + myConditionEvaluator = conditionEvaluator != null ? new DisableGC(conditionEvaluator) : null; + myUpdateEvaluator = updateEvaluator != null ? new DisableGC(updateEvaluator) : null; + myBodyEvaluator = bodyEvaluator != null ? new DisableGC(bodyEvaluator) : null; } public Modifier getModifier() { return myModifier; } - public Object evaluate(EvaluationContextImpl context) throws EvaluateException { - Object value = context.getDebugProcess().getVirtualMachineProxy().mirrorOf(); + @Override + protected void evaluateBody(EvaluationContextImpl context) throws EvaluateException { + if (myBodyEvaluator != null) { + myBodyEvaluator.evaluate(context); + } + } + + @Override + protected Object evaluateInitialization(EvaluationContextImpl context, Object value) throws EvaluateException { if (myInitializationEvaluator != null) { value = myInitializationEvaluator.evaluate(context); myModifier = myInitializationEvaluator.getModifier(); } - - while (true) { - if (myConditionEvaluator != null) { - value = myConditionEvaluator.evaluate(context); - myModifier = myConditionEvaluator.getModifier(); - if (!(value instanceof BooleanValue)) { - throw EvaluateExceptionUtil.BOOLEAN_EXPECTED; - } - else { - if (!((BooleanValue)value).booleanValue()) { - break; - } - } - } - - try { - myBodyEvaluator.evaluate(context); - } - catch (BreakException e) { - if (Comparing.equal(e.getLabelName(), myLabelName)) { - break; - } - else { - throw e; - } - } - catch (ContinueException e) { - if (Comparing.equal(e.getLabelName(), myLabelName)) { - //continue; - } - else { - throw e; - } - } - - if (myUpdateEvaluator != null) { - value = myUpdateEvaluator.evaluate(context); - myModifier = myUpdateEvaluator.getModifier(); - } - } - return value; } + @Override + protected Object evaluateCondition(EvaluationContextImpl context) throws EvaluateException { + if (myConditionEvaluator != null) { + Object value = myConditionEvaluator.evaluate(context); + myModifier = myConditionEvaluator.getModifier(); + return value; + } + return true; + } + + @Override + protected Object evaluateUpdate(EvaluationContextImpl context, Object value) throws EvaluateException { + if (myUpdateEvaluator != null) { + value = myUpdateEvaluator.evaluate(context); + myModifier = myUpdateEvaluator.getModifier(); + } + return value; + } } diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluatorBase.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluatorBase.java new file mode 100644 index 000000000000..792979206613 --- /dev/null +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluatorBase.java @@ -0,0 +1,96 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.debugger.engine.evaluation.expression; + +import com.intellij.debugger.engine.evaluation.EvaluateException; +import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil; +import com.intellij.debugger.engine.evaluation.EvaluationContextImpl; +import com.intellij.openapi.util.Comparing; +import com.sun.jdi.BooleanValue; + +/** + * @author egor + */ +public abstract class ForStatementEvaluatorBase implements Evaluator { + private final String myLabelName; + + public ForStatementEvaluatorBase(String labelName) { + myLabelName = labelName; + } + + public Object evaluate(EvaluationContextImpl context) throws EvaluateException { + Object value = context.getDebugProcess().getVirtualMachineProxy().mirrorOf(); + value = evaluateInitialization(context, value); + + while (true) { + // condition + value = evaluateCondition(context); + if (value instanceof Boolean && !(Boolean)value) { + break; + } + if (!(value instanceof BooleanValue)) { + throw EvaluateExceptionUtil.BOOLEAN_EXPECTED; + } + else { + if (!((BooleanValue)value).booleanValue()) { + break; + } + } + + // body + + try { + evaluateBody(context); + } + catch (BreakException e) { + if (Comparing.equal(e.getLabelName(), myLabelName)) { + break; + } + else { + throw e; + } + } + catch (ContinueException e) { + if (Comparing.equal(e.getLabelName(), myLabelName)) { + //continue; + } + else { + throw e; + } + } + + // update + value = evaluateUpdate(context, value); + } + + return value; + } + + protected Object evaluateInitialization(EvaluationContextImpl context, Object value) throws EvaluateException { + return value; + } + + protected Object evaluateCondition(EvaluationContextImpl context) throws EvaluateException { + return true; + } + + protected void evaluateBody(EvaluationContextImpl context) throws EvaluateException { + } + + protected Object evaluateUpdate(EvaluationContextImpl context, Object value) throws EvaluateException { + return value; + } +} diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForeachStatementEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForeachStatementEvaluator.java new file mode 100644 index 000000000000..7cc6be4c0cbf --- /dev/null +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForeachStatementEvaluator.java @@ -0,0 +1,72 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.debugger.engine.evaluation.expression; + +import com.intellij.debugger.engine.evaluation.EvaluateException; +import com.intellij.debugger.engine.evaluation.EvaluationContextImpl; +import com.sun.jdi.Value; + +/** + * @author egor + */ +public class ForeachStatementEvaluator extends ForStatementEvaluatorBase { + private final Evaluator myIterationParameterEvaluator; + private final Evaluator myIterableEvaluator; + private final Evaluator myBodyEvaluator; + + private Evaluator myConditionEvaluator; + private Evaluator myNextEvaluator; + + private Modifier myModifier; + + public ForeachStatementEvaluator(Evaluator iterationParameterEvaluator, + Evaluator iterableEvaluator, + Evaluator bodyEvaluator, + String labelName) { + super(labelName); + myIterationParameterEvaluator = iterationParameterEvaluator; + myIterableEvaluator = new DisableGC(iterableEvaluator); + myBodyEvaluator = bodyEvaluator != null ? new DisableGC(bodyEvaluator) : null; + } + + public Modifier getModifier() { + return myModifier; + } + + @Override + protected Object evaluateInitialization(EvaluationContextImpl context, Object value) throws EvaluateException { + Object iterator = new MethodEvaluator(myIterableEvaluator, null, "iterator", null, new Evaluator[0]).evaluate(context); + IdentityEvaluator iteratorEvaluator = new IdentityEvaluator(((Value)iterator)); + myConditionEvaluator = new MethodEvaluator(iteratorEvaluator, null, "hasNext", null, new Evaluator[0]); + myNextEvaluator = new AssignmentEvaluator(myIterationParameterEvaluator, new MethodEvaluator(iteratorEvaluator, null, "next", null, new Evaluator[0])); + return value; + } + + @Override + protected Object evaluateCondition(EvaluationContextImpl context) throws EvaluateException { + Object res = myConditionEvaluator.evaluate(context); + myModifier = myConditionEvaluator.getModifier(); + return res; + } + + @Override + protected void evaluateBody(EvaluationContextImpl context) throws EvaluateException { + myNextEvaluator.evaluate(context); + if (myBodyEvaluator != null) { + myBodyEvaluator.evaluate(context); + } + } +} From 77b70e9057ba89260c42efa5a68968ddbf62199c Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Wed, 18 Jun 2014 18:42:51 +0400 Subject: [PATCH 25/48] disposed check --- .../com/intellij/compiler/actions/CompileProjectAction.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/actions/CompileProjectAction.java b/java/compiler/impl/src/com/intellij/compiler/actions/CompileProjectAction.java index c7596e5cbaa4..f0c390d31459 100644 --- a/java/compiler/impl/src/com/intellij/compiler/actions/CompileProjectAction.java +++ b/java/compiler/impl/src/com/intellij/compiler/actions/CompileProjectAction.java @@ -19,7 +19,6 @@ import com.intellij.history.LocalHistory; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.compiler.CompileContext; import com.intellij.openapi.compiler.CompileStatusNotification; @@ -31,7 +30,9 @@ public class CompileProjectAction extends CompileActionBase { protected void doAction(DataContext dataContext, final Project project) { CompilerManager.getInstance(project).rebuild(new CompileStatusNotification() { public void finished(boolean aborted, int errors, int warnings, final CompileContext compileContext) { - if (aborted) return; + if (aborted || project.isDisposed()) { + return; + } String text = getTemplatePresentation().getText(); LocalHistory.getInstance().putSystemLabel(project, errors == 0 From aecfed29e7f236367280ca69fa82c61d5a018164 Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Wed, 18 Jun 2014 19:04:31 +0400 Subject: [PATCH 26/48] IDEA-126355 IntelliJ LaF: different sizes of browse buttons --- .../src/com/intellij/openapi/ui/FixedSizeButton.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/FixedSizeButton.java b/platform/platform-api/src/com/intellij/openapi/ui/FixedSizeButton.java index bdb9660c9090..a041fd2dd446 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/FixedSizeButton.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/FixedSizeButton.java @@ -87,6 +87,9 @@ public class FixedSizeButton extends JButton { public Dimension getPreferredSize() { if (myComponent != null) { int size = myComponent.getPreferredSize().height; + if (myComponent instanceof ComboBox && (UIUtil.isUnderIntelliJLaF() || UIUtil.isUnderDarcula())) { + size -= 2; // decrement to match JTextField's preferred height + } return new Dimension(size, size); } else if (mySize != -1) { From 406463b28349246f78628765a608c9a01538c130 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 18 Jun 2014 19:05:45 +0400 Subject: [PATCH 27/48] fixed PY-13280 Create New Django Project: generate proper project settings when selecting non-django templating engine --- .../jetbrains/python/templateLanguages/TemplatesService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/openapi/src/com/jetbrains/python/templateLanguages/TemplatesService.java b/python/openapi/src/com/jetbrains/python/templateLanguages/TemplatesService.java index a9487881fb51..987a7d4d3e73 100644 --- a/python/openapi/src/com/jetbrains/python/templateLanguages/TemplatesService.java +++ b/python/openapi/src/com/jetbrains/python/templateLanguages/TemplatesService.java @@ -70,6 +70,6 @@ public abstract class TemplatesService { public abstract void generateTemplates(@NotNull final TemplateSettingsHolder settings, VirtualFile baseDir); public abstract void installTemplateEngine(@NotNull final TemplateSettingsHolder settings, @NotNull final PyPackageManager packageManager, - @NotNull final Project project); + @NotNull final Project project, boolean isDjango); } From f0f8dd1db2faaa6c0b9b30a98cff70215357f79a Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 18 Jun 2014 16:14:24 +0200 Subject: [PATCH 28/48] variable incomplete code searcher should not find methods with the same name even if they are also unresolved; inline covered by RefactoringUtil.renameVariableReferences() (IDEA-126312) --- .../search/VariableInIncompleteCodeSearcher.java | 1 + .../inlineMethod/SameVarMethodNames.java | 13 +++++++++++++ .../inlineMethod/SameVarMethodNames.java.after | 9 +++++++++ .../refactoring/inline/InlineMethodTest.java | 4 ++++ 4 files changed, 27 insertions(+) create mode 100644 java/java-tests/testData/refactoring/inlineMethod/SameVarMethodNames.java create mode 100644 java/java-tests/testData/refactoring/inlineMethod/SameVarMethodNames.java.after diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/VariableInIncompleteCodeSearcher.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/VariableInIncompleteCodeSearcher.java index abedbcbbda23..abca8f160a3d 100644 --- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/VariableInIncompleteCodeSearcher.java +++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/VariableInIncompleteCodeSearcher.java @@ -54,6 +54,7 @@ public class VariableInIncompleteCodeSearcher extends QueryExecutorBaseectedAtCl(cl); + } + + private boolean haveSeenAllExpectedAtCl(int cl) { + return cl == cl(); + } + + int cl() { + return 0; + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/inlineMethod/SameVarMethodNames.java.after b/java/java-tests/testData/refactoring/inlineMethod/SameVarMethodNames.java.after new file mode 100644 index 000000000000..a7ff12c6344d --- /dev/null +++ b/java/java-tests/testData/refactoring/inlineMethod/SameVarMethodNames.java.after @@ -0,0 +1,9 @@ +class Test { + public boolean isConsideredFinal(int cl) { + return cl == cl(); + } + + int cl() { + return 0; + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java index c77b344f6722..99de5eb68dc4 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java @@ -264,6 +264,10 @@ public class InlineMethodTest extends LightRefactoringTestCase { doTest(); } + public void testSameVarMethodNames() throws Exception { + doTest(); + } + private void doTestInlineThisOnly() { @NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java"; configureByFile(fileName); From 51bb44ce4517586446dffc9548d0518c896f1269 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 18 Jun 2014 19:20:11 +0400 Subject: [PATCH 29/48] store sdk in remote project settings --- .../python/newProject/PythonBaseProjectGenerator.java | 9 ++++++--- .../jetbrains/python/remote/RemoteProjectSettings.java | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/python/ide/src/com/jetbrains/python/newProject/PythonBaseProjectGenerator.java b/python/ide/src/com/jetbrains/python/newProject/PythonBaseProjectGenerator.java index b97767138ade..a862956c7cea 100644 --- a/python/ide/src/com/jetbrains/python/newProject/PythonBaseProjectGenerator.java +++ b/python/ide/src/com/jetbrains/python/newProject/PythonBaseProjectGenerator.java @@ -8,6 +8,9 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.platform.DirectoryProjectGenerator; +import com.intellij.remote.RemoteSdkCredentials; +import com.jetbrains.python.remote.PythonRemoteInterpreterManager; +import com.jetbrains.python.remote.RemoteProjectSettings; import icons.PythonIcons; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; @@ -50,13 +53,13 @@ public class PythonBaseProjectGenerator extends PythonProjectGenerator implement @Override public void generateProject(@NotNull final Project project, @NotNull VirtualFile baseDir, final Object settings, @NotNull final Module module) { - /*if (settings instanceof RemoteProjectSettings) { + if (settings instanceof RemoteProjectSettings) { PythonRemoteInterpreterManager manager = PythonRemoteInterpreterManager.getInstance(); assert manager != null; manager.createDeployment(project, baseDir, (RemoteProjectSettings)settings, - (RemoteSdkCredentials)myProjectAction.getSdk().getSdkAdditionalData()); + (RemoteSdkCredentials)((RemoteProjectSettings)settings).getSdk().getSdkAdditionalData()); } - else */if (settings instanceof PyNewProjectSettings) { + else if (settings instanceof PyNewProjectSettings) { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { diff --git a/python/src/com/jetbrains/python/remote/RemoteProjectSettings.java b/python/src/com/jetbrains/python/remote/RemoteProjectSettings.java index 424ea52bbff6..80d8697e6311 100644 --- a/python/src/com/jetbrains/python/remote/RemoteProjectSettings.java +++ b/python/src/com/jetbrains/python/remote/RemoteProjectSettings.java @@ -15,10 +15,12 @@ */ package com.jetbrains.python.remote; +import com.jetbrains.python.newProject.PyNewProjectSettings; + /** * @author traff */ -public class RemoteProjectSettings { +public class RemoteProjectSettings extends PyNewProjectSettings { private String myDeploymentName; private String myRemoteRoot; From 053b99a1644acb16796c99e7a1ba3d4ffb676fc9 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 18 Jun 2014 19:40:08 +0400 Subject: [PATCH 30/48] removed browse button on templates folder, use only relative paths see PY-2078 Django: Support relative template path when creating django projects --- .../templateLanguages/TemplateLanguagePanel.form | 6 ++++-- .../templateLanguages/TemplateLanguagePanel.java | 12 ++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateLanguagePanel.form b/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateLanguagePanel.form index 94622c31567c..1ac79c6a0915 100644 --- a/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateLanguagePanel.form +++ b/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateLanguagePanel.form @@ -35,9 +35,11 @@ - + - + + + diff --git a/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateLanguagePanel.java b/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateLanguagePanel.java index 1ba12176218c..3ab3995b7950 100644 --- a/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateLanguagePanel.java +++ b/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateLanguagePanel.java @@ -2,17 +2,14 @@ package com.jetbrains.python.templateLanguages; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; -import com.intellij.openapi.ui.TextFieldWithBrowseButton; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.ui.components.JBLabel; import javax.swing.*; import java.awt.*; -import java.io.File; import java.util.List; public class TemplateLanguagePanel extends JPanel { - private TextFieldWithBrowseButton myTemplatesFolder; + private JTextField myTemplatesFolder; private JPanel myMainPanel; private JLabel myTemplatesFolderLabel; private JComboBox myTemplateLanguage; @@ -26,13 +23,12 @@ public class TemplateLanguagePanel extends JPanel { FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); descriptor.withTreeRootVisible(true); descriptor.setShowFileSystemRoots(true); - myTemplatesFolder.addBrowseFolderListener("Select Template Folder", - "Select template folder", null, descriptor); List templateConfigurations = TemplatesService.getAllTemplateLanguages(); for (String configuration : templateConfigurations) { if (!configuration.equals(TemplatesService.WEB2PY)) myTemplateLanguage.addItem(configuration); } + myTemplatesFolder.setText(DEFAULT_TEMPLATES_FOLDER); } public String getTemplatesFolder() { @@ -44,10 +40,6 @@ public class TemplateLanguagePanel extends JPanel { return selectedItem != null ? (String)selectedItem : null; } - public void setTemplatesRoot(String contentRoot) { - myTemplatesFolder.setText(FileUtil.toSystemDependentName(contentRoot) + File.separator + DEFAULT_TEMPLATES_FOLDER); - } - public void setTemplateLanguage(String language) { myTemplateLanguage.setSelectedItem(language); } From 56ed99c24576af3e678139e66fb0248e7fdfd639 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 18 Jun 2014 19:41:16 +0400 Subject: [PATCH 31/48] we don't want Create button to jump --- .../python/newProject/actions/AbstractProjectSettingsStep.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java b/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java index 9f8169e3c986..55d633f546d0 100644 --- a/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java +++ b/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java @@ -125,7 +125,7 @@ abstract public class AbstractProjectSettingsStep extends AbstractActionWithPane myCreateButton.setPreferredSize(new Dimension(mainPanel.getPreferredSize().width, 40)); myErrorLabel = new JLabel(""); myErrorLabel.setForeground(JBColor.RED); - bottomPanel.add(myErrorLabel, BorderLayout.SOUTH); + bottomPanel.add(myErrorLabel, BorderLayout.NORTH); bottomPanel.add(myCreateButton, BorderLayout.CENTER); mainPanel.add(bottomPanel, BorderLayout.SOUTH); From 0a4f964420de5b4875afe91c84616981e435b9c4 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Wed, 18 Jun 2014 19:36:19 +0400 Subject: [PATCH 32/48] foreach arrays iteration in debugger evaluation --- .../expression/ForStatementEvaluatorBase.java | 14 +++-- .../expression/ForeachStatementEvaluator.java | 51 ++++++++++++++++--- 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluatorBase.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluatorBase.java index 792979206613..7af8c894e9b4 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluatorBase.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForStatementEvaluatorBase.java @@ -37,17 +37,15 @@ public abstract class ForStatementEvaluatorBase implements Evaluator { while (true) { // condition - value = evaluateCondition(context); - if (value instanceof Boolean && !(Boolean)value) { - break; + Object codition = evaluateCondition(context); + if (codition instanceof Boolean) { + if (!(Boolean)codition) break; } - if (!(value instanceof BooleanValue)) { - throw EvaluateExceptionUtil.BOOLEAN_EXPECTED; + else if (codition instanceof BooleanValue) { + if (!((BooleanValue)codition).booleanValue()) break; } else { - if (!((BooleanValue)value).booleanValue()) { - break; - } + throw EvaluateExceptionUtil.BOOLEAN_EXPECTED; } // body diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForeachStatementEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForeachStatementEvaluator.java index 7cc6be4c0cbf..7b7b44856155 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForeachStatementEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ForeachStatementEvaluator.java @@ -17,6 +17,8 @@ package com.intellij.debugger.engine.evaluation.expression; import com.intellij.debugger.engine.evaluation.EvaluateException; import com.intellij.debugger.engine.evaluation.EvaluationContextImpl; +import com.sun.jdi.ArrayReference; +import com.sun.jdi.ObjectReference; import com.sun.jdi.Value; /** @@ -30,6 +32,9 @@ public class ForeachStatementEvaluator extends ForStatementEvaluatorBase { private Evaluator myConditionEvaluator; private Evaluator myNextEvaluator; + private int myArrayLength = -1; + private int myCurrentIndex = 0; + private Modifier myModifier; public ForeachStatementEvaluator(Evaluator iterationParameterEvaluator, @@ -48,18 +53,50 @@ public class ForeachStatementEvaluator extends ForStatementEvaluatorBase { @Override protected Object evaluateInitialization(EvaluationContextImpl context, Object value) throws EvaluateException { - Object iterator = new MethodEvaluator(myIterableEvaluator, null, "iterator", null, new Evaluator[0]).evaluate(context); - IdentityEvaluator iteratorEvaluator = new IdentityEvaluator(((Value)iterator)); - myConditionEvaluator = new MethodEvaluator(iteratorEvaluator, null, "hasNext", null, new Evaluator[0]); - myNextEvaluator = new AssignmentEvaluator(myIterationParameterEvaluator, new MethodEvaluator(iteratorEvaluator, null, "next", null, new Evaluator[0])); + final Object iterable = myIterableEvaluator.evaluate(context); + if (!(iterable instanceof ObjectReference)) { + throw new EvaluateException("Unable to do foreach for" + iterable); + } + IdentityEvaluator iterableEvaluator = new IdentityEvaluator((Value)iterable); + if (iterable instanceof ArrayReference) { + myArrayLength = ((ArrayReference)iterable).length(); + myNextEvaluator = new AssignmentEvaluator(myIterationParameterEvaluator, + new Evaluator() { + @Override + public Object evaluate(EvaluationContextImpl context) throws EvaluateException { + return ((ArrayReference)iterable).getValue(myCurrentIndex++); + } + + @Override + public Modifier getModifier() { + return null; + } + }); + } + else { + Object iterator = new MethodEvaluator(iterableEvaluator, null, "iterator", null, new Evaluator[0]).evaluate(context); + IdentityEvaluator iteratorEvaluator = new IdentityEvaluator((Value)iterator); + myConditionEvaluator = new MethodEvaluator(iteratorEvaluator, null, "hasNext", null, new Evaluator[0]); + myNextEvaluator = new AssignmentEvaluator(myIterationParameterEvaluator, + new MethodEvaluator(iteratorEvaluator, null, "next", null, new Evaluator[0])); + } return value; } + private boolean isArray() { + return myArrayLength > -1; + } + @Override protected Object evaluateCondition(EvaluationContextImpl context) throws EvaluateException { - Object res = myConditionEvaluator.evaluate(context); - myModifier = myConditionEvaluator.getModifier(); - return res; + if (isArray()) { + return myCurrentIndex < myArrayLength; + } + else { + Object res = myConditionEvaluator.evaluate(context); + myModifier = myConditionEvaluator.getModifier(); + return res; + } } @Override From 150dfb8866c808912eec549e95ddc0bd05c6b5b6 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 18 Jun 2014 20:13:34 +0400 Subject: [PATCH 33/48] reverted back height of new project --- .../jetbrains/python/newProject/PyCharmNewProjectDialog.java | 2 +- .../python/newProject/actions/AbstractProjectSettingsStep.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/python/ide/src/com/jetbrains/python/newProject/PyCharmNewProjectDialog.java b/python/ide/src/com/jetbrains/python/newProject/PyCharmNewProjectDialog.java index 30d07cac0073..3eb57773d299 100644 --- a/python/ide/src/com/jetbrains/python/newProject/PyCharmNewProjectDialog.java +++ b/python/ide/src/com/jetbrains/python/newProject/PyCharmNewProjectDialog.java @@ -53,7 +53,7 @@ public class PyCharmNewProjectDialog extends DialogWrapper { @Override public Dimension getMinimumSize() { - return new Dimension(650, 350); + return new Dimension(650, 450); } }; } diff --git a/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java b/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java index 55d633f546d0..a17c9a4ee522 100644 --- a/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java +++ b/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java @@ -106,7 +106,7 @@ abstract public class AbstractProjectSettingsStep extends AbstractActionWithPane final JPanel mainPanel = new JPanel(new BorderLayout()); final JPanel scrollPanel = new JPanel(new BorderLayout()); - mainPanel.setPreferredSize(new Dimension(mainPanel.getPreferredSize().width, 300)); + mainPanel.setPreferredSize(new Dimension(mainPanel.getPreferredSize().width, 400)); final JPanel panel = createBasePanel(); scrollPanel.add(panel, BorderLayout.NORTH); @@ -128,7 +128,6 @@ abstract public class AbstractProjectSettingsStep extends AbstractActionWithPane bottomPanel.add(myErrorLabel, BorderLayout.NORTH); bottomPanel.add(myCreateButton, BorderLayout.CENTER); mainPanel.add(bottomPanel, BorderLayout.SOUTH); - return mainPanel; } From 7c12432c194ca78332713258af0299084fdb55a3 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Wed, 18 Jun 2014 21:45:22 +0400 Subject: [PATCH 34/48] NPE fix; referencing service via API, not implementation --- .../src/com/intellij/compiler/impl/CompileContextImpl.java | 3 ++- .../impl/src/com/intellij/compiler/impl/CompileDriver.java | 2 +- .../src/com/intellij/compiler/impl/ProblemsViewImpl.java | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java index 17e2dfed1dee..c9e9ce31020a 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java @@ -24,6 +24,7 @@ package com.intellij.compiler.impl; import com.intellij.compiler.CompilerConfiguration; import com.intellij.compiler.CompilerMessageImpl; import com.intellij.compiler.CompilerWorkspaceConfiguration; +import com.intellij.compiler.ProblemsView; import com.intellij.compiler.progress.CompilerTask; import com.intellij.execution.impl.ExecutionManagerImpl; import com.intellij.openapi.application.ApplicationManager; @@ -156,7 +157,7 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon myTask.addMessage(msg); } if (myShouldUpdateProblemsView && msg.getCategory() == CompilerMessageCategory.ERROR) { - ProblemsViewImpl.SERVICE.getInstance(myProject).addMessage(msg, mySessionId); + ProblemsView.SERVICE.getInstance(myProject).addMessage(msg, mySessionId); } } diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java index f50fa0ad68bb..46584ef9c8bf 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java @@ -261,7 +261,7 @@ public class CompileDriver { @Override public void sessionTerminated(final UUID sessionId) { if (compileContext.shouldUpdateProblemsView()) { - final ProblemsView view = ProblemsViewImpl.SERVICE.getInstance(myProject); + final ProblemsView view = ProblemsView.SERVICE.getInstance(myProject); view.clearProgress(); view.clearOldMessages(compileContext.getCompileScope(), compileContext.getSessionId()); } diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java b/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java index 216f03b750d6..68dce61619cb 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java @@ -157,9 +157,10 @@ public class ProblemsViewImpl extends ProblemsView{ ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { - final ToolWindowManager twManager = ToolWindowManager.getInstance(myProject); - final ToolWindow tw = twManager.getToolWindow(PROBLEMS_TOOLWINDOW_ID); - tw.setIcon(active ? myActiveIcon : myPassiveIcon); + final ToolWindow tw = ToolWindowManager.getInstance(myProject).getToolWindow(PROBLEMS_TOOLWINDOW_ID); + if (tw != null) { + tw.setIcon(active ? myActiveIcon : myPassiveIcon); + } } }, myProject.getDisposed()); } From 9236754678097974dc505765b0c4db8ac5558f3f Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 18 Jun 2014 20:13:41 +0200 Subject: [PATCH 35/48] don't cast qualifier on completion when it leads to a less specific return type (fixes NormalCompletionTest.testListArrayListCast) --- .../intellij/codeInsight/completion/JavaCompletionUtil.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java index 4b8948d39b0d..1112738c5464 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java @@ -446,8 +446,10 @@ public class JavaCompletionUtil { PsiSubstitutor plainSub = plainResult.getSubstitutor(); PsiSubstitutor castSub = TypeConversionUtil.getSuperClassSubstitutor(plainClass, (PsiClassType)castType); + PsiType returnType = method.getReturnType(); if (method.getSignature(plainSub).equals(method.getSignature(castSub)) && - Comparing.equal(plainSub.substitute(method.getReturnType()), castSub.substitute(method.getReturnType())) && + returnType != null && + castSub.substitute(returnType).isAssignableFrom(plainSub.substitute(returnType)) && processor.isAccessible(plainClass.findMethodBySignature(method, true)) ) { return item; From b28b47a4cf2b82f7033fad8893e42043c75b6f9b Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Thu, 19 Jun 2014 01:14:43 +0400 Subject: [PATCH 36/48] make sure bounds is a square --- .../com/intellij/openapi/ui/FixedSizeButton.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/FixedSizeButton.java b/platform/platform-api/src/com/intellij/openapi/ui/FixedSizeButton.java index a041fd2dd446..6fe5554299da 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/FixedSizeButton.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/FixedSizeButton.java @@ -111,5 +111,18 @@ public class FixedSizeButton extends JButton { public void setSize(int size) { mySize = size; } -} + @Override + public void setBounds(int x, int y, int width, int height) { + int size = Math.min(width, height); + super.setBounds(x, y, size, size); + } + + @Override + public void setBounds(Rectangle r) { + int size = Math.min(r.width, r.height); + r.width = size; + r.height = size; + super.setBounds(r); + } +} From 09e304c55c038c87927cb120b80d2970e5a22a3b Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Thu, 19 Jun 2014 03:46:13 +0400 Subject: [PATCH 37/48] PY-8427 Behave BDD support PY-4186 Lettuce BDD tool support Initial extension point impl --- .../src/com/jetbrains/python/packaging/PyPackageManager.java | 2 ++ .../src/com/jetbrains/python/packaging/PyPackageManagers.java | 4 ++++ python/psi-api/src/com/jetbrains/python/psi/PyFile.java | 1 + .../psi-api/src/com/jetbrains/python/psi/impl/PyPsiUtils.java | 1 + .../com/jetbrains/python/packaging/PyPackageManagerImpl.java | 1 + .../com/jetbrains/python/packaging/PyPackageManagersImpl.java | 2 ++ python/src/com/jetbrains/python/psi/impl/PyFileImpl.java | 1 + 7 files changed, 12 insertions(+) diff --git a/python/openapi/src/com/jetbrains/python/packaging/PyPackageManager.java b/python/openapi/src/com/jetbrains/python/packaging/PyPackageManager.java index df6b91b1bfe8..4999b1bb519b 100644 --- a/python/openapi/src/com/jetbrains/python/packaging/PyPackageManager.java +++ b/python/openapi/src/com/jetbrains/python/packaging/PyPackageManager.java @@ -17,6 +17,7 @@ package com.jetbrains.python.packaging; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.Sdk; +import org.jetbrains.annotations.Nullable; import java.awt.*; @@ -39,6 +40,7 @@ public abstract class PyPackageManager { public abstract void showInstallationError(Project project, String title, String description); public abstract void showInstallationError(Component owner, String title, String description); public abstract void refresh(); + @Nullable public abstract PyPackage findPackage(String name) throws PyExternalProcessException; } diff --git a/python/openapi/src/com/jetbrains/python/packaging/PyPackageManagers.java b/python/openapi/src/com/jetbrains/python/packaging/PyPackageManagers.java index 796bc47286ac..9f598748aa7b 100644 --- a/python/openapi/src/com/jetbrains/python/packaging/PyPackageManagers.java +++ b/python/openapi/src/com/jetbrains/python/packaging/PyPackageManagers.java @@ -18,6 +18,7 @@ package com.jetbrains.python.packaging; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.projectRoots.Sdk; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; @@ -26,10 +27,13 @@ import java.util.List; * @author yole */ public abstract class PyPackageManagers { + + @NotNull public static PyPackageManagers getInstance() { return ServiceManager.getService(PyPackageManagers.class); } + @NotNull public abstract PyPackageManager forSdk(Sdk sdk); /** diff --git a/python/psi-api/src/com/jetbrains/python/psi/PyFile.java b/python/psi-api/src/com/jetbrains/python/psi/PyFile.java index 1786b934159b..48d1b50b5800 100644 --- a/python/psi-api/src/com/jetbrains/python/psi/PyFile.java +++ b/python/psi-api/src/com/jetbrains/python/psi/PyFile.java @@ -27,6 +27,7 @@ public interface PyFile extends PyElement, PsiFile, PyDocStringOwner, ScopeOwner List getTopLevelClasses(); + @NotNull List getTopLevelFunctions(); List getTopLevelAttributes(); diff --git a/python/psi-api/src/com/jetbrains/python/psi/impl/PyPsiUtils.java b/python/psi-api/src/com/jetbrains/python/psi/impl/PyPsiUtils.java index b3a1134a2e03..f4f3a74f5a9f 100644 --- a/python/psi-api/src/com/jetbrains/python/psi/impl/PyPsiUtils.java +++ b/python/psi-api/src/com/jetbrains/python/psi/impl/PyPsiUtils.java @@ -236,6 +236,7 @@ public class PyPsiUtils { } } + @NotNull static List collectStubChildren(U e, final StubElement stub, final IElementType elementType, final Class itemClass) { diff --git a/python/src/com/jetbrains/python/packaging/PyPackageManagerImpl.java b/python/src/com/jetbrains/python/packaging/PyPackageManagerImpl.java index f8850376370a..a5961c4e3b8e 100644 --- a/python/src/com/jetbrains/python/packaging/PyPackageManagerImpl.java +++ b/python/src/com/jetbrains/python/packaging/PyPackageManagerImpl.java @@ -603,6 +603,7 @@ public class PyPackageManagerImpl extends PyPackageManager { return packages != null ? findPackageByName(name, packages) : null; } + @Nullable private static PyPackage findPackageByName(String name, List packages) { for (PyPackage pkg : packages) { if (name.equalsIgnoreCase(pkg.getName())) { diff --git a/python/src/com/jetbrains/python/packaging/PyPackageManagersImpl.java b/python/src/com/jetbrains/python/packaging/PyPackageManagersImpl.java index 714bf8212b58..054e9e01d23f 100644 --- a/python/src/com/jetbrains/python/packaging/PyPackageManagersImpl.java +++ b/python/src/com/jetbrains/python/packaging/PyPackageManagersImpl.java @@ -17,6 +17,7 @@ package com.jetbrains.python.packaging; import com.intellij.openapi.module.Module; import com.intellij.openapi.projectRoots.Sdk; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.HashMap; @@ -29,6 +30,7 @@ import java.util.Map; public class PyPackageManagersImpl extends PyPackageManagers { private final Map myInstances = new HashMap(); + @NotNull @Override public synchronized PyPackageManager forSdk(Sdk sdk) { final String name = sdk.getName(); diff --git a/python/src/com/jetbrains/python/psi/impl/PyFileImpl.java b/python/src/com/jetbrains/python/psi/impl/PyFileImpl.java index c723aedb6b0d..030fcfe3d7e5 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyFileImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyFileImpl.java @@ -419,6 +419,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { return PyPsiUtils.collectStubChildren(this, this.getStub(), PyElementTypes.CLASS_DECLARATION, PyClass.class); } + @NotNull @Override public List getTopLevelFunctions() { return PyPsiUtils.collectStubChildren(this, this.getStub(), PyElementTypes.FUNCTION_DECLARATION, PyFunction.class); From 3393c56c59aaa605cba8f4a9918a6c2f30b962b6 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 18 Jun 2014 20:48:32 +0400 Subject: [PATCH 38/48] groovy plugin: removed unneeded optional dependency on 'cucumber' --- plugins/groovy/groovy-psi/src/META-INF/GroovyPlugin.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/groovy/groovy-psi/src/META-INF/GroovyPlugin.xml b/plugins/groovy/groovy-psi/src/META-INF/GroovyPlugin.xml index 0c3122457e19..c07e741a53a8 100644 --- a/plugins/groovy/groovy-psi/src/META-INF/GroovyPlugin.xml +++ b/plugins/groovy/groovy-psi/src/META-INF/GroovyPlugin.xml @@ -25,7 +25,6 @@ com.intellij.copyright org.intellij.intelliLang AntSupport - cucumber ByteCodeViewer From 5b0022ea95dbc41140591db16942c0d71e2a939d Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 18 Jun 2014 21:41:02 +0400 Subject: [PATCH 39/48] groovy: extension requiring optional dependencies on 'ByteCode Viewer' extracted to separate config file --- plugins/groovy/groovy-psi/src/META-INF/GroovyPlugin.xml | 6 +----- .../groovy-psi/src/META-INF/groovy-byte-code-viewer.xml | 5 +++++ 2 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 plugins/groovy/groovy-psi/src/META-INF/groovy-byte-code-viewer.xml diff --git a/plugins/groovy/groovy-psi/src/META-INF/GroovyPlugin.xml b/plugins/groovy/groovy-psi/src/META-INF/GroovyPlugin.xml index c07e741a53a8..85949a53df2b 100644 --- a/plugins/groovy/groovy-psi/src/META-INF/GroovyPlugin.xml +++ b/plugins/groovy/groovy-psi/src/META-INF/GroovyPlugin.xml @@ -25,7 +25,7 @@ com.intellij.copyright org.intellij.intelliLang AntSupport - ByteCodeViewer + ByteCodeViewer @@ -1509,10 +1509,6 @@ - - - - diff --git a/plugins/groovy/groovy-psi/src/META-INF/groovy-byte-code-viewer.xml b/plugins/groovy/groovy-psi/src/META-INF/groovy-byte-code-viewer.xml new file mode 100644 index 000000000000..ee9aeea6ff67 --- /dev/null +++ b/plugins/groovy/groovy-psi/src/META-INF/groovy-byte-code-viewer.xml @@ -0,0 +1,5 @@ + + + + + From 969da5b90c744e2424c31596b806f0e498ca12b8 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 19 Jun 2014 11:25:34 +0400 Subject: [PATCH 40/48] module-level 'nekohtml' library replaced by reference to project-level library --- .idea/libraries/nekohtml.xml | 9 +++++++++ java/java-impl/java-impl.iml | 10 +--------- 2 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 .idea/libraries/nekohtml.xml diff --git a/.idea/libraries/nekohtml.xml b/.idea/libraries/nekohtml.xml new file mode 100644 index 000000000000..4817f403af21 --- /dev/null +++ b/.idea/libraries/nekohtml.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/java/java-impl/java-impl.iml b/java/java-impl/java-impl.iml index 187f6db5d385..ed904dec772b 100644 --- a/java/java-impl/java-impl.iml +++ b/java/java-impl/java-impl.iml @@ -55,15 +55,7 @@ - - - - - - - - - + From 631e97a85c51917cc8d79b8ebc23cca4ef016ba1 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 19 Jun 2014 11:27:10 +0400 Subject: [PATCH 41/48] use BootstrapTests for community tests to fix problem with long command line - 2 --- build/scripts/common_tests.gant | 60 ++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/build/scripts/common_tests.gant b/build/scripts/common_tests.gant index 1af3d7a8f248..e7aaf1a5d34e 100644 --- a/build/scripts/common_tests.gant +++ b/build/scripts/common_tests.gant @@ -41,37 +41,43 @@ private pass(String prop) { target('run_tests': 'Run java tests') { depends([compile]) - ant.junit(fork: "yes", showoutput: "true", logfailedtests:false) { - pass("idea.test.group") - pass("idea.test.patterns") - pass("idea.fast.only") - pass("teamcity.build.tempDir") - pass("teamcity.tests.recentlyFailedTests.file") - jvmarg (value: "-Didea.platform.prefix=Idea") - jvmarg (value: "-Djava.system.class.loader=com.intellij.util.lang.UrlClassLoader") + def classpathFile = "$home/junit.classpath" + List testRuntimeClasspath = projectBuilder.moduleRuntimeClasspath(findModule("community-main"), true) + new File(classpathFile).text = testRuntimeClasspath.findAll({ new File((String)it).exists() }).join('\n') - System.getProperties().entrySet().each { - if (it.key.startsWith("pass.")) { - def trimmed = it.key.substring("pass.".length()); - jvmarg(value: "-D${trimmed}=${it.value}"); - }; - } + testcases.each { testCase -> + ant.junit(fork: "yes", showoutput: "true", logfailedtests: false) { + jvmarg(value: "-Dclasspath.file=${classpathFile}") + pass("idea.test.group") + pass("idea.test.patterns") + pass("idea.fast.only") + pass("teamcity.build.tempDir") + pass("teamcity.tests.recentlyFailedTests.file") + jvmarg(value: "-Didea.platform.prefix=Idea") - commonJvmArgs().each { jvmarg(value: it) } - - if (isDefined("jvm_args")) { - jvm_args.each { jvmarg(value: it) } - } - - classpath { - projectBuilder.moduleRuntimeClasspath(findModule("community-main"), true).each { - pathelement(location: it) + System.getProperties().entrySet().each { + if (it.key.startsWith("pass.")) { + def trimmed = it.key.substring("pass.".length()); + jvmarg(value: "-D${trimmed}=${it.value}"); + }; } - pathelement(location: "${jdkHome}/lib/tools.jar") - } - testcases.each { - test (name: it) + commonJvmArgs().each { jvmarg(value: it) } + + jvmarg(value: "-Dbootstrap.testcases=$testCase") + + if (isDefined("jvm_args")) { + jvm_args.each { jvmarg(value: it) } + } + + classpath { + projectBuilder.moduleRuntimeClasspath(findModule("tests_bootstrap"), false).each { + pathelement(location: it) + } + pathelement(location: "${jdkHome}/lib/tools.jar") + } + + test(name: 'com.intellij.tests.BootstrapTests') } } } From b21e515794f8df8f14913b740dcab89ee9e8ea8d Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Thu, 19 Jun 2014 11:54:59 +0400 Subject: [PATCH 42/48] EA-54811 - avoid InjectedCodeFoldingPass seeing outdated PSI for injected fragments --- .../editor/impl/FoldingExceptionTest.java | 14 ++-------- .../folding/impl/FoldingUpdate.java | 27 ++++++++++++------- .../injected/InjectedLanguageManagerImpl.java | 12 +-------- .../tree/injected/InjectedLanguageUtil.java | 11 ++++++++ .../psi/formatter/FormatterTestCase.java | 14 +++------- .../testFramework/EditorTestUtil.java | 20 ++++++++++++++ 6 files changed, 54 insertions(+), 44 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingExceptionTest.java b/java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingExceptionTest.java index f40a58b16788..b168bc214014 100644 --- a/java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingExceptionTest.java +++ b/java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingExceptionTest.java @@ -15,11 +15,8 @@ */ package com.intellij.openapi.editor.impl; -import com.intellij.codeHighlighting.TextEditorHighlightingPass; import com.intellij.codeInsight.daemon.impl.CodeFoldingPassFactory; -import com.intellij.mock.MockProgressIndicator; import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiFile; import com.intellij.testFramework.EditorTestUtil; import com.intellij.testFramework.LightCodeInsightTestCase; @@ -43,14 +40,7 @@ public class FoldingExceptionTest extends LightCodeInsightTestCase { } private static void runFoldingPass() { - PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(getProject()); - psiDocumentManager.commitAllDocuments(); - PsiFile psiFile = psiDocumentManager.getPsiFile(myEditor.getDocument()); - assertNotNull(psiFile); - - CodeFoldingPassFactory factory = getProject().getComponent(CodeFoldingPassFactory.class); - TextEditorHighlightingPass highlightingPass = factory.createHighlightingPass(psiFile, myEditor); - highlightingPass.collectInformation(new MockProgressIndicator()); - highlightingPass.doApplyInformationToEditor(); + PsiDocumentManager.getInstance(ourProject).commitAllDocuments(); + EditorTestUtil.runTextEditorHighlightingPass(myEditor, CodeFoldingPassFactory.class); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java index 4f7f3322a05b..7d0b4453c517 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java @@ -159,17 +159,24 @@ public class FoldingUpdate { final List injectedEditors = new ArrayList(); final List injectedFiles = new ArrayList(); final List maps = new ArrayList(); - for (DocumentWindow injectedDocument : injectedDocuments) { - PsiFile injectedFile = PsiDocumentManager.getInstance(project).getPsiFile(injectedDocument); - if (injectedFile == null || !injectedFile.isValid() || !injectedDocument.isValid()) continue; - Editor injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injectedFile); - if (!(injectedEditor instanceof EditorWindow)) continue; + for (final DocumentWindow injectedDocument : injectedDocuments) { + if (!injectedDocument.isValid()) { + continue; + } + InjectedLanguageUtil.enumerate(injectedDocument, file, new PsiLanguageInjectionHost.InjectedPsiVisitor() { + @Override + public void visit(@NotNull PsiFile injectedFile, @NotNull List places) { + if (!injectedFile.isValid()) return; + Editor injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injectedFile); + if (!(injectedEditor instanceof EditorWindow)) return; - injectedEditors.add((EditorWindow)injectedEditor); - injectedFiles.add(injectedFile); - final FoldingMap map = new FoldingMap(); - maps.add(map); - getFoldingsFor(injectedFile, injectedDocument, map, false); + injectedEditors.add((EditorWindow)injectedEditor); + injectedFiles.add(injectedFile); + final FoldingMap map = new FoldingMap(); + maps.add(map); + getFoldingsFor(injectedFile, injectedDocument, map, false); + } + }); } return new Runnable() { diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java index 7c7945d653a3..85472e245b1f 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java @@ -43,7 +43,6 @@ import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.Segment; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; @@ -141,18 +140,9 @@ public class InjectedLanguageManagerImpl extends InjectedLanguageManager impleme if (indicator != null && indicator.isCanceled()) return false; if (documentManager.isUncommited(hostDocument) || !hostPsiFile.isValid()) return false; // will be committed later - Segment[] ranges = documentWindow.getHostRanges(); - Segment rangeMarker = ranges.length > 0 ? ranges[0] : null; - PsiElement element = rangeMarker == null ? null : hostPsiFile.findElementAt(rangeMarker.getStartOffset()); - if (element == null) { - synchronized (PsiLock.LOCK) { - injected.remove(documentWindow); - } - return true; - } final DocumentWindow[] stillInjectedDocument = {null}; // it is here where the reparse happens and old file contents replaced - InjectedLanguageUtil.enumerate(element, hostPsiFile, true, new PsiLanguageInjectionHost.InjectedPsiVisitor() { + InjectedLanguageUtil.enumerate(documentWindow, hostPsiFile, new PsiLanguageInjectionHost.InjectedPsiVisitor() { @Override public void visit(@NotNull PsiFile injectedPsi, @NotNull List places) { stillInjectedDocument[0] = (DocumentWindow)injectedPsi.getViewProvider().getDocument(); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java index 1d6afc3d1fba..f2863469d614 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java @@ -92,6 +92,17 @@ public class InjectedLanguageUtil { return ((DocumentWindowImpl)myFileViewProvider.getDocument()).getShreds(); } + public static void enumerate(@NotNull DocumentWindow documentWindow, + @NotNull PsiFile hostPsiFile, + @NotNull PsiLanguageInjectionHost.InjectedPsiVisitor visitor) { + Segment[] ranges = documentWindow.getHostRanges(); + Segment rangeMarker = ranges.length > 0 ? ranges[0] : null; + PsiElement element = rangeMarker == null ? null : hostPsiFile.findElementAt(rangeMarker.getStartOffset()); + if (element != null) { + enumerate(element, hostPsiFile, true, visitor); + } + } + public static boolean enumerate(@NotNull PsiElement host, @NotNull PsiLanguageInjectionHost.InjectedPsiVisitor visitor) { PsiFile containingFile = host.getContainingFile(); return enumerate(host, containingFile, true, visitor); diff --git a/platform/testFramework/src/com/intellij/psi/formatter/FormatterTestCase.java b/platform/testFramework/src/com/intellij/psi/formatter/FormatterTestCase.java index 2afd09168420..4daee2640c27 100644 --- a/platform/testFramework/src/com/intellij/psi/formatter/FormatterTestCase.java +++ b/platform/testFramework/src/com/intellij/psi/formatter/FormatterTestCase.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. @@ -15,10 +15,8 @@ */ package com.intellij.psi.formatter; -import com.intellij.codeHighlighting.TextEditorHighlightingPass; import com.intellij.codeInsight.daemon.impl.CodeFoldingPassFactory; import com.intellij.lang.Language; -import com.intellij.mock.MockProgressIndicator; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ex.PathManagerEx; import com.intellij.openapi.command.CommandProcessor; @@ -42,6 +40,7 @@ import com.intellij.psi.codeStyle.CodeStyleManager; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; +import com.intellij.testFramework.EditorTestUtil; import com.intellij.testFramework.LightPlatformTestCase; import com.intellij.util.IncorrectOperationException; import com.intellij.util.LocalTimeCounter; @@ -199,7 +198,7 @@ public abstract class FormatterTestCase extends LightPlatformTestCase { assertEquals(file.getText(), document.getText()); if (false && doCheckDocumentUpdate()) { - makeFolding(file, editor); + EditorTestUtil.runTextEditorHighlightingPass(editor, CodeFoldingPassFactory.class); } try { if (doReformatRangeTest) { @@ -225,13 +224,6 @@ public abstract class FormatterTestCase extends LightPlatformTestCase { assertEquals(textAfter, file.getText()); } - protected static void makeFolding(final PsiFile file, final EditorImpl editor) { - final CodeFoldingPassFactory factory = getProject().getComponent(CodeFoldingPassFactory.class); - final TextEditorHighlightingPass highlightingPass = factory.createHighlightingPass(file, editor); - highlightingPass.collectInformation(new MockProgressIndicator()); - highlightingPass.doApplyInformationToEditor(); - } - @SuppressWarnings({"UNUSED_SYMBOL"}) private void checkPsi(final PsiFile file, String textAfter) { CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() { diff --git a/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java index 0d4453820c33..d42e639438c2 100644 --- a/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java @@ -15,7 +15,10 @@ */ package com.intellij.testFramework; +import com.intellij.codeHighlighting.TextEditorHighlightingPass; +import com.intellij.codeHighlighting.TextEditorHighlightingPassFactory; import com.intellij.ide.DataManager; +import com.intellij.mock.MockProgressIndicator; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.Result; import com.intellij.openapi.command.WriteCommandAction; @@ -32,10 +35,13 @@ import com.intellij.openapi.editor.impl.SoftWrapModelImpl; import com.intellij.openapi.editor.impl.softwrap.SoftWrapDrawingType; import com.intellij.openapi.editor.impl.softwrap.SoftWrapPainter; import com.intellij.openapi.editor.impl.softwrap.mapping.SoftWrapApplianceManager; +import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.psi.PsiDocumentManager; +import com.intellij.psi.PsiFile; import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -432,6 +438,20 @@ public class EditorTestUtil { return ref.get(); } + public static void runTextEditorHighlightingPass(@NotNull Editor editor, @NotNull Class passFactory) { + Project project = editor.getProject(); + assertNotNull(project); + PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project); + PsiFile psiFile = psiDocumentManager.getPsiFile(editor.getDocument()); + assertNotNull(psiFile); + + T factory = project.getComponent(passFactory); + TextEditorHighlightingPass pass = factory.createHighlightingPass(psiFile, editor); + assertNotNull(pass); + pass.collectInformation(new MockProgressIndicator()); + pass.applyInformationToEditor(); + } + public static class CaretAndSelectionState { public final List carets = new ArrayList(); @Nullable From 3b16bbb1938361896bf5509fb29630fa9f9b8f35 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 18 Jun 2014 19:29:43 +0400 Subject: [PATCH 43/48] cleanup --- .../find/findUsages/JavaFindUsagesHandler.java | 1 + .../progress/util/TooManyUsagesStatus.java | 15 ++++++--------- .../find/findUsages/AbstractFindUsagesDialog.java | 3 ++- .../find/findUsages/FindUsagesHandler.java | 2 ++ .../findUsages/PsiElement2UsageTargetAdapter.java | 3 ++- .../impl/BackgroundableProcessIndicator.java | 13 ++++++++++++- .../usages/impl/UsageViewManagerImpl.java | 2 +- .../findUsages/PyModuleFindUsagesHandler.java | 3 ++- 8 files changed, 28 insertions(+), 14 deletions(-) diff --git a/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java b/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java index d19ffadb5bda..9a1b86efd74e 100644 --- a/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java +++ b/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java @@ -757,6 +757,7 @@ public class JavaFindUsagesHandler extends FindUsagesHandler{ } + @NotNull @Override public Collection findReferencesToHighlight(@NotNull final PsiElement target, @NotNull final SearchScope searchScope) { if (target instanceof PsiMethod) { diff --git a/platform/core-impl/src/com/intellij/openapi/progress/util/TooManyUsagesStatus.java b/platform/core-impl/src/com/intellij/openapi/progress/util/TooManyUsagesStatus.java index 74d7bf36b911..f44d497edefa 100644 --- a/platform/core-impl/src/com/intellij/openapi/progress/util/TooManyUsagesStatus.java +++ b/platform/core-impl/src/com/intellij/openapi/progress/util/TooManyUsagesStatus.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. @@ -27,17 +27,14 @@ import java.util.concurrent.atomic.AtomicReference; public class TooManyUsagesStatus { private static final Key KEY = Key.create("TooManyUsagesStatus"); - private static final Null NULL = new Null(); + private static final NullStatus NULL_STATUS = new NullStatus(); @NotNull public static TooManyUsagesStatus getFrom(@Nullable ProgressIndicator indicator) { - TooManyUsagesStatus data = null; - if (indicator instanceof UserDataHolder) { - data = ((UserDataHolder)indicator).getUserData(KEY); - } - if (data == null) data = NULL; - return data; + TooManyUsagesStatus data = indicator instanceof UserDataHolder ? ((UserDataHolder)indicator).getUserData(KEY) : null; + return data == null ? NULL_STATUS : data; } + public static TooManyUsagesStatus createFor(@NotNull ProgressIndicator indicator) { TooManyUsagesStatus data = null; if (indicator instanceof UserDataHolder) { @@ -76,7 +73,7 @@ public class TooManyUsagesStatus { } } - private static class Null extends TooManyUsagesStatus { + private static class NullStatus extends TooManyUsagesStatus { @Override public boolean switchTooManyUsagesStatus() { return false; diff --git a/platform/lang-impl/src/com/intellij/find/findUsages/AbstractFindUsagesDialog.java b/platform/lang-impl/src/com/intellij/find/findUsages/AbstractFindUsagesDialog.java index d1bae2c48f57..ee76d0ee4cc2 100644 --- a/platform/lang-impl/src/com/intellij/find/findUsages/AbstractFindUsagesDialog.java +++ b/platform/lang-impl/src/com/intellij/find/findUsages/AbstractFindUsagesDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -143,6 +143,7 @@ public abstract class AbstractFindUsagesDialog extends DialogWrapper { return panel; } + @NotNull public final FindUsagesOptions calcFindUsagesOptions() { calcFindUsagesOptions(myFindUsagesOptions); return myFindUsagesOptions; diff --git a/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesHandler.java b/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesHandler.java index c98f179aaa82..889855d66c79 100644 --- a/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesHandler.java +++ b/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesHandler.java @@ -47,6 +47,7 @@ import java.util.Collections; */ public abstract class FindUsagesHandler { // return this handler if you want to cancel the search + @NotNull public static final FindUsagesHandler NULL_HANDLER = new FindUsagesHandler(PsiUtilCore.NULL_PSI_ELEMENT){}; private final PsiElement myPsiElement; @@ -204,6 +205,7 @@ public abstract class FindUsagesHandler { return false; } + @NotNull public Collection findReferencesToHighlight(@NotNull PsiElement target, @NotNull SearchScope searchScope) { return ReferencesSearch.search(target, searchScope, false).findAll(); } diff --git a/platform/lang-impl/src/com/intellij/find/findUsages/PsiElement2UsageTargetAdapter.java b/platform/lang-impl/src/com/intellij/find/findUsages/PsiElement2UsageTargetAdapter.java index e5119f26d088..355224f4a9b5 100644 --- a/platform/lang-impl/src/com/intellij/find/findUsages/PsiElement2UsageTargetAdapter.java +++ b/platform/lang-impl/src/com/intellij/find/findUsages/PsiElement2UsageTargetAdapter.java @@ -116,6 +116,7 @@ public class PsiElement2UsageTargetAdapter return getElement(); } + @Override public String toString() { return getPresentableText(); } @@ -209,7 +210,7 @@ public class PsiElement2UsageTargetAdapter @Override public String getLongDescriptiveName() { SearchScope searchScope = myOptions.searchScope; - String scopeString = searchScope == null ? null : searchScope.getDisplayName(); + String scopeString = searchScope.getDisplayName(); PsiElement psiElement = getElement(); return psiElement == null ? UsageViewBundle.message("node.invalid") : diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/impl/BackgroundableProcessIndicator.java b/platform/platform-impl/src/com/intellij/openapi/progress/impl/BackgroundableProcessIndicator.java index 30ddb76d1f5f..5b06c79a3ad2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/impl/BackgroundableProcessIndicator.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/impl/BackgroundableProcessIndicator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -55,10 +55,12 @@ public class BackgroundableProcessIndicator extends ProgressWindow { if (myDumbModeAction == DumbModeAction.CANCEL) { task.getProject().getMessageBus().connect(this).subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() { + @Override public void enteredDumbMode() { cancel(); } + @Override public void exitDumbMode() { } }); @@ -69,6 +71,7 @@ public class BackgroundableProcessIndicator extends ProgressWindow { super(info.isCancellable(), true, project, info.getCancelText()); if (project != null) { final ProjectManagerAdapter myListener = new ProjectManagerAdapter() { + @Override public void projectClosing(Project closingProject) { if (isRunning()) { cancel(); @@ -107,23 +110,28 @@ public class BackgroundableProcessIndicator extends ProgressWindow { @Nls final String cancelButtonText, @Nls final String backgroundStopTooltip, final boolean cancellable) { this(project, new TaskInfo() { + @Override public String getProcessId() { return ""; } + @Override @NotNull public String getTitle() { return progressTitle; } + @Override public String getCancelText() { return cancelButtonText; } + @Override public String getCancelTooltipText() { return backgroundStopTooltip; } + @Override public boolean isCancellable() { return cancellable; } @@ -134,6 +142,7 @@ public class BackgroundableProcessIndicator extends ProgressWindow { return myDumbModeAction; } + @Override protected void showDialog() { if (myDisposed) return; @@ -144,6 +153,7 @@ public class BackgroundableProcessIndicator extends ProgressWindow { super.showDialog(); } + @Override public void background() { if (myDisposed) return; @@ -158,6 +168,7 @@ public class BackgroundableProcessIndicator extends ProgressWindow { } } + @Override public void dispose() { super.dispose(); myDisposed = true; diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageViewManagerImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageViewManagerImpl.java index 0e7bae22d452..055414932b33 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageViewManagerImpl.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageViewManagerImpl.java @@ -174,7 +174,7 @@ public class UsageViewManagerImpl extends UsageViewManager { final SearchForUsagesRunnable runnable = new SearchForUsagesRunnable(myProject, usageView, presentation, searchFor, searcherFactory, processPresentation, listener); final Factory progressIndicatorFactory = processPresentation.getProgressIndicatorFactory(); - final ProgressIndicator progressIndicator = progressIndicatorFactory != null ? progressIndicatorFactory.create() : null; + final ProgressIndicator progressIndicator = progressIndicatorFactory == null ? null : progressIndicatorFactory.create(); final AtomicBoolean findUsagesStartedShown = new AtomicBoolean(); ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { diff --git a/python/src/com/jetbrains/python/findUsages/PyModuleFindUsagesHandler.java b/python/src/com/jetbrains/python/findUsages/PyModuleFindUsagesHandler.java index 6588d2d389a6..fd0eef003d6f 100644 --- a/python/src/com/jetbrains/python/findUsages/PyModuleFindUsagesHandler.java +++ b/python/src/com/jetbrains/python/findUsages/PyModuleFindUsagesHandler.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. @@ -72,6 +72,7 @@ public class PyModuleFindUsagesHandler extends FindUsagesHandler { }; } + @NotNull @Override public Collection findReferencesToHighlight(@NotNull PsiElement target, @NotNull SearchScope searchScope) { if (target instanceof PyImportedModule) { From dd8d04b3da1db1eb5798b30123b18d23d7a2febb Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 19 Jun 2014 13:34:11 +0400 Subject: [PATCH 44/48] eclipse wizard test --- .../newProjectWizard/AbstractProjectWizard.java | 16 +++++++++++----- .../ide/projectWizard/ProjectWizardTestCase.java | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AbstractProjectWizard.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AbstractProjectWizard.java index 4afaad08b5ba..0b83da74e9f5 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AbstractProjectWizard.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AbstractProjectWizard.java @@ -154,6 +154,11 @@ public abstract class AbstractProjectWizard extends AbstractWizard extends PlatformTestCase { - protected static final String DEFAULT_SDK = "default"; protected final List mySdks = new ArrayList(); protected T myWizard; @@ -133,6 +132,7 @@ public abstract class ProjectWizardTestCase ext throw new RuntimeException(currentStep + " is not validated"); } } + myWizard.doFinishAction(); } protected void createWizard(Project project) throws IOException { From c2f4f867719a06e5c410895f2e88f6969e36da87 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Thu, 19 Jun 2014 13:53:59 +0400 Subject: [PATCH 45/48] dispose classNameField properly and unregister focus listener on dispose --- .../settings/CompoundRendererConfigurable.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/CompoundRendererConfigurable.java b/java/debugger/impl/src/com/intellij/debugger/settings/CompoundRendererConfigurable.java index 0f813d0bf167..e570b642b2bd 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/CompoundRendererConfigurable.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/CompoundRendererConfigurable.java @@ -25,12 +25,14 @@ import com.intellij.debugger.impl.DebuggerUtilsEx; import com.intellij.debugger.ui.DebuggerExpressionTextField; import com.intellij.debugger.ui.JavaDebuggerSupport; import com.intellij.debugger.ui.tree.render.*; +import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.editor.Document; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.UnnamedConfigurable; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Pair; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; @@ -141,10 +143,17 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable { } } }, myProject); - myClassNameField.getEditorTextField().addFocusListener(new FocusAdapter() { + final EditorTextField textField = myClassNameField.getEditorTextField(); + final FocusAdapter updateContextListener = new FocusAdapter() { public void focusLost(FocusEvent e) { - final String qName = myClassNameField.getText(); - updateContext(qName); + updateContext(myClassNameField.getText()); + } + }; + textField.addFocusListener(updateContextListener); + Disposer.register(myClassNameField, new Disposable() { + @Override + public void dispose() { + textField.removeFocusListener(updateContextListener); } }); @@ -388,10 +397,12 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable { myChildrenEditor.dispose(); myChildrenExpandedEditor.dispose(); myListChildrenEditor.dispose(); + Disposer.dispose(myClassNameField); myLabelEditor = null; myChildrenEditor = null; myChildrenExpandedEditor = null; myListChildrenEditor = null; + myClassNameField = null; myProject = null; } From 6f5f75498f0abe783046cb4d7150b06db9665541 Mon Sep 17 00:00:00 2001 From: Michael Golubev Date: Thu, 19 Jun 2014 12:16:04 +0200 Subject: [PATCH 46/48] IDEA-116460 - Heroku deployment: deployed application name should have correct name in ApplicationServers view --- .../runtime/deployment/ServerRuntimeInstance.java | 5 +++++ .../remoteServer/impl/runtime/ServerConnectionImpl.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/deployment/ServerRuntimeInstance.java b/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/deployment/ServerRuntimeInstance.java index b057fb30a7fa..b43598945b40 100644 --- a/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/deployment/ServerRuntimeInstance.java +++ b/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/deployment/ServerRuntimeInstance.java @@ -15,6 +15,11 @@ public abstract class ServerRuntimeInstance { public abstract void computeDeployments(@NotNull ComputeDeploymentsCallback callback); + @NotNull + public String getDeploymentName(@NotNull DeploymentSource source, D configuration) { + return getDeploymentName(source); + } + @NotNull public String getDeploymentName(@NotNull DeploymentSource source) { return source.getPresentableName(); diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ServerConnectionImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ServerConnectionImpl.java index fe43f2aa4f4d..da16b9e72609 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ServerConnectionImpl.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ServerConnectionImpl.java @@ -110,7 +110,7 @@ public class ServerConnectionImpl implements @Override public void connected(@NotNull ServerRuntimeInstance instance) { DeploymentSource source = task.getSource(); - String deploymentName = instance.getDeploymentName(source); + String deploymentName = instance.getDeploymentName(source, task.getConfiguration()); DeploymentImpl deployment; synchronized (myLocalDeployments) { deployment = new DeploymentImpl(deploymentName, DeploymentStatus.DEPLOYING, null, null, task); From fc706491de12ca7f96c79fa1347dc4b09ce99864 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 19 Jun 2014 12:32:31 +0200 Subject: [PATCH 47/48] IDEA-126353 (ignore AWT splash errors) --- .../src/com/intellij/idea/IdeaApplication.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java index 432fcb975812..94b25a1b3c94 100644 --- a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java +++ b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java @@ -218,7 +218,13 @@ public class IdeaApplication { @Nullable private SplashScreen getSplashScreen() { - return SplashScreen.getSplashScreen(); + try { + return SplashScreen.getSplashScreen(); + } + catch (Throwable t) { + LOG.warn(t); + return null; + } } @Override From f93d26e76662fcf21d343e37d21e710101b5a56b Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 19 Jun 2014 12:33:26 +0200 Subject: [PATCH 48/48] Cleanup (warnings) --- platform/bootstrap/src/com/intellij/idea/Main.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/bootstrap/src/com/intellij/idea/Main.java b/platform/bootstrap/src/com/intellij/idea/Main.java index 7c328536d678..ce8a2d0f14e9 100644 --- a/platform/bootstrap/src/com/intellij/idea/Main.java +++ b/platform/bootstrap/src/com/intellij/idea/Main.java @@ -29,6 +29,7 @@ import java.io.*; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Locale; @SuppressWarnings({"UseOfSystemOutOrSystemErr", "MethodNamesDifferingOnlyByCase"}) public class Main { @@ -122,7 +123,7 @@ public class Main { private static void installPatch() throws IOException { String platform = System.getProperty(PLATFORM_PREFIX_PROPERTY, "idea"); - String patchFileName = ("jetbrains.patch.jar." + platform).toLowerCase(); + String patchFileName = ("jetbrains.patch.jar." + platform).toLowerCase(Locale.US); String tempDir = System.getProperty("java.io.tmpdir"); // always delete previous patch copy @@ -148,6 +149,7 @@ public class Main { args.add(Restarter.createTempExecutable(launcher).getPath()); } + //noinspection SpellCheckingInspection Collections.addAll(args, System.getProperty("java.home") + "/bin/java", "-Xmx500m",