From 5115bf0bd3b9a075e11081db48faaf63733f2be3 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Tue, 26 Aug 2014 18:53:01 +0400 Subject: [PATCH 01/34] fixed PY-9389 Install package: enter in search field should select most relevant package in the list of packages --- .../com/intellij/webcore/packaging/ManagePackagesDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java b/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java index fcbaa21f330b..f66982282fa0 100644 --- a/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java +++ b/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java @@ -419,7 +419,7 @@ public class ManagePackagesDialog extends DialogWrapper { else { myFilteredOut.add(repoPackage); } - if (StringUtil.equals(packageName, filter)) toSelect = repoPackage; + if (StringUtil.equalsIgnoreCase(packageName, filter)) toSelect = repoPackage; } filter(filtered, toSelect); } From 8431cb2299c2beb26feeb42c737770b08d1f950f Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Tue, 26 Aug 2014 20:41:48 +0200 Subject: [PATCH 02/34] SSR: remove unused class --- .../plugin/ui/DialogBase.java | 152 ------------------ 1 file changed, 152 deletions(-) delete mode 100644 platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/DialogBase.java diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/DialogBase.java b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/DialogBase.java deleted file mode 100644 index 83d93ba0d05c..000000000000 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/DialogBase.java +++ /dev/null @@ -1,152 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui; - -import com.intellij.openapi.MnemonicHelper; -import com.intellij.CommonBundle; - -import javax.swing.*; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; -import java.awt.event.InputEvent; -import java.awt.*; - -import org.jetbrains.annotations.NonNls; - -/** - * Base dialog class - */ -public abstract class DialogBase extends JDialog { - private JButton ok; - private JButton cancel; - - private Action okAction; - private Action cancelAction; - private static Rectangle virtualBounds; - - class OkAction extends AbstractAction { - OkAction() { - putValue(NAME, CommonBundle.getOkButtonText()); - } - public void actionPerformed(ActionEvent e) { - doOKAction(); - } - } - - class CancelAction extends AbstractAction { - CancelAction() { - putValue(NAME,CommonBundle.getCancelButtonText()); - } - - public void actionPerformed(ActionEvent e) { - doCancelAction(); - } - } - - protected DialogBase() { - this(null); - } - - protected DialogBase(Frame frame) { - this(frame,true); - } - - protected DialogBase(Frame frame,boolean modal) { - super(frame,modal); - - new MnemonicHelper().register(getContentPane()); - - okAction = new OkAction(); - cancelAction = new CancelAction(); - - ok = createJButtonForAction(okAction); - cancel = createJButtonForAction(cancelAction); - - if (virtualBounds == null) { - GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); - GraphicsDevice[] gs = ge.getScreenDevices(); - virtualBounds = new Rectangle(); - - for (int j = 0; j < gs.length; j++) { - GraphicsDevice gd = gs[j]; - GraphicsConfiguration[] gc = gd.getConfigurations(); - - for (int i=0; i < gc.length; i++) { - virtualBounds = virtualBounds.union(gc[i].getBounds()); - } - } - } - - @NonNls String cancelCommandName = "close"; - KeyStroke escKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0); - ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escKeyStroke, cancelCommandName); - ok.getActionMap().put(cancelCommandName, cancelAction); - - @NonNls String startCommandName = "start"; - KeyStroke enterKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,InputEvent.CTRL_MASK); - ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(enterKeyStroke, startCommandName); - ok.getActionMap().put(startCommandName, okAction); - } - - protected JButton getCancelButton() { - return cancel; - } - - protected JButton getOkButton() { - return ok; - } - - protected abstract JComponent createCenterPanel(); - - protected JComponent createSouthPanel() { - JPanel p = new JPanel( null ); - p.setLayout( new BoxLayout(p,BoxLayout.X_AXIS) ); - p.add(Box.createHorizontalGlue()); - p.add(getOkButton()); - p.add(getCancelButton()); - return p; - } - - public void init() { - getContentPane().setLayout(new BorderLayout()); - getContentPane().add(BorderLayout.CENTER,createCenterPanel()); - getContentPane().add(BorderLayout.SOUTH,createSouthPanel()); - pack(); - - Dimension dim = getPreferredSize(); - setLocation( - (int)(virtualBounds.getWidth()/2 - dim.getWidth()/2), - (int)(virtualBounds.getHeight()/2 - dim.getHeight()/2) - ); - } - - public void show() { - pack(); - super.show(); - } - - protected void doCancelAction() { - setVisible(false); - } - - protected void doOKAction() { - setVisible(false); - } - - protected void setOKActionEnabled(boolean b) { - okAction.setEnabled(b); - } - - protected void setOKButtonText(String text) { - okAction.putValue(Action.NAME,text); - } - - protected void setCancelButtonText(String text) { - cancelAction.putValue(Action.NAME,text); - } - - protected JButton createJButtonForAction(Action _action) { - JButton jb = new JButton( (String)_action.getValue(Action.NAME) ); - jb.setAction(_action); - - return jb; - } -} From ba5739a2fa47979e9f93760d054e438384832d78 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 27 Aug 2014 12:51:35 +0400 Subject: [PATCH 03/34] show excluded files in Project View: enabled by default (IDEA-23537) --- platform/util/resources/misc/registry.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index d3999262e330..f5522c0e6f45 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -58,7 +58,7 @@ ide.checkDuplicateMnemonics.description=Check for duplicate mnemonics. ide.dnd.textHints=false ide.max.recent.projects=25 -ide.hide.excluded.files=true +ide.hide.excluded.files=false ide.hide.excluded.files.restartRequired=true ide.hide.excluded.files.description=Do not show excluded files in Project View and exclude them from VCS From 61aeee6effd0c8530d183b2901584f20b0b35310 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 27 Aug 2014 11:07:49 +0200 Subject: [PATCH 04/34] correct file movement handing in TempFileSystem --- .../impl/file/impl/TempFileSystemTest.java | 43 +++++++++++++++++++ .../openapi/vfs/ex/temp/TempFileSystem.java | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testSrc/com/intellij/psi/impl/file/impl/TempFileSystemTest.java diff --git a/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/TempFileSystemTest.java b/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/TempFileSystemTest.java new file mode 100644 index 000000000000..dbdd61bc340b --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/TempFileSystemTest.java @@ -0,0 +1,43 @@ +/* + * 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.psi.impl.file.impl; + +import com.intellij.openapi.roots.ProjectRootManager; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiDirectory; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiManager; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; + +import java.io.IOException; + +public class TempFileSystemTest extends LightPlatformCodeInsightFixtureTestCase { + public void testMove() { + ProjectRootManager rootManager = ProjectRootManager.getInstance(getProject()); + VirtualFile sourceRoot = rootManager.getContentSourceRoots()[0]; + PsiManager psiManager = PsiManager.getInstance(getProject()); + PsiDirectory psiSourceRoot = psiManager.findDirectory(sourceRoot); + PsiFile psiFile = psiSourceRoot.createFile("TestDocument.xml"); + try { + psiFile.getVirtualFile().move(this, psiSourceRoot.createSubdirectory("com").getVirtualFile()); + } catch (IOException e) { + e.printStackTrace(); + } + assertTrue(psiFile.isValid()); + psiFile.delete(); + assertFalse(psiFile.isValid()); + } +} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java b/platform/platform-impl/src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java index 1c6e173b45d1..18b33b281740 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java @@ -136,7 +136,7 @@ public class TempFileSystem extends LocalFileSystemBase { } fsItem.getParent().removeChild(fsItem); - ((FSDir)newParentItem).addChild(fsItem); + newDir.addChild(fsItem.isDirectory() ? new FSDir(newDir, fsItem.myName) : new FSFile(newDir, fsItem.myName)); } @Override From 3ac1432fb93c81d89ba68cbccb3c1267c3bbff38 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 27 Aug 2014 11:08:29 +0200 Subject: [PATCH 05/34] make testdata catch really incomplete --- .../codeInsight/completion/keywords/finalInIncompleteCatch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/java-tests/testData/codeInsight/completion/keywords/finalInIncompleteCatch.java b/java/java-tests/testData/codeInsight/completion/keywords/finalInIncompleteCatch.java index 6346b73dd045..0cdeb4962618 100644 --- a/java/java-tests/testData/codeInsight/completion/keywords/finalInIncompleteCatch.java +++ b/java/java-tests/testData/codeInsight/completion/keywords/finalInIncompleteCatch.java @@ -2,6 +2,6 @@ public class StructuredConfigKey { { try { - } catch () + } catch ( } } From 8631984b22c9c6f8e03fa111af25898b32f0ec30 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 27 Aug 2014 13:14:14 +0400 Subject: [PATCH 06/34] fixed PY-13024 Provide unified capitalization of tooltips and proper number. --- .../com/jetbrains/python/configuration/PythonPathEditor.java | 2 +- .../jetbrains/python/configuration/PythonSdkDetailsDialog.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/ide/src/com/jetbrains/python/configuration/PythonPathEditor.java b/python/ide/src/com/jetbrains/python/configuration/PythonPathEditor.java index 33169a79d267..0512bb051bf7 100644 --- a/python/ide/src/com/jetbrains/python/configuration/PythonPathEditor.java +++ b/python/ide/src/com/jetbrains/python/configuration/PythonPathEditor.java @@ -126,7 +126,7 @@ public class PythonPathEditor extends SdkPathEditor { @Override protected void addToolbarButtons(ToolbarDecorator toolbarDecorator) { - AnActionButton reloadButton = new AnActionButton("Reload List of Paths", AllIcons.Actions.Refresh) { + AnActionButton reloadButton = new AnActionButton("Reload list of paths", AllIcons.Actions.Refresh) { @Override public void actionPerformed(AnActionEvent e) { onReloadButtonClicked(); diff --git a/python/ide/src/com/jetbrains/python/configuration/PythonSdkDetailsDialog.java b/python/ide/src/com/jetbrains/python/configuration/PythonSdkDetailsDialog.java index b0ca6dbff65f..213b0e1e69d5 100644 --- a/python/ide/src/com/jetbrains/python/configuration/PythonSdkDetailsDialog.java +++ b/python/ide/src/com/jetbrains/python/configuration/PythonSdkDetailsDialog.java @@ -435,7 +435,7 @@ public class PythonSdkDetailsDialog extends DialogWrapper { private class ShowPathButton extends AnActionButton implements DumbAware { public ShowPathButton() { - super("Show path for the selected interpreter", AllIcons.Actions.ShowAsTree); + super("Show paths for the selected interpreter", AllIcons.Actions.ShowAsTree); } @Override From bd1b6df7ebffdef1de4634b7e17ce56ce319e550 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 27 Aug 2014 12:26:25 +0400 Subject: [PATCH 07/34] testng depends on methods checks: check duplicated method names (IDEA-127239) --- .../inspection/DependsOnMethodInspection.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnMethodInspection.java b/plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnMethodInspection.java index c7582025ee73..aeda466432a2 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnMethodInspection.java +++ b/plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnMethodInspection.java @@ -23,12 +23,14 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.HashSet; import com.theoryinpractice.testng.util.TestNGUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -83,10 +85,25 @@ public class DependsOnMethodInspection extends BaseJavaLocalInspectionTool } } } - Matcher matcher = PATTERN.matcher(text); + final Set names = new HashSet(); + final Matcher matcher = PATTERN.matcher(text); + int idx = 0; while (matcher.find()) { - String methodName = matcher.group(1); + String methodName = matcher.group(1); + if (!names.add(methodName)) { + PsiAnnotationMemberValue element2Highlight = value; + if (value instanceof PsiArrayInitializerMemberValue) { + final PsiAnnotationMemberValue[] initializers = ((PsiArrayInitializerMemberValue)value).getInitializers(); + if (idx < initializers.length) { + element2Highlight = initializers[idx]; + } + } + problemDescriptors.add(manager.createProblemDescriptor(element2Highlight, "Duplicated method name: " + methodName, + (LocalQuickFix)null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, + isOnTheFly)); + } checkMethodNameDependency(manager, psiClass, methodName, value, problemDescriptors, isOnTheFly); + idx++; } } } From 50dd7ae973ab5f88d30bf7a0b2962a916beddf9b Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 27 Aug 2014 13:07:12 +0400 Subject: [PATCH 08/34] testng doesn't calculate test methods if the same suite already contains class with explicitly defined methods (IDEA-108159) --- .../configuration/SearchingForTestsTask.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java index 413aceebf8d4..2258b16a7a2a 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java @@ -191,11 +191,22 @@ public class SearchingForTestsTask extends Task.Backgroundable { private void composeTestSuiteFromClasses() { Map> map = new HashMap>(); + + final boolean findTestMethodsForClass = shouldSearchForTestMethods(); + for (final Map.Entry> entry : myClasses.entrySet()) { - Collection methods = new HashSet(entry.getValue().size()); - for (PsiMethod method : entry.getValue()) { + final Collection depMethods = entry.getValue(); + Collection methods = new HashSet(depMethods.size()); + for (PsiMethod method : depMethods) { methods.add(method.getName()); } + if (findTestMethodsForClass && depMethods.isEmpty()) { + for (PsiMethod method : entry.getKey().getMethods()) { + if (TestNGUtil.hasTest(method)) { + methods.add(method.getName()); + } + } + } map.put(ApplicationManager.getApplication().runReadAction( new Computable() { @Nullable @@ -243,6 +254,17 @@ public class SearchingForTestsTask extends Task.Backgroundable { } } + private boolean shouldSearchForTestMethods() { + boolean dependantMethods = false; + for (Collection methods : myClasses.values()) { + if (!methods.isEmpty()) { + dependantMethods = true; + break; + } + } + return dependantMethods; + } + private void composeTestSuiteFromXml() throws CantRunException { final Map buildTestParams = buildTestParameters(); try { From 446cde856b9771b08b29673370886bd5bb985f0a Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 27 Aug 2014 13:25:16 +0400 Subject: [PATCH 09/34] testng: balloon notification coupled with finish so status line and message are in sync --- .../testng/configuration/TestNGRunnableState.java | 15 +-------------- .../testng/model/TestNGRemoteListener.java | 4 ---- .../theoryinpractice/testng/ui/TestNGResults.java | 3 ++- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGRunnableState.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGRunnableState.java index 21afb568e912..0c73ae5f5761 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGRunnableState.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGRunnableState.java @@ -144,19 +144,6 @@ public class TestNGRunnableState extends JavaCommandLineState { if (mySearchForTestIndicator != null && !mySearchForTestIndicator.isCanceled()) { task.finish(); } - - final Runnable notificationRunnable = new Runnable() { - public void run() { - final Project project = config.getProject(); - if (project.isDisposed()) return; - - final TestConsoleProperties consoleProperties = console.getProperties(); - if (consoleProperties == null) return; - final TestNGResults resultsView = console.getResultsView(); - TestsUIUtil.notifyByBalloon(project, myStarted, console.getResultsView().getRoot(), consoleProperties, "in " + resultsView.getTime()); - } - }; - SwingUtilities.invokeLater(notificationRunnable); } @Override @@ -175,7 +162,7 @@ public class TestNGRunnableState extends JavaCommandLineState { public void processWillTerminate(ProcessEvent event, boolean willBeDestroyed) { final TestNGResults resultsView = console.getResultsView(); if (resultsView != null) { - resultsView.finish(); + resultsView.finish(myStarted); } } diff --git a/plugins/testng/src/com/theoryinpractice/testng/model/TestNGRemoteListener.java b/plugins/testng/src/com/theoryinpractice/testng/model/TestNGRemoteListener.java index cf8598d8ae3f..b4e89b28a5c6 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/model/TestNGRemoteListener.java +++ b/plugins/testng/src/com/theoryinpractice/testng/model/TestNGRemoteListener.java @@ -48,10 +48,6 @@ public class TestNGRemoteListener implements IRemoteSuiteListener, IRemoteTestLi public void onFinish(SuiteMessage suiteMessage) { unboundOutputRoot.flush(); console.finish(); - final TestNGResults view = console.getResultsView(); - if (view != null) { - view.finish(); - } } public void onStart(TestMessage tm) { diff --git a/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java b/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java index 35b76d3e8367..78f980aea83d 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java +++ b/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java @@ -378,7 +378,7 @@ public class TestNGResults extends TestResultsPanel implements TestFrameworkRunn rootNode.setStarted(true); } - public void finish() { + public void finish(final boolean started) { if (start > 0) { end = System.currentTimeMillis(); } @@ -409,6 +409,7 @@ public class TestNGResults extends TestResultsPanel implements TestFrameworkRunn } } tree.repaint(); + TestsUIUtil.notifyByBalloon(project, started, rootNode, getProperties(), "in " + getTime()); } }); } From 26660c4924e9d48001872644278a99df54340f47 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Wed, 27 Aug 2014 13:35:59 +0400 Subject: [PATCH 10/34] EA-59788 In case of xml properties file myProperty.getPsiElement() is not instance of Property, class cast removed --- .../ResourceBundlePropertyStructureViewElement.java | 11 ++++------- .../lang/properties/editor/ResourceBundleEditor.java | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.java index 724a794ca3bb..14cb1cb940c4 100644 --- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.java +++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.java @@ -20,11 +20,8 @@ package com.intellij.lang.properties.editor; import com.intellij.ide.structureView.StructureViewTreeElement; -import com.intellij.lang.properties.IProperty; -import com.intellij.lang.properties.PropertiesHighlighter; -import com.intellij.lang.properties.PropertiesUtil; +import com.intellij.lang.properties.*; import com.intellij.lang.properties.ResourceBundle; -import com.intellij.lang.properties.psi.Property; import com.intellij.navigation.ColoredItemPresentation; import com.intellij.navigation.ItemPresentation; import com.intellij.openapi.editor.colors.EditorColorsManager; @@ -62,7 +59,7 @@ public class ResourceBundlePropertyStructureViewElement implements StructureView @Override public PsiElement[] getPsiElements() { - return new PsiElement[] {getProperty().getPsiElement()}; + return new PsiElement[] {getValue()}; } public void setPresentableName(final String presentableName) { @@ -70,8 +67,8 @@ public class ResourceBundlePropertyStructureViewElement implements StructureView } @Override - public Property getValue() { - return (Property)myProperty.getPsiElement(); + public PsiElement getValue() { + return myProperty.getPsiElement(); } @Override diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java index 39e9ed67e7b2..27deebbff2af 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java @@ -170,7 +170,7 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit TreeElement[] children = myStructureViewComponent.getTreeModel().getRoot().getChildren(); if (children.length != 0) { TreeElement child = children[0]; - String propName = ((ResourceBundlePropertyStructureViewElement)child).getValue().getUnescapedKey(); + String propName = ((ResourceBundlePropertyStructureViewElement)child).getProperty().getUnescapedKey(); setState(new ResourceBundleEditorState(propName)); } myDataProviderPanel = new DataProviderPanel(splitPanel); @@ -248,7 +248,7 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit DefaultMutableTreeNode node = toCheck.pop(); final ResourceBundleEditorViewElement element = getSelectedElement(node); String value = element instanceof ResourceBundlePropertyStructureViewElement - ? ((ResourceBundlePropertyStructureViewElement)element).getValue().getUnescapedKey() + ? ((ResourceBundlePropertyStructureViewElement)element).getProperty().getUnescapedKey() : null; if (propertyName.equals(value)) { nodeToSelect = node; From 037832267cee3882be4ade82cdfcde2b9a369577 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 27 Aug 2014 10:00:49 +0200 Subject: [PATCH 11/34] overrides --- .../com/intellij/ide/actions/ShowStructureSettingsAction.java | 4 +++- .../intellij/ide/actions/TemplateProjectStructureAction.java | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java b/java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java index eeb8d1b95a49..b43698ece136 100644 --- a/java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java +++ b/java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java @@ -37,6 +37,7 @@ import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; public class ShowStructureSettingsAction extends AnAction implements DumbAware { + @Override public void actionPerformed(AnActionEvent e) { Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); if (project == null) { @@ -61,7 +62,8 @@ public class ShowStructureSettingsAction extends AnAction implements DumbAware { return panel; } }.show(); - } else { + } + else { ShowSettingsUtil .getInstance().editConfigurable(project, OptionsEditorDialog.DIMENSION_KEY, ProjectStructureConfigurable.getInstance(project)); } diff --git a/java/idea-ui/src/com/intellij/ide/actions/TemplateProjectStructureAction.java b/java/idea-ui/src/com/intellij/ide/actions/TemplateProjectStructureAction.java index 0255cb005ee7..093552e12be0 100644 --- a/java/idea-ui/src/com/intellij/ide/actions/TemplateProjectStructureAction.java +++ b/java/idea-ui/src/com/intellij/ide/actions/TemplateProjectStructureAction.java @@ -25,6 +25,7 @@ import com.intellij.openapi.project.ex.ProjectManagerEx; import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable; public class TemplateProjectStructureAction extends AnAction implements DumbAware { + @Override public void actionPerformed(final AnActionEvent e) { Project defaultProject = ProjectManagerEx.getInstanceEx().getDefaultProject(); ShowSettingsUtil.getInstance().editConfigurable(defaultProject, OptionsEditorDialog.DIMENSION_KEY, ProjectStructureConfigurable.getInstance(defaultProject)); From 51c6f6a76a50df24ace71024b16b507b1664e10b Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 27 Aug 2014 11:18:11 +0200 Subject: [PATCH 12/34] use field instead of override --- .../intellij/execution/impl/EditConfigurationsDialog.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/impl/EditConfigurationsDialog.java b/platform/lang-impl/src/com/intellij/execution/impl/EditConfigurationsDialog.java index d206283375e2..265d9c3f7410 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/EditConfigurationsDialog.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/EditConfigurationsDialog.java @@ -26,7 +26,7 @@ public class EditConfigurationsDialog extends SingleConfigurableEditor implement protected Executor myExecutor; public EditConfigurationsDialog(final Project project) { - super(project, new RunConfigurable(project), IdeModalityType.PROJECT); + super(project, new RunConfigurable(project), "#com.intellij.execution.impl.EditConfigurationsDialog", IdeModalityType.PROJECT); ((RunConfigurable)getConfigurable()).setRunDialog(this); setTitle(ExecutionBundle.message("run.debug.dialog.title")); setHorizontalStretch(1.3F); @@ -42,11 +42,6 @@ public class EditConfigurationsDialog extends SingleConfigurableEditor implement } } - @Override - protected String getDimensionServiceKey() { - return "#com.intellij.execution.impl.EditConfigurationsDialog"; - } - @Nullable @Override public Executor getExecutor() { From 7ee9057e09b3b3a2e7b354104a48b2278883b068 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 27 Aug 2014 11:20:47 +0200 Subject: [PATCH 13/34] cleanup --- .../remoteServer/util/CloudAccountSelectionEditor.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.java index 5a3d150daf57..729a1e9bc605 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudAccountSelectionEditor.java @@ -127,21 +127,16 @@ public class CloudAccountSelectionEditor { } }; - final SingleConfigurableEditor configurableEditor - = new SingleConfigurableEditor(myMainPanel, configurable, ShowSettingsUtilImpl.createDimensionKey(configurable), false) { - + if (!new SingleConfigurableEditor(myMainPanel, configurable, ShowSettingsUtilImpl.createDimensionKey(configurable), false) { { errorConsumerRef.set(new Consumer() { - @Override public void consume(String s) { setErrorText(s); } }); } - }; - - if (!configurableEditor.showAndGet()) { + }.showAndGet()) { return; } From 39be6459a84d303ad98f70cd7c2c0efb826006ef Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 27 Aug 2014 11:33:13 +0200 Subject: [PATCH 14/34] =?UTF-8?q?single=20configurable=20editor=20?= =?UTF-8?q?=E2=80=94=20show=20Apply=20button=20only=20if=20it=20is=20worth?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/AdjustArrayRangeAction.java | 41 ++++++++----------- .../actions/CustomizeThreadsViewAction.java | 16 ++------ .../openapi/options/ShowSettingsUtil.java | 6 ++- .../ide/actionMacro/EditMacrosDialog.java | 37 ----------------- .../actionMacro/actions/EditMacrosAction.java | 21 ++++------ .../ide/actions/ShowSettingsUtilImpl.java | 40 +++++++++++------- .../project/impl/ProjectMacrosUtil.java | 12 +----- 7 files changed, 60 insertions(+), 113 deletions(-) delete mode 100644 platform/platform-impl/src/com/intellij/ide/actionMacro/EditMacrosDialog.java diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/AdjustArrayRangeAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/AdjustArrayRangeAction.java index 3a821fb10c0f..ce375815bb77 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/AdjustArrayRangeAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/AdjustArrayRangeAction.java @@ -23,12 +23,10 @@ import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl; import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl; import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl; import com.intellij.debugger.ui.tree.render.*; -import com.intellij.ide.actions.ShowSettingsUtilImpl; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.options.Configurable; -import com.intellij.openapi.options.ex.SingleConfigurableEditor; +import com.intellij.openapi.options.ShowSettingsUtil; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.DialogWrapper; import org.jetbrains.annotations.Nullable; public class AdjustArrayRangeAction extends DebuggerAction { @@ -67,30 +65,25 @@ public class AdjustArrayRangeAction extends DebuggerAction { title = title + " " + label.substring(index); } final ArrayRenderer clonedRenderer = renderer.clone(); - final NamedArrayConfigurable configurable = new NamedArrayConfigurable(title, clonedRenderer); - SingleConfigurableEditor editor = new SingleConfigurableEditor(project, configurable, - ShowSettingsUtilImpl.createDimensionKey(configurable), false); - editor.show(); - - if(editor.getExitCode() == DialogWrapper.OK_EXIT_CODE) { + if (ShowSettingsUtil.getInstance().editConfigurable(project, new NamedArrayConfigurable(title, clonedRenderer))) { debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(debuggerContext.getSuspendContext()) { - @Override - public void contextAction() throws Exception { - final ValueDescriptorImpl nodeDescriptor = (ValueDescriptorImpl)selectedNode.getDescriptor(); - final Renderer lastRenderer = nodeDescriptor.getLastRenderer(); - if (lastRenderer instanceof ArrayRenderer) { - selectedNode.setRenderer(clonedRenderer); - } - else if (lastRenderer instanceof CompoundNodeRenderer) { - final CompoundNodeRenderer compoundRenderer = (CompoundNodeRenderer)lastRenderer; - final ChildrenRenderer childrenRenderer = compoundRenderer.getChildrenRenderer(); - if (childrenRenderer instanceof ExpressionChildrenRenderer) { - ExpressionChildrenRenderer.setPreferableChildrenRenderer(nodeDescriptor, clonedRenderer); - selectedNode.calcRepresentation(); - } + @Override + public void contextAction() throws Exception { + final ValueDescriptorImpl nodeDescriptor = (ValueDescriptorImpl)selectedNode.getDescriptor(); + final Renderer lastRenderer = nodeDescriptor.getLastRenderer(); + if (lastRenderer instanceof ArrayRenderer) { + selectedNode.setRenderer(clonedRenderer); + } + else if (lastRenderer instanceof CompoundNodeRenderer) { + final CompoundNodeRenderer compoundRenderer = (CompoundNodeRenderer)lastRenderer; + final ChildrenRenderer childrenRenderer = compoundRenderer.getChildrenRenderer(); + if (childrenRenderer instanceof ExpressionChildrenRenderer) { + ExpressionChildrenRenderer.setPreferableChildrenRenderer(nodeDescriptor, clonedRenderer); + selectedNode.calcRepresentation(); } } - }); + } + }); } } diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/CustomizeThreadsViewAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/CustomizeThreadsViewAction.java index 64705a373a21..7cef867334df 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/CustomizeThreadsViewAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/CustomizeThreadsViewAction.java @@ -19,23 +19,15 @@ import com.intellij.debugger.settings.ThreadsViewConfigurable; import com.intellij.debugger.settings.ThreadsViewSettings; import com.intellij.idea.ActionsBundle; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.PlatformDataKeys; -import com.intellij.openapi.options.ex.SingleConfigurableEditor; -import com.intellij.openapi.project.Project; +import com.intellij.openapi.options.ShowSettingsUtil; -/** - * User: lex - * Date: Sep 26, 2003 - * Time: 4:40:12 PM - */ public class CustomizeThreadsViewAction extends DebuggerAction { + @Override public void actionPerformed(AnActionEvent e) { - Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); - final SingleConfigurableEditor editor = new SingleConfigurableEditor(project, new ThreadsViewConfigurable(ThreadsViewSettings.getInstance())); - editor.show(); + ShowSettingsUtil.getInstance().editConfigurable(e.getProject(), new ThreadsViewConfigurable(ThreadsViewSettings.getInstance())); } + @Override public void update(AnActionEvent e) { e.getPresentation().setVisible(true); e.getPresentation().setText(ActionsBundle.actionText(DebuggerActions.CUSTOMIZE_THREADS_VIEW)); diff --git a/platform/platform-api/src/com/intellij/openapi/options/ShowSettingsUtil.java b/platform/platform-api/src/com/intellij/openapi/options/ShowSettingsUtil.java index aac770691806..34eaf920d78d 100644 --- a/platform/platform-api/src/com/intellij/openapi/options/ShowSettingsUtil.java +++ b/platform/platform-api/src/com/intellij/openapi/options/ShowSettingsUtil.java @@ -43,19 +43,23 @@ public abstract class ShowSettingsUtil { public abstract boolean editConfigurable(@Nullable Component parent, @NotNull Configurable configurable); - public abstract boolean editConfigurable(Component parent, Configurable configurable, Runnable advancedInitialization); + public abstract boolean editConfigurable(Component parent, Configurable configurable, @NotNull Runnable advancedInitialization); public abstract boolean editConfigurable(Project project, @NonNls String dimensionServiceKey, Configurable configurable); + public abstract boolean editConfigurable(Project project, @NonNls String dimensionServiceKey, Configurable configurable, boolean showApplyButton); + public abstract boolean editConfigurable(Component parent, String dimensionServiceKey, Configurable configurable); /** * @deprecated create a new instance of configurable instead + * to remove in IDEA 15 */ public abstract T findProjectConfigurable(Project project, Class confClass); /** * @deprecated create a new instance of configurable instead + * to remove in IDEA 15 */ public abstract T findApplicationConfigurable(Class confClass); diff --git a/platform/platform-impl/src/com/intellij/ide/actionMacro/EditMacrosDialog.java b/platform/platform-impl/src/com/intellij/ide/actionMacro/EditMacrosDialog.java deleted file mode 100644 index 8b2c9acfaef5..000000000000 --- a/platform/platform-impl/src/com/intellij/ide/actionMacro/EditMacrosDialog.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2000-2009 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.actionMacro; - -import com.intellij.openapi.options.ex.SingleConfigurableEditor; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.Nullable; - -/** - * Created by IntelliJ IDEA. - * User: max - * Date: Jul 22, 2003 - * Time: 3:30:56 PM - * To change this template use Options | File Templates. - */ -public class EditMacrosDialog extends SingleConfigurableEditor { - public EditMacrosDialog(@Nullable Project project) { - super(project, new ActionMacroConfigurable()); - } - - protected String getDimensionServiceKey(){ - return "#com.intellij.ide.actionMacro.EditMacrosDialog"; - } -} diff --git a/platform/platform-impl/src/com/intellij/ide/actionMacro/actions/EditMacrosAction.java b/platform/platform-impl/src/com/intellij/ide/actionMacro/actions/EditMacrosAction.java index cb0d0ffd4619..c46241d1c4d9 100644 --- a/platform/platform-impl/src/com/intellij/ide/actionMacro/actions/EditMacrosAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actionMacro/actions/EditMacrosAction.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. @@ -16,29 +16,22 @@ package com.intellij.ide.actionMacro.actions; import com.intellij.ide.actionMacro.ActionMacro; +import com.intellij.ide.actionMacro.ActionMacroConfigurable; import com.intellij.ide.actionMacro.ActionMacroManager; -import com.intellij.ide.actionMacro.EditMacrosDialog; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.options.ShowSettingsUtil; import com.intellij.openapi.project.DumbAware; -/** - * Created by IntelliJ IDEA. - * User: max - * Date: Jul 22, 2003 - * Time: 3:33:04 PM - * To change this template use Options | File Templates. - */ public class EditMacrosAction extends AnAction implements DumbAware { + @Override public void actionPerformed(AnActionEvent e) { - EditMacrosDialog dialog = new EditMacrosDialog(CommonDataKeys.PROJECT.getData(e.getDataContext())); - dialog.show(); + ShowSettingsUtil.getInstance().editConfigurable(e.getProject(), "#com.intellij.ide.actionMacro.EditMacrosDialog", new ActionMacroConfigurable()); } + @Override public void update(AnActionEvent e) { - final ActionMacroManager manager = ActionMacroManager.getInstance(); - ActionMacro[] macros = manager.getAllMacros(); + ActionMacro[] macros = ActionMacroManager.getInstance().getAllMacros(); e.getPresentation().setEnabled(macros != null && macros.length > 0); } } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ShowSettingsUtilImpl.java b/platform/platform-impl/src/com/intellij/ide/actions/ShowSettingsUtilImpl.java index db7b289eb354..2c5cc5b02282 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ShowSettingsUtilImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ShowSettingsUtilImpl.java @@ -18,10 +18,7 @@ package com.intellij.ide.actions; import com.intellij.ide.ui.search.SearchUtil; import com.intellij.openapi.actionSystem.DataProvider; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.options.Configurable; -import com.intellij.openapi.options.ConfigurableGroup; -import com.intellij.openapi.options.SearchableConfigurable; -import com.intellij.openapi.options.ShowSettingsUtil; +import com.intellij.openapi.options.*; import com.intellij.openapi.options.ex.*; import com.intellij.openapi.options.newEditor.IdeSettingsDialog; import com.intellij.openapi.options.newEditor.OptionsEditor; @@ -31,6 +28,7 @@ import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.ui.navigation.Place; import com.intellij.util.ui.update.Activatable; import com.intellij.util.ui.update.UiNotifyConnector; import org.jetbrains.annotations.NotNull; @@ -60,6 +58,7 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil { if (Registry.is("ide.new.settings.dialog")) { return new IdeSettingsDialog(project, filteredGroups, toSelect); } + //noinspection deprecation return Registry.is("ide.perProjectModality") ? new OptionsEditorDialog(project, filteredGroups, toSelect, true) : new OptionsEditorDialog(project, filteredGroups, toSelect); @@ -160,8 +159,6 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil { public static void showSettingsDialog(@Nullable Project project, final String id2Select, final String filter) { ConfigurableGroup[] group = getConfigurableGroups(project, true); - Project actualProject = getProject(project); - group = filterEmptyGroups(group); final Configurable configurable2Select = findConfigurable2Select(id2Select, group); @@ -231,17 +228,29 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil { @Override public T findProjectConfigurable(final Project project, final Class confClass) { + //noinspection deprecation return ConfigurableExtensionPointUtil.findProjectConfigurable(project, confClass); } @Override public boolean editConfigurable(Project project, String dimensionServiceKey, @NotNull Configurable configurable) { - return editConfigurable(null, project, configurable, dimensionServiceKey, null); + return editConfigurable(project, dimensionServiceKey, configurable, isWorthToShowApplyButton(configurable)); + } + + private static boolean isWorthToShowApplyButton(@NotNull Configurable configurable) { + return configurable instanceof Place.Navigator || + configurable instanceof Composite || + configurable instanceof TabbedConfigurable; + } + + @Override + public boolean editConfigurable(Project project, String dimensionServiceKey, @NotNull Configurable configurable, boolean showApplyButton) { + return editConfigurable(null, project, configurable, dimensionServiceKey, null, showApplyButton); } @Override public boolean editConfigurable(Project project, Configurable configurable, Runnable advancedInitialization) { - return editConfigurable(null, project, configurable, createDimensionKey(configurable), advancedInitialization); + return editConfigurable(null, project, configurable, createDimensionKey(configurable), advancedInitialization, isWorthToShowApplyButton(configurable)); } @Override @@ -251,20 +260,21 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil { @Override public boolean editConfigurable(@Nullable Component parent, @NotNull Configurable configurable, @Nullable Runnable advancedInitialization) { - return editConfigurable(parent, null, configurable, createDimensionKey(configurable), advancedInitialization); + return editConfigurable(parent, null, configurable, createDimensionKey(configurable), advancedInitialization, isWorthToShowApplyButton(configurable)); } private static boolean editConfigurable(@Nullable Component parent, @Nullable Project project, @NotNull Configurable configurable, String dimensionKey, - @Nullable final Runnable advancedInitialization) { - SingleConfigurableEditor editor; + @Nullable final Runnable advancedInitialization, + boolean showApplyButton) { + final SingleConfigurableEditor editor; if (parent == null) { - editor = new SingleConfigurableEditor(project, configurable, dimensionKey); + editor = new SingleConfigurableEditor(project, configurable, dimensionKey, showApplyButton); } else { - editor = new SingleConfigurableEditor(parent, configurable, dimensionKey); + editor = new SingleConfigurableEditor(parent, configurable, dimensionKey, showApplyButton); } if (advancedInitialization != null) { new UiNotifyConnector.Once(editor.getContentPane(), new Activatable.Adapter() { @@ -284,8 +294,8 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil { } @Override - public boolean editConfigurable(Component parent, String dimensionServiceKey,Configurable configurable) { - return editConfigurable(parent, null, configurable, dimensionServiceKey, null); + public boolean editConfigurable(Component parent, String dimensionServiceKey, Configurable configurable) { + return editConfigurable(parent, null, configurable, dimensionServiceKey, null, isWorthToShowApplyButton(configurable)); } public boolean isAlreadyShown() { diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectMacrosUtil.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectMacrosUtil.java index 77baf2a6b98c..1f3b9d149ccc 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectMacrosUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectMacrosUtil.java @@ -25,17 +25,13 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.application.PathMacros; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.options.ex.SingleConfigurableEditor; -import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.options.ShowSettingsUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectBundle; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.WaitForProgressToShow; import org.jetbrains.annotations.NonNls; -import javax.swing.*; -import java.lang.reflect.InvocationTargetException; import java.util.*; public class ProjectMacrosUtil { @@ -50,11 +46,7 @@ public class ProjectMacrosUtil { if (application.isHeadlessEnvironment() || application.isUnitTestMode()) { throw new RuntimeException(text + ": " + StringUtil.join(undefinedMacros, ", ")); } - final UndefinedMacrosConfigurable configurable = - new UndefinedMacrosConfigurable(text, undefinedMacros); - final SingleConfigurableEditor editor = new SingleConfigurableEditor(project, configurable); - editor.show(); - return editor.isOK(); + return ShowSettingsUtil.getInstance().editConfigurable(project, new UndefinedMacrosConfigurable(text, undefinedMacros)); } public static boolean checkNonIgnoredMacros(final Project project, final Set usedMacros){ From 65badaada8137f41330b8c30183311a0cde9d8b3 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 27 Aug 2014 13:51:41 +0400 Subject: [PATCH 15/34] fixed PY-13529 PyClassHasNoInitInspection false positive in doctests --- .../python/documentation/doctest/PyDocstringVisitorFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/documentation/doctest/PyDocstringVisitorFilter.java b/python/src/com/jetbrains/python/documentation/doctest/PyDocstringVisitorFilter.java index e79d52cb1685..71af6aa30fea 100644 --- a/python/src/com/jetbrains/python/documentation/doctest/PyDocstringVisitorFilter.java +++ b/python/src/com/jetbrains/python/documentation/doctest/PyDocstringVisitorFilter.java @@ -43,7 +43,7 @@ public class PyDocstringVisitorFilter implements PythonVisitorFilter { visitorClass == PyByteLiteralInspection.class || visitorClass == PyNonAsciiCharInspection.class || visitorClass == PyPackageRequirementsInspection.class || visitorClass == PyMandatoryEncodingInspection.class || visitorClass == PyInterpreterInspection.class || visitorClass == PyDocstringTypesInspection.class || - visitorClass == PySingleQuotedDocstringInspection.class) { + visitorClass == PySingleQuotedDocstringInspection.class || visitorClass == PyClassHasNoInitInspection.class) { return false; } //annotators From db4cbeb0fee96db46e211ff661686e254cbec1fa Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Wed, 27 Aug 2014 14:23:37 +0400 Subject: [PATCH 16/34] IDEA-128953 Broken highlighting sometimes in CSS Live Template settings - use layered highlighter instead of composite lexer --- .../generation/GenerateByPatternDialog.java | 17 +++++ .../impl/LiveTemplateSettingsEditor.java | 12 +--- .../template/impl/TemplateEditorUtil.java | 68 ++++++++----------- .../structuralsearch/plugin/ui/UIUtil.java | 16 +---- 4 files changed, 49 insertions(+), 64 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/generation/GenerateByPatternDialog.java b/platform/lang-impl/src/com/intellij/codeInsight/generation/GenerateByPatternDialog.java index abdcf6c44047..8d64f7f30126 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/generation/GenerateByPatternDialog.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/generation/GenerateByPatternDialog.java @@ -1,3 +1,18 @@ +/* + * 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.codeInsight.generation; import com.intellij.codeInsight.template.Template; @@ -13,6 +28,7 @@ import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.treeStructure.SimpleTree; import com.intellij.ui.treeStructure.Tree; import com.intellij.util.containers.MultiMap; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -141,6 +157,7 @@ public class GenerateByPatternDialog extends DialogWrapper { private DefaultMutableTreeNode createNode(@Nullable PatternDescriptor descriptor) { DefaultMutableTreeNode root = new DefaultMutableTreeNode(descriptor) { + @NotNull @Override public String toString() { Object object = getUserObject(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java index 1988c9d1d8a4..a186e362fdd1 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.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. @@ -28,7 +28,6 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.editor.event.DocumentAdapter; import com.intellij.openapi.editor.event.DocumentEvent; -import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.ComboBox; import com.intellij.openapi.ui.popup.JBPopup; @@ -469,14 +468,7 @@ public class LiveTemplateSettingsEditor extends JPanel { } private void updateHighlighter() { - List applicableContexts = getApplicableContexts(); - if (!applicableContexts.isEmpty()) { - TemplateContext contextByType = new TemplateContext(); - contextByType.setEnabled(applicableContexts.get(0), true); - TemplateEditorUtil.setHighlighter(myTemplateEditor, contextByType); - return; - } - ((EditorEx) myTemplateEditor).repaint(0, myTemplateEditor.getDocument().getTextLength()); + TemplateEditorUtil.setHighlighter(myTemplateEditor, ContainerUtil.getFirstItem(getApplicableContexts())); } private void validateEditVariablesButton() { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateEditorUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateEditorUtil.java index 1570bb18c040..de4609158291 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateEditorUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateEditorUtil.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. @@ -18,7 +18,6 @@ package com.intellij.codeInsight.template.impl; import com.intellij.codeInsight.template.TemplateContextType; import com.intellij.ide.DataManager; -import com.intellij.lexer.CompositeLexer; import com.intellij.lexer.Lexer; import com.intellij.lexer.MergingLexerAdapter; import com.intellij.openapi.actionSystem.CommonDataKeys; @@ -31,7 +30,8 @@ import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.ex.EditorEx; -import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; +import com.intellij.openapi.editor.ex.util.LayerDescriptor; +import com.intellij.openapi.editor.ex.util.LayeredLexerEditorHighlighter; import com.intellij.openapi.editor.highlighter.EditorHighlighter; import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory; import com.intellij.openapi.fileEditor.FileDocumentManager; @@ -42,6 +42,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; +import com.intellij.util.ObjectUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -87,54 +88,43 @@ public class TemplateEditorUtil { if (file != null) { EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project); ((EditorEx) editor).setHighlighter(highlighter); + } return editor; } - public static void setHighlighter(Editor editor, TemplateContext templateContext) { - SyntaxHighlighter baseHighlighter = null; - for(TemplateContextType type: TemplateManagerImpl.getAllContextTypes()) { - if (templateContext.isEnabled(type)) { - baseHighlighter = type.createHighlighter(); - if (baseHighlighter != null) break; + public static void setHighlighter(Editor editor, @Nullable TemplateContext templateContext) { + SyntaxHighlighter highlighter = null; + if (templateContext != null) { + for(TemplateContextType type: TemplateManagerImpl.getAllContextTypes()) { + if (templateContext.isEnabled(type)) { + highlighter = type.createHighlighter(); + if (highlighter != null) break; + } } } - if (baseHighlighter == null) { - baseHighlighter = new PlainSyntaxHighlighter(); - } + setHighlighter((EditorEx)editor, highlighter); + } - SyntaxHighlighter highlighter = createTemplateTextHighlighter(baseHighlighter); - ((EditorEx)editor).setHighlighter(new LexerEditorHighlighter(highlighter, EditorColorsManager.getInstance().getGlobalScheme())); + public static void setHighlighter(@NotNull Editor editor, @Nullable TemplateContextType templateContextType) { + setHighlighter((EditorEx)editor, templateContextType != null ? templateContextType.createHighlighter() : null); + } + + private static void setHighlighter(EditorEx editor, @Nullable SyntaxHighlighter highlighter) { + EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme(); + LayeredLexerEditorHighlighter layeredHighlighter = new LayeredLexerEditorHighlighter(new TemplateHighlighter(), editorColorsScheme); + layeredHighlighter.registerLayer(TemplateTokenType.TEXT, new LayerDescriptor(ObjectUtils.notNull(highlighter, new PlainSyntaxHighlighter()), "")); + editor.setHighlighter(layeredHighlighter); } private final static TokenSet TOKENS_TO_MERGE = TokenSet.create(TemplateTokenType.TEXT); - private static SyntaxHighlighter createTemplateTextHighlighter(final SyntaxHighlighter original) { - return new TemplateHighlighter(original); - } - private static class TemplateHighlighter extends SyntaxHighlighterBase { private final Lexer myLexer; - private final SyntaxHighlighter myOriginalHighlighter; - public TemplateHighlighter(SyntaxHighlighter original) { - myOriginalHighlighter = original; - Lexer originalLexer = original.getHighlightingLexer(); - Lexer templateLexer = new TemplateTextLexer(); - templateLexer = new MergingLexerAdapter(templateLexer, TOKENS_TO_MERGE); - - myLexer = new CompositeLexer(originalLexer, templateLexer) { - @Override - protected IElementType getCompositeTokenType(IElementType type1, IElementType type2) { - if (type2 == TemplateTokenType.VARIABLE) { - return type2; - } - else { - return type1; - } - } - }; + public TemplateHighlighter() { + myLexer = new MergingLexerAdapter(new TemplateTextLexer(), TOKENS_TO_MERGE); } @Override @@ -146,11 +136,7 @@ public class TemplateEditorUtil { @Override @NotNull public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { - if (tokenType == TemplateTokenType.VARIABLE) { - return pack(myOriginalHighlighter.getTokenHighlights(tokenType), TemplateColors.TEMPLATE_VARIABLE_ATTRIBUTES); - } - - return myOriginalHighlighter.getTokenHighlights(tokenType); + return tokenType == TemplateTokenType.VARIABLE ? pack(TemplateColors.TEMPLATE_VARIABLE_ATTRIBUTES) : EMPTY; } } } diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UIUtil.java b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UIUtil.java index e2c16bfbc355..7521b9bbc014 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UIUtil.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UIUtil.java @@ -3,7 +3,6 @@ package com.intellij.structuralsearch.plugin.ui; import com.intellij.codeInsight.hint.TooltipController; import com.intellij.codeInsight.hint.TooltipGroup; import com.intellij.codeInsight.template.TemplateContextType; -import com.intellij.codeInsight.template.impl.TemplateContext; import com.intellij.codeInsight.template.impl.TemplateEditorUtil; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; @@ -77,12 +76,8 @@ public class UIUtil { else { ((EditorEx)editor).setEmbeddedIntoDialogWrapper(true); } - - if (contextType != null) { - TemplateContext context = new TemplateContext(); - context.setEnabled(contextType, true); - TemplateEditorUtil.setHighlighter(editor, context); - } + + TemplateEditorUtil.setHighlighter(editor, contextType); if (addToolTipForVariableHandler) { SubstitutionShortInfoHandler handler = new SubstitutionShortInfoHandler(editor); @@ -222,11 +217,6 @@ public class UIUtil { } public static void updateHighlighter(Editor editor, StructuralSearchProfile profile) { - final TemplateContextType contextType = profile.getTemplateContextType(); - if (contextType != null) { - TemplateContext context = new TemplateContext(); - context.setEnabled(contextType, true); - TemplateEditorUtil.setHighlighter(editor, context); - } + TemplateEditorUtil.setHighlighter(editor, profile.getTemplateContextType()); } } From a452619386ed45b2086a1ba29f55c4034d4017c3 Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Wed, 27 Aug 2014 14:24:10 +0400 Subject: [PATCH 17/34] @NotNull --- .../codeInsight/generation/GenerateByPatternDialog.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/generation/GenerateByPatternDialog.java b/platform/lang-impl/src/com/intellij/codeInsight/generation/GenerateByPatternDialog.java index 8d64f7f30126..f736a02d83bf 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/generation/GenerateByPatternDialog.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/generation/GenerateByPatternDialog.java @@ -71,8 +71,9 @@ public class GenerateByPatternDialog extends DialogWrapper { }; myTree.setRootVisible(false); myTree.setCellRenderer(new DefaultTreeCellRenderer() { + @NotNull @Override - public Component getTreeCellRendererComponent(JTree tree, + public Component getTreeCellRendererComponent(@NotNull JTree tree, Object value, boolean sel, boolean expanded, @@ -94,7 +95,7 @@ public class GenerateByPatternDialog extends DialogWrapper { myTree.setModel(new DefaultTreeModel(root)); myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override - public void valueChanged(TreeSelectionEvent e) { + public void valueChanged(@NotNull TreeSelectionEvent e) { update(); } }); From 35ce9aca67adf0bd30c54549b7aa2ecfefa41419 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 27 Aug 2014 14:25:08 +0400 Subject: [PATCH 18/34] fixed PY-13213 importlib.reload() fails code compatibility inspection. --- .../python/inspections/PyCompatibilityInspection.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/python/src/com/jetbrains/python/inspections/PyCompatibilityInspection.java b/python/src/com/jetbrains/python/inspections/PyCompatibilityInspection.java index c8a40a095134..0f69f4f72a56 100644 --- a/python/src/com/jetbrains/python/inspections/PyCompatibilityInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyCompatibilityInspection.java @@ -200,9 +200,7 @@ public class PyCompatibilityInspection extends PyInspection { } for (int i = 0; i != myVersionsToProcess.size(); ++i) { LanguageLevel languageLevel = myVersionsToProcess.get(i); - PsiFile file = resolved.getContainingFile(); - VirtualFile virtualFile = file.getVirtualFile(); - if (virtualFile != null && ind.isInLibraryClasses(virtualFile)) { + if (PyBuiltinCache.getInstance(resolved).isBuiltin(resolved)) { if (!"print".equals(name) && !myUsedImports.contains(name) && UnsupportedFeaturesUtil.BUILTINS.get(languageLevel).contains(name)) { len = appendLanguageLevel(message, len, languageLevel); } From 595bdd19ab99381f7e9c31e35758d4b3ed87fd36 Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Wed, 27 Aug 2014 14:26:11 +0400 Subject: [PATCH 19/34] @NotNull --- .../template/impl/LiveTemplateSettingsEditor.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java index a186e362fdd1..c14eca966e5f 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java @@ -51,7 +51,6 @@ import com.intellij.util.ui.tree.TreeUtil; import com.intellij.util.ui.update.Activatable; import com.intellij.util.ui.update.UiNotifyConnector; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; @@ -181,7 +180,7 @@ public class LiveTemplateSettingsEditor extends JPanel { myEditVariablesButton.addActionListener( new ActionListener(){ @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed(@NotNull ActionEvent e) { editVariables(); } } @@ -200,7 +199,7 @@ public class LiveTemplateSettingsEditor extends JPanel { myTemplate.parseSegments(); } - @Nullable + @NotNull private JComponent createNorthPanel() { JPanel panel = new JPanel(new GridBagLayout()); @@ -239,7 +238,7 @@ public class LiveTemplateSettingsEditor extends JPanel { myExpandByCombo = new ComboBox(new String[]{myDefaultShortcutItem, SPACE, TAB, ENTER}); myExpandByCombo.addItemListener(new ItemListener() { @Override - public void itemStateChanged(ItemEvent e) { + public void itemStateChanged(@NotNull ItemEvent e) { Object selectedItem = myExpandByCombo.getSelectedItem(); if(myDefaultShortcutItem.equals(selectedItem)) { myTemplate.setShortcutChar(TemplateSettings.DEFAULT_CHAR); @@ -277,7 +276,7 @@ public class LiveTemplateSettingsEditor extends JPanel { cb.setSelected(myOptions.get(processor).booleanValue()); cb.addActionListener(new ActionListener() { @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed(@NotNull ActionEvent e) { myOptions.put(processor, cb.isSelected()); } }); @@ -512,7 +511,7 @@ public class LiveTemplateSettingsEditor extends JPanel { myCbReformat.setSelected(myTemplate.isToReformat()); myCbReformat.addActionListener(new ActionListener() { @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed(@NotNull ActionEvent e) { myTemplate.setToReformat(myCbReformat.isSelected()); } }); From 9fdf039a118d5e2f8962cf62589e1ce2d2628b90 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 27 Aug 2014 14:43:15 +0400 Subject: [PATCH 20/34] error text in dialog: increase window size only after dialog is shown to ensure that actual size is computed properly (IDEA-129105) --- .../src/com/intellij/openapi/ui/DialogWrapper.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java index 75cb4de7af74..741f67dee2c4 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java @@ -1233,6 +1233,7 @@ public abstract class DialogWrapper { if (SystemInfo.isWindows) { installEnterHook(root); } + myErrorTextAlarm.setActivationComponent(root); } @NotNull @@ -1838,15 +1839,14 @@ public abstract class DialogWrapper { return; } myLastErrorText = text; - if (myActualSize == null && !StringUtil.isEmpty(text)) { - myActualSize = getSize(); - } - myErrorTextAlarm.cancelAllRequests(); myErrorTextAlarm.addRequest(new Runnable() { @Override public void run() { final String text = myLastErrorText; + if (myActualSize == null && !StringUtil.isEmpty(text)) { + myActualSize = getSize(); + } myErrorText.setError(text); if (text != null && text.length() > myMaxErrorTextLength) { // during the first update, resize only for growing. during a subsequent update, From f63b79263e6f7c225e8dc5131d8f9b19e1115318 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 27 Aug 2014 12:48:36 +0200 Subject: [PATCH 21/34] fixing move in TempFileSystem, second attempt --- .../src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java b/platform/platform-impl/src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java index 18b33b281740..33ecf625c05d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java @@ -136,7 +136,8 @@ public class TempFileSystem extends LocalFileSystemBase { } fsItem.getParent().removeChild(fsItem); - newDir.addChild(fsItem.isDirectory() ? new FSDir(newDir, fsItem.myName) : new FSFile(newDir, fsItem.myName)); + newDir.addChild(fsItem); + fsItem.myParent = newDir; } @Override @@ -263,7 +264,7 @@ public class TempFileSystem extends LocalFileSystemBase { } private abstract static class FSItem { - private final FSDir myParent; + private FSDir myParent; private String myName; private long myTimestamp; private boolean myWritable; From ae9245e1caac72ed08b36df3a12b1247183ff8f5 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 27 Aug 2014 12:10:37 +0200 Subject: [PATCH 22/34] cleanup --- .../intellij/execution/ui/layout/impl/RunnerContentUi.java | 7 ++----- .../intellij/openapi/options/CompositeConfigurable.java | 4 ++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java index 9df85468734a..3ff773241264 100644 --- a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java +++ b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java @@ -290,7 +290,8 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac final ContentManager manager = ContentFactory.SERVICE.getInstance().createContentManager(this, false, myProject); Disposer.register((Disposable)myRunnerUi, manager); manager.getComponent(); - } else { + } + else { final DockManager dockManager = DockManager.getInstance(myProject); if (dockManager != null) { //default project dockManager.register(this); @@ -1375,7 +1376,6 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac } private class MyComponent extends Wrapper.FocusHolder implements DataProvider, QuickActionProvider { - private boolean myWasEverAdded; public MyComponent() { @@ -1841,9 +1841,6 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac public void dragOutFinished(MouseEvent event, TabInfo source) { final Component component = event.getComponent(); final IdeFrame window = UIUtil.getParentOfType(IdeFrame.class, component); - if (window != null) { - - } mySession.process(event); mySession = null; } diff --git a/platform/platform-impl/src/com/intellij/openapi/options/CompositeConfigurable.java b/platform/platform-impl/src/com/intellij/openapi/options/CompositeConfigurable.java index 0b9e5ade8d29..aaba0fdbaf6b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/CompositeConfigurable.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/CompositeConfigurable.java @@ -20,18 +20,21 @@ import java.util.List; public abstract class CompositeConfigurable extends BaseConfigurable { private List myConfigurables; + @Override public void reset() { for (T configurable : getConfigurables()) { configurable.reset(); } } + @Override public void apply() throws ConfigurationException { for (T configurable : getConfigurables()) { configurable.apply(); } } + @Override public boolean isModified() { for (T configurable : getConfigurables()) { if (configurable.isModified()) { @@ -41,6 +44,7 @@ public abstract class CompositeConfigurable exten return false; } + @Override public void disposeUIResources() { if (myConfigurables != null) { for (final T myConfigurable : myConfigurables) { From cd49876eadedc59cf7688c64caced630a5a21374 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 27 Aug 2014 12:54:08 +0200 Subject: [PATCH 23/34] we must use original data context (critical to get XDebugSessionfr ) --- .../execution/ui/layout/impl/RunnerContentUi.java | 8 ++++++-- .../com/intellij/ui/content/impl/ContentManagerImpl.java | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java index 3ff773241264..5384ea06de23 100644 --- a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java +++ b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java @@ -1390,9 +1390,13 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac if (KEY.is(dataId)) { return RunnerContentUi.this; } - else { - return null; + + ContentManager originalContentManager = myOriginal == null ? null : myOriginal.getContentManager(); + JComponent originalContentComponent = originalContentManager == null ? null : originalContentManager.getComponent(); + if (originalContentComponent instanceof DataProvider) { + return ((DataProvider)originalContentComponent).getData(dataId); } + return null; } @SuppressWarnings("NullableProblems") diff --git a/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java b/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java index d0b110f083bf..73f5fc0c8921 100644 --- a/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java @@ -676,6 +676,11 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene dataProviders.add(provider); } + @Nullable + public DataProvider getDataProvider() { + return myComponent; + } + @Override public void propertyChange(@NotNull PropertyChangeEvent event) { if (Content.PROP_COMPONENT.equals(event.getPropertyName())) { From 71aaac546196bb673b5ff137c64ead78ae304f5f Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Wed, 27 Aug 2014 15:08:05 +0400 Subject: [PATCH 24/34] Proper highlighting file templates --- .../template/impl/TemplateEditorUtil.java | 4 +- .../impl/FileTemplateConfigurable.java | 63 ++++++++----------- 2 files changed, 27 insertions(+), 40 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateEditorUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateEditorUtil.java index de4609158291..dd30df23a493 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateEditorUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateEditorUtil.java @@ -118,13 +118,11 @@ public class TemplateEditorUtil { editor.setHighlighter(layeredHighlighter); } - private final static TokenSet TOKENS_TO_MERGE = TokenSet.create(TemplateTokenType.TEXT); - private static class TemplateHighlighter extends SyntaxHighlighterBase { private final Lexer myLexer; public TemplateHighlighter() { - myLexer = new MergingLexerAdapter(new TemplateTextLexer(), TOKENS_TO_MERGE); + myLexer = new MergingLexerAdapter(new TemplateTextLexer(), TokenSet.create(TemplateTokenType.TEXT)); } @Override diff --git a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateConfigurable.java b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateConfigurable.java index be3be30fc247..6da70c223688 100644 --- a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateConfigurable.java +++ b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateConfigurable.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. @@ -21,7 +21,6 @@ import com.intellij.ide.DataManager; import com.intellij.ide.IdeBundle; import com.intellij.ide.fileTemplates.FileTemplate; import com.intellij.ide.fileTemplates.FileTemplateManager; -import com.intellij.lexer.CompositeLexer; import com.intellij.lexer.FlexAdapter; import com.intellij.lexer.Lexer; import com.intellij.lexer.MergingLexerAdapter; @@ -38,7 +37,8 @@ import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.event.DocumentAdapter; import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.editor.ex.EditorEx; -import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; +import com.intellij.openapi.editor.ex.util.LayerDescriptor; +import com.intellij.openapi.editor.ex.util.LayeredLexerEditorHighlighter; import com.intellij.openapi.editor.highlighter.EditorHighlighter; import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory; import com.intellij.openapi.fileTypes.*; @@ -99,7 +99,7 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc private URL myDefaultDescriptionUrl; private final Project myProject; - private final List myChangeListeners = ContainerUtil.createLockFreeCopyOnWriteList();; + private final List myChangeListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private Splitter mySplitter; private final FileType myVelocityFileType = FileTypeManager.getInstance().getFileTypeByExtension("ft"); private JPanel myDescriptionPanel; @@ -221,8 +221,11 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc private Editor createEditor() { EditorFactory editorFactory = EditorFactory.getInstance(); - Document doc = myFile == null ? editorFactory.createDocument(myTemplate == null ? "" : myTemplate.getText()) : PsiDocumentManager.getInstance(myFile.getProject()).getDocument(myFile); - Editor editor = myProject == null ? editorFactory.createEditor(doc) : editorFactory.createEditor(doc, myProject); + Document doc = myFile == null + ? editorFactory.createDocument(myTemplate == null ? "" : myTemplate.getText()) + : PsiDocumentManager.getInstance(myFile.getProject()).getDocument(myFile); + assert doc != null; + Editor editor = editorFactory.createEditor(doc, myProject); EditorSettings editorSettings = editor.getSettings(); editorSettings.setVirtualSpace(false); @@ -367,7 +370,7 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc @Nullable private PsiFile createFile(final String text, final String name) { - if (myTemplate == null || myProject == null) return null; + if (myTemplate == null) return null; final FileType fileType = myVelocityFileType; if (fileType == FileTypes.UNKNOWN) return null; @@ -388,7 +391,7 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc } private EditorHighlighter createHighlighter() { - if (myTemplate != null && myProject != null && myVelocityFileType != FileTypes.UNKNOWN) { + if (myTemplate != null && myVelocityFileType != FileTypes.UNKNOWN) { return EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, new LightVirtualFile("aaa." + myTemplate.getExtension() + ".ft")); } @@ -399,38 +402,27 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc if (fileType == null) { fileType = FileTypes.PLAIN_TEXT; } + SyntaxHighlighter originalHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, null, null); - if (originalHighlighter == null) originalHighlighter = new PlainSyntaxHighlighter(); - return new LexerEditorHighlighter(new TemplateHighlighter(originalHighlighter), EditorColorsManager.getInstance().getGlobalScheme()); + if (originalHighlighter == null) { + originalHighlighter = new PlainSyntaxHighlighter(); + } + + final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); + LayeredLexerEditorHighlighter highlighter = new LayeredLexerEditorHighlighter(new TemplateHighlighter(), scheme); + highlighter.registerLayer(FileTemplateTokenType.TEXT, new LayerDescriptor(originalHighlighter, "")); + return highlighter; } - private final static TokenSet TOKENS_TO_MERGE = TokenSet.create(FileTemplateTokenType.TEXT); - private static class TemplateHighlighter extends SyntaxHighlighterBase { private final Lexer myLexer; - private final SyntaxHighlighter myOriginalHighlighter; - public TemplateHighlighter(SyntaxHighlighter original) { - myOriginalHighlighter = original; - Lexer originalLexer = original.getHighlightingLexer(); - Lexer templateLexer = new FlexAdapter(new FileTemplateTextLexer()); - templateLexer = new MergingLexerAdapter(templateLexer, TOKENS_TO_MERGE); - - myLexer = new CompositeLexer(originalLexer, templateLexer) { - @Override - protected IElementType getCompositeTokenType(IElementType type1, IElementType type2) { - if (type2 == FileTemplateTokenType.MACRO || type2 == FileTemplateTokenType.DIRECTIVE) { - return type2; - } - else { - return type1; - } - } - }; + public TemplateHighlighter() { + myLexer = new MergingLexerAdapter(new FlexAdapter(new FileTemplateTextLexer()), TokenSet.create(FileTemplateTokenType.TEXT)); } - @Override @NotNull + @Override public Lexer getHighlightingLexer() { return myLexer; } @@ -438,14 +430,11 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc @Override @NotNull public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { - if (tokenType == FileTemplateTokenType.MACRO) { - return pack(myOriginalHighlighter.getTokenHighlights(tokenType), TemplateColors.TEMPLATE_VARIABLE_ATTRIBUTES); - } - else if (tokenType == FileTemplateTokenType.DIRECTIVE) { - return pack(myOriginalHighlighter.getTokenHighlights(tokenType), TemplateColors.TEMPLATE_VARIABLE_ATTRIBUTES); + if (tokenType == FileTemplateTokenType.MACRO || tokenType == FileTemplateTokenType.DIRECTIVE) { + return pack(TemplateColors.TEMPLATE_VARIABLE_ATTRIBUTES); } - return myOriginalHighlighter.getTokenHighlights(tokenType); + return EMPTY; } } From 20aa3e6d51906070de14ec848b010d386beb7066 Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Wed, 27 Aug 2014 15:08:27 +0400 Subject: [PATCH 25/34] @NotNull --- .../ide/fileTemplates/impl/FileTemplateConfigurable.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateConfigurable.java b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateConfigurable.java index 6da70c223688..21702dc68f4f 100644 --- a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateConfigurable.java +++ b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateConfigurable.java @@ -205,13 +205,13 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc myNameField.addFocusListener(new FocusAdapter() { @Override - public void focusLost(FocusEvent e) { + public void focusLost(@NotNull FocusEvent e) { onNameChanged(); } }); myExtensionField.addFocusListener(new FocusAdapter() { @Override - public void focusLost(FocusEvent e) { + public void focusLost(@NotNull FocusEvent e) { onNameChanged(); } }); From f674d6367a36ab1f3474dd21862b1021206e8f8e Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Wed, 27 Aug 2014 15:08:39 +0400 Subject: [PATCH 26/34] Deprecating CompositeLexer --- .../src/com/intellij/lexer/CompositeLexer.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/platform/lang-api/src/com/intellij/lexer/CompositeLexer.java b/platform/lang-api/src/com/intellij/lexer/CompositeLexer.java index d728aff0e823..af456e0074ac 100644 --- a/platform/lang-api/src/com/intellij/lexer/CompositeLexer.java +++ b/platform/lang-api/src/com/intellij/lexer/CompositeLexer.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. @@ -18,6 +18,16 @@ package com.intellij.lexer; import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull; +/** + * Naive implementation of lexer that able to combine element types of two other lexers. + * + * The implementation doesn't give any guarantees about valid points of 'incremental relexing', + * because it returns start/end-offsets not for token that was used but for the shortest one. + * + * Also it reduces state size to 16 bits for nested lexer. + * + * @deprecated use {@link com.intellij.psi.templateLanguages.TemplateBlackAndWhiteLexer} or {@link com.intellij.lexer.LayeredLexer} instead + */ public abstract class CompositeLexer extends LexerBase { private final Lexer myLexer1; private final Lexer myLexer2; From ad37dcdccbf7f47c03bb2bd2b0060ca69bd22565 Mon Sep 17 00:00:00 2001 From: Sergey Savenko Date: Wed, 27 Aug 2014 15:28:46 +0400 Subject: [PATCH 27/34] IDEA-128753: correct table column and row header bounds for overlaid scrollbars on Mac --- .../src/com/intellij/ui/components/JBScrollPane.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java b/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java index 97a42176a25b..51535b67f9af 100644 --- a/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java +++ b/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java @@ -235,7 +235,7 @@ public class JBScrollPane extends JScrollPane { } if (colHead != null) { Rectangle headerBounds = colHead.getBounds(); - headerBounds.width = viewportBounds.width - headerBounds.x; + headerBounds.width = viewportBounds.width; colHead.setBounds(headerBounds); } hideFromView(layout.getCorner(UPPER_RIGHT_CORNER)); @@ -249,7 +249,7 @@ public class JBScrollPane extends JScrollPane { } if (rowHead != null) { Rectangle headerBounds = rowHead.getBounds(); - headerBounds.height = viewportBounds.height - headerBounds.y; + headerBounds.height = viewportBounds.height; rowHead.setBounds(headerBounds); } From 574238282d1e86e91379f241cfc7bd24640a7619 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 27 Aug 2014 13:31:01 +0200 Subject: [PATCH 28/34] =?UTF-8?q?fix=20NPE=20=E2=80=94=20we=20can=20select?= =?UTF-8?q?=20grouping=20node=20in=20Edit=20Configurations=20dialog,=20so,?= =?UTF-8?q?=20selected=20configuration=20will=20be=20null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/ChooseRunConfigurationPopup.java | 128 +++++++++--------- 1 file changed, 65 insertions(+), 63 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationPopup.java b/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationPopup.java index a4764dae0036..0c11e71e5886 100644 --- a/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationPopup.java +++ b/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationPopup.java @@ -30,6 +30,7 @@ import com.intellij.ide.util.PropertiesComponent; import com.intellij.idea.ActionsBundle; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.ListPopupStep; @@ -919,35 +920,77 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider { } } - public static ItemWrapper[] createSettingsList(@NotNull final Project project, @NotNull ExecutorProvider executorProvider, boolean createEditAction) { - final RunManagerEx manager = RunManagerEx.getInstanceEx(project); + public static ItemWrapper[] createSettingsList(@NotNull Project project, @NotNull ExecutorProvider executorProvider, boolean createEditAction) { + List result = new ArrayList(); - final List result = new ArrayList(); + if (createEditAction) { + ItemWrapper edit = new ItemWrapper(null) { + @Override + public Icon getIcon() { + return AllIcons.Actions.EditSource; + } + @Override + public String getText() { + return UIUtil.removeMnemonic(ActionsBundle.message("action.editRunConfigurations.text")); + } + + @Override + public void perform(@NotNull final Project project, @NotNull final Executor executor, @NotNull DataContext context) { + if (new EditConfigurationsDialog(project) { + @Override + protected void init() { + setOKButtonText(executor.getStartActionText()); + setOKButtonIcon(executor.getIcon()); + myExecutor = executor; + super.init(); + } + }.showAndGet()) { + ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override + public void run() { + RunnerAndConfigurationSettings configuration = RunManager.getInstance(project).getSelectedConfiguration(); + if (configuration != null) { + ExecutionUtil.runConfiguration(configuration, executor); + } + } + }, project.getDisposed()); + } + } + + @Override + public boolean available(Executor executor) { + return true; + } + }; + edit.setMnemonic(0); + result.add(edit); + } + + RunManagerEx manager = RunManagerEx.getInstanceEx(project); final RunnerAndConfigurationSettings selectedConfiguration = manager.getSelectedConfiguration(); - if (selectedConfiguration != null) { boolean isFirst = true; final ExecutionTarget activeTarget = ExecutionTargetManager.getActiveTarget(project); - for (final ExecutionTarget eachTarget : ExecutionTargetManager.getTargetsToChooseFor(project, selectedConfiguration)) { + for (ExecutionTarget eachTarget : ExecutionTargetManager.getTargetsToChooseFor(project, selectedConfiguration)) { result.add(new ItemWrapper(eachTarget, isFirst) { { - setChecked(eachTarget.equals(activeTarget)); + setChecked(getValue().equals(activeTarget)); } @Override public Icon getIcon() { - return eachTarget.getIcon(); + return getValue().getIcon(); } @Override public String getText() { - return eachTarget.getDisplayName(); + return getValue().getDisplayName(); } @Override public void perform(@NotNull final Project project, @NotNull final Executor executor, @NotNull DataContext context) { - ExecutionTargetManager.setActiveTarget(project, eachTarget); + ExecutionTargetManager.setActiveTarget(project, getValue()); ExecutionUtil.runConfiguration(selectedConfiguration, executor); } @@ -960,18 +1003,24 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider { } } - final Map wrappedExisting = new LinkedHashMap(); - final ConfigurationType[] types = manager.getConfigurationFactories(); - for (final ConfigurationType type : types) { + Map wrappedExisting = new LinkedHashMap(); + for (ConfigurationType type : manager.getConfigurationFactories()) { if (!(type instanceof UnknownConfigurationType)) { Map> structure = manager.getStructure(type); - for (final Map.Entry> entry : structure.entrySet()) { - if (entry.getValue().isEmpty()) + for (Map.Entry> entry : structure.entrySet()) { + if (entry.getValue().isEmpty()) { continue; + } + final String key = entry.getKey(); - if (key != null){ + if (key != null) { boolean isSelected = entry.getValue().contains(selectedConfiguration); - FolderWrapper folderWrapper = new FolderWrapper(project, executorProvider, key + (isSelected ? " (mnemonic is to \"" + selectedConfiguration.getName()+"\")" : ""), entry.getValue()); + if (isSelected) { + assert selectedConfiguration != null; + } + FolderWrapper folderWrapper = new FolderWrapper(project, executorProvider, + key + (isSelected ? " (mnemonic is to \"" + selectedConfiguration.getName() + "\")" : ""), + entry.getValue()); if (isSelected) { folderWrapper.setMnemonic(1); } @@ -992,53 +1041,6 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider { populateWithDynamicRunners(result, wrappedExisting, project, manager, selectedConfiguration); result.addAll(wrappedExisting.values()); - - //noinspection unchecked - final ItemWrapper edit = new ItemWrapper(null) { - @Override - public Icon getIcon() { - return AllIcons.Actions.EditSource; - } - - @Override - public String getText() { - return UIUtil.removeMnemonic(ActionsBundle.message("action.editRunConfigurations.text")); - } - - @Override - public void perform(@NotNull final Project project, @NotNull final Executor executor, @NotNull DataContext context) { - final EditConfigurationsDialog dialog = new EditConfigurationsDialog(project) { - @Override - protected void init() { - setOKButtonText(executor.getStartActionText()); - setOKButtonIcon(executor.getIcon()); - myExecutor = executor; - super.init(); - } - }; - - dialog.show(); - if (dialog.isOK()) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - ExecutionUtil.runConfiguration(RunManager.getInstance(project).getSelectedConfiguration(), executor); - } - }); - } - } - - @Override - public boolean available(Executor executor) { - return true; - } - }; - - edit.setMnemonic(0); - if (createEditAction) { - result.add(0, edit); - } - return result.toArray(new ItemWrapper[result.size()]); } From f7f9fe285e7e2b17212d6a8d6e14afb8be474858 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Wed, 27 Aug 2014 15:19:50 +0400 Subject: [PATCH 29/34] Keep compile messages after compilation; ability to activate and show compilation messages by clicking on a hyperlink in EventLog (IDEA-69971) --- .../compiler/impl/CompileContextImpl.java | 12 ++- .../intellij/compiler/impl/CompileDriver.java | 53 +++++++-- .../compiler/progress/CompilerTask.java | 102 ++++++++++-------- 3 files changed, 113 insertions(+), 54 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 c9e9ce31020a..f57753ef7afc 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java @@ -55,7 +55,7 @@ import java.util.*; public class CompileContextImpl extends UserDataHolderBase implements CompileContextEx { private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.CompileContextImpl"); private final Project myProject; - private final CompilerTask myTask; + private final CompilerTask myBuildSession; private final Map> myMessages = new EnumMap>(CompilerMessageCategory.class); private final boolean myShouldUpdateProblemsView; private CompileScope myCompileScope; @@ -77,7 +77,7 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon CompileScope compileScope, boolean isMake, boolean isRebuild) { myProject = project; - myTask = compilerSession; + myBuildSession = compilerSession; myCompileScope = compileScope; myMake = isMake; myIsRebuild = isRebuild; @@ -99,6 +99,10 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon myShouldUpdateProblemsView = workspaceConfig.MAKE_PROJECT_ON_SAVE; } + public CompilerTask getBuildSession() { + return myBuildSession; + } + public boolean shouldUpdateProblemsView() { return myShouldUpdateProblemsView; } @@ -154,7 +158,7 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon myMessages.put(msg.getCategory(), messages); } if (messages.add(msg)) { - myTask.addMessage(msg); + myBuildSession.addMessage(msg); } if (myShouldUpdateProblemsView && msg.getCategory() == CompilerMessageCategory.ERROR) { ProblemsView.SERVICE.getInstance(myProject).addMessage(msg, mySessionId); @@ -200,7 +204,7 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon } public ProgressIndicator getProgressIndicator() { - return myTask.getIndicator(); + return myBuildSession.getIndicator(); } public Module getModuleByFile(VirtualFile file) { 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 3ff7406c9f88..c40edf0f595c 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java @@ -29,6 +29,8 @@ import com.intellij.compiler.ProblemsView; import com.intellij.compiler.progress.CompilerTask; import com.intellij.compiler.server.BuildManager; import com.intellij.compiler.server.DefaultMessageHandler; +import com.intellij.notification.Notification; +import com.intellij.notification.NotificationListener; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.compiler.*; import com.intellij.openapi.compiler.ex.CompilerPathsEx; @@ -53,10 +55,7 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFileManager; -import com.intellij.openapi.wm.StatusBar; -import com.intellij.openapi.wm.ToolWindowId; -import com.intellij.openapi.wm.ToolWindowManager; -import com.intellij.openapi.wm.WindowManager; +import com.intellij.openapi.wm.*; import com.intellij.packaging.artifacts.Artifact; import com.intellij.packaging.impl.compiler.ArtifactCompilerUtil; import com.intellij.packaging.impl.compiler.ArtifactsCompiler; @@ -68,6 +67,7 @@ import com.intellij.util.ThrowableRunnable; import com.intellij.util.containers.HashMap; import com.intellij.util.containers.MultiMap; import com.intellij.util.messages.MessageBus; +import com.intellij.util.text.DateFormatUtil; import gnu.trove.THashSet; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -79,7 +79,9 @@ import org.jetbrains.jps.api.RequestFuture; import org.jetbrains.jps.model.java.JavaSourceRootType; import javax.swing.*; +import javax.swing.event.HyperlinkEvent; import java.io.File; +import java.lang.ref.WeakReference; import java.util.*; import java.util.concurrent.TimeUnit; @@ -502,9 +504,24 @@ public class CompileDriver { if (duration > ONE_MINUTE_MS && CompilerWorkspaceConfiguration.getInstance(myProject).DISPLAY_NOTIFICATION_POPUP) { ToolWindowManager.getInstance(myProject).notifyByBalloon(ToolWindowId.MESSAGES_WINDOW, messageType, statusMessage); } - CompilerManager.NOTIFICATION_GROUP.createNotification(statusMessage, messageType).notify(myProject); + + final String wrappedMessage = _status != ExitStatus.UP_TO_DATE? "" + statusMessage + "" : statusMessage; + final Notification notification = CompilerManager.NOTIFICATION_GROUP.createNotification( + "", wrappedMessage, + messageType.toNotificationType(), + new MessagesActivationListener(compileContext) + ); + compileContext.getBuildSession().registerCloseAction(new Runnable() { + @Override + public void run() { + notification.expire(); + } + }); + notification.notify(myProject); + if (_status != ExitStatus.UP_TO_DATE && compileContext.getMessageCount(null) > 0) { - compileContext.addMessage(CompilerMessageCategory.INFORMATION, statusMessage, null, -1, -1); + final String msg = DateFormatUtil.formatDateTime(new Date()) + " - " + statusMessage; + compileContext.addMessage(CompilerMessageCategory.INFORMATION, msg, null, -1, -1); } } } @@ -785,4 +802,28 @@ public class CompileDriver { private void showConfigurationDialog(String moduleNameToSelect, String tabNameToSelect) { ProjectSettingsService.getInstance(myProject).showModuleConfigurationDialog(moduleNameToSelect, tabNameToSelect); } + + private static class MessagesActivationListener extends NotificationListener.Adapter { + private final WeakReference myProjectRef; + private final Object myContentId; + + public MessagesActivationListener(CompileContextImpl compileContext) { + myProjectRef = new WeakReference(compileContext.getProject()); + myContentId = compileContext.getBuildSession().getContentId(); + } + + @Override + protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) { + final Project project = myProjectRef.get(); + if (project != null && !project.isDisposed() && CompilerTask.showCompilerContent(project, myContentId)) { + final ToolWindow tw = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW); + if (tw != null) { + tw.activate(null, false); + } + } + else { + notification.expire(); + } + } + } } diff --git a/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java b/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java index f568f2d06364..2f9f023bc52a 100644 --- a/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java +++ b/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java @@ -22,12 +22,11 @@ package com.intellij.compiler.progress; import com.intellij.compiler.CompilerManagerImpl; -import com.intellij.compiler.CompilerMessageImpl; import com.intellij.compiler.impl.CompilerErrorTreeView; import com.intellij.ide.errorTreeView.NewErrorTreeViewPanel; import com.intellij.ide.errorTreeView.impl.ErrorTreeViewConfiguration; import com.intellij.ide.impl.ProjectUtil; -import com.intellij.openapi.application.Application; +import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.compiler.*; @@ -42,6 +41,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.project.ProjectManagerListener; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VirtualFile; @@ -120,6 +120,26 @@ public class CompilerTask extends Task.Backgroundable { mySessionId = sessionId; } + @NotNull + public Object getContentId() { + return myContentId; + } + + public void registerCloseAction(final Runnable onClose) { + synchronized (myMessageViewLock) { + if (myErrorTreeView != null) { + Disposer.register(myErrorTreeView, new Disposable() { + @Override + public void dispose() { + onClose.run(); + } + }); + return; + } + } + onClose.run(); + } + @Override public String getProcessId() { return "compilation"; @@ -221,13 +241,15 @@ public class CompilerTask extends Task.Backgroundable { private void addIndicatorDelegate() { ProgressIndicator indicator = myIndicator; - if (!(indicator instanceof ProgressIndicatorEx)) return; + if (!(indicator instanceof ProgressIndicatorEx)) { + return; + } ((ProgressIndicatorEx)indicator).addStateDelegate(new ProgressIndicatorBase() { @Override public void cancel() { super.cancel(); - closeUI(); + selectFirstMessage(); stopAppIconProgress(); } @@ -235,11 +257,26 @@ public class CompilerTask extends Task.Backgroundable { public void stop() { super.stop(); if (!isCanceled()) { - closeUI(); + selectFirstMessage(); } stopAppIconProgress(); } + private void selectFirstMessage() { + if (!isHeadlessMode()) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + synchronized (myMessageViewLock) { + if (myErrorTreeView != null) { + myErrorTreeView.selectFirstMessage(); + } + } + } + }); + } + } + private void stopAppIconProgress() { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override @@ -249,7 +286,8 @@ public class CompilerTask extends Task.Backgroundable { if (myErrorCount > 0) { appIcon.setErrorBadge(myProject, String.valueOf(myErrorCount)); appIcon.requestAttention(myProject, true); - } else if (!myCompilationStartedAutomatically) { + } + else if (!myCompilationStartedAutomatically) { appIcon.setOkBadge(myProject, true); appIcon.requestAttention(myProject, false); } @@ -450,18 +488,22 @@ public class CompilerTask extends Task.Backgroundable { public void showCompilerContent() { synchronized (myMessageViewLock) { if (myErrorTreeView != null) { - final MessageView messageView = MessageView.SERVICE.getInstance(myProject); - Content[] contents = messageView.getContentManager().getContents(); - for (Content content : contents) { - if (CONTENT_ID_KEY.get(content) == myContentId) { - messageView.getContentManager().setSelectedContent(content); - return; - } - } + showCompilerContent(myProject, myContentId); } } } + public static boolean showCompilerContent(final Project project, final Object contentId) { + final MessageView messageView = MessageView.SERVICE.getInstance(project); + for (Content content : messageView.getContentManager().getContents()) { + if (CONTENT_ID_KEY.get(content) == contentId) { + messageView.getContentManager().setSelectedContent(content); + return true; + } + } + return false; + } + private void removeAllContents(Project project, Content notRemove) { if (project.isDisposed()) { return; @@ -488,7 +530,7 @@ public class CompilerTask extends Task.Backgroundable { private void activateMessageView() { synchronized (myMessageViewLock) { - if (myErrorTreeView != null) { + if (myErrorTreeView != null && myProject != null) { final ToolWindow tw = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW); if (tw != null) { tw.activate(null, false); @@ -497,34 +539,6 @@ public class CompilerTask extends Task.Backgroundable { } } - private void closeUI() { - if (isHeadlessMode()) { - return; - } - Window window = getWindow(); - ModalityState modalityState = window != null ? ModalityState.stateForComponent(window) : ModalityState.NON_MODAL; - final Application application = ApplicationManager.getApplication(); - application.invokeLater(new Runnable() { - @Override - public void run() { - synchronized (myMessageViewLock) { - if (myErrorTreeView != null) { - final boolean shouldRetainView = myErrorCount > 0 || myWarningCount > 0 && !myErrorTreeView.isHideWarnings(); - if (shouldRetainView) { - addMessage(new CompilerMessageImpl(myProject, CompilerMessageCategory.STATISTICS, CompilerBundle.message("statistics.error.count", myErrorCount))); - addMessage(new CompilerMessageImpl(myProject, CompilerMessageCategory.STATISTICS, CompilerBundle.message("statistics.warnings.count", myWarningCount))); - //activateMessageView(); - myErrorTreeView.selectFirstMessage(); - } - else { - removeAllContents(myProject, null); - } - } - } - } - }, modalityState); - } - public Window getWindow(){ return null; } @@ -607,7 +621,7 @@ public class CompilerTask extends Task.Backgroundable { if (event.getContent() == myContent) { synchronized (myMessageViewLock) { if (myErrorTreeView != null) { - myErrorTreeView.dispose(); + Disposer.dispose(myErrorTreeView); myErrorTreeView = null; if (myIndicator.isRunning()) { cancel(); From 7876e4782ca62369f25e9ca52cdc53172b5a8162 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 27 Aug 2014 15:51:20 +0400 Subject: [PATCH 30/34] fixed PY-12842 Replace with function call: invalid replacement with in expression form --- .../StatementEffectFunctionCallQuickFix.java | 76 +++++++++++++++++-- 1 file changed, 71 insertions(+), 5 deletions(-) diff --git a/python/src/com/jetbrains/python/inspections/quickfix/StatementEffectFunctionCallQuickFix.java b/python/src/com/jetbrains/python/inspections/quickfix/StatementEffectFunctionCallQuickFix.java index d852fbc55c83..30c14e4df30c 100644 --- a/python/src/com/jetbrains/python/inspections/quickfix/StatementEffectFunctionCallQuickFix.java +++ b/python/src/com/jetbrains/python/inspections/quickfix/StatementEffectFunctionCallQuickFix.java @@ -21,8 +21,10 @@ import com.intellij.openapi.project.Project; import com.intellij.psi.PsiComment; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiWhiteSpace; +import com.intellij.psi.impl.source.tree.LeafPsiElement; import com.jetbrains.python.PyBundle; import com.jetbrains.python.PyNames; +import com.jetbrains.python.PyTokenTypes; import com.jetbrains.python.psi.*; import org.jetbrains.annotations.NotNull; @@ -46,15 +48,80 @@ public class StatementEffectFunctionCallQuickFix implements LocalQuickFix { PsiElement expression = descriptor.getPsiElement(); if (expression != null && expression.isWritable() && expression instanceof PyReferenceExpression) { final String expressionText = expression.getText(); - if (PyNames.PRINT.equals(expressionText) || PyNames.EXEC.equals(expressionText)) - replacePrintExec(expression); + if (PyNames.PRINT.equals(expressionText)) + replacePrint(expression); + else if (PyNames.EXEC.equals(expressionText)) + replaceExec(expression); else expression.replace(PyElementGenerator.getInstance(project).createCallExpression(LanguageLevel.forElement(expression), expressionText)); } } - private static void replacePrintExec(@NotNull final PsiElement expression) { + private static void replaceExec(@NotNull final PsiElement expression) { + final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(expression.getProject()); + final String expressionText = expression.getText(); + final StringBuilder stringBuilder = new StringBuilder(expressionText + " ("); + + final PsiElement whiteSpace = expression.getContainingFile().findElementAt(expression.getTextOffset() + expression.getTextLength()); + PsiElement next = null; + if (whiteSpace instanceof PsiWhiteSpace) { + final String whiteSpaceText = whiteSpace.getText(); + if (!whiteSpaceText.contains("\n")) { + next = whiteSpace.getNextSibling(); + while (next instanceof PsiWhiteSpace && whiteSpaceText.contains("\\")) { + next = next.getNextSibling(); + } + } + } + else + next = whiteSpace; + + RemoveUnnecessaryBackslashQuickFix.removeBackSlash(next); + if (whiteSpace != null) whiteSpace.delete(); + if (next == null) { + stringBuilder.append(")"); + expression.replace(elementGenerator.createFromText(LanguageLevel.forElement(expression), PyExpression.class, + stringBuilder.toString())); + return; + } + if (next instanceof PyExpressionStatement) { + final PyExpression expr = ((PyExpressionStatement)next).getExpression(); + if (expr instanceof PyBinaryExpression) { + addInArguments(stringBuilder, (PyBinaryExpression)expr); + } + else if (expr instanceof PyTupleExpression) { + final PyExpression[] elements = ((PyTupleExpression)expr).getElements(); + if (elements.length > 1) { + if (elements[0] instanceof PyBinaryExpression) { + addInArguments(stringBuilder, (PyBinaryExpression)elements[0]); + } + stringBuilder.append(", "); + stringBuilder.append(elements[1].getText()); + } + } + } + else { + stringBuilder.append(next.getText()); + } + next.delete(); + stringBuilder.append(")"); + expression.replace(elementGenerator.createFromText(LanguageLevel.forElement(expression), PyExpression.class, + stringBuilder.toString())); + } + + private static void addInArguments(@NotNull final StringBuilder stringBuilder, @NotNull final PyBinaryExpression binaryExpression) { + final PsiElement operator = binaryExpression.getPsiOperator(); + if (operator instanceof LeafPsiElement && ((LeafPsiElement)operator).getElementType() == PyTokenTypes.IN_KEYWORD) { + stringBuilder.append(binaryExpression.getLeftExpression().getText()); + stringBuilder.append(", "); + final PyExpression rightExpression = binaryExpression.getRightExpression(); + if (rightExpression != null) + stringBuilder.append(rightExpression.getText()); + } + } + + private static void replacePrint(@NotNull final PsiElement expression) { final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(expression.getProject()); final String expressionText = expression.getText(); final StringBuilder stringBuilder = new StringBuilder(expressionText + " ("); @@ -84,8 +151,7 @@ public class StatementEffectFunctionCallQuickFix implements LocalQuickFix { final String text = next instanceof PyExpressionStatement ? ((PyExpressionStatement)next).getExpression().getText() : next.getText(); stringBuilder.append(text); - if (text.endsWith(",") && PyNames.PRINT.equals(expressionText)) - stringBuilder.append(" end=' '"); + if (text.endsWith(",")) stringBuilder.append(" end=' '"); next.delete(); } stringBuilder.append(")"); From d3cce01dd9fd65a20bb2b2b68a4a03277fe8da88 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Wed, 27 Aug 2014 15:56:27 +0400 Subject: [PATCH 31/34] speed search: allow to select items with shift modifiers --- .../src/com/intellij/ui/SpeedSearchBase.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java b/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java index cbcde2d36418..76985ad77362 100644 --- a/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java +++ b/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java @@ -298,6 +298,7 @@ public abstract class SpeedSearchBase extends SpeedSear protected void processKeyEvent(KeyEvent e) { if (e.isAltDown()) return; + if (e.isShiftDown() && isNavigationKey(e.getKeyCode())) return; if (mySearchPopup != null) { mySearchPopup.processKeyEvent(e); return; @@ -499,6 +500,15 @@ public abstract class SpeedSearchBase extends SpeedSear return keyCode == KeyEvent.VK_HOME || keyCode == KeyEvent.VK_END || keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN; } + private static boolean isPgUpPgDown(int keyCode) { + return keyCode == KeyEvent.VK_PAGE_UP || keyCode == KeyEvent.VK_PAGE_DOWN; + } + + private static boolean isNavigationKey(int keyCode) { + return isPgUpPgDown(keyCode) || isUpDownHomeEnd(keyCode); + } + + private void manageSearchPopup(@Nullable SearchPopup searchPopup) { Project project = null; if (ApplicationManager.getApplication() != null && !ApplicationManager.getApplication().isDisposed()) { From d9472eb5f8b472197de7cc7b49bf55e0cc07e884 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 27 Aug 2014 16:05:19 +0400 Subject: [PATCH 32/34] fixed PY-12024 "Replace mutable default argument" quickfix outputs non-standard formatting --- .../python/inspections/quickfix/PyDefaultArgumentQuickFix.java | 2 +- python/testData/inspections/DefaultArgument_after.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/python/src/com/jetbrains/python/inspections/quickfix/PyDefaultArgumentQuickFix.java b/python/src/com/jetbrains/python/inspections/quickfix/PyDefaultArgumentQuickFix.java index 31723d3aab4e..89453451f78b 100644 --- a/python/src/com/jetbrains/python/inspections/quickfix/PyDefaultArgumentQuickFix.java +++ b/python/src/com/jetbrains/python/inspections/quickfix/PyDefaultArgumentQuickFix.java @@ -74,7 +74,7 @@ public class PyDefaultArgumentQuickFix implements LocalQuickFix { } str.append("):\n\tpass"); PyIfStatement ifStatement = elementGenerator.createFromText(LanguageLevel.forElement(function), PyIfStatement.class, - "if not " + defName + ": " + defName + " = " + defaultValue.getText()); + "if not " + defName + ":\n\t" + defName + " = " + defaultValue.getText()); PyStatement firstStatement = list.getStatements()[0]; PyStringLiteralExpression docString = function.getDocStringExpression(); diff --git a/python/testData/inspections/DefaultArgument_after.py b/python/testData/inspections/DefaultArgument_after.py index e2036d24bf53..8007f9411df1 100644 --- a/python/testData/inspections/DefaultArgument_after.py +++ b/python/testData/inspections/DefaultArgument_after.py @@ -1,3 +1,4 @@ def foo(args=None): - if not args: args = [] + if not args: + args = [] pass \ No newline at end of file From e583078c4fc143ae7b713374e407305e2576cc0f Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 27 Aug 2014 16:33:04 +0400 Subject: [PATCH 33/34] fixed PY-13737 NPE at com.jetbrains.python.newProject.actions.AbstractProjectSettingsStep.checkValid --- .../python/newProject/actions/AbstractProjectSettingsStep.java | 1 + 1 file changed, 1 insertion(+) 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 af1d40876d50..1ad9cf7ececc 100644 --- a/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java +++ b/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java @@ -272,6 +272,7 @@ abstract public class AbstractProjectSettingsStep extends AbstractActionWithPane } public boolean checkValid() { + if (myLocationField == null) return true; final String projectName = myLocationField.getText(); setErrorText(null); myInstallFramework = false; From 448c933e6e0fb972760d404398bfb20aaee94db6 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 27 Aug 2014 16:34:54 +0400 Subject: [PATCH 34/34] cleanup --- .../surrounders/statements/PyWithIfElseSurrounder.java | 1 - .../surrounders/statements/PyWithIfSurrounder.java | 9 +++------ .../statements/PyWithTryExceptSurrounder.java | 2 -- .../statements/PyWithTryFinallySurrounder.java | 1 - .../surrounders/statements/PyWithWhileSurrounder.java | 1 - 5 files changed, 3 insertions(+), 11 deletions(-) diff --git a/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithIfElseSurrounder.java b/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithIfElseSurrounder.java index 76c4f4932038..1e1b6d0db815 100644 --- a/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithIfElseSurrounder.java +++ b/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithIfElseSurrounder.java @@ -44,7 +44,6 @@ public class PyWithIfElseSurrounder extends PyStatementSurrounder { PyElementGenerator.getInstance(project).createFromText(LanguageLevel.getDefault(), PyIfStatement.class, "if True:\n pass\nelse: pass\n"); final PsiElement parent = elements[0].getParent(); final PyStatementList statementList = ifStatement.getIfPart().getStatementList(); - assert statementList != null; statementList.addRange(elements[0], elements[elements.length - 1]); statementList.deleteChildRange(statementList.getFirstChild(), statementList.getFirstChild()); diff --git a/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithIfSurrounder.java b/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithIfSurrounder.java index 5ccca3de55e6..ac93e60af828 100644 --- a/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithIfSurrounder.java +++ b/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithIfSurrounder.java @@ -22,10 +22,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.util.IncorrectOperationException; -import com.jetbrains.python.psi.LanguageLevel; -import com.jetbrains.python.psi.PyElementGenerator; -import com.jetbrains.python.psi.PyIfStatement; -import com.jetbrains.python.psi.PyStatementList; +import com.jetbrains.python.psi.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,7 +37,6 @@ public class PyWithIfSurrounder extends PyStatementSurrounder { PyIfStatement ifStatement = PyElementGenerator.getInstance(project).createFromText(LanguageLevel.getDefault(), PyIfStatement.class, "if True:\n "); final PsiElement parent = elements[0].getParent(); final PyStatementList statementList = ifStatement.getIfPart().getStatementList(); - assert statementList != null; statementList.addRange(elements[0], elements[elements.length - 1]); ifStatement = (PyIfStatement) parent.addBefore(ifStatement, elements[0]); parent.deleteChildRange(elements[0], elements[elements.length - 1]); @@ -49,7 +45,8 @@ public class PyWithIfSurrounder extends PyStatementSurrounder { if (ifStatement == null) { return null; } - return ifStatement.getIfPart().getCondition().getTextRange(); + final PyExpression condition = ifStatement.getIfPart().getCondition(); + return condition != null ? condition.getTextRange() : null; } public String getTemplateDescription() { diff --git a/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithTryExceptSurrounder.java b/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithTryExceptSurrounder.java index 25a9f26308d3..7466def257f4 100644 --- a/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithTryExceptSurrounder.java +++ b/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithTryExceptSurrounder.java @@ -44,7 +44,6 @@ public class PyWithTryExceptSurrounder extends PyStatementSurrounder { createFromText(LanguageLevel.getDefault(), PyTryExceptStatement.class, getTemplate()); final PsiElement parent = elements[0].getParent(); final PyStatementList statementList = tryStatement.getTryPart().getStatementList(); - assert statementList != null; statementList.addRange(elements[0], elements[elements.length - 1]); statementList.getFirstChild().delete(); tryStatement = (PyTryExceptStatement)parent.addBefore(tryStatement, elements[0]); @@ -71,7 +70,6 @@ public class PyWithTryExceptSurrounder extends PyStatementSurrounder { protected TextRange getResultRange(PyTryExceptStatement tryStatement) { final PyExceptPart part = tryStatement.getExceptParts()[0]; final PyStatementList list = part.getStatementList(); - assert list != null; return list.getTextRange(); } diff --git a/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithTryFinallySurrounder.java b/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithTryFinallySurrounder.java index d457e32232c2..532fad5c5114 100644 --- a/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithTryFinallySurrounder.java +++ b/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithTryFinallySurrounder.java @@ -42,7 +42,6 @@ public class PyWithTryFinallySurrounder extends PyWithTryExceptSurrounder { final PyFinallyPart finallyPart = tryStatement.getFinallyPart(); assert finallyPart != null; final PyStatementList statementList = finallyPart.getStatementList(); - assert statementList != null; return statementList.getTextRange(); } } diff --git a/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithWhileSurrounder.java b/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithWhileSurrounder.java index 4ce663900065..a564d4ca3d3f 100644 --- a/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithWhileSurrounder.java +++ b/python/src/com/jetbrains/python/refactoring/surround/surrounders/statements/PyWithWhileSurrounder.java @@ -41,7 +41,6 @@ public class PyWithWhileSurrounder extends PyStatementSurrounder{ PyElementGenerator.getInstance(project).createFromText(LanguageLevel.getDefault(), PyWhileStatement.class, "while True:\n "); final PsiElement parent = elements[0].getParent(); final PyStatementList statementList = whileStatement.getWhilePart().getStatementList(); - assert statementList != null; statementList.addRange(elements[0], elements[elements.length - 1]); whileStatement = (PyWhileStatement) parent.addBefore(whileStatement, elements[0]); parent.deleteChildRange(elements[0], elements[elements.length - 1]);