From 8a048a161fc985071f74375b24ac491c009c8bb8 Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Tue, 9 Sep 2014 15:20:28 +0400 Subject: [PATCH 01/28] IDEA-129568 'Tab title limit' setting does not dither out when Tab Placement set to 'None' --- .../editor/EditorTabsConfigurable.java | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java index 35a34085d035..39271f5cc23e 100644 --- a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java +++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java @@ -69,21 +69,14 @@ public class EditorTabsConfigurable implements EditorOptionsProvider { private void revalidateSingleRowCheckbox() { final int i = ((Integer)myEditorTabPlacement.getSelectedItem()).intValue(); - if (i == UISettings.TABS_NONE) { - myHideKnownExtensions.setEnabled(false); - myScrollTabLayoutInEditorCheckBox.setEnabled(false); - myCbModifiedTabsMarkedWithAsterisk.setEnabled(false); - myShowTabsTooltipsCheckBox.setEnabled(false); - myShowCloseButtonOnCheckBox.setEnabled(false); - myShowDirectoryInTabCheckBox.setEnabled(false); - } else { - myHideKnownExtensions.setEnabled(true); - myScrollTabLayoutInEditorCheckBox.setEnabled(true); - myCbModifiedTabsMarkedWithAsterisk.setEnabled(true); - myShowTabsTooltipsCheckBox.setEnabled(true); - myShowCloseButtonOnCheckBox.setEnabled(true); - myShowDirectoryInTabCheckBox.setEnabled(true); - } + boolean none = i == UISettings.TABS_NONE; + myHideKnownExtensions.setEnabled(!none); + myScrollTabLayoutInEditorCheckBox.setEnabled(!none); + myCbModifiedTabsMarkedWithAsterisk.setEnabled(!none); + myShowTabsTooltipsCheckBox.setEnabled(!none); + myShowCloseButtonOnCheckBox.setEnabled(!none); + myShowDirectoryInTabCheckBox.setEnabled(!none); + myTabTitleLimitField.setEnabled(!none); if (SwingConstants.TOP == i) { myScrollTabLayoutInEditorCheckBox.setEnabled(true); From 984b6760d8dfc1ae49760cab8c6614aabcd922c7 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Tue, 9 Sep 2014 15:23:54 +0400 Subject: [PATCH 02/28] IDEA-129319 Settings: gap between header and list of links for a group in Alloy --- .../openapi/options/newEditor/OptionsEditor.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java index 6969bf0a6221..c1e55a1419a2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java @@ -17,7 +17,6 @@ package com.intellij.openapi.options.newEditor; import com.intellij.AbstractBundle; import com.intellij.CommonBundle; -import com.intellij.icons.AllIcons; import com.intellij.ide.ui.laf.darcula.ui.DarculaTextBorder; import com.intellij.ide.ui.laf.darcula.ui.DarculaTextFieldUI; import com.intellij.ide.ui.search.SearchUtil; @@ -1219,16 +1218,18 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat * @return default view for the specified configurable */ private JComponent createDefaultComponent(SearchableConfigurable searchable) { - JPanel box = new JPanel(); - box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS)); + JPanel panel = new JPanel(new BorderLayout(0, 9)); try { - box.add(new JLabel(getDefaultDescription(searchable))); + panel.add(BorderLayout.NORTH, new JLabel(getDefaultDescription(searchable))); } catch (AssertionError error) { return null; // description is not set } if (searchable instanceof Configurable.Composite) { - box.add(Box.createVerticalStrut(9)); + JPanel box = new JPanel(); + box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS)); + panel.add(BorderLayout.CENTER, box); + Configurable.Composite composite = (Configurable.Composite)searchable; for (final Configurable configurable : composite.getConfigurables()) { LinkLabel label = new LinkLabel(configurable.getDisplayName(), null) { @@ -1241,7 +1242,7 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat box.add(label); } } - return box; + return panel; } @NotNull From 1b2823d9cd4c21e3d24075a4c7c01e51ba635382 Mon Sep 17 00:00:00 2001 From: Liana Bakradze Date: Tue, 9 Sep 2014 15:49:07 +0400 Subject: [PATCH 03/28] EDU-150 open all task files on double click in project view --- .../edu/projectView/StudyDirectoryNode.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/python/edu/learn-python/src/com/jetbrains/python/edu/projectView/StudyDirectoryNode.java b/python/edu/learn-python/src/com/jetbrains/python/edu/projectView/StudyDirectoryNode.java index 2f80dba12695..d8faacd23946 100644 --- a/python/edu/learn-python/src/com/jetbrains/python/edu/projectView/StudyDirectoryNode.java +++ b/python/edu/learn-python/src/com/jetbrains/python/edu/projectView/StudyDirectoryNode.java @@ -1,8 +1,10 @@ package com.jetbrains.python.edu.projectView; import com.intellij.ide.projectView.PresentationData; +import com.intellij.ide.projectView.ProjectView; import com.intellij.ide.projectView.ViewSettings; import com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode; +import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDirectory; @@ -17,6 +19,7 @@ import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.*; +import java.util.Set; public class StudyDirectoryNode extends PsiDirectoryNode { private final PsiDirectory myValue; @@ -110,4 +113,56 @@ public class StudyDirectoryNode extends PsiDirectoryNode { data.addText(additionalName, new SimpleTextAttributes(Font.PLAIN, color)); data.setIcon(icon); } + + @Override + public boolean canNavigate() { + return true; + } + + @Override + public boolean canNavigateToSource() { + return true; + } + + @Override + public void navigate(boolean requestFocus) { + if (myValue.getName().contains(Task.TASK_DIR)) { + TaskFile taskFile = null; + VirtualFile virtualFile = null; + for (PsiElement child : myValue.getChildren()) { + VirtualFile childFile = child.getContainingFile().getVirtualFile(); + taskFile = StudyTaskManager.getInstance(myProject).getTaskFile(childFile); + if (taskFile != null) { + virtualFile = childFile; + break; + } + } + if (taskFile != null) { + VirtualFile taskDir = virtualFile.getParent(); + Task task = taskFile.getTask(); + for (VirtualFile openFile : FileEditorManager.getInstance(myProject).getOpenFiles()) { + FileEditorManager.getInstance(myProject).closeFile(openFile); + } + VirtualFile child = null; + Set fileNames = task.getTaskFiles().keySet(); + for (String name : fileNames) { + child = taskDir.findChild(name); + if (child != null) { + FileEditorManager.getInstance(myProject).openFile(child, true); + } + } + if (child != null) { + ProjectView.getInstance(myProject).select(child, child, false); + } + } + } + } + + @Override + public boolean expandOnDoubleClick() { + if (myValue.getName().contains(Task.TASK_DIR)) { + return false; + } + return super.expandOnDoubleClick(); + } } From b8a3e8d1c62925c55891cab27be04a88d2f8afe3 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 9 Sep 2014 14:41:45 +0400 Subject: [PATCH 04/28] shortcuts to navigate to prev/next comparison failure --- .../testframework/stacktrace/DiffHyperlink.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/platform/testRunner/src/com/intellij/execution/testframework/stacktrace/DiffHyperlink.java b/platform/testRunner/src/com/intellij/execution/testframework/stacktrace/DiffHyperlink.java index 34ab07903c38..f8ff62996eca 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/stacktrace/DiffHyperlink.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/stacktrace/DiffHyperlink.java @@ -27,10 +27,7 @@ import com.intellij.execution.testframework.Printable; import com.intellij.execution.testframework.Printer; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.icons.AllIcons; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.diff.*; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.LocalFileSystem; @@ -93,12 +90,20 @@ public class DiffHyperlink implements Printable { @Override public void customize(DiffToolbar toolbar) { toolbar.addAction(new NextPrevAction("Compare Previous Failure", AllIcons.Actions.Prevfile, chain) { + { + registerCustomShortcutSet(ActionManager.getInstance().getAction("PreviousTab").getShortcutSet(), null); + } + @Override protected AbstractTestProxy.AssertEqualsMultiDiffViewProvider getNextId() { return chain.getPrevious(); } }); toolbar.addAction(new NextPrevAction("Compare Next Failure", AllIcons.Actions.Nextfile, chain) { + { + registerCustomShortcutSet(ActionManager.getInstance().getAction("NextTab").getShortcutSet(), null); + } + @Override protected AbstractTestProxy.AssertEqualsMultiDiffViewProvider getNextId() { return chain.getNext(); From 92518cf5c974702a6818fa850fcb6b0a1a3e4fc5 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 9 Sep 2014 15:42:34 +0400 Subject: [PATCH 05/28] extract light method object: filter inaccessible variables --- .../ExtractLightMethodObjectHandler.java | 21 ++++++++++++++++--- .../AnonymousClassParams.java | 8 +++++++ .../ExtractMethodObject4DebuggerTest.java | 14 +++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 java/java-tests/testData/refactoring/extractMethodObject4Debugger/AnonymousClassParams.java diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractLightMethodObjectHandler.java b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractLightMethodObjectHandler.java index 3ed6d102713c..5833daaae396 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractLightMethodObjectHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractLightMethodObjectHandler.java @@ -22,18 +22,23 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.RangeMarker; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; +import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.codeStyle.CodeStyleManager; import com.intellij.psi.codeStyle.JavaCodeStyleManager; import com.intellij.psi.controlFlow.*; +import com.intellij.psi.util.PsiTreeUtil; import com.intellij.refactoring.extractMethod.AbstractExtractDialog; +import com.intellij.refactoring.extractMethod.ControlFlowWrapper; import com.intellij.refactoring.extractMethod.InputVariables; import com.intellij.refactoring.extractMethod.PrepareFailedException; +import com.intellij.refactoring.introduceField.ElementToWorkOn; import com.intellij.refactoring.util.RefactoringUtil; import com.intellij.refactoring.util.VariableData; import com.intellij.util.Function; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -105,9 +110,19 @@ public class ExtractLightMethodObjectHandler { return null; } - final List variables = ControlFlowUtil.getUsedVariables(controlFlow, - controlFlow.getStartOffset(elementsCopy[0]), - controlFlow.getEndOffset(elementsCopy[elementsCopy.length - 1])); + List variables = ControlFlowUtil.getUsedVariables(controlFlow, + controlFlow.getStartOffset(elementsCopy[0]), + controlFlow.getEndOffset(elementsCopy[elementsCopy.length - 1])); + + variables = ContainerUtil.filter(variables, new Condition() { + @Override + public boolean value(PsiVariable variable) { + final PsiElement variableScope = variable instanceof PsiParameter ? ((PsiParameter)variable).getDeclarationScope() + : PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class, PsiForStatement.class); + return variableScope != null && PsiTreeUtil.isAncestor(variableScope, elementsCopy[elementsCopy.length - 1], false); + } + }); + final String outputVariables = StringUtil.join(variables, new Function() { @Override diff --git a/java/java-tests/testData/refactoring/extractMethodObject4Debugger/AnonymousClassParams.java b/java/java-tests/testData/refactoring/extractMethodObject4Debugger/AnonymousClassParams.java new file mode 100644 index 000000000000..3a722d36aeea --- /dev/null +++ b/java/java-tests/testData/refactoring/extractMethodObject4Debugger/AnonymousClassParams.java @@ -0,0 +1,8 @@ +interface I { + void foo(int i) {} +} +class Sample { + void foo() { + System.out.println("hello world"); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java index e8ba1657602e..ea22976efee0 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java @@ -98,6 +98,20 @@ public class ExtractMethodObject4DebuggerTest extends LightRefactoringTestCase { " }"); } + public void testAnonymousClassParams() throws Exception { + doTest("new I() {public void foo(int i) {i++;}};", "new Test().invoke();", + + "public class Test {\n" + + " public void invoke() {\n" + + " new I() {\n" + + " public void foo(int i) {\n" + + " i++;\n" + + " }\n" + + " };\n" + + " }\n" + + " }"); + } + @Override protected Sdk getProjectJDK() { return IdeaTestUtil.getMockJdk18(); From b436ef2fa70872baf5a2f9aa8cdbffbae42abc3b Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Tue, 9 Sep 2014 16:01:27 +0400 Subject: [PATCH 06/28] IDEA-129568 'Tab title limit' setting does not dither out when Tab Placement set to 'None' --- .../application/options/editor/EditorTabsConfigurable.form | 2 +- .../application/options/editor/EditorTabsConfigurable.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form index edb9fcdb9e18..4bc9490d0090 100644 --- a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form +++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form @@ -109,7 +109,7 @@ - + diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java index 39271f5cc23e..93cde6a72f6d 100644 --- a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java +++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java @@ -46,6 +46,7 @@ public class EditorTabsConfigurable implements EditorOptionsProvider { private JCheckBox myShowDirectoryInTabCheckBox; private JRadioButton myActivateRightNeighbouringTabRadioButton; private JTextField myTabTitleLimitField; + private JLabel myTabTitleLimitLabel; public EditorTabsConfigurable() { myEditorTabPlacement.setModel(new DefaultComboBoxModel(new Object[]{ @@ -77,6 +78,7 @@ public class EditorTabsConfigurable implements EditorOptionsProvider { myShowCloseButtonOnCheckBox.setEnabled(!none); myShowDirectoryInTabCheckBox.setEnabled(!none); myTabTitleLimitField.setEnabled(!none); + myTabTitleLimitLabel.setEnabled(!none); if (SwingConstants.TOP == i) { myScrollTabLayoutInEditorCheckBox.setEnabled(true); From 65c661af28ecd5de1a57736c8ad39ce49b730bb3 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 9 Sep 2014 14:09:27 +0200 Subject: [PATCH 07/28] Expected a string but was NULL --- .../jetbrains/debugger/sourcemap/SourceMapDecoder.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceMapDecoder.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceMapDecoder.java index bfad136ce39a..88ed91ce0580 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceMapDecoder.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceMapDecoder.java @@ -132,7 +132,12 @@ public final class SourceMapDecoder { if (reader.peek() != JsonToken.END_ARRAY) { sourcesContent = new SmartList(); do { - sourcesContent.add(StringUtilRt.convertLineSeparators(reader.nextString())); + if (reader.peek() == JsonToken.STRING) { + sourcesContent.add(StringUtilRt.convertLineSeparators(reader.nextString())); + } + else { + reader.skipValue(); + } } while (reader.hasNext()); } @@ -430,4 +435,4 @@ public final class SourceMapDecoder { return MAPPING_COMPARATOR_BY_GENERATED_POSITION; } } -} \ No newline at end of file +} From ca3d4f86720a9437a11cf06004c111540b0f1be6 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 9 Sep 2014 16:29:15 +0400 Subject: [PATCH 08/28] cleanup --- .../src/com/intellij/xml/refactoring/XmlInlineHandler.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xml/impl/src/com/intellij/xml/refactoring/XmlInlineHandler.java b/xml/impl/src/com/intellij/xml/refactoring/XmlInlineHandler.java index bd3b6b0c8c80..865805796322 100644 --- a/xml/impl/src/com/intellij/xml/refactoring/XmlInlineHandler.java +++ b/xml/impl/src/com/intellij/xml/refactoring/XmlInlineHandler.java @@ -3,22 +3,23 @@ package com.intellij.xml.refactoring; import com.intellij.lang.refactoring.InlineHandler; import com.intellij.openapi.editor.Editor; import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; /** * @author Eugene.Kudelevsky */ public class XmlInlineHandler implements InlineHandler { @Override - public Settings prepareInlineElement(PsiElement element, Editor editor, boolean invokedOnReference) { + public Settings prepareInlineElement(@NotNull PsiElement element, Editor editor, boolean invokedOnReference) { return null; } @Override - public void removeDefinition(PsiElement element, Settings settings) { + public void removeDefinition(@NotNull PsiElement element, @NotNull Settings settings) { } @Override - public Inliner createInliner(PsiElement element, Settings settings) { + public Inliner createInliner(@NotNull PsiElement element, @NotNull Settings settings) { return null; } } From 945e62b964d757300a33f45ef18b9bc65099e915 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 9 Sep 2014 16:29:54 +0400 Subject: [PATCH 09/28] cleanup --- .../SchemaPrefixRenameHandler.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/xml/impl/src/com/intellij/xml/refactoring/SchemaPrefixRenameHandler.java b/xml/impl/src/com/intellij/xml/refactoring/SchemaPrefixRenameHandler.java index bc4ba667afa4..2c1f5a781fcb 100644 --- a/xml/impl/src/com/intellij/xml/refactoring/SchemaPrefixRenameHandler.java +++ b/xml/impl/src/com/intellij/xml/refactoring/SchemaPrefixRenameHandler.java @@ -15,7 +15,6 @@ */ package com.intellij.xml.refactoring; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Editor; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; @@ -35,12 +34,6 @@ import java.util.Collection; */ public class SchemaPrefixRenameHandler extends VariableInplaceRenameHandler { - @Override - protected boolean isAvailable(PsiElement element, Editor editor, PsiFile file) { - PossiblePrefixReference ref = getReference(file, editor); - return ref != null && ref.resolve() instanceof SchemaPrefix; - } - @Nullable private static PossiblePrefixReference getReference(PsiFile file, Editor editor) { if (file != null && editor != null) { @@ -54,6 +47,12 @@ public class SchemaPrefixRenameHandler extends VariableInplaceRenameHandler { } + @Override + protected boolean isAvailable(PsiElement element, Editor editor, PsiFile file) { + PossiblePrefixReference ref = getReference(file, editor); + return ref != null && ref.resolve() instanceof SchemaPrefix; + } + @Override protected VariableInplaceRenamer createRenamer(@NotNull PsiElement elementToRename, Editor editor) { PossiblePrefixReference reference = getReference(elementToRename.getContainingFile(), editor); @@ -71,12 +70,6 @@ public class SchemaPrefixRenameHandler extends VariableInplaceRenameHandler { }; } } - if (ApplicationManager.getApplication().isUnitTestMode()) { - System.out.println("Reference: " + reference); - if (reference != null) { - System.out.println("Resolved: " + reference.resolve()); - } - } return null; } } From 3435b08b5e347c13eb0ed0e15022b731ef12a3e1 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 9 Sep 2014 16:51:10 +0400 Subject: [PATCH 10/28] IDEA-124279 DOM: IndexedElementInvocationHandler triggers PSI building for @Stubbed --- .../intellij/util/xml/impl/IndexedElementInvocationHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/IndexedElementInvocationHandler.java b/xml/dom-impl/src/com/intellij/util/xml/impl/IndexedElementInvocationHandler.java index b77a838eb0ec..9a90fbf0fcec 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/IndexedElementInvocationHandler.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/IndexedElementInvocationHandler.java @@ -44,7 +44,7 @@ public class IndexedElementInvocationHandler extends DomInvocationHandler Date: Tue, 9 Sep 2014 17:13:14 +0400 Subject: [PATCH 11/28] native libraries support: allow selecting .dll/.so files instead of selecting parent directories --- ...efaultLibraryRootsComponentDescriptor.java | 39 ++++++++++++++----- .../libraries/ui/impl/RootDetectionUtil.java | 6 +-- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java index eb87df2a47e7..5b3e9302a14b 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java @@ -17,6 +17,7 @@ package com.intellij.openapi.roots.ui.configuration.libraryEditor; import com.intellij.codeInsight.ExternalAnnotationsManager; import com.intellij.openapi.fileChooser.FileChooserDescriptor; +import com.intellij.openapi.fileChooser.FileElement; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProgressIndicator; @@ -29,7 +30,9 @@ import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.ui.*; import com.intellij.openapi.roots.ui.OrderRootTypeUIFactory; import com.intellij.openapi.roots.ui.configuration.PathUIUtils; +import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileVisitor; @@ -45,6 +48,14 @@ import java.util.*; * @author nik */ public class DefaultLibraryRootsComponentDescriptor extends LibraryRootsComponentDescriptor { + private static final Set NATIVE_LIBRARY_EXTENSIONS = ContainerUtil.newTroveSet(FileUtil.PATH_HASHING_STRATEGY, "dll", "so", "dylib"); + public static final Condition LIBRARY_ROOT_CONDITION = new Condition() { + @Override + public boolean value(VirtualFile file) { + return FileElement.isArchive(file) || isNativeLibrary(file); + } + }; + @Override public OrderRootTypePresentation getRootTypePresentation(@NotNull OrderRootType type) { return getDefaultPresentation(type); @@ -67,10 +78,17 @@ public class DefaultLibraryRootsComponentDescriptor extends LibraryRootsComponen new AnnotationsRootFilter(), new NativeLibraryRootFilter()); } + private static boolean isNativeLibrary(VirtualFile file) { + String extension = file.getExtension(); + return extension != null && NATIVE_LIBRARY_EXTENSIONS.contains(extension); + } + @NotNull @Override public FileChooserDescriptor createAttachFilesChooserDescriptor(@Nullable String libraryName) { - FileChooserDescriptor descriptor = super.createAttachFilesChooserDescriptor(libraryName); + final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, true, false, true, true).withFileFilter(LIBRARY_ROOT_CONDITION); + descriptor.setTitle(StringUtil.isEmpty(libraryName) ? ProjectBundle.message("library.attach.files.action") + : ProjectBundle.message("library.attach.files.to.library.action", libraryName)); descriptor.setDescription(ProjectBundle.message("library.java.attach.files.description")); return descriptor; } @@ -119,24 +137,25 @@ public class DefaultLibraryRootsComponentDescriptor extends LibraryRootsComponen } } - private static class NativeLibraryRootFilter extends RootFilter { - private static final Set NATIVE_LIBRARY_EXTENSIONS = ContainerUtil.newTroveSet(FileUtil.PATH_HASHING_STRATEGY, "dll", "so", "dylib"); - + private static class NativeLibraryRootFilter extends RootDetector { private NativeLibraryRootFilter() { - super(NativeLibraryOrderRootType.getInstance(), false, "external annotations"); + super(NativeLibraryOrderRootType.getInstance(), false, "native library location"); } + @NotNull @Override - public boolean isAccepted(@NotNull VirtualFile rootCandidate, @NotNull ProgressIndicator progressIndicator) { + public Collection detectRoots(@NotNull VirtualFile rootCandidate, @NotNull ProgressIndicator progressIndicator) { if (rootCandidate.isDirectory()) { for (VirtualFile file : rootCandidate.getChildren()) { - String extension = file.getExtension(); - if (extension != null && NATIVE_LIBRARY_EXTENSIONS.contains(extension)) { - return true; + if (isNativeLibrary(file)) { + return Collections.singleton(rootCandidate); } } } - return false; + else if (isNativeLibrary(rootCandidate)) { + return Collections.singleton(rootCandidate.getParent()); + } + return Collections.emptyList(); } } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/ui/impl/RootDetectionUtil.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/ui/impl/RootDetectionUtil.java index cb0ad880a079..ca273ba2373d 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/ui/impl/RootDetectionUtil.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/ui/impl/RootDetectionUtil.java @@ -70,7 +70,7 @@ public class RootDetectionUtil { try { for (VirtualFile rootCandidate : rootCandidates) { final Collection roots = detector.detectRoots(rootCandidate, indicator); - if (!roots.isEmpty() && allRootsHaveOneTypeAndEqualTo(roots, rootCandidate)) { + if (!roots.isEmpty() && allRootsHaveOneTypeAndEqualToOrAreDirectParentOf(roots, rootCandidate)) { for (DetectedLibraryRoot root : roots) { final LibraryRootType libraryRootType = root.getTypes().get(0); result.add(new OrderRoot(root.getFile(), libraryRootType.getType(), libraryRootType.isJarDirectory())); @@ -141,9 +141,9 @@ public class RootDetectionUtil { return result; } - private static boolean allRootsHaveOneTypeAndEqualTo(Collection roots, VirtualFile candidate) { + private static boolean allRootsHaveOneTypeAndEqualToOrAreDirectParentOf(Collection roots, VirtualFile candidate) { for (DetectedLibraryRoot root : roots) { - if (root.getTypes().size() > 1 || !root.getFile().equals(candidate)) { + if (root.getTypes().size() > 1 || !root.getFile().equals(candidate) && !root.getFile().equals(candidate.getParent())) { return false; } } From 3e7ffb61bf872817c041f04b748b5248ee25d4ba Mon Sep 17 00:00:00 2001 From: Liana Bakradze Date: Tue, 9 Sep 2014 17:27:10 +0400 Subject: [PATCH 12/28] synchronized project view and selected task --- .../python/edu/actions/StudyTaskNavigationAction.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/python/edu/learn-python/src/com/jetbrains/python/edu/actions/StudyTaskNavigationAction.java b/python/edu/learn-python/src/com/jetbrains/python/edu/actions/StudyTaskNavigationAction.java index 46c0981cb964..b98bbd098776 100644 --- a/python/edu/learn-python/src/com/jetbrains/python/edu/actions/StudyTaskNavigationAction.java +++ b/python/edu/learn-python/src/com/jetbrains/python/edu/actions/StudyTaskNavigationAction.java @@ -1,5 +1,6 @@ package com.jetbrains.python.edu.actions; +import com.intellij.ide.projectView.ProjectView; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.project.DumbAwareAction; @@ -12,6 +13,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowId; import com.intellij.openapi.wm.ToolWindowManager; +import com.intellij.util.ui.tree.TreeUtil; import com.jetbrains.python.edu.StudyState; import com.jetbrains.python.edu.course.Lesson; import com.jetbrains.python.edu.course.Task; @@ -20,6 +22,7 @@ import com.jetbrains.python.edu.editor.StudyEditor; import org.jetbrains.annotations.NotNull; import javax.swing.*; +import javax.swing.tree.TreePath; import java.util.Map; @@ -74,7 +77,11 @@ abstract public class StudyTaskNavigationAction extends DumbAwareAction { } } } + JTree tree = ProjectView.getInstance(project).getCurrentProjectViewPane().getTree(); + TreePath path = TreeUtil.getFirstNodePath(tree); + tree.collapsePath(path); if (shouldBeActive != null) { + ProjectView.getInstance(project).select(shouldBeActive, shouldBeActive, false); FileEditorManager.getInstance(project).openFile(shouldBeActive, true); } ToolWindow runToolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.RUN); From 9304742bdafc930c5c08ff739d3c734fc1e2c198 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 9 Sep 2014 17:33:43 +0400 Subject: [PATCH 13/28] extract light method object: remove write action from operation on non-phisical elements --- .../extractMethod/ExtractMethodProcessor.java | 2 +- .../ExtractLightMethodObjectHandler.java | 40 ++++++++++++++++--- .../ExtractMethodObjectHandler.java | 6 ++- .../ExtractMethodObjectProcessor.java | 19 ++++----- 4 files changed, 47 insertions(+), 20 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java index 44d1c2f9da10..0b760502384a 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java @@ -625,7 +625,7 @@ public class ExtractMethodProcessor implements MatchProvider { } } - private void doExtract() throws IncorrectOperationException { + public void doExtract() throws IncorrectOperationException { PsiMethod newMethod = generateEmptyMethod(getThrownExceptions(), isStatic()); diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractLightMethodObjectHandler.java b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractLightMethodObjectHandler.java index 5833daaae396..a88e4383dc7a 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractLightMethodObjectHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractLightMethodObjectHandler.java @@ -17,27 +17,30 @@ package com.intellij.refactoring.extractMethodObject; import com.intellij.codeInsight.CodeInsightUtil; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.RangeMarker; +import com.intellij.openapi.editor.ScrollType; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.codeStyle.CodeStyleManager; -import com.intellij.psi.codeStyle.JavaCodeStyleManager; import com.intellij.psi.controlFlow.*; +import com.intellij.psi.impl.source.PostprocessReformattingAspect; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.refactoring.extractMethod.AbstractExtractDialog; -import com.intellij.refactoring.extractMethod.ControlFlowWrapper; import com.intellij.refactoring.extractMethod.InputVariables; import com.intellij.refactoring.extractMethod.PrepareFailedException; -import com.intellij.refactoring.introduceField.ElementToWorkOn; +import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.refactoring.util.RefactoringUtil; import com.intellij.refactoring.util.VariableData; +import com.intellij.refactoring.util.duplicates.DuplicatesImpl; +import com.intellij.usageView.UsageInfo; import com.intellij.util.Function; +import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -141,7 +144,32 @@ public class ExtractLightMethodObjectHandler { }; extractMethodObjectProcessor.getExtractProcessor().setShowErrorDialogs(false); - ExtractMethodObjectHandler.extractMethodObject(project, null, extractMethodObjectProcessor); + final ExtractMethodObjectProcessor.MyExtractMethodProcessor extractProcessor = extractMethodObjectProcessor.getExtractProcessor(); + if (extractProcessor.prepare() && CommonRefactoringUtil + .checkReadOnlyStatus(project, extractProcessor.getTargetClass().getContainingFile())) { + if (extractProcessor.showDialog()) { + CommandProcessor.getInstance().executeCommand(project, new Runnable() { + public void run() { + try { + extractProcessor.doExtract(); + + final UsageInfo[] usages = extractMethodObjectProcessor.findUsages(); + extractMethodObjectProcessor.performRefactoring(usages); + extractMethodObjectProcessor.runChangeSignature(); + } + catch (IncorrectOperationException e) { + LOG.error(e); + } + if (extractMethodObjectProcessor.isCreateInnerClass()) { + extractMethodObjectProcessor.changeInstanceAccess(project); + } + final PsiElement method = extractMethodObjectProcessor.getMethod(); + LOG.assertTrue(method != null); + method.delete(); + } + }, ExtractMethodObjectProcessor.REFACTORING_NAME, ExtractMethodObjectProcessor.REFACTORING_NAME); + } + } PsiDocumentManager.getInstance(project).commitAllDocuments(); diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectHandler.java b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectHandler.java index 8004dcf77578..459a7030457f 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectHandler.java @@ -105,7 +105,11 @@ public class ExtractMethodObjectHandler implements RefactoringActionHandler { } }); processor.run(); - processor.runChangeSignature(); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + processor.runChangeSignature(); + } + }); } catch (IncorrectOperationException e) { LOG.error(e); diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java index 769453de0199..49f4b2727cee 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java @@ -149,7 +149,7 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor { return UsageViewUtil.removeDuplicatedUsages(usageInfos); } - protected void performRefactoring(final UsageInfo[] usages) { + public void performRefactoring(final UsageInfo[] usages) { try { if (isCreateInnerClass()) { myInnerClass = (PsiClass)getMethod().getContainingClass().add(myElementFactory.createClass(getInnerClassName())); @@ -392,19 +392,14 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor { void runChangeSignature() { if (myCopyMethodToInner != null) { - ApplicationManager.getApplication().runWriteAction(myCopyMethodToInner); + myCopyMethodToInner.run(); } if (myChangeReturnType) { - final Runnable runnable = new Runnable() { - public void run() { - final PsiTypeElement typeElement = ((PsiLocalVariable)((PsiDeclarationStatement)JavaPsiFacade.getElementFactory(myProject) - .createStatementFromText(myInnerClassName + " l =null;", myInnerClass)).getDeclaredElements()[0]).getTypeElement(); - final PsiTypeElement innerMethodReturnTypeElement = myInnerMethod.getReturnTypeElement(); - LOG.assertTrue(innerMethodReturnTypeElement != null); - innerMethodReturnTypeElement.replace(typeElement); - } - }; - ApplicationManager.getApplication().runWriteAction(runnable); + final PsiTypeElement typeElement = ((PsiLocalVariable)((PsiDeclarationStatement)JavaPsiFacade.getElementFactory(myProject) + .createStatementFromText(myInnerClassName + " l =null;", myInnerClass)).getDeclaredElements()[0]).getTypeElement(); + final PsiTypeElement innerMethodReturnTypeElement = myInnerMethod.getReturnTypeElement(); + LOG.assertTrue(innerMethodReturnTypeElement != null); + innerMethodReturnTypeElement.replace(typeElement); } } From 29436dcf6980ab6e310416443b23171e60a24083 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Tue, 9 Sep 2014 15:33:44 +0400 Subject: [PATCH 14/28] use constant for generated class name --- .../intellij/debugger/engine/JavaDebuggerEvaluator.java | 2 +- .../debugger/ui/impl/watch/CompilingEvaluator.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebuggerEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebuggerEvaluator.java index 99ebf0b6a22b..949f1a33d606 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebuggerEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebuggerEvaluator.java @@ -74,7 +74,7 @@ public class JavaDebuggerEvaluator extends XDebuggerEvaluator { PsiFile psiFile = element.getContainingFile(); PsiCodeFragment fragment = descriptor.createCodeFragment(element); ExtractLightMethodObjectHandler.ExtractedData data = - ExtractLightMethodObjectHandler.extractLightMethodObject(project, psiFile, fragment, "test"); + ExtractLightMethodObjectHandler.extractLightMethodObject(project, psiFile, fragment, CompilingEvaluator.getGeneratedClassName()); descriptor.putUserData(CompilingEvaluator.COMPILING_EVALUATOR_DATA, data); } catch (Exception e) { diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluator.java index 537ad24789b9..cf8a96be8e9b 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluator.java @@ -51,9 +51,9 @@ public class CompilingEvaluator implements ExpressionEvaluator { private final PsiCodeFragment myCodeFragment; private final PsiElement myPsiContext; private final ExtractLightMethodObjectHandler.ExtractedData myData; + private final EvaluationDescriptor myDescriptor; public static Key COMPILING_EVALUATOR_DATA = new Key("COMPILING_EVALUATOR_DATA"); - private final EvaluationDescriptor myDescriptor; public CompilingEvaluator(TextWithImports text, PsiCodeFragment codeFragment, @@ -161,7 +161,11 @@ public class CompilingEvaluator implements ExpressionEvaluator { return reference; } - private static final String GEN_CLASS_NAME = "Test"; + public static String getGeneratedClassName() { + return GEN_CLASS_NAME; + } + + private static final String GEN_CLASS_NAME = "GeneratedEvaluationClass"; private static final String GEN_CLASS_PACKAGE = "dummy"; private static final String GEN_CLASS_FULL_NAME = GEN_CLASS_PACKAGE + '.' + GEN_CLASS_NAME; private static final String GEN_METHOD_NAME = "invoke"; From e770389a9654bd28c7b4a57343ad4ade011afe22 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Tue, 9 Sep 2014 17:25:10 +0400 Subject: [PATCH 15/28] correctly evaluate new inner classes --- .../intellij/debugger/engine/JVMNameUtil.java | 21 +++++--- .../expression/EvaluatorBuilderImpl.java | 49 ++++++++++++------- .../expression/NewClassInstanceEvaluator.java | 6 +-- 3 files changed, 50 insertions(+), 26 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JVMNameUtil.java b/java/debugger/impl/src/com/intellij/debugger/engine/JVMNameUtil.java index 13e8f155dff4..eeaa1c21015e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JVMNameUtil.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JVMNameUtil.java @@ -285,13 +285,20 @@ public class JVMNameUtil { return DebuggerManager.getInstance(aClass.getProject()).getVMClassQualifiedName(aClass); } + public static JVMName getJVMConstructorSignature(@Nullable PsiMethod method, @Nullable PsiClass declaringClass) { + return getJVMSignature(method, true, declaringClass); + } + + public static JVMName getJVMSignature(@NotNull PsiMethod method) { + return getJVMSignature(method, method.isConstructor(), method.getContainingClass()); + } + @SuppressWarnings({"HardCodedStringLiteral"}) - public static JVMName getJVMSignature(PsiMethod method) { + private static JVMName getJVMSignature(@Nullable PsiMethod method, boolean constructor, @Nullable PsiClass declaringClass) { JVMNameBuffer signature = new JVMNameBuffer(); signature.append("("); - if (method.isConstructor()) { - final PsiClass declaringClass = method.getContainingClass(); + if (constructor) { if (declaringClass != null) { final PsiClass outerClass = declaringClass.getContainingClass(); if (outerClass != null) { @@ -302,11 +309,13 @@ public class JVMNameUtil { } } } - for (PsiParameter psiParameter : method.getParameterList().getParameters()) { - appendJVMSignature(signature, psiParameter.getType()); + if (method != null) { + for (PsiParameter psiParameter : method.getParameterList().getParameters()) { + appendJVMSignature(signature, psiParameter.getType()); + } } signature.append(")"); - if (!method.isConstructor()) { + if (!constructor && method != null) { appendJVMSignature(signature, method.getReturnType()); } else { diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java index caeaee61f20b..61fee2fc7240 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java @@ -741,24 +741,28 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder { } private int calcIterationCount(final PsiJavaCodeReferenceElement qualifier) { - int iterationCount = 0; if (qualifier != null) { - PsiElement targetClass = qualifier.resolve(); - if (targetClass == null || getContextPsiClass() == null) { - throwEvaluateException(DebuggerBundle.message("evaluation.error.invalid.expression", qualifier.getText())); - } - try { - PsiClass aClass = getContextPsiClass(); - while (aClass != null && !aClass.equals(targetClass)) { - iterationCount++; - aClass = getOuterClass(aClass); - } - } - catch (Exception e) { - //noinspection ThrowableResultOfMethodCallIgnored - throw new EvaluateRuntimeException(EvaluateExceptionUtil.createEvaluateException(e)); + return calcIterationCount(qualifier.resolve(), qualifier.getText()); + } + return 0; + } + + private int calcIterationCount(PsiElement targetClass, String name) { + int iterationCount = 0; + if (targetClass == null || getContextPsiClass() == null) { + throwEvaluateException(DebuggerBundle.message("evaluation.error.invalid.expression", name)); + } + try { + PsiClass aClass = getContextPsiClass(); + while (aClass != null && !aClass.equals(targetClass)) { + iterationCount++; + aClass = getOuterClass(aClass); } } + catch (Exception e) { + //noinspection ThrowableResultOfMethodCallIgnored + throw new EvaluateRuntimeException(EvaluateExceptionUtil.createEvaluateException(e)); + } return iterationCount; } @@ -1187,8 +1191,11 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder { argumentEvaluators = wrapVarargs(constructor.getParameterList().getParameters(), argExpressions, constructorResolveResult.getSubstitutor(), argumentEvaluators); } - //noinspection HardCodedStringLiteral - JVMName signature = constructor != null ? JVMNameUtil.getJVMSignature(constructor) : JVMNameUtil.getJVMRawText("()V"); + if (aClass != null && aClass.getContainingClass() != null && !aClass.hasModifierProperty(PsiModifier.STATIC)) { + argumentEvaluators = addThisEvaluator(argumentEvaluators, aClass.getContainingClass()); + } + + JVMName signature = JVMNameUtil.getJVMConstructorSignature(constructor, aClass); myResult = new NewClassInstanceEvaluator( new TypeEvaluator(JVMNameUtil.getJVMQualifiedName(expressionPsiType)), signature, @@ -1205,6 +1212,14 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder { } } + private Evaluator[] addThisEvaluator(Evaluator[] argumentEvaluators, PsiClass cls) { + Evaluator[] res = new Evaluator[argumentEvaluators.length+1]; + int depth = calcIterationCount(cls, "this"); + res[0] = new ThisEvaluator(depth); + System.arraycopy(argumentEvaluators, 0, res, 1, argumentEvaluators.length); + return res; + } + @Override public void visitArrayInitializerExpression(PsiArrayInitializerExpression expression) { PsiExpression[] initializers = expression.getInitializers(); diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/NewClassInstanceEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/NewClassInstanceEvaluator.java index c3e7f8173322..3bbb0c633cd6 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/NewClassInstanceEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/NewClassInstanceEvaluator.java @@ -21,13 +21,13 @@ */ package com.intellij.debugger.engine.evaluation.expression; +import com.intellij.debugger.DebuggerBundle; import com.intellij.debugger.engine.DebugProcessImpl; +import com.intellij.debugger.engine.DebuggerUtils; import com.intellij.debugger.engine.JVMName; import com.intellij.debugger.engine.evaluation.EvaluateException; import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil; import com.intellij.debugger.engine.evaluation.EvaluationContextImpl; -import com.intellij.debugger.impl.DebuggerUtilsEx; -import com.intellij.debugger.DebuggerBundle; import com.sun.jdi.ClassType; import com.sun.jdi.Method; import com.sun.jdi.ObjectReference; @@ -55,7 +55,7 @@ class NewClassInstanceEvaluator implements Evaluator { } ClassType classType = (ClassType)obj; // find constructor - Method method = DebuggerUtilsEx.findMethod(classType, "", myConstructorSignature.getName(debugProcess)); + Method method = DebuggerUtils.findMethod(classType, "", myConstructorSignature.getName(debugProcess)); if (method == null) { throw EvaluateExceptionUtil.createEvaluateException( DebuggerBundle.message("evaluation.error.cannot.resolve.constructor", myConstructorSignature.getDisplayName(debugProcess))); From 349b87fe48adb4bf59a4f864afa9c4dcccb3e948 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Tue, 9 Sep 2014 17:37:14 +0400 Subject: [PATCH 16/28] compiling evaluator - support try-catch --- .../engine/evaluation/expression/EvaluatorBuilderImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java index 61fee2fc7240..7d0a4aeb0989 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java @@ -184,6 +184,11 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder { return rEvaluator; } + @Override + public void visitTryStatement(PsiTryStatement statement) { + throw new EvaluateRuntimeException(new UnsupportedExpressionException(statement.getText())); + } + @Override public void visitStatement(PsiStatement statement) { throwEvaluateException(DebuggerBundle.message("evaluation.error.statement.not.supported", statement.getText())); From bfc8db84d4a778e63174446cec7a6a60d8b00196 Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Tue, 9 Sep 2014 17:51:51 +0400 Subject: [PATCH 17/28] IDEA-127739 Navigation Tab Stage 5 better "resizing" UI for sliding toolwindow --- .../openapi/fileEditor/impl/PreviewPanel.java | 11 +- .../openapi/wm/impl/InternalDecorator.java | 196 ++++++++---------- 2 files changed, 93 insertions(+), 114 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/PreviewPanel.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/PreviewPanel.java index 1c9af86cd12a..54a81453553b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/PreviewPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/PreviewPanel.java @@ -47,6 +47,9 @@ import java.util.ArrayList; import java.util.EnumSet; class PreviewPanel extends JPanel { + + private CardLayout myLayout; + enum ContentType {Files, Usages, Diagrams, Documentation} private static final Key FILE_KEY = Key.create("v_file"); @@ -162,8 +165,12 @@ class PreviewPanel extends JPanel { myEditorsSplitters.createCurrentWindow(); myWindow = myEditorsSplitters.getCurrentWindow(); myWindow.setTabsPlacement(UISettings.TABS_NONE); - setLayout(new GridLayout(1, 1)); - add(myEditorsSplitters); + myLayout = new CardLayout(); + setLayout(myLayout); + add(ContentType.Files.toString(), myEditorsSplitters); + //add(ContentType.Usages.toString(), myUsagesPreview);??? tree or editor ??? + //add(ContentType.Diagrams.toString(), myDiagramPanel); + //add(ContentType.Documentation.toString(), myDocumentationPanel);//todo myToolWindow.setTitleActions(new MoveToEditorTabsAction(), new CloseFileAction()); ArrayList myGearActions = new ArrayList(); for (ContentType contentType : ContentType.values()) { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java index 17acd7d1ee66..ba5c59a9ac25 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java @@ -17,6 +17,7 @@ package com.intellij.openapi.wm.impl; import com.intellij.ide.actions.ResizeToolWindowAction; import com.intellij.idea.ActionsBundle; +import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.keymap.Keymap; import com.intellij.openapi.keymap.KeymapManagerListener; @@ -55,8 +56,6 @@ import java.util.Map; */ public final class InternalDecorator extends JPanel implements Queryable, TypeSafeDataProvider { - private static final int DIVIDER_WIDTH = UIUtil.isUnderDarcula() ? 2 : 5; - private Project myProject; private WindowInfoImpl myInfo; private final ToolWindowImpl myToolWindow; @@ -170,7 +169,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa else if (ToolWindowAnchor.RIGHT == anchor) { add(myDivider, BorderLayout.WEST); } - myDivider.setPreferredSize(new Dimension(DIVIDER_WIDTH, DIVIDER_WIDTH)); + myDivider.setPreferredSize(new Dimension(0, 0)); } else { // docked and floating windows don't have divider remove(myDivider); @@ -304,10 +303,16 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa @Override public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) { - g.setColor(UIUtil.getPanelBackground()); - doPaintBorder(c, g, x, y, width, height); - g.setColor(new Color(0, 0, 0, 90)); - doPaintBorder(c, g, x, y, width, height); + if (UIUtil.isUnderDarcula()) { + g.setColor(Gray._40); + doPaintBorder(c, g, x, y, width, height); + } + else { + g.setColor(UIUtil.getPanelBackground()); + doPaintBorder(c, g, x, y, width, height); + g.setColor(Gray._155); + doPaintBorder(c, g, x, y, width, height); + } } private void doPaintBorder(Component c, Graphics g, int x, int y, int width, int height) { @@ -315,18 +320,22 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa if (insets.top > 0) { UIUtil.drawLine(g, x, y + insets.top - 1, x + width - 1, y + insets.top - 1); + UIUtil.drawLine(g, x, y + insets.top, x + width - 1, y + insets.top); } if (insets.left > 0) { - UIUtil.drawLine(g, x, y + insets.top, x, y + height - 1); + UIUtil.drawLine(g, x, y, x, y + height); + UIUtil.drawLine(g, x + 1, y, x + 1, y + height); } if (insets.right > 0) { - UIUtil.drawLine(g, x + width - 1, y + insets.top, x + width - 1, y + height - 1); + UIUtil.drawLine(g, x + width - 1, y + insets.top, x + width - 1, y + height); + UIUtil.drawLine(g, x + width, y + insets.top, x + width, y + height); } if (insets.bottom > 0) { - UIUtil.drawLine(g, x, y + height - 1, x + width - 1, y + height - 1); + UIUtil.drawLine(g, x, y + height - 1, x + width, y + height - 1); + UIUtil.drawLine(g, x, y + height, x + width, y + height); } } @@ -355,7 +364,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa component = parent; parent = component.getParent(); } - return new Insets(0, anchor == ToolWindowAnchor.RIGHT ? 1 : 0, 0, anchor == ToolWindowAnchor.LEFT ? 1 : 0); + return new Insets(0, anchor == ToolWindowAnchor.RIGHT ? 1 : 0, anchor == ToolWindowAnchor.TOP ? 1 : 0, anchor == ToolWindowAnchor.LEFT ? 1 : 0); } @Override @@ -614,135 +623,98 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa private final class MyDivider extends JPanel { private boolean myDragging; private Point myLastPoint; + private Disposable myDisposable; + private IdeGlassPane myGlassPane; - private MyDivider() { - myDragging = false; - enableEvents(MouseEvent.MOUSE_EVENT_MASK | MouseEvent.MOUSE_MOTION_EVENT_MASK); - setBorder(new DividerBorder()); + private final MouseAdapter myListener = new MyMouseAdapter(); + + @Override + public void addNotify() { + super.addNotify(); + myGlassPane = IdeGlassPaneUtil.find(this); + myDisposable = Disposer.newDisposable(); + myGlassPane.addMouseMotionPreprocessor(myListener, myDisposable); + myGlassPane.addMousePreprocessor(myListener, myDisposable); } @Override - protected final void processMouseMotionEvent(final MouseEvent e) { - super.processMouseMotionEvent(e); - if (MouseEvent.MOUSE_DRAGGED == e.getID()) { - myDragging = true; - final ToolWindowAnchor anchor = myInfo.getAnchor(); - final boolean isVerticalCursor = myInfo.isDocked() ? anchor.isSplitVertically() : anchor.isHorizontal(); - setCursor(isVerticalCursor ? Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR) : Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); - final Point point = e.getPoint(); + public void removeNotify() { + super.removeNotify(); + if (myDisposable != null && !Disposer.isDisposed(myDisposable)) { + Disposer.dispose(myDisposable); + } + } + boolean isInDragZone(MouseEvent e) { + final Point p = SwingUtilities.convertMouseEvent(e.getComponent(), e, this).getPoint(); + return Math.abs(myInfo.getAnchor().isHorizontal() ? p.y : p.x) < 6; + } + + + private class MyMouseAdapter extends MouseAdapter { + + private void updateCursor(MouseEvent e) { + if (isInDragZone(e)) { + myGlassPane.setCursor(MyDivider.this.getCursor(), MyDivider.this); + e.consume(); + } + } + + @Override + public void mousePressed(MouseEvent e) { + myDragging = isInDragZone(e); + updateCursor(e); + } + + @Override + public void mouseClicked(MouseEvent e) { + updateCursor(e); + } + + @Override + public void mouseReleased(MouseEvent e) { + updateCursor(e); + myDragging = false; + } + + @Override + public void mouseMoved(MouseEvent e) { + updateCursor(e); + } + + @Override + public void mouseDragged(MouseEvent e) { + if (!myDragging) return; + MouseEvent event = SwingUtilities.convertMouseEvent(e.getComponent(), e, MyDivider.this); + final ToolWindowAnchor anchor = myInfo.getAnchor(); + final Point point = event.getPoint(); final Container windowPane = InternalDecorator.this.getParent(); - myLastPoint = SwingUtilities.convertPoint(this, point, windowPane); + myLastPoint = SwingUtilities.convertPoint(MyDivider.this, point, windowPane); myLastPoint.x = Math.min(Math.max(myLastPoint.x, 0), windowPane.getWidth()); myLastPoint.y = Math.min(Math.max(myLastPoint.y, 0), windowPane.getHeight()); final Rectangle bounds = InternalDecorator.this.getBounds(); if (anchor == ToolWindowAnchor.TOP) { - if (myLastPoint.y < DIVIDER_WIDTH) { - myLastPoint.y = DIVIDER_WIDTH; - } InternalDecorator.this.setBounds(0, 0, bounds.width, myLastPoint.y); } else if (anchor == ToolWindowAnchor.LEFT) { - if (myLastPoint.x < DIVIDER_WIDTH) { - myLastPoint.x = DIVIDER_WIDTH; - } InternalDecorator.this.setBounds(0, 0, myLastPoint.x, bounds.height); } else if (anchor == ToolWindowAnchor.BOTTOM) { - if (myLastPoint.y > windowPane.getHeight() - DIVIDER_WIDTH) { - myLastPoint.y = windowPane.getHeight() - DIVIDER_WIDTH; - } InternalDecorator.this.setBounds(0, myLastPoint.y, bounds.width, windowPane.getHeight() - myLastPoint.y); } else if (anchor == ToolWindowAnchor.RIGHT) { - if (myLastPoint.x > windowPane.getWidth() - DIVIDER_WIDTH) { - myLastPoint.x = windowPane.getWidth() - DIVIDER_WIDTH; - } InternalDecorator.this.setBounds(myLastPoint.x, 0, windowPane.getWidth() - myLastPoint.x, bounds.height); } InternalDecorator.this.validate(); + e.consume(); } } @Override - protected final void processMouseEvent(final MouseEvent e) { - super.processMouseEvent(e); + public Cursor getCursor() { final boolean isVerticalCursor = myInfo.isDocked() ? myInfo.getAnchor().isSplitVertically() : myInfo.getAnchor().isHorizontal(); - switch (e.getID()) { - case MouseEvent.MOUSE_MOVED: - default: - break; - case MouseEvent.MOUSE_ENTERED: - setCursor( - isVerticalCursor ? Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR) : Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); - break; - case MouseEvent.MOUSE_EXITED: - if (!myDragging) { - setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } - break; - case MouseEvent.MOUSE_PRESSED: - setCursor( - isVerticalCursor ? Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR) : Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); - break; - case MouseEvent.MOUSE_RELEASED: - myDragging = false; - myLastPoint = null; - break; - case MouseEvent.MOUSE_CLICKED: - break; - } - } - - private final class DividerBorder implements Border { - @Override - public final void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) { - final ToolWindowAnchor anchor = myInfo.getAnchor(); - final boolean isVertical = !anchor.isSplitVertically(); - final JBColor outer = new JBColor(Color.white, Color.darkGray); - if (isVertical) { - if (anchor == ToolWindowAnchor.TOP) { - g.setColor(outer); - UIUtil.drawLine(g, x, y, x + width - 1, y); - g.setColor(Color.darkGray); - UIUtil.drawLine(g, x, y + height - 1, x + width - 1, y + height - 1); - } - else { - g.setColor(Color.darkGray); - UIUtil.drawLine(g, x, y, x + width - 1, y); - g.setColor(outer); - UIUtil.drawLine(g, x, y + height - 1, x + width - 1, y + height - 1); - } - } - else { - if (anchor == ToolWindowAnchor.LEFT) { - g.setColor(outer); - UIUtil.drawLine(g, x, y, x, y + height - 1); - g.setColor(Color.darkGray); - UIUtil.drawLine(g, x + width - 1, y, x + width - 1, y + height - 1); - } - else { - g.setColor(Color.darkGray); - UIUtil.drawLine(g, x, y, x, y + height - 1); - g.setColor(outer); - UIUtil.drawLine(g, x + width - 1, y, x + width - 1, y + height - 1); - } - } - } - - @Override - public final Insets getBorderInsets(final Component c) { - if (c instanceof MyDivider) { - return new Insets(1, 1, 1, 1); - } - return new Insets(0, 0, 0, 0); - } - - @Override - public final boolean isBorderOpaque() { - return true; - } + return isVerticalCursor ? Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR) : Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR); } } From b00cb94db528aa91896e0e021fddd06ad34d31ba Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Wed, 3 Sep 2014 19:36:19 +0400 Subject: [PATCH 18/28] IDEA-70425 transfer current working directory into ApplicationStarterEx --- .../application/ApplicationStarterEx.java | 7 +++++++ .../com/intellij/ide/CommandLineProcessor.java | 2 +- .../openapi/diff/ApplicationStarterBase.java | 18 +++++++++++------- .../intellij/openapi/diff/DiffApplication.java | 7 ++++--- .../openapi/diff/MergeApplication.java | 11 ++++++----- .../ui/win/RecentProjectApplication.java | 3 ++- 6 files changed, 31 insertions(+), 17 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarterEx.java b/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarterEx.java index c4b3a6384f56..86e322f6e0e3 100644 --- a/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarterEx.java +++ b/platform/platform-api/src/com/intellij/openapi/application/ApplicationStarterEx.java @@ -15,6 +15,8 @@ */ package com.intellij.openapi.application; +import org.jetbrains.annotations.Nullable; + /** * Implementers of the interface declared via {@link com.intellij.ExtensionPoints#APPLICATION_STARTER} * may be capable of processing an external command line within a running IntelliJ Platform instance. @@ -28,5 +30,10 @@ public abstract class ApplicationStarterEx implements ApplicationStarter { return false; } + @Deprecated public void processExternalCommandLine(String[] args) { } + + public void processExternalCommandLine(String[] args, @Nullable String currentDirectory) { + processExternalCommandLine(args); + } } diff --git a/platform/platform-impl/src/com/intellij/ide/CommandLineProcessor.java b/platform/platform-impl/src/com/intellij/ide/CommandLineProcessor.java index c288150bd7ab..293c4a55eeae 100644 --- a/platform/platform-impl/src/com/intellij/ide/CommandLineProcessor.java +++ b/platform/platform-impl/src/com/intellij/ide/CommandLineProcessor.java @@ -141,7 +141,7 @@ public class CommandLineProcessor { starter instanceof ApplicationStarterEx && ((ApplicationStarterEx)starter).canProcessExternalCommandLine()) { LOG.info("Processing command with " + starter); - ((ApplicationStarterEx) starter).processExternalCommandLine(ArrayUtil.toStringArray(args)); + ((ApplicationStarterEx) starter).processExternalCommandLine(ArrayUtil.toStringArray(args), currentDirectory); return null; } } diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/ApplicationStarterBase.java b/platform/platform-impl/src/com/intellij/openapi/diff/ApplicationStarterBase.java index b508686ade00..b5704b777ff5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/ApplicationStarterBase.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/ApplicationStarterBase.java @@ -26,6 +26,7 @@ import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.FileInputStream; @@ -57,13 +58,13 @@ public abstract class ApplicationStarterBase extends ApplicationStarterEx { } @Override - public void processExternalCommandLine(String[] args) { + public void processExternalCommandLine(String[] args, @Nullable String currentDirectory) { if (!checkArguments(args)) { Messages.showMessageDialog(getUsageMessage(), StringUtil.toTitleCase(getCommandName()), Messages.getInformationIcon()); return; } try { - processCommand(args); + processCommand(args, currentDirectory); } catch (Exception e) { Messages.showMessageDialog(String.format("Error showing %s: %s", getCommandName(), e.getMessage()), @@ -86,7 +87,7 @@ public abstract class ApplicationStarterBase extends ApplicationStarterEx { public abstract String getUsageMessage(); - protected abstract void processCommand(String[] args) throws Exception; + protected abstract void processCommand(String[] args, @Nullable String currentDirectory) throws Exception; @Override public void premain(String[] args) { @@ -99,7 +100,7 @@ public abstract class ApplicationStarterBase extends ApplicationStarterEx { @Override public void main(String[] args) { try { - processCommand(args); + processCommand(args, null); } catch (Exception e) { e.printStackTrace(); @@ -116,12 +117,12 @@ public abstract class ApplicationStarterBase extends ApplicationStarterEx { System.exit(0); } - public static VirtualFile findOrCreateFile(String path) throws IOException { + public static VirtualFile findOrCreateFile(String path, @Nullable String currentDirectory) throws IOException { final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(path)); if (file == null) { boolean result = new File(path).createNewFile(); if (result) { - return findFile(path); + return findFile(path, currentDirectory); } else { throw new FileNotFoundException("Can't create file " + path); @@ -167,8 +168,11 @@ public abstract class ApplicationStarterBase extends ApplicationStarterEx { } @NotNull - public static VirtualFile findFile(final String path) throws OperationFailedException { + public static VirtualFile findFile(final String path, @Nullable String currentDirectory) throws OperationFailedException { File ioFile = new File(path); + if (!ioFile.isAbsolute() && currentDirectory != null) { + ioFile = new File(currentDirectory, path); + } if (!ioFile.exists()) { final String dir = PathManager.getOriginalWorkingDir(); ioFile = new File(dir + File.separator + path); diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/DiffApplication.java b/platform/platform-impl/src/com/intellij/openapi/diff/DiffApplication.java index 742a405f350e..143df9617310 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/DiffApplication.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/DiffApplication.java @@ -21,6 +21,7 @@ import com.intellij.openapi.application.ApplicationNamesInfo; import com.intellij.openapi.fileTypes.UnknownFileType; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.Nullable; /** * @author max @@ -37,11 +38,11 @@ public class DiffApplication extends ApplicationStarterBase { return DiffBundle.message("diff.application.usage.parameters.and.description", scriptName); } - public void processCommand(String[] args) throws OperationFailedException { + public void processCommand(String[] args, @Nullable String currentDirectory) throws OperationFailedException { final String path1 = args[1]; final String path2 = args[2]; - final VirtualFile file1 = findFile(path1); - final VirtualFile file2 = findFile(path2); + final VirtualFile file1 = findFile(path1, currentDirectory); + final VirtualFile file2 = findFile(path2, currentDirectory); final boolean areDirs = areDirs(file1, file2); final boolean areJars = areJars(file1, file2); if (areDirs || areJars) { diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/MergeApplication.java b/platform/platform-impl/src/com/intellij/openapi/diff/MergeApplication.java index 0c088929ea49..d1d6cf6cb9f5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/MergeApplication.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/MergeApplication.java @@ -18,6 +18,7 @@ package com.intellij.openapi.diff; import com.intellij.openapi.application.ApplicationNamesInfo; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.Nullable; /** * @author Konstantin Bulenkov @@ -34,11 +35,11 @@ public class MergeApplication extends ApplicationStarterBase { } @Override - protected void processCommand(String[] args) throws Exception { - final VirtualFile left = findFile(args[1]); - final VirtualFile right = findFile(args[2]); - final VirtualFile middle = findFile(args[3]); - final VirtualFile result = findOrCreateFile(args.length == 4 ? args[3] : args[4]); + protected void processCommand(String[] args, @Nullable String currentDirectory) throws Exception { + final VirtualFile left = findFile(args[1], currentDirectory); + final VirtualFile right = findFile(args[2], currentDirectory); + final VirtualFile middle = findFile(args[3], currentDirectory); + final VirtualFile result = findOrCreateFile(args.length == 4 ? args[3] : args[4], currentDirectory); MergeRequest request = DiffRequestFactory.getInstance() .createMergeRequest(getText(left), getText(right), getText(middle), result, diff --git a/platform/platform-impl/src/com/intellij/ui/win/RecentProjectApplication.java b/platform/platform-impl/src/com/intellij/ui/win/RecentProjectApplication.java index 9561c77b02d6..3ece5a6b77cd 100644 --- a/platform/platform-impl/src/com/intellij/ui/win/RecentProjectApplication.java +++ b/platform/platform-impl/src/com/intellij/ui/win/RecentProjectApplication.java @@ -17,6 +17,7 @@ package com.intellij.ui.win; import com.intellij.ide.impl.ProjectUtil; import com.intellij.openapi.diff.ApplicationStarterBase; +import org.jetbrains.annotations.Nullable; /** @@ -33,7 +34,7 @@ public class RecentProjectApplication extends ApplicationStarterBase { } @Override - protected void processCommand(String[] args) throws Exception { + protected void processCommand(String[] args, @Nullable String currentDirectory) throws Exception { ProjectUtil.openProject(args[1], null, false); } } \ No newline at end of file From 994abe0df846c5a6ed255e616caaea3ba068312e Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Wed, 3 Sep 2014 19:36:19 +0400 Subject: [PATCH 19/28] IDEA-70425 remove deprecated workaround --- .../com/intellij/openapi/diff/ApplicationStarterBase.java | 4 ---- .../src/com/intellij/openapi/application/PathManager.java | 6 ------ 2 files changed, 10 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/ApplicationStarterBase.java b/platform/platform-impl/src/com/intellij/openapi/diff/ApplicationStarterBase.java index b5704b777ff5..369acf473cbc 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/ApplicationStarterBase.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/ApplicationStarterBase.java @@ -173,10 +173,6 @@ public abstract class ApplicationStarterBase extends ApplicationStarterEx { if (!ioFile.isAbsolute() && currentDirectory != null) { ioFile = new File(currentDirectory, path); } - if (!ioFile.exists()) { - final String dir = PathManager.getOriginalWorkingDir(); - ioFile = new File(dir + File.separator + path); - } final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioFile); if (file == null) { throw new OperationFailedException("Can't find file " + path); diff --git a/platform/util/src/com/intellij/openapi/application/PathManager.java b/platform/util/src/com/intellij/openapi/application/PathManager.java index 852f00cb7a68..0188203cde33 100644 --- a/platform/util/src/com/intellij/openapi/application/PathManager.java +++ b/platform/util/src/com/intellij/openapi/application/PathManager.java @@ -45,7 +45,6 @@ public class PathManager { @NonNls public static final String PROPERTY_HOME_PATH = "idea.home.path"; @NonNls public static final String PROPERTY_LOG_PATH = "idea.log.path"; @NonNls public static final String PROPERTY_PATHS_SELECTOR = "idea.paths.selector"; - @NonNls public static final String PROPERTY_ORIGINAL_WORKING_DIR = "original.working.dir"; @NonNls public static final String DEFAULT_OPTIONS_FILE_NAME = "other"; @NonNls private static final String LIB_FOLDER = "lib"; @@ -253,11 +252,6 @@ public class PathManager { // misc stuff - @Nullable - public static String getOriginalWorkingDir() { - return System.getProperty(PROPERTY_ORIGINAL_WORKING_DIR); - } - /** * Attempts to detect classpath entry which contains given resource. */ From 56cd1d0da4a5c33c3a9bd76ac442747e35bbecb3 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Tue, 9 Sep 2014 17:02:31 +0400 Subject: [PATCH 20/28] [vcs] simplify: use existing constant --- .../src/com/intellij/dvcs/repo/RepositoryUtil.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/repo/RepositoryUtil.java b/platform/dvcs-impl/src/com/intellij/dvcs/repo/RepositoryUtil.java index 5a5a555768ba..35b5bceebff4 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/repo/RepositoryUtil.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/repo/RepositoryUtil.java @@ -20,7 +20,7 @@ import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Consumer; import com.intellij.util.Processor; @@ -101,15 +101,10 @@ public class RepositoryUtil { } public static void visitAllChildrenRecursively(@Nullable VirtualFile dir) { - if (dir == null) { - return; + if (dir != null) { + //noinspection unchecked + VfsUtilCore.processFilesRecursively(dir, Processor.TRUE); } - VfsUtil.processFilesRecursively(dir, new Processor() { - @Override - public boolean process(VirtualFile virtualFile) { - return true; - } - }); } public static class Updater implements Consumer { From 833f2f0c2aa89444b450cbbf87a0dd3b96d53967 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Tue, 9 Sep 2014 18:53:00 +0400 Subject: [PATCH 21/28] [git] IDEA-115997 Listen to the whole .git/refs dir & notify if tag has changed If .git/refs/tags changes, immediately send the event, bypassing the standard GitRepository#update(), because we don't read and store tags, but we still want to be notified if they change. --- .../src/git4idea/branch/GitBranchWorker.java | 3 ++- .../src/git4idea/repo/GitRepositoryFiles.java | 19 +++++++++++++-- .../git4idea/repo/GitRepositoryUpdater.java | 24 +++++++++++-------- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/plugins/git4idea/src/git4idea/branch/GitBranchWorker.java b/plugins/git4idea/src/git4idea/branch/GitBranchWorker.java index a6ae9d288dee..3ca83568ff42 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBranchWorker.java +++ b/plugins/git4idea/src/git4idea/branch/GitBranchWorker.java @@ -22,6 +22,7 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Couple; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.changes.Change; +import com.intellij.openapi.vfs.VfsUtil; import git4idea.GitCommit; import git4idea.GitExecutionException; import git4idea.GitPlatformFacade; @@ -67,9 +68,9 @@ public final class GitBranchWorker { } public void createNewTag(@NotNull final String name, @NotNull final String reference, @NotNull final List repositories) { - updateInfo(repositories); for (GitRepository repository : repositories) { myGit.createNewTag(repository, name, null, reference); + VfsUtil.markDirtyAndRefresh(true, true, false, repository.getGitDir()); } } diff --git a/plugins/git4idea/src/git4idea/repo/GitRepositoryFiles.java b/plugins/git4idea/src/git4idea/repo/GitRepositoryFiles.java index d32a0e12f28d..cb0bd9d3dd71 100644 --- a/plugins/git4idea/src/git4idea/repo/GitRepositoryFiles.java +++ b/plugins/git4idea/src/git4idea/repo/GitRepositoryFiles.java @@ -45,6 +45,7 @@ public class GitRepositoryFiles { public static final String PACKED_REFS = "packed-refs"; public static final String REFS_HEADS = "refs/heads"; public static final String REFS_REMOTES = "refs/remotes"; + public static final String REFS_TAGS = "refs/tags"; public static final String SQUASH_MSG = "SQUASH_MSG"; public static final String GIT_HEAD = DOT_GIT + slash(HEAD); @@ -64,6 +65,7 @@ public class GitRepositoryFiles { private final String myPackedRefsPath; private final String myRefsHeadsDirPath; private final String myRefsRemotesDirPath; + private final String myRefsTagsPath; private final String myCommitMessagePath; private final String myExcludePath; @@ -85,6 +87,7 @@ public class GitRepositoryFiles { myRebaseMergePath = gitDirPath + slash(REBASE_MERGE); myPackedRefsPath = gitDirPath + slash(PACKED_REFS); myRefsHeadsDirPath = gitDirPath + slash(REFS_HEADS); + myRefsTagsPath = gitDirPath + slash(REFS_TAGS); myRefsRemotesDirPath = gitDirPath + slash(REFS_REMOTES); myExcludePath = gitDirPath + slash(INFO_EXCLUDE); } @@ -99,19 +102,24 @@ public class GitRepositoryFiles { */ @NotNull static Collection getSubDirRelativePaths() { - return Arrays.asList(slash(REFS_HEADS), slash(REFS_REMOTES), slash(INFO)); + return Arrays.asList(slash(REFS_HEADS), slash(REFS_REMOTES), slash(REFS_TAGS), slash(INFO)); } @NotNull String getRefsHeadsPath() { return myRefsHeadsDirPath; } - + @NotNull String getRefsRemotesPath() { return myRefsRemotesDirPath; } + @NotNull + String getRefsTagsPath() { + return myRefsTagsPath; + } + /** * {@code .git/config} */ @@ -147,6 +155,13 @@ public class GitRepositoryFiles { return filePath.startsWith(myRefsRemotesDirPath); } + /** + * .git/refs/tags/* + */ + public boolean isTagFile(@NotNull String path) { + return path.startsWith(myRefsTagsPath); + } + /** * .git/rebase-merge or .git/rebase-apply */ diff --git a/plugins/git4idea/src/git4idea/repo/GitRepositoryUpdater.java b/plugins/git4idea/src/git4idea/repo/GitRepositoryUpdater.java index 70a41d3d2da8..a5af8fca6352 100644 --- a/plugins/git4idea/src/git4idea/repo/GitRepositoryUpdater.java +++ b/plugins/git4idea/src/git4idea/repo/GitRepositoryUpdater.java @@ -34,19 +34,21 @@ import java.util.List; /** * Listens to .git service files changes and updates {@link GitRepository} when needed. - * @author Kirill Likhodedov */ final class GitRepositoryUpdater implements Disposable, BulkFileListener { + + @NotNull private final GitRepository myRepository; @NotNull private final GitRepositoryFiles myRepositoryFiles; @Nullable private final MessageBusConnection myMessageBusConnection; @NotNull private final QueueProcessor myUpdateQueue; @NotNull private final Object DUMMY_UPDATE_OBJECT = new Object(); @Nullable private final VirtualFile myRemotesDir; @Nullable private final VirtualFile myHeadsDir; + @Nullable private final VirtualFile myTagsDir; @Nullable private final LocalFileSystem.WatchRequest myWatchRequest; - GitRepositoryUpdater(@NotNull GitRepository repository) { + myRepository = repository; VirtualFile gitDir = repository.getGitDir(); myWatchRequest = LocalFileSystem.getInstance().addRootToWatch(gitDir.getPath(), true); @@ -54,6 +56,7 @@ final class GitRepositoryUpdater implements Disposable, BulkFileListener { RepositoryUtil.visitVcsDirVfs(gitDir, GitRepositoryFiles.getSubDirRelativePaths()); myHeadsDir = VcsUtil.getVirtualFile(myRepositoryFiles.getRefsHeadsPath()); myRemotesDir = VcsUtil.getVirtualFile(myRepositoryFiles.getRefsRemotesPath()); + myTagsDir = VcsUtil.getVirtualFile(myRepositoryFiles.getRefsTagsPath()); Project project = repository.getProject(); myUpdateQueue = new QueueProcessor(new RepositoryUtil.Updater(repository), project.getDisposed()); @@ -66,8 +69,6 @@ final class GitRepositoryUpdater implements Disposable, BulkFileListener { } } - - @Override public void dispose() { if (myWatchRequest != null) { @@ -92,19 +93,16 @@ final class GitRepositoryUpdater implements Disposable, BulkFileListener { boolean packedRefsChanged = false; boolean rebaseFileChanged = false; boolean mergeFileChanged = false; + boolean tagChanged = false; for (VFileEvent event : events) { - String filePath = event.getPath(); - if (filePath == null) { - continue; - } - filePath = GitFileUtils.stripFileProtocolPrefix(filePath); + String filePath = GitFileUtils.stripFileProtocolPrefix(event.getPath()); if (myRepositoryFiles.isConfigFile(filePath)) { configChanged = true; } else if (myRepositoryFiles.isHeadFile(filePath)) { headChanged = true; } else if (myRepositoryFiles.isBranchFile(filePath)) { // it is also possible, that a local branch with complex name ("folder/branch") was created => the folder also to be watched. - branchFileChanged = true; + branchFileChanged = true; RepositoryUtil.visitAllChildrenRecursively(myHeadsDir); } else if (myRepositoryFiles.isRemoteBranchFile(filePath)) { // it is possible, that a branch from a new remote was fetch => we need to add new remote folder to the VFS @@ -116,12 +114,18 @@ final class GitRepositoryUpdater implements Disposable, BulkFileListener { rebaseFileChanged = true; } else if (myRepositoryFiles.isMergeFile(filePath)) { mergeFileChanged = true; + } else if (myRepositoryFiles.isTagFile(filePath)) { + RepositoryUtil.visitAllChildrenRecursively(myTagsDir); + tagChanged = true; } } if (headChanged || configChanged || branchFileChanged || packedRefsChanged || rebaseFileChanged || mergeFileChanged) { myUpdateQueue.add(DUMMY_UPDATE_OBJECT); } + else if (tagChanged) { + myRepository.getProject().getMessageBus().syncPublisher(GitRepository.GIT_REPO_CHANGE).repositoryChanged(myRepository); + } } } From 4f428380e939f300e59995bc55b843edc286c05f Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Tue, 9 Sep 2014 18:53:50 +0400 Subject: [PATCH 22/28] [git] Remove test on the parser which is used only in tests --- .../tests/git4idea/log/RefParserTest.java | 125 ------------------ 1 file changed, 125 deletions(-) delete mode 100644 plugins/git4idea/tests/git4idea/log/RefParserTest.java diff --git a/plugins/git4idea/tests/git4idea/log/RefParserTest.java b/plugins/git4idea/tests/git4idea/log/RefParserTest.java deleted file mode 100644 index 4cd22e0add5c..000000000000 --- a/plugins/git4idea/tests/git4idea/log/RefParserTest.java +++ /dev/null @@ -1,125 +0,0 @@ -package git4idea.log; - -import com.intellij.openapi.util.ThrowableComputable; -import com.intellij.openapi.vcs.changes.Change; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.newvfs.impl.NullVirtualFile; -import com.intellij.vcs.log.*; -import com.intellij.vcs.log.impl.VcsRefImpl; -import org.jetbrains.annotations.NotNull; -import org.junit.Test; - -import java.util.Collection; -import java.util.List; - -import static junit.framework.Assert.assertEquals; - -/** - * @author erokhins - */ -public class RefParserTest { - - public String toStr(VcsRef ref) { - return String.format("%s TAG %s", ref.getCommitHash().asString(), ref.getName()); - } - - public void runTest(String inputStr, String outStr) { - List refs = new RefParser(new TestLogObjectsFactory()).parseCommitRefs(inputStr, NullVirtualFile.INSTANCE); - StringBuilder s = new StringBuilder(); - for (VcsRef ref : refs) { - if (s.length() > 0) { - s.append("\n"); - } - s.append(toStr(ref)); - } - assertEquals(outStr, s.toString()); - } - - @Test - public void tagTest() { - runTest("22762ebf7203f6a2888425a3207d2ddc63085dd7 (tag: refs/tags/v3.6-rc1, refs/heads/br)", - "22762ebf7203f6a2888425a3207d2ddc63085dd7 TAG v3.6-rc1"); - } - - @Test - public void severalRefsTest() { - runTest("f85125c (refs/tags/v3.6-rc1, HEAD)", "f85125c TAG v3.6-rc1"); - } - - @Test - public void severalRefsTest2() { - runTest("ed7a0d14da090ea256d68a06c6f8dd7311de192e (refs/tags/category/v3.6-rc1, HEAD, refs/remotes/origin/graph_fix)", - "ed7a0d14da090ea256d68a06c6f8dd7311de192e TAG category/v3.6-rc1"); - } - - @Test - public void severalRefsTest3() { - runTest("ed7a0d14da090ea256d68a06c6f8dd7311de192e (tag: refs/tags/web/130.1599, tag: refs/tags/ruby/130.1597, " + - "tag: refs/tags/py/130.1598, " + - "tag: refs/tags/php/130.1596, tag: refs/tags/idea/130.1601, tag: refs/tags/app/130.1600)", - "ed7a0d14da090ea256d68a06c6f8dd7311de192e TAG web/130.1599\n" + - "ed7a0d14da090ea256d68a06c6f8dd7311de192e TAG ruby/130.1597\n" + - "ed7a0d14da090ea256d68a06c6f8dd7311de192e TAG py/130.1598\n" + - "ed7a0d14da090ea256d68a06c6f8dd7311de192e TAG php/130.1596\n" + - "ed7a0d14da090ea256d68a06c6f8dd7311de192e TAG idea/130.1601\n" + - "ed7a0d14da090ea256d68a06c6f8dd7311de192e TAG app/130.1600" - ); - } - - @Test - public void noTagName() { - runTest("787ec72f340d740433ba068d4d58a6e58f6226bf", ""); - } - - private static class TestLogObjectsFactory implements VcsLogObjectsFactory { - @NotNull - @Override - public Hash createHash(@NotNull String stringHash) { - throw new UnsupportedOperationException(); - } - - @NotNull - @Override - public TimedVcsCommit createTimedCommit(@NotNull Hash hash, @NotNull List parents, long timeStamp) { - throw new UnsupportedOperationException(); - } - - @NotNull - @Override - public VcsShortCommitDetails createShortDetails(@NotNull Hash hash, @NotNull List parents, long timeStamp, VirtualFile root, - @NotNull String subject, @NotNull String authorName, String authorEmail) { - throw new UnsupportedOperationException(); - } - - @NotNull - @Override - public VcsFullCommitDetails createCommitMetadata(@NotNull Hash hash, @NotNull List parents, long time, VirtualFile root, - @NotNull String subject, @NotNull String authorName, @NotNull String authorEmail, - @NotNull String message, @NotNull String committerName, @NotNull String committerEmail, - long authorTime) { - throw new UnsupportedOperationException(); - } - - @NotNull - @Override - public VcsFullCommitDetails createFullDetails(@NotNull Hash hash, @NotNull List parents, long time, VirtualFile root, - @NotNull String subject, @NotNull String authorName, @NotNull String authorEmail, - @NotNull String message, @NotNull String committerName, @NotNull String committerEmail, - long authorTime, - @NotNull ThrowableComputable, ? extends Exception> changesGetter) { - throw new UnsupportedOperationException(); - } - - @NotNull - @Override - public VcsUser createUser(@NotNull String name, @NotNull String email) { - throw new UnsupportedOperationException(); - } - - @NotNull - @Override - public VcsRef createRef(@NotNull Hash commitHash, @NotNull String name, @NotNull VcsRefType type, @NotNull VirtualFile root) { - return new VcsRefImpl(commitHash, name, type, root); - } - } -} From 797585b2112910e69a576e60cb3c69d00c1c4ee8 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Tue, 9 Sep 2014 19:04:44 +0400 Subject: [PATCH 23/28] compiling evaluator - define only generated classes --- .../ui/impl/watch/CompilingEvaluator.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluator.java index cf8a96be8e9b..be5e5c367990 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluator.java @@ -138,14 +138,17 @@ public class CompilingEvaluator implements ExpressionEvaluator { VirtualMachineProxyImpl proxy = (VirtualMachineProxyImpl)process.getVirtualMachineProxy(); for (OutputFileObject cls : classes) { - Method defineMethod = ((ClassType)classLoader.referenceType()).concreteMethodByName("defineClass", "(Ljava/lang/String;[BII)Ljava/lang/Class;"); - byte[] bytes = cls.toByteArray(); - ArrayList args = new ArrayList(); - args.add(proxy.mirrorOf(cls.myOrigName)); - args.add(mirrorOf(bytes, context, process)); - args.add(proxy.mirrorOf(0)); - args.add(proxy.mirrorOf(bytes.length)); - classLoader.invokeMethod(threadReference, defineMethod, args, ClassType.INVOKE_SINGLE_THREADED); + if (cls.getName().contains(getGenClassName())) { + Method defineMethod = + ((ClassType)classLoader.referenceType()).concreteMethodByName("defineClass", "(Ljava/lang/String;[BII)Ljava/lang/Class;"); + byte[] bytes = cls.toByteArray(); + ArrayList args = new ArrayList(); + args.add(proxy.mirrorOf(cls.myOrigName)); + args.add(mirrorOf(bytes, context, process)); + args.add(proxy.mirrorOf(0)); + args.add(proxy.mirrorOf(bytes.length)); + classLoader.invokeMethod(threadReference, defineMethod, args, ClassType.INVOKE_SINGLE_THREADED); + } } return (ClassType)process.findClass(context, getGenPackageName() + '.' + getGenClassName(), classLoader); } From 393ba6a2e9ad20e1287ad6c645e9c5784466a498 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Tue, 9 Sep 2014 19:23:04 +0400 Subject: [PATCH 24/28] setup data provider for x debugger frame list, now we can see git history during frames navigation --- .../impl/frame/XDebuggerFramesList.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java index 9b39ad63deb8..69c762995b1a 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.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. @@ -15,6 +15,8 @@ */ package com.intellij.xdebugger.impl.frame; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.actionSystem.DataProvider; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; @@ -27,7 +29,9 @@ import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.XDebuggerBundle; import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.frame.XStackFrame; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; @@ -90,6 +94,17 @@ public class XDebuggerFramesList extends DebuggerFramesList { doInit(); setTransferHandler(DEFAULT_TRANSFER_HANDLER); + setDataProvider(new DataProvider() { + @Nullable + @Override + public Object getData(@NonNls String dataId) { + if (CommonDataKeys.VIRTUAL_FILE.is(dataId) && mySelectedFrame != null) { + XSourcePosition position = mySelectedFrame.getSourcePosition(); + return position != null ? position.getFile() : null; + } + return null; + } + }); } @Override From 299d05edd9aec75e642afbed0b1fb02dd736dbdf Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Tue, 9 Sep 2014 19:32:37 +0400 Subject: [PATCH 25/28] notnull --- .../com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java index 69c762995b1a..63a1cfeea6af 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java @@ -82,7 +82,7 @@ public class XDebuggerFramesList extends DebuggerFramesList { } @Override - public int getSourceActions(JComponent c) { + public int getSourceActions(@NotNull JComponent c) { return COPY; } }; From 8486b1e3b86b0d6581114c6da0a2612f0a891096 Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Tue, 9 Sep 2014 15:27:17 +0400 Subject: [PATCH 26/28] Live template: cleanup edit variables dialog --- .../codeInsight/template/impl/EditVariableDialog.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/EditVariableDialog.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/EditVariableDialog.java index e32fab35508b..bab6ade7b935 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/EditVariableDialog.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/EditVariableDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -26,6 +26,7 @@ import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.help.HelpManager; +import com.intellij.openapi.ui.ComboBox; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.table.JBTable; @@ -107,11 +108,11 @@ class EditVariableDialog extends DialogWrapper { myTable.getSelectionModel().setSelectionInterval(0, 0); } - JComboBox comboField = new JComboBox(); + ComboBox comboField = new ComboBox(); Macro[] macros = MacroFactory.getMacros(); Arrays.sort(macros, new Comparator () { @Override - public int compare(Macro m1, Macro m2) { + public int compare(@NotNull Macro m1, @NotNull Macro m2) { return m1.getPresentableName().compareTo(m2.getPresentableName()); } }); @@ -231,11 +232,13 @@ class EditVariableDialog extends DialogWrapper { } } + @NotNull @Override public String getColumnName(int column) { return myNames[column]; } + @NotNull @Override public Class getColumnClass(int c) { if (c <= 2) { From 2f0583fe2c773e437994bc8e5cfb6668b9008887 Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Tue, 9 Sep 2014 19:35:47 +0400 Subject: [PATCH 27/28] WEB-13309 Emmet trips up on rules with parenthesis --- .../intellij/codeInsight/template/emmet/EmmetParser.java | 8 ++++++-- .../codeInsight/template/emmet/XmlEmmetParser.java | 2 +- .../template/emmet/nodes/MoreOperationNode.java | 8 ++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetParser.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetParser.java index 6bc71f9f8549..aa7e62cbcd54 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetParser.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetParser.java @@ -80,6 +80,10 @@ public abstract class EmmetParser { ZenCodingNode mul = parseMul(); ZenCodingToken operationToken = getToken(); + if (operationToken == ZenCodingTokens.OPENING_R_BRACKET) { + mul = new MoreOperationNode(notNullNode(mul), parseExpression()); + operationToken = getToken(); + } if (!(operationToken instanceof OperationToken)) { return mul; } @@ -132,7 +136,7 @@ public abstract class EmmetParser { @Nullable private ZenCodingNode parseMul() { - ZenCodingNode exp = parseExpressionInBraces(); + ZenCodingNode exp = parseExpression(); if (exp == null) { return null; } @@ -153,7 +157,7 @@ public abstract class EmmetParser { } @Nullable - private ZenCodingNode parseExpressionInBraces() { + private ZenCodingNode parseExpression() { ZenCodingToken token = getToken(); if (token == ZenCodingTokens.OPENING_R_BRACKET) { advance(); diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/XmlEmmetParser.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/XmlEmmetParser.java index 4ab715a404bf..01ddc3ca563f 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/XmlEmmetParser.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/XmlEmmetParser.java @@ -202,7 +202,7 @@ public class XmlEmmetParser extends EmmetParser { int loremWordsCount = DEFAULT_LOREM_LENGTH; if (matcher.groupCount() > 1) { String group = matcher.group(2); - loremWordsCount = group.isEmpty() ? DEFAULT_LOREM_LENGTH : Integer.parseInt(group); + loremWordsCount = group == null || group.isEmpty() ? DEFAULT_LOREM_LENGTH : Integer.parseInt(group); } final List> attrList = parseSelectors(); diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/MoreOperationNode.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/MoreOperationNode.java index 0a1bea140d6b..56d440abc538 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/MoreOperationNode.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/nodes/MoreOperationNode.java @@ -89,8 +89,12 @@ public class MoreOperationNode extends ZenCodingNode { } return result; } - List leftGenNodes = myLeftOperand.expand(numberInIteration, totalIterations, surroundedText, callback, insertSurroundedTextAtTheEnd, - parent); + List leftGenNodes = myLeftOperand.expand(numberInIteration, totalIterations, surroundedText, callback, insertSurroundedTextAtTheEnd, parent); + + if (leftGenNodes.isEmpty()) { + return myRightOperand.expand(numberInIteration, totalIterations, surroundedText, callback, insertSurroundedTextAtTheEnd, parent); + } + for (GenerationNode leftGenNode : leftGenNodes) { myRightOperand.expand(numberInIteration,totalIterations , surroundedText, callback, insertSurroundedTextAtTheEnd, leftGenNode); } From 24faae16f801f6480c5abcb99a4be47927eae39a Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Tue, 9 Sep 2014 19:57:19 +0400 Subject: [PATCH 28/28] [git] IDEA-75353 Let skip detached HEAD commit warning --- .../checkin/GitCheckinHandlerFactory.java | 40 ++++++++++++++++--- .../src/git4idea/config/GitVcsPanel.form | 11 ++++- .../src/git4idea/config/GitVcsPanel.java | 6 ++- .../src/git4idea/config/GitVcsSettings.java | 9 +++++ 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/plugins/git4idea/src/git4idea/checkin/GitCheckinHandlerFactory.java b/plugins/git4idea/src/git4idea/checkin/GitCheckinHandlerFactory.java index 8bfc52ca261a..c31966176ae0 100644 --- a/plugins/git4idea/src/git4idea/checkin/GitCheckinHandlerFactory.java +++ b/plugins/git4idea/src/git4idea/checkin/GitCheckinHandlerFactory.java @@ -15,12 +15,14 @@ */ package git4idea.checkin; +import com.intellij.CommonBundle; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Couple; @@ -281,7 +283,7 @@ public class GitCheckinHandlerFactory extends VcsCheckinHandlerFactory { private ReturnResult warnAboutDetachedHeadIfNeeded() { // Warning: commit on a detached HEAD DetachedRoot detachedRoot = getDetachedRoot(); - if (detachedRoot == null) { + if (detachedRoot == null || !GitVcsSettings.getInstance(myProject).warnAboutDetachedHead()) { return ReturnResult.COMMIT; } @@ -303,10 +305,38 @@ public class GitCheckinHandlerFactory extends VcsCheckinHandlerFactory { readMore("http://gitolite.com/detached-head.html", "Read more about detached HEAD"); } - final int choice = Messages.showOkCancelDialog(myPanel.getComponent(), XmlStringUtil.wrapInHtml(message), title, - "Cancel", "Commit", - Messages.getWarningIcon()); - if (choice != Messages.OK) { + DialogWrapper.DoNotAskOption dontAskAgain = new DialogWrapper.DoNotAskOption() { + @Override + public boolean isToBeShown() { + return true; + } + + @Override + public void setToBeShown(boolean toBeShown, int exitCode) { + if (exitCode == Messages.OK) { + GitVcsSettings.getInstance(myProject).setWarnAboutDetachedHead(toBeShown); + } + } + + @Override + public boolean canBeHidden() { + return true; + } + + @Override + public boolean shouldSaveOptionsOnCancel() { + return false; + } + + @NotNull + @Override + public String getDoNotShowMessage() { + return "Don't warn again"; + } + }; + int choice = Messages.showOkCancelDialog(myProject, XmlStringUtil.wrapInHtml(message), title, "Commit", + CommonBundle.getCancelButtonText(), Messages.getWarningIcon(), dontAskAgain); + if (choice == Messages.OK) { return ReturnResult.COMMIT; } else { return ReturnResult.CLOSE_WINDOW; diff --git a/plugins/git4idea/src/git4idea/config/GitVcsPanel.form b/plugins/git4idea/src/git4idea/config/GitVcsPanel.form index 0f24aaf99d56..87d3578f7c0a 100644 --- a/plugins/git4idea/src/git4idea/config/GitVcsPanel.form +++ b/plugins/git4idea/src/git4idea/config/GitVcsPanel.form @@ -91,7 +91,7 @@ - + @@ -134,6 +134,15 @@ + + + + + + + + + diff --git a/plugins/git4idea/src/git4idea/config/GitVcsPanel.java b/plugins/git4idea/src/git4idea/config/GitVcsPanel.java index 3a4cab90deb3..c8c2ad46a274 100644 --- a/plugins/git4idea/src/git4idea/config/GitVcsPanel.java +++ b/plugins/git4idea/src/git4idea/config/GitVcsPanel.java @@ -51,6 +51,7 @@ public class GitVcsPanel { private JBCheckBox mySyncBranchControl; private JCheckBox myAutoCommitOnCherryPick; private JBCheckBox myWarnAboutCrlf; + private JCheckBox myWarnAboutDetachedHead; public GitVcsPanel(@NotNull Project project) { myVcs = GitVcs.getInstance(project); @@ -121,6 +122,7 @@ public class GitVcsPanel { mySyncBranchControl.setSelected(settings.getSyncSetting() == DvcsBranchSync.SYNC); myAutoCommitOnCherryPick.setSelected(settings.isAutoCommitOnCherryPick()); myWarnAboutCrlf.setSelected(settings.warnAboutCrlf()); + myWarnAboutDetachedHead.setSelected(settings.warnAboutDetachedHead()); } /** @@ -134,7 +136,8 @@ public class GitVcsPanel { !settings.autoUpdateIfPushRejected() == myAutoUpdateIfPushRejected.isSelected() || ((settings.getSyncSetting() == DvcsBranchSync.SYNC) != mySyncBranchControl.isSelected() || settings.isAutoCommitOnCherryPick() != myAutoCommitOnCherryPick.isSelected() || - settings.warnAboutCrlf() != myWarnAboutCrlf.isSelected()); + settings.warnAboutCrlf() != myWarnAboutCrlf.isSelected() || + settings.warnAboutDetachedHead() != myWarnAboutDetachedHead.isSelected()); } /** @@ -153,6 +156,7 @@ public class GitVcsPanel { settings.setSyncSetting(mySyncBranchControl.isSelected() ? DvcsBranchSync.SYNC : DvcsBranchSync.DONT); settings.setAutoCommitOnCherryPick(myAutoCommitOnCherryPick.isSelected()); settings.setWarnAboutCrlf(myWarnAboutCrlf.isSelected()); + settings.setWarnAboutDetachedHead(myWarnAboutDetachedHead.isSelected()); } } diff --git a/plugins/git4idea/src/git4idea/config/GitVcsSettings.java b/plugins/git4idea/src/git4idea/config/GitVcsSettings.java index ab59e8f80ae3..7dd7f9b1004b 100644 --- a/plugins/git4idea/src/git4idea/config/GitVcsSettings.java +++ b/plugins/git4idea/src/git4idea/config/GitVcsSettings.java @@ -66,6 +66,7 @@ public class GitVcsSettings implements PersistentStateComponent