From 48775309034ee79af815f1e8b94edb5971d051c3 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 16 Mar 2012 13:00:45 +0100 Subject: [PATCH 01/50] "check now" button uses update channel currently selected in the dialog --- .../updateSettings/impl/CheckForUpdateAction.java | 11 +++++++---- .../impl/UpdateSettingsConfigurable.java | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/CheckForUpdateAction.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/CheckForUpdateAction.java index f9cd94fea2d6..719dd5276cd4 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/CheckForUpdateAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/CheckForUpdateAction.java @@ -40,14 +40,17 @@ public class CheckForUpdateAction extends AnAction implements DumbAware { public void actionPerformed(AnActionEvent e) { Project project = e.getData(PlatformDataKeys.PROJECT); - actionPerformed(project, true, null); + actionPerformed(project, true, null, UpdateSettings.getInstance()); } - public static void actionPerformed(Project project, final boolean enableLink, final @Nullable PluginHostsConfigurable hostsConfigurable) { + public static void actionPerformed(Project project, + final boolean enableLink, + final @Nullable PluginHostsConfigurable hostsConfigurable, + final UpdateSettings instance) { ProgressManager.getInstance().run(new Task.Modal(project, "Checking for updates", false) { @Override public void run(@NotNull ProgressIndicator indicator) { - final CheckForUpdateResult result = UpdateChecker.checkForUpdates(UpdateSettings.getInstance(), PropertiesComponent.getInstance(), + final CheckForUpdateResult result = UpdateChecker.checkForUpdates(instance, PropertiesComponent.getInstance(), true ); @@ -60,7 +63,7 @@ public class CheckForUpdateAction extends AnAction implements DumbAware { return; } - UpdateSettings.getInstance().LAST_TIME_CHECKED = System.currentTimeMillis(); + instance.LAST_TIME_CHECKED = System.currentTimeMillis(); UpdateChecker.showUpdateResult(result, updatedPlugins, true, enableLink, true); } }); diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.java index 34c8f76d896f..4b78b9a77f3a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.java @@ -20,7 +20,6 @@ import com.intellij.ide.IdeBundle; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.ApplicationInfo; import com.intellij.openapi.options.BaseConfigurable; -import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.project.Project; @@ -118,7 +117,10 @@ public class UpdateSettingsConfigurable extends BaseConfigurable implements Sear myBtnCheckNow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myBtnCheckNow)); - CheckForUpdateAction.actionPerformed(project, false, null); //todo load configured hosts on the fly + UpdateSettings settings = new UpdateSettings(); + settings.loadState(UpdateSettings.getInstance().getState()); + settings.UPDATE_CHANNEL_TYPE = getSelectedChannelType().getCode(); + CheckForUpdateAction.actionPerformed(project, false, null, settings); //todo load configured hosts on the fly updateLastCheckedLabel(); } }); From 3f2ef785148baec23f06843d7846af11adb7e241 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 16 Mar 2012 13:55:01 +0100 Subject: [PATCH 02/50] avoid exception on reloading notifications configuration state (EA-34725 - assert: NotificationsConfigurationImpl.loadState) --- .../notification/impl/NotificationsConfigurationImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsConfigurationImpl.java b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsConfigurationImpl.java index f620dba5529c..5b7ca893a0eb 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsConfigurationImpl.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsConfigurationImpl.java @@ -172,6 +172,7 @@ public class NotificationsConfigurationImpl extends NotificationsConfiguration i } public synchronized void loadState(final Element state) { + myIdToSettingsMap.clear(); for (@NonNls Element child : (Iterable)state.getChildren("notification")) { final NotificationSettings settings = NotificationSettings.load(child); if (settings != null) { From e8ae211c3f03e8a32897aba72357c195993ecd09 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 16 Mar 2012 14:04:33 +0100 Subject: [PATCH 03/50] EA-34487 - NPE: TabLayout.isDragOut --- .../src/com/intellij/ui/tabs/impl/DragHelper.java | 1 + .../platform-api/src/com/intellij/ui/tabs/impl/TabLayout.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/DragHelper.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/DragHelper.java index 0875bffe57e5..6e1186198afb 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/DragHelper.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/DragHelper.java @@ -50,6 +50,7 @@ class DragHelper extends MouseDragHelper { if (myDragSource == null || !myDragSource.canBeDraggedOut()) return false; TabLabel label = myTabs.myInfo2Label.get(myDragSource); + if (label == null) return false; int dX = dragToScreenPoint.x - startScreenPoint.x; int dY = dragToScreenPoint.y - startScreenPoint.y; diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLayout.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLayout.java index 8a452c998e70..5ced062c8543 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLayout.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLayout.java @@ -16,7 +16,7 @@ package com.intellij.ui.tabs.impl; import com.intellij.openapi.util.registry.Registry; -import com.intellij.ui.awt.RelativePoint; +import org.jetbrains.annotations.NotNull; import java.awt.*; @@ -31,7 +31,7 @@ public abstract class TabLayout { return new ShapeTransform.Top(rectangle); } - public boolean isDragOut(TabLabel tabLabel, int deltaX, int deltaY) { + public boolean isDragOut(@NotNull TabLabel tabLabel, int deltaX, int deltaY) { return Math.abs(deltaY) > tabLabel.getSize().height * getDragOutMultiplier(); } From aea355560613ea545bf6d5e40860d3218001d82f Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 16 Mar 2012 15:26:31 +0100 Subject: [PATCH 04/50] try harder to return @NotNull from EditorColorsManager.getGlobalScheme() (EA-34272 - IAE: PythonFileType$.getEditorHighlighter) --- .../openapi/editor/colors/EditorColorsManager.java | 1 + .../editor/colors/impl/EditorColorsManagerImpl.java | 12 ++++++++++-- .../highlighter/EditorHighlighterFactoryImpl.java | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsManager.java b/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsManager.java index 4a5c1f51d692..037df73d11ff 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsManager.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsManager.java @@ -18,6 +18,7 @@ package com.intellij.openapi.editor.colors; import com.intellij.openapi.Disposable; import com.intellij.openapi.components.ServiceManager; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; public abstract class EditorColorsManager { @NonNls public static final String DEFAULT_SCHEME_NAME = "Default"; diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java index fc9c085ad7c9..4a27a07a35a5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java @@ -285,13 +285,21 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name @Override public void setGlobalScheme(EditorColorsScheme scheme) { - mySchemesManager.setCurrentSchemeName(scheme == null ? DefaultColorSchemesManager.getInstance().getAllSchemes()[0].getName() : scheme.getName()); + mySchemesManager.setCurrentSchemeName(scheme == null ? getDefaultScheme().getName() : scheme.getName()); fireChanges(scheme); } + private static DefaultColorsScheme getDefaultScheme() { + return DefaultColorSchemesManager.getInstance().getAllSchemes()[0]; + } + @Override public EditorColorsScheme getGlobalScheme() { - return mySchemesManager.getCurrentScheme(); + final EditorColorsScheme scheme = mySchemesManager.getCurrentScheme(); + if (scheme == null) { + return getDefaultScheme(); + } + return scheme; } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/highlighter/EditorHighlighterFactoryImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/highlighter/EditorHighlighterFactoryImpl.java index 58c19f686397..e53742e1e2f4 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/highlighter/EditorHighlighterFactoryImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/highlighter/EditorHighlighterFactoryImpl.java @@ -54,7 +54,7 @@ public class EditorHighlighterFactoryImpl extends EditorHighlighterFactory { } @Override - public EditorHighlighter createEditorHighlighter(@NotNull final VirtualFile vFile, final EditorColorsScheme settings, final Project project) { + public EditorHighlighter createEditorHighlighter(@NotNull final VirtualFile vFile, @NotNull final EditorColorsScheme settings, final Project project) { final FileType fileType = vFile.getFileType(); if (fileType instanceof LanguageFileType) { LanguageFileType substFileType = substituteFileType(((LanguageFileType)fileType).getLanguage(), vFile, project); From bcf4fd2f658777fe5370b442d25973ca3a67da09 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Sat, 17 Mar 2012 17:40:17 +0100 Subject: [PATCH 05/50] fix "Suspicious test for oddness" inspection description --- .../src/inspectionDescriptions/BadOddness.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BadOddness.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BadOddness.html index ae1eb20bdc84..6e0616a2ac02 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/BadOddness.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BadOddness.html @@ -3,7 +3,7 @@ This inspection reports any checks for oddness of the form:
x % 2 == 1
Such checks will fail for negative odd values, which is probably not the behaviour intended. Consider using: -
x % 2 != 0
or:
x & 1 == 1
instead. +
x % 2 != 0
or:
(x & 1) == 1
instead.

Powered by InspectionGadgets From 00d1d56b049c0e39a38b96b4454a1fddffe3cf3f Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Sat, 17 Mar 2012 17:41:35 +0100 Subject: [PATCH 06/50] DEA-82643 ("Abstract method overrides abstract method" should allow for exceptions based on annotations) --- .../siyeh/InspectionGadgetsBundle.properties | 3 +- ...thodOverridesAbstractMethodInspection.java | 64 +++++++++++++++++-- ...AbstractMethodOverridesAbstractMethod.html | 6 +- ...thodOverridesAbstractMethodInspection.java | 11 ---- ...AbstractMethodOverridesAbstractMethod.java | 31 +++++++++ .../expected.xml | 11 ++++ ...OverridesAbstractMethodInspectionTest.java | 13 ++++ 7 files changed, 119 insertions(+), 20 deletions(-) delete mode 100644 plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/AbstractMethodOverridesAbstractMethodInspection.java create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method/AbstractMethodOverridesAbstractMethod.java create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method/expected.xml create mode 100644 plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspectionTest.java diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties index 62555bcfe923..a1a6f8eab86d 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties @@ -917,7 +917,8 @@ utility.class.without.private.constructor.problem.descriptor=Class #ref#ref() overrides concrete method #loc abstract.method.with.missing.implementations.problem.descriptor=Abstract method #ref() is not implemented in every subclass #loc abstract.method.overrides.abstract.method.problem.descriptor=Abstract method #ref() overrides abstract method #loc -abstract.method.overrides.abstract.method.ignore.different.javadoc.option=Ignore methods with a different JavaDoc than their super methods +abstract.method.overrides.abstract.method.ignore.different.javadoc.option=Ignore methods with different JavaDoc than their super methods +abstract.method.overrides.abstract.method.ignore.different.annotations.option=Ignore methods with different annotations than their super methods abstract.class.extends.concrete.class.problem.descriptor=Class #ref is declared 'abstract', and extends a concrete class #loc static.non.final.field.problem.descriptor='static' non-'final' field #ref #loc constant.declared.in.abstract.class.problem.descriptor=Constant #ref declared in abstract class #loc diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspection.java index cd1de1310380..9ef603908f9c 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package com.siyeh.ig.inheritance; import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel; +import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel; import com.intellij.openapi.project.Project; import com.intellij.psi.*; import com.intellij.psi.javadoc.PsiDocComment; @@ -34,8 +34,12 @@ import java.util.Set; public class AbstractMethodOverridesAbstractMethodInspection extends BaseInspection { + @SuppressWarnings("PublicField") public boolean ignoreJavaDoc = false; + @SuppressWarnings("PublicField") + public boolean ignoreAnnotations = false; + @Override @NotNull public String getDisplayName() { @@ -55,8 +59,12 @@ public class AbstractMethodOverridesAbstractMethodInspection extends BaseInspect @Override public JComponent createOptionsPanel() { - return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message( - "abstract.method.overrides.abstract.method.ignore.different.javadoc.option"), this, "ignoreJavaDoc"); + final MultipleCheckboxOptionsPanel panel = new MultipleCheckboxOptionsPanel(this); + panel.addCheckbox(InspectionGadgetsBundle.message( + "abstract.method.overrides.abstract.method.ignore.different.javadoc.option"), "ignoreJavaDoc"); + panel.addCheckbox(InspectionGadgetsBundle.message( + "abstract.method.overrides.abstract.method.ignore.different.annotations.option"), "ignoreAnnotations"); + return panel; } private static class AbstractMethodOverridesAbstractMethodFix extends InspectionGadgetsFix { @@ -83,7 +91,6 @@ public class AbstractMethodOverridesAbstractMethodInspection extends BaseInspect private class AbstractMethodOverridesAbstractMethodVisitor extends BaseInspectionVisitor { - @Override public void visitMethod(@NotNull PsiMethod method) { //no call to super, so we don't drill into anonymous classes @@ -105,18 +112,61 @@ public class AbstractMethodOverridesAbstractMethodInspection extends BaseInspect if (!isAbstract(superMethod)) { continue; } - if (!methodsHaveSameReturnTypes(method, superMethod) || - !haveSameExceptionSignatures(method, superMethod)) { + if (!methodsHaveSameReturnTypes(method, superMethod) || !haveSameExceptionSignatures(method, superMethod)) { continue; } if (ignoreJavaDoc && !haveSameJavaDoc(method, superMethod)) { return; } + if (ignoreAnnotations && !methodsHaveSameAnnotations(method, superMethod)) { + return; + } registerMethodError(method); return; } } + private boolean methodsHaveSameAnnotations(PsiMethod method, PsiMethod superMethod) { + if (!haveSameAnnotations(method, superMethod)) { + return false; + } + final PsiParameterList superParameterList = superMethod.getParameterList(); + final PsiParameter[] superParameters = superParameterList.getParameters(); + final PsiParameterList parameterList = method.getParameterList(); + final PsiParameter[] parameters = parameterList.getParameters(); + for (int i = 0, length = superParameters.length; i < length; i++) { + final PsiParameter superParameter = superParameters[i]; + final PsiParameter parameter = parameters[i]; + if (!haveSameAnnotations(parameter, superParameter)) { + return false; + } + } + return true; + } + + private boolean haveSameAnnotations(PsiModifierListOwner owner1, PsiModifierListOwner owner2) { + final PsiModifierList modifierList = owner1.getModifierList(); + final PsiModifierList superModifierList = owner2.getModifierList(); + if (superModifierList == null) { + return modifierList == null; + } else if (modifierList == null) { + return false; + } + final PsiAnnotation[] superAnnotations = superModifierList.getAnnotations(); + final PsiAnnotation[] annotations = modifierList.getAnnotations(); + final Set annotationsSet = new HashSet(Arrays.asList(superAnnotations)); + for (PsiAnnotation annotation : annotations) { + final String qualifiedName = annotation.getQualifiedName(); + if ("java.lang.Override".equals(qualifiedName)) { + continue; + } + if (!annotationsSet.contains(annotation)) { + return false; + } + } + return true; + } + private boolean haveSameJavaDoc(PsiMethod method, PsiMethod superMethod) { final PsiDocComment superDocComment = superMethod.getDocComment(); final PsiDocComment docComment = method.getDocComment(); diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodOverridesAbstractMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodOverridesAbstractMethod.html index abd9135fc4c2..59e628bae7ef 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodOverridesAbstractMethod.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodOverridesAbstractMethod.html @@ -1,9 +1,13 @@ -This inspection reports abstract methods which override abstract methods. Methods with +This inspection reports abstract methods which override abstract methods. Methods with different return types or exception declarations than the method they override are not reported by this inspection.

+Use the first checkbox to ignore any abstract methods that have a different JavaDoc comment than their super method. +

+Use the second checkbox to ignore any abstract methods that have one or more annotations that are not present on their super method. +

Powered by InspectionGadgets \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/AbstractMethodOverridesAbstractMethodInspection.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/AbstractMethodOverridesAbstractMethodInspection.java deleted file mode 100644 index 2cdf865ca3ec..000000000000 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/AbstractMethodOverridesAbstractMethodInspection.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.siyeh.igtest.classlayout; - - -public abstract class AbstractMethodOverridesAbstractMethodInspection { - public abstract Object foo() throws Exception; -} - - abstract class Child extends AbstractMethodOverridesAbstractMethodInspection -{ - public abstract Object foo() ; -} diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method/AbstractMethodOverridesAbstractMethod.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method/AbstractMethodOverridesAbstractMethod.java new file mode 100644 index 000000000000..55c25977c82b --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method/AbstractMethodOverridesAbstractMethod.java @@ -0,0 +1,31 @@ +package com.siyeh.igtest.inheritance.abstract_method_overrides_abstract_method; + + +import org.jetbrains.annotations.Nullable; + +public abstract class AbstractMethodOverridesAbstractMethod { + public abstract Object foo() throws Exception; + + abstract void one(String s); + + abstract void two(); + + public abstract void three(); + + + + +} +abstract class Child extends AbstractMethodOverridesAbstractMethod +{ + public abstract String foo() ; + + abstract void one(@Nullable String s); + + /** + * some documentation + */ + abstract void two(); + + public abstract void three(); +} diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method/expected.xml new file mode 100644 index 000000000000..7682ee3c3a6a --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method/expected.xml @@ -0,0 +1,11 @@ + + + + + AbstractMethodOverridesAbstractMethod.java + 30 + Abstract method overrides abstract method + Abstract method <code>three()</code> overrides abstract method #loc + + + \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspectionTest.java new file mode 100644 index 000000000000..5e6ed0b25c88 --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspectionTest.java @@ -0,0 +1,13 @@ +package com.siyeh.ig.inheritance; + +import com.siyeh.ig.IGInspectionTestCase; + +public class AbstractMethodOverridesAbstractMethodInspectionTest extends IGInspectionTestCase { + + public void test() throws Exception { + final AbstractMethodOverridesAbstractMethodInspection tool = new AbstractMethodOverridesAbstractMethodInspection(); + tool.ignoreAnnotations = true; + tool.ignoreJavaDoc = true; + doTest("com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method", tool); + } +} From cc91cafe5669bbc5564d2ba328bbf0ac717ab6d7 Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 19 Mar 2012 11:38:24 +0400 Subject: [PATCH 07/50] IDEA-82720 IAE at com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier.showOverChangesView --- .../intellij/openapi/vcs/changes/AbstractRefreshablePanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/AbstractRefreshablePanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/AbstractRefreshablePanel.java index 226e1b3c1bb0..af635d50dbe2 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/AbstractRefreshablePanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/AbstractRefreshablePanel.java @@ -135,7 +135,7 @@ public abstract class AbstractRefreshablePanel implements RefreshablePanel { cause = e; } LOG.info(e); - VcsBalloonProblemNotifier.showOverChangesView(myProject, cause.getMessage(), MessageType.ERROR); + VcsBalloonProblemNotifier.showOverChangesView(myProject, cause.getMessage() == null ? e.getMessage() : cause.getMessage(), MessageType.ERROR); } @Override From 3f9745383d7198059611f7989ec5409f09628740 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 19 Mar 2012 09:15:17 +0100 Subject: [PATCH 08/50] get back automatic stacktrace analyzer on mac --- .../src/com/intellij/unscramble/UnscrambleListener.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/unscramble/UnscrambleListener.java b/java/java-impl/src/com/intellij/unscramble/UnscrambleListener.java index 23afeba19ed8..2612500f018e 100644 --- a/java/java-impl/src/com/intellij/unscramble/UnscrambleListener.java +++ b/java/java-impl/src/com/intellij/unscramble/UnscrambleListener.java @@ -33,8 +33,6 @@ public class UnscrambleListener implements ApplicationActivationListener { @Override public void applicationActivated(final IdeFrame ideFrame) { - if (SystemInfo.isMac) return; - final Runnable processClipboard = new Runnable() { @Override public void run() { From 409ba238394bdf6f0f829e8cc953d5b1a27bc99f Mon Sep 17 00:00:00 2001 From: Rustam Vishnyakov Date: Mon, 19 Mar 2012 13:01:06 +0400 Subject: [PATCH 09/50] Limit custom folding lookup depth --- .../intellij/lang/folding/CustomFoldingBuilder.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/platform/lang-api/src/com/intellij/lang/folding/CustomFoldingBuilder.java b/platform/lang-api/src/com/intellij/lang/folding/CustomFoldingBuilder.java index 1b5822fbe3e2..cc6c34625ef8 100644 --- a/platform/lang-api/src/com/intellij/lang/folding/CustomFoldingBuilder.java +++ b/platform/lang-api/src/com/intellij/lang/folding/CustomFoldingBuilder.java @@ -22,6 +22,7 @@ import java.util.List; public abstract class CustomFoldingBuilder extends FoldingBuilderEx implements DumbAware { private CustomFoldingProvider myDefaultProvider; + private static final int MAX_LOOKUP_DEPTH = 10; @NotNull @Override @@ -29,7 +30,7 @@ public abstract class CustomFoldingBuilder extends FoldingBuilderEx implements D List descriptors = new ArrayList(); if (CustomFoldingProvider.getAllProviders().length > 0) { myDefaultProvider = null; - addCustomFoldingRegionsRecursively(null, root.getNode(), descriptors); + addCustomFoldingRegionsRecursively(null, root.getNode(), descriptors, 0); } buildLanguageFoldRegions(descriptors, root, document, quick); return descriptors.toArray(new FoldingDescriptor[descriptors.size()]); @@ -57,7 +58,8 @@ public abstract class CustomFoldingBuilder extends FoldingBuilderEx implements D private void addCustomFoldingRegionsRecursively(@Nullable FoldingStack foldingStack, @NotNull ASTNode node, - List descriptors) { + List descriptors, + int currDepth) { FoldingStack localFoldingStack = isCustomFoldingRoot(node) || foldingStack == null ? new FoldingStack(node) : foldingStack; for (ASTNode child = node.getFirstChildNode(); child != null; child = child.getTreeNext()) { if (isCustomRegionStart(child)) { @@ -72,7 +74,9 @@ public abstract class CustomFoldingBuilder extends FoldingBuilderEx implements D } } else { - addCustomFoldingRegionsRecursively(localFoldingStack, child, descriptors); + if (currDepth < MAX_LOOKUP_DEPTH) { + addCustomFoldingRegionsRecursively(localFoldingStack, child, descriptors, currDepth + 1); + } } } } From c449784440ca095c603c07ad2b643113c1b2fd49 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Mon, 19 Mar 2012 13:02:18 +0400 Subject: [PATCH 10/50] Inspections. Toolbar decorator. --- .../intellij/codeInspection/ui/AddAction.java | 55 ---- .../codeInspection/ui/ListEditForm.form | 47 ---- .../codeInspection/ui/ListEditForm.java | 77 ++++-- .../codeInspection/ui/RemoveAction.java | 60 ----- .../siyeh/InspectionGadgetsBundle.properties | 4 - .../ig/bugs/IgnoreResultOfCallInspection.java | 48 +--- ...atchedCollectionQueryUpdateInspection.java | 35 +-- .../BadExceptionCaughtInspection.java | 40 +-- .../BadExceptionDeclaredInspection.java | 30 +-- .../BadExceptionThrownInspection.java | 42 +-- .../TestMethodWithoutAssertionInspection.java | 42 +-- .../ClassWithMultipleLoggersInspection.java | 31 +-- .../logging/ClassWithoutLoggerInspection.java | 41 +-- ...tementGuardedByLogConditionInspection.java | 52 +--- ...odNameMustStartWithQuestionInspection.java | 38 +-- ...NameMayNotStartWithQuestionInspection.java | 45 +--- .../ig/naming/QuestionableNameInspection.java | 29 +- .../ig/resources/IOResourceInspection.java | 50 +--- .../src/com/siyeh/ig/ui/UiUtils.java | 247 ++++++------------ 19 files changed, 237 insertions(+), 776 deletions(-) delete mode 100644 platform/lang-api/src/com/intellij/codeInspection/ui/AddAction.java delete mode 100644 platform/lang-api/src/com/intellij/codeInspection/ui/ListEditForm.form delete mode 100644 platform/lang-api/src/com/intellij/codeInspection/ui/RemoveAction.java diff --git a/platform/lang-api/src/com/intellij/codeInspection/ui/AddAction.java b/platform/lang-api/src/com/intellij/codeInspection/ui/AddAction.java deleted file mode 100644 index 7e0fd8359699..000000000000 --- a/platform/lang-api/src/com/intellij/codeInspection/ui/AddAction.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2007-2010 Bas Leijdekkers - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.codeInspection.ui; - -import com.intellij.CommonBundle; - -import javax.swing.*; -import javax.swing.table.TableCellEditor; -import java.awt.*; -import java.awt.event.ActionEvent; - -public class AddAction extends AbstractAction { - - final ListTable table; - - public AddAction(ListTable table) { - this.table = table; - putValue(NAME, CommonBundle.message("button.add.a")); - } - - public void actionPerformed(ActionEvent e) { - final ListWrappingTableModel tableModel = table.getModel(); - tableModel.addRow(); - EventQueue.invokeLater(new Runnable() { - public void run() { - final int lastRowIndex = tableModel.getRowCount() - 1; - final Rectangle rectangle = - table.getCellRect(lastRowIndex, 0, true); - table.scrollRectToVisible(rectangle); - table.editCellAt(lastRowIndex, 0); - final ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval(lastRowIndex, lastRowIndex); - final TableCellEditor editor = table.getCellEditor(); - final Component component = - editor.getTableCellEditorComponent(table, - null, true, lastRowIndex, 0); - component.requestFocus(); - } - }); - } -} \ No newline at end of file diff --git a/platform/lang-api/src/com/intellij/codeInspection/ui/ListEditForm.form b/platform/lang-api/src/com/intellij/codeInspection/ui/ListEditForm.form deleted file mode 100644 index 605c7defe87f..000000000000 --- a/platform/lang-api/src/com/intellij/codeInspection/ui/ListEditForm.form +++ /dev/null @@ -1,47 +0,0 @@ - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/platform/lang-api/src/com/intellij/codeInspection/ui/ListEditForm.java b/platform/lang-api/src/com/intellij/codeInspection/ui/ListEditForm.java index 5e1072ad4dc2..61513a26a583 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/ui/ListEditForm.java +++ b/platform/lang-api/src/com/intellij/codeInspection/ui/ListEditForm.java @@ -15,32 +15,77 @@ */ package com.intellij.codeInspection.ui; -import com.intellij.codeInspection.ui.AddAction; -import com.intellij.codeInspection.ui.ListTable; -import com.intellij.codeInspection.ui.ListWrappingTableModel; -import com.intellij.codeInspection.ui.RemoveAction; +import com.intellij.ui.AnActionButton; +import com.intellij.ui.AnActionButtonRunnable; +import com.intellij.ui.ToolbarDecorator; import javax.swing.*; +import javax.swing.table.TableCellEditor; +import java.awt.*; import java.util.List; public class ListEditForm { - JPanel contentPanel; - JButton addButton; - JButton removeButton; ListTable table; - private List myStringList; - private String myTitle; public ListEditForm(String title, List stringList) { - myStringList = stringList; - myTitle = title; - removeButton.setAction(new RemoveAction(table)); - addButton.setAction(new AddAction(table)); - } + table = new ListTable(new ListWrappingTableModel(stringList, title)); - private void createUIComponents() { - table = new ListTable(new ListWrappingTableModel(myStringList, myTitle)); + contentPanel = ToolbarDecorator.createDecorator(table) + .setAddAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + final ListWrappingTableModel tableModel = table.getModel(); + tableModel.addRow(); + EventQueue.invokeLater(new Runnable() { + public void run() { + final int lastRowIndex = tableModel.getRowCount() - 1; + final Rectangle rectangle = + table.getCellRect(lastRowIndex, 0, true); + table.scrollRectToVisible(rectangle); + table.editCellAt(lastRowIndex, 0); + final ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval(lastRowIndex, lastRowIndex); + final TableCellEditor editor = table.getCellEditor(); + final Component component = + editor.getTableCellEditorComponent(table, + null, true, lastRowIndex, 0); + component.requestFocus(); + } + }); + } + }).setRemoveAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + final ListSelectionModel selectionModel = table.getSelectionModel(); + final int minIndex = selectionModel.getMinSelectionIndex(); + final int maxIndex = selectionModel.getMaxSelectionIndex(); + if (minIndex == -1 || maxIndex == -1) { + return; + } + final ListWrappingTableModel tableModel = table.getModel(); + for (int i = minIndex; i <= maxIndex; i++) { + if (selectionModel.isSelectedIndex(i)) { + tableModel.removeRow(i); + } + } + final int count = tableModel.getRowCount(); + if (count <= minIndex) { + selectionModel.setSelectionInterval(count - 1, + count - 1); + } + else if (minIndex <= 0) { + if (count > 0) { + selectionModel.setSelectionInterval(0, 0); + } + } + else { + selectionModel.setSelectionInterval(minIndex - 1, + minIndex - 1); + } + } + }).disableUpDownActions().createPanel(); } public JComponent getContentPanel() { diff --git a/platform/lang-api/src/com/intellij/codeInspection/ui/RemoveAction.java b/platform/lang-api/src/com/intellij/codeInspection/ui/RemoveAction.java deleted file mode 100644 index e89b6383189e..000000000000 --- a/platform/lang-api/src/com/intellij/codeInspection/ui/RemoveAction.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2007 Bas Leijdekkers - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.codeInspection.ui; - -import com.intellij.CommonBundle; - -import javax.swing.*; -import java.awt.event.ActionEvent; - -public class RemoveAction extends AbstractAction { - - private final ListTable table; - - public RemoveAction(ListTable table) { - this.table = table; - putValue(NAME, CommonBundle.message("button.remove.r")); - } - - public void actionPerformed(ActionEvent e) { - final ListSelectionModel selectionModel = table.getSelectionModel(); - final int minIndex = selectionModel.getMinSelectionIndex(); - final int maxIndex = selectionModel.getMaxSelectionIndex(); - if (minIndex == -1 || maxIndex == -1) { - return; - } - final ListWrappingTableModel tableModel = table.getModel(); - for (int i = minIndex; i <= maxIndex; i++) { - if (selectionModel.isSelectedIndex(i)) { - tableModel.removeRow(i); - } - } - final int count = tableModel.getRowCount(); - if (count <= minIndex) { - selectionModel.setSelectionInterval(count - 1, - count - 1); - } - else if (minIndex <= 0) { - if (count > 0) { - selectionModel.setSelectionInterval(0, 0); - } - } - else { - selectionModel.setSelectionInterval(minIndex - 1, - minIndex - 1); - } - } -} \ No newline at end of file diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties index 62555bcfe923..41aacead7db1 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties @@ -1411,9 +1411,6 @@ assignment.replaceable.with.operator.assignment.problem.descriptor=#ref#ref() is identical to its super method #loc @@ -1425,7 +1422,6 @@ pointless.indexof.comparison.display.name=Pointless 'indexOf()' comparison pointless.indexof.comparison.always.true.problem.descriptor=#ref is always true #loc pointless.indexof.comparison.always.false.problem.descriptor=#ref is always false #loc reuse.of.local.variable.problem.descriptor=Reuse of local variable #ref #loc -button.remove=&Remove single.character.startswith.display.name=Single character 'startsWith()' or 'endsWith()' single.character.startswith.problem.descriptor=Single character #ref() could be replaced with 'charAt()' expression #loc indexof.replaceable.by.contains.display.name='indexOf()' expression is replaceable with 'contains()' diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspection.java index 39f8b70db984..873a2407a5cc 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspection.java @@ -17,12 +17,10 @@ package com.siyeh.ig.bugs; import com.intellij.codeInspection.ui.ListTable; import com.intellij.codeInspection.ui.ListWrappingTableModel; -import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; import com.intellij.psi.*; import com.intellij.psi.util.InheritanceUtil; -import com.intellij.ui.ScrollPaneFactory; import com.intellij.util.ui.CheckBox; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; @@ -107,43 +105,15 @@ public class IgnoreResultOfCallInspection extends BaseInspection { @Override public JComponent createOptionsPanel() { - final JPanel panel = new JPanel(new GridBagLayout()); - final ListTable table = - new ListTable(new ListWrappingTableModel( - Arrays.asList(classNames, methodNamePatterns), - InspectionGadgetsBundle.message( - "result.of.method.call.ignored.class.column.title"), - InspectionGadgetsBundle.message( - "result.of.method.call.ignored.method.column.title"))); - final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(table); - UiUtils.setScrollPaneSize(scrollPane, 7, 25); - - final ActionToolbar toolbar = UiUtils.createAddRemoveToolbar(table); - - final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message( - "result.of.method.call.ignored.non.library.option"), this, - "m_reportAllNonLibraryCalls"); - - final GridBagConstraints constraints = new GridBagConstraints(); - constraints.anchor = GridBagConstraints.FIRST_LINE_START; - constraints.gridx = 0; - constraints.gridy = 0; - constraints.insets.left = 4; - constraints.insets.right = 4; - constraints.fill = GridBagConstraints.HORIZONTAL; - panel.add(toolbar.getComponent(), constraints); - - constraints.gridy = 1; - constraints.weightx = 1.0; - constraints.weighty = 1.0; - constraints.fill = GridBagConstraints.BOTH; - panel.add(scrollPane, constraints); - - constraints.gridy = 2; - constraints.weighty = 0.0; - constraints.fill = GridBagConstraints.HORIZONTAL; - panel.add(checkBox, constraints); - panel.add(checkBox, constraints); + final JPanel panel = new JPanel(new BorderLayout()); + final ListTable table = new ListTable(new ListWrappingTableModel(Arrays.asList(classNames, methodNamePatterns), InspectionGadgetsBundle + .message("result.of.method.call.ignored.class.column.title"), InspectionGadgetsBundle + .message("result.of.method.call.ignored.method.column.title"))); + final JPanel tablePanel = UiUtils.createAddRemovePanel(table); + final CheckBox checkBox = + new CheckBox(InspectionGadgetsBundle.message("result.of.method.call.ignored.non.library.option"), this, "m_reportAllNonLibraryCalls"); + panel.add(tablePanel, BorderLayout.CENTER); + panel.add(checkBox, BorderLayout.SOUTH); return panel; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/MismatchedCollectionQueryUpdateInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/MismatchedCollectionQueryUpdateInspection.java index 91bb9d973765..b8d2d84576c9 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/MismatchedCollectionQueryUpdateInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/MismatchedCollectionQueryUpdateInspection.java @@ -17,12 +17,11 @@ package com.siyeh.ig.bugs; import com.intellij.codeInspection.ui.ListTable; import com.intellij.codeInspection.ui.ListWrappingTableModel; -import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.psi.*; import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; -import com.intellij.ui.ScrollPaneFactory; +import com.intellij.util.ui.UIUtil; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; @@ -76,37 +75,15 @@ public class MismatchedCollectionQueryUpdateInspection @Override public JComponent createOptionsPanel() { - final JPanel panel = new JPanel(new GridBagLayout()); + final JPanel panel = new JPanel(new GridLayout(1, 2, UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP)); final ListTable table1 = new ListTable(new ListWrappingTableModel(queryNames, InspectionGadgetsBundle.message("query.column.name"))); - final JScrollPane scrollPane1 = ScrollPaneFactory.createScrollPane(table1); - UiUtils.setScrollPaneSize(scrollPane1, 10, 15); - final ActionToolbar toolbar1 = UiUtils.createAddRemoveToolbar(table1); + final JPanel tablePanel1 = UiUtils.createAddRemovePanel(table1); final ListTable table2 = new ListTable(new ListWrappingTableModel(updateNames, InspectionGadgetsBundle.message("update.column.name"))); - final JScrollPane scrollPane2 = ScrollPaneFactory.createScrollPane(table2); - UiUtils.setScrollPaneSize(scrollPane2, 10, 15); - final ActionToolbar toolbar2 = UiUtils.createAddRemoveToolbar(table2); + final JPanel tablePanel2 = UiUtils.createAddRemovePanel(table2); - final GridBagConstraints constraints = new GridBagConstraints(); - constraints.gridx = 0; - constraints.gridy = 0; - constraints.insets.left = 4; - constraints.insets.right = 4; - constraints.fill = GridBagConstraints.HORIZONTAL; - panel.add(toolbar1.getComponent(), constraints); - - constraints.gridx = 1; - panel.add(toolbar2.getComponent(), constraints); - - constraints.gridx = 0; - constraints.gridy = 1; - constraints.weightx = 0.5; - constraints.weighty = 1.0; - constraints.fill = GridBagConstraints.BOTH; - panel.add(scrollPane1, constraints); - - constraints.gridx = 1; - panel.add(scrollPane2, constraints); + panel.add(tablePanel1); + panel.add(tablePanel2); return panel; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionCaughtInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionCaughtInspection.java index 71b8faa8fe44..7d266394df4a 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionCaughtInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionCaughtInspection.java @@ -17,13 +17,11 @@ package com.siyeh.ig.errorhandling; import com.intellij.codeInspection.ui.ListTable; import com.intellij.codeInspection.ui.ListWrappingTableModel; -import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiCatchSection; import com.intellij.psi.PsiParameter; import com.intellij.psi.PsiType; import com.intellij.psi.PsiTypeElement; -import com.intellij.ui.ScrollPaneFactory; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; @@ -31,11 +29,7 @@ import com.siyeh.ig.ui.ExternalizableStringSet; import com.siyeh.ig.ui.UiUtils; import org.jetbrains.annotations.NotNull; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; +import javax.swing.*; import java.util.List; public class BadExceptionCaughtInspection extends BaseInspection { @@ -88,36 +82,10 @@ public class BadExceptionCaughtInspection extends BaseInspection { @Override public JComponent createOptionsPanel() { - final JComponent panel = new JPanel(new GridBagLayout()); - final ListTable table = - new ListTable(new ListWrappingTableModel(exceptions, - InspectionGadgetsBundle.message( - "exception.class.column.name"))); - final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(table); - UiUtils.setScrollPaneSize(scrollPane, 7, 25); - final ActionToolbar toolbar = - UiUtils.createAddRemoveTreeClassChooserToolbar(table, - InspectionGadgetsBundle.message( - "choose.exception.class"), - "java.lang.Throwable"); - - final GridBagConstraints constraints = new GridBagConstraints(); - constraints.anchor = GridBagConstraints.FIRST_LINE_START; - constraints.gridx = 0; - constraints.gridy = 0; - constraints.insets.left = 4; - constraints.insets.right = 4; - constraints.fill = GridBagConstraints.HORIZONTAL; - panel.add(toolbar.getComponent(), constraints); - - constraints.gridy = 1; - constraints.weightx = 1.0; - constraints.weighty = 1.0; - constraints.fill = GridBagConstraints.BOTH; - panel.add(scrollPane, constraints); - - return panel; + new ListTable(new ListWrappingTableModel(exceptions, InspectionGadgetsBundle.message("exception.class.column.name"))); + return UiUtils + .createAddRemoveTreeClassChooserPanel(table, InspectionGadgetsBundle.message("choose.exception.class"), "java.lang.Throwable"); } @Override diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionDeclaredInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionDeclaredInspection.java index 2561e3730ae5..cfa98c4e706c 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionDeclaredInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionDeclaredInspection.java @@ -18,10 +18,8 @@ package com.siyeh.ig.errorhandling; import com.intellij.codeInsight.TestFrameworks; import com.intellij.codeInspection.ui.ListTable; import com.intellij.codeInspection.ui.ListWrappingTableModel; -import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; -import com.intellij.ui.ScrollPaneFactory; import com.intellij.util.ui.CheckBox; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; @@ -95,28 +93,16 @@ public class BadExceptionDeclaredInspection extends BaseInspection { @Override public JComponent createOptionsPanel() { - final JComponent panel = new JPanel(new BorderLayout()); - final ListTable table = - new ListTable(new ListWrappingTableModel(exceptions, - InspectionGadgetsBundle.message( - "exception.class.column.name"))); - final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(table); - UiUtils.setScrollPaneSize(scrollPane, 7, 25); - final ActionToolbar toolbar = - UiUtils.createAddRemoveTreeClassChooserToolbar(table, - InspectionGadgetsBundle.message( - "choose.exception.class"), - "java.lang.Throwable"); - - final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message( - "bad.exception.declared.ignore.exceptions.declared.in.tests.option"), - this, "ignoreTestCases"); - - panel.add(toolbar.getComponent(), BorderLayout.NORTH); - panel.add(scrollPane, BorderLayout.CENTER); + new ListTable(new ListWrappingTableModel(exceptions, InspectionGadgetsBundle.message("exception.class.column.name"))); + JPanel tablePanel = + UiUtils.createAddRemoveTreeClassChooserPanel(table, InspectionGadgetsBundle.message("choose.exception.class"), "java.lang.Throwable"); + final CheckBox checkBox = + new CheckBox(InspectionGadgetsBundle.message("bad.exception.declared.ignore.exceptions.declared.in.tests.option"), this, + "ignoreTestCases"); + final JComponent panel = new JPanel(new BorderLayout()); + panel.add(tablePanel, BorderLayout.CENTER); panel.add(checkBox, BorderLayout.SOUTH); - return panel; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionThrownInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionThrownInspection.java index 059de791a131..aceb1ada64e7 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionThrownInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/BadExceptionThrownInspection.java @@ -17,12 +17,10 @@ package com.siyeh.ig.errorhandling; import com.intellij.codeInspection.ui.ListTable; import com.intellij.codeInspection.ui.ListWrappingTableModel; -import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiExpression; import com.intellij.psi.PsiThrowStatement; import com.intellij.psi.PsiType; -import com.intellij.ui.ScrollPaneFactory; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; @@ -30,13 +28,7 @@ import com.siyeh.ig.ui.ExternalizableStringSet; import com.siyeh.ig.ui.UiUtils; import org.jetbrains.annotations.NotNull; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import java.awt.Dimension; -import java.awt.FontMetrics; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; +import javax.swing.*; import java.util.List; public class BadExceptionThrownInspection extends BaseInspection { @@ -85,36 +77,8 @@ public class BadExceptionThrownInspection extends BaseInspection { @Override public JComponent createOptionsPanel() { - final JComponent panel = new JPanel(new GridBagLayout()); - - final ListTable table = - new ListTable(new ListWrappingTableModel(exceptions, - InspectionGadgetsBundle.message( - "exception.class.column.name"))); - final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(table); - UiUtils.setScrollPaneSize(scrollPane, 7, 25); - final ActionToolbar toolbar = - UiUtils.createAddRemoveTreeClassChooserToolbar(table, - InspectionGadgetsBundle.message( - "choose.exception.class"), - "java.lang.Throwable"); - - final GridBagConstraints constraints = new GridBagConstraints(); - constraints.anchor = GridBagConstraints.FIRST_LINE_START; - constraints.gridx = 0; - constraints.gridy = 0; - constraints.insets.left = 4; - constraints.insets.right = 4; - constraints.fill = GridBagConstraints.HORIZONTAL; - panel.add(toolbar.getComponent(), constraints); - - constraints.gridy = 1; - constraints.weightx = 1.0; - constraints.weighty = 1.0; - constraints.fill = GridBagConstraints.BOTH; - panel.add(scrollPane, constraints); - - return panel; + final ListTable table = new ListTable(new ListWrappingTableModel(exceptions, InspectionGadgetsBundle.message( "exception.class.column.name"))); + return UiUtils.createAddRemoveTreeClassChooserPanel(table, InspectionGadgetsBundle.message("choose.exception.class"), "java.lang.Throwable"); } @Override diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/junit/TestMethodWithoutAssertionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/TestMethodWithoutAssertionInspection.java index 65eb48a313bc..849531914a18 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/junit/TestMethodWithoutAssertionInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/TestMethodWithoutAssertionInspection.java @@ -17,12 +17,10 @@ package com.siyeh.ig.junit; import com.intellij.codeInspection.ui.ListTable; import com.intellij.codeInspection.ui.ListWrappingTableModel; -import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; import com.intellij.psi.*; import com.intellij.psi.util.InheritanceUtil; -import com.intellij.ui.ScrollPaneFactory; import com.intellij.util.ui.CheckBox; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; @@ -84,37 +82,15 @@ public class TestMethodWithoutAssertionInspection extends BaseInspection { @Override public JComponent createOptionsPanel() { - final JPanel panel = new JPanel(new GridBagLayout()); - final ListTable table = new ListTable(new ListWrappingTableModel( - Arrays.asList(classNames, methodNamePatterns), - InspectionGadgetsBundle.message("class.name"), - InspectionGadgetsBundle.message("method.name.pattern"))); - final JScrollPane scrollPane = - ScrollPaneFactory.createScrollPane(table); - UiUtils.setScrollPaneSize(scrollPane, 7, 25); - final ActionToolbar toolbar = - UiUtils.createAddRemoveToolbar(table); - - final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message( - "assert.keyword.is.considered.an.assertion"), this, - "assertKeywordIsAssertion"); - - final GridBagConstraints constraints = new GridBagConstraints(); - constraints.gridx = 0; - constraints.gridy = 0; - constraints.fill = GridBagConstraints.HORIZONTAL; - panel.add(toolbar.getComponent(), constraints); - - constraints.gridx = 0; - constraints.gridy = 1; - constraints.weightx = 1.0; - constraints.weighty = 1.0; - constraints.fill = GridBagConstraints.BOTH; - panel.add(scrollPane, constraints); - - constraints.gridy = 2; - constraints.weighty = 0.0; - panel.add(checkBox, constraints); + final JPanel panel = new JPanel(new BorderLayout()); + final ListTable table = new ListTable( + new ListWrappingTableModel(Arrays.asList(classNames, methodNamePatterns), InspectionGadgetsBundle.message("class.name"), + InspectionGadgetsBundle.message("method.name.pattern"))); + final JPanel tablePanel = UiUtils.createAddRemovePanel(table); + final CheckBox checkBox = + new CheckBox(InspectionGadgetsBundle.message("assert.keyword.is.considered.an.assertion"), this, "assertKeywordIsAssertion"); + panel.add(tablePanel, BorderLayout.CENTER); + panel.add(checkBox, BorderLayout.SOUTH); return panel; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/logging/ClassWithMultipleLoggersInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/logging/ClassWithMultipleLoggersInspection.java index 0ea7e17054aa..893d77f20b57 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/logging/ClassWithMultipleLoggersInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/logging/ClassWithMultipleLoggersInspection.java @@ -17,11 +17,9 @@ package com.siyeh.ig.logging; import com.intellij.codeInspection.ui.ListTable; import com.intellij.codeInspection.ui.ListWrappingTableModel; -import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; import com.intellij.psi.*; -import com.intellij.ui.ScrollPaneFactory; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; @@ -31,7 +29,6 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import javax.swing.*; -import java.awt.*; import java.util.ArrayList; import java.util.List; @@ -78,32 +75,8 @@ public class ClassWithMultipleLoggersInspection extends BaseInspection { @Override public JComponent createOptionsPanel() { - final JComponent panel = new JPanel(new GridBagLayout()); - - final ListTable table = - new ListTable(new ListWrappingTableModel(loggerNames, - InspectionGadgetsBundle.message("logger.class.names"))); - final JScrollPane scrollPane = - ScrollPaneFactory.createScrollPane(table); - UiUtils.setScrollPaneSize(scrollPane, 7, 25); - final ActionToolbar toolbar = - UiUtils.createAddRemoveTreeClassChooserToolbar(table, - InspectionGadgetsBundle.message("choose.logger.class")); - - final GridBagConstraints constraints = new GridBagConstraints(); - constraints.gridx = 0; - constraints.gridy = 0; - constraints.insets.left = 4; - constraints.insets.right = 4; - constraints.fill = GridBagConstraints.HORIZONTAL; - panel.add(toolbar.getComponent(), constraints); - - constraints.gridy = 1; - constraints.weightx = 1.0; - constraints.weighty = 1.0; - constraints.fill = GridBagConstraints.BOTH; - panel.add(scrollPane, constraints); - return panel; + final ListTable table = new ListTable(new ListWrappingTableModel(loggerNames, InspectionGadgetsBundle.message("logger.class.names"))); + return UiUtils.createAddRemoveTreeClassChooserPanel(table, InspectionGadgetsBundle.message("choose.logger.class")); } @Override diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/logging/ClassWithoutLoggerInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/logging/ClassWithoutLoggerInspection.java index d72c0668981c..751dd8ae30d0 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/logging/ClassWithoutLoggerInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/logging/ClassWithoutLoggerInspection.java @@ -17,12 +17,10 @@ package com.siyeh.ig.logging; import com.intellij.codeInspection.ui.ListTable; import com.intellij.codeInspection.ui.ListWrappingTableModel; -import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; import com.intellij.psi.*; import com.intellij.psi.util.PsiUtil; -import com.intellij.ui.ScrollPaneFactory; import com.intellij.util.ui.CheckBox; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; @@ -84,39 +82,12 @@ public class ClassWithoutLoggerInspection extends BaseInspection { @Override public JComponent createOptionsPanel() { - final JComponent panel = new JPanel(new GridBagLayout()); - - final ListTable table = - new ListTable(new ListWrappingTableModel(loggerNames, - InspectionGadgetsBundle.message("logger.class.names"))); - final JScrollPane scrollPane = - ScrollPaneFactory.createScrollPane(table); - UiUtils.setScrollPaneSize(scrollPane, 7, 25); - final ActionToolbar toolbar = - UiUtils.createAddRemoveTreeClassChooserToolbar(table, - InspectionGadgetsBundle.message("choose.logger.class")); - - final GridBagConstraints constraints = new GridBagConstraints(); - constraints.gridx = 0; - constraints.gridy = 0; - constraints.insets.left = 4; - constraints.insets.right = 4; - constraints.fill = GridBagConstraints.HORIZONTAL; - panel.add(toolbar.getComponent(), constraints); - - constraints.gridy = 1; - constraints.weightx = 1.0; - constraints.weighty = 1.0; - constraints.fill = GridBagConstraints.BOTH; - panel.add(scrollPane, constraints); - - final CheckBox checkBox = new CheckBox( - InspectionGadgetsBundle.message("super.class.logger.option"), - this, "ignoreSuperLoggers"); - constraints.gridy = 2; - constraints.weighty = 0.0; - constraints.fill = GridBagConstraints.HORIZONTAL; - panel.add(checkBox, constraints); + final JComponent panel = new JPanel(new BorderLayout()); + final ListTable table = new ListTable(new ListWrappingTableModel(loggerNames, InspectionGadgetsBundle.message("logger.class.names"))); + final JPanel tablePanel = UiUtils.createAddRemoveTreeClassChooserPanel(table, InspectionGadgetsBundle.message("choose.logger.class")); + final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message("super.class.logger.option"), this, "ignoreSuperLoggers"); + panel.add(tablePanel, BorderLayout.CENTER); + panel.add(checkBox, BorderLayout.SOUTH); return panel; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/logging/LogStatementGuardedByLogConditionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/logging/LogStatementGuardedByLogConditionInspection.java index 38fcd9c0f80f..ddf001bde062 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/logging/LogStatementGuardedByLogConditionInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/logging/LogStatementGuardedByLogConditionInspection.java @@ -18,7 +18,6 @@ package com.siyeh.ig.logging; import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.codeInspection.ui.ListTable; import com.intellij.codeInspection.ui.ListWrappingTableModel; -import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; @@ -26,8 +25,8 @@ import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; -import com.intellij.ui.ScrollPaneFactory; import com.intellij.util.IncorrectOperationException; +import com.intellij.util.ui.FormBuilder; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; @@ -80,47 +79,16 @@ public class LogStatementGuardedByLogConditionInspection @Override public JComponent createOptionsPanel() { - final GridBagLayout layout = new GridBagLayout(); - final JPanel panel = new JPanel(layout); - - final JLabel classNameLabel = new JLabel( - InspectionGadgetsBundle.message("logger.name.option")); + final JPanel panel = new JPanel(new BorderLayout()); + final JLabel classNameLabel = new JLabel(InspectionGadgetsBundle.message("logger.name.option")); classNameLabel.setHorizontalAlignment(SwingConstants.TRAILING); - final TextField loggerClassNameField = - new TextField(this, "loggerClassName"); - final ListTable table = new ListTable(new ListWrappingTableModel( - Arrays.asList(logMethodNameList, logConditionMethodNameList), - InspectionGadgetsBundle.message("log.method.name"), - InspectionGadgetsBundle.message("log.condition.text"))); - final JScrollPane scrollPane = - ScrollPaneFactory.createScrollPane(table); - UiUtils.setScrollPaneSize(scrollPane, 7, 25); - final ActionToolbar toolbar = UiUtils.createAddRemoveToolbar(table); - - final GridBagConstraints constraints = new GridBagConstraints(); - constraints.gridx = 0; - constraints.gridy = 2; - constraints.ipady = 10; - - constraints.anchor = GridBagConstraints.NORTHEAST; - panel.add(classNameLabel, constraints); - - constraints.gridx = 1; - constraints.ipady = 0; - constraints.weightx = 1.0; - constraints.fill = GridBagConstraints.HORIZONTAL; - panel.add(loggerClassNameField, constraints); - - constraints.gridwidth = 2; - constraints.gridx = 0; - constraints.gridy = 0; - panel.add(toolbar.getComponent(), constraints); - - constraints.weighty = 1.0; - constraints.gridy = 1; - constraints.fill = GridBagConstraints.BOTH; - panel.add(scrollPane, constraints); - + final TextField loggerClassNameField = new TextField(this, "loggerClassName"); + final ListTable table = new ListTable(new ListWrappingTableModel(Arrays.asList(logMethodNameList, logConditionMethodNameList), + InspectionGadgetsBundle.message("log.method.name"), + InspectionGadgetsBundle.message("log.condition.text"))); + final JPanel tablePanel = UiUtils.createAddRemovePanel(table); + panel.add(tablePanel, BorderLayout.CENTER); + panel.add(FormBuilder.createFormBuilder().addLabeledComponent(classNameLabel, loggerClassNameField).getPanel(), BorderLayout.NORTH); return panel; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestionInspection.java index f55151b46390..b4d9ac91e14b 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestionInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/BooleanMethodNameMustStartWithQuestionInspection.java @@ -17,7 +17,6 @@ package com.siyeh.ig.naming; import com.intellij.codeInspection.ui.ListTable; import com.intellij.codeInspection.ui.ListWrappingTableModel; -import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; import com.intellij.psi.CommonClassNames; @@ -26,7 +25,6 @@ import com.intellij.psi.PsiMethod; import com.intellij.psi.PsiType; import com.intellij.psi.search.searches.SuperMethodsSearch; import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; -import com.intellij.ui.ScrollPaneFactory; import com.intellij.util.Query; import com.intellij.util.ui.CheckBox; import com.siyeh.InspectionGadgetsBundle; @@ -99,48 +97,32 @@ public class BooleanMethodNameMustStartWithQuestionInspection @Override public JComponent createOptionsPanel() { final JPanel panel = new JPanel(new GridBagLayout()); - final ListTable table = - new ListTable(new ListWrappingTableModel(questionList, - InspectionGadgetsBundle.message( - "boolean.method.name.must.start.with.question.table.column.name"))); - final JScrollPane scrollPane = - ScrollPaneFactory.createScrollPane(table); - UiUtils.setScrollPaneSize(scrollPane, 7, 25); - final ActionToolbar toolbar = - UiUtils.createAddRemoveToolbar(table); + final ListTable table = new ListTable(new ListWrappingTableModel(questionList, InspectionGadgetsBundle + .message("boolean.method.name.must.start.with.question.table.column.name"))); + final JPanel tablePanel = UiUtils.createAddRemovePanel(table); final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; - constraints.fill = GridBagConstraints.HORIZONTAL; - panel.add(toolbar.getComponent(), constraints); - - constraints.gridy = 1; constraints.weightx = 1.0; constraints.weighty = 1.0; constraints.fill = GridBagConstraints.BOTH; - panel.add(scrollPane, constraints); + panel.add(tablePanel, constraints); final CheckBox checkBox1 = - new CheckBox(InspectionGadgetsBundle.message( - "ignore.methods.with.boolean.return.type.option"), - this, "ignoreBooleanMethods"); - constraints.gridy = 2; + new CheckBox(InspectionGadgetsBundle.message("ignore.methods.with.boolean.return.type.option"), this, "ignoreBooleanMethods"); + constraints.gridy = 1; constraints.weighty = 0.0; panel.add(checkBox1, constraints); final CheckBox checkBox2 = - new CheckBox(InspectionGadgetsBundle.message( - "ignore.boolean.methods.in.an.interface.option"), - this, "ignoreInAnnotationInterface"); - constraints.gridy = 3; + new CheckBox(InspectionGadgetsBundle.message("ignore.boolean.methods.in.an.interface.option"), this, "ignoreInAnnotationInterface"); + constraints.gridy = 2; panel.add(checkBox2, constraints); final CheckBox checkBox3 = - new CheckBox(InspectionGadgetsBundle.message( - "ignore.methods.overriding.super.method"), - this, "onlyWarnOnBaseMethods"); - constraints.gridy = 4; + new CheckBox(InspectionGadgetsBundle.message("ignore.methods.overriding.super.method"), this, "onlyWarnOnBaseMethods"); + constraints.gridy = 3; panel.add(checkBox3, constraints); return panel; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java index 22031e3470a5..7744a4f72d15 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/NonBooleanMethodNameMayNotStartWithQuestionInspection.java @@ -17,7 +17,6 @@ package com.siyeh.ig.naming; import com.intellij.codeInspection.ui.ListTable; import com.intellij.codeInspection.ui.ListWrappingTableModel; -import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; import com.intellij.psi.CommonClassNames; @@ -25,9 +24,9 @@ import com.intellij.psi.PsiMethod; import com.intellij.psi.PsiType; import com.intellij.psi.search.searches.SuperMethodsSearch; import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; -import com.intellij.ui.ScrollPaneFactory; import com.intellij.util.Query; import com.intellij.util.ui.CheckBox; +import com.intellij.util.ui.FormBuilder; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; @@ -94,42 +93,18 @@ public class NonBooleanMethodNameMayNotStartWithQuestionInspection @Override public JComponent createOptionsPanel() { - final JPanel panel = new JPanel(new GridBagLayout()); - final ListTable table = - new ListTable(new ListWrappingTableModel(questionList, - InspectionGadgetsBundle.message( - "boolean.method.name.must.start.with.question.table.column.name"))); - final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(table); - UiUtils.setScrollPaneSize(scrollPane, 7, 25); - - final ActionToolbar toolbar = - UiUtils.createAddRemoveToolbar(table); - final GridBagConstraints constraints = new GridBagConstraints(); - constraints.gridx = 0; - constraints.gridy = 0; - constraints.fill = GridBagConstraints.HORIZONTAL; - panel.add(toolbar.getComponent(), constraints); - - constraints.gridy = 1; - constraints.weightx = 1.0; - constraints.weighty = 1.0; - constraints.fill = GridBagConstraints.BOTH; - panel.add(scrollPane, constraints); + final JPanel panel = new JPanel(new BorderLayout()); + final ListTable table = new ListTable(new ListWrappingTableModel(questionList, InspectionGadgetsBundle + .message("boolean.method.name.must.start.with.question.table.column.name"))); + final JPanel tablePanel = UiUtils.createAddRemovePanel(table); final CheckBox checkBox1 = - new CheckBox(InspectionGadgetsBundle.message( - "ignore.methods.with.boolean.return.type.option"), - this, "ignoreBooleanMethods"); - constraints.gridy = 2; - constraints.weighty = 0.0; - panel.add(checkBox1, constraints); - + new CheckBox(InspectionGadgetsBundle.message("ignore.methods.with.boolean.return.type.option"), this, "ignoreBooleanMethods"); final CheckBox checkBox2 = - new CheckBox(InspectionGadgetsBundle.message( - "ignore.methods.overriding.super.method"), - this, "onlyWarnOnBaseMethods"); - constraints.gridy = 3; - panel.add(checkBox2, constraints); + new CheckBox(InspectionGadgetsBundle.message("ignore.methods.overriding.super.method"), this, "onlyWarnOnBaseMethods"); + + panel.add(tablePanel, BorderLayout.CENTER); + panel.add(FormBuilder.createFormBuilder().addComponent(checkBox1).addComponent(checkBox2).getPanel(), BorderLayout.SOUTH); return panel; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/QuestionableNameInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/QuestionableNameInspection.java index 08011bf76880..72e4d4e119bc 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/QuestionableNameInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/QuestionableNameInspection.java @@ -17,13 +17,11 @@ package com.siyeh.ig.naming; import com.intellij.codeInspection.ui.ListTable; import com.intellij.codeInspection.ui.ListWrappingTableModel; -import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiMethod; import com.intellij.psi.PsiVariable; -import com.intellij.ui.ScrollPaneFactory; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; @@ -35,7 +33,6 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import javax.swing.*; -import java.awt.*; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -86,29 +83,9 @@ public class QuestionableNameInspection extends BaseInspection { @Override public JComponent createOptionsPanel() { - final JPanel panel = new JPanel(new GridBagLayout()); - final ListTable table = new ListTable(new ListWrappingTableModel( - nameList, InspectionGadgetsBundle.message( - "questionable.name.column.title"))); - final JScrollPane scrollPane = - ScrollPaneFactory.createScrollPane(table); - UiUtils.setScrollPaneSize(scrollPane, 7, 25); - final ActionToolbar toolbar = - UiUtils.createAddRemoveToolbar(table); - - final GridBagConstraints constraints = new GridBagConstraints(); - constraints.gridx = 0; - constraints.gridy = 0; - constraints.fill = GridBagConstraints.HORIZONTAL; - panel.add(toolbar.getComponent(), constraints); - - constraints.gridy = 1; - constraints.weightx = 1.0; - constraints.weighty = 1.0; - constraints.fill = GridBagConstraints.BOTH; - panel.add(scrollPane, constraints); - - return panel; + final ListTable table = + new ListTable(new ListWrappingTableModel(nameList, InspectionGadgetsBundle.message("questionable.name.column.title"))); + return UiUtils.createAddRemovePanel(table); } @Override diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/resources/IOResourceInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/resources/IOResourceInspection.java index 0374d38a3397..136cb5fdb86d 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/resources/IOResourceInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/resources/IOResourceInspection.java @@ -17,12 +17,10 @@ package com.siyeh.ig.resources; import com.intellij.codeInspection.ui.ListTable; import com.intellij.codeInspection.ui.ListWrappingTableModel; -import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.ui.ScrollPaneFactory; import com.intellij.util.ui.CheckBox; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspectionVisitor; @@ -88,44 +86,15 @@ public class IOResourceInspection extends ResourceInspection { @Override public JComponent createOptionsPanel() { - final JComponent panel = new JPanel(new GridBagLayout()); - + final JComponent panel = new JPanel(new BorderLayout()); final ListTable table = - new ListTable(new ListWrappingTableModel(ignoredTypes, - InspectionGadgetsBundle.message( - "ignored.io.resource.types"))); - final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(table); - UiUtils.setScrollPaneSize(scrollPane, 7, 25); - final ActionToolbar toolbar = - UiUtils.createAddRemoveTreeClassChooserToolbar(table, - InspectionGadgetsBundle.message( - "choose.io.resource.type.to.ignore"), IO_TYPES); - - final CheckBox checkBox = new CheckBox( - InspectionGadgetsBundle.message( - "allow.resource.to.be.opened.inside.a.try.block"), - this, "insideTryAllowed"); - - final GridBagConstraints constraints = new GridBagConstraints(); - constraints.anchor = GridBagConstraints.FIRST_LINE_START; - constraints.gridx = 0; - constraints.gridy = 0; - constraints.insets.left = 4; - constraints.insets.right = 4; - constraints.fill = GridBagConstraints.HORIZONTAL; - panel.add(toolbar.getComponent(), constraints); - - constraints.gridy = 1; - constraints.weightx = 1.0; - constraints.weighty = 1.0; - constraints.fill = GridBagConstraints.BOTH; - panel.add(scrollPane, constraints); - - constraints.gridy = 2; - constraints.weighty = 0.0; - constraints.fill = GridBagConstraints.HORIZONTAL; - panel.add(checkBox, constraints); - + new ListTable(new ListWrappingTableModel(ignoredTypes, InspectionGadgetsBundle.message("ignored.io.resource.types"))); + JPanel tablePanel = + UiUtils.createAddRemoveTreeClassChooserPanel(table, InspectionGadgetsBundle.message("choose.io.resource.type.to.ignore"), IO_TYPES); + final CheckBox checkBox = + new CheckBox(InspectionGadgetsBundle.message("allow.resource.to.be.opened.inside.a.try.block"), this, "insideTryAllowed"); + panel.add(tablePanel, BorderLayout.CENTER); + panel.add(checkBox, BorderLayout.SOUTH); return panel; } @@ -148,7 +117,8 @@ public class IOResourceInspection extends ResourceInspection { private class IOResourceVisitor extends BaseInspectionVisitor { - IOResourceVisitor() {} + IOResourceVisitor() { + } @Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) { diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/ui/UiUtils.java b/plugins/InspectionGadgets/src/com/siyeh/ig/ui/UiUtils.java index a1d89f8d2f04..fb7b8dab1738 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/ui/UiUtils.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/ui/UiUtils.java @@ -21,17 +21,15 @@ import com.intellij.ide.DataManager; import com.intellij.ide.util.ClassFilter; import com.intellij.ide.util.TreeClassChooser; import com.intellij.ide.util.TreeClassChooserFactory; -import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiClass; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.InheritanceUtil; import com.intellij.ui.*; import com.intellij.ui.components.JBList; -import com.intellij.util.PlatformIcons; -import com.siyeh.InspectionGadgetsBundle; import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; import javax.swing.*; import javax.swing.table.TableCellEditor; @@ -40,7 +38,8 @@ import java.util.Collection; public class UiUtils { - private UiUtils() {} + private UiUtils() { + } public static void setScrollPaneSize(JScrollPane scrollPane, int rows, int columns) { final Component view = scrollPane.getViewport().getView(); @@ -55,19 +54,35 @@ public class UiUtils { component.setPreferredSize(new Dimension(width, fontMetrics.getHeight() * rows)); } - public static ActionToolbar createAddRemoveToolbar(ListTable table) { - final AnAction addAction = new AddAction(table); - final AnAction removeAction = new RemoveAction(table); - final ActionGroup group = - new DefaultActionGroup(addAction, removeAction); - final ActionManager actionManager = ActionManager.getInstance(); - return actionManager.createActionToolbar(ActionPlaces.UNKNOWN, - group, true); + public static JPanel createAddRemovePanel(final ListTable table) { + return ToolbarDecorator.createDecorator(table) + .setAddAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + final ListWrappingTableModel tableModel = table.getModel(); + tableModel.addRow(); + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + final int lastRowIndex = tableModel.getRowCount() - 1; + final Rectangle rectangle = table.getCellRect(lastRowIndex, 0, true); + table.scrollRectToVisible(rectangle); + table.editCellAt(lastRowIndex, 0); + final ListSelectionModel selectionModel = table.getSelectionModel(); + selectionModel.setSelectionInterval(lastRowIndex, lastRowIndex); + final TableCellEditor editor = table.getCellEditor(); + final Component component = editor.getTableCellEditorComponent(table, null, true, lastRowIndex, 0); + component.requestFocus(); + } + }); + } + }).setRemoveAction(new RemoveAction(table)) + .disableUpDownActions().createPanel(); } - public static ActionToolbar createAddRemoveTreeClassChooserToolbar( - ListTable table, String chooserTitle, - @NonNls String... ancestorClasses) { + public static JPanel createAddRemoveTreeClassChooserPanel(final ListTable table, + final String chooserTitle, + @NonNls String... ancestorClasses) { final ClassFilter filter; if (ancestorClasses.length == 0) { filter = ClassFilter.ALL; @@ -75,19 +90,53 @@ public class UiUtils { else { filter = new SubclassFilter(ancestorClasses); } - final AnAction addAction = new TreeClassChooserAction(table, - chooserTitle, filter); - final AnAction removeAction = new RemoveAction(table); - final ActionGroup group = - new DefaultActionGroup(addAction, removeAction); - final ActionManager actionManager = ActionManager.getInstance(); - return actionManager.createActionToolbar(ActionPlaces.UNKNOWN, - group, true); + return ToolbarDecorator.createDecorator(table) + .setAddAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + final DataContext dataContext = DataManager.getInstance().getDataContext(table); + final Project project = PlatformDataKeys.PROJECT.getData(dataContext); + if (project == null) { + return; + } + final TreeClassChooserFactory chooserFactory = TreeClassChooserFactory.getInstance(project); + final TreeClassChooser classChooser = + chooserFactory.createWithInnerClassesScopeChooser(chooserTitle, GlobalSearchScope.allScope(project), filter, null); + classChooser.showDialog(); + final PsiClass selectedClass = classChooser.getSelected(); + if (selectedClass == null) { + return; + } + final String qualifiedName = selectedClass.getQualifiedName(); + final ListWrappingTableModel tableModel = table.getModel(); + final int index = tableModel.indexOf(qualifiedName, 0); + final int rowIndex; + if (index < 0) { + tableModel.addRow(qualifiedName); + rowIndex = tableModel.getRowCount() - 1; + } + else { + rowIndex = index; + } + final ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval(rowIndex, rowIndex); + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + final Rectangle rectangle = table.getCellRect(rowIndex, 0, true); + table.scrollRectToVisible(rectangle); + } + }); + } + }).setRemoveAction(new RemoveAction(table)) + .disableUpDownActions().createPanel(); } - public static JPanel createTreeClassChooserList( - final Collection collection, String borderTitle, - final String chooserTitle, String... ancestorClasses) { + public static JPanel createTreeClassChooserList(final Collection collection, + String borderTitle, + final String chooserTitle, + String... ancestorClasses) { final ClassFilter filter; if (ancestorClasses.length == 0) { filter = ClassFilter.ALL; @@ -103,26 +152,20 @@ public class UiUtils { .setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton anActionButton) { - final DataContext dataContext = - DataManager.getInstance().getDataContext(list); - final Project project = - DataKeys.PROJECT.getData(dataContext); + final DataContext dataContext = DataManager.getInstance().getDataContext(list); + final Project project = PlatformDataKeys.PROJECT.getData(dataContext); if (project == null) { return; } - final TreeClassChooser chooser = - TreeClassChooserFactory.getInstance(project) - .createNoInnerClassesScopeChooser(chooserTitle, - GlobalSearchScope.allScope(project), - filter, null); + final TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project) + .createNoInnerClassesScopeChooser(chooserTitle, GlobalSearchScope.allScope(project), filter, null); chooser.showDialog(); final PsiClass selected = chooser.getSelected(); if (selected == null) { return; } final String qualifiedName = selected.getQualifiedName(); - final DefaultListModel model = - (DefaultListModel)list.getModel(); + final DefaultListModel model = (DefaultListModel)list.getModel(); final int index = model.indexOf(qualifiedName); if (index < 0) { model.addElement(qualifiedName); @@ -147,112 +190,16 @@ public class UiUtils { return optionsPanel; } - private static class TreeClassChooserAction extends AnAction { - - private final ListTable table; - private final String chooserTitle; - private final ClassFilter myFilter; - - public TreeClassChooserAction( - @NotNull ListTable table, @NotNull String chooserTitle, - @NotNull ClassFilter filter) { - super(InspectionGadgetsBundle.message("button.add"), "", - PlatformIcons.ADD_ICON); - this.table = table; - this.chooserTitle = chooserTitle; - this.myFilter = filter; - } - - @Override - public void actionPerformed(AnActionEvent e) { - final DataContext dataContext = e.getDataContext(); - final Project project = DataKeys.PROJECT.getData(dataContext); - if (project == null) { - return; - } - final TreeClassChooserFactory chooserFactory = - TreeClassChooserFactory.getInstance(project); - final TreeClassChooser classChooser = - chooserFactory.createWithInnerClassesScopeChooser(chooserTitle, - GlobalSearchScope.allScope(project), myFilter, null); - classChooser.showDialog(); - final PsiClass selectedClass = classChooser.getSelected(); - if (selectedClass == null) { - return; - } - final String qualifiedName = selectedClass.getQualifiedName(); - final ListWrappingTableModel tableModel = table.getModel(); - final int index = tableModel.indexOf(qualifiedName, 0); - final int rowIndex; - if (index < 0) { - tableModel.addRow(qualifiedName); - rowIndex = tableModel.getRowCount() - 1; - } - else { - rowIndex = index; - } - final ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval(rowIndex, rowIndex); - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - final Rectangle rectangle = - table.getCellRect(rowIndex, 0, true); - table.scrollRectToVisible(rectangle); - } - }); - } - } - - private static class AddAction extends AnAction { - - private final ListTable table; - - public AddAction(ListTable table) { - super(InspectionGadgetsBundle.message("button.add"), "", - PlatformIcons.ADD_ICON); - this.table = table; - } - - @Override - public void actionPerformed(AnActionEvent anActionEvent) { - final ListWrappingTableModel tableModel = table.getModel(); - tableModel.addRow(); - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - final int lastRowIndex = tableModel.getRowCount() - 1; - final Rectangle rectangle = - table.getCellRect(lastRowIndex, 0, true); - table.scrollRectToVisible(rectangle); - table.editCellAt(lastRowIndex, 0); - final ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval(lastRowIndex, - lastRowIndex); - final TableCellEditor editor = table.getCellEditor(); - final Component component = - editor.getTableCellEditorComponent(table, - null, true, lastRowIndex, 0); - component.requestFocus(); - } - }); - } - } - - private static class RemoveAction extends AnAction { + private static class RemoveAction implements AnActionButtonRunnable { private final ListTable table; public RemoveAction(ListTable table) { - super(InspectionGadgetsBundle.message("button.remove"), "", - PlatformIcons.DELETE_ICON); this.table = table; } @Override - public void actionPerformed(AnActionEvent anActionEvent) { + public void run(AnActionButton button) { EventQueue.invokeLater(new Runnable() { @Override public void run() { @@ -260,8 +207,7 @@ public class UiUtils { if (editor != null) { editor.stopCellEditing(); } - final ListSelectionModel selectionModel = - table.getSelectionModel(); + final ListSelectionModel selectionModel = table.getSelectionModel(); final int minIndex = selectionModel.getMinSelectionIndex(); final int maxIndex = selectionModel.getMaxSelectionIndex(); if (minIndex == -1 || maxIndex == -1) { @@ -275,8 +221,7 @@ public class UiUtils { } final int count = tableModel.getRowCount(); if (count <= minIndex) { - selectionModel.setSelectionInterval(count - 1, - count - 1); + selectionModel.setSelectionInterval(count - 1, count - 1); } else if (minIndex <= 0) { if (count > 0) { @@ -284,27 +229,7 @@ public class UiUtils { } } else { - selectionModel.setSelectionInterval(minIndex - 1, - minIndex - 1); - } - } - }); - } - - @Override - public void update(final AnActionEvent e) { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - final ListSelectionModel selectionModel = - table.getSelectionModel(); - final int minIndex = selectionModel.getMinSelectionIndex(); - final int maxIndex = selectionModel.getMaxSelectionIndex(); - if (minIndex == -1 || maxIndex == -1) { - e.getPresentation().setEnabled(false); - } - else { - e.getPresentation().setEnabled(true); + selectionModel.setSelectionInterval(minIndex - 1, minIndex - 1); } } }); From 3b51803ddb07010974589d8e3c75a842469bbce8 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 16 Mar 2012 15:52:32 +0400 Subject: [PATCH 11/50] synchronization --- .../vfs/newvfs/impl/VirtualDirectoryImpl.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualDirectoryImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualDirectoryImpl.java index 035266c4dd47..c7b2b88a308c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualDirectoryImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualDirectoryImpl.java @@ -73,7 +73,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry { private final NewVirtualFileSystem myFS; // guarded by this - protected Object myChildren; // Either HashMap or VFile[] + private Object myChildren; // Either HashMap or VFile[] public VirtualDirectoryImpl(@NotNull String name, final VirtualDirectoryImpl parent, @NotNull NewVirtualFileSystem fs, final int id) { super(name, parent, id); @@ -379,8 +379,9 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry { @NotNull private synchronized Collection getInDbChildren() { - if (myChildren instanceof VirtualFileSystemEntry[]) { - return Arrays.asList((VirtualFile[])myChildren); + VirtualFileSystemEntry[] children = asArray(); + if (children != null) { + return Arrays.asList((VirtualFile[])children); } if (!ourPersistence.wereChildrenAccessed(this)) { @@ -404,13 +405,13 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry { @Override @NotNull public synchronized VirtualFile[] getChildren() { - if (myChildren instanceof VirtualFileSystemEntry[]) { - return (VirtualFileSystemEntry[])myChildren; + VirtualFileSystemEntry[] children = asArray(); + if (children != null) { + return children; } Pair pair = PersistentFS.listAll(this); final int[] childrenIds = pair.second; - VirtualFileSystemEntry[] children; if (childrenIds.length == 0) { children = EMPTY_ARRAY; } @@ -454,7 +455,10 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry { @Override public NewVirtualFile findChildByIdIfCached(int id) { - final VirtualFile[] a = asArray(); + final VirtualFile[] a; + synchronized (this) { + a = asArray(); + } if (a != null) { for (VirtualFile file : a) { NewVirtualFile withId = (NewVirtualFile)file; @@ -477,12 +481,15 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry { return null; } + // MUST BE CALLED UNDER this LOCK @Nullable private VirtualFileSystemEntry[] asArray() { - if (myChildren instanceof VirtualFileSystemEntry[]) return (VirtualFileSystemEntry[])myChildren; + Object children = myChildren; + if (children instanceof VirtualFileSystemEntry[]) return (VirtualFileSystemEntry[])children; return null; } + // MUST BE CALLED UNDER this LOCK @Nullable private Map asMap() { if (myChildren instanceof Map) { @@ -530,7 +537,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry { } public synchronized boolean allChildrenLoaded() { - return myChildren instanceof VirtualFileSystemEntry[]; + return asArray() != null; } @NotNull From 1f87b4a9937782b883e471890476ea2166ca24ba Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 16 Mar 2012 16:25:04 +0400 Subject: [PATCH 12/50] supply project name in tests --- .../fixtures/JavaCodeInsightFixtureTestCase.java | 2 +- .../testFramework/fixtures/JavaTestFixtureFactory.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/java/testFramework/src/com/intellij/testFramework/fixtures/JavaCodeInsightFixtureTestCase.java b/java/testFramework/src/com/intellij/testFramework/fixtures/JavaCodeInsightFixtureTestCase.java index c2dd1a155a13..4fc029dcd86c 100644 --- a/java/testFramework/src/com/intellij/testFramework/fixtures/JavaCodeInsightFixtureTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/fixtures/JavaCodeInsightFixtureTestCase.java @@ -44,7 +44,7 @@ public abstract class JavaCodeInsightFixtureTestCase extends UsefulTestCase{ protected void setUp() throws Exception { super.setUp(); - final TestFixtureBuilder projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(); + final TestFixtureBuilder projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName()); myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(projectBuilder.getFixture()); final JavaModuleFixtureBuilder moduleFixtureBuilder = projectBuilder.addModule(JavaModuleFixtureBuilder.class); moduleFixtureBuilder.addSourceContentRoot(myFixture.getTempDirPath()); diff --git a/java/testFramework/src/com/intellij/testFramework/fixtures/JavaTestFixtureFactory.java b/java/testFramework/src/com/intellij/testFramework/fixtures/JavaTestFixtureFactory.java index b7b03b1de9df..5ae19176c25b 100644 --- a/java/testFramework/src/com/intellij/testFramework/fixtures/JavaTestFixtureFactory.java +++ b/java/testFramework/src/com/intellij/testFramework/fixtures/JavaTestFixtureFactory.java @@ -15,6 +15,8 @@ */ package com.intellij.testFramework.fixtures; +import org.jetbrains.annotations.NotNull; + /** * @author yole */ @@ -41,8 +43,15 @@ public abstract class JavaTestFixtureFactory { public abstract JavaCodeInsightTestFixture createCodeInsightFixture(IdeaProjectTestFixture projectFixture, TempDirTestFixture tempDirFixture); + /** + * + * @deprecated use {@link JavaTestFixtureFactory#createFixtureBuilder(String)} + */ //also implicitly initializes ourInstance and registers java module fixture builder public static TestFixtureBuilder createFixtureBuilder() { return IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(); } + public static TestFixtureBuilder createFixtureBuilder(@NotNull String name) { + return IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(name); + } } From b60202e290c99498f2da2436adfe1a6bcabcf2b1 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 16 Mar 2012 18:01:35 +0400 Subject: [PATCH 13/50] memory: do not store PsiFiles --- .../daemon/impl/DaemonCodeAnalyzerImpl.java | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java index 4cd590aa5898..252b26675a03 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java @@ -61,6 +61,7 @@ import com.intellij.psi.impl.PsiDocumentManagerImpl; import com.intellij.psi.search.scope.packageSet.NamedScope; import com.intellij.psi.search.scope.packageSet.NamedScopeManager; import com.intellij.psi.search.scope.packageSet.NamedScopesHolder; +import com.intellij.psi.util.PsiUtilCore; import com.intellij.util.Alarm; import com.intellij.util.CommonProcessors; import com.intellij.util.Processor; @@ -94,7 +95,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx private final Alarm myAlarm = new Alarm(); private boolean myUpdateByTimerEnabled = true; private final Collection myDisabledHintsFiles = new THashSet(); - private final Collection myDisabledHighlightingFiles = new THashSet(); + private final Collection myDisabledHighlightingFiles = new THashSet(); private final FileStatusMap myFileStatusMap; private DaemonCodeAnalyzerSettings myLastSettings; @@ -122,6 +123,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx myFileStatusMap = new FileStatusMap(myProject); myPassExecutorService = new PassExecutorService(myProject) { + @Override protected void afterApplyInformationToEditor(final TextEditorHighlightingPass pass, final FileEditor fileEditor, final ProgressIndicator updateProgress) { @@ -132,6 +134,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx } } + @Override protected boolean isDisposed() { return myDisposed || super.isDisposed(); } @@ -283,14 +286,17 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx myPassExecutorService.cancelAll(true); } + @Override @NotNull public String getComponentName() { return "DaemonCodeAnalyzer"; } + @Override public void initComponent() { } + @Override public void disposeComponent() { } @@ -309,6 +315,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx myFileStatusMap.markAllFilesDirty(); } + @Override public void projectClosed() { assert myInitialized : "Disposing not initialized component"; assert !myDisposed : "Double dispose"; @@ -354,6 +361,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx return myScopes; } + @Override public void settingsChanged() { DaemonCodeAnalyzerSettings settings = DaemonCodeAnalyzerSettings.getInstance(); if (settings.isCodeHighlightingChanged(myLastSettings)) { @@ -362,11 +370,13 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx myLastSettings = (DaemonCodeAnalyzerSettings)settings.clone(); } + @Override public void updateVisibleHighlighters(@NotNull Editor editor) { ApplicationManager.getApplication().assertIsDispatchThread(); // no need, will not work anyway } + @Override public void setUpdateByTimerEnabled(boolean value) { myUpdateByTimerEnabled = value; stopProcess(value); @@ -376,6 +386,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx return myUpdateByTimerEnabled; } + @Override public void setImportHintsEnabled(@NotNull PsiFile file, boolean value) { VirtualFile vFile = file.getVirtualFile(); if (value) { @@ -388,23 +399,27 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx } } + @Override public void resetImportHintsEnabledForProject() { myDisabledHintsFiles.clear(); } + @Override public void setHighlightingEnabled(@NotNull PsiFile file, boolean value) { + VirtualFile virtualFile = PsiUtilCore.getVirtualFile(file); if (value) { - myDisabledHighlightingFiles.remove(file); + myDisabledHighlightingFiles.remove(virtualFile); } else { - myDisabledHighlightingFiles.add(file); + myDisabledHighlightingFiles.add(virtualFile); } } + @Override public boolean isHighlightingAvailable(PsiFile file) { - if (myDisabledHighlightingFiles.contains(file)) return false; - if (file == null || !file.isPhysical()) return false; + if (myDisabledHighlightingFiles.contains(PsiUtilCore.getVirtualFile(file))) return false; + if (file instanceof PsiCompiledElement) return false; final FileType fileType = file.getFileType(); if (fileType == StdFileTypes.GUI_DESIGNER_FORM){ @@ -414,14 +429,17 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx return !fileType.isBinary(); } + @Override public boolean isImportHintsEnabled(@NotNull PsiFile file) { return isAutohintsAvailable(file) && !myDisabledHintsFiles.contains(file.getVirtualFile()); } + @Override public boolean isAutohintsAvailable(PsiFile file) { return isHighlightingAvailable(file) && !(file instanceof PsiCompiledElement); } + @Override public void restart() { myFileStatusMap.markAllFilesDirty(); stopProcess(true); @@ -507,6 +525,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project); MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true); return model.processRangeHighlightersOverlappingWith(startOffset, endOffset, new Processor() { + @Override public boolean process(RangeHighlighterEx marker) { Object tt = marker.getErrorStripeTooltip(); if (!(tt instanceof HighlightInfo)) return true; @@ -529,6 +548,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project); MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true); return model.processRangeHighlightersOutside(startOffset, endOffset, new Processor() { + @Override public boolean process(RangeHighlighterEx marker) { Object tt = marker.getErrorStripeTooltip(); if (!(tt instanceof HighlightInfo)) return true; @@ -548,6 +568,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx final boolean includeFixRange, @NotNull final Processor processor) { return processHighlights(document, project, null, 0, document.getTextLength(), new Processor() { + @Override public boolean process(HighlightInfo info) { if (!isOffsetInsideHighlightInfo(offset, info, includeFixRange)) return true; @@ -561,6 +582,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx public HighlightInfo findHighlightByOffset(Document document, final int offset, final boolean includeFixRange) { final List foundInfoList = new SmartList(); processHighlightsNearOffset(document, myProject, HighlightSeverity.INFORMATION, offset, includeFixRange, new Processor() { + @Override public boolean process(HighlightInfo info) { if (!foundInfoList.isEmpty()) { HighlightInfo foundInfo = foundInfoList.get(0); @@ -635,6 +657,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx return myLastIntentionHint; } + @Override public void writeExternal(Element parentNode) throws WriteExternalException { Element disableHintsElement = new Element(DISABLE_HINTS_TAG); parentNode.addContent(disableHintsElement); @@ -654,6 +677,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx } } + @Override public void readExternal(Element parentNode) throws InvalidDataException { myDisabledHintsFiles.clear(); @@ -675,12 +699,14 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx private Runnable createUpdateRunnable() { return new Runnable() { + @Override public void run() { if (myDisposed || !myProject.isInitialized()) return; if (PowerSaveMode.isEnabled()) return; Editor activeEditor = FileEditorManager.getInstance(myProject).getSelectedTextEditor(); Runnable runnable = new Runnable() { + @Override public void run() { PassExecutorService.log(myUpdateProgress, null, "Update Runnable. myUpdateByTimerEnabled:",myUpdateByTimerEnabled," something disposed:",PowerSaveMode.isEnabled() || myDisposed || !myProject.isInitialized()," activeEditors:",myProject.isDisposed() ? null : myDaemonListeners.getSelectedEditors()); if (!myUpdateByTimerEnabled) return; @@ -745,6 +771,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx return myDaemonListeners.canChangeFileSilently(file); } + @Override public void autoImportReferenceAtCursor(@NotNull Editor editor, @NotNull PsiFile file) { for(ReferenceImporter importer: Extensions.getExtensions(ReferenceImporter.EP_NAME)) { if (importer.autoImportReferenceAtCursor(editor, file)) break; From d3d5ef6ed6e30c6b9cd802b425436a37b1737a60 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 16 Mar 2012 18:04:19 +0400 Subject: [PATCH 14/50] cleanup --- .../ExternalAnnotationsManagerImpl.java | 68 ++++++++++++------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java index b86759580bca..8722fdfd04be 100644 --- a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java +++ b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java @@ -79,14 +79,13 @@ import java.io.IOException; import java.util.*; import java.util.List; import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.atomic.AtomicReference; public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { @NotNull public static final Icon ICON = IconLoader.getIcon("/modules/annotation.png"); private static final Logger LOG = Logger.getInstance("#" + ExternalAnnotationsManagerImpl.class.getName()); @NotNull private final ConcurrentMap> myExternalAnnotations = new ConcurrentWeakValueHashMap>(); - @NotNull private final AtomicReference myHasAnyAnnotationsRoots = new AtomicReference(ThreeState.UNSURE); + @NotNull private volatile ThreeState myHasAnyAnnotationsRoots = ThreeState.UNSURE; @NotNull private static final List NULL = new ArrayList(); private final PsiManager myPsiManager; @@ -94,38 +93,42 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { myPsiManager = psiManager; final MessageBusConnection connection = project.getMessageBus().connect(project); connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { + @Override public void beforeRootsChange(ModuleRootEvent event) { } + @Override public void rootsChanged(ModuleRootEvent event) { myExternalAnnotations.clear(); - myHasAnyAnnotationsRoots.set(ThreeState.UNSURE); + myHasAnyAnnotationsRoots = ThreeState.UNSURE; } }); } private ThreeState hasAnyAnnotationsRoots() { - if (myHasAnyAnnotationsRoots.get() == ThreeState.UNSURE) { + if (myHasAnyAnnotationsRoots == ThreeState.UNSURE) { final Module[] modules = ModuleManager.getInstance(myPsiManager.getProject()).getModules(); for (Module module : modules) { for (OrderEntry entry : ModuleRootManager.getInstance(module).getOrderEntries()) { final String[] urls = AnnotationOrderRootType.getUrls(entry); if (urls.length > 0) { - myHasAnyAnnotationsRoots.set(ThreeState.YES); + myHasAnyAnnotationsRoots = ThreeState.YES; return ThreeState.YES; } } } - myHasAnyAnnotationsRoots.set(ThreeState.NO); + myHasAnyAnnotationsRoots = ThreeState.NO; } - return myHasAnyAnnotationsRoots.get(); + return myHasAnyAnnotationsRoots; } + @Override @Nullable public PsiAnnotation findExternalAnnotation(@NotNull final PsiModifierListOwner listOwner, @NotNull final String annotationFQN) { return collectExternalAnnotations(listOwner).get(annotationFQN); } + @Override @Nullable public PsiAnnotation[] findExternalAnnotations(@NotNull final PsiModifierListOwner listOwner) { final Map result = collectExternalAnnotations(listOwner); @@ -135,11 +138,11 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { @NotNull private Map collectExternalAnnotations(@NotNull final PsiModifierListOwner listOwner) { if (hasAnyAnnotationsRoots() == ThreeState.NO) return Collections.emptyMap(); - final Map result = new HashMap(); - final List files = findExternalAnnotationsFile(listOwner); + final List files = findExternalAnnotationsFiles(listOwner); if (files == null) { return Collections.emptyMap(); } + final Map result = new HashMap(); for (XmlFile file : files) { if (!file.isValid()) continue; final XmlDocument document = file.getDocument(); @@ -168,7 +171,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { "@" + annotationFQN + (buf.length() > 0 ? "(" + StringUtil.trimStart(buf.toString(), ",") + ")" : ""); try { result.put(annotationFQN, - JavaPsiFacade.getInstance(listOwner.getProject()).getElementFactory().createAnnotationFromText( + JavaPsiFacade.getInstance(myPsiManager.getProject()).getElementFactory().createAnnotationFromText( annotationText, null)); } catch (IncorrectOperationException e) { @@ -186,11 +189,12 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { } + @Override public void annotateExternally(@NotNull final PsiModifierListOwner listOwner, @NotNull final String annotationFQName, @NotNull final PsiFile fromFile, final PsiNameValuePair[] value) { - final Project project = listOwner.getProject(); + final Project project = myPsiManager.getProject(); final PsiFile containingFile = listOwner.getContainingFile(); if (!(containingFile instanceof PsiJavaFile)) { return; @@ -215,6 +219,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { return; } SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { setupRootAndAnnotateExternally(entry, project, listOwner, annotationFQName, fromFile, packageName, virtualFile, value); } @@ -240,9 +245,10 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { return; } new WriteCommandAction(project) { + @Override protected void run(final Result result) throws Throwable { appendChosenAnnotationsRoot(entry, file); - final List xmlFiles = findExternalAnnotationsFile(listOwner); + final List xmlFiles = findExternalAnnotationsFiles(listOwner); if (xmlFiles != null) { //file already exists under appeared content root if (!CodeInsightUtilBase.preparePsiElementForWrite(xmlFiles.get(0))) return; annotateExternally(listOwner, annotationFQName, xmlFiles.get(0), fromFile, value); @@ -314,7 +320,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { @NotNull final PsiFile fromFile, final PsiNameValuePair[] value) { final XmlFile[] annotationsXml = new XmlFile[1]; - List xmlFiles = findExternalAnnotationsFile(listOwner); + List xmlFiles = findExternalAnnotationsFiles(listOwner); if (xmlFiles != null) { for (XmlFile xmlFile : xmlFiles) { final VirtualFile vXmlFile = xmlFile.getVirtualFile(); @@ -330,6 +336,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { final List annotationFiles = new ArrayList(xmlFiles); new WriteCommandAction(project) { + @Override protected void run(final Result result) throws Throwable { if (annotationsXml[0] == null) { annotationsXml[0] = createAnnotationsXml(file, packageName); @@ -343,8 +350,9 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { }.execute(); } + @Override public boolean deannotate(@NotNull final PsiModifierListOwner listOwner, @NotNull final String annotationFQN) { - final List files = findExternalAnnotationsFile(listOwner); + final List files = findExternalAnnotationsFiles(listOwner); if (files != null) { for (XmlFile file : files) { if (file.isValid()) { @@ -359,7 +367,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { if (Comparing.strEqual(className, externalName) || Comparing.strEqual(className, oldExternalName)) { for (XmlTag annotationTag : tag.getSubTags()) { if (Comparing.strEqual(annotationTag.getAttributeValue("name"), annotationFQN)) { - if (ReadonlyStatusHandler.getInstance(file.getProject()) + if (ReadonlyStatusHandler.getInstance(myPsiManager.getProject()) .ensureFilesWritable(file.getVirtualFile()).hasReadonlyFiles()) { return false; } @@ -386,11 +394,12 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { return false; } + @Override @NotNull public AnnotationPlace chooseAnnotationsPlace(@NotNull final PsiElement element) { if (!element.isPhysical()) return AnnotationPlace.IN_CODE; //element just created if (!element.getManager().isInProject(element)) return AnnotationPlace.EXTERNAL; - final Project project = element.getProject(); + final Project project = myPsiManager.getProject(); final PsiFile containingFile = element.getContainingFile(); final VirtualFile virtualFile = containingFile.getVirtualFile(); LOG.assertTrue(virtualFile != null); @@ -472,7 +481,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { myExternalAnnotations.clear(); } - private static void annotateExternally(final PsiModifierListOwner listOwner, + private void annotateExternally(final PsiModifierListOwner listOwner, final String annotationFQName, @Nullable final XmlFile xmlFile, @NotNull PsiFile codeUsageFile, @@ -492,7 +501,8 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { break; } } - tag.add(XmlElementFactory.getInstance(xmlFile.getProject()).createTagFromText(createAnnotationTag(annotationFQName, values))); + tag.add(XmlElementFactory.getInstance(myPsiManager.getProject()).createTagFromText( + createAnnotationTag(annotationFQName, values))); return; } } @@ -500,7 +510,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { "\n"; text += createAnnotationTag(annotationFQName, values); text += ""; - rootTag.add(XmlElementFactory.getInstance(xmlFile.getProject()).createTagFromText(text)); + rootTag.add(XmlElementFactory.getInstance(myPsiManager.getProject()).createTagFromText(text)); } } } @@ -520,13 +530,13 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { if (values != null) { text = " \n"; text += StringUtil.join(values, new Function() { + @NonNls @NotNull @Override public String fun(@NotNull PsiNameValuePair pair) { - if (pair.getName() != null) { - return ""; - } - return ""; + return ""; } }, " \n"); text += " "; @@ -572,8 +582,8 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { } @Nullable - private List findExternalAnnotationsFile(@NotNull PsiModifierListOwner listOwner) { - final Project project = listOwner.getProject(); + private List findExternalAnnotationsFiles(@NotNull PsiModifierListOwner listOwner) { + final Project project = myPsiManager.getProject(); final PsiFile containingFile = listOwner.getContainingFile(); if (!(containingFile instanceof PsiJavaFile)) { return null; @@ -672,15 +682,18 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { init(); } + @Override protected String getOkActionName() { return ADD_IN_CODE; } + @Override @NotNull protected String getCancelActionName() { return CommonBundle.getCancelButtonText(); } + @Override @NotNull @SuppressWarnings({"NonStaticInitializer"}) protected Action[] createActions() { @@ -692,6 +705,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { assignMnemonic(externalName, this); } + @Override public void actionPerformed(final ActionEvent e) { if (canBeHidden()) { setToBeShown(toBeShown(), true); @@ -701,20 +715,24 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { }, getCancelAction()}; } + @Override protected boolean isToBeShown() { return CodeStyleSettingsManager.getSettings(myProject).USE_EXTERNAL_ANNOTATIONS; } + @Override protected void setToBeShown(boolean value, boolean onOk) { CodeStyleSettingsManager.getSettings(myProject).USE_EXTERNAL_ANNOTATIONS = value; } + @Override protected JComponent createNorthPanel() { final JPanel northPanel = (JPanel)super.createNorthPanel(); northPanel.add(new JLabel(MESSAGE), BorderLayout.CENTER); return northPanel; } + @Override protected boolean shouldSaveOptionsOnCancel() { return true; } From 6ac2ab2e779873e9df3c8f8c660a7168a336fce9 Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 19 Mar 2012 13:09:54 +0400 Subject: [PATCH 15/50] Throve library for git4idea --- plugins/git4idea/git4idea.iml | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/git4idea/git4idea.iml b/plugins/git4idea/git4idea.iml index 733b2cb41b6a..a6f6343628fd 100644 --- a/plugins/git4idea/git4idea.iml +++ b/plugins/git4idea/git4idea.iml @@ -71,6 +71,7 @@ + From bf65902a6d1a8aaa50787bd6805c980900844cab Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Mon, 19 Mar 2012 13:10:02 +0400 Subject: [PATCH 16/50] AnnotationsEditor. Toolbar decorator. --- .../ui/configuration/AnnotationsEditor.java | 117 ++++++------------ 1 file changed, 36 insertions(+), 81 deletions(-) diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/AnnotationsEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/AnnotationsEditor.java index 082ecbaef263..0f0e88489a7e 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/AnnotationsEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/AnnotationsEditor.java @@ -22,23 +22,17 @@ import com.intellij.openapi.project.ProjectBundle; import com.intellij.openapi.roots.AnnotationOrderRootType; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.ui.ColoredTableCellRenderer; -import com.intellij.ui.ScrollPaneFactory; -import com.intellij.ui.TableUtil; +import com.intellij.ui.*; import com.intellij.ui.components.JBLabel; +import com.intellij.ui.table.JBTable; import com.intellij.util.ArrayUtil; import com.intellij.util.ui.ItemRemovable; -import com.intellij.util.ui.Table; import com.intellij.util.ui.UIUtil; import javax.swing.*; import javax.swing.border.Border; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.util.List; /** @@ -48,8 +42,6 @@ import java.util.List; */ public class AnnotationsEditor extends ModuleElementsEditor { private JTable myTable; - private JButton myAddPathButton; - private JButton myRemoveButton; public static final String NAME = ProjectBundle.message("project.roots.external.annotations.tab.title"); public static final Icon ICON = IconLoader.getIcon("/modules/annotation.png"); @@ -82,10 +74,8 @@ public class AnnotationsEditor extends ModuleElementsEditor { } public JComponent createComponentImpl() { - final JPanel mainPanel = new JPanel(new BorderLayout(5, 10)); - mainPanel.setPreferredSize(new Dimension(-1, 200)); final DefaultTableModel tableModel = createModel(); - myTable = new Table(tableModel); + myTable = new JBTable(tableModel); myTable.setIntercellSpacing(new Dimension(0, 0)); myTable.setDefaultRenderer(TableItem.class, new MyRenderer()); myTable.setShowGrid(false); @@ -94,43 +84,43 @@ public class AnnotationsEditor extends ModuleElementsEditor { myTable.setShowVerticalLines(false); myTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - myAddPathButton = new JButton(ProjectBundle.message("module.javadoc.add.path.button")); - myAddPathButton.addActionListener(new AddPathActionListener()); - - - myRemoveButton = new JButton(ProjectBundle.message("module.javadoc.remove.button")); - myRemoveButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - final List removedItems = TableUtil.removeSelectedItems(myTable); - if (removedItems.size() > 0) { + JPanel tablePanel = ToolbarDecorator.createDecorator(myTable) + .setAddAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + FileChooserDescriptor myDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); + myDescriptor.setTitle(ProjectBundle.message("add.external.annotations.path.title")); + myDescriptor.setDescription(ProjectBundle.message("add.external.annotations.path.description")); + VirtualFile[] files = FileChooser.chooseFiles(myTable, myDescriptor); + final MyTableModel tableModel = (MyTableModel)myTable.getModel(); + boolean changes = false; + for (final VirtualFile file : files) { + if (file != null) { + tableModel.addTableItem(new TableItem(file)); + changes = true; + } + } + if (changes) { saveData(); + TableUtil.selectRows(myTable, new int[] {tableModel.getRowCount() - 1}); } } - }); - - final JPanel panel = new JPanel(new GridBagLayout()); - panel.add(myAddPathButton, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - panel.add(myRemoveButton, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 0), 0, 0)); - - mainPanel.add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER); - mainPanel.add(panel, BorderLayout.EAST); - mainPanel.add(new JBLabel(ProjectBundle.message("project.roots.external.annotations.description"), UIUtil.ComponentStyle.SMALL, UIUtil.FontColor.BRIGHTER), BorderLayout.NORTH); - - myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - if (e.getValueIsAdjusting()) { - return; + }).setRemoveAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + final List removedItems = TableUtil.removeSelectedItems(myTable); + if (removedItems.size() > 0) { + saveData(); + } } - final int selectedIndex = myTable.getSelectedRow(); - myRemoveButton.setEnabled(selectedIndex >= 0); - } - }); - if (tableModel.getRowCount() > 0) { - TableUtil.selectRows(myTable, new int[] {0}); - } - else { - myRemoveButton.setEnabled(false); - } + }).createPanel(); + + + final JPanel mainPanel = new JPanel(new BorderLayout()); + + mainPanel.add(tablePanel, BorderLayout.CENTER); + mainPanel.add(new JBLabel(ProjectBundle.message("project.roots.external.annotations.description"), UIUtil.ComponentStyle.SMALL, + UIUtil.FontColor.BRIGHTER), BorderLayout.NORTH); return mainPanel; } @@ -147,7 +137,6 @@ public class AnnotationsEditor extends ModuleElementsEditor { if (myTable != null) { final DefaultTableModel tableModel = createModel(); myTable.setModel(tableModel); - myRemoveButton.setEnabled(tableModel.getRowCount() > 0); } } @@ -189,38 +178,4 @@ public class AnnotationsEditor extends ModuleElementsEditor { addRow(new Object[] {item}); } } - - private abstract class MyAddAction implements ActionListener { - protected abstract VirtualFile[] getFiles(); - - public void actionPerformed(ActionEvent e) { - VirtualFile[] files = getFiles(); - final MyTableModel tableModel = (MyTableModel)myTable.getModel(); - boolean changes = false; - for (final VirtualFile file : files) { - if (file != null) { - tableModel.addTableItem(new TableItem(file)); - changes = true; - } - } - if (changes) { - saveData(); - TableUtil.selectRows(myTable, new int[] {tableModel.getRowCount() - 1}); - } - } - } - - private class AddPathActionListener extends MyAddAction{ - private final FileChooserDescriptor myDescriptor; - - public AddPathActionListener() { - myDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); - myDescriptor.setTitle(ProjectBundle.message("add.external.annotations.path.title")); - myDescriptor.setDescription(ProjectBundle.message("add.external.annotations.path.description")); - } - - protected VirtualFile[] getFiles() { - return FileChooser.chooseFiles(myTable, myDescriptor); - } - } } From db49adf62343537ec4a1d8c2f378ae35a15783af Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 19 Mar 2012 10:16:45 +0100 Subject: [PATCH 17/50] IDEA-83009 (Exception without arguments false positive: shouldn't trigger on exception classes with no visible constructors) --- .../siyeh/InspectionGadgetsBundle.properties | 1 + ...ewExceptionWithoutArgumentsInspection.java | 45 +++++++++++++++---- .../NewExceptionWithoutArguments.html | 6 ++- .../NewExceptionWithoutArguments.java | 16 +++++++ .../expected.xml | 11 +++++ ...ceptionWithoutArgumentsInspectionTest.java | 13 ++++++ 6 files changed, 81 insertions(+), 11 deletions(-) create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/NewExceptionWithoutArguments.java create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/expected.xml create mode 100644 plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspectionTest.java diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties index a1a6f8eab86d..adc47a6ce812 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties @@ -1960,6 +1960,7 @@ unclear.binary.expression.problem.descriptor=Expression could use clarifying par unclear.binary.expression.quickfix=Add clarifying parentheses new.exception.without.arguments.display.name=Exception constructor called without arguments new.exception.without.arguments.problem.descriptor=new #ref() without arguments #loc +new.exception.without.arguments.ignore.option=Ignore for exceptions that have no constructors with parameters absolute.alignment.in.user.interface.display.name=Absolute alignment used in AWT/Swing code absolute.alignment.in.user.interface.problem.descriptor=Absolute alignment constant {0}.#ref used #loc absolute.alignment.in.user.interface.quickfix=Replace with ''{0}.{1}'' diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspection.java index b6453a340e03..7355df374b26 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspection.java @@ -15,14 +15,22 @@ */ package com.siyeh.ig.errorhandling; +import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel; import com.intellij.psi.*; -import com.intellij.psi.search.GlobalSearchScope; -import com.siyeh.InspectionGadgetsBundle;import com.siyeh.ig.BaseInspection; +import com.intellij.psi.util.InheritanceUtil; +import com.siyeh.InspectionGadgetsBundle; +import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import javax.swing.*; + public class NewExceptionWithoutArgumentsInspection extends BaseInspection { + + @SuppressWarnings("PublicField") + public boolean ignoreWithoutParameters = false; + @Nls @NotNull @Override @@ -36,12 +44,18 @@ public class NewExceptionWithoutArgumentsInspection extends BaseInspection { return InspectionGadgetsBundle.message("new.exception.without.arguments.problem.descriptor"); } + @Override + public JComponent createOptionsPanel() { + return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message("new.exception.without.arguments.ignore.option"), this, + "ignoreWithoutParameters"); + } + @Override public BaseInspectionVisitor buildVisitor() { return new NewExceptionWithoutArgumentsVisitor(); } - private static class NewExceptionWithoutArgumentsVisitor extends BaseInspectionVisitor { + private class NewExceptionWithoutArgumentsVisitor extends BaseInspectionVisitor { @Override public void visitNewExpression(PsiNewExpression expression) { @@ -63,16 +77,29 @@ public class NewExceptionWithoutArgumentsInspection extends BaseInspection { return; } final PsiClass aClass = (PsiClass)target; - final GlobalSearchScope resolveScope = expression.getResolveScope(); - final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(expression.getProject()); - final PsiClass exceptionClass = psiFacade.findClass(CommonClassNames.JAVA_LANG_EXCEPTION, resolveScope); - if (exceptionClass == null) { + if (!InheritanceUtil.isInheritor(aClass, CommonClassNames.JAVA_LANG_EXCEPTION)) { return; } - if (!aClass.isInheritor(exceptionClass, true)) { - return; + if (ignoreWithoutParameters) { + if (!hasAccessibleConstructorWithParameters(aClass, expression)) return; } registerNewExpressionError(expression); } + + private boolean hasAccessibleConstructorWithParameters(PsiClass aClass, PsiElement context) { + final PsiMethod[] constructors = aClass.getConstructors(); + for (PsiMethod constructor : constructors) { + final PsiParameterList parameterList = constructor.getParameterList(); + final int count = parameterList.getParametersCount(); + if (count <= 0) { + continue; + } + final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(context.getProject()).getResolveHelper(); + if (resolveHelper.isAccessible(constructor, context, aClass)) { + return true; + } + } + return false; + } } } diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NewExceptionWithoutArguments.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NewExceptionWithoutArguments.html index dd38673c63b7..5ce387634751 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/NewExceptionWithoutArguments.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NewExceptionWithoutArguments.html @@ -1,7 +1,9 @@ -This inspection reports construction of exceptions without arguments. When an exception is constructed without arguments it contains no -information about the fault that happened, which makes debugging needlessly hard. +This inspection reports exception instance creation without any arguments specified. When an exception is constructed +without arguments it contains no information about the fault that happened, which makes debugging needlessly hard. +

+Use the checkbox below to ignore instance creation of exception classes which have no constructors that take arguments.

New in 11, Powered by InspectionGadgets diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/NewExceptionWithoutArguments.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/NewExceptionWithoutArguments.java new file mode 100644 index 000000000000..f563cab3b3c1 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/NewExceptionWithoutArguments.java @@ -0,0 +1,16 @@ +package com.siyeh.igtest.errorhandling.new_exception_without_arguments; + +class NewExceptionWithoutArguments { + + void foo() { + throw new RuntimeException(); + } + + void bar() { + throw new MyException(); + } + +} +class MyException extends RuntimeException { + +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/expected.xml new file mode 100644 index 000000000000..3d60c6a05598 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/new_exception_without_arguments/expected.xml @@ -0,0 +1,11 @@ + + + + + NewExceptionWithoutArguments.java + 6 + Exception constructor called without arguments + <code>new RuntimeException()</code> without arguments #loc + + + \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspectionTest.java new file mode 100644 index 000000000000..fbd585cddfc8 --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/NewExceptionWithoutArgumentsInspectionTest.java @@ -0,0 +1,13 @@ +package com.siyeh.ig.errorhandling; + +import com.siyeh.ig.IGInspectionTestCase; + +public class NewExceptionWithoutArgumentsInspectionTest extends IGInspectionTestCase { + + public void test() throws Exception { + final NewExceptionWithoutArgumentsInspection tool = new NewExceptionWithoutArgumentsInspection(); + tool.ignoreWithoutParameters = true; + doTest("com/siyeh/igtest/errorhandling/new_exception_without_arguments", tool); + } + +} From feba90b13b59cd444a014f85520866a9c6e8b38c Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Mon, 19 Mar 2012 13:18:42 +0400 Subject: [PATCH 18/50] BuildFilePropertiesPanel. Toolbar decorator and some fixes. --- .../AntClasspathEditorPanel.form | 35 ++++--------- .../AntClasspathEditorPanel.java | 13 +---- .../BuildFilePropertiesPanel.java | 52 ++++++++++++++----- .../config/impl/configuration/FiltersTab.form | 14 ++--- .../impl/configuration/PropertiesTab.form | 52 ------------------- 5 files changed, 51 insertions(+), 115 deletions(-) delete mode 100644 plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/PropertiesTab.form diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.form b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.form index d68af3e02d70..0acb741d97e5 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.form +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.form @@ -1,18 +1,16 @@

- + - - - + @@ -20,8 +18,7 @@ - - + @@ -29,8 +26,7 @@ - - + @@ -38,8 +34,7 @@ - - + @@ -47,14 +42,12 @@ - - + - + - - + @@ -65,19 +58,9 @@ - - - - - - - - - - - + diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.java index c71c6b5f0e37..53fded553a8a 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/AntClasspathEditorPanel.java @@ -18,7 +18,6 @@ package com.intellij.lang.ant.config.impl.configuration; import com.intellij.lang.ant.config.impl.AllJarsUnderDirEntry; import com.intellij.lang.ant.config.impl.AntClasspathEntry; import com.intellij.lang.ant.config.impl.SinglePathEntry; -import com.intellij.openapi.ui.LabeledComponent; import com.intellij.ui.ListUtil; import com.intellij.util.config.AbstractProperty; import com.intellij.util.config.ListProperty; @@ -68,19 +67,17 @@ public class AntClasspathEditorPanel extends JPanel { return myBinding; } - private static class Form { + public static class Form { private JButton myAddButton; private JButton myAddAllInDir; private JButton myRemoveButton; private JButton myMoveUpButton; private JButton myMoveDownButton; private JPanel myWholePanel; - private JLabel myClasspathLabel; private JList myClasspathList; private final ArrayList myUpdatables = new ArrayList(); public Form() { - myClasspathLabel.setLabelFor(myClasspathList); myClasspathList.setCellRenderer(new AntUIUtil.ClasspathRenderer()); myUpdatables.add(ListUtil.addRemoveListener(myRemoveButton, myClasspathList)); @@ -96,14 +93,6 @@ public class AntClasspathEditorPanel extends JPanel { } } - public void setClasspathLabel(String textWithMnemonic) { - LabeledComponent.TextWithMnemonic.fromTextWithMnemonic(textWithMnemonic).setToLabel(myForm.myClasspathLabel); - } - - public String getClasspathLabel() { - return LabeledComponent.TextWithMnemonic.fromLabel(myForm.myClasspathLabel).getTextWithMnemonic(); - } - public JComponent getPreferedFocusComponent() { return myForm.myClasspathList; } diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/BuildFilePropertiesPanel.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/BuildFilePropertiesPanel.java index 9cbb98c13ce2..e2ad3ac39e05 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/BuildFilePropertiesPanel.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/BuildFilePropertiesPanel.java @@ -28,16 +28,13 @@ import com.intellij.openapi.projectRoots.ui.ProjectJdksEditor; import com.intellij.openapi.ui.ComponentWithBrowseButton; import com.intellij.openapi.ui.DialogBuilder; import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Disposer; -import com.intellij.ui.ComboboxWithBrowseButton; -import com.intellij.ui.RawCommandLineEditor; -import com.intellij.ui.SimpleColoredComponent; -import com.intellij.ui.TabbedPaneWrapper; -import com.intellij.util.NewInstanceFactory; +import com.intellij.ui.*; +import com.intellij.ui.table.JBTable; import com.intellij.util.config.AbstractProperty; import com.intellij.util.containers.Convertor; import com.intellij.util.ui.ColumnInfo; +import com.intellij.util.ui.ListTableModel; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -197,8 +194,6 @@ public class BuildFilePropertiesPanel { } private static class PropertiesTab extends Tab { - private JButton myAddButton; - private JButton myRemoveButton; private JTable myPropertiesTable; private JPanel myWholePanel; @@ -237,11 +232,41 @@ public class BuildFilePropertiesPanel { private static final ColumnInfo[] PROPERTY_COLUMNS = new ColumnInfo[]{NAME_COLUMN, VALUE_COLUMN}; public PropertiesTab() { + myPropertiesTable = new JBTable(); UIPropertyBinding.TableListBinding tableListBinding = getBinding().bindList(myPropertiesTable, PROPERTY_COLUMNS, - AntBuildFileImpl.ANT_PROPERTIES); + AntBuildFileImpl.ANT_PROPERTIES); tableListBinding.setColumnWidths(GlobalAntConfiguration.PROPERTIES_TABLE_LAYOUT); - tableListBinding.addAddFacility(myAddButton, NewInstanceFactory.fromClass(BuildFileProperty.class)); - tableListBinding.addRemoveFacility(myRemoveButton, Condition.TRUE); + + myWholePanel = ToolbarDecorator.createDecorator(myPropertiesTable) + .setAddAction(new AnActionButtonRunnable() { + + + @Override + public void run(AnActionButton button) { + if (myPropertiesTable.isEditing() && !myPropertiesTable.getCellEditor().stopCellEditing()) { + return; + } + BuildFileProperty item = new BuildFileProperty(); + ListTableModel model = (ListTableModel)myPropertiesTable.getModel(); + ArrayList items = new ArrayList(model.getItems()); + items.add(item); + model.setItems(items); + int newIndex = model.indexOf(item); + ListSelectionModel selectionModel = myPropertiesTable.getSelectionModel(); + selectionModel.clearSelection(); + selectionModel.setSelectionInterval(newIndex, newIndex); + ColumnInfo[] columns = model.getColumnInfos(); + for (int i = 0; i < columns.length; i++) { + ColumnInfo column = columns[i]; + if (column.isCellEditable(item)) { + myPropertiesTable.requestFocusInWindow(); + myPropertiesTable.editCellAt(newIndex, i); + break; + } + } + } + }).disableUpDownActions().createPanel(); + myWholePanel.setBorder(null); } public JComponent getComponent() { @@ -288,9 +313,9 @@ public class BuildFilePropertiesPanel { private static final Comparator NAME_COMPARATOR = new Comparator() { public int compare(TargetFilter o1, TargetFilter o2) { final String name1 = o1.getTargetName(); - if(name1 == null) return -1; + if (name1 == null) return -1; final String name2 = o2.getTargetName(); - if(name2 == null) return 1; + if (name2 == null) return 1; return name1.compareToIgnoreCase(name2); } }; @@ -482,5 +507,4 @@ public class BuildFilePropertiesPanel { private static void setLabelFor(JLabel label, ComponentWithBrowseButton component) { label.setLabelFor(component.getChildComponent()); } - } diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/FiltersTab.form b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/FiltersTab.form index 33932c1f1244..5083f5d7a604 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/FiltersTab.form +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/FiltersTab.form @@ -1,24 +1,16 @@ - - + + - - - - - - - - - + diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/PropertiesTab.form b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/PropertiesTab.form deleted file mode 100644 index 77e09e903231..000000000000 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/PropertiesTab.form +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 5100643f057d778d6b4a01c7177e6c68c0274644 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Mon, 19 Mar 2012 13:24:42 +0400 Subject: [PATCH 19/50] JavadocEditor. Toolbar decorator. --- .../roots/ui/configuration/JavadocEditor.java | 159 +++++++----------- 1 file changed, 61 insertions(+), 98 deletions(-) diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavadocEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavadocEditor.java index 4cbb4489199b..aed4f1931ebc 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavadocEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavadocEditor.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.roots.ui.configuration; +import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; @@ -23,35 +24,27 @@ import com.intellij.openapi.projectRoots.ui.Util; import com.intellij.openapi.roots.JavadocOrderRootType; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.ui.ColoredTableCellRenderer; -import com.intellij.ui.ScrollPaneFactory; -import com.intellij.ui.TableUtil; +import com.intellij.ui.*; import com.intellij.ui.components.JBLabel; +import com.intellij.ui.table.JBTable; import com.intellij.util.ArrayUtil; +import com.intellij.util.PlatformIcons; import com.intellij.util.ui.ItemRemovable; -import com.intellij.util.ui.Table; import com.intellij.util.ui.UIUtil; import javax.swing.*; import javax.swing.border.Border; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.util.List; /** * @author Eugene Zhuravlev - * Date: Oct 4, 2003 - * Time: 6:54:57 PM + * Date: Oct 4, 2003 + * Time: 6:54:57 PM */ public class JavadocEditor extends ModuleElementsEditor { private JTable myTable; - private JButton myAddPathButton; - private JButton myAddUrlButton; - private JButton myRemoveButton; public static final String NAME = ProjectBundle.message("module.javadoc.title"); public static final Icon ICON = IconLoader.getIcon("/modules/javadoc.png"); @@ -84,9 +77,8 @@ public class JavadocEditor extends ModuleElementsEditor { } public JComponent createComponentImpl() { - final JPanel mainPanel = new JPanel(new BorderLayout(5, 10)); final DefaultTableModel tableModel = createModel(); - myTable = new Table(tableModel); + myTable = new JBTable(tableModel); myTable.setIntercellSpacing(new Dimension(0, 0)); myTable.setDefaultRenderer(TableItem.class, new MyRenderer()); myTable.setShowGrid(false); @@ -95,46 +87,59 @@ public class JavadocEditor extends ModuleElementsEditor { myTable.setShowVerticalLines(false); myTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - myAddPathButton = new JButton(ProjectBundle.message("module.javadoc.add.path.button")); - myAddPathButton.addActionListener(new AddPathActionListener()); - - myAddUrlButton = new JButton(ProjectBundle.message("module.javadoc.add.url.button")); - myAddUrlButton.addActionListener(new AddUrlActionListener()); - - myRemoveButton = new JButton(ProjectBundle.message("module.javadoc.remove.button")); - myRemoveButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - final List removedItems = TableUtil.removeSelectedItems(myTable); - if (removedItems.size() > 0) { - saveData(); + JPanel tablePanel = ToolbarDecorator.createDecorator(myTable) + .setAddAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + FileChooserDescriptor myDescriptor = FileChooserDescriptorFactory.createMultipleJavaPathDescriptor(); + myDescriptor.setTitle(ProjectBundle.message("module.javadoc.add.path.title")); + myDescriptor.setDescription(ProjectBundle.message("module.javadoc.add.path.prompt")); + VirtualFile[] files = FileChooser.chooseFiles(myTable, myDescriptor); + final MyTableModel tableModel = (MyTableModel)myTable.getModel(); + boolean changes = false; + for (final VirtualFile file : files) { + if (file != null) { + tableModel.addTableItem(new TableItem(file)); + changes = true; + } + } + if (changes) { + saveData(); + TableUtil.selectRows(myTable, new int[]{tableModel.getRowCount() - 1}); + } } - } - }); - - final JPanel panel = new JPanel(new GridBagLayout()); - panel.add(myAddPathButton, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - panel.add(myAddUrlButton, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 0), 0, 0)); - panel.add(myRemoveButton, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 0), 0, 0)); - - mainPanel.add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER); - mainPanel.add(panel, BorderLayout.EAST); - mainPanel.add(new JBLabel(ProjectBundle.message("project.roots.javadoc.tab.description"), UIUtil.ComponentStyle.SMALL, UIUtil.FontColor.BRIGHTER), BorderLayout.NORTH); - - myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - if (e.getValueIsAdjusting()) { - return; + }).addExtraAction(new AnActionButton(ProjectBundle.message("module.javadoc.add.url.button"), PlatformIcons.TABLE_URL) { + @Override + public void actionPerformed(AnActionEvent e) { + VirtualFile[] files = new VirtualFile[]{Util.showSpecifyJavadocUrlDialog(myTable)}; + final MyTableModel tableModel = (MyTableModel)myTable.getModel(); + boolean changes = false; + for (final VirtualFile file : files) { + if (file != null) { + tableModel.addTableItem(new TableItem(file)); + changes = true; + } + } + if (changes) { + saveData(); + TableUtil.selectRows(myTable, new int[]{tableModel.getRowCount() - 1}); + } } - final int selectedIndex = myTable.getSelectedRow(); - myRemoveButton.setEnabled(selectedIndex >= 0); - } - }); - if (tableModel.getRowCount() > 0) { - TableUtil.selectRows(myTable, new int[] {0}); - } - else { - myRemoveButton.setEnabled(false); - } + }).setRemoveAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + final List removedItems = TableUtil.removeSelectedItems(myTable); + if (removedItems.size() > 0) { + saveData(); + } + } + }).createPanel(); + + final JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(tablePanel, BorderLayout.CENTER); + mainPanel.add( + new JBLabel(ProjectBundle.message("project.roots.javadoc.tab.description"), UIUtil.ComponentStyle.SMALL, UIUtil.FontColor.BRIGHTER), + BorderLayout.NORTH); return mainPanel; } @@ -151,7 +156,6 @@ public class JavadocEditor extends ModuleElementsEditor { if (myTable != null) { final DefaultTableModel tableModel = createModel(); myTable.setModel(tableModel); - myRemoveButton.setEnabled(tableModel.getRowCount() > 0); } } @@ -170,7 +174,7 @@ public class JavadocEditor extends ModuleElementsEditor { } } - private static class MyTableModel extends DefaultTableModel implements ItemRemovable{ + private static class MyTableModel extends DefaultTableModel implements ItemRemovable { public String getColumnName(int column) { return null; } @@ -192,48 +196,7 @@ public class JavadocEditor extends ModuleElementsEditor { } public void addTableItem(TableItem item) { - addRow(new Object[] {item}); + addRow(new Object[]{item}); } } - - private abstract class MyAddAction implements ActionListener { - protected abstract VirtualFile[] getFiles(); - - public void actionPerformed(ActionEvent e) { - VirtualFile[] files = getFiles(); - final MyTableModel tableModel = (MyTableModel)myTable.getModel(); - boolean changes = false; - for (final VirtualFile file : files) { - if (file != null) { - tableModel.addTableItem(new TableItem(file)); - changes = true; - } - } - if (changes) { - saveData(); - TableUtil.selectRows(myTable, new int[] {tableModel.getRowCount() - 1}); - } - } - } - - private class AddUrlActionListener extends MyAddAction{ - protected VirtualFile[] getFiles() { - return new VirtualFile[] {Util.showSpecifyJavadocUrlDialog(myTable)}; - } - } - - private class AddPathActionListener extends MyAddAction{ - private final FileChooserDescriptor myDescriptor; - - public AddPathActionListener() { - myDescriptor = FileChooserDescriptorFactory.createMultipleJavaPathDescriptor(); - myDescriptor.setTitle(ProjectBundle.message("module.javadoc.add.path.title")); - myDescriptor.setDescription(ProjectBundle.message("module.javadoc.add.path.prompt")); - } - - protected VirtualFile[] getFiles() { - final VirtualFile[] files = FileChooser.chooseFiles(myTable, myDescriptor); - return (files != null)? files : VirtualFile.EMPTY_ARRAY; - } - } -} +} \ No newline at end of file From 163bd4061229815a53c0adb332db0ca282ff1585 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Mon, 19 Mar 2012 13:25:47 +0400 Subject: [PATCH 20/50] TagListDialog. Toolbar decorator. --- .../application/options/TagListDialog.java | 113 ++++++------------ 1 file changed, 37 insertions(+), 76 deletions(-) diff --git a/xml/impl/src/com/intellij/application/options/TagListDialog.java b/xml/impl/src/com/intellij/application/options/TagListDialog.java index 5c681cd37df3..9cdb941078a1 100644 --- a/xml/impl/src/com/intellij/application/options/TagListDialog.java +++ b/xml/impl/src/com/intellij/application/options/TagListDialog.java @@ -15,28 +15,55 @@ */ package com.intellij.application.options; -import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ApplicationBundle; -import com.intellij.openapi.roots.ui.configuration.actions.IconWithTextAction; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; -import com.intellij.ui.ScrollPaneFactory; +import com.intellij.ui.AnActionButton; +import com.intellij.ui.AnActionButtonRunnable; +import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.components.JBList; -import com.intellij.util.PlatformIcons; import javax.swing.*; -import java.awt.*; import java.util.ArrayList; -public class TagListDialog extends DialogWrapper{ - private final JPanel myPanel = new JPanel(new BorderLayout()); +public class TagListDialog extends DialogWrapper { + private final JPanel myPanel; private final JList myList = new JBList(new DefaultListModel()); private ArrayList myData; public TagListDialog(String title) { super(true); - myPanel.add(createToolbar(), BorderLayout.NORTH); - myPanel.add(createList(), BorderLayout.CENTER); + myPanel = ToolbarDecorator.createDecorator(myList) + .setAddAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + final String tagName = Messages.showInputDialog(ApplicationBundle.message("editbox.enter.tag.name"), + ApplicationBundle.message("title.tag.name"), Messages.getQuestionIcon()); + if (tagName != null) { + while (myData.contains(tagName)) { + myData.remove(tagName); + } + myData.add(tagName); + updateData(); + myList.setSelectedIndex(myData.size() - 1); + } + } + }).setRemoveAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + int selectedIndex = myList.getSelectedIndex(); + if (selectedIndex >= 0) { + myData.remove(selectedIndex); + updateData(); + if (selectedIndex >= myData.size()) { + selectedIndex -= 1; + } + if (selectedIndex >= 0) { + myList.setSelectedIndex(selectedIndex); + } + } + } + }).disableUpDownActions().createPanel(); setTitle(title); init(); } @@ -57,76 +84,10 @@ public class TagListDialog extends DialogWrapper{ } } - public ArrayList getData(){ + public ArrayList getData() { return myData; } - private JComponent createList() { - return ScrollPaneFactory.createScrollPane(myList); - } - - private JComponent createToolbar() { - return ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, - createActionGroup(), - true).getComponent(); - } - - private ActionGroup createActionGroup() { - final DefaultActionGroup result = new DefaultActionGroup(); - final AnAction addAction = createAddAction(); - addAction.registerCustomShortcutSet(CommonShortcuts.INSERT, myList); - result.add(addAction); - - final AnAction deleteAction = createDeleteAction(); - deleteAction.registerCustomShortcutSet(CommonShortcuts.DELETE, myList); - result.add(deleteAction); - return result; - } - - private AnAction createDeleteAction() { - return new IconWithTextAction(ApplicationBundle.message("action.remove"), null, PlatformIcons.DELETE_ICON) { - public void update(AnActionEvent e) { - final int selectedIndex = myList.getSelectedIndex(); - if (selectedIndex >= 0) { - e.getPresentation().setEnabled(true); - } else { - e.getPresentation().setEnabled(false); - } - } - - public void actionPerformed(AnActionEvent e) { - int selectedIndex = myList.getSelectedIndex(); - if (selectedIndex >= 0) { - myData.remove(selectedIndex); - updateData(); - if (selectedIndex >= myData.size()) { - selectedIndex -= 1; - } - if (selectedIndex >= 0) { - myList.setSelectedIndex(selectedIndex); - } - } - } - }; - } - - private AnAction createAddAction() { - return new IconWithTextAction(ApplicationBundle.message("action.add"), null, PlatformIcons.ADD_ICON){ - public void actionPerformed(AnActionEvent e) { - final String tagName = Messages.showInputDialog(ApplicationBundle.message("editbox.enter.tag.name"), - ApplicationBundle.message("title.tag.name"), Messages.getQuestionIcon()); - if (tagName != null) { - while (myData.contains(tagName)) { - myData.remove(tagName); - } - myData.add(tagName); - updateData(); - myList.setSelectedIndex(myData.size() - 1); - } - } - }; - } - protected JComponent createCenterPanel() { return myPanel; } From 167740c9b9b46c081f497845416d90d09e03035e Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Mon, 19 Mar 2012 13:27:24 +0400 Subject: [PATCH 21/50] Some UI fixes --- .../javaCompiler/jikes/JikesConfigurable.java | 10 +-- .../javaCompiler/jikes/JikesOptionsPanel.form | 47 ++++-------- .../compiler/options/ComparingUtils.java | 5 ++ .../openapi/projectRoots/ui/PathEditor.java | 61 ++++++++-------- .../jetbrains/idea/svn/SvnConfigurable.form | 3 + .../uiDesigner/GeneralConfigurable.form | 60 ++++++++-------- .../impl/AddAssociationAction.java | 7 +- .../associations/impl/AssociationsEditor.java | 3 +- .../xpathView/ui/EditContextDialog.java | 72 ++++++++----------- .../src/messages/CompilerBundle.properties | 2 +- 10 files changed, 118 insertions(+), 152 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesConfigurable.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesConfigurable.java index d9cc3f71b7a3..e5e5115108a7 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesConfigurable.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesConfigurable.java @@ -22,6 +22,7 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.ConfigurationException; +import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.RawCommandLineEditor; @@ -34,19 +35,18 @@ import java.io.File; * @author Eugene Zhuravlev * Date: Mar 30, 2004 */ -public class JikesConfigurable implements Configurable{ +public class JikesConfigurable implements Configurable { private JPanel myPanel; private JCheckBox myCbDebuggingInfo; private JCheckBox myCbDeprecation; - private JCheckBox myCbGenerateNoWarnings ; + private JCheckBox myCbGenerateNoWarnings; private RawCommandLineEditor myAdditionalOptionsField; - private JTextField myPathField; - private JButton myJikesPathFieldBrowseButton; + private TextFieldWithBrowseButton myPathField; private final JikesSettings myJikesSettings; public JikesConfigurable(JikesSettings jikesSettings) { myJikesSettings = jikesSettings; - myJikesPathFieldBrowseButton.addActionListener(new ActionListener() { + myPathField.getButton().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(); VirtualFile file = FileChooser.chooseFile(myPathField, descriptor, null); diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesOptionsPanel.form b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesOptionsPanel.form index ca0dbdd1fd4d..cf2cfb167190 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesOptionsPanel.form +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesOptionsPanel.form @@ -3,7 +3,7 @@ - + @@ -46,14 +46,20 @@ - - + + - + + + + + + + @@ -62,39 +68,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/java/compiler/impl/src/com/intellij/compiler/options/ComparingUtils.java b/java/compiler/impl/src/com/intellij/compiler/options/ComparingUtils.java index b85d0c1f94cf..bac1d24e9a48 100644 --- a/java/compiler/impl/src/com/intellij/compiler/options/ComparingUtils.java +++ b/java/compiler/impl/src/com/intellij/compiler/options/ComparingUtils.java @@ -15,6 +15,7 @@ */ package com.intellij.compiler.options; +import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.ui.RawCommandLineEditor; import javax.swing.*; @@ -24,6 +25,10 @@ import javax.swing.*; * Date: Mar 30, 2004 */ public class ComparingUtils { + public static boolean isModified(TextFieldWithBrowseButton field, String value) { + return !field.getText().equals(value); + } + public static boolean isModified(JCheckBox checkBox, boolean value) { return checkBox.isSelected() != value; } diff --git a/platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java b/platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java index 26732a0f1817..374c5adc6c39 100644 --- a/platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java +++ b/platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java @@ -113,46 +113,41 @@ public class PathEditor { myList = new JBList(getListModel()); myList.setCellRenderer(createListCellRenderer(myList)); - ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(myList).disableUpDownActions(); - toolbarDecorator.setAddAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - final VirtualFile[] added = doAdd(); - if (added.length > 0) { - setModified(true); + ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(myList).disableUpDownActions() + .setAddAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + final VirtualFile[] added = doAdd(); + if (added.length > 0) { + setModified(true); + } + requestDefaultFocus(); + setSelectedRoots(added); } - requestDefaultFocus(); - setSelectedRoots(added); - } - }); - - toolbarDecorator.setRemoveAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - int[] idxs = myList.getSelectedIndices(); - doRemoveItems(idxs, myList); - } - }); + }).setRemoveAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + int[] idxs = myList.getSelectedIndices(); + doRemoveItems(idxs, myList); + } + }).setAddActionUpdater(new AnActionButtonUpdater() { + @Override + public boolean isEnabled(AnActionEvent e) { + return myEnabled; + } + }).setRemoveActionUpdater(new AnActionButtonUpdater() { + @Override + public boolean isEnabled(AnActionEvent e) { + Object[] values = getSelectedRoots(); + return values.length > 0 && myEnabled; + } + }); addToolbarButtons(toolbarDecorator); myPanel = toolbarDecorator.createPanel(); myPanel.setBorder(null); - ToolbarDecorator.findAddButton(myPanel).addCustomUpdater(new AnActionButtonUpdater() { - @Override - public boolean isEnabled(AnActionEvent e) { - return myEnabled; - } - }); - ToolbarDecorator.findRemoveButton(myPanel).addCustomUpdater(new AnActionButtonUpdater() { - @Override - public boolean isEnabled(AnActionEvent e) { - Object[] values = getSelectedRoots(); - return values.length > 0 && myEnabled; - } - }); - return myPanel; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurable.form b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurable.form index 00f5d0b665c7..afb2ad4e7703 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurable.form +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurable.form @@ -266,6 +266,9 @@ + + + diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/GeneralConfigurable.form b/plugins/ui-designer/src/com/intellij/uiDesigner/GeneralConfigurable.form index 869561dda670..ff304500493e 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/GeneralConfigurable.form +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/GeneralConfigurable.form @@ -1,6 +1,6 @@
- + @@ -10,53 +10,53 @@ - + - + + - - - - - - - - - - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - + @@ -64,7 +64,7 @@ - + @@ -73,7 +73,7 @@ - + @@ -82,13 +82,13 @@ - + - + @@ -101,7 +101,7 @@ - + diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/AddAssociationAction.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/AddAssociationAction.java index 0b104a4af5c9..84371985dab9 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/AddAssociationAction.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/AddAssociationAction.java @@ -15,8 +15,6 @@ */ package org.intellij.lang.xpath.xslt.associations.impl; -import org.intellij.lang.xpath.xslt.associations.FileAssociationsManager; - import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; @@ -24,15 +22,16 @@ import com.intellij.openapi.actionSystem.LangDataKeys; import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; +import com.intellij.util.PlatformIcons; +import org.intellij.lang.xpath.xslt.associations.FileAssociationsManager; class AddAssociationAction extends AnAction { private final FileAssociationsManager myManager; public AddAssociationAction(FileAssociationsManager manager) { - super("Add...", "Add File Association", IconLoader.getIcon("/general/add.png")); + super("Add...", "Add File Association", PlatformIcons.TABLE_ADD_ROW); myManager = manager; } diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/AssociationsEditor.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/AssociationsEditor.java index 5e073fcc3957..f1f1faf0edac 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/AssociationsEditor.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/associations/impl/AssociationsEditor.java @@ -23,6 +23,7 @@ import com.intellij.ui.*; import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.treeStructure.Tree; +import com.intellij.util.PlatformIcons; import com.intellij.util.config.StorageAccessors; import com.intellij.util.ui.UIUtil; import org.intellij.lang.xpath.xslt.XsltSupport; @@ -224,7 +225,7 @@ class AssociationsEditor { class RemoveAssociationAction extends AnAction { public RemoveAssociationAction() { - super(null, "Remove Association", IconLoader.getIcon("/general/remove.png")); + super(null, "Remove Association", PlatformIcons.TABLE_REMOVE_ROW); } public void actionPerformed(AnActionEvent e) { diff --git a/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/ui/EditContextDialog.java b/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/ui/EditContextDialog.java index 2c00cecf867c..898bf0134082 100644 --- a/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/ui/EditContextDialog.java +++ b/plugins/xpath/xpath-view/src/org/intellij/plugins/xpathView/ui/EditContextDialog.java @@ -16,10 +16,10 @@ package org.intellij.plugins.xpathView.ui; import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.ide.DataManager; import com.intellij.javaee.ExternalResourceManager; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.LangDataKeys; +import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.fileTypes.LanguageFileType; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; @@ -30,8 +30,10 @@ import com.intellij.openapi.util.Pair; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; import com.intellij.psi.xml.XmlElement; -import com.intellij.ui.*; -import com.intellij.util.IconUtil; +import com.intellij.ui.AnActionButton; +import com.intellij.ui.AnActionButtonRunnable; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.ToolbarDecorator; import com.intellij.util.containers.BidirectionalMap; import com.intellij.util.ui.Table; import com.intellij.util.ui.UIUtil; @@ -120,19 +122,36 @@ public class EditContextDialog extends DialogWrapper { public void run(AnActionButton button) { myVariableTableModel.removeVariable(myVariableTable.getSelectedRow()); } - }).createPanel(); + }).disableUpDownActions().createPanel(); UIUtil.addBorder(p, IdeBorderFactory.createTitledBorder("Variables", false)); final JPanel n = ToolbarDecorator.createDecorator(myNamespaceTable) - .addExtraAction(myContextProvider.getContextElement() != null ? null : - AnActionButton.fromAction(new AddAction(myNamespaceTableModel, myUnresolvedPrefixes))) - .setRemoveAction( + .setAddAction(myContextProvider.getContextElement() != null ? null : new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + final ExternalResourceManager erm = ExternalResourceManager.getInstance(); + final List allURIs = new ArrayList(Arrays.asList(erm.getResourceUrls(null, true))); + final Collection namespaces = myNamespaceTableModel.getNamespaces(); + for (Namespace namespace : namespaces) { + allURIs.remove(namespace.getUri()); + } + Collections.sort(allURIs); + + final DataContext dataContext = DataManager.getInstance().getDataContext(myNamespaceTable); + final Project project = PlatformDataKeys.PROJECT.getData(dataContext); + final AddNamespaceDialog dlg = new AddNamespaceDialog(project, myUnresolvedPrefixes, allURIs, AddNamespaceDialog.Mode.EDITABLE); + dlg.show(); + if (dlg.isOK()) { + myNamespaceTableModel.addNamespace(new Namespace(dlg.getPrefix(), dlg.getURI())); + } + } + }).setRemoveAction( myContextProvider.getContextElement() != null ? null : new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { myNamespaceTableModel.removeNamespace(myNamespaceTable.getSelectedRow()); } - }).setButtonComparator("Add", "Remove").createPanel(); + }).disableUpDownActions().createPanel(); UIUtil.addBorder(n, IdeBorderFactory.createTitledBorder("Namespaces", false)); int extendedState = myDimensionService.getExtendedState(getDimensionServiceKey()); @@ -490,37 +509,4 @@ public class EditContextDialog extends DialogWrapper { return myContextProvider.getElements(forValidation); } } - - private static class AddAction extends AnAction { - private NamespaceTableModel myNamespaceTableModel; - private Set myUnresolvedPrefixes; - - public AddAction(NamespaceTableModel model, Set prefixes) { - super("Add", "Add", IconUtil.getAddRowIcon()); - myNamespaceTableModel = model; - myUnresolvedPrefixes = prefixes; - setShortcutSet(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.ADD)); - } - - public void update(AnActionEvent e) { - e.getPresentation().setEnabled(true); - } - - public void actionPerformed(AnActionEvent e) { - final ExternalResourceManager erm = ExternalResourceManager.getInstance(); - final List allURIs = new ArrayList(Arrays.asList(erm.getResourceUrls(null, true))); - final Collection namespaces = myNamespaceTableModel.getNamespaces(); - for (Namespace namespace : namespaces) { - allURIs.remove(namespace.getUri()); - } - Collections.sort(allURIs); - - final Project project = LangDataKeys.PROJECT.getData(e.getDataContext()); - final AddNamespaceDialog dlg = new AddNamespaceDialog(project, myUnresolvedPrefixes, allURIs, AddNamespaceDialog.Mode.EDITABLE); - dlg.show(); - if (dlg.isOK()) { - myNamespaceTableModel.addNamespace(new Namespace(dlg.getPrefix(), dlg.getURI())); - } - } - } } diff --git a/resources-en/src/messages/CompilerBundle.properties b/resources-en/src/messages/CompilerBundle.properties index 6d67ba3e3db7..bcac3fc731f1 100644 --- a/resources-en/src/messages/CompilerBundle.properties +++ b/resources-en/src/messages/CompilerBundle.properties @@ -121,7 +121,7 @@ java.compiler.option.generate.no.warnings=Generate no warnings java.compiler.option.generate.debugging.info=Generate debugging info java.compiler.option.report.deprecated=Report use of deprecated features javac.option.max.heap.size=Maximum heap size (MB): -jikes.option.path.to.executable= Path to Jikes executable: +jikes.option.path.to.executable=Path to Jikes executable: jikes.options.group.title=Jikes Options javac.options.group.title=Javac Options rmic.option.generate.iiop.stubs=Generate IIOP stubs From bbbc8644e29238b5a85b12e626decd37f733aae6 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Mon, 19 Mar 2012 13:33:36 +0400 Subject: [PATCH 22/50] Reparse for language dialects --- .../com/intellij/psi/impl/source/JavaDummyHolder.java | 8 ++++---- .../psi/impl/source/tree/JavaDocElementType.java | 3 ++- .../intellij/psi/impl/source/tree/JavaElementType.java | 2 +- .../com/intellij/psi/tree/IReparseableElementType.java | 6 +++--- .../src/com/intellij/psi/impl/source/DummyHolder.java | 10 +++++++++- .../psi/impl/source/text/BlockSupportImpl.java | 4 ++-- .../psi/tree/IErrorCounterReparseableElementType.java | 6 +++--- .../groovy/lang/parser/GrCodeBlockElementType.java | 3 ++- xml/impl/src/com/intellij/psi/xml/XmlElementType.java | 3 ++- 9 files changed, 28 insertions(+), 17 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/JavaDummyHolder.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/JavaDummyHolder.java index d03ec0fc0972..9580c45d0276 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/JavaDummyHolder.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/JavaDummyHolder.java @@ -35,7 +35,7 @@ public class JavaDummyHolder extends DummyHolder implements PsiImportHolder { private Map myPseudoImports = EMPTY; public JavaDummyHolder(@NotNull PsiManager manager, TreeElement contentElement, PsiElement context) { - super(manager, contentElement, context, null, null, JavaLanguage.INSTANCE); + super(manager, contentElement, context, null, null, language(context, JavaLanguage.INSTANCE)); } public JavaDummyHolder(@NotNull PsiManager manager, CharTable table, boolean validity) { @@ -43,15 +43,15 @@ public class JavaDummyHolder extends DummyHolder implements PsiImportHolder { } public JavaDummyHolder(@NotNull PsiManager manager, PsiElement context) { - super(manager, null, context, null, null, JavaLanguage.INSTANCE); + super(manager, null, context, null, null, language(context, JavaLanguage.INSTANCE)); } public JavaDummyHolder(@NotNull PsiManager manager, TreeElement contentElement, PsiElement context, CharTable table) { - super(manager, contentElement, context, table, null, JavaLanguage.INSTANCE); + super(manager, contentElement, context, table, null, language(context, JavaLanguage.INSTANCE)); } public JavaDummyHolder(@NotNull PsiManager manager, PsiElement context, CharTable table) { - super(manager, null, context, table, null, JavaLanguage.INSTANCE); + super(manager, null, context, table, null, language(context, JavaLanguage.INSTANCE)); } public JavaDummyHolder(@NotNull PsiManager manager, final CharTable table) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaDocElementType.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaDocElementType.java index acd68f964221..4c4776cb1653 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaDocElementType.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaDocElementType.java @@ -16,6 +16,7 @@ package com.intellij.psi.impl.source.tree; import com.intellij.lang.ASTNode; +import com.intellij.lang.Language; import com.intellij.lang.PsiBuilder; import com.intellij.lang.java.JavaLanguage; import com.intellij.lang.java.parser.JavaParserUtil; @@ -120,7 +121,7 @@ public interface JavaDocElementType { } @Override - public boolean isParsable(final CharSequence buffer, final Project project) { + public boolean isParsable(final CharSequence buffer, Language fileLanguage, final Project project) { final JavaLexer lexer = new JavaLexer(LanguageLevelProjectExtension.getInstance(project).getLanguageLevel()); lexer.start(buffer); if (lexer.getTokenType() == DOC_COMMENT) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaElementType.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaElementType.java index de737552382a..1dd8689c4fd0 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaElementType.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaElementType.java @@ -165,7 +165,7 @@ public interface JavaElementType { } @Override - public int getErrorsCount(final CharSequence seq, final Project project) { + public int getErrorsCount(final CharSequence seq, Language fileLanguage, final Project project) { final Lexer lexer = new JavaLexer(LanguageLevel.HIGHEST); lexer.start(seq); diff --git a/platform/core-api/src/com/intellij/psi/tree/IReparseableElementType.java b/platform/core-api/src/com/intellij/psi/tree/IReparseableElementType.java index f8cda346ad84..5a1636d9b4b5 100644 --- a/platform/core-api/src/com/intellij/psi/tree/IReparseableElementType.java +++ b/platform/core-api/src/com/intellij/psi/tree/IReparseableElementType.java @@ -42,11 +42,11 @@ public class IReparseableElementType extends ILazyParseableElementType { * chameleon node. * * @param buffer the content to parse. - * @param project the project containing the content. - * @return true if the content is valid, false if not + * @param fileLanguage language of the file + * @param project the project containing the content. @return true if the content is valid, false if not */ - public boolean isParsable(CharSequence buffer, final Project project) { + public boolean isParsable(CharSequence buffer, Language fileLanguage, final Project project) { return false; } } diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/DummyHolder.java b/platform/core-impl/src/com/intellij/psi/impl/source/DummyHolder.java index 4bd9b53cb2c1..1a1a5111c878 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/DummyHolder.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/DummyHolder.java @@ -47,7 +47,15 @@ public class DummyHolder extends PsiFileImpl { } public DummyHolder(@NotNull PsiManager manager, TreeElement contentElement, PsiElement context, CharTable table) { - this(manager, contentElement, context, table, null, context == null ? PlainTextLanguage.INSTANCE : context.getLanguage()); + this(manager, contentElement, context, table, null, language(context, PlainTextLanguage.INSTANCE)); + } + + protected static Language language(PsiElement context, Language defaultLanguage) { + if (context == null) return defaultLanguage; + Language contextLanguage = context.getLanguage(); + Language language = context.getContainingFile().getLanguage(); + if (language.isKindOf(contextLanguage)) return language; + return contextLanguage; } public DummyHolder(@NotNull PsiManager manager, TreeElement contentElement, PsiElement context, CharTable table, Boolean validity, Language language) { diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java b/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java index efb9d3bf0aa8..14ce9c6860c1 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java @@ -112,14 +112,14 @@ public class BlockSupportImpl extends BlockSupport { final TextRange textRange = node.getTextRange(); final IReparseableElementType reparseable = (IReparseableElementType)elementType; - if (reparseable.getLanguage() == baseLanguage) { + if (baseLanguage.isKindOf(reparseable.getLanguage())) { final int start = textRange.getStartOffset(); final int end = start + textRange.getLength() + lengthShift; assertFileLength(file, newFileText, node, elementType, start, end); CharSequence newTextStr = newFileText.subSequence(start, end); - if (reparseable.isParsable(newTextStr, project)) { + if (reparseable.isParsable(newTextStr, baseLanguage, project)) { ASTNode chameleon = reparseable.createNode(newTextStr); if (chameleon != null) { DummyHolder holder = DummyHolderFactory.createHolder(fileImpl.getManager(), null, node.getPsi(), charTable); diff --git a/platform/core-impl/src/com/intellij/psi/tree/IErrorCounterReparseableElementType.java b/platform/core-impl/src/com/intellij/psi/tree/IErrorCounterReparseableElementType.java index 40524866aaea..dfa9c3647f61 100644 --- a/platform/core-impl/src/com/intellij/psi/tree/IErrorCounterReparseableElementType.java +++ b/platform/core-impl/src/com/intellij/psi/tree/IErrorCounterReparseableElementType.java @@ -28,10 +28,10 @@ public abstract class IErrorCounterReparseableElementType extends IReparseableEl super(debugName, language); } - public abstract int getErrorsCount(CharSequence seq, Project project); + public abstract int getErrorsCount(CharSequence seq, Language fileLanguage, Project project); @Override - public boolean isParsable(CharSequence buffer, final Project project) { - return getErrorsCount(buffer, project) == NO_ERRORS; + public boolean isParsable(CharSequence buffer, Language fileLanguage, final Project project) { + return getErrorsCount(buffer, fileLanguage, project) == NO_ERRORS; } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GrCodeBlockElementType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GrCodeBlockElementType.java index 9ffb906c353e..027a1da94d79 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GrCodeBlockElementType.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GrCodeBlockElementType.java @@ -16,6 +16,7 @@ package org.jetbrains.plugins.groovy.lang.parser; import com.intellij.lang.ASTNode; +import com.intellij.lang.Language; import com.intellij.lexer.Lexer; import com.intellij.openapi.project.Project; import com.intellij.psi.tree.ICompositeElementType; @@ -47,7 +48,7 @@ public abstract class GrCodeBlockElementType extends IErrorCounterReparseableEle public abstract GrBlockImpl createNode(final CharSequence text); @Override - public int getErrorsCount(final CharSequence seq, final Project project) { + public int getErrorsCount(final CharSequence seq, Language fileLanguage, final Project project) { final Lexer lexer = new GroovyLexer(); lexer.start(seq); diff --git a/xml/impl/src/com/intellij/psi/xml/XmlElementType.java b/xml/impl/src/com/intellij/psi/xml/XmlElementType.java index 9e0c058e70cd..24e2316c169e 100644 --- a/xml/impl/src/com/intellij/psi/xml/XmlElementType.java +++ b/xml/impl/src/com/intellij/psi/xml/XmlElementType.java @@ -16,6 +16,7 @@ package com.intellij.psi.xml; import com.intellij.lang.ASTNode; +import com.intellij.lang.Language; import com.intellij.lang.dtd.DTDLanguage; import com.intellij.lang.html.HTMLLanguage; import com.intellij.lang.xhtml.XHTMLLanguage; @@ -75,7 +76,7 @@ public interface XmlElementType extends XmlTokenType { final XmlParsingContext parsingContext = new XmlParsingContext(table); return parsingContext.getXmlParsing().parse(new OldXmlLexer(), chars, 0, chars.length(), SharedImplUtil.getManagerByTree(chameleon)); } - public boolean isParsable(CharSequence buffer, final Project project) {return true;} + public boolean isParsable(CharSequence buffer, Language fileLanguage, final Project project) {return true;} }; IElementType XML_MARKUP = new CustomParsingType("XML_MARKUP_DECL", XMLLanguage.INSTANCE){ From df78efbc857531e2b869581f291c0075f3e8d90a Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 19 Mar 2012 11:34:20 +0100 Subject: [PATCH 23/50] Fix isSymlink performance on Java6/Win --- .../src/com/intellij/openapi/util/io/FileSystemUtil.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java index 33fb57c01f33..55ddc639be3a 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java @@ -88,8 +88,11 @@ public class FileSystemUtil { } public static boolean isSymLink(@NotNull final String path) { - final FileAttributes attributes = getAttributes(path); - return attributes != null && attributes.isSymlink; + if (SystemInfo.areSymLinksSupported) { + final FileAttributes attributes = getAttributes(path); + return attributes != null && attributes.isSymlink; + } + return false; } public static boolean isSymLink(@NotNull final File file) { From a5353766cdeba1628a3b27eb52d55e06dfb99384 Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 19 Mar 2012 14:35:11 +0400 Subject: [PATCH 24/50] revert of "Throve library for git4idea" --- plugins/git4idea/git4idea.iml | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/git4idea/git4idea.iml b/plugins/git4idea/git4idea.iml index a6f6343628fd..733b2cb41b6a 100644 --- a/plugins/git4idea/git4idea.iml +++ b/plugins/git4idea/git4idea.iml @@ -71,7 +71,6 @@ - From 1b2e74750c7277765c8b0c0989741c7306876943 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 19 Mar 2012 11:34:42 +0100 Subject: [PATCH 25/50] mem leak in svn auth manager --- .../idea/svn/SvnAuthenticationManager.java | 20 ++++++++++++- .../idea/svn/SvnAuthenticationNotifier.java | 2 +- .../jetbrains/idea/svn/SvnConfigurable.java | 2 +- .../jetbrains/idea/svn/SvnConfiguration.java | 30 +++++++++---------- .../src/org/jetbrains/idea/svn/SvnVcs.java | 2 +- .../idea/svn/branchConfig/BranchesLoader.java | 2 +- .../idea/svn/SvnAuthenticationTest.java | 4 +-- .../idea/svn16/SvnAuthenticationTest.java | 4 +-- 8 files changed, 41 insertions(+), 25 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java index a4333cc4da16..bf8eab65c0c5 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java @@ -15,6 +15,7 @@ */ package org.jetbrains.idea.svn; +import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; @@ -23,6 +24,7 @@ import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Getter; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; @@ -57,7 +59,7 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im public static final String SVN_SSH = "svn+ssh"; public static final String HTTP = "http"; public static final String HTTPS = "https"; - private final Project myProject; + private Project myProject; private File myConfigDirectory; private PersistentAuthenticationProviderProxy myPersistentAuthenticationProviderProxy; private SvnConfiguration myConfig; @@ -81,6 +83,22 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im myPersistentAuthenticationProviderProxy.setProject(myProject); } myInteraction = new MySvnAuthenticationInteraction(myProject); + Disposer.register(project, new Disposable() { + @Override + public void dispose() { + myProject = null; + if (myPersistentAuthenticationProviderProxy != null) { + myPersistentAuthenticationProviderProxy.myProject = null; + myPersistentAuthenticationProviderProxy = null; + } + if (myConfig != null) { + myConfig.clear(); + myConfig = null; + } + myInteraction = null; + + } + }); } public void setArtificialSaving(boolean artificialSaving) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java index c34c056eba86..53dcac7c99c1 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java @@ -303,7 +303,7 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl { private boolean myIsKeepLocks; private boolean myAutoUpdateAfterCommit; private boolean myRemoteStatus; - private final Project myProject; private SvnAuthenticationManager myAuthManager; private SvnAuthenticationManager myPassiveAuthManager; private SvnAuthenticationManager myInteractiveManager; @@ -146,7 +146,6 @@ public class SvnConfiguration implements PersistentStateComponent { } public SvnConfiguration(final Project project) { - myProject = project; myAnnotationListeners = new ArrayList(); } @@ -210,10 +209,10 @@ public class SvnConfiguration implements PersistentStateComponent { } } - public SvnSupportOptions getSupportOptions() { + public SvnSupportOptions getSupportOptions(Project project) { if (mySupportOptions == null) { // used to be kept in SvnBranchConfigurationManager - mySupportOptions = new SvnSupportOptions(SvnBranchConfigurationManager.getInstance(myProject).getSupportValue()); + mySupportOptions = new SvnSupportOptions(SvnBranchConfigurationManager.getInstance(project).getSupportValue()); } return mySupportOptions; } @@ -234,6 +233,10 @@ public class SvnConfiguration implements PersistentStateComponent { File dir = path == null ? new File(IdeaSubversionConfigurationDirectory.getPath()) : new File(path); SVNConfigFile.createDefaultConfiguration(dir); + clear(); + } + + public void clear() { myOptions = null; myAuthManager = null; myPassiveAuthManager = null; @@ -244,12 +247,7 @@ public class SvnConfiguration implements PersistentStateComponent { public void setUseDefaultConfiguation(boolean useDefault) { myIsUseDefaultConfiguration = useDefault; - myOptions = null; - myAuthManager = null; - myPassiveAuthManager = null; - myInteractiveManager = null; - myInteractiveProvider = null; - RUNTIME_AUTH_CACHE.clear(); + clear(); } public ISVNOptions getOptions(Project project) { @@ -277,7 +275,7 @@ public class SvnConfiguration implements PersistentStateComponent { public SvnAuthenticationManager getAuthenticationManager(final SvnVcs svnVcs) { if (myAuthManager == null) { // reloaded when configuration directory changes - myAuthManager = new SvnAuthenticationManager(myProject, new File(getConfigurationDirectory())); + myAuthManager = new SvnAuthenticationManager(svnVcs.getProject(), new File(getConfigurationDirectory())); getInteractiveManager(svnVcs); // to init myAuthManager.setAuthenticationProvider(new SvnAuthenticationProvider(svnVcs, myInteractiveProvider, RUNTIME_AUTH_CACHE)); @@ -286,9 +284,9 @@ public class SvnConfiguration implements PersistentStateComponent { return myAuthManager; } - public SvnAuthenticationManager getPassiveAuthenticationManager() { + public SvnAuthenticationManager getPassiveAuthenticationManager(Project project) { if (myPassiveAuthManager == null) { - myPassiveAuthManager = new SvnAuthenticationManager(myProject, new File(getConfigurationDirectory())); + myPassiveAuthManager = new SvnAuthenticationManager(project, new File(getConfigurationDirectory())); myPassiveAuthManager.setAuthenticationProvider(new ISVNAuthenticationProvider() { @Override public SVNAuthentication requestClientAuthentication(String kind, @@ -312,7 +310,7 @@ public class SvnConfiguration implements PersistentStateComponent { public SvnAuthenticationManager getInteractiveManager(final SvnVcs svnVcs) { if (myInteractiveManager == null) { - myInteractiveManager = new SvnAuthenticationManager(myProject, new File(getConfigurationDirectory())); + myInteractiveManager = new SvnAuthenticationManager(svnVcs.getProject(), new File(getConfigurationDirectory())); myInteractiveManager.setRuntimeStorage(RUNTIME_AUTH_CACHE); myInteractiveProvider = new SvnInteractiveAuthenticationProvider(svnVcs, myInteractiveManager); myInteractiveManager.setAuthenticationProvider(myInteractiveProvider); @@ -517,7 +515,7 @@ public class SvnConfiguration implements PersistentStateComponent { private static final List ourAuthKinds = Arrays.asList(ISVNAuthenticationManager.PASSWORD, ISVNAuthenticationManager.SSH, ISVNAuthenticationManager.SSL, ISVNAuthenticationManager.USERNAME, "svn.ssl.server", "svn.ssh.server"); - public void clearAuthenticationDirectory() { + public void clearAuthenticationDirectory(@Nullable Project project) { final File authDir = new File(getConfigurationDirectory(), "auth"); if (authDir.exists()) { ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { @@ -540,7 +538,7 @@ public class SvnConfiguration implements PersistentStateComponent { FileUtil.delete(dir); } } - }, "button.text.clear.authentication.cache", false, myProject); + }, "button.text.clear.authentication.cache", false, project); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java index e7b5616a3210..a4af67b2fdcf 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java @@ -298,7 +298,7 @@ public class SvnVcs extends AbstractVcs { try { ChangeListManager.getInstance(myProject).setReadOnly(SvnChangeProvider.ourDefaultListName, true); - supportOptions = myConfiguration.getSupportOptions(); + supportOptions = myConfiguration.getSupportOptions(myProject); upgradeToRecentVersion(supportOptions); if (! supportOptions.changeListsSynchronized()) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java index 0a3ace6fc501..7eac0632a910 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java @@ -39,7 +39,7 @@ public class BranchesLoader { final List result = new LinkedList(); final SvnConfiguration configuration = SvnConfiguration.getInstance(project); - final ISVNAuthenticationManager passiveManager = passive ? configuration.getPassiveAuthenticationManager() : configuration.getInteractiveManager( + final ISVNAuthenticationManager passiveManager = passive ? configuration.getPassiveAuthenticationManager(project) : configuration.getInteractiveManager( SvnVcs.getInstance(project)); final SVNLogClient logClient = new SVNLogClient(passiveManager, configuration.getOptions(project)); diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnAuthenticationTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnAuthenticationTest.java index 0aa30d1ee5c7..6116da48797d 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnAuthenticationTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnAuthenticationTest.java @@ -730,7 +730,7 @@ public class SvnAuthenticationTest extends PlatformTestCase { @Override public void run() { try { - myConfiguration.clearAuthenticationDirectory(); + myConfiguration.clearAuthenticationDirectory(getProject()); } catch (Exception e) { throw new RuntimeException(e); @@ -875,7 +875,7 @@ public class SvnAuthenticationTest extends PlatformTestCase { @Override public void run() { try { - myConfiguration.clearAuthenticationDirectory(); + myConfiguration.clearAuthenticationDirectory(getProject()); } catch (Exception e) { throw new RuntimeException(e); diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnAuthenticationTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnAuthenticationTest.java index 1fdb34c6429e..665d5d34abac 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnAuthenticationTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnAuthenticationTest.java @@ -734,7 +734,7 @@ public class SvnAuthenticationTest extends PlatformTestCase { @Override public void run() { try { - myConfiguration.clearAuthenticationDirectory(); + myConfiguration.clearAuthenticationDirectory(getProject()); } catch (Exception e) { throw new RuntimeException(e); @@ -879,7 +879,7 @@ public class SvnAuthenticationTest extends PlatformTestCase { @Override public void run() { try { - myConfiguration.clearAuthenticationDirectory(); + myConfiguration.clearAuthenticationDirectory(getProject()); } catch (Exception e) { throw new RuntimeException(e); From 4fdf47bb4cd30fc170df5197b94e4736cf23feab Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 19 Mar 2012 12:34:36 +0100 Subject: [PATCH 26/50] IDEA-82634 (Inspection warning on entire file not displayed) --- .../src/com/siyeh/ig/BaseInspectionVisitor.java | 2 +- .../com/siyeh/igtest/classlayout/emptyclass/EmptyFile.java | 0 .../com/siyeh/igtest/classlayout/emptyclass/expected.xml | 7 +++++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/emptyclass/EmptyFile.java diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/BaseInspectionVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/BaseInspectionVisitor.java index 88626a6de410..aedb7b302c1d 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/BaseInspectionVisitor.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/BaseInspectionVisitor.java @@ -173,7 +173,7 @@ public abstract class BaseInspectionVisitor extends JavaElementVisitor { protected final void registerError(@NotNull PsiElement location, Object... infos) { - if (location.getTextLength() == 0) { + if (location.getTextLength() == 0 && !(location instanceof PsiFile)) { return; } final InspectionGadgetsFix[] fixes = createFixes(infos); diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/emptyclass/EmptyFile.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/emptyclass/EmptyFile.java new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/emptyclass/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/emptyclass/expected.xml index 05c0cc1b6d2d..ea5fd37b96a9 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/emptyclass/expected.xml +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/emptyclass/expected.xml @@ -6,4 +6,11 @@ Empty class Class <code>ReportMe</code> is empty #loc + + + EmptyFile.java + 1 + Empty class + Java file does not declare any class #loc + \ No newline at end of file From 9c506be58ac1e3498e035263ed2f654b8b9074e2 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Mon, 19 Mar 2012 12:36:48 +0100 Subject: [PATCH 27/50] missing dependency --- java/debugger/openapi/debugger-openapi.iml | 1 + 1 file changed, 1 insertion(+) diff --git a/java/debugger/openapi/debugger-openapi.iml b/java/debugger/openapi/debugger-openapi.iml index ff0584c35f08..52013f3be018 100644 --- a/java/debugger/openapi/debugger-openapi.iml +++ b/java/debugger/openapi/debugger-openapi.iml @@ -10,6 +10,7 @@ + From ce4dbbf82dfbe482e12fb97c6124ee1b2a70f491 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Mon, 19 Mar 2012 15:36:56 +0400 Subject: [PATCH 28/50] fix NPE in case context element has no containing file --- .../src/com/intellij/psi/impl/source/DummyHolder.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/DummyHolder.java b/platform/core-impl/src/com/intellij/psi/impl/source/DummyHolder.java index 1a1a5111c878..c12f291f9431 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/DummyHolder.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/DummyHolder.java @@ -52,8 +52,10 @@ public class DummyHolder extends PsiFileImpl { protected static Language language(PsiElement context, Language defaultLanguage) { if (context == null) return defaultLanguage; + PsiFile file = context.getContainingFile(); + if (file == null) return defaultLanguage; Language contextLanguage = context.getLanguage(); - Language language = context.getContainingFile().getLanguage(); + Language language = file.getLanguage(); if (language.isKindOf(contextLanguage)) return language; return contextLanguage; } From f1fd467f3be08810f24a77823520d64dbb4b09e8 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 19 Mar 2012 12:30:07 +0100 Subject: [PATCH 29/50] EA-34150 (examine temp. dir on startup just like JNA) --- .../src/com/intellij/idea/StartupUtil.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/idea/StartupUtil.java b/platform/platform-impl/src/com/intellij/idea/StartupUtil.java index 0127e75b5b8d..d144ba429f34 100644 --- a/platform/platform-impl/src/com/intellij/idea/StartupUtil.java +++ b/platform/platform-impl/src/com/intellij/idea/StartupUtil.java @@ -122,14 +122,22 @@ public class StartupUtil { private static boolean checkTmpIsAccessible() { if (!SystemInfo.isUnix || SystemInfo.isMac) return true; + final File tmpDir = new File(System.getProperty("java.io.tmpdir")); + if (!tmpDir.isDirectory()) { + showError("Inaccessible Temp Directory", "Temp directory '" + tmpDir + "' does not exist.\n" + + "Please set 'java.io.tmpdir' system property to point to an existing directory."); + return false; + } + final File tmp; try { - tmp = FileUtil.createTempFile("idea_check_", ".tmp"); + //noinspection SSBasedInspection + tmp = File.createTempFile("idea_tmp_check_", ".sh", tmpDir); FileUtil.writeToFile(tmp, "#!/bin/sh\n" + "exit 0"); } catch (IOException e) { - showError("Inaccessible Temp Directory", e.getMessage() + " (" + FileUtil.getTempDirectory() + ").\n" + + showError("Inaccessible Temp Directory", e.getMessage() + " (" + tmpDir + ").\n" + "Temp directory is not accessible.\n" + "Please set 'java.io.tmpdir' system property to point to a writable directory."); return false; From 9da612dca5f099f234548da0599ac99d6de1d866 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Mon, 19 Mar 2012 15:20:00 +0400 Subject: [PATCH 30/50] AntArtifactPropertiesEditor. Toolbar decorator. --- .../AntArtifactPropertiesEditor.form | 66 +---------- .../AntArtifactPropertiesEditor.java | 109 +++++++++++++----- 2 files changed, 84 insertions(+), 91 deletions(-) diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.form b/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.form index 5e3784cb08d4..c3b2d1907107 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.form +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.form @@ -42,74 +42,18 @@ - - + - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.java index a28cc76295e2..c94215d3b25f 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/artifacts/AntArtifactPropertiesEditor.java @@ -21,20 +21,23 @@ import com.intellij.lang.ant.config.AntConfiguration; import com.intellij.lang.ant.config.impl.BuildFileProperty; import com.intellij.lang.ant.config.impl.TargetChooserDialog; import com.intellij.lang.ant.config.impl.configuration.UIPropertyBinding; +import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.ui.FixedSizeButton; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Condition; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.packaging.ui.ArtifactEditorContext; import com.intellij.packaging.ui.ArtifactPropertiesEditor; +import com.intellij.ui.*; import com.intellij.ui.table.JBTable; -import com.intellij.util.NewInstanceFactory; import com.intellij.util.config.ListProperty; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.ColumnInfo; +import com.intellij.util.ui.ListTableModel; import com.intellij.util.ui.UIUtil; import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; @@ -45,32 +48,34 @@ import java.util.List; */ public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor { private static final ListProperty ANT_PROPERTIES = ListProperty.create("ant-properties"); - private static final ColumnInfo NAME_COLUMN = new ColumnInfo(AntBundle.message("edit.ant.properties.name.column.name")) { - public String valueOf(BuildFileProperty buildFileProperty) { - return buildFileProperty.getPropertyName(); - } + private static final ColumnInfo NAME_COLUMN = + new ColumnInfo(AntBundle.message("edit.ant.properties.name.column.name")) { + public String valueOf(BuildFileProperty buildFileProperty) { + return buildFileProperty.getPropertyName(); + } - public boolean isCellEditable(BuildFileProperty buildFileProperty) { - return USER_PROPERTY_CONDITION.value(buildFileProperty); - } + public boolean isCellEditable(BuildFileProperty buildFileProperty) { + return USER_PROPERTY_CONDITION.value(buildFileProperty); + } - public void setValue(BuildFileProperty buildFileProperty, String name) { - buildFileProperty.setPropertyName(name); - } - }; - private static final ColumnInfo VALUE_COLUMN = new ColumnInfo(AntBundle.message("edit.ant.properties.value.column.name")) { - public boolean isCellEditable(BuildFileProperty buildFileProperty) { - return USER_PROPERTY_CONDITION.value(buildFileProperty); - } + public void setValue(BuildFileProperty buildFileProperty, String name) { + buildFileProperty.setPropertyName(name); + } + }; + private static final ColumnInfo VALUE_COLUMN = + new ColumnInfo(AntBundle.message("edit.ant.properties.value.column.name")) { + public boolean isCellEditable(BuildFileProperty buildFileProperty) { + return USER_PROPERTY_CONDITION.value(buildFileProperty); + } - public String valueOf(BuildFileProperty buildFileProperty) { - return buildFileProperty.getPropertyValue(); - } + public String valueOf(BuildFileProperty buildFileProperty) { + return buildFileProperty.getPropertyValue(); + } - public void setValue(BuildFileProperty buildFileProperty, String value) { - buildFileProperty.setPropertyValue(value); - } - }; + public void setValue(BuildFileProperty buildFileProperty, String value) { + buildFileProperty.setPropertyValue(value); + } + }; private static final ColumnInfo[] PROPERTY_COLUMNS = new ColumnInfo[]{NAME_COLUMN, VALUE_COLUMN}; private static final Condition USER_PROPERTY_CONDITION = new Condition() { @Override @@ -84,8 +89,6 @@ public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor { private JCheckBox myRunTargetCheckBox; private FixedSizeButton mySelectTargetButton; private JBTable myPropertiesTable; - private JButton myAddButton; - private JButton myRemoveButton; private JPanel myPropertiesPanel; private AntBuildTarget myTarget; private final boolean myPostProcessing; @@ -111,10 +114,59 @@ public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor { } }); + myPropertiesTable = new JBTable(); UIPropertyBinding.Composite binding = new UIPropertyBinding.Composite(); myBinding = binding.bindList(myPropertiesTable, PROPERTY_COLUMNS, ANT_PROPERTIES); - myBinding.addAddFacility(myAddButton, NewInstanceFactory.fromClass(BuildFileProperty.class)); - myBinding.addRemoveFacility(myRemoveButton, USER_PROPERTY_CONDITION); + myPropertiesPanel.add( + ToolbarDecorator.createDecorator(myPropertiesTable) + .setAddAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + ListTableModel model = (ListTableModel)myPropertiesTable.getModel(); + if (myPropertiesTable.isEditing() && !myPropertiesTable.getCellEditor().stopCellEditing()) { + return; + } + BuildFileProperty item = new BuildFileProperty(); + ArrayList items = new ArrayList(model.getItems()); + items.add(item); + model.setItems(items); + int newIndex = model.indexOf(item); + ListSelectionModel selectionModel = myPropertiesTable.getSelectionModel(); + selectionModel.clearSelection(); + selectionModel.setSelectionInterval(newIndex, newIndex); + ColumnInfo[] columns = model.getColumnInfos(); + for (int i = 0; i < columns.length; i++) { + ColumnInfo column = columns[i]; + if (column.isCellEditable(item)) { + myPropertiesTable.requestFocusInWindow(); + myPropertiesTable.editCellAt(newIndex, i); + break; + } + } + } + }).setRemoveAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + TableUtil.removeSelectedItems(myPropertiesTable); + } + }).setRemoveActionUpdater(new AnActionButtonUpdater() { + @Override + public boolean isEnabled(AnActionEvent e) { + final ListSelectionModel selectionModel = myPropertiesTable.getSelectionModel(); + ListTableModel model = (ListTableModel)myPropertiesTable.getModel(); + boolean enable = false; + if (!selectionModel.isSelectionEmpty()) { + enable = true; + for (int i : myPropertiesTable.getSelectedRows()) { + if (AntArtifactProperties.isPredefinedProperty(model.getItems().get(i).getPropertyName())) { + enable = false; + break; + } + } + } + return enable; + } + }).disableUpDownActions().createPanel(), BorderLayout.CENTER); } private void selectTarget() { @@ -135,9 +187,6 @@ public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor { } final boolean enabled = myTarget != null && myRunTargetCheckBox.isSelected(); UIUtil.setEnabled(myPropertiesPanel, enabled, true); - if (enabled) { - myBinding.updateRemoveButton(myRemoveButton, USER_PROPERTY_CONDITION); - } } public String getTabName() { From 4828593738419dd2b36e24e2542bbdbc07c5bdc0 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Mon, 19 Mar 2012 15:20:22 +0400 Subject: [PATCH 31/50] IDEA-82224 Toolbar decorator: vertical border is too thick (look at the left of '+' button) --- .../src/com/intellij/ui/ToolbarDecorator.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/ToolbarDecorator.java b/platform/platform-api/src/com/intellij/ui/ToolbarDecorator.java index 6ae7c8641b7a..40bba4bb9849 100644 --- a/platform/platform-api/src/com/intellij/ui/ToolbarDecorator.java +++ b/platform/platform-api/src/com/intellij/ui/ToolbarDecorator.java @@ -17,7 +17,6 @@ package com.intellij.ui; import com.intellij.ide.DataManager; import com.intellij.openapi.actionSystem.*; -import com.intellij.openapi.util.SystemInfo; import com.intellij.ui.border.CustomLineBorder; import com.intellij.ui.table.TableView; import com.intellij.util.ui.ElementProducer; @@ -89,8 +88,11 @@ public abstract class ToolbarDecorator implements DataProvider, CommonActionsPan } protected ToolbarDecorator initPositionAndBorder() { - myToolbarPosition = SystemInfo.isMac ? ActionToolbarPosition.BOTTOM : ActionToolbarPosition.RIGHT; - myBorder = new CustomLineBorder(0, SystemInfo.isMac ? 0 : 1, 0, 0); + myToolbarPosition = UIUtil.isUnderAquaLookAndFeel() ? ActionToolbarPosition.BOTTOM : ActionToolbarPosition.RIGHT; + myBorder = new CustomLineBorder(0, + myToolbarPosition == ActionToolbarPosition.RIGHT ? 1 : 0, + myToolbarPosition == ActionToolbarPosition.TOP ? 1 : 0, + myToolbarPosition == ActionToolbarPosition.LEFT ? 1 : 0); final JComponent c = getComponent(); if (c != null) { c.setBorder(IdeBorderFactory.createEmptyBorder(0)); @@ -180,6 +182,10 @@ public abstract class ToolbarDecorator implements DataProvider, CommonActionsPan public ToolbarDecorator setToolbarPosition(ActionToolbarPosition position) { myToolbarPosition = position; + myBorder = new CustomLineBorder(0, + myToolbarPosition == ActionToolbarPosition.RIGHT ? 1 : 0, + myToolbarPosition == ActionToolbarPosition.TOP ? 1 : 0, + myToolbarPosition == ActionToolbarPosition.LEFT ? 1 : 0); return this; } From 6d0f60973a5a4f15af7f4a5f919e2390165f9cf1 Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 19 Mar 2012 15:58:11 +0400 Subject: [PATCH 32/50] IDEA-82406 Subversion 1.7 plugin slow to notice changes to file --- .../idea/svn/SvnEntriesFileListener.java | 30 ++++++++++++++----- .../src/org/jetbrains/idea/svn/SvnUtil.java | 1 + 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnEntriesFileListener.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnEntriesFileListener.java index 7dc0e446112a..ecc48df7336d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnEntriesFileListener.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnEntriesFileListener.java @@ -15,11 +15,10 @@ */ package org.jetbrains.idea.svn; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; -import com.intellij.openapi.vcs.AbstractVcs; -import com.intellij.openapi.vcs.FilePath; -import com.intellij.openapi.vcs.FilePathImpl; -import com.intellij.openapi.vcs.ProjectLevelVcsManager; +import com.intellij.openapi.vcs.*; +import com.intellij.openapi.vcs.changes.ChangeListManager; import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileAdapter; @@ -36,10 +35,15 @@ public class SvnEntriesFileListener extends VirtualFileAdapter { private final Project myProject; private final Collection myListeners = new ArrayList(); private final ProjectLevelVcsManager myVcsManager; + private static final Logger LOG = Logger.getInstance("#org.jetbrains.idea.svn.SvnEntriesFileListener"); + private ChangeListManager myChangeListManager; + private VcsDirtyScopeManager myDirtyScopeManager; public SvnEntriesFileListener(final Project project) { myProject = project; myVcsManager = ProjectLevelVcsManager.getInstance(myProject); + myChangeListManager = ChangeListManager.getInstance(myProject); + myDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject); } public void fileCreated(VirtualFileEvent event) { @@ -72,6 +76,13 @@ public class SvnEntriesFileListener extends VirtualFileAdapter { return; } final VirtualFile file = event.getFile(); + if (isWcDbFile(file)) { + LOG.debug("wc.db had changed"); + // all that we have now? or all? + final List affectedPaths = myChangeListManager.getAffectedPaths(); + myDirtyScopeManager.filePathsDirty(ObjectsConvertor.convert(affectedPaths, ObjectsConvertor.FILE_FILEPATH, ObjectsConvertor.NOT_NULL), null); + return; + } if (isEntriesFile(file) && file.getParent() != null) { VirtualFile parent = file.getParent(); if (parent != null) { @@ -116,7 +127,7 @@ public class SvnEntriesFileListener extends VirtualFileAdapter { if (SvnVcs.VCS_NAME.equals(vcsFor.getName())) { final RootUrlInfo path = ((SvnVcs)vcsFor).getSvnFileUrlMapping().getWcRootForFilePath(new File(parent.getPath())); if (path != null && WorkingCopyFormat.ONE_DOT_SEVEN.equals(path.getFormat())) { - VcsDirtyScopeManager.getInstance(myProject).filePathsDirty( + myDirtyScopeManager.filePathsDirty( Collections.singletonList(new FilePathImpl(new File(file.getPath()), file.isDirectory())), null); } } @@ -158,7 +169,7 @@ public class SvnEntriesFileListener extends VirtualFileAdapter { final List files = new ArrayList(children.length + 1); files.add(parent); Collections.addAll(files, children); - VcsDirtyScopeManager.getInstance(myProject).filesDirty(files, null); + myDirtyScopeManager.filesDirty(files, null); /* final FileStatusManager fileStatusManager = FileStatusManager.getInstance(myProject); final VirtualFile[] children = parent.getChildren(); @@ -175,6 +186,11 @@ public class SvnEntriesFileListener extends VirtualFileAdapter { private static boolean isEntriesFile(final VirtualFile file) { VirtualFile parent = file.getParent(); - return !file.isDirectory() && SvnUtil.ENTRIES_FILE_NAME.equals(file.getName()) && parent != null && SvnUtil.SVN_ADMIN_DIR_NAME.equals(parent.getName()); + return ! file.isDirectory() && SvnUtil.ENTRIES_FILE_NAME.equals(file.getName()) && parent != null && SvnUtil.SVN_ADMIN_DIR_NAME.equals(parent.getName()); + } + + private static boolean isWcDbFile(final VirtualFile file) { + VirtualFile parent = file.getParent(); + return ! file.isDirectory() && SvnUtil.WC_DB_FILE_NAME.equals(file.getName()) && parent != null && SvnUtil.SVN_ADMIN_DIR_NAME.equals(parent.getName()); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java index df29dcd3bed4..296b61a24b1f 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java @@ -52,6 +52,7 @@ import java.util.*; public class SvnUtil { @NonNls public static final String SVN_ADMIN_DIR_NAME = SVNFileUtil.getAdminDirectoryName(); @NonNls public static final String ENTRIES_FILE_NAME = "entries"; + @NonNls public static final String WC_DB_FILE_NAME = "wc.db"; @NonNls public static final String DIR_PROPS_FILE_NAME = "dir-props"; @NonNls public static final String PATH_TO_LOCK_FILE = SVN_ADMIN_DIR_NAME + "/lock"; @NonNls public static final String LOCK_FILE_NAME = "lock"; From c3058cb2b53468e7f1891ceb2c2c84cdd379788a Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Mon, 19 Mar 2012 15:58:21 +0400 Subject: [PATCH 33/50] IDEA-80954 --- .../xdebugger/impl/frame/XFramesView.java | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java index 8627536e625e..91f31c4a3886 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java @@ -20,10 +20,10 @@ import com.intellij.ide.CommonActionsManager; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.ActionPlaces; -import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.CaptionPanel; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.border.CustomLineBorder; @@ -58,6 +58,8 @@ public class XFramesView extends XDebugViewBase { private XExecutionStack mySelectedStack; private boolean myListenersEnabled; private final Map myBuilders = new HashMap(); + private final ActionToolbarImpl myToolbar; + private final Wrapper myThreadsPanel; public XFramesView(final XDebugSession session, final Disposable parentDisposable) { super(session, parentDisposable); @@ -85,27 +87,28 @@ public class XFramesView extends XDebugViewBase { myThreadComboBox = new JComboBox(); myThreadComboBox.setRenderer(new ThreadComboBoxRenderer(myThreadComboBox)); myThreadComboBox.addItemListener(new MyItemListener()); - final ActionToolbar toolbar = createToolbar(); - Wrapper threadsPanel = new Wrapper(); + myToolbar = createToolbar(); + myThreadsPanel = new Wrapper(); CustomLineBorder border = new CustomLineBorder(CaptionPanel.CNT_ACTIVE_COLOR, 0, 0, 1, 0); - threadsPanel.setBorder(border); - threadsPanel.add(toolbar.getComponent(), BorderLayout.EAST); - threadsPanel.add(myThreadComboBox, BorderLayout.CENTER); - myMainPanel.add(threadsPanel, BorderLayout.NORTH); + myThreadsPanel.setBorder(border); + myThreadsPanel.add(myToolbar.getComponent(), BorderLayout.EAST); + myThreadsPanel.add(myThreadComboBox, BorderLayout.CENTER); + myMainPanel.add(myThreadsPanel, BorderLayout.NORTH); rebuildView(SessionEvent.RESUMED); } - private ActionToolbar createToolbar() { + private ActionToolbarImpl createToolbar() { final DefaultActionGroup framesGroup = new DefaultActionGroup(); CommonActionsManager actionsManager = CommonActionsManager.getInstance(); framesGroup.add(actionsManager.createPrevOccurenceAction(getFramesList())); framesGroup.add(actionsManager.createNextOccurenceAction(getFramesList())); - final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.DEBUGGER_TOOLBAR, framesGroup, true); + final ActionToolbarImpl toolbar = + (ActionToolbarImpl)ActionManager.getInstance().createActionToolbar(ActionPlaces.DEBUGGER_TOOLBAR, framesGroup, true); toolbar.setReservePlaceAutoPopupIcon(false); - ((ActionToolbarImpl)toolbar).setAddSeparatorFirst(true); + toolbar.setAddSeparatorFirst(true); toolbar.getComponent().setBorder(new EmptyBorder(1, 0, 0, 0)); return toolbar; } @@ -152,6 +155,15 @@ public class XFramesView extends XDebugViewBase { } XExecutionStack activeExecutionStack = suspendContext.getActiveExecutionStack(); myThreadComboBox.setSelectedItem(activeExecutionStack); + final boolean invisible = executionStacks.length == 1 && StringUtil.isEmpty(executionStacks[0].getDisplayName()); + myThreadsPanel.removeAll(); + if (invisible) { + myThreadsPanel.add(myToolbar.getComponent(), BorderLayout.WEST); + } else { + myThreadsPanel.add(myToolbar.getComponent(), BorderLayout.EAST); + myThreadsPanel.add(myThreadComboBox, BorderLayout.CENTER); + } + myToolbar.setAddSeparatorFirst(!invisible); updateFrames(activeExecutionStack); myListenersEnabled = true; } From 65359ce607a9ebeec8ffd8c832a15757007b4656 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Mon, 19 Mar 2012 16:14:37 +0400 Subject: [PATCH 34/50] removed classes relevant to old parsing (we still need to fix old xml one) --- .../psi/impl/source/ParsingContext.java | 40 ---- .../DefaultWhiteSpaceTokenProcessorImpl.java | 59 ------ .../source/parsing/MissingTokenInserter.java | 173 ------------------ .../impl/source/parsing/TokenProcessor.java | 30 --- .../source/parsing/xml/OldXmlParsing.java | 24 ++- .../source/parsing/xml/XmlParsingContext.java | 26 ++- 6 files changed, 29 insertions(+), 323 deletions(-) delete mode 100644 platform/lang-impl/src/com/intellij/psi/impl/source/ParsingContext.java delete mode 100644 platform/lang-impl/src/com/intellij/psi/impl/source/parsing/DefaultWhiteSpaceTokenProcessorImpl.java delete mode 100644 platform/lang-impl/src/com/intellij/psi/impl/source/parsing/MissingTokenInserter.java delete mode 100644 platform/lang-impl/src/com/intellij/psi/impl/source/parsing/TokenProcessor.java diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/ParsingContext.java b/platform/lang-impl/src/com/intellij/psi/impl/source/ParsingContext.java deleted file mode 100644 index a45ac8c81132..000000000000 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/ParsingContext.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.intellij.psi.impl.source; - -import com.intellij.lexer.Lexer; -import com.intellij.lexer.LexerUtil; -import com.intellij.util.CharTable; - -/** - * @author ven - */ -public class ParsingContext { - private final CharTable myTable; - - public ParsingContext(final CharTable table) { - myTable = table; - } - - public CharTable getCharTable() { - return myTable; - } - - public CharSequence tokenText(Lexer lexer) { - return LexerUtil.internToken(lexer, myTable); - } -} diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/DefaultWhiteSpaceTokenProcessorImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/DefaultWhiteSpaceTokenProcessorImpl.java deleted file mode 100644 index b495d0e12907..000000000000 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/DefaultWhiteSpaceTokenProcessorImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.intellij.psi.impl.source.parsing; - -import com.intellij.lang.ASTFactory; -import com.intellij.lexer.Lexer; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.psi.impl.source.ParsingContext; -import com.intellij.psi.impl.source.tree.TreeElement; -import com.intellij.psi.tree.IElementType; - -public abstract class DefaultWhiteSpaceTokenProcessorImpl implements TokenProcessor { - private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.parsing.DefaultWhiteSpaceTokenProcessorImpl"); - - @Override - public boolean isTokenValid(IElementType tokenType) { - return tokenType != null && isInSet(tokenType); - } - - @Override - public TreeElement process(Lexer lexer, ParsingContext context) { - TreeElement first = null; - TreeElement last = null; - while (isTokenValid(lexer.getTokenType())) { - TreeElement tokenElement = ASTFactory.leaf(lexer.getTokenType(), context.tokenText(lexer)); - IElementType type = lexer.getTokenType(); - - if (!isInSet(type)) { - LOG.error("Missed token should be white space or comment:" + tokenElement + "; type:" + type); - throw new RuntimeException(); - } - if (last != null) { - last.rawInsertAfterMe(tokenElement); - last = tokenElement; - } - else { - first = last = tokenElement; - } - lexer.advance(); - } - return first; - } - - protected abstract boolean isInSet(final IElementType type); -} diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/MissingTokenInserter.java b/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/MissingTokenInserter.java deleted file mode 100644 index 5f69fe29d7d0..000000000000 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/MissingTokenInserter.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.intellij.psi.impl.source.parsing; - -import com.intellij.lang.ASTNode; -import com.intellij.lexer.Lexer; -import com.intellij.psi.impl.source.ParsingContext; -import com.intellij.psi.impl.source.tree.CompositeElement; -import com.intellij.psi.impl.source.tree.LeafElement; -import com.intellij.psi.impl.source.tree.TreeElement; -import com.intellij.psi.impl.source.tree.TreeUtil; -import com.intellij.psi.templateLanguages.OuterLanguageElement; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.tree.ILazyParseableElementType; - -public class MissingTokenInserter { - protected final CompositeElement myRoot; - protected final Lexer myLexer; - private final int myStartOffset; - private final int myEndOffset; - private final int myState; - private final TokenProcessor myProcessor; - private final ParsingContext myContext; - - public MissingTokenInserter(final CompositeElement root, - final Lexer lexer, - final int startOffset, - final int endOffset, - final int state, - final TokenProcessor processor, - final ParsingContext context) { - myRoot = root; - myLexer = lexer; - myStartOffset = startOffset; - myEndOffset = endOffset; - myState = state; - myProcessor = processor; - myContext = context; - } - - public void invoke() { - if (myState < 0) { - myLexer.start(myLexer.getBufferSequence(), myStartOffset, myEndOffset); - } - else { - myLexer.start(myLexer.getBufferSequence(), myStartOffset, myEndOffset, myState); - } - - TreeElement leaf = TreeUtil.findFirstLeafOrChameleon(myRoot); - if (leaf == null) { - final TreeElement firstMissing = myProcessor.process(myLexer, myContext); - if (firstMissing != null) { - myRoot.rawAddChildren(firstMissing); - } - return; - } - else { - // Missing in the beginning - final IElementType tokenType = getNextTokenType(); - if (tokenType != leaf.getElementType() && myProcessor.isTokenValid(tokenType)) { - final TreeElement firstMissing = myProcessor.process(myLexer, myContext); - if (firstMissing != null) { - myRoot.getFirstChildNode().rawInsertBeforeMe(firstMissing); - } - } - passTokenOrChameleon(leaf); - } - // Missing in tree body - insertMissingTokensInTreeBody(leaf); - if (myLexer.getTokenType() != null) { - // whitespaces at the end of the file - final TreeElement firstMissing = myProcessor.process(myLexer, myContext); - if (firstMissing != null) { - ASTNode current = myRoot; - while (current instanceof CompositeElement) { - if (current.getUserData(TreeUtil.UNCLOSED_ELEMENT_PROPERTY) != null) break; - current = current.getLastChildNode(); - } - if (current instanceof CompositeElement) { - ((CompositeElement)current).rawAddChildren(firstMissing); - } - else { - myRoot.getLastChildNode().rawInsertAfterMe(firstMissing); - } - } - } - } - - protected IElementType getNextTokenType() { - return myLexer.getTokenType(); - } - - private void insertMissingTokensInTreeBody(TreeElement leaf) { - final TreeUtil.CommonParentState commonParents = new TreeUtil.CommonParentState(); - while (leaf != null) { - commonParents.strongWhiteSpaceHolder = null; - final IElementType tokenType = getNextTokenType(); - final TreeElement next = TreeUtil.nextLeaf(leaf, commonParents, tokenType instanceof ILazyParseableElementType ? tokenType : null, false); - - if (next == null || tokenType == null) break; - if (tokenType != next.getElementType() && myProcessor.isTokenValid(tokenType)) { - final TreeElement firstMissing = myProcessor.process(myLexer, myContext); - final CompositeElement unclosedElement = commonParents.strongWhiteSpaceHolder; - if (unclosedElement != null) { - if (commonParents.isStrongElementOnRisingSlope || unclosedElement.getFirstChildNode() == null) { - unclosedElement.rawAddChildren(firstMissing); - } - else { - unclosedElement.getFirstChildNode().rawInsertBeforeMe(firstMissing); - } - } - else { - final ASTNode insertBefore = commonParents.nextLeafBranchStart; - TreeElement insertAfter = commonParents.startLeafBranchStart; - TreeElement current = commonParents.startLeafBranchStart; - while (current != insertBefore) { - final TreeElement treeNext = current.getTreeNext(); - if (treeNext == insertBefore) { - insertAfter = current; - break; - } - if (isInsertAfterElement(treeNext)) { - insertAfter = current; - break; - } - if (treeNext.getUserData(TreeUtil.UNCLOSED_ELEMENT_PROPERTY) != null) { - insertAfter = null; - ((CompositeElement)treeNext).rawAddChildren(firstMissing); - break; - } - current = treeNext; - } - if (insertAfter != null) insertAfter.rawInsertAfterMe(firstMissing); - } - } - passTokenOrChameleon(next); - leaf = next; - } - } - - protected boolean isInsertAfterElement(TreeElement treeNext) { - return false; - } - - private void passTokenOrChameleon(final ASTNode node) { - if (node instanceof LeafElement && node instanceof OuterLanguageElement - || TreeUtil.isCollapsedChameleon(node)) { - final int endOfChameleon = node.getTextLength() + myLexer.getTokenStart(); - while (myLexer.getTokenType() != null && myLexer.getTokenEnd() < endOfChameleon) { - myLexer.advance(); - } - } - advanceLexer(node); - } - - protected void advanceLexer(final ASTNode next) { - myLexer.advance(); - } -} diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/TokenProcessor.java b/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/TokenProcessor.java deleted file mode 100644 index b94573c0ac99..000000000000 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/parsing/TokenProcessor.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.intellij.psi.impl.source.parsing; - -import org.jetbrains.annotations.Nullable; -import com.intellij.psi.impl.source.tree.TreeElement; -import com.intellij.psi.impl.source.ParsingContext; -import com.intellij.psi.tree.IElementType; -import com.intellij.lexer.Lexer; - -public interface TokenProcessor { - @Nullable - TreeElement process(Lexer lexer, ParsingContext context); - - boolean isTokenValid(IElementType tokenType); -} diff --git a/xml/impl/src/com/intellij/psi/impl/source/parsing/xml/OldXmlParsing.java b/xml/impl/src/com/intellij/psi/impl/source/parsing/xml/OldXmlParsing.java index 57093fb7ac98..3068d0316d1d 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/parsing/xml/OldXmlParsing.java +++ b/xml/impl/src/com/intellij/psi/impl/source/parsing/xml/OldXmlParsing.java @@ -22,8 +22,6 @@ import com.intellij.lexer.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.psi.PsiManager; import com.intellij.psi.impl.source.DummyHolderFactory; -import com.intellij.psi.impl.source.ParsingContext; -import com.intellij.psi.impl.source.parsing.TokenProcessor; import com.intellij.psi.impl.source.tree.*; import com.intellij.psi.templateLanguages.OuterLanguageElement; import com.intellij.psi.tree.IElementType; @@ -49,10 +47,10 @@ public class OldXmlParsing implements XmlElementType { public static final TokenSet XML_COMMENT_BIT_SET = TokenSet.create(new IElementType[]{XML_COMMENT_START, XML_COMMENT_CHARACTERS, XML_COMMENT_END}); - private final ParsingContext myContext; + private final XmlParsingContext myContext; private int myLastTokenEnd = -1; - public OldXmlParsing(ParsingContext context) { + public OldXmlParsing(XmlParsingContext context) { myContext = context; } @@ -931,13 +929,13 @@ public class OldXmlParsing implements XmlElementType { } } - public static class WhiteSpaceAndCommentsProcessor implements TokenProcessor { - public static final TokenProcessor INSTANCE = new WhiteSpaceAndCommentsProcessor(); + public static class WhiteSpaceAndCommentsProcessor { + public static final WhiteSpaceAndCommentsProcessor INSTANCE = new WhiteSpaceAndCommentsProcessor(); private WhiteSpaceAndCommentsProcessor() { } - public TreeElement process(Lexer lexer, ParsingContext context) { + public TreeElement process(Lexer lexer, XmlParsingContext context) { TreeElement first = null; TreeElement last = null; while (isTokenValid(lexer.getTokenType())) { @@ -972,7 +970,7 @@ public class OldXmlParsing implements XmlElementType { return tokenType != null && XML_WHITE_SPACE_OR_COMMENT_BIT_SET.contains(tokenType); } - private TreeElement parseComment(Lexer lexer, ParsingContext context) { + private TreeElement parseComment(Lexer lexer, XmlParsingContext context) { final CompositeElement comment = ASTFactory.composite(XML_COMMENT); while (lexer.getTokenType() != null && XML_COMMENT_BIT_SET.contains(lexer.getTokenType())) { @@ -990,8 +988,8 @@ public class OldXmlParsing implements XmlElementType { int startOffset, int endOffset, int state, - TokenProcessor processor, - ParsingContext context) { + WhiteSpaceAndCommentsProcessor processor, + XmlParsingContext context) { if (state < 0) { lexer.start(lexer.getBufferSequence(), startOffset, endOffset); } @@ -1039,9 +1037,9 @@ public class OldXmlParsing implements XmlElementType { } } - public static void insertMissingTokensInTreeBody(TreeElement leaf, Lexer lexer, - TokenProcessor processor, - ParsingContext context, + private static void insertMissingTokensInTreeBody(TreeElement leaf, Lexer lexer, + WhiteSpaceAndCommentsProcessor processor, + XmlParsingContext context, ASTNode endToken) { final TreeUtil.CommonParentState commonParents = new TreeUtil.CommonParentState(); while (leaf != null) { diff --git a/xml/impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParsingContext.java b/xml/impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParsingContext.java index fb7de2c709e9..77c23ef635ae 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParsingContext.java +++ b/xml/impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParsingContext.java @@ -15,21 +15,31 @@ */ package com.intellij.psi.impl.source.parsing.xml; -import com.intellij.psi.impl.source.ParsingContext; +import com.intellij.lexer.Lexer; +import com.intellij.lexer.LexerUtil; import com.intellij.util.CharTable; /** * @author ven */ -public class XmlParsingContext extends ParsingContext { - protected final OldXmlParsing myXmlParsing; +public class XmlParsingContext { + private final OldXmlParsing myXmlParsing; + private final CharTable myTable; + + public XmlParsingContext(final CharTable table) { + myTable = table; + myXmlParsing = new OldXmlParsing(this); + } + + public CharTable getCharTable() { + return myTable; + } + + public CharSequence tokenText(Lexer lexer) { + return LexerUtil.internToken(lexer, myTable); + } public OldXmlParsing getXmlParsing() { return myXmlParsing; } - - public XmlParsingContext(final CharTable table) { - super(table); - myXmlParsing = new OldXmlParsing(this); - } } From cc6bede9b6881fbebba5b91bb451cc69b7fc9ecd Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 19 Mar 2012 16:24:16 +0400 Subject: [PATCH 35/50] SVN: already disposed in svn file url mapping --- .../src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java index 2cb502ffbe4d..ff9a56ba1c68 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java @@ -247,13 +247,15 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { + if (myProject.isDisposed()) return; synchronized (myMonitor) { myMapping.copyFrom(mapping); myMoreRealMapping.copyFrom(groupedMapping); } + // all listeners are asynchronous + myProject.getMessageBus().syncPublisher(SvnVcs.ROOTS_RELOADED).run(); } }); - myProject.getMessageBus().syncPublisher(SvnVcs.ROOTS_RELOADED).run(); } } From 764afcec62e5471cc59a369ddb1549f59a62ea5b Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Mon, 19 Mar 2012 16:44:58 +0400 Subject: [PATCH 36/50] IDEA-83008 (Maven treats goal specific required parameters as required when missing from default plugin configuration section) --- .../MavenPluginConfigurationDomExtender.java | 27 ++++++++--- ...avenPluginCompletionAndResolutionTest.java | 48 +++++++++++++++++++ 2 files changed, 69 insertions(+), 6 deletions(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java index 85689bea5aa5..4637a0cf00d7 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java @@ -34,6 +34,7 @@ import org.jetbrains.idea.maven.dom.converters.MavenPluginCustomParameterValueCo import org.jetbrains.idea.maven.dom.model.MavenDomConfiguration; import org.jetbrains.idea.maven.dom.model.MavenDomConfigurationParameter; import org.jetbrains.idea.maven.dom.model.MavenDomPluginExecution; +import org.jetbrains.idea.maven.dom.model.MavenDomPluginManagement; import org.jetbrains.idea.maven.dom.plugin.MavenDomMojo; import org.jetbrains.idea.maven.dom.plugin.MavenDomParameter; import org.jetbrains.idea.maven.dom.plugin.MavenDomPluginModel; @@ -52,11 +53,23 @@ public class MavenPluginConfigurationDomExtender extends DomExtender collectParameters(MavenDomPluginModel pluginModel, MavenDomConfiguration config) { List selectedGoals = null; @@ -124,15 +137,15 @@ public class MavenPluginConfigurationDomExtender extends DomExtendertest" + + "project" + + "1" + + + "" + + " " + + " " + + " " + + " maven-compiler-plugin" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""); + + assertCompletionVariants(myProjectPom, "compile", "testCompile"); + + createProjectPom("test" + + "project" + + "1" + + + "" + + " " + + " " + + " " + + " maven-compiler-plugin" + + " " + + " " + + " " + + " xxx" + + " " + + " " + + " " + + " " + + " " + + " " + + ""); + + checkHighlighting(); + } + public void testGoalsResolution() throws Throwable { createProjectPom("test" + "project" + From dae547e42d3b5733d995f82320fb8301bddf5aef Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 19 Mar 2012 16:46:16 +0400 Subject: [PATCH 37/50] SVN: browse Subversion Repository didn't work from welcome screen --- .../src/org/jetbrains/idea/svn/SvnVcs.java | 26 ++++++++++++++----- .../idea/svn/annotate/SvnFileAnnotation.java | 4 +-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java index a4af67b2fdcf..a817078ce36d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java @@ -216,8 +216,6 @@ public class SvnVcs extends AbstractVcs { dumpFileStatus(SvnFileStatus.EXTERNAL); dumpFileStatus(SvnFileStatus.OBSTRUCTED); - myEntriesFileListener = new SvnEntriesFileListener(project); - final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project); myAddConfirmation = vcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.ADD, this); myDeleteConfirmation = vcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.REMOVE, this); @@ -225,8 +223,10 @@ public class SvnVcs extends AbstractVcs { if (myProject.isDefault()) { myChangeListListener = null; + myEntriesFileListener = null; } else { + myEntriesFileListener = new SvnEntriesFileListener(project); upgradeIfNeeded(bus); myChangeListListener = new SvnChangelistListener(myProject, createChangelistClient()); @@ -397,7 +397,9 @@ public class SvnVcs extends AbstractVcs { } SvnApplicationSettings.getInstance().svnActivated(); - VirtualFileManager.getInstance().addVirtualFileListener(myEntriesFileListener); + if (myEntriesFileListener != null) { + VirtualFileManager.getInstance().addVirtualFileListener(myEntriesFileListener); + } // this will initialize its inner listener for committed changes upload LoadedRevisionsCache.getInstance(myProject); FrameStateManager.getInstance().addListener(myFrameStateListener); @@ -512,8 +514,10 @@ public class SvnVcs extends AbstractVcs { if (myVcsListener != null) { vcsManager.removeVcsListener(myVcsListener); } - - VirtualFileManager.getInstance().removeVirtualFileListener(myEntriesFileListener); + + if (myEntriesFileListener != null) { + VirtualFileManager.getInstance().removeVirtualFileListener(myEntriesFileListener); + } SvnApplicationSettings.getInstance().svnDeactivated(); if (myCommittedChangesProvider != null) { myCommittedChangesProvider.deactivate(); @@ -731,8 +735,16 @@ public class SvnVcs extends AbstractVcs { return myAnnotationProvider; } - public SvnEntriesFileListener getSvnEntriesFileListener() { - return myEntriesFileListener; + public void addEntriesListener(final SvnEntriesListener listener) { + if (myEntriesFileListener != null) { + myEntriesFileListener.addListener(listener); + } + } + + public void removeEntriesListener(final SvnEntriesListener listener) { + if (myEntriesFileListener != null) { + myEntriesFileListener.removeListener(listener); + } } public DiffProvider getDiffProvider() { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnFileAnnotation.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnFileAnnotation.java index 3fed59faf0cd..f6448c5c05a9 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnFileAnnotation.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnFileAnnotation.java @@ -181,7 +181,7 @@ public class SvnFileAnnotation implements FileAnnotation { myFile = file; myContents = contents; myBaseRevision = baseRevision; - myVcs.getSvnEntriesFileListener().addListener(myListener); + myVcs.addEntriesListener(myListener); myConfiguration = SvnConfiguration.getInstance(vcs.getProject()); myShowMergeSources = myConfiguration.SHOW_MERGE_SOURCES_IN_ANNOTATE; @@ -199,7 +199,7 @@ public class SvnFileAnnotation implements FileAnnotation { } public void dispose() { - myVcs.getSvnEntriesFileListener().removeListener(myListener); + myVcs.removeEntriesListener(myListener); } public LineAnnotationAspect[] getAspects() { From 64bb1c226ebb76e7795c7b5dcfadc429a001aa4b Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 19 Mar 2012 16:59:17 +0400 Subject: [PATCH 38/50] SVN: we do not need auto-upgrade to any SVN version now (native svn does not upgrade to 1.7 automatically) --- .../src/org/jetbrains/idea/svn/SvnVcs.java | 53 ------------------- 1 file changed, 53 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java index a817078ce36d..d2ffac3d0ac7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java @@ -297,10 +297,8 @@ public class SvnVcs extends AbstractVcs { SvnConfiguration.SvnSupportOptions supportOptions = null; try { ChangeListManager.getInstance(myProject).setReadOnly(SvnChangeProvider.ourDefaultListName, true); - supportOptions = myConfiguration.getSupportOptions(myProject); - upgradeToRecentVersion(supportOptions); if (! supportOptions.changeListsSynchronized()) { processChangeLists(lists); } @@ -363,30 +361,6 @@ public class SvnVcs extends AbstractVcs { } } - private void upgradeToRecentVersion(final SvnConfiguration.SvnSupportOptions supportOptions) { - if (! supportOptions.upgradeTo16Asked()) { - final SvnWorkingCopyChecker workingCopyChecker = new SvnWorkingCopyChecker(); - - if (workingCopyChecker.upgradeNeeded()) { - - Notifications.Bus.notify(new Notification(getDisplayName(), SvnBundle.message("upgrade.format.to16.question.title"), - "Old format Subversion working copies could be upgraded to version 1.6.", - NotificationType.INFORMATION, new NotificationListener() { - public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) { - final int upgradeAnswer = Messages.showYesNoDialog(SvnBundle.message("upgrade.format.to16.question.text", - SvnBundle.message("label.where.svn.format.can.be.changed.text", SvnBundle.message("action.show.svn.map.text.reference"))), - SvnBundle.message("upgrade.format.to16.question.title"), Messages.getWarningIcon()); - if (DialogWrapper.OK_EXIT_CODE == upgradeAnswer) { - workingCopyChecker.doUpgrade(); - } - - notification.expire(); - } - })); - } - } - } - @Override public void activate() { createPool(); @@ -1011,33 +985,6 @@ public class SvnVcs extends AbstractVcs { return infos; } - private class SvnWorkingCopyChecker { - private List myAllWcInfos; - - public boolean upgradeNeeded() { - myAllWcInfos = getAllWcInfos(); - for (WCInfo info : myAllWcInfos) { - if (! WorkingCopyFormat.ONE_DOT_SIX.equals(info.getFormat())) { - return true; - } - } - return false; - } - - public void doUpgrade() { - ApplicationManager.getApplication().invokeLater(new Runnable() { - public void run() { - final SvnFormatWorker formatWorker = new SvnFormatWorker(myProject, WorkingCopyFormat.ONE_DOT_SIX, myAllWcInfos); - // additionally ask about working copies with roots above the project root - formatWorker.checkForOutsideCopies(); - if (formatWorker.haveStuffToConvert()) { - ProgressManager.getInstance().run(formatWorker); - } - } - }); - } - } - @Override public RootsConvertor getCustomConvertor() { if (myProject.isDefault()) return null; From 28352a91d251361cf03804acacf3cc15cc553047 Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 19 Mar 2012 17:24:30 +0400 Subject: [PATCH 39/50] IDEA-82933 Offer "Cleanup" function in "Subversion Working Copies Information" window 1) cleanup before convert WC format to 1.7 --- .../idea/svn/dialogs/CopiesPanel.java | 28 +------------------ .../idea/svn/dialogs/SvnFormatWorker.java | 22 +++++++++++++-- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java index 7854e92c5b11..47173b7b04ab 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java @@ -153,33 +153,6 @@ public class CopiesPanel { return myRefreshLabel; } - private JTextField createField(final String text) { - final JTextField field = new JTextField(text) { - public Dimension getPreferredSize() { - Dimension preferredSize = super.getPreferredSize(); - return new Dimension(preferredSize.width, myTextHeight); - } - }; - field.setBackground(UIUtil.getPanelBackground()); - field.setEditable(false); - final Border lineBorder = BorderFactory.createLineBorder(UIUtil.getPanelBackground()); - final DottedBorder dotted = new DottedBorder(UIUtil.getActiveTextColor()); - field.setBorder(lineBorder); - //field.setFocusable(false); - field.setHorizontalAlignment(JTextField.RIGHT); - field.setCaretPosition(0); - field.addFocusListener(new FocusAdapter() { - public void focusGained(FocusEvent e) { - field.setBorder(dotted); - } - - public void focusLost(FocusEvent e) { - field.setBorder(lineBorder); - } - }); - return field; - } - private void updateList(final List infoList) { myPanel.removeAll(); final Insets nullIndent = new Insets(1, 3, 1, 0); @@ -340,6 +313,7 @@ public class CopiesPanel { final String newMode = dialog.getUpgradeMode(); if (! wcInfo.getFormat().getOption().equals(newMode)) { final WorkingCopyFormat newFormat = WorkingCopyFormat.getInstance(newMode); + ApplicationManager.getApplication().saveAll(); final Task.Backgroundable task = new SvnFormatWorker(myProject, newFormat, wcInfo) { @Override public void onSuccess() { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnFormatWorker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnFormatWorker.java index 0b25e032946f..972bab503239 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnFormatWorker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnFormatWorker.java @@ -31,6 +31,10 @@ import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.WorkingCopyFormat; +import org.tmatesoft.svn.core.SVNCancelException; +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.wc.ISVNEventHandler; +import org.tmatesoft.svn.core.wc.SVNEvent; import org.tmatesoft.svn.core.wc.SVNWCClient; import java.io.File; @@ -117,16 +121,28 @@ public class SvnFormatWorker extends Task.Backgroundable { myBeforeChangeLists = ChangeListManager.getInstance(myProject).getChangeListsCopy(); } final SVNWCClient wcClient = myVcs.createWCClient(); - + wcClient.setEventHandler(new ISVNEventHandler() { + @Override + public void handleEvent(SVNEvent event, double progress) throws SVNException { + } + @Override + public void checkCancelled() throws SVNCancelException { + if (indicator.isCanceled()) throw new SVNCancelException(); + } + }); try { for (WCInfo wcInfo : myWcInfos) { File path = new File(wcInfo.getPath()); if (! wcInfo.isIsWcRoot()) { path = SvnUtil.getWorkingCopyRoot(path); } - indicator.setText(SvnBundle.message("action.change.wcopy.format.task.progress.text", path.getAbsolutePath(), - SvnUtil.formatRepresentation(wcInfo.getFormat()), SvnUtil.formatRepresentation(myNewFormat))); + indicator.setText(SvnBundle.message("action.Subversion.cleanup.progress.text", path.getAbsolutePath())); try { + if (WorkingCopyFormat.ONE_DOT_SEVEN.equals(myNewFormat)) { + wcClient.doCleanup(path); + } + indicator.setText(SvnBundle.message("action.change.wcopy.format.task.progress.text", path.getAbsolutePath(), + SvnUtil.formatRepresentation(wcInfo.getFormat()), SvnUtil.formatRepresentation(myNewFormat))); wcClient.doSetWCFormat(path, myNewFormat.getFormat()); } catch (Throwable e) { myExceptions.add(e); From 8eb0cd322ab3c74ceeb07a53cb8664a2e44ab747 Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 19 Mar 2012 18:07:54 +0400 Subject: [PATCH 40/50] IDEA-82933 Offer "Cleanup" function in "Subversion Working Copies Information" window 1) cleanup action in Changes | Subversion Working Copies for 1.7 copies --- .../src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java index 47173b7b04ab..60b323fa3e62 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java @@ -39,6 +39,7 @@ import com.intellij.util.ui.UIUtil; import org.jetbrains.idea.svn.NestedCopyType; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.WorkingCopyFormat; +import org.jetbrains.idea.svn.actions.CleanupWorker; import org.jetbrains.idea.svn.actions.SelectBranchPopup; import org.jetbrains.idea.svn.branchConfig.SvnBranchConfigurationNew; import org.jetbrains.idea.svn.checkout.SvnCheckoutProvider; @@ -73,6 +74,7 @@ public class CopiesPanel { private int myTextHeight; private final static String CHANGE_FORMAT = "CHANGE_FORMAT"; + private final static String CLEANUP = "CLEANUP"; private final static String FIX_DEPTH = "FIX_DEPTH"; private final static String CONFIGURE_BRANCHES = "CONFIGURE_BRANCHES"; private final static String MERGE_FROM = "MERGE_FROM"; @@ -195,6 +197,9 @@ public class CopiesPanel { } else if (MERGE_FROM.equals(e.getDescription())) { if (! checkRoot(root, wcInfo.getPath(), " invoke Merge From")) return; mergeFrom(wcInfo, root, editorPane); + } else if (CLEANUP.equals(e.getDescription())) { + if (! checkRoot(root, wcInfo.getPath(), " invoke Cleanup")) return; + new CleanupWorker(new VirtualFile[] {root}, myVcs.getProject(), "action.Subversion.cleanup.progress.title").execute(); } } } @@ -262,6 +267,9 @@ public class CopiesPanel { if (info.isIsWcRoot()) { sb.append("").append("Working copy root"); } + if (WorkingCopyFormat.ONE_DOT_SEVEN.equals(info.getFormat())) { + sb.append("Cleanup"); + } sb.append("Configure Branches"); sb.append("Merge From..."); From dec44500b556155310b5cae10e27263e30fe8595 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Mon, 19 Mar 2012 18:21:57 +0400 Subject: [PATCH 41/50] [rollback] NotNullValues mustn't end up in equivalence classes table. (Check SliceTreeTest next time) --- .../intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java | 4 +++- .../codeInspection/DataFlowInspectionFixtureTest.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java index b85c5fc4a1b0..2b4005a40ef8 100644 --- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java @@ -568,6 +568,7 @@ public class DfaMemoryStateImpl implements DfaMemoryState { return true; } + /* if (dfaRight instanceof DfaNotNullValue) { if (dfaLeft instanceof DfaVariableValue) { DfaVariableState varState = getVariableState((DfaVariableValue)dfaLeft); @@ -576,11 +577,12 @@ public class DfaMemoryStateImpl implements DfaMemoryState { if (isNegated) { return varState.addNotInstanceofValue(type) || applyCondition(compareToNull(dfaVar, false)); } - return applyCondition(compareToNull(dfaVar, false)) && varState.setInstanceofValue(type); + return applyCondition(compareToNull(dfaVar, true)) && varState.setInstanceofValue(type); } return true; } + */ if (dfaRight == myFactory.getConstFactory().getNull() && dfaLeft instanceof DfaVariableValue) { final DfaVariableState varState = getVariableState((DfaVariableValue)dfaLeft); diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java index 160e94d71460..a4b7ec1fe242 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java @@ -50,7 +50,7 @@ public class DataFlowInspectionFixtureTest extends JavaCodeInsightFixtureTestCas public void testFieldInAnonymous() throws Throwable { doTest(); } public void testNullableField() throws Throwable { doTest(); } public void testCanBeNullDoesntImplyIsNull() throws Throwable { doTest(); } - public void testAnnReport() throws Throwable { doTest(); } + /*public void testAnnReport() throws Throwable { doTest(); }*/ public void testBigMethodNotComplex() throws Throwable { doTest(); } } From 44454cadbaf501cc4329dd17c86e9c3dcb290161 Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Mon, 19 Mar 2012 18:32:52 +0400 Subject: [PATCH 42/50] Revert last commit --- .../idea/maven/dom/MavenPluginConfigurationDomExtender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java index 4637a0cf00d7..44cb3dff60bd 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java @@ -53,7 +53,7 @@ public class MavenPluginConfigurationDomExtender extends DomExtender Date: Mon, 19 Mar 2012 18:30:29 +0400 Subject: [PATCH 43/50] project view hover icons --- .../icons/src/general/collapseAllHover.png | Bin 0 -> 1086 bytes platform/icons/src/general/gearHover.png | Bin 0 -> 1513 bytes platform/icons/src/general/hideDownHover.png | Bin 0 -> 1137 bytes .../icons/src/general/hideDownPartHover.png | Bin 0 -> 1132 bytes platform/icons/src/general/hideLeftHover.png | Bin 0 -> 1159 bytes .../icons/src/general/hideLeftPartHover.png | Bin 0 -> 1143 bytes platform/icons/src/general/hideRightHover.png | Bin 0 -> 1187 bytes .../icons/src/general/hideRightPartHover.png | Bin 0 -> 1157 bytes platform/icons/src/general/locateHover.png | Bin 0 -> 1432 bytes .../ide/projectView/impl/ProjectViewImpl.java | 2 + .../openapi/wm/impl/ToolWindowHeader.java | 80 ++++++++++++++++-- 11 files changed, 74 insertions(+), 8 deletions(-) create mode 100755 platform/icons/src/general/collapseAllHover.png create mode 100755 platform/icons/src/general/gearHover.png create mode 100755 platform/icons/src/general/hideDownHover.png create mode 100755 platform/icons/src/general/hideDownPartHover.png create mode 100755 platform/icons/src/general/hideLeftHover.png create mode 100755 platform/icons/src/general/hideLeftPartHover.png create mode 100755 platform/icons/src/general/hideRightHover.png create mode 100755 platform/icons/src/general/hideRightPartHover.png create mode 100755 platform/icons/src/general/locateHover.png diff --git a/platform/icons/src/general/collapseAllHover.png b/platform/icons/src/general/collapseAllHover.png new file mode 100755 index 0000000000000000000000000000000000000000..c061455271447762da365330276a655c4984030a GIT binary patch literal 1086 zcmaJ=TSyd97#khaQTuhaL(Fk^(6RDtfFWB(YYS&Zw(Bv<;j&7ryWNzyCk~8Ea{7 zEGykxN)SX@G$O?Dyd967CB^vv2cAVi}ksDM@T2ju?**ASg(U)dAFBmIdbEpa5O{i;NwDgBNpEIsV;OYCDw9 z2Mr)1Xe1!)$yKqX3nFNCL7fb?x@nGVQ#2W-%{6>1#z!?1iJAnWf}g?)w4%s-*uyzl z)+KnkfS2P!Tp(1-1;eh8+v^Jl1gA5{6`<6o0uAN3@)kFgmut6zs^iE4FqD2EhYhHb zYboKBIlq@+UM_>pF!sg%b>oCzh<)F{x(2stSi^rlrHnH_kl$xL99u>1Abh z{*HOAzvOz&a?SJ|fA(z0<@tiZ{wt5aO%_g_d_7@}Hyv9Tp8Q$WQywUK_O<1^W&P&Z zk?}*G$x8L$7t8uI-#Aiw;PXml#hxW^`;Q$DDkA&tN8Z9$W$}x*3#un?nO=Ui;8&@z qyZrrWH9Iz;jizhsUPO-XDk@=#;^dprxf7=h`$b1X&BEP4`^X=r(ry3% literal 0 HcmV?d00001 diff --git a/platform/icons/src/general/gearHover.png b/platform/icons/src/general/gearHover.png new file mode 100755 index 0000000000000000000000000000000000000000..4d4518ab2b76f161b7e55f2807435546f8363b2e GIT binary patch literal 1513 zcmaJ>drT8|9KWr)DFe|oI#9>X1Eb5JcUK;@CzVGJq>&=4FqkiTv;=)>| zgH)MPFfxYIp(Ji@8BVf^&x2IAX-IUzO>kQb%ncz?WVPuK>FvtP{V{gQ-S3gl=kxu1 zA30}s*2a*a}JR3Qj+e z7>zL&VLCj0I+l1+K_whVV=!#BT4mN)8O0RCs8Xqf5jiZE$B2j+w$j28wipW=IirA+ ztbsAnoQbl40Y##aD(6&?=yWOtGd(M7VW-O^77Vr#G>poSKuR+}t@i(+X7enX<#gn8 zzyB%B=2X%otRq>foH2-vD~b$+qA@i?5*)?kP*mAW6|+kyj$%tF8dPtIm!V*u$zr6e z>?B^R#WWU{BP<3|gR3A>L1r=;F{J`UQrD&83N%%LqG_lSSEk_c2pXTRP^T(z`3x7Q z4CQ9h!p(4v&$(%Has#7arp3rO$(SlgV>&~b!O4^{)7)M}BXfC~;u`1nqMnlri)P?J zWB=9YnJaO60^8ZK6%Vt6Pg=xjXT-5iUUZxUfERaY@RS_e-NI*rkRGOXr{OS)e?;WZ7F0?7@dUNBVc&|3g3S9Te2x)H z;2LVivP006Aa=;##{1=`+IYS9_-K;HlUKlBsq$R@#N~3OWb8Ys(;aSZcI_D*=?3;1 zel6>^?-_or<>@v@@AB)HP9|@cB-}3l&Lz}#a-CPZe*n&^8yZW8_tEZ^b*E3{4xZXM z@kDjNHJaou(65uIy3Q!v)k~s^cU<81)->(s7l*#-z6kT-6-O_$kCs?Dpm*G7xkTy< z3FG31egkkmD{tGaMQc||>U-*!omuZ4kh%rC5WZ72cJ=W{DAeutZHlhm8Z;u#sa=K%+UqZR(upxEhJN(vtLhq9De%Z){Xn& z>IYG)3p%`sUw}1TKE=HV|Ac3AW_F508s+WpuNmo%&TQ+zJMP;r3%mLW{@kh`HN(H$ zxz{4_LQ^o8yRvTl(cp++Pafdy!r=U^&=XHzV_L1?AFQu$MI70Grt60b^|tlyc-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxKsVXI%uvD1M9IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr4|esh*)icxGNo zet9uiy|1s8XI^nhVqS8pr;Du;&;-5A%oHmFb7wO{V-qKHLnlW=LsvsfBU3X+Cksa- zBR5M!XIB@PUYGpj(%jU%5}4i;gkEQydO=Acw*Y9fOKMSOS!#+~QGTuh*vnR#xZPrj z(>$o&6x?oc#Hm*w=oo!a#3DsBObD2IKumbD1#;jCKQ#}S+KYh6dg+y)r+``Fsi%u$ zNX4zBKmY&RGrKaRFfi_spKs&HJZsyWpZ)&xIwx?~8*hFvRXyXt^7}kfBtN`+F2Co~ zk2~AtUH1I@C4G*K$-Tt2XUC$zjR}|Q11;^?#M0c_?Cbv<@2UGT@!>y~dbdTq42&=D z^!{&s!YXmk_Q!z_C0xtW7F}wrc*eHpV#m9tzbZ={-Ffs)a_xT4pW55mII~moMY$TA zn%a!jl9K=a{yzSJz2*O()QYdKR1ddU@VoUy?D+78o7q}hIfVN{HP8QpIw|LyUGCZZ z?y!|QAM?9`Bi8N91}CmcH@-(njS>zU85tPa7^IT!zBzlwFCJ6~c)I$ztaD0e0sw=) Bg-8GZ literal 0 HcmV?d00001 diff --git a/platform/icons/src/general/hideDownPartHover.png b/platform/icons/src/general/hideDownPartHover.png new file mode 100755 index 0000000000000000000000000000000000000000..97d7fda24393004d210a5264df9d5a720a8e7c24 GIT binary patch literal 1132 zcmaJ=TWHfz7>-uwWg7_MWeV<)`k-QS>3Uh?>g<|yE7&o+f)!s(ld~;s$%)CC?S@z< z-Uf=kh~UdWeNqtgNpLVPc!MeGlc6h+l0+r%`Pm$_qc75UeHb7V5rVJV9{Q5Vk37NlY-%0ZCS3 z53OagIGfroC`e~y7sC{EldvhOskvavN-xA92fH;RN`JjEMgvWa(mR7GE@j4HkJdJ5 z!Op?!0}-Aqe(PN?Gn;rVm21pMd==lO@U?e z`8<lAAe$`DaBfOvU@G;0sIJeUZJdUG{Qgte&J384O+y>?TMD_jF0UKP6yg?? zF|slU^_8pG(StCudyom@ok4~NJ2gW^d3y$*N(o8B#2`~>^@_Wzc919WCMm`; zg%`P!<1~9DN~Kng)*oxEy0_{1==C@w14*gtzG1gkc2K22{BS(%54-GFlTvs>!bL!NY1Eudv z?z~&iCQf9pPnN1ZTdKXDwu$>+otlr&K3_dLw0r82llAOax4IfIUhjs!(=BVNowp0x hK5^-DYd3}{aFa@&oxsauPvY+TPfG3Lm6kn+egOvpet-Y~ literal 0 HcmV?d00001 diff --git a/platform/icons/src/general/hideLeftHover.png b/platform/icons/src/general/hideLeftHover.png new file mode 100755 index 0000000000000000000000000000000000000000..37e59950136e8eb691dede61f2528b34d77f1a32 GIT binary patch literal 1159 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+n3Xa^B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxKsVXI%uvD1M9IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr4|esh*)icxGNo zet9uiy|1s8XI^nhVqS8pr;Du;&;-5A%oHnU3rj;sGjk(zLnm`XLsvsb17|ZgGc#u+ zOABXnBNGdlUYGpj(%jU%5}4i;gkEEudO=Acw*Y9fOKMSOS!#+~QGTuh*vnR#xZPra z(>$o&6x?nx#Hm*w=oo!a#3DsBObD2IKumbD1#;jCKQ#}S+KYh6I{0C{6fjHt_H=O! zskoK&=l_3uX4Qs?v)JCa3ze(fZ0M6s|G#;|CWAl!zxOY^a&^MQ2<90HJ^J?ljZPF5 z8Pxp$+^?d4fcM9TzvhRJ$Ja~R{XJxmpj*gR^ZV?FXUF9iIMxT4gumPOs`)&Fn8ah{ z3k}!f>kaq({v*83viPv;{Pp$!HY{W{@NziJ`{U1J{lmBO>m}~h{$YHUJvDFBq-oF7 zlhe{zHp*Tojeq^kx%A+7`~Q;r{e`wTJ9M5{QT5Yk^f4Yv*EKX47B`^1L2|aJu%e6i5%Jq8C4k}(QdF_QZd0Fyq zmv(5o7KZ(2vy6e;KN|>wARDs%rL0v%#XtL(I0P#vD06Vz6n0x}Z!fi1_s4F5(2NLExw^v8ni^q7 zf+>(P-XA0zy0;3b1?t2m#?J?E^gEcpnGCULJ_Sun2g1`(cPTOC1+8Qs1^O zVnvt&#-_+|rBaD4`B`L5aJ(Q09Pn{IpO+xK_OyXz$7|RJ>k1OI6-zU*h78(Ol=G;F zBMgc3WeU2vBWu{(Wg-RR9NFY}7Pu+ZfvMF0Lv?)zZQ~4l74Lrv+u3Ooav5l&qNR|= zjURMfnPS|6GDcPwp{aTm(*=Z)T|g!s9}coSJ)#*ZD%o53R7y-5HkJ(qCZz~N6j)7D z#aJko2>L^zFy9;J`2;WcK`0UP^C6)x{vI*wTnQ;f9U8dKRbO$#4Y}?p=qB+jK}-7x zs(lvH>8+GSt#K@YhI-pvwQ(%LhFp#W!?}(9SEK7kWP04~&e#%TXYipxrrjcAy`28( zD7g|(lTs|}{G5MLt3^GB=9a#0{#+lmC8N4 z<*Uy>`5@PP>hC|kh@JT}eD2eGV?RE;C!aOG)wtR=j*@wmJ7e$UFaz@8^xA}gKk znEPS1c=DI$%KQA9A+H_Se1(vo8*LPh4xOwiMUDfAFa5x3-Q`(b>(n z?@|NLH>%aecRXvW)$;!ELasXY?Ygj=^)KzBnp&xK@$B+v=ev%$zk+09Q2MSnH~$ZO C9Eh0! literal 0 HcmV?d00001 diff --git a/platform/icons/src/general/hideRightHover.png b/platform/icons/src/general/hideRightHover.png new file mode 100755 index 0000000000000000000000000000000000000000..f971f5cdab811dbe41d06e05eab71b4ecf1b8ec3 GIT binary patch literal 1187 zcmaJ>eP|PB9KKtp9j?x}4Yn3WkE>%K=Dyn6-mPhxI1BD#?-HMjR_Q}@TRgS+>G z=Xri#4>#4{w`1dmrVRu^Y>e%c6L|G`?{n+%xA~!~;H44urqBS)pqyd@BBa4IpkjtH z1QI~e#`b>)x(K3<){`leitmzCXfTS0Ve*EB*#yxQ%v*{&3=owDL%JED|F|?uQ@R$Q z_q4~kxD^3eedo9h2FCl6>iDoKYILxh>dH%4zyL_0^2UhiNcjN0qATIOcg@n&3Iq)Y z=qE{~;{8+v+JI_jIKRqm=c(;&4By6yZQ?dc;CPPZ1(xgZ^PJS)A#psl`p`ISY8xGmJ?V(@MDDE88eZR_nS^jRY3-hYU>u#p-Fj) zN*a!$0F5(!Qi5Tv$(qh;n{dO}ykfCD!+9lDf${kNLk(jM?VtpBn(u!KJIOH%unFM6 zQCr1>%d~i*EGc3G1wlIr;YhWM{aJ{hlZ6%)8E9vCYL9MeFz2k`<8diwI!G~95R(Hm zR$z2plQ=;Pg~PJg!H2^<-^+_pAtH7PywJvlLebVpl`BJa)Bq-`a9up|sHwNg)oSO`S(D4+WLR&o{~C1l3cJVKuGtnJ){GBK>~>=J z6^q~39|!a1{e8bZ0Hq?CCFbGe+=4sUWSyU%*?ec+r>|XdXAdqJ_wF2W37=cf`S!Y% z`kS{ePmpf~%NHJ8+44c=E3#+iYZnZbrix^xN50kYOz_<9MLmD5|jH2t&!5PN$+O@j2oJvZ4}jjP AoB#j- literal 0 HcmV?d00001 diff --git a/platform/icons/src/general/hideRightPartHover.png b/platform/icons/src/general/hideRightPartHover.png new file mode 100755 index 0000000000000000000000000000000000000000..e4daccb9083894486a99cbe9369cc9552e9997c6 GIT binary patch literal 1157 zcmaJ>UuY9|9KSZub+t0*d{77WJQ?i4+@CZty<5|m~CJ~?6dG8p1mQ>|>cF(!yUC=wAtL}{xcwKeVeySAx57!U4#fB1Yp z-#@?4@4oNuimz|j+CUJ*`b3AA#N!6{t*^u1rk9S4hb^eR5B0zd%E=ZWA}UM+GNH>^ zkOZ4+QhlgT>J${H)3S@9^SX)I1koDKo3b(h5Sa#9%?MF5e-tTFQ$tj5 zKw>2`2Ku#*Q492pcBPcj0fkqoa2wg07qEa1kWA+FLBkgEA!=Dyz;kz-p~z(j8VFG< zN%cwHWDHt>4A87sVRv!lEDg@Bz-K$GMtZLgI{=v*@mtt`XwJkPK`#^>{5gx4N1kev4#_Ku2z2yDgDOr$}BbQR?^ z97Z7uXSz~?Zm!81_G+7O!0)<3M9}VsCK>Aq&>Y#T87j=#%Xmo=5{8XrLjegfL}3M5 z(^Nrh;hS;0qd_hj<+ye(8W7ob-ro{oqyAuXi@(AZp)#xk168={J8rBh*R_If;>aSf zv_nAMV?mutGB_E=J=pgSy0V4c<4)IXix+Fg2L^V#g>Bum zcRG%*#C$@Gr1E#uWycA7zABu)Q}^tXbll(8xchpf?!mSDhw0jj&KtSBApPyk%@ki0 zYdWT`|9rDEewCS60$<-X@6=>oUVz2TM;6Qf&3@i7MXdYreDB1Kn){1;|EX4%mo{bz;q~(`4^Ez$d9-Er>EotT zkDSr z1<%~X^wgl##FWaylc_cg49rTIArU1JzCKpT`MG+DAT@dwxdlMo3=B5*6$OdO*{LN8 zNvY|XdA3ULckfqH$V{%1*XSQL?vFu&J;D8jzb> zlBiITo0C^;Rbi_HHrEQs1_|pcDS(xfWZNo192Makpx~Tel&WB=XP}#GU}mUbW};_k zVqj@vsiRh+i#(Mch>H3D2mX`VkM*2oZxQ#zd*q`*i_F@Av`lL zCBM8Ftlrnx$}_LHBrz{J)zigR321^|W@d_&i>rl&sezH3xuKJ}p`ojxg}I5LrK72V zn~95|g{!e6Os`9Ra%paAUI|QZ3S6(T0ZzT3q>x(xwAm%KD6=dz#jPkmR{`v0t4!Q( zalvUGRBsASw-~wN)TknMZjde^+`}G0|OI} zr;B4q#jT`2|Nq-FTQ+d^%W#W4p5nsx#zBVlNLc;9zv0Z<2}yfcm-I1yG*bA-8GNGS zNytz6`hVMUcmF%{;K$-}n?o{ZiWClRxBq9iX^QZ#M@uzJ8=G5qa%p@Kh*Um3*F65( z8Oy@+-#$(5kFWpp$M|^2yyb!_g})w7ui`74CK4-I_fCX+>0vD;8%2kQ_6hcNzrUIn z9(-Bdm;Qdg{m*xA&A;yb+2?!yUR^RnqJXpt+a%_dj4NB&&rK@k|D3ny&#&Kyf6E^{ zzWVO|<|FIw{^dBPz#znYvhhm8l_u6kzf{lY;&;Cf8S}qqy7_zI3`XAOqmEe)S&mf_ zkJDtHSDgLv-CCGi`SASv|0VwY`*(VS_3?RvmMdbH%ltWi=G2)3r%oOD@cn!}+r|H9 z=IFGq-}^&X^Z57wzqjA-nQ#B+fK)pFyLyJpdzfT+=ESV|pKtT)i}V|j)7NbKtG?gc z$CL7Tku`tkdF~+QAnr%a%+KH6&NsdmSF!5Po5THP3gHYYX_o(|FmpKTiZYxkZ2~&@ zkn`8e*Y{7JXZQ1yLh;k12cFNbYY6f<^Ss<%!a?E)Tj$dCJ0uu@rgcv$I&#VEgyBZR zyr&NzPvAD2x_95pZ`s8YcFbS(;^fxl^4WENzdXKpKmPyT__JIUE%Tm8v;>=PFf=ks z0Tw-N%$eREC5AHTKfc$iPMG(#tn5H}PUch<27v^I=hlHM1LPN&g33xyS3j3^P6 Date: Mon, 19 Mar 2012 18:25:26 +0400 Subject: [PATCH 44/50] Move some functionality from FileUtil to FileUtilLight. This fixes git-ssh, because SSHMain script is no more dependent on trove4j. --- .../intellij/openapi/util/io/FileUtil.java | 203 +-------------- .../openapi/util/io/FileUtilLight.java | 238 ++++++++++++++++++ .../jetbrains/git4idea/ssh/GitSSHService.java | 4 +- .../org/jetbrains/git4idea/ssh/SSHMain.java | 4 +- .../git4idea/util/ScriptGenerator.java | 8 +- 5 files changed, 247 insertions(+), 210 deletions(-) create mode 100644 platform/util/src/com/intellij/openapi/util/io/FileUtilLight.java diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java index 512ccc600349..a8ab9439d248 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java @@ -35,7 +35,6 @@ import org.intellij.lang.annotations.RegExp; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.TestOnly; import java.io.*; import java.lang.reflect.Method; @@ -44,7 +43,7 @@ import java.util.*; import java.util.regex.Pattern; @SuppressWarnings({"UtilityClassWithoutPrivateConstructor"}) -public class FileUtil { +public class FileUtil extends FileUtilLight { public static final int MEGABYTE = 1024 * 1024; @NonNls public static final String ASYNC_DELETE_EXTENSION = ".__del__"; @@ -58,7 +57,6 @@ public class FileUtil { // do not use channels to copy files larger than 5 Mb because of possible MapFailed error private static final long CHANNELS_COPYING_LIMIT = 5L * MEGABYTE; - private static String ourCanonicalTempPathCache = null; private static final int MAX_FILE_DELETE_ATTEMPTS = 10; public static final Method JAVA_IO_FILESYSTEM_GET_BOOLEAN_ATTRIBUTES_METHOD; public static final Object/* java.io.FileSystem */ JAVA_IO_FILESYSTEM; @@ -186,63 +184,6 @@ public class FileUtil { } } - @NotNull - public static String loadFile(@NotNull File file) throws IOException { - return loadFile(file, null, false); - } - - @NotNull - public static String loadFile(@NotNull File file, boolean convertLineSeparators) throws IOException { - return loadFile(file, null, convertLineSeparators); - } - - @NotNull - public static String loadFile(@NotNull File file, String encoding) throws IOException { - return loadFile(file, encoding, false); - } - - @NotNull - public static String loadFile(@NotNull File file, String encoding, boolean convertLineSeparators) throws IOException { - final String s = new String(loadFileText(file, encoding)); - return convertLineSeparators ? StringUtil.convertLineSeparators(s) : s; - } - - @NotNull - public static char[] loadFileText(@NotNull File file) throws IOException { - return loadFileText(file, null); - } - - @NotNull - public static char[] loadFileText(@NotNull File file, @NonNls String encoding) throws IOException { - InputStream stream = new FileInputStream(file); - Reader reader = encoding == null ? new InputStreamReader(stream) : new InputStreamReader(stream, encoding); - try { - return loadText(reader, (int)file.length()); - } - finally { - reader.close(); - } - } - - @NotNull - public static char[] loadText(@NotNull Reader reader, int length) throws IOException { - char[] chars = new char[length]; - int count = 0; - while (count < chars.length) { - int n = reader.read(chars, count, chars.length - count); - if (n <= 0) break; - count += n; - } - if (count == chars.length) { - return chars; - } - else { - char[] newChars = new char[count]; - System.arraycopy(chars, 0, newChars, 0, count); - return newChars; - } - } - @NotNull public static byte[] loadFileBytes(@NotNull File file) throws IOException { byte[] bytes; @@ -396,120 +337,6 @@ public class FileUtil { return result; } - @NotNull - public static File createTempDirectory(@NotNull @NonNls String prefix, @Nullable @NonNls String suffix) throws IOException { - File file = doCreateTempFile(prefix, suffix); - file.delete(); - file.mkdir(); - file.deleteOnExit(); - return file; - } - - @NotNull - public static File createTempDirectory(File dir, @NotNull @NonNls String prefix, @Nullable @NonNls String suffix) throws IOException { - File file = doCreateTempFile(prefix, suffix, dir); - file.delete(); - file.mkdir(); - file.deleteOnExit(); - return file; - } - - @NotNull - public static File createTempFile(@NonNls final File dir, @NotNull @NonNls String prefix, @Nullable @NonNls String suffix, final boolean create) - throws IOException { - return createTempFile(dir, prefix, suffix, create, true); - } - - public static File createTempFile(@NonNls final File dir, - @NotNull @NonNls String prefix, - @Nullable @NonNls String suffix, - final boolean create, - boolean deleteOnExit) throws IOException { - File file = doCreateTempFile(prefix, suffix, dir); - file.delete(); - if (create) { - file.createNewFile(); - } - if (deleteOnExit) { - file.deleteOnExit(); - } - return file; - } - - @NotNull - public static File createTempFile(@NotNull @NonNls String prefix, @Nullable @NonNls String suffix) throws IOException { - return createTempFile(prefix, suffix, false); //false until TeamCity fixes its plugin - } - - @NotNull - public static File createTempFile(@NotNull @NonNls String prefix, @Nullable @NonNls String suffix, boolean deleteOnExit) throws IOException { - File file = doCreateTempFile(prefix, suffix); - file.delete(); - file.createNewFile(); - if (deleteOnExit) { - file.deleteOnExit(); - } - return file; - } - - @NotNull - private static File doCreateTempFile(String prefix, String suffix) throws IOException { - return doCreateTempFile(prefix, suffix, new File(getTempDirectory())); - } - - @NotNull - private static File doCreateTempFile(@NotNull String prefix, String suffix, final File dir) throws IOException { - dir.mkdirs(); - - if (prefix.length() < 3) { - prefix = (prefix + "___").substring(0, 3); - } - - int exceptionsCount = 0; - while (true) { - try { - //noinspection SSBasedInspection - final File temp = File.createTempFile(prefix, suffix, dir); - return normalizeFile(temp); - } - catch (IOException e) { // Win32 createFileExclusively access denied - if (++exceptionsCount >= 100) { - throw e; - } - } - } - } - - private static File normalizeFile(File temp) throws IOException { - final File canonical = temp.getCanonicalFile(); - return SystemInfo.isWindows && canonical.getAbsolutePath().contains(" ") ? temp.getAbsoluteFile() : canonical; - } - - public static String getTempDirectory() { - if (ourCanonicalTempPathCache == null) { - ourCanonicalTempPathCache = calcCanonicalTempPath(); - } - return ourCanonicalTempPathCache; - } - - @TestOnly - public static void resetCanonicalTempPathCache(final String tempPath) { - ourCanonicalTempPathCache = tempPath; - } - - private static String calcCanonicalTempPath() { - final File file = new File(System.getProperty("java.io.tmpdir")); - try { - final String canonical = file.getCanonicalPath(); - if (!SystemInfo.isWindows || !canonical.contains(" ")) { - return canonical; - } - } - catch (IOException ignore) { - } - return file.getAbsolutePath(); - } - public static void asyncDelete(@NotNull File file) { final File tempFile = renameToTempFileOrDelete(file); if (tempFile == null) { @@ -1130,20 +957,6 @@ public class FileUtil { } } - /** - * Set executable attribute, it makes sense only on non-windows platforms. - * - * @param path the path to use - * @param executableFlag new value of executable attribute - * @throws IOException if there is a problem with setting the flag - */ - public static void setExecutableAttribute(@NotNull String path, boolean executableFlag) throws IOException { - final File file = new File(path); - if (!file.setExecutable(executableFlag) && file.canExecute() != executableFlag) { - LOG.warn("Can't set executable attribute of '" + path + "' to " + executableFlag); - } - } - public static void appendToFile(@NotNull File file, @NotNull String text) throws IOException { writeToFile(file, text.getBytes("UTF-8"), true); } @@ -1296,20 +1109,6 @@ public class FileUtil { return false; } - @NotNull - public static File generateRandomTemporaryPath() throws IOException { - File file = new File(getTempDirectory(), UUID.randomUUID().toString()); - int i = 0; - while (file.exists() && i < 5) { - file = new File(getTempDirectory(), UUID.randomUUID().toString()); - ++i; - } - if (file.exists()) { - throw new IOException("Couldn't generate unique random path."); - } - return normalizeFile(file); - } - @Nullable public static String getLocationRelativeToUserHome(@Nullable final String path) { if (path == null) return null; diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtilLight.java b/platform/util/src/com/intellij/openapi/util/io/FileUtilLight.java new file mode 100644 index 000000000000..ae174b7901d7 --- /dev/null +++ b/platform/util/src/com/intellij/openapi/util/io/FileUtilLight.java @@ -0,0 +1,238 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.util.io; + +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.text.StringUtil; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; + +import java.io.*; +import java.util.UUID; + +/** + * This is a light version of {@link FileUtil}. + * It is used by scripts loaded externally and almost independent of IDEA, so add here as few dependencies as possible. + */ +public class FileUtilLight { + + private static String ourCanonicalTempPathCache = null; + private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.io.FileUtilLight"); + + + @NotNull + public static File createTempDirectory(@NotNull @NonNls String prefix, @Nullable @NonNls String suffix) throws IOException { + File file = doCreateTempFile(prefix, suffix); + file.delete(); + file.mkdir(); + file.deleteOnExit(); + return file; + } + + @NotNull + public static File createTempDirectory(File dir, @NotNull @NonNls String prefix, @Nullable @NonNls String suffix) throws IOException { + File file = doCreateTempFile(prefix, suffix, dir); + file.delete(); + file.mkdir(); + file.deleteOnExit(); + return file; + } + + @NotNull + public static File createTempFile(@NonNls final File dir, @NotNull @NonNls String prefix, @Nullable @NonNls String suffix, final boolean create) + throws IOException { + return createTempFile(dir, prefix, suffix, create, true); + } + + public static File createTempFile(@NonNls final File dir, + @NotNull @NonNls String prefix, + @Nullable @NonNls String suffix, + final boolean create, + boolean deleteOnExit) throws IOException { + File file = doCreateTempFile(prefix, suffix, dir); + file.delete(); + if (create) { + file.createNewFile(); + } + if (deleteOnExit) { + file.deleteOnExit(); + } + return file; + } + + @NotNull + public static File createTempFile(@NotNull @NonNls String prefix, @Nullable @NonNls String suffix) throws IOException { + return createTempFile(prefix, suffix, false); //false until TeamCity fixes its plugin + } + + @NotNull + public static File createTempFile(@NotNull @NonNls String prefix, @Nullable @NonNls String suffix, boolean deleteOnExit) throws IOException { + File file = doCreateTempFile(prefix, suffix); + file.delete(); + file.createNewFile(); + if (deleteOnExit) { + file.deleteOnExit(); + } + return file; + } + + @NotNull + private static File doCreateTempFile(String prefix, String suffix) throws IOException { + return doCreateTempFile(prefix, suffix, new File(getTempDirectory())); + } + + @NotNull + private static File doCreateTempFile(@NotNull String prefix, String suffix, final File dir) throws IOException { + dir.mkdirs(); + + if (prefix.length() < 3) { + prefix = (prefix + "___").substring(0, 3); + } + + int exceptionsCount = 0; + while (true) { + try { + //noinspection SSBasedInspection + final File temp = File.createTempFile(prefix, suffix, dir); + return normalizeFile(temp); + } + catch (IOException e) { // Win32 createFileExclusively access denied + if (++exceptionsCount >= 100) { + throw e; + } + } + } + } + + private static File normalizeFile(File temp) throws IOException { + final File canonical = temp.getCanonicalFile(); + return SystemInfo.isWindows && canonical.getAbsolutePath().contains(" ") ? temp.getAbsoluteFile() : canonical; + } + + public static String getTempDirectory() { + if (ourCanonicalTempPathCache == null) { + ourCanonicalTempPathCache = calcCanonicalTempPath(); + } + return ourCanonicalTempPathCache; + } + + private static String calcCanonicalTempPath() { + final File file = new File(System.getProperty("java.io.tmpdir")); + try { + final String canonical = file.getCanonicalPath(); + if (!SystemInfo.isWindows || !canonical.contains(" ")) { + return canonical; + } + } + catch (IOException ignore) { + } + return file.getAbsolutePath(); + } + + @TestOnly + public static void resetCanonicalTempPathCache(final String tempPath) { + ourCanonicalTempPathCache = tempPath; + } + + @NotNull + public static File generateRandomTemporaryPath() throws IOException { + File file = new File(getTempDirectory(), UUID.randomUUID().toString()); + int i = 0; + while (file.exists() && i < 5) { + file = new File(getTempDirectory(), UUID.randomUUID().toString()); + ++i; + } + if (file.exists()) { + throw new IOException("Couldn't generate unique random path."); + } + return normalizeFile(file); + } + + /** + * Set executable attribute, it makes sense only on non-windows platforms. + * + * @param path the path to use + * @param executableFlag new value of executable attribute + * @throws IOException if there is a problem with setting the flag + */ + public static void setExecutableAttribute(@NotNull String path, boolean executableFlag) throws IOException { + final File file = new File(path); + if (!file.setExecutable(executableFlag) && file.canExecute() != executableFlag) { + LOG.warn("Can't set executable attribute of '" + path + "' to " + executableFlag); + } + } + + @NotNull + public static String loadFile(@NotNull File file) throws IOException { + return loadFile(file, null, false); + } + + @NotNull + public static String loadFile(@NotNull File file, boolean convertLineSeparators) throws IOException { + return loadFile(file, null, convertLineSeparators); + } + + @NotNull + public static String loadFile(@NotNull File file, String encoding) throws IOException { + return loadFile(file, encoding, false); + } + + @NotNull + public static String loadFile(@NotNull File file, String encoding, boolean convertLineSeparators) throws IOException { + final String s = new String(loadFileText(file, encoding)); + return convertLineSeparators ? StringUtil.convertLineSeparators(s) : s; + } + + @NotNull + public static char[] loadFileText(@NotNull File file) throws IOException { + return loadFileText(file, null); + } + + @NotNull + public static char[] loadFileText(@NotNull File file, @NonNls String encoding) throws IOException { + InputStream stream = new FileInputStream(file); + Reader reader = encoding == null ? new InputStreamReader(stream) : new InputStreamReader(stream, encoding); + try { + return loadText(reader, (int)file.length()); + } + finally { + reader.close(); + } + } + + @NotNull + public static char[] loadText(@NotNull Reader reader, int length) throws IOException { + char[] chars = new char[length]; + int count = 0; + while (count < chars.length) { + int n = reader.read(chars, count, chars.length - count); + if (n <= 0) break; + count += n; + } + if (count == chars.length) { + return chars; + } + else { + char[] newChars = new char[count]; + System.arraycopy(chars, 0, newChars, 0, count); + return newChars; + } + } + +} diff --git a/plugins/git4idea/src/org/jetbrains/git4idea/ssh/GitSSHService.java b/plugins/git4idea/src/org/jetbrains/git4idea/ssh/GitSSHService.java index 201f654b16f6..389254f3ab8a 100644 --- a/plugins/git4idea/src/org/jetbrains/git4idea/ssh/GitSSHService.java +++ b/plugins/git4idea/src/org/jetbrains/git4idea/ssh/GitSSHService.java @@ -15,7 +15,7 @@ */ package org.jetbrains.git4idea.ssh; -import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilLight; import com.trilead.ssh2.KnownHosts; import gnu.trove.THashMap; import org.apache.commons.codec.DecoderException; @@ -67,7 +67,7 @@ public abstract class GitSSHService { if (myScriptPath == null || !myScriptPath.exists()) { ScriptGenerator generator = new ScriptGenerator(GitSSHHandler.GIT_SSH_PREFIX, SSHMain.class, getTempDir()); generator.addClasses(XmlRpcClientLite.class, DecoderException.class); - generator.addClasses(KnownHosts.class, FileUtil.class); + generator.addClasses(KnownHosts.class, FileUtilLight.class); generator.addResource(SSHMainBundle.class, "/org/jetbrains/git4idea/ssh/SSHMainBundle.properties"); myScriptPath = generator.generate(); } diff --git a/plugins/git4idea/src/org/jetbrains/git4idea/ssh/SSHMain.java b/plugins/git4idea/src/org/jetbrains/git4idea/ssh/SSHMain.java index 5a3af1dd5d4f..85b67ce944ca 100644 --- a/plugins/git4idea/src/org/jetbrains/git4idea/ssh/SSHMain.java +++ b/plugins/git4idea/src/org/jetbrains/git4idea/ssh/SSHMain.java @@ -15,7 +15,7 @@ */ package org.jetbrains.git4idea.ssh; -import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilLight; import com.intellij.util.ArrayUtil; import com.trilead.ssh2.*; import com.trilead.ssh2.crypto.PEMDecoder; @@ -302,7 +302,7 @@ public class SSHMain { if (file.exists()) { // if encrypted ask user for passphrase String passphrase = null; - char[] text = FileUtil.loadFileText(file); + char[] text = FileUtilLight.loadFileText(file); if (isEncryptedKey(text)) { // need to ask passphrase from user int i; diff --git a/plugins/git4idea/src/org/jetbrains/git4idea/util/ScriptGenerator.java b/plugins/git4idea/src/org/jetbrains/git4idea/util/ScriptGenerator.java index 34de8ac04e53..b754a56493e6 100644 --- a/plugins/git4idea/src/org/jetbrains/git4idea/util/ScriptGenerator.java +++ b/plugins/git4idea/src/org/jetbrains/git4idea/util/ScriptGenerator.java @@ -17,7 +17,7 @@ package org.jetbrains.git4idea.util; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilLight; import com.intellij.util.PathUtil; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NonNls; @@ -149,8 +149,8 @@ public class ScriptGenerator { */ @SuppressWarnings({"HardCodedStringLiteral"}) public File generate() throws IOException { - File scriptPath = myTempDir != null ? FileUtil.createTempFile(myTempDir, myPrefix, SCRIPT_EXT, true) - : FileUtil.createTempFile(myPrefix, SCRIPT_EXT); + File scriptPath = myTempDir != null ? FileUtilLight.createTempFile(myTempDir, myPrefix, SCRIPT_EXT, true) + : FileUtilLight.createTempFile(myPrefix, SCRIPT_EXT); scriptPath.deleteOnExit(); PrintWriter out = new PrintWriter(new FileWriter(scriptPath)); try { @@ -172,7 +172,7 @@ public class ScriptGenerator { finally { out.close(); } - FileUtil.setExecutableAttribute(scriptPath.getPath(), true); + FileUtilLight.setExecutableAttribute(scriptPath.getPath(), true); return scriptPath; } From 7759a25131ddaf9df61b46fcf1de1ae2da54c848 Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 19 Mar 2012 19:18:45 +0400 Subject: [PATCH 45/50] IDEA-82197 svn: E200009: Wrong number of targets has been specified (0), at least 1 is required. --- .../src/org/jetbrains/idea/svn/actions/CopyAction.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CopyAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CopyAction.java index 4eb663d5aa03..5812f4e63244 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CopyAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CopyAction.java @@ -137,8 +137,10 @@ public class CopyAction extends BasicAction { throw new VcsException("Invalid repository root path for " + baseUrl); } } - SVNCommitClient commitClient = activeVcs.createCommitClient(); - commitClient.doMkDir(dirsToCreate.toArray(new SVNURL[dirsToCreate.size()]), comment); + if (! dirsToCreate.isEmpty()) { + SVNCommitClient commitClient = activeVcs.createCommitClient(); + commitClient.doMkDir(dirsToCreate.toArray(new SVNURL[dirsToCreate.size()]), comment); + } } private static boolean dirExists(Project project, final SVNURL url, final SVNWCClient client) throws SVNException { From c124c37fc1480ef8309bc674ba5a48c0a91bcfb9 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 19 Mar 2012 16:49:42 +0100 Subject: [PATCH 46/50] remove unnecessary border --- .../src/com/intellij/openapi/diff/ex/DiffStatusBar.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffStatusBar.java b/platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffStatusBar.java index a7379192358e..7f3edab64237 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffStatusBar.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffStatusBar.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package com.intellij.openapi.diff.ex; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; -import com.intellij.ui.IdeBorderFactory; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nullable; @@ -109,8 +108,7 @@ public class DiffStatusBar extends JPanel { } }; setLayout(new BorderLayout()); - setBorder(BorderFactory.createCompoundBorder(IdeBorderFactory.createBorder(), - BorderFactory.createEmptyBorder(3, 20, 3, 20))); + setBorder(BorderFactory.createEmptyBorder(3, 20, 3, 20)); add(myTextLabel, BorderLayout.WEST); Box box = Box.createHorizontalBox(); From 58f279dac7c7a03c6700bcd98d203ed889ed5dd5 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Mon, 19 Mar 2012 20:06:54 +0400 Subject: [PATCH 47/50] IDEA-82907 Don't suggest to delete "master" branch after merge --- .../src/git4idea/branch/GitMergeOperation.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java b/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java index 72a1c03cba63..468a7f85d17f 100644 --- a/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java +++ b/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java @@ -159,7 +159,7 @@ class GitMergeOperation extends GitBranchOperation { @Override protected void notifySuccess(@NotNull String message) { - if (!myLocalBranch) { + if (isRemoteBranch() || isMasterBranch()) { super.notifySuccess(message); } else { @@ -169,6 +169,14 @@ class GitMergeOperation extends GitBranchOperation { } } + private boolean isMasterBranch() { + return myBranchToMerge.equals("master"); + } + + private boolean isRemoteBranch() { + return !myLocalBranch; + } + private boolean resolveConflicts() { if (!myConflictedRepositories.isEmpty()) { return new MyMergeConflictResolver().merge(); From b3da343138cb65551d7496c1838acf1eef5f9343 Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 19 Mar 2012 20:34:41 +0400 Subject: [PATCH 48/50] IDEA-73821 Local Change List isn't always up-to-date - problems with Synchronize (fixed for externals) --- plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java index d2ffac3d0ac7..e05f70a8b0b1 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java @@ -578,7 +578,7 @@ public class SvnVcs extends AbstractVcs { public SVNStatusClient createStatusClient() { SVNStatusClient client = new SVNStatusClient(getPool(), myConfiguration.getOptions(myProject)); client.getOperationsFactory().setAuthenticationManager(myConfiguration.getAuthenticationManager(this)); - client.setIgnoreExternals(true); + client.setIgnoreExternals(false); return client; } From 6cccdfd80ca00ae32b5ceed6eeea19a9a2de9704 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 19 Mar 2012 17:47:17 +0100 Subject: [PATCH 49/50] Don't load focus killer in headless mode; cleanup --- .../platform-main/src/com/intellij/idea/MainImpl.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/platform/platform-main/src/com/intellij/idea/MainImpl.java b/platform/platform-main/src/com/intellij/idea/MainImpl.java index bd1dfa8060df..7b204d186375 100644 --- a/platform/platform-main/src/com/intellij/idea/MainImpl.java +++ b/platform/platform-main/src/com/intellij/idea/MainImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,9 +35,8 @@ public class MainImpl { private MainImpl() { } /** - * Is called from PluginManager via reflection. + * Called from PluginManager via reflection. */ - @SuppressWarnings("UnusedDeclaration") protected static void start(final String[] args) { if (System.getProperty("idea.platform.prefix") == null) { System.setProperty("idea.platform.prefix", "Idea"); @@ -66,8 +65,7 @@ public class MainImpl { Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook - logging") { public void run() { - LOG.info( - "------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------"); + LOG.info("------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------"); } }); LOG.info("------------------------------------------------------ IDE STARTED ------------------------------------------------------"); @@ -86,7 +84,7 @@ public class MainImpl { // http://weblogs.java.net/blog/shan_man/archive/2005/06/improved_drag_g.html System.setProperty("sun.swing.enableImprovedDragGesture", ""); - if (SystemInfo.isWindows && !SystemInfo.isWindows9x) { + if (SystemInfo.isWindows && !SystemInfo.isWindows9x && !StartupUtil.isHeadless) { final Logger LOG = Logger.getInstance(LOG_CATEGORY); try { if (SystemInfo.isAMD64) { From c9be01529f22ab2f001073f890d2041360d188bb Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 19 Mar 2012 17:47:42 +0100 Subject: [PATCH 50/50] EA-34442 (check config/system paths validity on start) --- .../src/com/intellij/idea/StartupUtil.java | 26 +++++++++++++++++-- .../openapi/application/PathManager.java | 8 +++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/idea/StartupUtil.java b/platform/platform-impl/src/com/intellij/idea/StartupUtil.java index d144ba429f34..5412e6e1f3eb 100644 --- a/platform/platform-impl/src/com/intellij/idea/StartupUtil.java +++ b/platform/platform-impl/src/com/intellij/idea/StartupUtil.java @@ -99,6 +99,26 @@ public class StartupUtil { return true; } + private synchronized static boolean checkSystemFolders() { + final String configPath = PathManager.getConfigPath(); + if (configPath == null || !new File(configPath).isDirectory()) { + showError("Invalid config path", "Config path '" + configPath + "' is invalid.\n" + + "If you have modified the 'idea.config.path' property please make sure it is correct,\n" + + "otherwise please re-install the IDE."); + return false; + } + + final String systemPath = PathManager.getSystemPath(); + if (systemPath == null || !new File(systemPath).isDirectory()) { + showError("Invalid system path", "System path '" + systemPath + "' is invalid.\n" + + "If you have modified the 'idea.system.path' property please make sure it is correct,\n" + + "otherwise please re-install the IDE."); + return false; + } + + return true; + } + private synchronized static boolean lockSystemFolders(String[] args) { if (ourLock == null) { ourLock = new SocketLock(); @@ -169,12 +189,14 @@ public class StartupUtil { return false; } - return true; } static boolean checkStartupPossible(String[] args) { - return checkJdkVersion() && lockSystemFolders(args) && checkTmpIsAccessible(); + return checkJdkVersion() && + checkTmpIsAccessible() && + checkSystemFolders() && + lockSystemFolders(args); } static void runStartupWizard() { diff --git a/platform/util/src/com/intellij/openapi/application/PathManager.java b/platform/util/src/com/intellij/openapi/application/PathManager.java index c053d8f6b176..d9ef319b731f 100644 --- a/platform/util/src/com/intellij/openapi/application/PathManager.java +++ b/platform/util/src/com/intellij/openapi/application/PathManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -156,11 +156,11 @@ public class PathManager { public static boolean ensureConfigFolderExists(final boolean createIfNotExists) { getConfigPathWithoutDialog(); - File file = new File(ourConfigPath); + final File file = new File(ourConfigPath); if (createIfNotExists && !file.exists()) { - file.mkdirs(); - return true; + return file.mkdirs(); // shouldn't copy configs if failed to create new directory } + return false; }