From 7c82cebc1dd2b2e2bb88f73ca916e866ef4b752e Mon Sep 17 00:00:00 2001 From: irengrig Date: Wed, 14 Dec 2011 11:04:23 +0400 Subject: [PATCH 01/41] Fix Editor not released on project close --- .../openapi/vcs/impl/ProjectLevelVcsManagerImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java index 1624d79aae9e..3769f684845e 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java @@ -382,6 +382,12 @@ public void addMessageToConsoleWindow(final String message, final TextAttributes final String displayName = VcsBundle.message("vcs.console.toolwindow.display.name"); Content content = contentManager.findContent(displayName); if (content == null) { + if (myEditorAdapter != null) { + final Editor editor = myEditorAdapter.getEditor(); + if (! editor.isDisposed()) { + EditorFactory.getInstance().releaseEditor(editor); + } + } final EditorFactory editorFactory = EditorFactory.getInstance(); final Editor editor = editorFactory.createViewer(editorFactory.createDocument(""), myProject); EditorSettings editorSettings = editor.getSettings(); From c3b4476d8d44c75841e812709369062fafc30963 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Wed, 14 Dec 2011 13:53:14 +0400 Subject: [PATCH 02/41] Take win separators into an account when comparing paths --- platform/testFramework/src/com/intellij/TestAll.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/platform/testFramework/src/com/intellij/TestAll.java b/platform/testFramework/src/com/intellij/TestAll.java index bde8685224b6..50bd7b7b5c5d 100644 --- a/platform/testFramework/src/com/intellij/TestAll.java +++ b/platform/testFramework/src/com/intellij/TestAll.java @@ -353,6 +353,14 @@ public class TestAll implements Test { } } + private static Set normalizePaths(String[] array) { + Set answer = new LinkedHashSet(array.length); + for (String path : array) { + answer.add(path.replace('\\', '/')); + } + return answer; + } + public static String[] getClassRoots() { String testRoots = System.getProperty("test.roots"); if (testRoots != null) { @@ -363,8 +371,8 @@ public class TestAll implements Test { if (roots != null) { if (Comparing.equal(System.getProperty(TestCaseLoader.SKIP_COMMUNITY_TESTS), "true")) { System.out.println("Skipping community tests"); - Set set = new LinkedHashSet(Arrays.asList(roots)); - set.removeAll(Arrays.asList(ExternalClasspathClassLoader.getExcludeRoots())); + Set set = normalizePaths(roots); + set.removeAll(normalizePaths(ExternalClasspathClassLoader.getExcludeRoots())); roots = set.toArray(new String[set.size()]); } From df36731b380508869385574e949305066f8ba902 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 14 Dec 2011 10:55:09 +0100 Subject: [PATCH 03/41] IDEA-78181 Live Templates Editing-Field is too small --- .../template/impl/LiveTemplateSettingsEditor.java | 2 +- .../template/impl/TemplateListPanel.java | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java index 20a653a476d9..c81ac0ca7e97 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java @@ -154,7 +154,7 @@ public class LiveTemplateSettingsEditor extends JPanel { panel.add(createTemplateOptionsPanel(), gb.nextLine().next().next().coverColumn(2).weighty(1)); - panel.add(createShortContextPanel(allowNoContexts), gb.nextLine().next().fillCellNone().anchor(GridBagConstraints.WEST)); + panel.add(createShortContextPanel(allowNoContexts), gb.nextLine().next().weighty(0).fillCellNone().anchor(GridBagConstraints.WEST)); myTemplateEditor.getDocument().addDocumentListener( new DocumentAdapter() { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java index 7304a1d00504..3ed55f13f278 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java @@ -32,11 +32,15 @@ import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.InputValidator; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.*; -import com.intellij.util.*; +import com.intellij.util.Alarm; +import com.intellij.util.NullableFunction; +import com.intellij.util.ObjectUtils; +import com.intellij.util.PlatformIcons; import com.intellij.util.containers.Convertor; import com.intellij.util.ui.tree.TreeUtil; import com.intellij.util.ui.update.UiNotifyConnector; @@ -92,8 +96,11 @@ public class TemplateListPanel extends JPanel implements Disposable { createTemplateEditor(MOCK_TEMPLATE, "Tab", MOCK_TEMPLATE.createOptions(), MOCK_TEMPLATE.createContext()); add(createExpandByPanel(), BorderLayout.NORTH); - add(createTable(), BorderLayout.CENTER); - add(myDetailsPanel, BorderLayout.SOUTH); + + Splitter splitter = new Splitter(true, 0.9f); + splitter.setFirstComponent(createTable()); + splitter.setSecondComponent(myDetailsPanel); + add(splitter, BorderLayout.CENTER); } public void dispose() { From 48b730aa0b9f4f9075b548e3bb92c7cfba5e20d7 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 14 Dec 2011 10:56:57 +0100 Subject: [PATCH 04/41] NPE --- .../moveClassesOrPackages/DestinationFolderComboBox.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/DestinationFolderComboBox.java b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/DestinationFolderComboBox.java index ec5a46f1d70f..82e69525570c 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/DestinationFolderComboBox.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/DestinationFolderComboBox.java @@ -33,7 +33,10 @@ import com.intellij.psi.PsiManager; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.refactoring.MoveDestination; import com.intellij.refactoring.PackageWrapper; -import com.intellij.ui.*; +import com.intellij.ui.CollectionComboBoxModel; +import com.intellij.ui.ComboboxSpeedSearch; +import com.intellij.ui.ComboboxWithBrowseButton; +import com.intellij.ui.EditorComboBox; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -46,6 +49,7 @@ import java.util.*; * Date: 9/13/11 */ public abstract class DestinationFolderComboBox extends ComboboxWithBrowseButton { + private static final String LEAVE_IN_SAME_SOURCE_ROOT = "Leave in same source root"; private PsiDirectory myInitialTargetDirectory; private VirtualFile[] mySourceRoots; @@ -81,6 +85,7 @@ public abstract class DestinationFolderComboBox extends ComboboxWithBrowseButton new ComboboxSpeedSearch(getComboBox()) { @Override protected String getElementText(Object element) { + if (element == null) return LEAVE_IN_SAME_SOURCE_ROOT; if (element instanceof DirectoryChooser.ItemWrapper) { final VirtualFile virtualFile = ((DirectoryChooser.ItemWrapper)element).getDirectory().getVirtualFile(); final Module module = ModuleUtil.findModuleForFile(virtualFile, project); @@ -105,7 +110,7 @@ public abstract class DestinationFolderComboBox extends ComboboxWithBrowseButton setText(getPresentableText(itemWrapper, project)); } else { - setText("Leave in same source root"); + setText(LEAVE_IN_SAME_SOURCE_ROOT); } } }); From d4b9ff6322e1590b181b02bb90e4cb05afb285e8 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 14 Dec 2011 14:20:50 +0400 Subject: [PATCH 05/41] fixed memory leak in 'new project' wizard --- .../newProjectWizard/OldFrameworkSupportProviderWrapper.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/OldFrameworkSupportProviderWrapper.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/OldFrameworkSupportProviderWrapper.java index 8c45b50edb9a..adfcabae8431 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/OldFrameworkSupportProviderWrapper.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/OldFrameworkSupportProviderWrapper.java @@ -29,6 +29,7 @@ import com.intellij.openapi.roots.ModifiableModelsProvider; import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.ui.configuration.FacetsProvider; import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription; +import com.intellij.openapi.util.Disposer; import com.intellij.ui.GuiUtils; import com.intellij.util.ui.EmptyIcon; import org.jetbrains.annotations.NotNull; @@ -125,6 +126,7 @@ public class OldFrameworkSupportProviderWrapper extends FrameworkSupportInModule private final FrameworkLibraryVersionFilter myVersionFilter; public FrameworkSupportConfigurableWrapper(FrameworkSupportConfigurable configurable) { + Disposer.register(this, configurable); myConfigurable = configurable; if (configurable instanceof FrameworkSupportWithLibrary) { myVersionFilter = FrameworkLibraryVersionFilter.ALL; From 02083c5ad3ac7e56d131e85dec35e66cc73a7e43 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 14 Dec 2011 15:24:14 +0400 Subject: [PATCH 06/41] java run configuration: search main class in runtime dependencies (IDEA-78837) --- .../openapi/src/com/intellij/execution/JavaExecutionUtil.java | 2 +- .../execution/configurations/JavaRunConfigurationModule.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java b/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java index da7e9477770b..3239824d4ada 100644 --- a/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java +++ b/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java @@ -135,7 +135,7 @@ public class JavaExecutionUtil { @Nullable public static PsiClass findMainClass(final Module module, final String mainClassName) { - return findMainClass(module.getProject(), mainClassName, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module)); + return findMainClass(module.getProject(), mainClassName, module.getModuleRuntimeScope(true)); } @Nullable diff --git a/java/execution/openapi/src/com/intellij/execution/configurations/JavaRunConfigurationModule.java b/java/execution/openapi/src/com/intellij/execution/configurations/JavaRunConfigurationModule.java index a8cc13d35cc7..27a27adf3ae8 100644 --- a/java/execution/openapi/src/com/intellij/execution/configurations/JavaRunConfigurationModule.java +++ b/java/execution/openapi/src/com/intellij/execution/configurations/JavaRunConfigurationModule.java @@ -53,8 +53,7 @@ public class JavaRunConfigurationModule extends RunConfigurationModule { final Module module = getModule(); final GlobalSearchScope scope; if (module != null) { - scope = myClassesInLibraries ? GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module) - : GlobalSearchScope.moduleWithDependenciesScope(module); + scope = myClassesInLibraries ? module.getModuleRuntimeScope(true) : GlobalSearchScope.moduleWithDependenciesScope(module); } else { scope = myClassesInLibraries ? GlobalSearchScope.allScope(getProject()) : GlobalSearchScope.projectScope(getProject()); From 3d035540befb73884c75815960e9d8dbee9247a7 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Wed, 14 Dec 2011 15:33:41 +0400 Subject: [PATCH 07/41] IDEA-78633 Slashy strings with injections false notification --- .../plugins/groovy/annotator/GroovyAnnotator.java | 7 ------- plugins/groovy/testdata/highlighting/SlashyStrings.groovy | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java index 8a2545cef8c6..c3ea2c2b2d9e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -890,13 +890,6 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { } } } - - if (regex instanceof GrRegex && ((GrRegex)regex).getInjections().length > 0) { - if (!config.isVersionAtLeast(regex, GroovyConfigUtils.GROOVY1_8)) { - myHolder.createErrorAnnotation(regex, GroovyBundle - .message("slashy.strings.with.injections.are.not.allowed.in.groovy.0", config.getSDKVersion(regex))); - } - } } @Override diff --git a/plugins/groovy/testdata/highlighting/SlashyStrings.groovy b/plugins/groovy/testdata/highlighting/SlashyStrings.groovy index 17ca8bb6a589..3ba00ecb60f6 100644 --- a/plugins/groovy/testdata/highlighting/SlashyStrings.groovy +++ b/plugins/groovy/testdata/highlighting/SlashyStrings.groovy @@ -2,7 +2,7 @@ print (/abc/) print (/ab c/) -print (/abc${false}def/) +print (/abc${false}def/) print (/abc${false}d ef/) \ No newline at end of file From 094b78231762a441d29056e52ea59b35474b902c Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Wed, 14 Dec 2011 15:37:33 +0400 Subject: [PATCH 08/41] IDEA-78495 fix gant runner --- .../src/org/jetbrains/plugins/groovy/gant/GantRunner.java | 2 +- .../org/jetbrains/plugins/groovy/gant/GantScriptType.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java index 5b57d0c2c1f4..aff6a430778a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java @@ -126,7 +126,7 @@ public class GantRunner extends GroovyScriptRunner { params.getProgramParametersList().add("--debug"); } - params.getProgramParametersList().addParametersString(configuration.getProgramParameters()); + params.getProgramParametersList().addParametersString(configuration.getScriptParameters()); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantScriptType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantScriptType.java index d2e812af0e8f..e8f36cba6a4e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantScriptType.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantScriptType.java @@ -15,16 +15,16 @@ */ package org.jetbrains.plugins.groovy.gant; +import com.intellij.compiler.options.CompileStepBeforeRun; import com.intellij.execution.Location; import com.intellij.execution.RunManagerEx; -import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.NonClasspathDirectoryScope; -import com.intellij.compiler.options.CompileStepBeforeRun; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -93,7 +93,7 @@ public class GantScriptType extends GroovyScriptType { public void tuneConfiguration(@NotNull GroovyFile file, @NotNull GroovyScriptRunConfiguration configuration, Location location) { String target = getTargetName(location); if (target != null) { - configuration.setProgramParameters(target); + configuration.setScriptParameters(target); configuration.setName(configuration.getName() + "." + target); } final CompileStepBeforeRun.MakeBeforeRunTask runTask = From 3621fed30c00de04d3454960f6436e84be83b1a2 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 14 Dec 2011 12:35:31 +0100 Subject: [PATCH 09/41] Code style settings in CE project --- .idea/codeStyleSettings.xml | 216 ++++++++++++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 .idea/codeStyleSettings.xml diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml new file mode 100644 index 000000000000..b99a172034b3 --- /dev/null +++ b/.idea/codeStyleSettings.xml @@ -0,0 +1,216 @@ + + + + + + + From 4d97cd1a45a01c224ff5b219228d4e8d24de15b9 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Wed, 14 Dec 2011 15:52:12 +0400 Subject: [PATCH 10/41] Mute "no tests" warning --- .../src/com/intellij/TestAll.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/platform/testFramework/src/com/intellij/TestAll.java b/platform/testFramework/src/com/intellij/TestAll.java index 50bd7b7b5c5d..e77bde661baa 100644 --- a/platform/testFramework/src/com/intellij/TestAll.java +++ b/platform/testFramework/src/com/intellij/TestAll.java @@ -313,20 +313,25 @@ public class TestAll implements Test { } return adapter; } - return new TestSuite(testCaseClass){ + + final int[] testsCount = {0}; + TestSuite suite = new TestSuite(testCaseClass) { @Override public void addTest(Test test) { - if (!(test instanceof TestCase)) { + if (!(test instanceof TestCase)) { + testsCount[0]++; super.addTest(test); - } else { - if (isPerformanceTestsRun() ^ (hasPerformance(((TestCase)test).getName()) || hasPerformance(testCaseClass.getSimpleName()))) return; - + } + else { + if (isPerformanceTestsRun() ^ (hasPerformance(((TestCase)test).getName()) || hasPerformance(testCaseClass.getSimpleName()))) + return; + Method method = findTestMethod((TestCase)test); if (method == null || !TestCaseLoader.isBombed(method)) { + testsCount[0]++; super.addTest(test); } } - } @Nullable @@ -334,6 +339,8 @@ public class TestAll implements Test { return safeFindMethod(testCase.getClass(), testCase.getName()); } }; + + return testsCount[0] > 0 ? suite : null; } return null; From fba470d64dcaa78fc22a53db2feec280f3854e57 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 14 Dec 2011 12:08:22 +0100 Subject: [PATCH 11/41] introduce "Introduce" refactorings subgroup --- .../src/messages/ActionsBundle.properties | 5 ++-- .../src/idea/LangActions.xml | 26 +++++++++++-------- plugins/java-i18n/src/META-INF/plugin.xml | 2 +- resources/src/idea/JavaActions.xml | 15 ++++++++--- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index a2e2275e992a..0622dc768fba 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -516,7 +516,7 @@ action.SafeDelete.text=Safe _Delete... action.SafeDelete.description=Delete the selected class, method or field, checking for usages action.ExtractMethod.text=E_xtract Method... action.ExtractMethod.description=Turn the selected code fragment into a method -action.RemoveMiddleman.text=Remove _Middleman +action.RemoveMiddleman.text=Remove _Middleman... action.RemoveMiddleman.description=Get the client to call the delegate directly action.MethodDuplicates.text=Replace Met_hod Code Duplicates... action.MethodDuplicates.description=Finds code in current file that can be transformed into a call of selected method @@ -524,7 +524,7 @@ action.InvertBoolean.text=Invert _Boolean... action.InvertBoolean.description=Makes the method return or variable contain the opposite value and corrects the references action.IntroduceParameterObject.text=Introduce Parameter Ob_ject... action.IntroduceParameterObject.description=Replaces method parameters list with object -action.ExtractClass.text=E_xtract Class... +action.ExtractClass.text=Extract Cla_ss... action.ExtractClass.description=Extract Delegate action.IntroduceVariable.text=Introduce _Variable... action.IntroduceVariable.description=Put a result of the selected expression into a variable @@ -540,6 +540,7 @@ action.ExtractModule.text=Extract _Module... action.ExtractModule.description=Extract module from the selected class action.ExtractSuperclass.text=Extract S_uperclass... action.ExtractSuperclass.description=Extract superclass from the selected class +group.IntroduceActionsGroup.text=Introd_uce action.TurnRefsToSuper.text=Use Interface _Where Possible... action.TurnRefsToSuper.description=Change usages of a class to those of its superclass or interface action.MembersPullUp.text=Pu_ll Members Up... diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml index 3c78baf31150..abcbcebc27a5 100644 --- a/platform/platform-resources/src/idea/LangActions.xml +++ b/platform/platform-resources/src/idea/LangActions.xml @@ -261,21 +261,25 @@ - - - - + + + + + + + + + + + + + + + - - - - - - - diff --git a/plugins/java-i18n/src/META-INF/plugin.xml b/plugins/java-i18n/src/META-INF/plugin.xml index 74ba4bab516c..398fb92da335 100644 --- a/plugins/java-i18n/src/META-INF/plugin.xml +++ b/plugins/java-i18n/src/META-INF/plugin.xml @@ -49,7 +49,7 @@ - + diff --git a/resources/src/idea/JavaActions.xml b/resources/src/idea/JavaActions.xml index 4688bab71e6e..39556a4d4be5 100644 --- a/resources/src/idea/JavaActions.xml +++ b/resources/src/idea/JavaActions.xml @@ -1,4 +1,4 @@ - + @@ -59,12 +59,19 @@ - - + - + + + + + + + + + From e8ccd03fa2f86d2533f3848d334824206750e205 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 14 Dec 2011 12:58:28 +0100 Subject: [PATCH 12/41] extract method object: order moved methods by usages; write access (IDEA-78847) --- .../ExtractMethodObjectHandler.java | 1 + .../ExtractMethodObjectProcessor.java | 19 +++--- .../WithPrivateMethodUsed1.java | 54 +++++++++++++++++ .../WithPrivateMethodUsed1.java.after | 59 +++++++++++++++++++ .../refactoring/ExtractMethodObjectTest.java | 4 ++ 5 files changed, 129 insertions(+), 8 deletions(-) create mode 100644 java/java-tests/testData/refactoring/extractMethodObject/WithPrivateMethodUsed1.java create mode 100644 java/java-tests/testData/refactoring/extractMethodObject/WithPrivateMethodUsed1.java.after 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 fa229ac8022d..93b9a847d49f 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectHandler.java @@ -98,6 +98,7 @@ public class ExtractMethodObjectHandler implements RefactoringActionHandler { PsiDocumentManager.getInstance(project).commitAllDocuments(); if (processor.isCreateInnerClass()) { processor.moveUsedMethodsToInner(); + PsiDocumentManager.getInstance(project).commitAllDocuments(); DuplicatesImpl.processDuplicates(extractProcessor, project, editor); } ApplicationManager.getApplication().runWriteAction(new Runnable() { 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 d8e4f27c6595..18b0ea35a282 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java @@ -80,7 +80,7 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor { private PsiMethod myInnerMethod; private boolean myMadeStatic = false; - private final Set myUsages = new HashSet(); + private final Set myUsages = new LinkedHashSet(); private PsiClass myInnerClass; private ChangeSignatureProcessor myChangeSignatureProcessor; private Runnable myCopyMethodToInner; @@ -109,7 +109,7 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor { } } if (isCreateInnerClass()) { - final Set usedMethods = new HashSet(); + final Set usedMethods = new LinkedHashSet(); getMethod().accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitMethodCallExpression(PsiMethodCallExpression expression) { @@ -224,13 +224,16 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor { }; dlg.show(); if (dlg.isOK()) { - for (MemberInfoBase memberInfo : panel.getTable().getSelectedMemberInfos()) { - if (memberInfo.isChecked()) { - myInnerClass.add(memberInfo.getMember().copy()); - memberInfo.getMember().delete(); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + for (MemberInfoBase memberInfo : panel.getTable().getSelectedMemberInfos()) { + if (memberInfo.isChecked()) { + myInnerClass.add(memberInfo.getMember().copy()); + memberInfo.getMember().delete(); + } + } } - - } + }); } } } diff --git a/java/java-tests/testData/refactoring/extractMethodObject/WithPrivateMethodUsed1.java b/java/java-tests/testData/refactoring/extractMethodObject/WithPrivateMethodUsed1.java new file mode 100644 index 000000000000..c5fbbd81e4c1 --- /dev/null +++ b/java/java-tests/testData/refactoring/extractMethodObject/WithPrivateMethodUsed1.java @@ -0,0 +1,54 @@ +import java.util.Date; + +public class TestClass { + + private Date expiry; + private Date maturity; + private int commitment; + private double outstanding; + private Iterable payments; + private Date today; + private Date start; + private int riskRating; + + + public double calculate() { + return ( outstandingRiskAmount() * duration() * riskFactor() ) + ( unusedRiskAmount() * duration() * unusedRiskFactor() ); + } + + private double riskFactor() { + return 5.0; + } + + private double unusedRiskFactor() { + return 6.0; + } + + private double unusedRiskAmount() { + return ( commitment - outstanding ); + } + + private double outstandingRiskAmount() { + return outstanding; + } + + private double getUsedPercentage() { + return 1.0; + } + + private double duration() { + if ( expiry == null && maturity != null ) { + return 1.0; + } else if ( expiry != null && maturity == null ) { + return yearsTo( expiry ); + } + return 0.0; + + } + + private double yearsTo( final Date endDate ) { + Date beginDate = ( today == null ? start : today ); + return ( ( endDate.getTime() - beginDate.getTime() )); + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractMethodObject/WithPrivateMethodUsed1.java.after b/java/java-tests/testData/refactoring/extractMethodObject/WithPrivateMethodUsed1.java.after new file mode 100644 index 000000000000..b19b72b035ae --- /dev/null +++ b/java/java-tests/testData/refactoring/extractMethodObject/WithPrivateMethodUsed1.java.after @@ -0,0 +1,59 @@ +import java.util.Date; + +public class TestClass { + + private Date expiry; + private Date maturity; + private int commitment; + private double outstanding; + private Iterable payments; + private Date today; + private Date start; + private int riskRating; + + + public double calculate() { + return new InnerClass().invoke(); + } + + private double getUsedPercentage() { + return 1.0; + } + + private double yearsTo( final Date endDate ) { + Date beginDate = ( today == null ? start : today ); + return ( ( endDate.getTime() - beginDate.getTime() )); + } + + private class InnerClass { + public double invoke() { + return ( outstandingRiskAmount() * duration() * riskFactor() ) + ( unusedRiskAmount() * duration() * unusedRiskFactor() ); + } + + private double outstandingRiskAmount() { + return outstanding; + } + + private double duration() { + if ( expiry == null && maturity != null ) { + return 1.0; + } else if ( expiry != null && maturity == null ) { + return yearsTo( expiry ); + } + return 0.0; + + } + + private double riskFactor() { + return 5.0; + } + + private double unusedRiskAmount() { + return ( commitment - outstanding ); + } + + private double unusedRiskFactor() { + return 6.0; + } + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java index ea43a5ed4b22..bfbef6b40775 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java @@ -110,6 +110,10 @@ public class ExtractMethodObjectTest extends LightRefactoringTestCase { public void testWithPrivateMethodUsed() throws Exception { doTest(); } + + public void testWithPrivateMethodUsed1() throws Exception { + doTest(); + } public void testWithPrivateMethodWhichCantBeMoved() throws Exception { doTest(); From 6a47009e964ba0816e7fc4589b2fc7c4716a7fca Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 14 Dec 2011 15:40:37 +0400 Subject: [PATCH 13/41] EA-31521 - assert: DirectoryIndexImpl.checkAvailability(cherry picked from commit 088317f) --- .../lang-api/src/com/intellij/openapi/module/ModuleUtil.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/lang-api/src/com/intellij/openapi/module/ModuleUtil.java b/platform/lang-api/src/com/intellij/openapi/module/ModuleUtil.java index 6f78c4cbb31e..e7c99a4b0538 100644 --- a/platform/lang-api/src/com/intellij/openapi/module/ModuleUtil.java +++ b/platform/lang-api/src/com/intellij/openapi/module/ModuleUtil.java @@ -108,6 +108,7 @@ public class ModuleUtil { if (!element.isValid()) return null; Project project = element.getProject(); + if (project.isDefault()) return null; final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); if (element instanceof PsiFileSystemItem && (!(element instanceof PsiFile) || element.getContext() == null)) { From 5ded82b3aaba39dc41e04ccdf4dd425e9e216f8c Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 14 Dec 2011 15:40:57 +0400 Subject: [PATCH 14/41] EA-31594 - CCE: CreateNSDeclarationIntentionFix.invoke(cherry picked from commit 763227a) --- .../impl/analysis/CreateNSDeclarationIntentionFix.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/CreateNSDeclarationIntentionFix.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/CreateNSDeclarationIntentionFix.java index db610e505cfc..073e4236cd69 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/CreateNSDeclarationIntentionFix.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/CreateNSDeclarationIntentionFix.java @@ -84,14 +84,15 @@ public class CreateNSDeclarationIntentionFix implements HintAction, LocalQuickFi } protected CreateNSDeclarationIntentionFix(@NotNull final PsiElement element, - @NotNull final String namespacePrefix, XmlFile containingFile) { + @NotNull final String namespacePrefix, + @NotNull XmlFile containingFile) { this(element, namespacePrefix, null, containingFile); } public CreateNSDeclarationIntentionFix(final PsiElement element, final String namespacePrefix, @Nullable final XmlToken token, - XmlFile containingFile) { + @NotNull XmlFile containingFile) { myNamespacePrefix = namespacePrefix; myElement = element; myFile = containingFile; @@ -132,7 +133,7 @@ public class CreateNSDeclarationIntentionFix implements HintAction, LocalQuickFi public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException { if (!myElement.isValid() || !CodeInsightUtilBase.prepareFileForWrite(file)) return; - final Set set = XmlExtension.getExtension(file).guessUnboundNamespaces(myElement, (XmlFile)file); + final Set set = XmlExtension.getExtension(myFile).guessUnboundNamespaces(myElement, myFile); final String[] namespaces = ArrayUtil.toStringArray(set); Arrays.sort(namespaces); From 0d04f9c757d9911dc821642e36dcf8000caa715b Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 14 Dec 2011 15:41:23 +0400 Subject: [PATCH 15/41] EA-31679 - NPE: JarMemoryLoader.load(cherry picked from commit d284800) --- platform/util/src/com/intellij/util/lang/JarMemoryLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/util/src/com/intellij/util/lang/JarMemoryLoader.java b/platform/util/src/com/intellij/util/lang/JarMemoryLoader.java index 97a29e9cf152..ec0c822d2373 100644 --- a/platform/util/src/com/intellij/util/lang/JarMemoryLoader.java +++ b/platform/util/src/com/intellij/util/lang/JarMemoryLoader.java @@ -49,7 +49,7 @@ public class JarMemoryLoader { ZipInputStream zipStream = new ZipInputStream(inputStream); try { ZipEntry sizeEntry = zipStream.getNextEntry(); - if (!sizeEntry.getName().equals(SIZE_ENTRY)) return null; + if (sizeEntry == null || !sizeEntry.getName().equals(SIZE_ENTRY)) return null; byte[] bytes = FileUtil.loadBytes(zipStream, 2); int size = ZipShort.getValue(bytes); From 102b16b3ba20821522698e4a80047f20aeaee0bf Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 14 Dec 2011 15:42:36 +0400 Subject: [PATCH 16/41] display repository editor when new one added (didn't work if invoked from a dialog)(cherry picked from commit dd671eb) --- .../tasks/config/TaskRepositoriesConfigurable.form | 14 ++++++++++++-- .../tasks/config/TaskRepositoriesConfigurable.java | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.form b/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.form index e532db90db9b..bb2cf0d68e45 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.form +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.form @@ -1,6 +1,6 @@
- + @@ -28,12 +28,22 @@ - + + + + + + + + + + +
diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.java index 6797b6023f80..f3865d38868b 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskRepositoriesConfigurable.java @@ -10,6 +10,7 @@ import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ui.configuration.actions.IconWithTextAction; +import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.tasks.TaskManager; @@ -49,6 +50,7 @@ public class TaskRepositoriesConfigurable extends BaseConfigurable implements Co private JPanel myToolbarPanel; private JPanel myRepositoryEditor; private JBLabel myServersLabel; + private Splitter mySplitter; private final List myRepositories = new ArrayList(); private final Project myProject; @@ -150,6 +152,8 @@ public class TaskRepositoriesConfigurable extends BaseConfigurable implements Co String name = myRepoNames.get(repository); assert name != null; ((CardLayout)myRepositoryEditor.getLayout()).show(myRepositoryEditor, name); + mySplitter.doLayout(); + mySplitter.repaint(); } } }); From 46e3be89af91a31dfe0abe9483cccbaed7ac570f Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 14 Dec 2011 15:45:41 +0400 Subject: [PATCH 17/41] IDEA-77863 No class or file name completion in "Commit Changes"(cherry picked from commit ed6f88f) --- .../src/com/intellij/tasks/impl/TaskCompletionContributor.java | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskCompletionContributor.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskCompletionContributor.java index 1d8ea494f704..8d5929f712c8 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskCompletionContributor.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/TaskCompletionContributor.java @@ -53,7 +53,6 @@ public class TaskCompletionContributor extends CompletionContributor { } if (consumer != null) { - result.stopHere(); String text = parameters.getOriginalFile().getText(); int i = text.lastIndexOf(' ', parameters.getOffset() - 1) + 1; From b2b3e8b9cdc0578390c27a90cc9c5c7bcf84a1f9 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 14 Dec 2011 15:46:33 +0400 Subject: [PATCH 18/41] logging for EA-32202 - NPE: FileReference.getVariants(cherry picked from commit 2ba2e01) --- .../resolve/reference/impl/providers/FileReference.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java index 2514e0e182ed..25f3fffbed51 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java @@ -23,6 +23,7 @@ import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.codeInspection.LocalQuickFix; import com.intellij.codeInspection.LocalQuickFixProvider; import com.intellij.lang.LangBundle; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Iconable; @@ -61,6 +62,8 @@ public class FileReference implements FileReferenceOwner, PsiPolyVariantReferenc QuickFixProvider, LocalQuickFixProvider, EmptyResolveMessageProvider, BindablePsiReference { + private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference"); + public static final FileReference[] EMPTY = new FileReference[0]; private static final TObjectHashingStrategy RESOLVE_RESULT_HASHING_STRATEGY = new TObjectHashingStrategy() { @Override @@ -123,7 +126,11 @@ public class FileReference implements FileReferenceOwner, PsiPolyVariantReferenc protected Collection getContexts() { final FileReference contextRef = getContextReference(); if (contextRef == null) { - return myFileReferenceSet.getDefaultContexts(); + Collection defaultContexts = myFileReferenceSet.getDefaultContexts(); + for (PsiFileSystemItem context : defaultContexts) { + LOG.assertTrue(context != null, myFileReferenceSet.getClass() + " provided a null context"); + } + return defaultContexts; } ResolveResult[] resolveResults = contextRef.multiResolve(false); ArrayList result = new ArrayList(); From 2e8eda397e6babfa0c1fa5dfd1f6ed716b1b8053 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 14 Dec 2011 16:13:35 +0400 Subject: [PATCH 19/41] applyToDialects processed properly(cherry picked from commit 94e75a8) --- .../codeInsight/daemon/impl/LocalInspectionsPass.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java index 3aed41568a8b..cf271064c67d 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java @@ -275,8 +275,10 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass LocalInspectionTool tool = wrapper.getTool(); if (!checkDumbAwareness || tool instanceof DumbAware) { map.putValue(tool, language); - for (Language dialect : lang.getDialects()) { - map.putValue(tool, dialect.getID()); + if (wrapper.applyToDialects()) { + for (Language dialect : lang.getDialects()) { + map.putValue(tool, dialect.getID()); + } } } } From 6982d068c1b0e3cfa693f85a251b2131e497702f Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Tue, 13 Dec 2011 20:44:13 +0400 Subject: [PATCH 20/41] IDEA-76860 android ui preview: correctly set default device configuration for file; save device configuration per file [rev=nnmatveev] --- .../AndroidLayoutPreviewToolWindowForm.java | 91 ++++++++++++--- ...AndroidLayoutPreviewToolWindowManager.java | 16 +-- ...ndroidLayoutPreviewToolWindowSettings.java | 108 ++++++++++++++---- 3 files changed, 170 insertions(+), 45 deletions(-) diff --git a/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowForm.java b/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowForm.java index ada0c73fd715..29f37c6b6d39 100644 --- a/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowForm.java +++ b/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowForm.java @@ -2,6 +2,7 @@ package org.jetbrains.android.uipreview; import com.android.AndroidConstants; import com.android.ide.common.resources.ResourceResolver; +import com.android.ide.common.resources.configuration.FolderConfiguration; import com.android.ide.common.resources.configuration.LanguageQualifier; import com.android.ide.common.resources.configuration.RegionQualifier; import com.android.ide.common.resources.configuration.ScreenSizeQualifier; @@ -252,12 +253,12 @@ class AndroidLayoutPreviewToolWindowForm implements Disposable { optionsGroup.addAction(new CheckboxAction("Hide for non-layout files") { @Override public boolean isSelected(AnActionEvent e) { - return mySettings.getState().isHideForNonLayoutFiles(); + return mySettings.getGlobalState().isHideForNonLayoutFiles(); } @Override public void setSelected(AnActionEvent e, boolean state) { - mySettings.getState().setHideForNonLayoutFiles(state); + mySettings.getGlobalState().setHideForNonLayoutFiles(state); } }).setAsSecondary(true); @@ -391,6 +392,7 @@ class AndroidLayoutPreviewToolWindowForm implements Disposable { } public void setFile(@Nullable PsiFile file) { + final boolean fileChanged = !Comparing.equal(myFile, file); myFile = file; final AndroidPlatform newPlatform = getPlatform(file); @@ -403,9 +405,16 @@ class AndroidLayoutPreviewToolWindowForm implements Disposable { if (!myResetFlag) { reset(); myResetFlag = true; + return; } } } + + if (file != null && fileChanged) { + myResetFlag = false; + reset(); + myResetFlag = true; + } } @Nullable @@ -427,9 +436,14 @@ class AndroidLayoutPreviewToolWindowForm implements Disposable { } return null; } + + @Nullable + private VirtualFile getVirtualFile() { + return myFile != null ? myFile.getVirtualFile() : null; + } private void saveState() { - final AndroidLayoutPreviewToolWindowSettings.State state = mySettings.getState(); + final AndroidLayoutPreviewToolWindowSettings.GlobalState state = mySettings.getGlobalState(); if (myResetFlag) { final LayoutDevice selectedDevice = getSelectedDevice(); @@ -438,8 +452,18 @@ class AndroidLayoutPreviewToolWindowForm implements Disposable { } final LayoutDeviceConfiguration deviceConfig = getSelectedDeviceConfiguration(); - if (deviceConfig != null) { - state.setDeviceConfiguration(deviceConfig.getName()); + final VirtualFile vFile = getVirtualFile(); + if (deviceConfig != null && vFile != null) { + final LayoutDeviceConfiguration defaultConfig = getDefaultDeviceConfigForFile(vFile); + final String defaultConfigName = defaultConfig != null ? defaultConfig.getName() : null; + final String deviceConfigName = deviceConfig.getName(); + + if (Comparing.equal(deviceConfigName, defaultConfigName)) { + mySettings.removeDeviceConfiguration(vFile); + } + else { + mySettings.setDeviceConfiguration(vFile, deviceConfigName); + } } final UiMode dockMode = getSelectedDockMode(); @@ -473,7 +497,7 @@ class AndroidLayoutPreviewToolWindowForm implements Disposable { } private void reset() { - final AndroidLayoutPreviewToolWindowSettings.State state = mySettings.getState(); + final AndroidLayoutPreviewToolWindowSettings.GlobalState state = mySettings.getGlobalState(); final String savedDeviceName = state.getDevice(); if (savedDeviceName != null) { @@ -489,17 +513,28 @@ class AndroidLayoutPreviewToolWindowForm implements Disposable { } } - final String savedDeviceConfigName = state.getDeviceConfiguration(); - if (savedDeviceConfigName != null) { - LayoutDeviceConfiguration savedDeviceConfig = null; - for (LayoutDeviceConfiguration config : myDeviceConfigurations) { - if (savedDeviceConfigName.equals(config.getName())) { - savedDeviceConfig = config; - break; + final VirtualFile vFile = getVirtualFile(); + if (vFile != null) { + final String savedDeviceConfigName = mySettings.getDeviceConfiguration(vFile); + + if (savedDeviceConfigName != null) { + LayoutDeviceConfiguration savedDeviceConfig = null; + for (LayoutDeviceConfiguration config : myDeviceConfigurations) { + if (savedDeviceConfigName.equals(config.getName())) { + savedDeviceConfig = config; + break; + } + } + if (savedDeviceConfig != null) { + myDeviceConfigurationsCombo.setSelectedItem(savedDeviceConfig); } } - if (savedDeviceConfig != null) { - myDeviceConfigurationsCombo.setSelectedItem(savedDeviceConfig); + else { + final LayoutDeviceConfiguration defaultConfig = getDefaultDeviceConfigForFile(vFile); + + if (defaultConfig != null) { + myDeviceConfigurationsCombo.setSelectedItem(defaultConfig); + } } } @@ -556,8 +591,32 @@ class AndroidLayoutPreviewToolWindowForm implements Disposable { } } + @Nullable + private LayoutDeviceConfiguration getDefaultDeviceConfigForFile(@NotNull VirtualFile vFile) { + final VirtualFile folder = vFile.getParent(); + + if (folder == null) { + return null; + } + final String[] folderSegments = folder.getName().split(AndroidConstants.RES_QUALIFIER_SEP); + + if (folderSegments.length == 0) { + return null; + } + final FolderConfiguration config = FolderConfiguration.getConfig(folderSegments); + + if (config != null) { + for (LayoutDeviceConfiguration deviceConfig : myDeviceConfigurations) { + if (deviceConfig.getConfiguration().isMatchFor(config)) { + return deviceConfig; + } + } + } + return null; + } + private void resetThemes(Collection themes) { - final String savedThemeName = mySettings.getState().getTheme(); + final String savedThemeName = mySettings.getGlobalState().getTheme(); if (savedThemeName != null) { ThemeData savedTheme = null; for (Object o : themes) { diff --git a/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowManager.java b/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowManager.java index 6391255a280b..827844b76141 100644 --- a/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowManager.java +++ b/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowManager.java @@ -185,7 +185,7 @@ public class AndroidLayoutPreviewToolWindowManager implements ProjectComponent { final ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(toolWindowId); if (window != null && window.isAvailable()) { final boolean visible = window.isVisible(); - AndroidLayoutPreviewToolWindowSettings.getInstance(myProject).getState().setVisible(visible); + AndroidLayoutPreviewToolWindowSettings.getInstance(myProject).getGlobalState().setVisible(visible); if (visible && !myVisible) { render(); @@ -244,7 +244,7 @@ public class AndroidLayoutPreviewToolWindowManager implements ProjectComponent { } final AndroidLayoutPreviewToolWindowSettings settings = AndroidLayoutPreviewToolWindowSettings.getInstance(myProject); - final boolean hideForNonLayoutFiles = settings.getState().isHideForNonLayoutFiles(); + final boolean hideForNonLayoutFiles = settings.getGlobalState().isHideForNonLayoutFiles(); if (activeEditor == null) { myToolWindowForm.setFile(null); @@ -266,7 +266,7 @@ public class AndroidLayoutPreviewToolWindowManager implements ProjectComponent { } myToolWindow.setAvailable(true, null); - final boolean visible = AndroidLayoutPreviewToolWindowSettings.getInstance(myProject).getState().isVisible(); + final boolean visible = AndroidLayoutPreviewToolWindowSettings.getInstance(myProject).getGlobalState().isVisible(); if (visible) { myToolWindow.show(null); } @@ -364,12 +364,12 @@ public class AndroidLayoutPreviewToolWindowManager implements ProjectComponent { synchronized (RENDERING_LOCK) { final StringBuilder warnBuilder = new StringBuilder(); - if (target != null && theme != null && - RenderUtil.renderLayout(myProject, layoutXmlText, layoutXmlFile, imgPath, - target, facet, config, xdpi, ydpi, theme, warnBuilder)) { + if (target != null && theme != null && + RenderUtil.renderLayout(myProject, layoutXmlText, layoutXmlFile, imgPath, + target, facet, config, xdpi, ydpi, theme, warnBuilder)) { warnMessage = warnBuilder.toString(); - final File input = new File(imgPath); - image = ImageIO.read(input); + final File input = new File(imgPath); + image = ImageIO.read(input); } } } diff --git a/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowSettings.java b/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowSettings.java index 96d641a1d1ae..ac408eee2f96 100644 --- a/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowSettings.java +++ b/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowSettings.java @@ -5,8 +5,15 @@ import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.VirtualFileManager; +import com.intellij.util.containers.HashMap; +import com.intellij.util.xmlb.annotations.MapAnnotation; +import com.intellij.util.xmlb.annotations.Tag; import org.jetbrains.annotations.NotNull; +import java.util.Map; + /** * @author Eugene.Kudelevsky */ @@ -16,26 +23,93 @@ import org.jetbrains.annotations.NotNull; @Storage(id = "AndroidLayoutPreviewToolWindow", file = "$WORKSPACE_FILE$") } ) -public class AndroidLayoutPreviewToolWindowSettings implements PersistentStateComponent { - private State myState = new State(); +public class AndroidLayoutPreviewToolWindowSettings implements PersistentStateComponent { + private final Map myFile2DeviceConfig = new HashMap(); + private GlobalState myGlobalState = new GlobalState(); public static AndroidLayoutPreviewToolWindowSettings getInstance(@NotNull Project project) { - return ServiceManager.getService(project, AndroidLayoutPreviewToolWindowSettings.class); + return ServiceManager.getService(project, AndroidLayoutPreviewToolWindowSettings.class); + } + + @NotNull + public GlobalState getGlobalState() { + return myGlobalState; + } + + public String getDeviceConfiguration(@NotNull VirtualFile file) { + synchronized (myFile2DeviceConfig) { + return myFile2DeviceConfig.get(file); + } + } + + public void setDeviceConfiguration(@NotNull VirtualFile file, @NotNull String deviceConfiguration) { + synchronized (myFile2DeviceConfig) { + myFile2DeviceConfig.put(file, deviceConfiguration); + } + } + + public void removeDeviceConfiguration(@NotNull VirtualFile file) { + synchronized (myFile2DeviceConfig) { + myFile2DeviceConfig.remove(file); + } + } + + @Override + public MyState getState() { + final Map url2DeviceConfig = new HashMap(); + + synchronized (myFile2DeviceConfig) { + for (Map.Entry entry : myFile2DeviceConfig.entrySet()) { + url2DeviceConfig.put(entry.getKey().getUrl(), entry.getValue()); + } + } + final MyState state = new MyState(); + state.setUrl2DeviceConfig(url2DeviceConfig); + state.setState(myGlobalState); + return state; + } + + @Override + public void loadState(MyState state) { + myGlobalState = state.getState(); + synchronized (myFile2DeviceConfig) { + myFile2DeviceConfig.clear(); + + for (Map.Entry entry : state.getUrl2DeviceConfig().entrySet()) { + final VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(entry.getKey()); + + if (file != null) { + myFile2DeviceConfig.put(file, entry.getValue()); + } + } + } + } + + public static class MyState { + private GlobalState myGlobalState = new GlobalState(); + private Map myUrl2DeviceConfig = new HashMap(); + + public GlobalState getState() { + return myGlobalState; } - @Override - public void loadState(State state) { - myState = state; + @Tag("device-configurations") + @MapAnnotation(surroundWithTag = false) + public Map getUrl2DeviceConfig() { + return myUrl2DeviceConfig; + } + + public void setState(GlobalState state) { + myGlobalState = state; + } + + public void setUrl2DeviceConfig(Map url2DeviceConfig) { + myUrl2DeviceConfig = url2DeviceConfig; + } } - @Override - public State getState() { - return myState; - } - - public static class State { + public static class GlobalState { private String myDevice; - private String myDeviceConfiguration; private String myDockMode; private String myNightMode; private String myTargetHashString; @@ -53,14 +127,6 @@ public class AndroidLayoutPreviewToolWindowSettings implements PersistentStateCo myDevice = device; } - public String getDeviceConfiguration() { - return myDeviceConfiguration; - } - - public void setDeviceConfiguration(String deviceConfiguration) { - myDeviceConfiguration = deviceConfiguration; - } - public String getDockMode() { return myDockMode; } From edc15dd54f8f11d158def34da85af713a67a6fd4 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Tue, 13 Dec 2011 22:43:40 +0400 Subject: [PATCH 21/41] android packaging: correct value of 'debug-mode' parameter --- .../android/compiler/AndroidResourcesPackagingCompiler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidResourcesPackagingCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidResourcesPackagingCompiler.java index 236c4cbde162..50783b06c374 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidResourcesPackagingCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidResourcesPackagingCompiler.java @@ -157,7 +157,7 @@ public class AndroidResourcesPackagingCompiler implements ClassPostProcessingCom preprocessedManifestFile.getPath(), item.myResourceDirPaths, item.myAssetsDirPath, - outputPath, null, false, 0); + outputPath, null, !releasePackage, 0); AndroidCompileUtil.addMessages(context, messages, presentableFilesMap); } catch (final IOException e) { From bf6e4ec66be2efda08b5b108733af75ad559af41 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Wed, 14 Dec 2011 14:58:14 +0400 Subject: [PATCH 22/41] quote paths --- .../android/compiler/AndroidProguardCompiler.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidProguardCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidProguardCompiler.java index dbf2fbaafd75..0c637845975d 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidProguardCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidProguardCompiler.java @@ -229,16 +229,16 @@ public class AndroidProguardCompiler implements ClassPostProcessingCompiler { if (logDirOutputOsPath != null) { commands.add("-dump"); - commands.add(new File(logDirOutputOsPath, "dump.txt").getAbsolutePath()); + commands.add(quotePath(new File(logDirOutputOsPath, "dump.txt").getAbsolutePath())); commands.add("-printseeds"); - commands.add(new File(logDirOutputOsPath, "seeds.txt").getAbsolutePath()); + commands.add(quotePath(new File(logDirOutputOsPath, "seeds.txt").getAbsolutePath())); commands.add("-printusage"); - commands.add(new File(logDirOutputOsPath, "usage.txt").getAbsolutePath()); + commands.add(quotePath(new File(logDirOutputOsPath, "usage.txt").getAbsolutePath())); commands.add("-printmapping"); - commands.add(new File(logDirOutputOsPath, "mapping.txt").getAbsolutePath()); + commands.add(quotePath(new File(logDirOutputOsPath, "mapping.txt").getAbsolutePath())); } LOG.info(AndroidUtils.command2string(commands)); From 54d3fe418451cbb1f205ec73bb0bbef9595c56d3 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 14 Dec 2011 13:23:17 +0100 Subject: [PATCH 23/41] experimental --- .../surroundWith/JavaWithRunnableSurrounder.java | 5 +++++ .../introduce/inplace/InplaceVariableIntroducer.java | 5 +++++ .../com/intellij/refactoring/rename/RenameDialog.java | 7 ++++++- .../rename/inplace/VariableInplaceRenamer.java | 6 ++++++ .../intellij/refactoring/ui/NameSuggestionsField.java | 9 +++++++-- 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithRunnableSurrounder.java b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithRunnableSurrounder.java index 0f7e7ae14dc1..19f65c5202a3 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithRunnableSurrounder.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithRunnableSurrounder.java @@ -74,6 +74,11 @@ public class JavaWithRunnableSurrounder extends JavaStatementsSurrounder{ editor.getCaretModel().moveToOffset(textOffset); editor.getSelectionModel().removeSelection(); new VariableInplaceRenamer(variable, editor){ + @Override + protected boolean shouldSelectAll() { + return true; + } + @Override protected void moveOffsetAfter(boolean success) { super.moveOffsetAfter(success); diff --git a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/InplaceVariableIntroducer.java b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/InplaceVariableIntroducer.java index c57894747d03..c2a2981a89aa 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/InplaceVariableIntroducer.java +++ b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/InplaceVariableIntroducer.java @@ -80,6 +80,11 @@ public class InplaceVariableIntroducer extends VariableInp initOccurrencesMarkers(); } + @Override + protected boolean shouldSelectAll() { + return true; + } + @Override protected StartMarkAction startRename() throws StartMarkAction.AlreadyStartedException { return null; diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java index 9da647f7a4f4..07ecad7713a7 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java @@ -115,7 +115,12 @@ public class RenameDialog extends RefactoringDialog { private void createNewNameComponent() { String[] suggestedNames = getSuggestedNames(); - myNameSuggestionsField = new NameSuggestionsField(suggestedNames, myProject, FileTypes.PLAIN_TEXT, myEditor); + myNameSuggestionsField = new NameSuggestionsField(suggestedNames, myProject, FileTypes.PLAIN_TEXT, myEditor) { + @Override + protected boolean shouldSelectAll() { + return false; + } + }; if (myPsiElement instanceof PsiFile && myEditor == null) { myNameSuggestionsField.selectNameWithoutExtension(); } diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java index 15c1267fd004..fc32f5e340b4 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java @@ -404,6 +404,8 @@ public class VariableInplaceRenamer { myEditor.getCaretModel().moveToOffset(rangeMarker.isValid() ? rangeMarker.getStartOffset() : offset); if (selectedRange != null){ myEditor.getSelectionModel().setSelection(selectedRange.getStartOffset(), selectedRange.getEndOffset()); + } else if (!shouldSelectAll()){ + myEditor.getSelectionModel().removeSelection(); } } }; @@ -444,6 +446,10 @@ public class VariableInplaceRenamer { return true; } + protected boolean shouldSelectAll() { + return false; + } + protected void navigateToAlreadyStarted(Document oldDocument, int exitCode) { final PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(oldDocument); if (file != null) { diff --git a/platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java b/platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java index ccdf4202f269..fda256aca006 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java +++ b/platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java @@ -36,7 +36,8 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.event.EventListenerList; import java.awt.*; -import java.awt.event.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.EventListener; import java.util.List; @@ -104,7 +105,7 @@ public class NameSuggestionsField extends JPanel { if (selectionModel.hasSelection() && selected != null && !selected.isEmpty()) { myEditor.getSelectionModel().setSelection(selected.getStartOffset(), selected.getEndOffset()); } - else { + else if (shouldSelectAll()) { myEditor.getSelectionModel().setSelection(0, myEditor.getDocument().getTextLength()); } break; @@ -113,6 +114,10 @@ public class NameSuggestionsField extends JPanel { }); } + protected boolean shouldSelectAll() { + return true; + } + public void selectNameWithoutExtension() { SwingUtilities.invokeLater(new Runnable() { public void run() { From 347da6164dcfbc010fcfdbaed4ae989e0d49e47b Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Wed, 14 Dec 2011 13:15:19 +0100 Subject: [PATCH 24/41] cosmetics --- .../lang/ant/psi/impl/ReflectedProject.java | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/plugins/ant/src/com/intellij/lang/ant/psi/impl/ReflectedProject.java b/plugins/ant/src/com/intellij/lang/ant/psi/impl/ReflectedProject.java index ec82c9a6bf5d..15c9166b4dc3 100644 --- a/plugins/ant/src/com/intellij/lang/ant/psi/impl/ReflectedProject.java +++ b/plugins/ant/src/com/intellij/lang/ant/psi/impl/ReflectedProject.java @@ -64,9 +64,6 @@ public final class ReflectedProject { iterator.remove(); } else { - if (pair.first != null && pair.first.getProject() == null) { - iterator.remove(); - } if (pair.second == classLoader) { return pair.first; } @@ -76,35 +73,35 @@ public final class ReflectedProject { finally { ourProjectsLock.unlock(); } - final ReflectedProject project = new ReflectedProject(classLoader); - if (project.getProject() != null) { // do not cache partially-loaded stuff + final ReflectedProject reflectedProj = new ReflectedProject(classLoader); + if (reflectedProj.getProject() != null) { // do not cache partially-loaded stuff ourProjectsLock.lock(); try { ourProjects.add(new SoftReference>( - new Pair(project, classLoader) + new Pair(reflectedProj, classLoader) )); } finally { ourProjectsLock.unlock(); } } - return project; + return reflectedProj; } ReflectedProject(final ClassLoader classLoader) { - Object myProject = null; + Object project = null; try { final Class projectClass = classLoader.loadClass("org.apache.tools.ant.Project"); if (projectClass != null) { - myProject = projectClass.newInstance(); + project = projectClass.newInstance(); Method method = projectClass.getMethod(INIT_METHOD_NAME); - method.invoke(myProject); + method.invoke(project); method = getMethod(projectClass, GET_TASK_DEFINITIONS_METHOD_NAME); - myTaskDefinitions = (Hashtable)method.invoke(myProject); + myTaskDefinitions = (Hashtable)method.invoke(project); method = getMethod(projectClass, GET_DATA_TYPE_DEFINITIONS_METHOD_NAME); - myDataTypeDefinitions = (Hashtable)method.invoke(myProject); + myDataTypeDefinitions = (Hashtable)method.invoke(project); method = getMethod(projectClass, GET_PROPERTIES_METHOD_NAME); - myProperties = (Hashtable)method.invoke(myProject); + myProperties = (Hashtable)method.invoke(project); myTargetClass = classLoader.loadClass("org.apache.tools.ant.Target"); } } @@ -118,7 +115,7 @@ public final class ReflectedProject { } else { LOG.info(e); - myProject = null; + project = null; } } catch (InvocationTargetException e) { @@ -128,14 +125,14 @@ public final class ReflectedProject { } else { LOG.info(e); - myProject = null; + project = null; } } catch (Throwable e) { LOG.info(e); - myProject = null; + project = null; } - this.myProject = myProject; + myProject = project; } private static Method getMethod(final Class introspectionHelperClass, final String name) throws NoSuchMethodException { From 306d10a2fd59e253a1e0b46e658e700c8ab5c384 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Wed, 14 Dec 2011 16:30:48 +0400 Subject: [PATCH 25/41] last two usages of groovy script program parameters fixed --- .../org/jetbrains/plugins/gradle/config/GradleScriptType.java | 2 +- .../src/org/jetbrains/plugins/groovy/gant/GantScriptType.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java index 2b419614cdf6..ad65a832013a 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java @@ -84,7 +84,7 @@ public class GradleScriptType extends GroovyScriptType { @Override public boolean isConfigurationByLocation(@NotNull GroovyScriptRunConfiguration existing, @NotNull Location location) { - final String params = existing.getProgramParameters(); + final String params = existing.getScriptParameters(); final String s = getTaskTarget(location); return s != null && params != null && (params.startsWith(s + " ") || params.equals(s)); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantScriptType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantScriptType.java index e8f36cba6a4e..faac54dbab44 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantScriptType.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantScriptType.java @@ -65,7 +65,7 @@ public class GantScriptType extends GroovyScriptType { @Override public boolean isConfigurationByLocation(@NotNull GroovyScriptRunConfiguration existing, @NotNull Location place) { - final String params = existing.getProgramParameters(); + final String params = existing.getScriptParameters(); final String s = getTargetName(place); return s != null && params != null && (params.startsWith(s + " ") || params.equals(s)); } From 3f7342de07d23d9f76c9156bc0e049a2e5c43aec Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Wed, 14 Dec 2011 17:13:31 +0400 Subject: [PATCH 26/41] Mute "no tests" warning, take II --- platform/testFramework/src/com/intellij/TestAll.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/testFramework/src/com/intellij/TestAll.java b/platform/testFramework/src/com/intellij/TestAll.java index e77bde661baa..eec7f36d2478 100644 --- a/platform/testFramework/src/com/intellij/TestAll.java +++ b/platform/testFramework/src/com/intellij/TestAll.java @@ -323,7 +323,9 @@ public class TestAll implements Test { super.addTest(test); } else { - if (isPerformanceTestsRun() ^ (hasPerformance(((TestCase)test).getName()) || hasPerformance(testCaseClass.getSimpleName()))) + String name = ((TestCase)test).getName(); + if ("warning".equals(name)) return; // Mute TestSuite's "no tests found" warning + if (isPerformanceTestsRun() ^ (hasPerformance(name) || hasPerformance(testCaseClass.getSimpleName()))) return; Method method = findTestMethod((TestCase)test); From 774d17c533581858eaa8fc9da68c567a634640a2 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Wed, 14 Dec 2011 17:14:25 +0400 Subject: [PATCH 27/41] in persistent fs use more optimal getInt / getLong / putInt / putLong via unsafe, given the fact file record is page aligned --- .../intellij/openapi/vfs/newvfs/persistent/FSRecords.java | 5 ++++- platform/util/src/com/intellij/util/io/PagedFileStorage.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java index d974d2a90ec7..e7906619043a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java @@ -190,7 +190,10 @@ public class FSRecords implements Forceable { myNames = new PersistentStringEnumerator(namesFile); myAttributes = new Storage(attributesFile.getCanonicalPath()); myContents = new RefCountingStorage(contentsFile.getCanonicalPath()); - myRecords = new ResizeableMappedFile(recordsFile, 20 * 1024, new PagedFileStorage.StorageLock(false)); + boolean aligned = PagedFileStorage.BUFFER_SIZE % RECORD_SIZE == 0; + assert aligned; // for performance + myRecords = new ResizeableMappedFile(recordsFile, 20 * 1024, new PagedFileStorage.StorageLock(false), + PagedFileStorage.BUFFER_SIZE, aligned); if (myRecords.length() == 0) { cleanRecord(0); // Clean header diff --git a/platform/util/src/com/intellij/util/io/PagedFileStorage.java b/platform/util/src/com/intellij/util/io/PagedFileStorage.java index 4a1a16e79d7f..6a6c14671010 100644 --- a/platform/util/src/com/intellij/util/io/PagedFileStorage.java +++ b/platform/util/src/com/intellij/util/io/PagedFileStorage.java @@ -44,7 +44,7 @@ public class PagedFileStorage implements Forceable { private final static int LOWER_LIMIT; private final static int UPPER_LIMIT; - private final static int BUFFER_SIZE; + public final static int BUFFER_SIZE; private static final int UNKNOWN_PAGE = -1; static { From 25f7e20d309e335b9bcdbff00a601f0b0f9291ed Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 14 Dec 2011 14:33:51 +0100 Subject: [PATCH 28/41] fix SmartTypeCompletionTest.testChainingPerformance --- .../SecondSmartTypeCompletionTest.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SecondSmartTypeCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SecondSmartTypeCompletionTest.java index b520670d9f5a..082584d0aa84 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SecondSmartTypeCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SecondSmartTypeCompletionTest.java @@ -4,7 +4,8 @@ import com.intellij.JavaTestUtil; import com.intellij.codeInsight.CodeInsightSettings; import com.intellij.codeInsight.lookup.*; import com.intellij.codeInsight.lookup.impl.LookupImpl; -import com.intellij.testFramework.IdeaTestUtil; +import com.intellij.testFramework.PlatformTestUtil; +import com.intellij.util.ThrowableRunnable; import org.jetbrains.annotations.NonNls; @SuppressWarnings({"ALL"}) @@ -75,10 +76,16 @@ public class SecondSmartTypeCompletionTest extends LightCompletionTestCase { public void testNewStaticProblem() throws Throwable { doTest(); } public void testChainingPerformance() throws Throwable { - long time = System.currentTimeMillis(); - configure(); - IdeaTestUtil.assertTiming("", 3000, System.currentTimeMillis() - time); - assertNotNull(myItems); + configureByFileNoComplete(BASE_PATH + "/" + getTestName(false) + ".java"); + PlatformTestUtil.startPerformanceTest(getTestName(false), 1000, new ThrowableRunnable() { + @Override + public void run() throws Exception { + configure(); + assertNotNull(myItems); + LookupManager.getInstance(getProject()).hideActiveLookup(); + } + }).cpuBound().assertTiming(); + } public void testArrayMemberAccess() throws Throwable { doTest(); } From 334d3a8489050ea5723704843d0672648eb9f214 Mon Sep 17 00:00:00 2001 From: Shaverdova Elena Date: Wed, 14 Dec 2011 17:36:17 +0400 Subject: [PATCH 29/41] WI-8238 File deployment: Sync: Zoom actions are disabled for image --- .../org/intellij/images/editor/impl/ImageEditorImpl.java | 4 ++-- .../images/editor/impl/ImageFileEditorProvider.java | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/images/src/org/intellij/images/editor/impl/ImageEditorImpl.java b/images/src/org/intellij/images/editor/impl/ImageEditorImpl.java index dfedbcd7a76f..658f7803bc89 100644 --- a/images/src/org/intellij/images/editor/impl/ImageEditorImpl.java +++ b/images/src/org/intellij/images/editor/impl/ImageEditorImpl.java @@ -38,14 +38,14 @@ import java.beans.PropertyChangeListener; * * @author Alexey Efimov */ -public class ImageEditorImpl implements ImageEditor { +class ImageEditorImpl implements ImageEditor { private final PropertyChangeListener optionsChangeListener = new OptionsChangeListener(); private final Project project; private final ImageContentProvider contentProvider; private final ImageEditorUI editorUI; private boolean disposed; - public ImageEditorImpl(@NotNull Project project, @NotNull final ImageContentProvider contentProvider) { + ImageEditorImpl(@NotNull Project project, @NotNull final ImageContentProvider contentProvider) { this.project = project; this.contentProvider = contentProvider; diff --git a/images/src/org/intellij/images/editor/impl/ImageFileEditorProvider.java b/images/src/org/intellij/images/editor/impl/ImageFileEditorProvider.java index 9c344f6f8a8a..88e89eef1957 100644 --- a/images/src/org/intellij/images/editor/impl/ImageFileEditorProvider.java +++ b/images/src/org/intellij/images/editor/impl/ImageFileEditorProvider.java @@ -30,7 +30,7 @@ import org.jetbrains.annotations.NotNull; * * @author Alexey Efimov */ -final class ImageFileEditorProvider implements FileEditorProvider, DumbAware { +public final class ImageFileEditorProvider implements FileEditorProvider, DumbAware { @NonNls private static final String EDITOR_TYPE_ID = "images"; private final ImageFileTypeManager typeManager; @@ -45,7 +45,11 @@ final class ImageFileEditorProvider implements FileEditorProvider, DumbAware { @NotNull public FileEditor createEditor(@NotNull Project project, @NotNull VirtualFile file) { - ImageContentProvider contentProvider = new VirtualFileImageContentProvider(file); + return createImageEditor(project, new VirtualFileImageContentProvider(file)); + } + + @NotNull + public static FileEditor createImageEditor(@NotNull Project project, @NotNull ImageContentProvider contentProvider) { ImageFileEditorImpl editor = new ImageFileEditorImpl(project, contentProvider); Disposer.register(editor, contentProvider); return editor; From a0eb7d47e6a145a31790533664e4f3f6b288e178 Mon Sep 17 00:00:00 2001 From: irengrig Date: Wed, 14 Dec 2011 17:55:03 +0400 Subject: [PATCH 30/41] IDEA-78712 Apply patch issues listen to patch file contents changes refresh patch contents button --- .../patch/ApplyPatchDifferentiatedDialog.java | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java index 3b26f78c933a..c557a030ab57 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java @@ -16,6 +16,7 @@ package com.intellij.openapi.vcs.changes.patch; import com.intellij.ide.util.PropertiesComponent; +import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.diff.impl.patch.PatchReader; import com.intellij.openapi.diff.impl.patch.PatchSyntaxException; @@ -32,6 +33,7 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.PopupStep; import com.intellij.openapi.ui.popup.util.BaseListPopupStep; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Getter; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.Pair; @@ -47,8 +49,7 @@ import com.intellij.openapi.vcs.changes.actions.DiffRequestPresentable; import com.intellij.openapi.vcs.changes.actions.ShowDiffAction; import com.intellij.openapi.vcs.changes.actions.ShowDiffUIContext; import com.intellij.openapi.vcs.changes.ui.*; -import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.*; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.SimpleColoredComponent; import com.intellij.ui.SimpleTextAttributes; @@ -94,6 +95,7 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper { private JLabel myPatchFileLabel; private PatchReader myReader; private CommitContext myCommitContext; + private final VirtualFileAdapter myListener; public ApplyPatchDifferentiatedDialog(final Project project, final ApplyPatchExecutor callback, final List executors, @NotNull final ApplyPatchMode applyPatchMode, @NotNull final VirtualFile patchFile) { @@ -163,6 +165,24 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper { } myPatchFileLabel.setVisible(applyPatchMode.isCanChangePatchFile()); myPatchFile.setVisible(applyPatchMode.isCanChangePatchFile()); + + myListener = new VirtualFileAdapter() { + @Override + public void contentsChanged(VirtualFileEvent event) { + if (myRecentPathFileChange.get() != null && myRecentPathFileChange.get().getVf() != null && + myRecentPathFileChange.get().getVf().equals(event.getFile())) { + myLoadQueue.queue(myUpdater); + } + } + }; + final VirtualFileManager fileManager = VirtualFileManager.getInstance(); + fileManager.addVirtualFileListener(myListener); + Disposer.register(getDisposable(), new Disposable() { + @Override + public void dispose() { + fileManager.removeVirtualFileListener(myListener); + } + }); } public static FileChooserDescriptor createSelectPatchDescriptor() { @@ -239,7 +259,9 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper { } final VirtualFile file = filePresentation.getVf(); - final PatchReader patchReader = loadPatches(file); + final PatchReader patchReader = loadPatches(filePresentation); + if (patchReader == null) return; + final List matchedPathes = patchReader == null ? Collections.emptyList() : new AutoMatchIterator(myProject).execute(patchReader.getPatches()); @@ -256,10 +278,13 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper { } @Nullable - private PatchReader loadPatches(final VirtualFile patchFile) { + private PatchReader loadPatches(final FilePresentation filePresentation) { + final VirtualFile patchFile = filePresentation.getVf(); + patchFile.refresh(false, false); if (! patchFile.isValid()) { return null; } + PatchReader reader; try { reader = PatchVirtualFileReader.create(patchFile); @@ -344,6 +369,12 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper { group.add(new StripDown()); group.add(new ResetStrip()); group.add(new ZeroStrip()); + group.add(new AnAction("Refresh", "Refresh", IconLoader.getIcon("/actions/sync.png")) { + @Override + public void actionPerformed(AnActionEvent e) { + myLoadQueue.queue(myUpdater); + } + }); final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("APPLY_PATCH", group, true); myCenterPanel.add(toolbar.getComponent(), gb); From e1bce3801fdbfa2979fffddc4e1aaad375029b10 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 14 Dec 2011 14:07:05 +0100 Subject: [PATCH 31/41] multi-selection in live template tree, delete honors it (IDEA-76867) --- .../template/impl/TemplateListPanel.java | 120 +++++++----------- .../src/messages/CodeInsightBundle.properties | 2 - 2 files changed, 47 insertions(+), 75 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java index 3ed55f13f278..e39d535f08ce 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java @@ -29,7 +29,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SchemesManager; import com.intellij.openapi.project.DumbAwareAction; -import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.InputValidator; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.Splitter; @@ -50,7 +49,10 @@ import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; -import javax.swing.tree.*; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.*; import java.util.*; @@ -197,7 +199,7 @@ public class TemplateListPanel extends JPanel implements Disposable { @Nullable public JComponent getPreferredFocusedComponent() { - if (getTemplate(getSelectedIndex()) != null) { + if (getTemplate(getSingleSelectedIndex()) != null) { return myCurrentTemplateEditor.getKeyField(); } return null; @@ -297,7 +299,7 @@ public class TemplateListPanel extends JPanel implements Disposable { myCurrentTemplateEditor = new LiveTemplateSettingsEditor(template, shortcut, options, context, new Runnable() { @Override public void run() { - DefaultMutableTreeNode node = getNode(getSelectedIndex()); + DefaultMutableTreeNode node = getNode(getSingleSelectedIndex()); if (node != null) { ((DefaultTreeModel)myTree.getModel()).nodeChanged(node); TemplateSettings.getInstance().setLastSelectedTemplate(template.getGroupName(), template.getKey()); @@ -322,7 +324,7 @@ public class TemplateListPanel extends JPanel implements Disposable { } private void exportCurrentGroup() { - int selected = getSelectedIndex(); + int selected = getSingleSelectedIndex(); if (selected < 0) return; ExportSchemeAction.doExport(getGroup(selected), getSchemesManager()); @@ -437,7 +439,7 @@ public class TemplateListPanel extends JPanel implements Disposable { private void addRow() { String defaultGroup = TemplateSettings.USER_GROUP_NAME; - final DefaultMutableTreeNode node = getNode(getSelectedIndex()); + final DefaultMutableTreeNode node = getNode(getSingleSelectedIndex()); if (node != null) { if (node.getUserObject() instanceof TemplateImpl) { defaultGroup = ((TemplateImpl) node.getUserObject()).getGroupName(); @@ -463,7 +465,7 @@ public class TemplateListPanel extends JPanel implements Disposable { } private void copyRow() { - int selected = getSelectedIndex(); + int selected = getSingleSelectedIndex(); if (selected < 0) return; TemplateImpl orTemplate = getTemplate(selected); @@ -477,38 +479,42 @@ public class TemplateListPanel extends JPanel implements Disposable { updateTemplateDetails(true); } - private int getSelectedIndex() { - TreePath selectionPath = myTree.getSelectionPath(); - if (selectionPath == null) { - return -1; - } - else { - return myTree.getRowForPath(selectionPath); - } - + private int getSingleSelectedIndex() { + int[] rows = myTree.getSelectionRows(); + return rows != null && rows.length == 1 ? rows[0] : -1; } - private void removeRow() { - int selected = getSelectedIndex(); - TemplateKey templateKey = getTemplateKey(selected); - if (templateKey != null) { - removeTemplateAt(selected); - } - else { - TemplateGroup group = getGroup(selected); - if (group != null) { - int result = Messages.showOkCancelDialog(this, CodeInsightBundle.message("template.delete.group.confirmation.text"), - CodeInsightBundle.message("template.delete.confirmation.title"), - Messages.getQuestionIcon()); - if (result != DialogWrapper.OK_EXIT_CODE) return; + private void removeRows() { + TreeNode toSelect = null; - myTemplateGroups.remove(group); + TreePath[] paths = myTree.getSelectionPaths(); + for (TreePath path : paths) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); + Object o = node.getUserObject(); + if (o instanceof TemplateGroup) { + myTemplateGroups.remove(o); + removeNodeFromParent(node); + } else if (o instanceof TemplateImpl) { + TemplateImpl template = (TemplateImpl)o; + TemplateGroup templateGroup = getTemplateGroup(template.getGroupName()); + if (templateGroup != null) { + templateGroup.removeElement(template); + DefaultMutableTreeNode parent = (DefaultMutableTreeNode)node.getParent(); - removeNodeFromParent((DefaultMutableTreeNode)myTree.getPathForRow(selected).getLastPathComponent()); + if (templateGroup.getElements().isEmpty()) { + myTemplateGroups.remove(templateGroup); + removeNodeFromParent(parent); + } else { + toSelect = parent.getChildAfter(node); + removeNodeFromParent(node); + } + } } - } + if (toSelect instanceof DefaultMutableTreeNode) { + setSelectedNode((DefaultMutableTreeNode)toSelect); + } } private JPanel createTable() { @@ -567,14 +573,10 @@ public class TemplateListPanel extends JPanel implements Disposable { myTree.setRootVisible(false); myTree.setShowsRootHandles(true); - DefaultTreeSelectionModel selModel = new DefaultTreeSelectionModel(); - myTree.setSelectionModel(selModel); - selModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); - myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener(){ public void valueChanged(final TreeSelectionEvent e) { TemplateSettings templateSettings = TemplateSettings.getInstance(); - TemplateImpl template = getTemplate(getSelectedIndex()); + TemplateImpl template = getTemplate(getSingleSelectedIndex()); if (template != null) { templateSettings.setLastSelectedTemplate(template.getGroupName(), template.getKey()); } else { @@ -617,7 +619,7 @@ public class TemplateListPanel extends JPanel implements Disposable { Point point = dnDActionInfo.getPoint(); if (myTree.getPathForLocation(point.x, point.y) == null) return null; - int selectedIndex = getSelectedIndex(); + int selectedIndex = getSingleSelectedIndex(); TemplateImpl template = getTemplate(selectedIndex); return template != null ? new DnDDragStartBean(Pair.create(template, getNode(selectedIndex))) : null; } @@ -672,7 +674,7 @@ public class TemplateListPanel extends JPanel implements Disposable { .setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton anActionButton) { - removeRow(); + removeRows(); } }) .disableDownAction() @@ -685,7 +687,7 @@ public class TemplateListPanel extends JPanel implements Disposable { @Override public void updateButton(AnActionEvent e) { - e.getPresentation().setEnabled(getTemplate(getSelectedIndex()) != null); + e.getPresentation().setEnabled(getTemplate(getSingleSelectedIndex()) != null); } }); if (getSchemesManager().isExportAvailable()) { @@ -697,7 +699,7 @@ public class TemplateListPanel extends JPanel implements Disposable { @Override public void updateButton(AnActionEvent e) { - TemplateGroup group = getGroup(getSelectedIndex()); + TemplateGroup group = getGroup(getSingleSelectedIndex()); e.getPresentation().setEnabled(group != null && !getSchemesManager().isShared(group)); } }); @@ -745,7 +747,7 @@ public class TemplateListPanel extends JPanel implements Disposable { @Override public void update(AnActionEvent e) { - final int selected = getSelectedIndex(); + final int selected = getSingleSelectedIndex(); final TemplateGroup templateGroup = getGroup(selected); boolean enabled = templateGroup != null; e.getPresentation().setEnabled(enabled); @@ -763,7 +765,7 @@ public class TemplateListPanel extends JPanel implements Disposable { final DefaultActionGroup move = new DefaultActionGroup("Move", true) { @Override public void update(AnActionEvent e) { - final int selected = getSelectedIndex(); + final int selected = getSingleSelectedIndex(); final TemplateImpl template = getTemplate(selected); boolean enabled = template != null; e.getPresentation().setEnabled(enabled); @@ -811,7 +813,7 @@ public class TemplateListPanel extends JPanel implements Disposable { } private void renameGroup() { - final int selected = getSelectedIndex(); + final int selected = getSingleSelectedIndex(); final TemplateGroup templateGroup = getGroup(selected); if (templateGroup == null) return; @@ -826,7 +828,7 @@ public class TemplateListPanel extends JPanel implements Disposable { } private void updateTemplateDetails(boolean focusKey) { - int selected = getSelectedIndex(); + int selected = getSingleSelectedIndex(); CardLayout layout = (CardLayout)myDetailsPanel.getLayout(); if (selected < 0 || getTemplate(selected) == null) { layout.show(myDetailsPanel, NO_SELECTION); @@ -903,34 +905,6 @@ public class TemplateListPanel extends JPanel implements Disposable { myTree.scrollRowToVisible(row); } - private void removeTemplateAt(int row) { - JTree tree = myTree; - TreePath path = tree.getPathForRow(row); - DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); - LOG.assertTrue(node.getUserObject() instanceof TemplateImpl); - - TemplateImpl template = (TemplateImpl)node.getUserObject(); - TemplateGroup templateGroup = getTemplateGroup(template.getGroupName()); - if (templateGroup != null) { - templateGroup.removeElement(template); - } - - DefaultMutableTreeNode parent = (DefaultMutableTreeNode)node.getParent(); - TreePath treePathToSelect = (parent.getChildAfter(node) != null || parent.getChildCount() == 1 ? - tree.getPathForRow(row + 1) : - tree.getPathForRow(row - 1)); - DefaultMutableTreeNode toSelect = treePathToSelect != null ? (DefaultMutableTreeNode)treePathToSelect.getLastPathComponent() : null; - - removeNodeFromParent(node); - if (parent.getChildCount() == 0) { - myTemplateGroups.remove((TemplateGroup)parent.getUserObject()); - removeNodeFromParent(parent); - } - if (toSelect != null) { - setSelectedNode(toSelect); - } - } - private void removeNodeFromParent(DefaultMutableTreeNode node) { TreeNode parent = node.getParent(); int idx = parent.getIndex(node); diff --git a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties index aa4dedba329e..649bcf59210d 100644 --- a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties +++ b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties @@ -281,8 +281,6 @@ templates.dialog.table.column.description=Description templates.dialog.table.column.active=Active templates.dialog.shortcut.chooser.label=By default expand with dialog.copy.live.template.title=Copy Live Template -template.delete.confirmation.title=Confirm Delete -template.delete.group.confirmation.text=Do you want to delete this template group? dialog.edit.template.shortcut.default=Default ({0}) dialog.edit.template.template.text.title=&Template text: dialog.edit.template.button.edit.variables=&Edit variables From 097447001e1edcdad27438de1fd1d10b0ca3d8e3 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 14 Dec 2011 14:56:13 +0100 Subject: [PATCH 32/41] cleanup and allow to move multiple templates (IDEA-76867) --- .../template/impl/TemplateListPanel.java | 141 +++++++++--------- 1 file changed, 69 insertions(+), 72 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java index e39d535f08ce..412d38f4c0c2 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java @@ -33,7 +33,6 @@ import com.intellij.openapi.ui.InputValidator; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.*; import com.intellij.util.Alarm; @@ -341,7 +340,6 @@ public class TemplateListPanel extends JPanel implements Disposable { gbConstraints.weighty = 0; gbConstraints.weightx = 0; gbConstraints.gridy = 0; -// panel.add(createLabel("By default expand with "), gbConstraints); panel.add(new JLabel(CodeInsightBundle.message("templates.dialog.shortcut.chooser.label")), gbConstraints); gbConstraints.gridx = 1; @@ -359,20 +357,6 @@ public class TemplateListPanel extends JPanel implements Disposable { return panel; } - @Nullable - private TemplateKey getTemplateKey(int row) { - JTree tree = myTree; - TreePath path = tree.getPathForRow(row); - if (path != null) { - DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); - if (node.getUserObject() instanceof TemplateImpl) { - return new TemplateKey((TemplateImpl)node.getUserObject()); - } - } - - return null; - } - @Nullable private TemplateImpl getTemplate(int row) { JTree tree = myTree; @@ -401,19 +385,31 @@ public class TemplateListPanel extends JPanel implements Disposable { return null; } - private void moveTemplate(TemplateImpl template, String newGroupName, DefaultMutableTreeNode oldTemplateNode) { - TemplateGroup oldGroup = getTemplateGroup(template.getGroupName()); - if (oldGroup != null) { - oldGroup.removeElement(template); + private void moveTemplates(Map map, String newGroupName) { + List toSelect = new ArrayList(); + for (TemplateImpl template : map.keySet()) { + DefaultMutableTreeNode oldTemplateNode = map.get(template); + + TemplateGroup oldGroup = getTemplateGroup(template.getGroupName()); + if (oldGroup != null) { + oldGroup.removeElement(template); + } + + template.setGroupName(newGroupName); + + DefaultMutableTreeNode parent = (DefaultMutableTreeNode)oldTemplateNode.getParent(); + removeNodeFromParent(oldTemplateNode); + if (parent.getChildCount() == 0) removeNodeFromParent(parent); + + toSelect.add(new TreePath(registerTemplate(template).getPath())); } - template.setGroupName(newGroupName); - - DefaultMutableTreeNode parent = (DefaultMutableTreeNode)oldTemplateNode.getParent(); - removeNodeFromParent(oldTemplateNode); - if (parent.getChildCount() == 0) removeNodeFromParent(parent); - - registerTemplate(template); + myTree.getSelectionModel().clearSelection(); + for (TreePath path : toSelect) { + myTree.expandPath(path.getParentPath()); + myTree.addSelectionPath(path); + myTree.scrollRowToVisible(myTree.getRowForPath(path)); + } } @Nullable @@ -488,10 +484,13 @@ public class TemplateListPanel extends JPanel implements Disposable { TreeNode toSelect = null; TreePath[] paths = myTree.getSelectionPaths(); + if (paths == null) return; + for (TreePath path : paths) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); Object o = node.getUserObject(); if (o instanceof TemplateGroup) { + //noinspection SuspiciousMethodCalls myTemplateGroups.remove(o); removeNodeFromParent(node); } else if (o instanceof TemplateImpl) { @@ -619,20 +618,18 @@ public class TemplateListPanel extends JPanel implements Disposable { Point point = dnDActionInfo.getPoint(); if (myTree.getPathForLocation(point.x, point.y) == null) return null; - int selectedIndex = getSingleSelectedIndex(); - TemplateImpl template = getTemplate(selectedIndex); - return template != null ? new DnDDragStartBean(Pair.create(template, getNode(selectedIndex))) : null; + Map templates = getSelectedTemplates(); + + return !templates.isEmpty() ? new DnDDragStartBean(templates) : null; } }). setDisposableParent(this) .setTargetChecker(new DnDTargetChecker() { @Override public boolean update(DnDEvent event) { - @SuppressWarnings("unchecked") Pair pair = (Pair)event.getAttachedObject(); - TemplateImpl template = pair.first; - String oldGroupName = template.getGroupName(); + @SuppressWarnings("unchecked") Set oldGroupNames = getAllGroups((Map)event.getAttachedObject()); TemplateGroup group = getDropGroup(event); - boolean differentGroup = group != null && !oldGroupName.equals(group.getName()); + boolean differentGroup = group != null && !oldGroupNames.contains(group.getName()); boolean possible = differentGroup && !getSchemesManager().isShared(group); event.setDropPossible(possible, differentGroup && !possible ? "Cannot modify a shared group" : ""); return true; @@ -641,8 +638,9 @@ public class TemplateListPanel extends JPanel implements Disposable { .setDropHandler(new DnDDropHandler() { @Override public void drop(DnDEvent event) { - @SuppressWarnings("unchecked") Pair pair = (Pair)event.getAttachedObject(); - moveTemplate(pair.first, ObjectUtils.assertNotNull(getDropGroup(event)).getName(), pair.second); + //noinspection unchecked + moveTemplates((Map)event.getAttachedObject(), + ObjectUtils.assertNotNull(getDropGroup(event)).getName()); } }) .setImageProvider(new NullableFunction() { @@ -765,24 +763,24 @@ public class TemplateListPanel extends JPanel implements Disposable { final DefaultActionGroup move = new DefaultActionGroup("Move", true) { @Override public void update(AnActionEvent e) { - final int selected = getSingleSelectedIndex(); - final TemplateImpl template = getTemplate(selected); - boolean enabled = template != null; + final Map templates = getSelectedTemplates(); + boolean enabled = !templates.isEmpty(); e.getPresentation().setEnabled(enabled); e.getPresentation().setVisible(enabled); if (enabled) { - final String oldGroupName = template.getGroupName(); + Set oldGroups = getAllGroups(templates); + removeAll(); SchemesManager schemesManager = TemplateSettings.getInstance().getSchemesManager(); for (TemplateGroup group : getTemplateGroups()) { final String newGroupName = group.getName(); - if (!Comparing.equal(newGroupName, oldGroupName) && !schemesManager.isShared(group)) { + if (!oldGroups.contains(newGroupName) && !schemesManager.isShared(group)) { add(new DumbAwareAction(newGroupName) { @Override public void actionPerformed(AnActionEvent e) { - moveTemplate(template, newGroupName, getNode(selected)); + moveTemplates(templates, newGroupName); } }); } @@ -791,9 +789,9 @@ public class TemplateListPanel extends JPanel implements Disposable { add(new DumbAwareAction("New group...") { @Override public void actionPerformed(AnActionEvent e) { - String newName = Messages.showInputDialog(myTree, "Enter the new group name:", "Move to a new group", null, "", new TemplateGroupInputValidator(null)); + String newName = Messages.showInputDialog(myTree, "Enter the new group name:", "Move to a New Group", null, "", new TemplateGroupInputValidator(null)); if (newName != null) { - moveTemplate(template, newName, getNode(selected)); + moveTemplates(templates, newName); } } }); @@ -812,6 +810,31 @@ public class TemplateListPanel extends JPanel implements Disposable { }); } + private static Set getAllGroups(Map templates) { + Set oldGroups = new HashSet(); + for (TemplateImpl template : templates.keySet()) { + oldGroups.add(template.getGroupName()); + } + return oldGroups; + } + + private Map getSelectedTemplates() { + TreePath[] paths = myTree.getSelectionPaths(); + if (paths == null) { + return Collections.emptyMap(); + } + Map templates = new LinkedHashMap(); + for (TreePath path : paths) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); + Object o = node.getUserObject(); + if (!(o instanceof TemplateImpl)) { + return Collections.emptyMap(); + } + templates.put((TemplateImpl)o, node); + } + return templates; + } + private void renameGroup() { final int selected = getSingleSelectedIndex(); final TemplateGroup templateGroup = getGroup(selected); @@ -849,7 +872,7 @@ public class TemplateListPanel extends JPanel implements Disposable { } } - private void registerTemplate(TemplateImpl template) { + private CheckedTreeNode registerTemplate(TemplateImpl template) { TemplateGroup newGroup = getTemplateGroup(template.getGroupName()); if (newGroup == null) { newGroup = new TemplateGroup(template.getGroupName()); @@ -871,6 +894,7 @@ public class TemplateListPanel extends JPanel implements Disposable { setSelectedNode(node); } } + return node; } private void insertNewGroup(final TemplateGroup newGroup) { @@ -966,33 +990,6 @@ public class TemplateListPanel extends JPanel implements Disposable { } } - private static class TemplateKey { - private final String myKey; - private final String myGroupName; - - public TemplateKey(TemplateImpl template) { - String key = template.getKey(); - if (key == null) { - key = ""; - } - myKey = key; - String groupName = template.getGroupName(); - if (groupName == null) { - groupName = ""; - } - myGroupName =groupName; - } - - public boolean equals(Object obj) { - if (!(obj instanceof TemplateKey)) { - return false; - } - TemplateKey templateKey = (TemplateKey)obj; - return myGroupName.equals(templateKey.myGroupName) && myKey.equals(templateKey.myKey); - } - - } - private class TemplateGroupInputValidator implements InputValidator { private final String myOldName; From 6263ac21f54f140dec1e01278720aef652a9e883 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 14 Dec 2011 14:17:30 +0100 Subject: [PATCH 33/41] javadoc generation: allow to include jdk javadoc (IDEA-78788 ) --- .../intellij/javadoc/JavaDocGeneration.form | 37 ++++++++++++------- .../intellij/javadoc/JavadocConfigurable.java | 4 ++ .../javadoc/JavadocConfiguration.java | 7 +++- .../javadoc/JavadocGenerationPanel.java | 1 + 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/java/java-impl/src/com/intellij/javadoc/JavaDocGeneration.form b/java/java-impl/src/com/intellij/javadoc/JavaDocGeneration.form index 6b25000e046e..3a2b94603d97 100644 --- a/java/java-impl/src/com/intellij/javadoc/JavaDocGeneration.form +++ b/java/java-impl/src/com/intellij/javadoc/JavaDocGeneration.form @@ -1,16 +1,16 @@
- - + + - + - + @@ -19,7 +19,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -172,7 +172,7 @@ - + @@ -181,7 +181,7 @@ - + @@ -189,7 +189,7 @@ - + @@ -198,7 +198,7 @@ - + @@ -208,7 +208,7 @@ - + @@ -221,12 +221,12 @@ - + - + @@ -235,12 +235,21 @@ - + + + + + + + + + + diff --git a/java/java-impl/src/com/intellij/javadoc/JavadocConfigurable.java b/java/java-impl/src/com/intellij/javadoc/JavadocConfigurable.java index 0ae7266d42a5..cafff6e5ccbf 100644 --- a/java/java-impl/src/com/intellij/javadoc/JavadocConfigurable.java +++ b/java/java-impl/src/com/intellij/javadoc/JavadocConfigurable.java @@ -50,6 +50,7 @@ public final class JavadocConfigurable implements Configurable { configuration.OPTION_DOCUMENT_TAG_VERSION = myPanel.myTagVersion.isSelected(); configuration.OPTION_DOCUMENT_TAG_DEPRECATED = myPanel.myTagDeprecated.isSelected(); configuration.OPTION_DEPRECATED_LIST = myPanel.myDeprecatedList.isSelected(); + configuration.OPTION_INCLUDE_LIBS = myPanel.myIncludeLibraryCb.isSelected(); } public void loadFrom(JavadocConfiguration configuration) { @@ -71,6 +72,8 @@ public final class JavadocConfigurable implements Configurable { myPanel.mySeparateIndex.setEnabled(myPanel.myIndex.isSelected()); myPanel.myDeprecatedList.setEnabled(myPanel.myTagDeprecated.isSelected()); + + myPanel.myIncludeLibraryCb.setSelected(configuration.OPTION_INCLUDE_LIBS); } public boolean isModified() { @@ -91,6 +94,7 @@ public final class JavadocConfigurable implements Configurable { isModified |= myPanel.myTagVersion.isSelected() != configuration.OPTION_DOCUMENT_TAG_VERSION; isModified |= myPanel.myTagDeprecated.isSelected() != configuration.OPTION_DOCUMENT_TAG_DEPRECATED; isModified |= myPanel.myDeprecatedList.isSelected() != configuration.OPTION_DEPRECATED_LIST; + isModified |= myPanel.myIncludeLibraryCb.isSelected() != configuration.OPTION_INCLUDE_LIBS; return isModified; } diff --git a/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java b/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java index 4913ac98998d..62f82057f7e1 100644 --- a/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java +++ b/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java @@ -83,6 +83,7 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl private final Project myProject; private AnalysisScope myGenerationScope; private static final Logger LOGGER = Logger.getInstance("#" + JavadocConfiguration.class.getName()); + public boolean OPTION_INCLUDE_LIBS = false; public void setGenerationScope(AnalysisScope generationScope) { myGenerationScope = generationScope; @@ -274,7 +275,11 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl writer.println(source); } writer.println("-sourcepath"); - final PathsList pathsList = OrderEnumerator.orderEntries(myProject).withoutSdk().withoutLibraries().getSourcePathsList(); + OrderEnumerator enumerator = OrderEnumerator.orderEntries(myProject); + if (!OPTION_INCLUDE_LIBS) { + enumerator = enumerator.withoutSdk().withoutLibraries(); + } + final PathsList pathsList = enumerator.getSourcePathsList(); final List files = pathsList.getRootDirs(); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); final StringBuilder sourcePath = new StringBuilder(); diff --git a/java/java-impl/src/com/intellij/javadoc/JavadocGenerationPanel.java b/java/java-impl/src/com/intellij/javadoc/JavadocGenerationPanel.java index d23682265916..5cc096016683 100644 --- a/java/java-impl/src/com/intellij/javadoc/JavadocGenerationPanel.java +++ b/java/java-impl/src/com/intellij/javadoc/JavadocGenerationPanel.java @@ -46,6 +46,7 @@ final class JavadocGenerationPanel extends JPanel { JCheckBox myDeprecatedList; JCheckBox myOpenInBrowserCheckBox; JTextField myLocaleTextField; + JCheckBox myIncludeLibraryCb; JavadocGenerationPanel() { myTfOutputDir.addBrowseFolderListener(JavadocBundle.message("javadoc.generate.output.directory.browse"), null, null, FileChooserDescriptorFactory.createSingleFolderDescriptor()); From bab58cef31d1f09c1673f2a5be7eba91881087fa Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Wed, 14 Dec 2011 18:19:09 +0400 Subject: [PATCH 34/41] [mac] switching off native clipboard by default, reverting back async handling due to errors --- .../intellij/ide/ClipboardSynchronizer.java | 88 +++---------------- .../src/misc/registry.properties | 2 +- 2 files changed, 11 insertions(+), 79 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/ClipboardSynchronizer.java b/platform/platform-impl/src/com/intellij/ide/ClipboardSynchronizer.java index 1e75289c3297..0e5046e5ab64 100644 --- a/platform/platform-impl/src/com/intellij/ide/ClipboardSynchronizer.java +++ b/platform/platform-impl/src/com/intellij/ide/ClipboardSynchronizer.java @@ -25,15 +25,12 @@ import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.registry.Registry; import com.intellij.ui.mac.foundation.Foundation; import com.intellij.ui.mac.foundation.ID; -import com.intellij.ui.mac.foundation.MacUtil; -import com.sun.jna.Callback; import com.sun.jna.IntegerType; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import sun.awt.datatransfer.DataTransferer; -import javax.swing.*; import java.awt.*; import java.awt.datatransfer.*; import java.io.IOException; @@ -182,35 +179,8 @@ public class ClipboardSynchronizer implements ApplicationComponent { } private static class MacClipboardHandler extends ClipboardHandler { - - private static final String CLIPBOARD_CONTENTS = "CLIPBOARD_CONTENTS"; - private static final String MAC_CLIPBOARD_SYNC_ACTIVE = "Mac.Clipboard.Sync.Active"; private Pair myFullTransferable; - private static Callback myClipboardQueryCallback = new Callback() { - public void callback(ID self, String selector, ID params) { - JRootPane pane = getRootPane(); - if (pane != null) { - Transferable transferable = getClipboardContentNatively(); - if (transferable != null) { - pane.putClientProperty(CLIPBOARD_CONTENTS, transferable); - } - - pane.putClientProperty(MAC_CLIPBOARD_SYNC_ACTIVE, null); - } - } - }; - - static { - if (SystemInfo.isMac) { - final ID delegateClass = Foundation.allocateObjcClassPair(Foundation.getClass("NSObject"), "ClipboardSynchronizer_"); - if (!Foundation.addMethod(delegateClass, Foundation.createSelector("run:"), myClipboardQueryCallback, "v*")) { - throw new RuntimeException("Unable to add method to objective-c delegate class!"); - } - Foundation.registerObjcClassPair(delegateClass); - } - } - @Nullable private Transferable doGetContents() throws IllegalStateException { if (Registry.is("ide.mac.useNativeClipboard")) { @@ -277,59 +247,21 @@ public class ClipboardSynchronizer implements ApplicationComponent { } } - @Nullable - private static JRootPane getRootPane() { - Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); - if (window == null) return null; - return SwingUtilities.getRootPane(window); - } - @Nullable public static Transferable getContentsSafe() { final Ref result = new Ref(); - final JRootPane pane = getRootPane(); - if (pane != null) { - try { - Runnable run = new Runnable() { - @Override - public void run() { - ID synchronizer_ = Foundation.getClass("ClipboardSynchronizer_"); - final ID synchronizer = Foundation.invoke(Foundation.invoke(synchronizer_, "alloc"), "init"); - Foundation - .invoke(synchronizer, "performSelectorOnMainThread:withObject:waitUntilDone:", Foundation.createSelector("run:"), null, - false); - - pane.putClientProperty(MAC_CLIPBOARD_SYNC_ACTIVE, Boolean.TRUE); - MacUtil.startModal(pane, MAC_CLIPBOARD_SYNC_ACTIVE); - - Foundation.cfRelease(synchronizer); - - Object contents = pane.getClientProperty(CLIPBOARD_CONTENTS); - pane.putClientProperty(CLIPBOARD_CONTENTS, null); - if (contents != null) { - result.set((Transferable)contents); - } - } - }; - - if (SwingUtilities.isEventDispatchThread()) { - run.run(); - } else { - SwingUtilities.invokeAndWait(run); - } - - Transferable transferable = result.get(); - if (transferable != null) return transferable; - } - catch (InterruptedException e) { - // do nothing - } - catch (InvocationTargetException e) { - // do nothing + + Foundation.executeOnMainThread(new Runnable() { + @Override + public void run() { + Transferable transferable = getClipboardContentNatively(); + if (transferable != null) { + result.set(transferable); } } - - return null; + }, true, true); + + return result.get(); } } diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index fd6bb8351f10..8e919fa85bad 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -153,7 +153,7 @@ dir.diff.default.trg.folder= show.live.templates.in.completion=false documentation.component.editor.font=false -ide.mac.useNativeClipboard=true +ide.mac.useNativeClipboard=false show.all.classes.on.first.completion=false limited.relevance.sorting.in.completion=false From c3b06906439c165e953e9d961dc751dede6ef8f5 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 14 Dec 2011 15:26:15 +0100 Subject: [PATCH 35/41] a test for velocity brace matching --- .../highlighting/BraceMatchingUtil.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java index c73071840be8..f1d074009100 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java @@ -19,6 +19,10 @@ package com.intellij.codeInsight.highlighting; import com.intellij.lang.Language; import com.intellij.lang.LanguageBraceMatching; import com.intellij.lang.PairedBraceMatcher; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.ex.EditorEx; +import com.intellij.openapi.editor.highlighter.EditorHighlighter; import com.intellij.openapi.editor.highlighter.HighlighterIterator; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileTypes.FileType; @@ -30,6 +34,7 @@ import com.intellij.psi.tree.IElementType; import com.intellij.util.containers.Stack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; import java.util.HashMap; import java.util.List; @@ -57,6 +62,17 @@ public class BraceMatchingUtil { BRACE_MATCHERS.put(fileType, braceMatcher); } + @TestOnly + public static int getMatchedBraceOffset(Editor editor, boolean forward, PsiFile file) { + Document document = editor.getDocument(); + int offset = editor.getCaretModel().getOffset(); + EditorHighlighter editorHighlighter = ((EditorEx)editor).getHighlighter(); + HighlighterIterator iterator = editorHighlighter.createIterator(offset); + boolean matched = matchBrace(document.getCharsSequence(), file.getFileType(), iterator, forward); + assert matched; + return iterator.getStart(); + } + private static class MatchBraceContext { CharSequence fileText; FileType fileType; From 55d0f3323e5007b33a86298ec74ea657a96d270a Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 14 Dec 2011 16:17:06 +0100 Subject: [PATCH 36/41] IDEA-78618 Sample text in the preview area of XML code style refers to ReSharper --- .../src/codeStyle/preview/preview.xml.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/platform-resources/src/codeStyle/preview/preview.xml.template b/platform/platform-resources/src/codeStyle/preview/preview.xml.template index 85b3d0efc4a5..6edd0817d215 100644 --- a/platform/platform-resources/src/codeStyle/preview/preview.xml.template +++ b/platform/platform-resources/src/codeStyle/preview/preview.xml.template @@ -7,9 +7,9 @@ - ReSharper makes C# development a real pleasure. It decreases the time you spend on routine, repetitive + Our product makes development a real pleasure. It decreases the time you spend on routine, repetitive handwork, giving you more time to focus on the task at hand. Its robust set of features for automatic error-checking - and code correction cuts development time and increases your efficiency. You'll find that ReSharper quickly + and code correction cuts development time and increases your efficiency. You'll find that our product quickly pays back it's cost in increased developer productivity and improved code quality. From 4b1fdda6c853008d53027af8895fa5dc5697c3d3 Mon Sep 17 00:00:00 2001 From: irengrig Date: Wed, 14 Dec 2011 19:42:21 +0400 Subject: [PATCH 37/41] IDEA-78710 How to stop "Reveal in Finder" dialog after creating a patch? --- .../src/com/intellij/openapi/ui/Messages.java | 2 +- .../ide/actions/ShowFilePathAction.java | 42 ++++++++++++++++++- .../openapi/vcs/VcsConfiguration.java | 1 + .../patch/CreatePatchCommitExecutor.java | 10 ++++- .../VcsGeneralConfigurationPanel.form | 32 ++++++++++++-- .../VcsGeneralConfigurationPanel.java | 29 ++++++++++++- 6 files changed, 107 insertions(+), 9 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index f683f2eab0f2..a6861357baf9 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -308,7 +308,7 @@ public class Messages { doNotAskOption); } - return showDialog(project, message, title, new String[]{okText, cancelText}, 0, icon); + return showDialog(project, message, title, new String[]{okText, cancelText}, 0, icon, doNotAskOption); } public static int showOkCancelDialog(Project project, String message, String title, String okText, String cancelText, Icon icon) { diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java index 2fc467d8b923..54e5abbb9aab 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ShowFilePathAction.java @@ -15,6 +15,7 @@ */ package com.intellij.ide.actions; +import com.intellij.CommonBundle; import com.intellij.execution.ExecutionException; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.util.ExecUtil; @@ -28,6 +29,7 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.impl.LaterInvocator; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.ListPopup; @@ -234,10 +236,46 @@ public class ShowFilePathAction extends AnAction { return PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext()); } - public static void showDialog(Project project, String message, String title, File file) { + public static Boolean showDialog(Project project, String message, String title, File file) { + final Boolean[] ref = new Boolean[1]; + final DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() { + @Override + public boolean isToBeShown() { + return true; + } + + @Override + public void setToBeShown(boolean value, int exitCode) { + if (!value) { + if (exitCode == 0) { + // yes + ref[0] = true; + } + else { + ref[0] = false; + } + } + } + + @Override + public boolean canBeHidden() { + return true; + } + + @Override + public boolean shouldSaveOptionsOnCancel() { + return true; + } + + @Override + public String getDoNotShowMessage() { + return CommonBundle.message("dialog.options.do.not.ask"); + } + }; if (Messages.showOkCancelDialog(project, message, title, RevealFileAction.getActionName(), - IdeBundle.message("action.close"), Messages.getInformationIcon()) == 0) { + IdeBundle.message("action.close"), Messages.getInformationIcon(), option) == 0) { open(file, file); } + return ref[0]; } } diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java index 29bab41567f2..0030810d4fb5 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java @@ -88,6 +88,7 @@ public final class VcsConfiguration implements PersistentStateComponent public boolean INCLUDE_TEXT_INTO_PATCH = false; public boolean INCLUDE_TEXT_INTO_SHELF = false; public boolean CREATE_PATCH_EXPAND_DETAILS_DEFAULT = true; + public Boolean SHOW_PATCH_IN_EXPLORER = null; public enum StandardOption { ADD(VcsBundle.message("vcs.command.name.add")), diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java index ded368b51aae..09a8d9e8a9e4 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java @@ -207,7 +207,15 @@ public class CreatePatchCommitExecutor implements CommitExecutorWithHelp, Projec } WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() { public void run() { - ShowFilePathAction.showDialog(myProject, message, VcsBundle.message("create.patch.commit.action.title"), file); + final VcsConfiguration configuration = VcsConfiguration.getInstance(myProject); + if (Boolean.TRUE.equals(configuration.SHOW_PATCH_IN_EXPLORER)) { + ShowFilePathAction.open(file, file); + } else if (Boolean.FALSE.equals(configuration.SHOW_PATCH_IN_EXPLORER)) { + return; + } else { + configuration.SHOW_PATCH_IN_EXPLORER = + ShowFilePathAction.showDialog(myProject, message, VcsBundle.message("create.patch.commit.action.title"), file); + } } }, null, myProject); } catch (ProcessCanceledException e) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.form b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.form index f771e3418650..207841e3db13 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.form +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.form @@ -152,7 +152,7 @@ - + @@ -184,9 +184,9 @@ - + - + @@ -210,6 +210,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java index e17529dc7d63..a8007ab2fec8 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java @@ -19,6 +19,7 @@ import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.*; import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx; @@ -60,6 +61,7 @@ public class VcsGeneralConfigurationPanel implements SearchableConfigurable { private JPanel myAddConfirmationPanel; private JCheckBox myCbOfferToMoveChanges; private JComboBox myFailedCommitChangelistCombo; + private JComboBox myOnPatchCreation; private ButtonGroup myEmptyChangelistRemovingGroup; public VcsGeneralConfigurationPanel(final Project project) { @@ -91,7 +93,7 @@ public class VcsGeneralConfigurationPanel implements SearchableConfigurable { } myPromptsPanel.setSize(myPromptsPanel.getPreferredSize()); - + myOnPatchCreation.setName((SystemInfo.isMac ? "Reveal patch in" : "Show patch in ") + SystemInfo.nativeFileManagerName + " after creation:"); } public void apply() throws ConfigurationException { @@ -109,11 +111,26 @@ public class VcsGeneralConfigurationPanel implements SearchableConfigurable { getAddConfirmation().setValue(getSelected(myOnFileAddingGroup)); getRemoveConfirmation().setValue(getSelected(myOnFileRemovingGroup)); - + applyPatchOption(settings); getReadOnlyStatusHandler().getState().SHOW_DIALOG = myShowReadOnlyStatusDialog.isSelected(); } + private void applyPatchOption(VcsConfiguration settings) { + settings.SHOW_PATCH_IN_EXPLORER = getShowPatchValue(); + } + + private Boolean getShowPatchValue() { + final int index = myOnPatchCreation.getSelectedIndex(); + if (index == 0) { + return null; + } else if (index == 1) { + return true; + } else { + return false; + } + } + private VcsShowConfirmationOption.Value getFailedCommitConfirm() { switch(myFailedCommitChangelistCombo.getSelectedIndex()) { case 0: return VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY; @@ -180,6 +197,7 @@ public class VcsGeneralConfigurationPanel implements SearchableConfigurable { if (getSelected(myOnFileAddingGroup) != getAddConfirmation().getValue()) return true; if (getSelected(myOnFileRemovingGroup) != getRemoveConfirmation().getValue()) return true; + if (! Comparing.equal(settings.SHOW_PATCH_IN_EXPLORER, getShowPatchValue())) return true; return false; } @@ -207,6 +225,13 @@ public class VcsGeneralConfigurationPanel implements SearchableConfigurable { selectInGroup(myOnFileAddingGroup, getAddConfirmation()); selectInGroup(myOnFileRemovingGroup, getRemoveConfirmation()); + if (settings.SHOW_PATCH_IN_EXPLORER == null) { + myOnPatchCreation.setSelectedIndex(0); + } else if (Boolean.TRUE.equals(settings.SHOW_PATCH_IN_EXPLORER)) { + myOnPatchCreation.setSelectedIndex(1); + } else { + myOnPatchCreation.setSelectedIndex(2); + } } private static void selectInGroup(final JRadioButton[] group, final VcsShowConfirmationOption confirmation) { From 0179d0c29b495df4a7873420e2cd2218d479fd42 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 14 Dec 2011 16:43:57 +0100 Subject: [PATCH 38/41] search for actions: prepend group name if any --- .../ide/util/gotoByName/GotoActionModel.java | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java index b773ec6cfcba..1d3408afcbd8 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java @@ -37,7 +37,10 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { private final Project myProject; @@ -51,11 +54,15 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { private Pattern myCompiledPattern; private final PatternMatcher myMatcher = new Perl5Matcher(); + + private Map myActionsMap = new HashMap(); public GotoActionModel(Project project, final Component component) { myProject = project; myContextComponent = component; + final ActionGroup mainMenu = (ActionGroup)myActionManager.getActionOrStub(IdeActions.GROUP_MAIN_MENU); + collectActions(myActionsMap, mainMenu, mainMenu.getTemplatePresentation().getText()); } public String getPromptText() { @@ -175,7 +182,10 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { public String[] getNames(boolean checkBoxState) { final ArrayList result = new ArrayList(); - collectActionIds(result, (ActionGroup)myActionManager.getActionOrStub(IdeActions.GROUP_MAIN_MENU)); + for (AnAction action : myActionsMap.keySet()) { + if (action instanceof ActionGroup) continue; + result.add(getActionId(action)); + } if (checkBoxState) { final Set ids = ((ActionManagerImpl)myActionManager).getActionIds(); for (String id : ids) { @@ -188,22 +198,10 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { return ArrayUtil.toStringArray(result); } - private void collectActionIds(Collection result, ActionGroup group){ - final AnAction[] actions = group.getChildren(null); - for (AnAction action : actions) { - if (action instanceof ActionGroup) { - collectActionIds(result, (ActionGroup)action); - } - else if (action != null) { - result.add(getActionId(action)); - } - } - } - public Object[] getElementsByName(final String id, final boolean checkBoxState, final String pattern) { final HashMap map = new HashMap(); - final ActionGroup mainMenu = (ActionGroup)myActionManager.getActionOrStub(IdeActions.GROUP_MAIN_MENU); - collectActions(id, map, mainMenu, mainMenu.getTemplatePresentation().getText()); + final AnAction act = myActionManager.getAction(id); + map.put(act, myActionsMap.get(act)); if (checkBoxState) { final Set ids = ((ActionManagerImpl)myActionManager).getActionIds(); for (AnAction action : map.keySet()) { //do not add already included actions @@ -219,15 +217,15 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { return map.entrySet().toArray(new Map.Entry[map.size()]); } - private void collectActions(String id, Map result, ActionGroup group, final String containingGroupName){ + private static void collectActions(Map result, ActionGroup group, final String containingGroupName){ final AnAction[] actions = group.getChildren(null); for (AnAction action : actions) { if (action != null) { if (action instanceof ActionGroup) { final ActionGroup actionGroup = (ActionGroup)action; final String groupName = actionGroup.getTemplatePresentation().getText(); - collectActions(id, result, actionGroup, groupName != null ? groupName : containingGroupName); - } else if (getActionId(action) == id) { + collectActions(result, actionGroup, groupName != null ? groupName : containingGroupName); + } else { final String groupName = group.getTemplatePresentation().getText(); result.put(action, groupName != null && groupName.length() > 0 ? groupName : containingGroupName); } @@ -265,6 +263,10 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { (description != null && myMatcher.matches(description, compiledPattern))) { return true; } + final String groupName = myActionsMap.get(anAction); + if (groupName != null && text != null && myMatcher.matches(groupName + " " + text, compiledPattern)) { + return true; + } } return false; } From 735d3574aa662dbbe11da6ad4f75407bfcf4b14c Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 14 Dec 2011 16:44:40 +0100 Subject: [PATCH 39/41] introduce -> extract --- .../src/messages/ActionsBundle.properties | 26 +++++++++---------- .../src/main/resources/META-INF/plugin.xml | 4 +-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index 0622dc768fba..6a54304b2fc4 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -514,7 +514,7 @@ action.CloneElement.text=Clo_ne... action.CloneElement.description=Create a copy of the selected class, file or directory in the same package/directory action.SafeDelete.text=Safe _Delete... action.SafeDelete.description=Delete the selected class, method or field, checking for usages -action.ExtractMethod.text=E_xtract Method... +action.ExtractMethod.text=_Method... action.ExtractMethod.description=Turn the selected code fragment into a method action.RemoveMiddleman.text=Remove _Middleman... action.RemoveMiddleman.description=Get the client to call the delegate directly @@ -522,25 +522,25 @@ action.MethodDuplicates.text=Replace Met_hod Code Duplicates... action.MethodDuplicates.description=Finds code in current file that can be transformed into a call of selected method action.InvertBoolean.text=Invert _Boolean... action.InvertBoolean.description=Makes the method return or variable contain the opposite value and corrects the references -action.IntroduceParameterObject.text=Introduce Parameter Ob_ject... +action.IntroduceParameterObject.text=Parameter Ob_ject... action.IntroduceParameterObject.description=Replaces method parameters list with object -action.ExtractClass.text=Extract Cla_ss... +action.ExtractClass.text=Cla_ss... action.ExtractClass.description=Extract Delegate -action.IntroduceVariable.text=Introduce _Variable... +action.IntroduceVariable.text=_Variable... action.IntroduceVariable.description=Put a result of the selected expression into a variable -action.IntroduceField.text=Introduce _Field... +action.IntroduceField.text=_Field... action.IntroduceField.description=Put a result of the selected expression into a field -action.IntroduceConstant.text=Introduce _Constant... +action.IntroduceConstant.text=_Constant... action.IntroduceConstant.description=Replace selected expression with a constant (static final field) -action.IntroduceParameter.text=Introduce _Parameter... +action.IntroduceParameter.text=_Parameter... action.IntroduceParameter.description=Turn the selected expression into method parameter -action.ExtractInterface.text=Extract _Interface... +action.ExtractInterface.text=_Interface... action.ExtractInterface.description=Extract interface from the selected class -action.ExtractModule.text=Extract _Module... +action.ExtractModule.text=_Module... action.ExtractModule.description=Extract module from the selected class -action.ExtractSuperclass.text=Extract S_uperclass... +action.ExtractSuperclass.text=S_uperclass... action.ExtractSuperclass.description=Extract superclass from the selected class -group.IntroduceActionsGroup.text=Introd_uce +group.IntroduceActionsGroup.text=E_xtract action.TurnRefsToSuper.text=Use Interface _Where Possible... action.TurnRefsToSuper.description=Change usages of a class to those of its superclass or interface action.MembersPullUp.text=Pu_ll Members Up... @@ -559,7 +559,7 @@ action.ReplaceTempWithQuery.text=Replace Temp with _Query... action.ReplaceTempWithQuery.description=Turn the selected variable into a method action.ReplaceConstructorWithFactory.text=Replace Constructor with F_actory Method... action.ReplaceConstructorWithFactory.description=Create a static factory method and use it instead of a constructor -action.ReplaceMethodWithMethodObject.text=Extract Method Ob_ject... +action.ReplaceMethodWithMethodObject.text=Method Ob_ject... action.ReplaceMethodWithMethodObject.description=Turn the method into its own object so that all the parameters become fields on that object action.Generify.text=Ge_nerify... action.Generify.description=Convert your code to use generic types @@ -567,7 +567,7 @@ action.Migrate.text=_Migrate... action.Migrate.description=Open migration dialog action.Type\ Migration.text=Type Migration... action.Type\ Migration.description=Migrate one type to another -action.ExtractInclude.text=E_xtract Include File... +action.ExtractInclude.text=_Include File... action.ExtractInclude.description=Turn the selected code fragment into included file group.BuildMenu.text=_Build action.CompileProject.text=_Rebuild Project diff --git a/plugins/maven/src/main/resources/META-INF/plugin.xml b/plugins/maven/src/main/resources/META-INF/plugin.xml index 832515ed6d5e..865c37124ff6 100644 --- a/plugins/maven/src/main/resources/META-INF/plugin.xml +++ b/plugins/maven/src/main/resources/META-INF/plugin.xml @@ -388,9 +388,9 @@ - + - From 91f49975caadcfbacbbf1bfb30daee5a10c2fa8a Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 14 Dec 2011 16:50:14 +0100 Subject: [PATCH 40/41] cleanup --- .../com/intellij/ide/util/gotoByName/GotoActionModel.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java index 1d3408afcbd8..2774d3f5ae1d 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java @@ -120,7 +120,7 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { final DataContext dataContext = DataManager.getInstance().getDataContext(myContextComponent); - final AnActionEvent event = updateActionBeforShow(anAction, dataContext); + final AnActionEvent event = updateActionBeforeShow(anAction, dataContext); final Presentation presentation = event.getPresentation(); final Color fg = defaultActionForeground(isSelected, presentation); @@ -164,7 +164,7 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { return actionLabel; } - protected AnActionEvent updateActionBeforShow(AnAction anAction, DataContext dataContext) { + protected static AnActionEvent updateActionBeforeShow(AnAction anAction, DataContext dataContext) { final AnActionEvent event = new AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN, new Presentation(), ActionManager.getInstance(), 0); @@ -173,7 +173,7 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { return event; } - protected Color defaultActionForeground(boolean isSelected, Presentation presentation) { + protected static Color defaultActionForeground(boolean isSelected, Presentation presentation) { return isSelected ? UIUtil.getListSelectionForeground() : presentation.isEnabled() && presentation.isVisible() ? UIUtil.getListForeground() @@ -294,7 +294,7 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel { pattern = pattern.substring(0, 80); } - final @NonNls StringBuffer buffer = new StringBuffer(".*"); + final @NonNls StringBuilder buffer = new StringBuilder(".*"); pattern = pattern.toLowerCase(); for (int i = 0; i < pattern.length(); i++) { final char c = pattern.charAt(i); From a012a230e3a9016d767409a23096f9e400ddad9c Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 14 Dec 2011 17:13:43 +0100 Subject: [PATCH 41/41] correct rename range for inplace rename --- .../src/com/intellij/spellchecker/quickfixes/RenameTo.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/quickfixes/RenameTo.java b/plugins/spellchecker/src/com/intellij/spellchecker/quickfixes/RenameTo.java index e888ad5d421b..b700a27957b6 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/quickfixes/RenameTo.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/quickfixes/RenameTo.java @@ -25,6 +25,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileEditor.impl.text.TextEditorPsiDataProvider; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; @@ -106,6 +107,10 @@ public class RenameTo extends ShowSuggestions implements SpellCheckerQuickFix { DataContext dataContext = SimpleDataContext.getSimpleContext(map, DataManager.getInstance().getDataContext(editor.getComponent())); AnAction action = new RenameElementAction(); + final TextRange range = psiElement.getTextRange(); + if (range != null) { + editor.getSelectionModel().setSelection(range.getStartOffset(), range.getEndOffset()); + } AnActionEvent event = new AnActionEvent(null, dataContext, "", action.getTemplatePresentation(), ActionManager.getInstance(), 0); action.actionPerformed(event); if (provider != null) {