From d69a88596a7b3be5376c389a9aed6660128a6381 Mon Sep 17 00:00:00 2001 From: Yuri Denison Date: Fri, 8 Jun 2012 14:43:12 +0400 Subject: [PATCH 001/172] added SCSS introduce variable dialog --- .../src/messages/RefactoringBundle.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/platform-resources-en/src/messages/RefactoringBundle.properties b/platform/platform-resources-en/src/messages/RefactoringBundle.properties index ecc25b700edb..e5385b9079b8 100644 --- a/platform/platform-resources-en/src/messages/RefactoringBundle.properties +++ b/platform/platform-resources-en/src/messages/RefactoringBundle.properties @@ -139,6 +139,8 @@ introduce.variable.title=Extract Variable refactoring.introduce.context.error=Cannot perform refactoring in this context refactoring.introduceVariable=Extract Variable refactoring refactoring.introduce.selection.error=Cannot perform refactoring using selected element(s) +refactoring.introduce.name.error=Incorrect name +refactoring.introduce.name.used.error=This name is already used variable.of.type=Variable of &type: convert.to.instance.method.title=Convert To Instance Method From 78cf87d2c8a71bac00ad92ee7835aacab8ac6daa Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 8 Jun 2012 14:42:52 +0400 Subject: [PATCH 002/172] do not replace diamonds without necessity (IDEA-87172) --- .../intellij/psi/impl/PsiDiamondTypeUtil.java | 14 +++++++++++- ...troduceParameterMethodUsagesProcessor.java | 4 +++- .../afterPreserveDiamondOccurrences.java | 22 +++++++++++++++++++ .../beforePreserveDiamondOccurrences.java | 22 +++++++++++++++++++ .../refactoring/IntroduceParameterTest.java | 4 ++++ .../ReplaceIfWithConditionalIntention.java | 16 ++++++++++++-- ...placeableAssignmentsWithDiamondsLeave.java | 17 ++++++++++++++ ...bleAssignmentsWithDiamondsLeave_after.java | 12 ++++++++++ ...ReplaceIfWithConditionalIntentionTest.java | 4 ++++ 9 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 java/java-tests/testData/refactoring/introduceParameter/afterPreserveDiamondOccurrences.java create mode 100644 java/java-tests/testData/refactoring/introduceParameter/beforePreserveDiamondOccurrences.java create mode 100644 plugins/IntentionPowerPak/test/com/siyeh/ipp/trivialif/replaceIfWithConditional/ReplaceableAssignmentsWithDiamondsLeave.java create mode 100644 plugins/IntentionPowerPak/test/com/siyeh/ipp/trivialif/replaceIfWithConditional/ReplaceableAssignmentsWithDiamondsLeave_after.java diff --git a/java/java-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java b/java/java-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java index 502055854d22..c5037ac91c3f 100644 --- a/java/java-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java +++ b/java/java-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java @@ -40,6 +40,18 @@ public class PsiDiamondTypeUtil { public static boolean canCollapseToDiamond(final PsiNewExpression expression, final PsiNewExpression context, final @Nullable PsiType expectedType) { + return canCollapseToDiamond(expression, context, expectedType, false); + } + + public static boolean canChangeContextForDiamond(final PsiNewExpression expression, final PsiType expectedType) { + final PsiNewExpression copy = (PsiNewExpression)expression.copy(); + return canCollapseToDiamond(copy, copy, expectedType, true); + } + + private static boolean canCollapseToDiamond(final PsiNewExpression expression, + final PsiNewExpression context, + final @Nullable PsiType expectedType, + boolean skipDiamonds) { if (PsiUtil.getLanguageLevel(context).isAtLeast(LanguageLevel.JDK_1_7)) { final PsiJavaCodeReferenceElement classReference = expression.getClassOrAnonymousClassReference(); if (classReference != null) { @@ -47,7 +59,7 @@ public class PsiDiamondTypeUtil { if (parameterList != null) { final PsiTypeElement[] typeElements = parameterList.getTypeParameterElements(); if (typeElements.length > 0) { - if (typeElements.length == 1 && typeElements[0].getType() instanceof PsiDiamondType) return false; + if (!skipDiamonds && typeElements.length == 1 && typeElements[0].getType() instanceof PsiDiamondType) return false; final PsiDiamondTypeImpl.DiamondInferenceResult inferenceResult = PsiDiamondTypeImpl.resolveInferredTypes(expression, context); if (inferenceResult.getErrorMessage() == null) { final List types = inferenceResult.getInferredTypes(); diff --git a/java/java-impl/src/com/intellij/refactoring/introduceParameter/JavaIntroduceParameterMethodUsagesProcessor.java b/java/java-impl/src/com/intellij/refactoring/introduceParameter/JavaIntroduceParameterMethodUsagesProcessor.java index 827540c785a4..3f16cfb1e0eb 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceParameter/JavaIntroduceParameterMethodUsagesProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceParameter/JavaIntroduceParameterMethodUsagesProcessor.java @@ -94,7 +94,9 @@ public class JavaIntroduceParameterMethodUsagesProcessor implements IntroducePar ExpressionConverter.getExpression(data.getParameterInitializer().getExpression(), StdLanguages.JAVA, data.getProject()); assert initializer instanceof PsiExpression; if (initializer instanceof PsiNewExpression) { - initializer = PsiDiamondTypeUtil.expandTopLevelDiamondsInside((PsiNewExpression)initializer); + if (!PsiDiamondTypeUtil.canChangeContextForDiamond((PsiNewExpression)initializer, ((PsiNewExpression)initializer).getType())) { + initializer = PsiDiamondTypeUtil.expandTopLevelDiamondsInside((PsiNewExpression)initializer); + } } substituteTypeParametersInInitializer(initializer, callExpression, argList, methodToSearchFor); ChangeContextUtil.encodeContextInfo(initializer, true); diff --git a/java/java-tests/testData/refactoring/introduceParameter/afterPreserveDiamondOccurrences.java b/java/java-tests/testData/refactoring/introduceParameter/afterPreserveDiamondOccurrences.java new file mode 100644 index 000000000000..4f62137d7950 --- /dev/null +++ b/java/java-tests/testData/refactoring/introduceParameter/afterPreserveDiamondOccurrences.java @@ -0,0 +1,22 @@ + +public class TestCompletion { + + public static ParallelPipeline test(T base, V newStage, T upstream, final ParallelPipeline anObject) { + if (base != null){ + return anObject; + } + else { + return new ParallelPipeline<>(upstream, newStage); + } + + } + + + void f() { + test(null, null, null, new ParallelPipeline<>(null, null)); + } + private static class ParallelPipeline { + public ParallelPipeline(T p0, V p1) { + } + } +} diff --git a/java/java-tests/testData/refactoring/introduceParameter/beforePreserveDiamondOccurrences.java b/java/java-tests/testData/refactoring/introduceParameter/beforePreserveDiamondOccurrences.java new file mode 100644 index 000000000000..2bf9a854544d --- /dev/null +++ b/java/java-tests/testData/refactoring/introduceParameter/beforePreserveDiamondOccurrences.java @@ -0,0 +1,22 @@ + +public class TestCompletion { + + public static ParallelPipeline test(T base, V newStage, T upstream) { + if (base != null){ + return new ParallelPipeline<>(base, newStage); + } + else { + return new ParallelPipeline<>(upstream, newStage); + } + + } + + + void f() { + test(null, null, null); + } + private static class ParallelPipeline { + public ParallelPipeline(T p0, V p1) { + } + } +} diff --git a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java index 4893ce72e001..0cad5462136e 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java @@ -275,6 +275,10 @@ public class IntroduceParameterTest extends LightRefactoringTestCase { doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false); } + public void testPreserveDiamondOccurrences() throws Exception { + doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false); + } + public void testSubstituteTypeParams() throws Exception { doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false); } diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/trivialif/ReplaceIfWithConditionalIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/trivialif/ReplaceIfWithConditionalIntention.java index faa30fd258d9..fb1bbd251bb5 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/trivialif/ReplaceIfWithConditionalIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/trivialif/ReplaceIfWithConditionalIntention.java @@ -170,11 +170,14 @@ public class ReplaceIfWithConditionalIntention extends Intention { PsiExpression elseValue, PsiType requiredType) { condition = ParenthesesUtils.stripParentheses(condition); - thenValue = PsiDiamondTypeUtil.expandTopLevelDiamondsInside(ParenthesesUtils.stripParentheses(thenValue)); + thenValue = ParenthesesUtils.stripParentheses(thenValue); + elseValue = ParenthesesUtils.stripParentheses(elseValue); + + thenValue = expandDiamondsWhenNeeded(thenValue, requiredType); if (thenValue == null) { return null; } - elseValue = PsiDiamondTypeUtil.expandTopLevelDiamondsInside(ParenthesesUtils.stripParentheses(elseValue)); + elseValue = expandDiamondsWhenNeeded(elseValue, requiredType); if (elseValue == null) { return null; } @@ -217,6 +220,15 @@ public class ReplaceIfWithConditionalIntention extends Intention { return conditional.toString(); } + private static PsiExpression expandDiamondsWhenNeeded(PsiExpression thenValue, PsiType requiredType) { + if (thenValue instanceof PsiNewExpression) { + if (!PsiDiamondTypeUtil.canChangeContextForDiamond((PsiNewExpression)thenValue, requiredType)) { + return PsiDiamondTypeUtil.expandTopLevelDiamondsInside(thenValue); + } + } + return thenValue; + } + private static String getExpressionText(PsiExpression expression) { if (ParenthesesUtils.getPrecedence(expression) <= ParenthesesUtils.CONDITIONAL_PRECEDENCE) { diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/trivialif/replaceIfWithConditional/ReplaceableAssignmentsWithDiamondsLeave.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/trivialif/replaceIfWithConditional/ReplaceableAssignmentsWithDiamondsLeave.java new file mode 100644 index 000000000000..47b35995ff25 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/trivialif/replaceIfWithConditional/ReplaceableAssignmentsWithDiamondsLeave.java @@ -0,0 +1,17 @@ +public class TestCompletion { + + public static ParallelPipeline test(T base, V newStage, T upstream) { + if (base != null) { + return new ParallelPipeline<>(base, newStage); + } + else { + return new ParallelPipeline<>(upstream, newStage); + } + } + + private static class ParallelPipeline { + public ParallelPipeline(T p0, V p1) { + } + } +} + diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/trivialif/replaceIfWithConditional/ReplaceableAssignmentsWithDiamondsLeave_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/trivialif/replaceIfWithConditional/ReplaceableAssignmentsWithDiamondsLeave_after.java new file mode 100644 index 000000000000..a11449b495b4 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/trivialif/replaceIfWithConditional/ReplaceableAssignmentsWithDiamondsLeave_after.java @@ -0,0 +1,12 @@ +public class TestCompletion { + + public static ParallelPipeline test(T base, V newStage, T upstream) { + return base != null ? new ParallelPipeline<>(base, newStage) : new ParallelPipeline<>(upstream, newStage); + } + + private static class ParallelPipeline { + public ParallelPipeline(T p0, V p1) { + } + } +} + diff --git a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/trivialif/ReplaceIfWithConditionalIntentionTest.java b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/trivialif/ReplaceIfWithConditionalIntentionTest.java index f4a51a62f53e..9cbfe40f0d35 100644 --- a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/trivialif/ReplaceIfWithConditionalIntentionTest.java +++ b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/trivialif/ReplaceIfWithConditionalIntentionTest.java @@ -28,6 +28,10 @@ public class ReplaceIfWithConditionalIntentionTest extends IPPTestCase { doTest(); } + public void testReplaceableAssignmentsWithDiamondsLeave() { + doTest(); + } + @Override protected String getIntentionName() { return IntentionPowerPackBundle.message("replace.if.with.conditional.intention.name"); From a5c210ebf6ac3cfce70f241b3c2e2d3b31f5236f Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 8 Jun 2012 14:12:36 +0200 Subject: [PATCH 003/172] make title compact --- .../find/actions/ShowUsagesAction.java | 27 +++++++++++++------ .../src/com/intellij/ui/CaptionPanel.java | 4 +-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java index 6bcbd42a0ebf..4dffeb5f5e5e 100644 --- a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java +++ b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 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. @@ -460,7 +460,8 @@ public class ShowUsagesAction extends AnAction implements PopupAction { else { s = title + " (" + UsageViewBundle.message("usages.n", usages.size()) + " found)"; } - builder.setTitle(suggestSecondInvocation(options, handler, s)); + builder.setTitle("" + s + ""); + builder.setAdText(getSecondInvocationTitle(options, handler)); } builder.setMovable(true).setResizable(true); @@ -555,16 +556,26 @@ public class ShowUsagesAction extends AnAction implements PopupAction { } private static String suggestSecondInvocation(FindUsagesOptions options, FindUsagesHandler handler, String s) { - if (getShowUsagesShortcut() != null) { - GlobalSearchScope maximalScope = getMaximalScope(handler); - if (!notNullizeScope(options, handler.getProject()).equals(maximalScope)) { - s += "
Press " + KeymapUtil.getShortcutText(getShowUsagesShortcut()) + - " again to search in " + maximalScope.getDisplayName() + ""; - } + final String title = getSecondInvocationTitle(options, handler); + + if (title != null) { + s += "
Press " + title + ""; } return "" + s + ""; } + @Nullable + private static String getSecondInvocationTitle(FindUsagesOptions options, FindUsagesHandler handler) { + if (getShowUsagesShortcut() != null) { + GlobalSearchScope maximalScope = getMaximalScope(handler); + if (!notNullizeScope(options, handler.getProject()).equals(maximalScope)) { + return "Press " + KeymapUtil.getShortcutText(getShowUsagesShortcut()) + + " again to search in " + maximalScope.getDisplayName(); + } + } + return null; + } + private void searchEverywhere(FindUsagesOptions options, FindUsagesHandler handler, Editor editor, diff --git a/platform/util/src/com/intellij/ui/CaptionPanel.java b/platform/util/src/com/intellij/ui/CaptionPanel.java index ec2c436517ef..0d2b16cf178d 100644 --- a/platform/util/src/com/intellij/ui/CaptionPanel.java +++ b/platform/util/src/com/intellij/ui/CaptionPanel.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. @@ -87,7 +87,7 @@ public class CaptionPanel extends JPanel { public void addSettingsComponent(Component component) { if (mySettingComponent == null) { - mySettingComponent = new JPanel(new FlowLayout()); + mySettingComponent = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); mySettingComponent.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); add(mySettingComponent, BorderLayout.WEST); mySettingComponent.setOpaque(false); From b59b63299784674e1c6dff36e0fd6d84cac582a5 Mon Sep 17 00:00:00 2001 From: Danila Ponomarenko Date: Fri, 8 Jun 2012 15:58:50 +0400 Subject: [PATCH 004/172] startInWriteAction -> false --- .../codeInsight/intention/impl/IntroduceVariableAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/IntroduceVariableAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/IntroduceVariableAction.java index c3244099a525..6b7277685a60 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/IntroduceVariableAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/IntroduceVariableAction.java @@ -79,6 +79,6 @@ public class IntroduceVariableAction implements IntentionAction { @Override public boolean startInWriteAction() { - return true; + return false; } } From 8edc336fd2802d8affb93a8d2261e68bcb772e5f Mon Sep 17 00:00:00 2001 From: Danila Ponomarenko Date: Fri, 8 Jun 2012 16:18:14 +0400 Subject: [PATCH 005/172] IDEA-61130 Intention to replace an assignment with a setter call implemented --- .../impl/EncapsulateFieldAction.java | 101 ++++++++++++++++++ .../encapsulateField/beforeFinal.java | 13 +++ .../encapsulateField/beforePrivate.java | 13 +++ .../encapsulateField/beforeThisClass.java | 9 ++ .../beforeThisClassQualified.java | 9 ++ .../intention/EncapsulateFieldTest.java | 31 ++++++ .../src/messages/CodeInsightBundle.properties | 1 + resources/src/META-INF/IdeaPlugin.xml | 4 + 8 files changed, 181 insertions(+) create mode 100644 java/java-impl/src/com/intellij/codeInsight/intention/impl/EncapsulateFieldAction.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField/beforeFinal.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField/beforePrivate.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField/beforeThisClass.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField/beforeThisClassQualified.java create mode 100644 java/java-tests/testSrc/com/intellij/codeInsight/intention/EncapsulateFieldTest.java diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/EncapsulateFieldAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/EncapsulateFieldAction.java new file mode 100644 index 000000000000..deda615abcf7 --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/EncapsulateFieldAction.java @@ -0,0 +1,101 @@ +/* + * 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.codeInsight.intention.impl; + +import com.intellij.codeInsight.CodeInsightBundle; +import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.openapi.editor.CaretModel; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.psi.*; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.refactoring.JavaRefactoringActionHandlerFactory; +import com.intellij.refactoring.RefactoringActionHandler; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Danila Ponomarenko + */ +public class EncapsulateFieldAction implements IntentionAction { + + @NotNull + @Override + public String getText() { + return CodeInsightBundle.message("intention.encapsulate.field.text"); + } + + @NotNull + @Override + public String getFamilyName() { + return getText(); + } + + @Override + public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { + final PsiField field = getField(getElement(editor, file)); + return field != null && !field.hasModifierProperty(PsiModifier.FINAL) && !field.hasModifierProperty(PsiModifier.PRIVATE); + } + + + @Override + public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + final PsiField field = getField(getElement(editor, file)); + if (field == null) { + return; + } + + final RefactoringActionHandler refactoringActionHandler = JavaRefactoringActionHandlerFactory.getInstance().createEncapsulateFieldsHandler(); + refactoringActionHandler.invoke(project, new PsiElement[]{field}, null); + } + + @Nullable + protected static PsiField getField(@Nullable PsiElement element) { + if (element == null || !(element instanceof PsiIdentifier)) { + return null; + } + + final PsiElement parent = element.getParent(); + if (parent == null || !(parent instanceof PsiReferenceExpression)) { + return null; + } + final PsiReferenceExpression ref = (PsiReferenceExpression)parent; + final PsiExpression qualifier = ref.getQualifierExpression(); + if (qualifier == null || qualifier instanceof PsiThisExpression) { + return null; + } + + final PsiElement resolved = ref.resolve(); + if (resolved == null || !(resolved instanceof PsiField)) { + return null; + } + return (PsiField)resolved; + } + + @Nullable + protected static PsiElement getElement(Editor editor, @NotNull PsiFile file) { + if (!file.getManager().isInProject(file)) return null; + final CaretModel caretModel = editor.getCaretModel(); + final int position = caretModel.getOffset(); + return file.findElementAt(position); + } + + @Override + public boolean startInWriteAction() { + return false; + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField/beforeFinal.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField/beforeFinal.java new file mode 100644 index 000000000000..e082b01cf8fb --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField/beforeFinal.java @@ -0,0 +1,13 @@ +// "Encapsulate field" "false" + +class A { + public final boolean m_bool; +} + +public class B { + void method() { + A a = new A(); + + a.m_bool = true; + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField/beforePrivate.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField/beforePrivate.java new file mode 100644 index 000000000000..061d152e95e6 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField/beforePrivate.java @@ -0,0 +1,13 @@ +// "Encapsulate field" "false" + +class A { + private boolean m_bool; +} + +public class B { + void method() { + A a = new A(); + + a.m_bool = true; + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField/beforeThisClass.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField/beforeThisClass.java new file mode 100644 index 000000000000..4721b752ed5e --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField/beforeThisClass.java @@ -0,0 +1,9 @@ +// "Encapsulate field" "false" + +class A { + public final boolean m_bool; + + void method() { + m_bool = true; + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField/beforeThisClassQualified.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField/beforeThisClassQualified.java new file mode 100644 index 000000000000..a4aa102c4a85 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField/beforeThisClassQualified.java @@ -0,0 +1,9 @@ +// "Encapsulate field" "false" + +class A { + public final boolean m_bool; + + void method() { + this.m_bool = true; + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/intention/EncapsulateFieldTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/intention/EncapsulateFieldTest.java new file mode 100644 index 000000000000..165073beedbd --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/intention/EncapsulateFieldTest.java @@ -0,0 +1,31 @@ +/* + * 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.codeInsight.intention; + +import com.intellij.codeInsight.daemon.LightIntentionActionTestCase; + +/** + * @author Danila Ponomarenko + */ +public class EncapsulateFieldTest extends LightIntentionActionTestCase { + + public void test() throws Exception { doAllTests(); } + + @Override + protected String getBasePath() { + return "/codeInsight/daemonCodeAnalyzer/quickFix/encapsulateField"; + } +} diff --git a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties index 91dbe3809874..3139e449dd77 100644 --- a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties +++ b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties @@ -157,6 +157,7 @@ intention.make.type.generic.text=Change type of {0} to {1} intention.split.if.family=Split If intention.split.if.text=Split into 2 if's intention.introduce.variable.text=Introduce local variable +intention.encapsulate.field.text=Encapsulate field intention.implement.abstract.method.family=Implement Abstract Method intention.implement.abstract.method.text=Implement method ''{0}'' intention.override.method.text=Override method ''{0}'' diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 50c1395999d8..605a9c3edae4 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -639,6 +639,10 @@ com.intellij.codeInsight.intention.impl.IntroduceVariableAction Declaration + + com.intellij.codeInsight.intention.impl.EncapsulateFieldAction + Declaration + com.intellij.codeInsight.daemon.impl.quickfix.DelegateWithDefaultParamValueIntentionAction From e67c74c7ba59304b4c2ad0af1096a96fbf4cfae2 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 8 Jun 2012 14:52:10 +0200 Subject: [PATCH 006/172] prefer more recent matches --- .../testSrc/com/intellij/psi/util/NameUtilTest.java | 4 ++++ .../util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilTest.java b/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilTest.java index c2a329e9dcae..ef0108a05aa4 100644 --- a/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilTest.java +++ b/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilTest.java @@ -390,6 +390,10 @@ public class NameUtilTest extends UsefulTestCase { assertPreference(" Boo", "boolean", "Boolean", NameUtil.MatchingCaseSensitivity.NONE); } + public void testPreferEarlyMatching() { + assertPreference(" path", "getAbsolutePath", "findPath"); + } + public void testMeaningfulMatchingDegree() { assertTrue(new MinusculeMatcher(" EUC-", NameUtil.MatchingCaseSensitivity.FIRST_LETTER).matchingDegree("x-EUC-TW") > Integer.MIN_VALUE); } diff --git a/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java b/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java index 32074ac649f6..6daebde0ffec 100644 --- a/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java +++ b/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java @@ -276,8 +276,9 @@ public class MinusculeMatcher implements Matcher { boolean prefixMatching = first != null && first.getStartOffset() == 0; boolean middleWordStart = first != null && first.getStartOffset() > 0 && NameUtil.isWordStart(name, first.getStartOffset()); + int startIndex = first != null ? first.getStartOffset() : 42; - return -fragmentCount + matchingCase * 10 + commonStart + (prefixMatching ? 2 : middleWordStart ? 1 : 0) * 100; + return -fragmentCount + matchingCase * 10 + commonStart - startIndex + (prefixMatching ? 2 : middleWordStart ? 1 : 0) * 100; } @Override From c9ca3bcc9bd361de4507f5774d55c2348642ff65 Mon Sep 17 00:00:00 2001 From: Danila Ponomarenko Date: Fri, 8 Jun 2012 16:57:03 +0400 Subject: [PATCH 007/172] description added --- .../impl/EncapsulateFieldAction.java | 1 - .../after.java.template | 21 +++++++++++++++++++ .../before.java.template | 12 +++++++++++ .../EncapsulateFieldAction/description.html | 5 +++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 resources-en/src/intentionDescriptions/EncapsulateFieldAction/after.java.template create mode 100644 resources-en/src/intentionDescriptions/EncapsulateFieldAction/before.java.template create mode 100644 resources-en/src/intentionDescriptions/EncapsulateFieldAction/description.html diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/EncapsulateFieldAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/EncapsulateFieldAction.java index deda615abcf7..8e2588455db1 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/EncapsulateFieldAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/EncapsulateFieldAction.java @@ -21,7 +21,6 @@ import com.intellij.openapi.editor.CaretModel; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.*; -import com.intellij.psi.util.PsiTreeUtil; import com.intellij.refactoring.JavaRefactoringActionHandlerFactory; import com.intellij.refactoring.RefactoringActionHandler; import com.intellij.util.IncorrectOperationException; diff --git a/resources-en/src/intentionDescriptions/EncapsulateFieldAction/after.java.template b/resources-en/src/intentionDescriptions/EncapsulateFieldAction/after.java.template new file mode 100644 index 000000000000..d791754be04a --- /dev/null +++ b/resources-en/src/intentionDescriptions/EncapsulateFieldAction/after.java.template @@ -0,0 +1,21 @@ +class A { + public int field; + + public int getField() { + return field; + } + + public void setField(int field) { + this.field = field; + } +} + +class B { + void method() { + A a = new A(); + + a.setField(0); + int i = a.getField(); + } +} + diff --git a/resources-en/src/intentionDescriptions/EncapsulateFieldAction/before.java.template b/resources-en/src/intentionDescriptions/EncapsulateFieldAction/before.java.template new file mode 100644 index 000000000000..e14450436351 --- /dev/null +++ b/resources-en/src/intentionDescriptions/EncapsulateFieldAction/before.java.template @@ -0,0 +1,12 @@ +class A { + public int field; +} + +class B { + void method() { + A a = new A(); + + a.field = 0; + int b = a.field; + } +} diff --git a/resources-en/src/intentionDescriptions/EncapsulateFieldAction/description.html b/resources-en/src/intentionDescriptions/EncapsulateFieldAction/description.html new file mode 100644 index 000000000000..5e832c04d34f --- /dev/null +++ b/resources-en/src/intentionDescriptions/EncapsulateFieldAction/description.html @@ -0,0 +1,5 @@ + + +This intention replaces direct access to field with use of accessor methods. + + \ No newline at end of file From 5d980acadb5d8b33d5325f189de188c5ee3df042 Mon Sep 17 00:00:00 2001 From: nik Date: Fri, 8 Jun 2012 17:07:44 +0400 Subject: [PATCH 008/172] fixed compilation for jdk 1.6 --- .../src/org/jetbrains/jps/model/impl/JpsElementBase.java | 4 ++-- .../org/jetbrains/jps/model/library/impl/JpsLibraryImpl.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsElementBase.java b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsElementBase.java index df9e701f815e..dd53713729d0 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsElementBase.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsElementBase.java @@ -10,7 +10,7 @@ import org.jetbrains.jps.model.*; */ public abstract class JpsElementBase> implements JpsElement, JpsElement.BulkModificationSupport { private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.model.impl.JpsElementBase"); - protected JpsElementBase myParent; + protected JpsElementBase myParent; protected JpsElementBase() { } @@ -60,7 +60,7 @@ public abstract class JpsElementBase> implemen public abstract void applyChanges(@NotNull Self modified); - public JpsElementBase getParent() { + public JpsElementBase getParent() { return myParent; } } diff --git a/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryImpl.java index fb3794aae814..45728e409a93 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryImpl.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryImpl.java @@ -66,6 +66,7 @@ public class JpsLibraryImpl extends JpsNamedCompositeElementBase getParent() { + //noinspection unchecked return (JpsElementCollectionImpl)myParent; } From 4b3fdfb213d497ea2798b4affb0b79047e29af35 Mon Sep 17 00:00:00 2001 From: Danila Ponomarenko Date: Fri, 8 Jun 2012 17:55:09 +0400 Subject: [PATCH 009/172] IntroduceVariableAction and EncapsulateFieldAction both extends from BaseRunRefactoringAction --- .../impl/quickfix/PullAsAbstractUpFix.java | 7 +-- .../impl/BaseRunRefactoringAction.java | 49 +++++++++++++++++++ .../impl/EncapsulateFieldAction.java | 20 ++------ .../impl/IntroduceVariableAction.java | 20 ++------ .../impl/RunRefactoringAction.java} | 31 ++---------- .../src/messages/CodeInsightBundle.properties | 1 + 6 files changed, 64 insertions(+), 64 deletions(-) create mode 100644 java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseRunRefactoringAction.java rename java/java-impl/src/com/intellij/codeInsight/{daemon/impl/quickfix/RunRefactoringIntention.java => intention/impl/RunRefactoringAction.java} (59%) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PullAsAbstractUpFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PullAsAbstractUpFix.java index 883c17f21592..399b5d624ef0 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PullAsAbstractUpFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PullAsAbstractUpFix.java @@ -17,6 +17,7 @@ package com.intellij.codeInsight.daemon.impl.quickfix; import com.intellij.codeInsight.CodeInsightUtilBase; import com.intellij.codeInsight.daemon.impl.HighlightInfo; +import com.intellij.codeInsight.intention.impl.RunRefactoringAction; import com.intellij.codeInsight.navigation.NavigationUtil; import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement; import com.intellij.ide.util.PsiClassListCellRenderer; @@ -163,13 +164,13 @@ public class PullAsAbstractUpFix extends LocalQuickFixAndIntentionActionOnPsiEle name+= " and make it abstract"; } } - QuickFixAction.registerQuickFixAction(highlightInfo, new RunRefactoringIntention(new ExtractInterfaceHandler(), "Extract interface")); - QuickFixAction.registerQuickFixAction(highlightInfo, new RunRefactoringIntention(new ExtractSuperclassHandler(), "Extract superclass")); + QuickFixAction.registerQuickFixAction(highlightInfo, new RunRefactoringAction(new ExtractInterfaceHandler(), "Extract interface")); + QuickFixAction.registerQuickFixAction(highlightInfo, new RunRefactoringAction(new ExtractSuperclassHandler(), "Extract superclass")); } if (canBePulledUp) { - QuickFixAction.registerQuickFixAction(highlightInfo, new RunRefactoringIntention(new JavaPullUpHandler(), "Pull members up")); + QuickFixAction.registerQuickFixAction(highlightInfo, new RunRefactoringAction(new JavaPullUpHandler(), "Pull members up")); } QuickFixAction.registerQuickFixAction(highlightInfo, new PullAsAbstractUpFix(methodWithOverrides, name)); } diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseRunRefactoringAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseRunRefactoringAction.java new file mode 100644 index 000000000000..b9fbab23fa76 --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseRunRefactoringAction.java @@ -0,0 +1,49 @@ +/* + * 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.codeInsight.intention.impl; + +import com.intellij.codeInsight.CodeInsightBundle; +import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.codeInsight.intention.LowPriorityAction; +import com.intellij.icons.AllIcons; +import com.intellij.openapi.util.Iconable; +import com.intellij.refactoring.RefactoringActionHandler; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; + +/** + * @author Danila Ponomarenko + */ +public abstract class BaseRunRefactoringAction implements IntentionAction, Iconable, LowPriorityAction { + public static final Icon REFACTORING_BULB = AllIcons.Actions.RefactoringBulb; + + @NotNull + @Override + public final String getFamilyName() { + return CodeInsightBundle.message("intention.refactoring.family"); + } + + @Override + public final boolean startInWriteAction() { + return false; + } + + @Override + public final Icon getIcon(int flags) { + return REFACTORING_BULB; + } +} \ No newline at end of file diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/EncapsulateFieldAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/EncapsulateFieldAction.java index 8e2588455db1..685f37b375b0 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/EncapsulateFieldAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/EncapsulateFieldAction.java @@ -16,13 +16,11 @@ package com.intellij.codeInsight.intention.impl; import com.intellij.codeInsight.CodeInsightBundle; -import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.openapi.editor.CaretModel; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.*; -import com.intellij.refactoring.JavaRefactoringActionHandlerFactory; -import com.intellij.refactoring.RefactoringActionHandler; +import com.intellij.refactoring.encapsulateFields.EncapsulateFieldsHandler; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -30,7 +28,7 @@ import org.jetbrains.annotations.Nullable; /** * @author Danila Ponomarenko */ -public class EncapsulateFieldAction implements IntentionAction { +public class EncapsulateFieldAction extends BaseRunRefactoringAction { @NotNull @Override @@ -38,12 +36,6 @@ public class EncapsulateFieldAction implements IntentionAction { return CodeInsightBundle.message("intention.encapsulate.field.text"); } - @NotNull - @Override - public String getFamilyName() { - return getText(); - } - @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { final PsiField field = getField(getElement(editor, file)); @@ -58,8 +50,7 @@ public class EncapsulateFieldAction implements IntentionAction { return; } - final RefactoringActionHandler refactoringActionHandler = JavaRefactoringActionHandlerFactory.getInstance().createEncapsulateFieldsHandler(); - refactoringActionHandler.invoke(project, new PsiElement[]{field}, null); + new EncapsulateFieldsHandler().invoke(project, new PsiElement[]{field}, null); } @Nullable @@ -92,9 +83,4 @@ public class EncapsulateFieldAction implements IntentionAction { final int position = caretModel.getOffset(); return file.findElementAt(position); } - - @Override - public boolean startInWriteAction() { - return false; - } } \ No newline at end of file diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/IntroduceVariableAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/IntroduceVariableAction.java index 6b7277685a60..4ac04eaed610 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/IntroduceVariableAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/IntroduceVariableAction.java @@ -16,14 +16,12 @@ package com.intellij.codeInsight.intention.impl; import com.intellij.codeInsight.CodeInsightBundle; -import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.openapi.editor.CaretModel; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.refactoring.JavaRefactoringActionHandlerFactory; -import com.intellij.refactoring.RefactoringActionHandler; +import com.intellij.refactoring.introduceVariable.IntroduceVariableHandler; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -31,7 +29,7 @@ import org.jetbrains.annotations.Nullable; /** * @author Danila Ponomarenko */ -public class IntroduceVariableAction implements IntentionAction { +public class IntroduceVariableAction extends BaseRunRefactoringAction { @NotNull @Override @@ -39,12 +37,6 @@ public class IntroduceVariableAction implements IntentionAction { return CodeInsightBundle.message("intention.introduce.variable.text"); } - @NotNull - @Override - public String getFamilyName() { - return getText(); - } - @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { final PsiElement element = getElement(editor, file); @@ -73,12 +65,6 @@ public class IntroduceVariableAction implements IntentionAction { @Override public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { - final RefactoringActionHandler refactoringActionHandler = JavaRefactoringActionHandlerFactory.getInstance().createIntroduceVariableHandler(); - refactoringActionHandler.invoke(project, editor, file, null); - } - - @Override - public boolean startInWriteAction() { - return false; + new IntroduceVariableHandler().invoke(project, editor, file, null); } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RunRefactoringIntention.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/RunRefactoringAction.java similarity index 59% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RunRefactoringIntention.java rename to java/java-impl/src/com/intellij/codeInsight/intention/impl/RunRefactoringAction.java index f053a18527b7..6462dbe404b9 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RunRefactoringIntention.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/RunRefactoringAction.java @@ -13,31 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.codeInsight.daemon.impl.quickfix; +package com.intellij.codeInsight.intention.impl; -import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.codeInsight.intention.LowPriorityAction; -import com.intellij.icons.AllIcons; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Iconable; import com.intellij.psi.PsiFile; import com.intellij.refactoring.RefactoringActionHandler; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; -import javax.swing.*; - /** * User: anna * Date: 9/5/11 */ -public class RunRefactoringIntention implements IntentionAction, Iconable, LowPriorityAction { - public static final Icon REFACTORING_BULB = AllIcons.Actions.RefactoringBulb; +public class RunRefactoringAction extends BaseRunRefactoringAction { private final RefactoringActionHandler myHandler; private final String myCommandName; - public RunRefactoringIntention(RefactoringActionHandler handler, String commandName) { + public RunRefactoringAction(RefactoringActionHandler handler, String commandName) { myHandler = handler; myCommandName = commandName; } @@ -48,29 +41,13 @@ public class RunRefactoringIntention implements IntentionAction, Iconable, LowPr return myCommandName; } - @NotNull - @Override - public String getFamilyName() { - return "Refactorings"; - } - @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { return true; } @Override - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public final void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { myHandler.invoke(project, editor, file, null); } - - @Override - public boolean startInWriteAction() { - return false; - } - - @Override - public Icon getIcon(int flags) { - return REFACTORING_BULB; - } } diff --git a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties index 3139e449dd77..17413a924376 100644 --- a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties +++ b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties @@ -156,6 +156,7 @@ intention.make.type.generic.family=Make Type Generic intention.make.type.generic.text=Change type of {0} to {1} intention.split.if.family=Split If intention.split.if.text=Split into 2 if's +intention.refactoring.family=Refactoring intention.introduce.variable.text=Introduce local variable intention.encapsulate.field.text=Encapsulate field intention.implement.abstract.method.family=Implement Abstract Method From c19a212d1fb9d50b438d3ed0c1a27dc0c5ff7272 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 8 Jun 2012 17:02:06 +0400 Subject: [PATCH 010/172] EA-36502 - IAE: ArrayUtil.mergeArrays --- .../intellij/refactoring/copy/CopyClassesHandler.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/copy/CopyClassesHandler.java b/java/java-impl/src/com/intellij/refactoring/copy/CopyClassesHandler.java index aae30f20540f..ff4bc6f5b392 100644 --- a/java/java-impl/src/com/intellij/refactoring/copy/CopyClassesHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/copy/CopyClassesHandler.java @@ -138,10 +138,14 @@ public class CopyClassesHandler extends CopyHandlerDelegateBase { private static void fillResultsMap(Map result, PsiFile containingFile, PsiClass[] topLevelClasses) { PsiClass[] classes = result.get(containingFile); - if (classes != null) { - topLevelClasses = ArrayUtil.mergeArrays(classes, topLevelClasses, PsiClass.ARRAY_FACTORY); + if (topLevelClasses != null) { + if (classes != null) { + topLevelClasses = ArrayUtil.mergeArrays(classes, topLevelClasses, PsiClass.ARRAY_FACTORY); + } + result.put(containingFile, topLevelClasses); + } else { + result.put(containingFile, classes); } - result.put(containingFile, topLevelClasses); } public void doCopy(PsiElement[] elements, PsiDirectory defaultTargetDirectory) { From 5b83f7b15de152090d31fda660ced822068487e5 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 8 Jun 2012 17:08:36 +0400 Subject: [PATCH 011/172] EA-36519 - IAE: RefactoringUtil.sortDepthFirstRightLeftOrder --- .../src/com/intellij/refactoring/util/RefactoringUtil.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java index 2eda3ad6425f..4d725b7759b6 100644 --- a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java +++ b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java @@ -175,7 +175,11 @@ public class RefactoringUtil { public int compare(final UsageInfo usage1, final UsageInfo usage2) { final PsiElement element1 = usage1.getElement(); final PsiElement element2 = usage2.getElement(); - if (element1 == null || element2 == null) return 0; + if (element1 == null) { + if (element2 == null) return 0; + return 1; + } + if (element2 == null) return -1; return element2.getTextRange().getStartOffset() - element1.getTextRange().getStartOffset(); } }); From 7c6c45bc7d241e4e08e789bd034184bb4130713f Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 8 Jun 2012 18:01:06 +0400 Subject: [PATCH 012/172] escape (IDEA-87202) --- .../com/siyeh/ig/j2me/SimplifiableIfStatementInspection.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/j2me/SimplifiableIfStatementInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/j2me/SimplifiableIfStatementInspection.java index 0c01d1fcb0e2..c490e76bdce1 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/j2me/SimplifiableIfStatementInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/j2me/SimplifiableIfStatementInspection.java @@ -17,6 +17,7 @@ package com.siyeh.ig.j2me; import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PsiTreeUtil; @@ -53,7 +54,8 @@ public class SimplifiableIfStatementInspection extends BaseInspection { @NotNull public String buildErrorString(Object... infos) { final PsiIfStatement statement = (PsiIfStatement)infos[0]; - return InspectionGadgetsBundle.message("simplifiable.if.statement.problem.descriptor", calculateReplacementStatement(statement)); + return InspectionGadgetsBundle.message("simplifiable.if.statement.problem.descriptor", + StringUtil.escapeXml(calculateReplacementStatement(statement))); } @Nullable From 3f61db9bd2acf4f18788a64a9c1ff9ff2d030595 Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Fri, 8 Jun 2012 18:10:37 +0400 Subject: [PATCH 013/172] EA-36509 --- .../com/intellij/uiDesigner/designSurface/GuiEditor.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java index e829de30dae4..6e59ddc09207 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java @@ -1137,8 +1137,15 @@ public final class GuiEditor extends JPanel implements DataProvider { } public void run() { + if (myModule.isDisposed()) { + return; + } + Project project = myModule.getProject(); + if (project.isDisposed()) { + return; + } LOG.debug("Synchronizing GUI editor " + myFile.getName() + " to document"); - PsiDocumentManager.getInstance(myModule.getProject()).commitDocument(myDocument); + PsiDocumentManager.getInstance(project).commitDocument(myDocument); readFromFile(myKeepSelection); } } From aaad69c6dc46d9cd7ad46e0018caaef86c901761 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Thu, 7 Jun 2012 19:37:09 +0400 Subject: [PATCH 014/172] javadoc --- .../intellij/util/concurrency/JBReentrantReadWriteLock.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform/util/src/com/intellij/util/concurrency/JBReentrantReadWriteLock.java b/platform/util/src/com/intellij/util/concurrency/JBReentrantReadWriteLock.java index d246be51b621..9430087e6a3e 100644 --- a/platform/util/src/com/intellij/util/concurrency/JBReentrantReadWriteLock.java +++ b/platform/util/src/com/intellij/util/concurrency/JBReentrantReadWriteLock.java @@ -19,6 +19,9 @@ */ package com.intellij.util.concurrency; +/** + * @see LockFactory + */ public interface JBReentrantReadWriteLock { JBLock readLock(); JBLock writeLock(); From 7a732e833b561d3c24870faff1c61d5a41424be2 Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Fri, 8 Jun 2012 18:44:00 +0400 Subject: [PATCH 015/172] EA-36379 --- .../propertyInspector/UIDesignerToolWindowManager.java | 6 ++++-- .../com/intellij/designer/DesignerToolWindowManager.java | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/UIDesignerToolWindowManager.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/UIDesignerToolWindowManager.java index d0fa6234802c..9d4db6976e88 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/UIDesignerToolWindowManager.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/UIDesignerToolWindowManager.java @@ -168,8 +168,10 @@ public class UIDesignerToolWindowManager implements ProjectComponent { @Nullable public UIFormEditor getActiveFormFileEditor() { FileEditor[] fileEditors = myFileEditorManager.getSelectedEditors(); - if (fileEditors.length > 0 && fileEditors [0] instanceof UIFormEditor) { - return (UIFormEditor) fileEditors [0]; + for (FileEditor fileEditor : fileEditors) { + if (fileEditor instanceof UIFormEditor) { + return (UIFormEditor)fileEditor; + } } return null; } diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/DesignerToolWindowManager.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/DesignerToolWindowManager.java index 80a8c4c0ca97..ac15746f593f 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/DesignerToolWindowManager.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/DesignerToolWindowManager.java @@ -165,6 +165,7 @@ public final class DesignerToolWindowManager implements ProjectComponent { @Nullable public DesignerEditorPanel getActiveDesigner() { FileEditor[] editors = myFileEditorManager.getSelectedEditors(); + // TODO: check all editors instead first return editors.length > 0 ? getDesigner(editors[0]) : null; } From c4950c8dd5f9249fed03d0a0de6d5f94558976d4 Mon Sep 17 00:00:00 2001 From: Dmitry Boulytchev Date: Fri, 8 Jun 2012 18:47:02 +0400 Subject: [PATCH 016/172] Ultimately fixed bug in integrate (classToSubClasses) (compile-server) --- .../incremental/storage/BuildDataManager.java | 2 +- .../ether/dependencyView/Mappings.java | 43 +++++++++++++++++-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java index e1a634a869ae..8b1e97111783 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java @@ -18,7 +18,7 @@ import java.util.Map; * Date: 10/7/11 */ public class BuildDataManager implements StorageOwner { - private static final int VERSION = 3; + private static final int VERSION = 4; private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.storage.BuildDataManager"); private static final String SRC_TO_OUTPUTS_STORAGE = "src-out"; private static final String SRC_TO_FORM_STORAGE = "src-form"; diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java b/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java index bd739573dcfd..cecac9e10441 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java @@ -78,6 +78,14 @@ public class Mappings { private IntObjectMultiMaplet mySourceFileToUsages; private IntIntMaplet myClassToSourceFile; + private IntIntTransientMultiMaplet myRemovedSuperClasses; + + private void registerRemovedSuperClass (final int aClass, final int superClass) { + assert (myRemovedSuperClasses != null); + myIsDifferentiated = true; + myRemovedSuperClasses.put(superClass, aClass); + } + private Mappings(final Mappings base) throws IOException { myLock = base.myLock; myIsDelta = true; @@ -115,6 +123,8 @@ public class Mappings { myDebugS = myContext.getLogger(LOG); } + myRemovedSuperClasses = myIsDelta ? new IntIntTransientMultiMaplet() : null; + if (myIsDelta && myDeltaIsTransient) { myClassToSubclasses = new IntIntTransientMultiMaplet(); myClassToClassDependency = new IntIntTransientMultiMaplet(); @@ -193,6 +203,10 @@ public class Mappings { } } + public IntIntTransientMultiMaplet getRemovedSuperClasses() { + return myRemovedSuperClasses; + } + private static class Option { final X myValue; @@ -653,10 +667,6 @@ public class Mappings { } } - void affectAll(final int className, final Collection affectedFiles) { - affectAll(className, affectedFiles, null); - } - void affectAll(final int className, final Collection affectedFiles, final DependentFilesFilter filter) { final TIntHashSet dependants = myClassToClassDependency.get(className); @@ -1533,6 +1543,16 @@ public class Mappings { final boolean interfacesChanged = !diff.interfaces().unchanged(); final boolean signatureChanged = (diff.base() & Difference.SIGNATURE) > 0; + if (superClassChanged) { + myDelta.registerRemovedSuperClass(it.name, ((TypeRepr.ClassType)it.superClass).className); + } + + if (interfacesChanged) { + for (final TypeRepr.AbstractType typ: diff.interfaces().removed()) { + myDelta.registerRemovedSuperClass(it.name, ((TypeRepr.ClassType)typ).className); + } + } + if (superClassChanged || interfacesChanged || signatureChanged) { debug("Superclass changed: ", superClassChanged); debug("Interfaces changed: ", interfacesChanged); @@ -1975,6 +1995,21 @@ public class Mappings { return true; } }); + + delta.getRemovedSuperClasses ().forEachEntry(new TIntObjectProcedure() { + @Override + public boolean execute(final int a, final TIntHashSet b) { + if (!compiledClasses.contains(a)) { + final TIntHashSet old = myClassToSubclasses.get(a); + + old.removeAll(b.toArray()); + + myClassToSubclasses.replace(a, old); + } + + return true; + } + }); } else { subclassesTrashBin.forEachEntry(new TIntObjectProcedure() { From 09281b34e49389b31b648478a8ff3d3f7688b3ac Mon Sep 17 00:00:00 2001 From: Danila Ponomarenko Date: Fri, 8 Jun 2012 19:16:51 +0400 Subject: [PATCH 017/172] IntroduceVariable scope fixed --- .../intention/impl/IntroduceVariableAction.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/IntroduceVariableAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/IntroduceVariableAction.java index 4ac04eaed610..f629c1bfc21c 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/IntroduceVariableAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/IntroduceVariableAction.java @@ -43,18 +43,24 @@ public class IntroduceVariableAction extends BaseRunRefactoringAction Date: Fri, 8 Jun 2012 17:01:37 +0400 Subject: [PATCH 018/172] EA-36469 (diagnostic) --- platform/util/src/com/intellij/util/ArrayUtil.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platform/util/src/com/intellij/util/ArrayUtil.java b/platform/util/src/com/intellij/util/ArrayUtil.java index 081ac6923cd6..b011492ecf40 100644 --- a/platform/util/src/com/intellij/util/ArrayUtil.java +++ b/platform/util/src/com/intellij/util/ArrayUtil.java @@ -269,7 +269,14 @@ public class ArrayUtil extends ArrayUtilRt { return array; } - final T[] array2 = collection.toArray(factory.create(collection.size())); + final T[] array2; + try { + array2 = collection.toArray(factory.create(collection.size())); + } + catch (ArrayStoreException e) { + throw new RuntimeException("Bad elements in collection: " + collection, e); + } + if (array.length == 0) { return array2; } From aad9c45f6d022b70f6d6dd80444d276f2d76cb9a Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 8 Jun 2012 18:54:20 +0400 Subject: [PATCH 019/172] CompositeException formatting fixed --- .../testFramework/CompositeException.java | 43 +++++++++++++------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/CompositeException.java b/platform/testFramework/src/com/intellij/testFramework/CompositeException.java index f1d915456fb8..9d3bdba69d22 100644 --- a/platform/testFramework/src/com/intellij/testFramework/CompositeException.java +++ b/platform/testFramework/src/com/intellij/testFramework/CompositeException.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. @@ -18,6 +18,7 @@ package com.intellij.testFramework; import com.intellij.util.CommonProcessors; import com.intellij.util.Function; import com.intellij.util.Processor; +import com.intellij.util.StringBuilderSpinAllocator; import org.jetbrains.annotations.NotNull; import java.io.PrintStream; @@ -116,20 +117,34 @@ public class CompositeException extends Exception { stringProcessor.process(s); return s; } - String s = "CompositeException ("+myExceptions.size() +" nested exceptions):\n--------------------\n"; - stringProcessor.process(s); - for (int i = 0; i < myExceptions.size(); i++) { - Throwable exception = myExceptions.get(i); - String line = "Nested Exception " + i + " (of " + myExceptions.size() + "):\n"; + + StringBuilder sb = StringBuilderSpinAllocator.alloc(); + try { + String line = "CompositeException ("+myExceptions.size() +" nested):\n------------------------------\n"; stringProcessor.process(line); - s += line; - String excString = exceptionProcessor.fun(exception); - stringProcessor.process(excString); - s += excString; + sb.append(line); + + for (int i = 0; i < myExceptions.size(); i++) { + Throwable exception = myExceptions.get(i); + + line = "[" + i + "]: "; + stringProcessor.process(line); + sb.append(line); + + line = exceptionProcessor.fun(exception); + if (!line.endsWith("\n")) line += '\n'; + stringProcessor.process(line); + sb.append(line); + } + + line = "------------------------------\n"; + stringProcessor.process(line); + sb.append(line); + + return sb.toString(); + } + finally { + StringBuilderSpinAllocator.dispose(sb); } - String footer = "\n-----------------------\n"; - stringProcessor.process(footer); - s += footer; - return s; } } From 6a55208230955e9a794578aa1f3ff80ab2e01221 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 8 Jun 2012 19:40:34 +0400 Subject: [PATCH 020/172] Cleanup --- xml/dom-impl/dom-impl.iml | 1 - 1 file changed, 1 deletion(-) diff --git a/xml/dom-impl/dom-impl.iml b/xml/dom-impl/dom-impl.iml index 962377203400..cc3900c660e5 100644 --- a/xml/dom-impl/dom-impl.iml +++ b/xml/dom-impl/dom-impl.iml @@ -20,7 +20,6 @@ - From f793b786881307704fd324f42fe9a5be2958219d Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 8 Jun 2012 20:27:45 +0400 Subject: [PATCH 021/172] Drop stupid dependencies --- java/java-impl/java-impl.iml | 1 - resources/resources.iml | 1 - 2 files changed, 2 deletions(-) diff --git a/java/java-impl/java-impl.iml b/java/java-impl/java-impl.iml index d19011b3e584..9735a4a7fad1 100644 --- a/java/java-impl/java-impl.iml +++ b/java/java-impl/java-impl.iml @@ -32,7 +32,6 @@ - diff --git a/resources/resources.iml b/resources/resources.iml index a54a13ba939e..1f8b3f27d2df 100644 --- a/resources/resources.iml +++ b/resources/resources.iml @@ -11,7 +11,6 @@ - From fcacee79e7892dae4cc34828dbb953a2a2035d50 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 8 Jun 2012 20:31:05 +0400 Subject: [PATCH 022/172] EA-36386 (missing watch root disk isn't so catastrophic) --- .../vfs/impl/local/LocalFileSystemImpl.java | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java index 7c1eb96e1263..f987be6f184a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java @@ -40,6 +40,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.util.*; @@ -55,14 +56,17 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap private String myFSRootPath; private boolean myDominated; - public WatchRequestImpl(String rootPath, final boolean toWatchRecursively) { + public WatchRequestImpl(String rootPath, final boolean toWatchRecursively) throws FileNotFoundException { final int index = rootPath.indexOf(JarFileSystem.JAR_SEPARATOR); if (index >= 0) rootPath = rootPath.substring(0, index); File rootFile = new File(FileUtil.toSystemDependentName(rootPath)); if (index > 0 || !rootFile.isDirectory()) { - rootFile = rootFile.getParentFile(); - assert rootFile != null : rootPath; + final File parentFile = rootFile.getParentFile(); + if (parentFile == null) { + throw new FileNotFoundException(rootPath); + } + rootFile = parentFile; } myFSRootPath = rootFile.getAbsolutePath(); @@ -437,7 +441,8 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap boolean update = false; for (String root : recursiveRoots) { - final WatchRequestImpl request = new WatchRequestImpl(root, true); + final WatchRequestImpl request = watch(root, true); + if (request == null) continue; final boolean alreadyWatched = isAlreadyWatched(request); request.myDominated = alreadyWatched; @@ -448,7 +453,8 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap } for (String root : flatRoots) { - final WatchRequestImpl request = new WatchRequestImpl(root, false); + final WatchRequestImpl request = watch(root, false); + if (request == null) continue; final boolean alreadyWatched = isAlreadyWatched(request); if (!alreadyWatched) { @@ -468,6 +474,17 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap return update; } + @Nullable + private static WatchRequestImpl watch(final String root, final boolean recursively) { + try { + return new WatchRequestImpl(root, recursively); + } + catch (FileNotFoundException e) { + LOG.warn(e); + return null; + } + } + private void syncFiles(@NotNull final Set filesToSync) { if (filesToSync.isEmpty() || ApplicationManager.getApplication().isUnitTestMode()) return; From da14fb5c428734fb0deacc8bb96a55c9c858ae6d Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 8 Jun 2012 19:33:48 +0400 Subject: [PATCH 023/172] merge pulled interfaces (IDEA-87191) --- .../intellij/refactoring/memberPullUp/PullUpHelper.java | 7 +++++-- .../testData/refactoring/pullUp/MergeInterfaces.java | 3 +++ .../testData/refactoring/pullUp/MergeInterfaces_after.java | 3 +++ .../testSrc/com/intellij/refactoring/PullUpTest.java | 4 ++++ 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 java/java-tests/testData/refactoring/pullUp/MergeInterfaces.java create mode 100644 java/java-tests/testData/refactoring/pullUp/MergeInterfaces_after.java diff --git a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpHelper.java b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpHelper.java index aa7f8d617d00..71305101c8d1 100644 --- a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpHelper.java +++ b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpHelper.java @@ -33,8 +33,10 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.Ref; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.codeStyle.CodeStyleSettings; @@ -62,6 +64,7 @@ import com.intellij.util.IncorrectOperationException; import com.intellij.util.Query; import com.intellij.util.VisibilityUtil; import com.intellij.util.containers.HashMap; +import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -148,7 +151,7 @@ public class PullUpHelper extends BaseRefactoringProcessor{ final Set methodsToSearchDuplicates = new HashSet(); for (PsiMember psiMember : myMembersAfterMove) { if (psiMember instanceof PsiMethod && ((PsiMethod)psiMember).getBody() != null) { - methodsToSearchDuplicates.add((PsiMethod)psiMember); + methodsToSearchDuplicates.add(psiMember); } } @@ -289,7 +292,7 @@ public class PullUpHelper extends BaseRefactoringProcessor{ PsiJavaCodeReferenceElement ref = mySourceClass.equals(sourceReferenceList.getParent()) ? RefactoringUtil.removeFromReferenceList(sourceReferenceList, aClass) : RefactoringUtil.findReferenceToClass(sourceReferenceList, aClass); - if (ref != null) { + if (ref != null && !myTargetSuperClass.isInheritor(aClass, false)) { RefactoringUtil.replaceMovedMemberTypeParameters(ref, PsiUtil.typeParametersIterable(mySourceClass), substitutor, elementFactory); final PsiReferenceList referenceList = myTargetSuperClass.isInterface() ? myTargetSuperClass.getExtendsList() : myTargetSuperClass.getImplementsList(); diff --git a/java/java-tests/testData/refactoring/pullUp/MergeInterfaces.java b/java/java-tests/testData/refactoring/pullUp/MergeInterfaces.java new file mode 100644 index 000000000000..68f3d11cf803 --- /dev/null +++ b/java/java-tests/testData/refactoring/pullUp/MergeInterfaces.java @@ -0,0 +1,3 @@ +class Base implements I {} +class Test extends Base implements I {} +interface I{} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pullUp/MergeInterfaces_after.java b/java/java-tests/testData/refactoring/pullUp/MergeInterfaces_after.java new file mode 100644 index 000000000000..dfad6f6eb34f --- /dev/null +++ b/java/java-tests/testData/refactoring/pullUp/MergeInterfaces_after.java @@ -0,0 +1,3 @@ +class Base implements I {} +class Test extends Base {} +interface I{} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/refactoring/PullUpTest.java b/java/java-tests/testSrc/com/intellij/refactoring/PullUpTest.java index b17563b2f75c..c4f5a7aa0e89 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/PullUpTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/PullUpTest.java @@ -111,6 +111,10 @@ public class PullUpTest extends LightRefactoringTestCase { doTest(false, new RefactoringTestUtil.MemberDescriptor("foo", PsiMethod.class)); } + public void testMergeInterfaces() throws Exception { + doTest(false, new RefactoringTestUtil.MemberDescriptor("I", PsiClass.class)); + } + private void doTest(RefactoringTestUtil.MemberDescriptor... membersToFind) throws Exception { doTest(true, membersToFind); } From 55f930a0e180a732a40ee18a8ae691f1e43b6c27 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 8 Jun 2012 20:34:45 +0400 Subject: [PATCH 024/172] change signature: substitute param types according to class hierarchy (IDEA-87146) --- .../JavaChangeSignatureUsageProcessor.java | 14 ++++++-- .../ParamTypeSubst.java | 10 ++++++ .../ParamTypeSubst.java.after | 10 ++++++ .../ChangeSignaturePropagationTest.java | 35 ++++++++++++++----- 4 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 java/java-tests/testData/refactoring/changeSignaturePropagation/ParamTypeSubst.java create mode 100644 java/java-tests/testData/refactoring/changeSignaturePropagation/ParamTypeSubst.java.after diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java index 2d99c94337d0..a5ead200d950 100644 --- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java @@ -741,8 +741,13 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr final JavaParameterInfo[] primaryNewParms = changeInfo.getNewParameters(); PsiSubstitutor substitutor = baseMethod == null ? PsiSubstitutor.EMPTY : ChangeSignatureProcessor.calculateSubstitutor(caller, baseMethod); + final PsiClass aClass = changeInfo.getMethod().getContainingClass(); + final PsiClass callerContainingClass = caller.getContainingClass(); + final PsiSubstitutor psiSubstitutor = aClass != null && callerContainingClass != null && callerContainingClass.isInheritor(aClass, true) + ? TypeConversionUtil.getSuperClassSubstitutor(aClass, callerContainingClass, substitutor) + : PsiSubstitutor.EMPTY; for (JavaParameterInfo info : primaryNewParms) { - if (info.getOldIndex() < 0) newParameters.add(createNewParameter(changeInfo, info, substitutor)); + if (info.getOldIndex() < 0) newParameters.add(createNewParameter(changeInfo, info, psiSubstitutor, substitutor)); } PsiParameter[] arrayed = newParameters.toArray(new PsiParameter[newParameters.size()]); boolean[] toRemoveParm = new boolean[arrayed.length]; @@ -802,10 +807,13 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr } private static PsiParameter createNewParameter(JavaChangeInfo changeInfo, JavaParameterInfo newParm, - PsiSubstitutor substitutor) throws IncorrectOperationException { + PsiSubstitutor... substitutor) throws IncorrectOperationException { final PsiParameterList list = changeInfo.getMethod().getParameterList(); final PsiElementFactory factory = JavaPsiFacade.getInstance(list.getProject()).getElementFactory(); - final PsiType type = substitutor.substitute(newParm.createType(list, list.getManager())); + PsiType type = newParm.createType(list, list.getManager()); + for (PsiSubstitutor psiSubstitutor : substitutor) { + type = psiSubstitutor.substitute(type); + } return factory.createParameter(newParm.getName(), type); } diff --git a/java/java-tests/testData/refactoring/changeSignaturePropagation/ParamTypeSubst.java b/java/java-tests/testData/refactoring/changeSignaturePropagation/ParamTypeSubst.java new file mode 100644 index 000000000000..374f3cccbad1 --- /dev/null +++ b/java/java-tests/testData/refactoring/changeSignaturePropagation/ParamTypeSubst.java @@ -0,0 +1,10 @@ +class Base { + void m() { + } +} + +class A extends Base { + void x() { + m(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/changeSignaturePropagation/ParamTypeSubst.java.after b/java/java-tests/testData/refactoring/changeSignaturePropagation/ParamTypeSubst.java.after new file mode 100644 index 000000000000..070698a3d8c6 --- /dev/null +++ b/java/java-tests/testData/refactoring/changeSignaturePropagation/ParamTypeSubst.java.after @@ -0,0 +1,10 @@ +class Base { + void m(T clazz) { + } +} + +class A extends Base { + void x(String clazz) { + m(clazz); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignaturePropagationTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignaturePropagationTest.java index bdb1445df3ce..6daec4d62b1d 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignaturePropagationTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignaturePropagationTest.java @@ -6,6 +6,8 @@ import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.searches.ClassInheritorsSearch; import com.intellij.psi.search.searches.MethodReferencesSearch; +import com.intellij.psi.search.searches.ReferencesSearch; +import com.intellij.psi.util.PsiTreeUtil; import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor; import com.intellij.refactoring.changeSignature.JavaThrownExceptionInfo; import com.intellij.refactoring.changeSignature.ParameterInfoImpl; @@ -29,6 +31,18 @@ public class ChangeSignaturePropagationTest extends LightRefactoringTestCase { parameterPropagationTest(); } + public void testParamTypeSubst() throws Exception { + final PsiMethod method = getPrimaryMethod(); + final HashSet methods = new HashSet(); + for (PsiReference reference : ReferencesSearch.search(method)) { + final PsiMethod psiMethod = PsiTreeUtil.getParentOfType(reference.getElement(), PsiMethod.class); + if (psiMethod != null) { + methods.add(psiMethod); + } + } + parameterPropagationTest(method, methods, JavaPsiFacade.getElementFactory(getProject()).createTypeByFQClassName("T")); + } + public void testExceptionSimple() throws Exception { exceptionPropagationTest(); } @@ -39,7 +53,7 @@ public class ChangeSignaturePropagationTest extends LightRefactoringTestCase { public void testParamWithNoConstructor() throws Exception { final PsiMethod method = getPrimaryMethod(); - parameterPropagationTest(method, collectNonPhysicalMethodsToPropagate(method)); + parameterPropagationTest(method, collectNonPhysicalMethodsToPropagate(method), JavaPsiFacade.getElementFactory(getProject()).createTypeByFQClassName("java.lang.Class", GlobalSearchScope.allScope(getProject()))); } public void testExceptionWithNoConstructor() throws Exception { @@ -62,12 +76,12 @@ public class ChangeSignaturePropagationTest extends LightRefactoringTestCase { public void testParamWithImplicitConstructor() throws Exception { final PsiMethod method = getPrimaryMethod(); - parameterPropagationTest(method, collectDefaultConstructorsToPropagate(method)); + parameterPropagationTest(method, collectDefaultConstructorsToPropagate(method), JavaPsiFacade.getElementFactory(getProject()).createTypeByFQClassName("java.lang.Class", GlobalSearchScope.allScope(getProject()))); } public void testParamWithImplicitConstructors() throws Exception { final PsiMethod method = getPrimaryMethod(); - parameterPropagationTest(method, collectDefaultConstructorsToPropagate(method)); + parameterPropagationTest(method, collectDefaultConstructorsToPropagate(method), JavaPsiFacade.getElementFactory(getProject()).createTypeByFQClassName("java.lang.Class", GlobalSearchScope.allScope(getProject()))); } public void testExceptionWithImplicitConstructor() throws Exception { @@ -84,13 +98,18 @@ public class ChangeSignaturePropagationTest extends LightRefactoringTestCase { } private void parameterPropagationTest() throws Exception { - final PsiMethod method = getPrimaryMethod(); - parameterPropagationTest(method, new HashSet(Arrays.asList(method.getContainingClass().getMethods()))); + parameterPropagationTest(JavaPsiFacade.getElementFactory(getProject()) + .createTypeByFQClassName("java.lang.Class", GlobalSearchScope.allScope(getProject()))); } - private void parameterPropagationTest(final PsiMethod method, final HashSet psiMethods) throws Exception { - PsiType newParamType = JavaPsiFacade.getElementFactory(getProject()).createTypeByFQClassName("java.lang.Class", GlobalSearchScope.allScope(getProject())); - final ParameterInfoImpl[] newParameters = new ParameterInfoImpl[]{new ParameterInfoImpl(-1, "clazz", newParamType, "null")}; + private void parameterPropagationTest(final PsiClassType paramType) throws Exception { + final PsiMethod method = getPrimaryMethod(); + parameterPropagationTest(method, new HashSet(Arrays.asList(method.getContainingClass().getMethods())), + paramType); + } + + private void parameterPropagationTest(final PsiMethod method, final HashSet psiMethods, final PsiType paramType) throws Exception { + final ParameterInfoImpl[] newParameters = new ParameterInfoImpl[]{new ParameterInfoImpl(-1, "clazz", paramType, "null")}; doTest(newParameters, new ThrownExceptionInfo[0], psiMethods, null, method); } From defcac6ef958c5b41cf1bd9e0ee848619355f561 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Fri, 8 Jun 2012 15:29:58 +0400 Subject: [PATCH 025/172] Revert deletion, used by EA plugin --- platform/icons/src/modules/edit.png | Bin 0 -> 718 bytes .../util/src/com/intellij/icons/AllIcons.java | 1 + 2 files changed, 1 insertion(+) create mode 100644 platform/icons/src/modules/edit.png diff --git a/platform/icons/src/modules/edit.png b/platform/icons/src/modules/edit.png new file mode 100644 index 0000000000000000000000000000000000000000..bd9bca9417264859b83aaf65c159e44f1aa22066 GIT binary patch literal 718 zcmV;<0x|uGP)%h_WSeq`}Fwy_xk<+ng;)x2>+xS|I(|Mqq3Q#vzn*B zpRBy1ugImb&DrSm+UWG$>Gj>}^xf+9-R%F~=lS33_TcRH;qCV0?ewo~5#;Xlhk&P^ZD%a`Rw!h?WG@Nc8z6rjYU~dEnmC6=Vl7Mjk+lK$$j{o0@|NZI7O1w1y001I% zQchC<1!K9-)z#hJ-rnBc-rnBc-rnBc-rncu_xt?*{{H^{{;q5a=>Px#z)3_wR2b7^ zU_b|Kf}&!=LIV7JygXc-tUv*7-30f_W_4rNyzHh54xoTYR&{`%cR^-KyrX?$Bv>F! z+qc+LEh*X|HOIz=2`HeW<*i(nuj-O+(56%(0~GN0DRNVbi}5h3RccTH3505RWhBQI z8rCQUsid(01vHi2N>wBD+m!-U%)}Xi0_H&Atk-HAsA4G#v_)D12%;37?1D|K Date: Fri, 8 Jun 2012 19:24:39 +0400 Subject: [PATCH 026/172] typo --- .../projectRoot/ModuleStructureConfigurable.java | 2 +- .../icons/src/actions/{modul.png => module.png} | Bin platform/util/src/com/intellij/icons/AllIcons.java | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename platform/icons/src/actions/{modul.png => module.png} (100%) diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java index c583216282ec..40837d333a15 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java @@ -925,7 +925,7 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple private class AddModuleAction extends AnAction implements DumbAware { public AddModuleAction() { - super(ProjectBundle.message("add.new.module.text.full"), null, AllIcons.Actions.Modul); + super(ProjectBundle.message("add.new.module.text.full"), null, AllIcons.Actions.Module); } public void actionPerformed(final AnActionEvent e) { diff --git a/platform/icons/src/actions/modul.png b/platform/icons/src/actions/module.png similarity index 100% rename from platform/icons/src/actions/modul.png rename to platform/icons/src/actions/module.png diff --git a/platform/util/src/com/intellij/icons/AllIcons.java b/platform/util/src/com/intellij/icons/AllIcons.java index fab286c7c33c..8540a4856fc9 100644 --- a/platform/util/src/com/intellij/icons/AllIcons.java +++ b/platform/util/src/com/intellij/icons/AllIcons.java @@ -64,7 +64,7 @@ public class AllIcons { public static final Icon Menu_replace = IconLoader.getIcon("/actions/menu-replace.png"); public static final Icon Menu_saveall = IconLoader.getIcon("/actions/menu-saveall.png"); public static final Icon Minimize = IconLoader.getIcon("/actions/minimize.png"); - public static final Icon Modul = IconLoader.getIcon("/actions/modul.png"); + public static final Icon Module = IconLoader.getIcon("/actions/module.png"); public static final Icon Move_to_button_top = IconLoader.getIcon("/actions/move-to-button-top.png"); public static final Icon Move_to_button = IconLoader.getIcon("/actions/move-to-button.png"); public static final Icon MoveDown = IconLoader.getIcon("/actions/moveDown.png"); From ec518e1797ffb3013bf5be382c755da627719a46 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Fri, 8 Jun 2012 20:43:47 +0400 Subject: [PATCH 027/172] Dead icons hunt --- platform/icons/src/actions/exception.png | Bin 354 -> 0 bytes platform/icons/src/actions/import.png | Bin 592 -> 0 bytes platform/icons/src/ant/filterError.png | Bin 636 -> 0 bytes platform/icons/src/ant/filterInfo.png | Bin 640 -> 0 bytes platform/icons/src/ant/filterWarning.png | Bin 634 -> 0 bytes platform/icons/src/debugger/attach.png | Bin 163 -> 0 bytes platform/icons/src/debugger/detach.png | Bin 154 -> 0 bytes platform/icons/src/debugger/pattern.png | Bin 402 -> 0 bytes platform/icons/src/general/errorMask.png | Bin 288 -> 0 bytes platform/icons/src/general/errorsOK.png | Bin 416 -> 0 bytes platform/icons/src/general/fix.png | Bin 429 -> 0 bytes platform/icons/src/general/separator.png | Bin 87 -> 0 bytes platform/icons/src/general/separatorV.png | Bin 958 -> 0 bytes platform/icons/src/general/template.png | Bin 612 -> 0 bytes platform/icons/src/general/warningsFound.png | Bin 400 -> 0 bytes platform/icons/src/gutter/unique.png | Bin 212 -> 0 bytes .../icons/src/icons/inspector/collapseall.png | Bin 232 -> 0 bytes .../icons/src/icons/inspector/expandall.png | Bin 231 -> 0 bytes platform/icons/src/ide/dnd/error.png | Bin 783 -> 0 bytes platform/icons/src/ide/tab.png | Bin 164 -> 0 bytes platform/icons/src/modules/excludeFolder.png | Bin 648 -> 0 bytes platform/icons/src/nodes/servletMapping.png | Bin 841 -> 0 bytes platform/icons/src/nodes/sql.png | Bin 443 -> 0 bytes platform/icons/src/objectBrowser/bean.png | Bin 664 -> 0 bytes platform/icons/src/objectBrowser/variable.png | Bin 547 -> 0 bytes platform/icons/src/webreferences/add.png | Bin 706 -> 0 bytes .../icons/src/webreferences/properties.png | Bin 226 -> 0 bytes platform/icons/src/webreferences/remove.png | Bin 685 -> 0 bytes .../util/src/com/intellij/icons/AllIcons.java | 28 ------------------ 29 files changed, 28 deletions(-) delete mode 100644 platform/icons/src/actions/exception.png delete mode 100644 platform/icons/src/actions/import.png delete mode 100644 platform/icons/src/ant/filterError.png delete mode 100644 platform/icons/src/ant/filterInfo.png delete mode 100644 platform/icons/src/ant/filterWarning.png delete mode 100644 platform/icons/src/debugger/attach.png delete mode 100644 platform/icons/src/debugger/detach.png delete mode 100644 platform/icons/src/debugger/pattern.png delete mode 100644 platform/icons/src/general/errorMask.png delete mode 100644 platform/icons/src/general/errorsOK.png delete mode 100644 platform/icons/src/general/fix.png delete mode 100644 platform/icons/src/general/separator.png delete mode 100644 platform/icons/src/general/separatorV.png delete mode 100644 platform/icons/src/general/template.png delete mode 100644 platform/icons/src/general/warningsFound.png delete mode 100644 platform/icons/src/gutter/unique.png delete mode 100644 platform/icons/src/icons/inspector/collapseall.png delete mode 100644 platform/icons/src/icons/inspector/expandall.png delete mode 100644 platform/icons/src/ide/dnd/error.png delete mode 100644 platform/icons/src/ide/tab.png delete mode 100644 platform/icons/src/modules/excludeFolder.png delete mode 100644 platform/icons/src/nodes/servletMapping.png delete mode 100644 platform/icons/src/nodes/sql.png delete mode 100644 platform/icons/src/objectBrowser/bean.png delete mode 100644 platform/icons/src/objectBrowser/variable.png delete mode 100644 platform/icons/src/webreferences/add.png delete mode 100644 platform/icons/src/webreferences/properties.png delete mode 100644 platform/icons/src/webreferences/remove.png diff --git a/platform/icons/src/actions/exception.png b/platform/icons/src/actions/exception.png deleted file mode 100644 index 3c0afdaf49a8c0cb583ccd914ea02673a4f99829..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 354 zcmV-o0iFJdP)N#%OD6LlzeR z;&*@k{9*j{>lee#n>YVTN=mv-nlx!2hDId72*hWQG%)}*IsN$Y;}BLGkw5`ZlQNP` zHb6}$8XFr?6fvP`k_Bq&MY72griq`Qp8=PROh8S?fSMSgn%XilGIk3J3W7CpadDyg z2NtSLO--FZO{G77{$vDV2B1w0@87>?U}0f73^dSb_3G7susRi}sS&7w4~Tt`G;IcI zvPaj1;#3n8lW)Sp!VHTSFK&ZsTCjZi@=2N0KA-{-02m}Q~&?~07*qoM6N<$f`wg% A?*IS* diff --git a/platform/icons/src/actions/import.png b/platform/icons/src/actions/import.png deleted file mode 100644 index 860be14ca16ab84a0f64dfa0447de4cfdbf1536f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 592 zcmV-W0eC+V>_xSku`1l`O zxlxI_S9qdXnBy~m(p+qqTy2!Q8v zq`mQ^zwH!Du&2T8MOS*Ty3er5^Ud7$(BJmZGb+a zZ=CD#@ay&YOLd>^@bK^O@bCBe@bK{U`1nqv=1_W~vdiseFr{ev7Kp;rP_)_0{R|*6a1z?DX92^WEtB-thC_?fBsE^5gOF znBb_K`$1)N@EKuE$D9}HU z5DS)Wt8CbPyVKm{fwjQ*xl|2QE3JtY5PO8;n4|7ukKb67iSrhb{afS$U5uHS-HYlEoQg;;Ehv*E|y@Yv(( z;_UO|I4R^qG>lzwjI!X6KuPB9_UG{S={YFt@%8KS_3ZNYk+k8KMo*Z8m6?*RT#?gd zj>2o5-fxh%b(gt&rr-Z|VE=<||GlhztKa{}x&b5Z-~a#sB6LztQvd(}5HL+xT54)) zgNc)rn4Y1bqq4Ka#@pWQ?(y{X`TG5bD>U!`006K_L_t&-S7Ts80}Kd0E3X(YD-#1F zHxHkHu#lihnv8<4yc8RQxSL_1MRHPnShTZRfwxl#1DB(wL3V(Dj(Kc;k(!r#Dgy(v zbVhKvii(wKRGyEgEH48C1B+sorK+mEjcueyf&?p2fPurMFv8W^EXrT+JqX_uL$g!gc7>hD9Km-7k W!yFRpa$AW20000HR_3QHWEK`f|^!6-YrGT#AgQ(Ywv*C=g;E}Z9 zlD4Q<+Y?!p+gymjT#?gU+#6+%!e-wZYnNneo!)EUCu`v;Z;-dW&EdxNdB@)H&i9Mh zoKbAi8ax}BAWSFEZH16PoNZAx)bj*~@vT1K*( zH3I{)Y)nX|va)M}ep0rc3@-x%1B+6ki;9Y8gpsC(oCGUSfPq83Fe}i_J>OE27tCj1 z;54)MbIdhQh44UtKhDQKS_HvoU^ej%H)UjGL^`7@`a4pa^J(DX^mm1c)*- aKm-8XP#pYHEP1;C0000hA^7Qid_B(2(J8iH$YNkGMvp#aTKX$r9Z>>Xly+muDMRBfHg0)$d+gymjT#?gd zj>2o5-Yip#oUf&vu*aT{IG&I!puXayzS*XqWU0yHtjOc7#@nsPHR_3QHWHD8+X^!7P{*#GGa|LG9_@IwFaN&oRf|M{bti87m@jK|*a z&%GJZzZuiO9@NG^*yHNr?DKDsw{@4fd#2xgtKWW^y6p1yfS$U5uHS>G*NKc-i;i21 zv*C=g;E}Z9|M5!y@lgNrQj(Kj|N5@~`mn%AZ8`t|03&o#PE!B?01z-uSXydoYJ-WB zl$f5Op`)_1#Kz9v=j`n6@b&fg{c~R);s5{uut`KgR2WxdU_t{72tF&X7%wXm10y#N zpMbECpkGN>aRSXkKAKpuZIZ1GB72 zT8yfyqg_-`aDWUi0|Nt#l9_{=nya&Qq`#a5D^P%e!zVG;*U7~qU6L2fXJFveSN5_= zFmQwLK!D%WL)lma!DnFBRms+4WMo7LX{u!EpbKcD3uvGSsAtKuqX?LbGBZE~0NZIC UO{cN4Q~&?~07*qoM6N<$f}>qH?EnA( diff --git a/platform/icons/src/debugger/attach.png b/platform/icons/src/debugger/attach.png deleted file mode 100644 index 8a09f79e1b3fdca1b941b119ca13429ec50b1fdf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPGa2=EDU{r~^Jky{cbYHPeB3sl2V z666=m@XVLtczxNDiXAg@fnr9UE{-7_(a8x1m?M~2fxv;sH8nXohDTLZm4kVighuil oh9rj6DO?Ub;tB-`3TzAvENj@^wihg_0_tY)boFyt=akR{08_XsxBvhE diff --git a/platform/icons/src/debugger/detach.png b/platform/icons/src/debugger/detach.png deleted file mode 100644 index fd867a661d065051fc49a897c234652a045a7b5a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 154 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPE^3h)VW{r~^Jky{cnlDcMp4k*i3 z666=m@Qh)mcOid$;#Z)Ep{I*u2uE~s!U1*(Rv$Mr}85+>khPfRo|TPPTtfj~AZ+YG&|s^>bP0l+XkK9@#UR diff --git a/platform/icons/src/debugger/pattern.png b/platform/icons/src/debugger/pattern.png deleted file mode 100644 index f5eb698570602fd574dd48f1622bdc57cf196777..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 402 zcmV;D0d4+?P)-I`+3d_P9It(t!88J@>ys_rF5-*NXVR zN%+G;_{U24$V>RiSNPeD`P`NH-kAB~qWR>d`pQW9(op)+X!_TL`sc3t=&}0ixBBe5 z`_NbW(OLW1W&7Na`|rN{@WA`=!~62Z`}4&6^uqh}#{2ce{MuUl+iCpUdHms>{Nil< zOBi=(}*jhV5!JR?NF z&CbfyNKQ!EA&@A<}=PZsZzxNi>s^`<{ zy=~H0sDJB|tJB*D*DpqzpLI5Qy{me9L6GID*st4--~|DqhKlobcZ%BJi>r=z0cES3j3^P6Iq zrXw)KFfz(AGt4t_+;NTKjsO4uDz_>uyeuxiE-t_>A)+BM$1x$GAtb3JNzzGA(@#;; zQB%}YRn%1`ttNTid4u4CC$A?buqP#|B_*pRFT*b)qarcJF($4iGRZO`q#`rRGa#TK zHOw_R&N(~IJ3Y@mLC--!&_PAeMMcp?N6|+pvnVOEDJiunDz+*ls3cd_S6J0pUDjP* z*Ir=PU}D%}W7uP4*kotfXK2}IY}#yX+ih^$a4Wehb=-A%-FYjzD}CR6f!~2FyDWv^ zg^S{gBBCOYS+0MPL`Ai{kwDbFIs*h~Qoi7GWR#FoTi4L<4qvRY` zA*YqYOrlNlAIQ?F6@IFcU<=Z#=*ln+r$!w@wQ)ITkDAIJofa0ZYI5rL3! zaX14m3sMIIPhNanz5mXxbFbGOy1(||y#-q?F5G(Q>B~=NAO7o_w|mcpx3kurK5^&g zvR&67KmRy?^Mzx#zCU^SscqKw+b{pmTzhKc(MS6)f7pHg&EAXePTu|1Id@m%)J>C@ zADOr5{K~zz4qf{^cjLLOC!Za>`swP^|4-iizxM3^_R}vm9C>)@@&AW!{&E&#ej zq9n*Kn88ISve3kmIVjOdPAJMZPdlEM%h)r(>gk%vr-5qfJY5_^D&lI-9pyXZAmRE@ zUh`d*`)k*`vG@KjZ731q;NExlrtGitS`nU$XXpm<#T$jRt(Gu}x0v2Oce%(Nx#mX) zYfH9WULT{?`S+oO#d3?S2Ywt|zWbkoALrw_&h}F#zs`AAxqeN;)^FxkcZ?JlXwmb6yfo7 haSY**O)g0|!p-Ptz#_=ua}p%Z;OXk;vd$@?2>|UU6gmI^ diff --git a/platform/icons/src/general/separatorV.png b/platform/icons/src/general/separatorV.png deleted file mode 100644 index 6f6ef147c66f2367adcf91f415d57822a4364d47..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 958 zcmaJ=O>fgM7|t|Qp`jf(plKi>%R542JL|_{EtEFiXeBaDUB!A_nz(J)5{JZHvz`za z#1BE@#2?@QC&c~&ocIO&0i@w{ZO4HUDe`OUd7k%qU%!5Lc<^j}?f#mkY3r>fYpeB+ z`tRN@7_HzN=}gFz9q;*LhAo5$bM^ z(X%jCY)#v(WwGm>atV5T5JVRI_31MNfp5X%vV)!2=EI;lN%+y^pyN$WJ=2G^Ctx?D zN+9IY1zC6&r8KkPRF|qaKSmHtA@bCM*QUD8A+SZlL0QK|4_64Nlyp+UX32aE3`{U0 z2Ex@M!L(eZn1I;_RkpB|mumm=A#hCDl_9raL)bxM1){kG7Xk{DJ|8TasB09%1gOOnL+u*{&mswBQ-sFxENct zSqwgp)U+pRtj{C3rJjV*V)ah;z4!a-s%iJuO^8 zFj_z`SwJs;Xe7lH(~BR~pI6tCBDHG~ z*_9^Rmnz$vHQS?3-k><%p*-K9G2o&$;i5F*qBiBJI>wVc=dC^LwL|W>NAI;n@3=plVED#n_|k^?$#MD1ZTii4`p$p*#a{c( zcKg$a`__&8&|&=5mHgVE{m^0k(P91ClFEJ+%6}C9+I!1?760P9|KpJV=EVQ$%>V7Q z|L?y4^0~}`7XSYK|Nr6sQ!o9*S|Xm7300T$p3 zjh2&A*R%+fw&I2egvlueNa`6U_?QVp1ahVPRWi&y<6I5JAp+i6l0d#pvRk?cM8I7w z4ak=b_t4^p2soRXc*=z2#Mop)1bChD6XRtg^CGn6AzDQ3qWr@oG0000j_gW<~;hOb{i>Hq?W39R}e z1H)Se1`Y-WpsAt^47~sUGyM7mQuN^iNE#r3Ac{^fFx+Qg_`$#cG?)#@2P*pg8)VF< zPatW40Ac|PU1wzc$-n?a|G{=W`tt{5($Aj^KuduDAb>!M{{3TMW(K;39ir&}|JOi8 za0CPZ0R%A#sO~ot(;Wte-$3@?zfc6!4CDdlYM@C#%@C6S0tloCr~()sz)%57 u07b!0gqq6A3Q`0RK#cz(Zo>-z0t^7n4Wd>1Rkq#$0000t<7Z{`|f?iOq1on+<~ zYw8jW;Nsx$h6j1T9X@84=riqpW`2{l= zZ(3=w$@J*w!wX-&Sa9^q5zAHPo49HU<^UDwc)B=-a6~63I54P*rJ02ZG*6t{JX!F_ ugGXXdAF_6T_{iPhI)kOP#Z|(9kwL+U;jP5af2V=^7(8A5T-G@yGywp=Xhnkn diff --git a/platform/icons/src/icons/inspector/collapseall.png b/platform/icons/src/icons/inspector/collapseall.png deleted file mode 100644 index a2b5f7e65004368830a0db27c03bf66e62c3532a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 232 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!Uw}`D>;M1%^_>$mQWpD6IBr<7 zMI(8UcIFDbytR7y>ogJ?ArACTwn>Eakt5m$QVINt#U9_9-P zW#8rg|6eR>F5X(cNmq4|_4?%K<38QeIbRONXv}rIWNCr<=KbLh*2~7a?zg)8b diff --git a/platform/icons/src/icons/inspector/expandall.png b/platform/icons/src/icons/inspector/expandall.png deleted file mode 100644 index 0049c522ca4c7587cc1e59f2352187eb0638e2ed..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 231 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!Uw}`D>;M1%^_>$mQWk3@FET9I z;xpm6Wyw0ry1kmIOZ~cc`*-gN?AxcExx%@At4Hrqy}Y%0`RgZ2jsbVx;TbNNR}RS=R2Ul!*I}4 zcW?N={}&4mYb3G#b5RyFTDWep$o&Q}`FfU3m8QqGSeIU}<@>v3;?86GVrP4&Oj@Tu50+T3JwIUP4k{NLgMZoR zeSW%ufV!BQyGug7R#LuscfNvxzfefOqou#2r@>A~!ap&>d33{7Ps50a#9&&)j*kCT zKmS%f|6E5|M_T`4NB?6<|6@%5WJ>>LP5+aD|CEFOm4^SAhyR(2|C)*aosIvWlmDTW z|Du-vC=35B3jZw&|1A^$E)4%L4*xR||1=W+HWmLj7XLRF|2H51IT`;t8~;5g|3W7J zMk@bDEdNL@|4T0aOf&yYHUCgE|4}&qQ91uoHvdvP|5Z2tRXABkSy@C@#aU3rXko^S zipOeX$B2fB3#>UUp)z#YC+S}XT-{0Tg-{0uy^Yi@t{EQKeP5=M^%}GQ-R2b7^ zV88|#*?47S`Pdj?d?pF)dasg1Em0;YUoCJ_zrS~BT(l}!gi$<+S7eTjp=oQKrIB-R3J=Iy$%IV%a9v$p zr?6~kuw$9k(+WI*0=k77tPrO%tHk8GxfQ2NvA{jYDI_N^!p(@)=KvrAE^OE+q3Hks N002ovPDHLkV1jB-bWi{Q diff --git a/platform/icons/src/ide/tab.png b/platform/icons/src/ide/tab.png deleted file mode 100644 index ad44adead8c01158e382700518e0b1a6b8343c7c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 164 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPGa3-AeXHF8V(|NlRbL`J5|EnRnd z)SqwM$!`$?RLNcv?M5RT|%ffgpVMG}iLGcz3(+9W2- w=1KD~<636WAR*M+q^TFMa*N5DTb#xWGZ=YlW|iHH1?pt*boFyt=akR{08C;qKmY&$ diff --git a/platform/icons/src/modules/excludeFolder.png b/platform/icons/src/modules/excludeFolder.png deleted file mode 100644 index 54f2ae2499b94f66771cbe53e6c297dc25c5f248..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 648 zcmV;30(bq1P)&jcQ^qLttTWhKgxiifLVmWm}46TZv;?iDX-eWm}13Scz#}h-h4iXkCeD zT$5>6lw?%4CIel}5-~RFB{`Kqr_3i)9qW{~t|Ki90<eT=7<^S~R|Ml$u_U`}p@N=Mz#Q*>R6?9Tg zQvgw1aFnyN)z#J2*4Eb7+1c6I-QM-DrmFw|0KG{>K~xx5V_+Z%7}+^EIM~^l-~wD? zP9Pu*7vRhYkdqY`PZ8o5Uk8f!raG}ps%5s i=b4WXV1)t(bN~Q7k|9Bpk{e^O+}8X=$Y=~g75YH@b>-m`2KTtVRLw4b9!TQeR*?z zdUJk)bAE+UZi`cBhgEHkoUwhU$n{sFw_|mX&fxma;rhH{``o}{-0Az?u@2tRMc(WC3TLzmZ@mh9*$Zd2WpaUNwB%`W zd}*Q0YIS{TvF2;5x@>oOa(i#}`TqIgH2Ln0`SE=D`~La-#rpfm`uw2!{KotFx%}i4 z{Pmpt`O5tK+Wp=Z{pTS5;!XbMOaI9L|Je=y-vGt|Msf? z_qYH1od5pW|NpuF|HVZ7x^Dmg04;PU6U%FNc*+1lLP z+}-8v@9+2f`}_O+{Qmy_{{H@Fz5ogU008AlL_t&-S7Ttn2AH^cMMZeH7-4)CF=efU zNDUP!RtTS2R@2M-0S0yn)o@QeF9YK!UlXtZ10$!5dO=P`T98RRL;wi*1qFbBkB<)kr8hQd Tezg=D00000NkvXXu0mjf#cRVC diff --git a/platform/icons/src/nodes/sql.png b/platform/icons/src/nodes/sql.png deleted file mode 100644 index 5ead39b675f36d65f6a540c1ffe611d761992599..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 443 zcmV;s0Yv_ZP)UDWLsMkQ&elUvUPDn{FPHyAQ)WX`XEsf6I8Jb*yVkJ2(6`9l zzs1hM!otDF(8kNt$-=KXPjDTK|Ig?D(&+!y+27Ub|K0BYJWz1olK|lF|MQ~;`s>U= zpa1>CRsHeU|E>@JvKs%kC;z-Q|HDfE$XP;9S^x0S|M1lR@z?+J+yC|ALQr2rP+fB( zu=@Z201b3fPE!EAz0c(2^78fi`u_gVKjO3i004_gL_t(|UX9E}7K2a_L{SJ3@2_aw z-Q7L=-%{W=ne&GC)F~}VDU}{&Ab4Rr7G=h8y`0x$M2{Ax(f25I*>jM`$mg(dky997BQjSIr>}-d{>_!NY%Bl;FO>h0Yu) lrFS|WmX-p;jIvZ(f`01_4IP8-WdHyG002ovPDHLkV1m={=Mw+` diff --git a/platform/icons/src/objectBrowser/bean.png b/platform/icons/src/objectBrowser/bean.png deleted file mode 100644 index deffd2d52604444378a110c48b32b1e6f27ebd09..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 664 zcmV;J0%!e+P))@!R#Zw>R7zD-NmWxwWm!I4R6$`| zNm@@gR82ZBgTy+$&eFxsUt+O9X; zq%qvBHRHx+=C(ZQ$YJirMexQ#@Xu)R(QfkBW%Js7^xSv!-hueyg81Wv_~nTE>52R5 zi$tUH2><{9Ep$>&Qvd)26dFWQXKHYDd3%3?hK84##K+Fn*WTmf@bdHY_4fJt`}_O+ z{Qdp@{{CvmhI;@20I5ktK~xx5V_-xB3|IshScIfxr6o8RfB-DOED~5$Rav6S2NU4b z4$UYm$jjH^feMIaSNMjcrl%#T^FjpV%F9Z<{o-SyBURYI0+Pv@ImNDSL16**;$Q($ z=eWeITq|2ocWXtk0IO1PL{w~wnWdeL2E-j)Y92oR;R(hjhVl>r25wCUM<*9AJzW8) y00Y0Wk%hUbfiMG1fPq~`OJ6~di2=LkPyqmxTphpEX#v3i00000kK2+azG-9$w1PhFbhap)CU>Y`hoxszv4cArTqfRNBGrF2x?vu);TAkdq>RrvWE3bb=yNa-q)>y9ymrm z_lW=MSNJx$5S8ufXt_ zxRxo?W-M5^a`o!XyY}usaOm*y6DLlczi{jJ{U=Xfzkd7f-TRN9K7aZ0IYEJa#cb&lpN$MYWY387Y-9~luIY7=kPtZ>!=rkD ziOI~-uSmv*&u&{*O#-9Z(*ph4z?%W)wuNdPig(l+zj=xMyQUQr5G=XW*`~KSw)BWZ z;|sT)wKWs diff --git a/platform/icons/src/webreferences/add.png b/platform/icons/src/webreferences/add.png deleted file mode 100644 index 2ffcd5f95d2a05b2a0ef0baf929a53fb4364d92e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 706 zcmV;z0zLhSP)T@q_vrS zQJQ~LoOe&0fmoh;QJ{TNp^0XqfmEW4Yom>Bq=QwYj&fwRc{@_;Q!Zu|Jj58*@TR0MgREh|N8W^ zyvMYbakZFrwwigioPM^?^SGXZxY6{vhX%QxgS*h=z0~!AFi6h;Y zGToRn-JJyCyFKEfK;z70a9-duTAT)Q0v#61ZCZ8h|GP#@Py-J z9o+<^k$3jTYxm1>_seql$8Pw^ZTZl5`O<&+*q8dhTKdm(`^|Lw&vyLLcl_Co{NAJd z-le6IeWr(3rj>)Imx!o|Sg4nXs*7B#jb5y@z^uvfuFCSSw!yE;^01L<|JjBA+KvC* zk^kME|K_*C5o7K!v5LM0ZKOfJp z53%T`0iY{ZY;VZtUV@n1Wwv$nn4PIhzCG?@k`k7+6u9ZyL}+gflZ{268lZEQYpHp{ zQbb9QNoRFDu(OJZ$2F<|sJ^ka^DAyjQ{`u diff --git a/platform/icons/src/webreferences/properties.png b/platform/icons/src/webreferences/properties.png deleted file mode 100644 index 8eda095c85e54ff191074b58108ddf63c25bc71a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 226 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!Wq?nJ>;M1%^_>&)YbREB%&PC6 zyJ+=}_1h1Xw@g2F`trrAx36732T|Z0S`e30-#cT))cNcD;!0w(>om<`R{#y+Dhcun zW;k>6&fTXk-@pIJlPv!VDC+0w;uum9S9{iz>wp1|bKvS?)$%?66TO|pn;iaqN?e@5 z+?ILo@`DLerXQSpCbTh#b#G-K-y`P}abgU73nwvVC0>Z>Q295N@5kwDb8~+)%(r8D Umi4Op0?=dzPgg&ebxsLQ06$z`vj6}9 diff --git a/platform/icons/src/webreferences/remove.png b/platform/icons/src/webreferences/remove.png deleted file mode 100644 index f9399c5aa6eadc4cc33fb007dd875dcbc2deb6d4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 685 zcmV;e0#f~nP)M{;{;{hjA})WZAXxCNRo6*ly^>)@O_qg zPnV>%nSD{3e^i`zPn>~Ro_bNBeNv%`W}<;qqKj*zjc%laRiut`q>*=}l6|I!R~zpD z9o+=-zG3shW%kEw_seql$8Pw^ZTio1`^|Lw&vyLLcl_R?{NAMiYVZHqga6rt|JjBA z+K&I+k^kME|KX|s<+T6ixBu+6|Lo0MOhEtm?Em`oz0~!AFi6h;Y zGToRn-JJyCyFKEfK;z70aR`fuu$vQoNI{8eZlaA<7B3lgQu5> zsEJspmx!v1T>03Stc_l*w7{&%@vh49ueQOj%JTixdi~v;{p7a&OUwsBNmVskY3{&=F@~O5jj-s<5}KO0mc?HP#aasZa?m%dN4}H)ml< z(h>m)7>1PQq#8uCuxM+j2{ACmau_z2SldDXrvOL=H&=0HGA9J^Gcc7`I=B?1n;B`V zsj>(9@G&qkGc&X1r Date: Fri, 8 Jun 2012 20:53:05 +0400 Subject: [PATCH 028/172] IDEA-87248 (smart type pointer manager should be more tolerant to unknown types) --- .../SmartTypePointerManagerImpl.java | 15 ++++++++++++--- .../src/com/intellij/psi/PsiType.java | 1 + .../src/com/intellij/psi/PsiTypeVisitor.java | 13 ++++++++++++- .../src/com/intellij/psi/Bottom.java | 6 ++++-- .../src/com/intellij/psi/PsiTypeVariable.java | 7 ++++--- .../src/com/intellij/psi/PsiTypeVisitorEx.java | 6 +++++- .../advHighlighting7/LambdaExpressions.java | 4 ++++ 7 files changed, 42 insertions(+), 10 deletions(-) diff --git a/java/java-impl/src/com/intellij/psi/impl/smartPointers/SmartTypePointerManagerImpl.java b/java/java-impl/src/com/intellij/psi/impl/smartPointers/SmartTypePointerManagerImpl.java index 175b3a143b4a..5d86dc4ec0a0 100644 --- a/java/java-impl/src/com/intellij/psi/impl/smartPointers/SmartTypePointerManagerImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/smartPointers/SmartTypePointerManagerImpl.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. @@ -42,6 +42,11 @@ import java.util.Set; public class SmartTypePointerManagerImpl extends SmartTypePointerManager { private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.smartPointers.SmartTypePointerManagerImpl"); + private static final SmartTypePointer NULL_POINTER = new SmartTypePointer() { + @Override + public PsiType getType() { return null; } + }; + private final SmartPointerManager myPsiPointerManager; private final Project myProject; @@ -53,7 +58,8 @@ public class SmartTypePointerManagerImpl extends SmartTypePointerManager { @Override @NotNull public SmartTypePointer createSmartTypePointer(@NotNull PsiType type) { - return type.accept(new SmartTypeCreatingVisitor()); + final SmartTypePointer pointer = type.accept(new SmartTypeCreatingVisitor()); + return pointer != null ? pointer : NULL_POINTER; } private static class SimpleTypePointer implements SmartTypePointer { @@ -77,6 +83,7 @@ public class SmartTypePointerManagerImpl extends SmartTypePointerManager { myComponentTypePointer = componentTypePointer; } + @Nullable @Override protected PsiArrayType calcType() { final PsiType type = myComponentTypePointer.getType(); @@ -164,6 +171,7 @@ public class SmartTypePointerManagerImpl extends SmartTypePointerManager { return myType; } + @Nullable protected abstract T calcType(); } @@ -228,7 +236,8 @@ public class SmartTypePointerManagerImpl extends SmartTypePointerManager { @Override public SmartTypePointer visitArrayType(PsiArrayType arrayType) { - return new ArrayTypePointer(arrayType, arrayType.getComponentType().accept(this)); + final SmartTypePointer componentTypePointer = arrayType.getComponentType().accept(this); + return componentTypePointer != null ? new ArrayTypePointer(arrayType, componentTypePointer) : null; } @Override diff --git a/java/java-psi-api/src/com/intellij/psi/PsiType.java b/java/java-psi-api/src/com/intellij/psi/PsiType.java index 5ed21bd5fdd0..2c3af2dd9499 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiType.java @@ -174,6 +174,7 @@ public abstract class PsiType implements PsiAnnotationOwner { * @param visitor the visitor to accept the type. * @return the value returned by the visitor. */ + @Nullable public abstract A accept(@NotNull PsiTypeVisitor visitor); /** diff --git a/java/java-psi-api/src/com/intellij/psi/PsiTypeVisitor.java b/java/java-psi-api/src/com/intellij/psi/PsiTypeVisitor.java index bd2add5b490a..29b1bce17fb4 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiTypeVisitor.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiTypeVisitor.java @@ -15,44 +15,55 @@ */ package com.intellij.psi; +import org.jetbrains.annotations.Nullable; + /** * Visitor which can be used to visit Java types. * * @author dsl */ public class PsiTypeVisitor { + @Nullable public A visitType(PsiType type) { return null; } + @Nullable public A visitPrimitiveType(PsiPrimitiveType primitiveType) { return visitType(primitiveType); } + @Nullable public A visitArrayType(PsiArrayType arrayType) { return visitType(arrayType); } + @Nullable public A visitClassType(PsiClassType classType) { return visitType(classType); } + @Nullable public A visitCapturedWildcardType(PsiCapturedWildcardType capturedWildcardType) { return visitWildcardType(capturedWildcardType.getWildcard()); } + @Nullable public A visitWildcardType(PsiWildcardType wildcardType) { return visitType(wildcardType); } + @Nullable public A visitEllipsisType(PsiEllipsisType ellipsisType) { return visitArrayType(ellipsisType); } + @Nullable public A visitDisjunctionType(PsiDisjunctionType disjunctionType) { return visitType(disjunctionType); } - + + @Nullable public A visitDiamondType(PsiDiamondType diamondType) { return visitType(diamondType); } diff --git a/java/java-psi-impl/src/com/intellij/psi/Bottom.java b/java/java-psi-impl/src/com/intellij/psi/Bottom.java index 4b640f1b3b92..942d7792d80e 100644 --- a/java/java-psi-impl/src/com/intellij/psi/Bottom.java +++ b/java/java-psi-impl/src/com/intellij/psi/Bottom.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. @@ -66,7 +66,9 @@ public class Bottom extends PsiType { if (visitor instanceof PsiTypeVisitorEx) { return ((PsiTypeVisitorEx)visitor).visitBottom(this); } - return visitor.visitType(this); + else { + return visitor.visitType(this); + } } @Override diff --git a/java/java-psi-impl/src/com/intellij/psi/PsiTypeVariable.java b/java/java-psi-impl/src/com/intellij/psi/PsiTypeVariable.java index 8625b26292a0..872c8ded71ea 100644 --- a/java/java-psi-impl/src/com/intellij/psi/PsiTypeVariable.java +++ b/java/java-psi-impl/src/com/intellij/psi/PsiTypeVariable.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. @@ -33,7 +33,8 @@ public abstract class PsiTypeVariable extends PsiType { if (visitor instanceof PsiTypeVisitorEx) { return ((PsiTypeVisitorEx)visitor).visitTypeVariable(this); } - - return visitor.visitType(this); + else { + return visitor.visitType(this); + } } } diff --git a/java/java-psi-impl/src/com/intellij/psi/PsiTypeVisitorEx.java b/java/java-psi-impl/src/com/intellij/psi/PsiTypeVisitorEx.java index eb31de2bcbc8..47eac032290e 100644 --- a/java/java-psi-impl/src/com/intellij/psi/PsiTypeVisitorEx.java +++ b/java/java-psi-impl/src/com/intellij/psi/PsiTypeVisitorEx.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. @@ -15,14 +15,18 @@ */ package com.intellij.psi; +import org.jetbrains.annotations.Nullable; + /** * @author ven */ public class PsiTypeVisitorEx extends PsiTypeVisitor { + @Nullable public A visitTypeVariable(PsiTypeVariable var) { return visitType(var); } + @Nullable public A visitBottom (Bottom bottom) { return visitType(bottom); } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/LambdaExpressions.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/LambdaExpressions.java index 14ce1ba5cffd..129b60a46457 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/LambdaExpressions.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/LambdaExpressions.java @@ -37,4 +37,8 @@ class C { IntParser intParser = (String s) -> Integer.parseInt(s); ListProducer listProducer = () -> new ArrayList(); } + + Runnable foo() { + return () -> { System.out.println("foo"); }; + } } \ No newline at end of file From 1dcfe0ed7797d42302dfad7d039e866789582309 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Fri, 8 Jun 2012 21:19:52 +0400 Subject: [PATCH 029/172] Move toolwindow icons near each other --- .../ide/palette/impl/PaletteManager.java | 2 +- .../src/com/intellij/util/PlatformIcons.java | 1 - platform/icons/src/ant/allJarsInDir.png | Bin 630 -> 0 bytes .../documentation.png | Bin .../toolWindowAnt.png | Bin .../toolWindowChanges.png | Bin .../toolWindowCommander.png | Bin .../toolWindowCoverage.png | Bin .../toolWindowCvs.png | Bin .../toolWindowDebugger.png | Bin .../toolWindowFavorites.png | Bin .../toolWindowFind.png | Bin .../toolWindowHierarchy.png | Bin .../toolWindowInspection.png | Bin .../toolWindowMessages.png | Bin .../toolWindowModuleDependencies.png | Bin .../toolWindowPalette.png | Bin .../toolWindowProject.png | Bin .../toolWindowRun.png | Bin .../toolWindowStructure.png | Bin .../toolWindowTodo.png | Bin .../{general => toolwindows}/vcsSmallTab.png | Bin .../{javaee => toolwindows}/webToolWindow.png | Bin .../executors/DefaultRunExecutor.java | 2 +- .../documentation/DockablePopupManager.java | 2 +- .../ex/InspectionManagerEx.java | 2 +- .../codeInspection/ui/InspectionNode.java | 2 +- .../find/actions/ShowUsagesAction.java | 2 +- .../favoritesTreeView/FavoritesListNode.java | 2 +- .../FavoritesProjectViewPane.java | 2 +- .../hierarchy/HierarchyBrowserManager.java | 2 +- .../DependenciesAnalyzeManager.java | 2 +- .../ModulesDependenciesPanel.java | 2 +- .../DependenciesToolWindow.java | 2 +- .../usageView/impl/UsageViewManagerImpl.java | 2 +- .../ide/actions/ToolWindowsGroup.java | 26 +- .../application/impl/ApplicationInfoImpl.java | 2 +- .../ui/content/impl/MessageViewImpl.java | 2 +- .../src/META-INF/LangExtensions.xml | 8 +- .../src/idea/LangActions.xml | 2 +- .../util/src/com/intellij/icons/AllIcons.java | 1806 +++++++++-------- .../changes/ui/ChangesViewContentManager.java | 2 +- .../vcs/impl/ProjectLevelVcsManagerImpl.java | 4 +- .../executors/DefaultDebugExecutor.java | 2 +- plugins/ant/src/META-INF/plugin.xml | 2 +- .../ant/config/impl/AllJarsUnderDirEntry.java | 7 +- .../ant/config/impl/AntClasspathEntry.java | 2 - .../lang/ant/config/impl/SinglePathEntry.java | 4 - plugins/commander/src/META-INF/plugin.xml | 2 +- 49 files changed, 944 insertions(+), 954 deletions(-) delete mode 100644 platform/icons/src/ant/allJarsInDir.png rename platform/icons/src/{general => toolwindows}/documentation.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowAnt.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowChanges.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowCommander.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowCoverage.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowCvs.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowDebugger.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowFavorites.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowFind.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowHierarchy.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowInspection.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowMessages.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowModuleDependencies.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowPalette.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowProject.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowRun.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowStructure.png (100%) rename platform/icons/src/{general => toolwindows}/toolWindowTodo.png (100%) rename platform/icons/src/{general => toolwindows}/vcsSmallTab.png (100%) rename platform/icons/src/{javaee => toolwindows}/webToolWindow.png (100%) diff --git a/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteManager.java b/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteManager.java index b3c8af6564d8..5aa1bf611e7a 100644 --- a/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteManager.java +++ b/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteManager.java @@ -71,7 +71,7 @@ public class PaletteManager implements ProjectComponent { ToolWindowAnchor.RIGHT, myProject, true); - myPaletteToolWindow.setIcon(AllIcons.General.ToolWindowPalette); + myPaletteToolWindow.setIcon(AllIcons.Toolwindows.ToolWindowPalette); setContent(); final MyFileEditorManagerListener myListener = new MyFileEditorManagerListener(); myFileEditorManager.addFileEditorManagerListener(myListener, myProject); diff --git a/platform/core-api/src/com/intellij/util/PlatformIcons.java b/platform/core-api/src/com/intellij/util/PlatformIcons.java index 1fcb335de91e..2974eeee030b 100644 --- a/platform/core-api/src/com/intellij/util/PlatformIcons.java +++ b/platform/core-api/src/com/intellij/util/PlatformIcons.java @@ -72,7 +72,6 @@ public interface PlatformIcons { Icon UI_FORM_ICON = AllIcons.FileTypes.UiForm; Icon JSP_ICON = AllIcons.FileTypes.Jsp; Icon SMALL_VCS_CONFIGURABLE = AllIcons.General.SmallConfigurableVcs; - Icon VCS_SMALL_TAB = AllIcons.General.VcsSmallTab; Icon GROUP_BY_PACKAGES = AllIcons.Toolbar.Folders; Icon ADD_ICON = IconUtil.getAddIcon(); Icon DELETE_ICON = IconUtil.getRemoveIcon(); diff --git a/platform/icons/src/ant/allJarsInDir.png b/platform/icons/src/ant/allJarsInDir.png deleted file mode 100644 index 5f61672cb487214a9b234a0109b77d9ed528e533..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 630 zcmV-+0*U>JP)$er-cvV_1G|LY#Xmg?3Plctq{C9{A*d|MRZ-=Y^brAOHRF z|N8Cz@1FhYm7j<)|Ni;;;FbB^iul}tpo=*8*mwKdbE1tf|Ni>_B1}j^~C@6zWCHs_0vuN_Q(F>Y5(-O{_vlkhcKIjD4T#H zn|~kw^}ULCG5`DO``K;!(^~q_Qvdqs|N7?t`s4rk+W+{|`QxJbB+3t7`G@glhz3(z-uP4h`#X@ zE)FIx;8UH@f%z#k7tjTw0c?bk@7X+Gp6b8S8rTcoo4stEMI2gP6?SqGuv QT>t<807*qoM6N<$f}&StK>z>% diff --git a/platform/icons/src/general/documentation.png b/platform/icons/src/toolwindows/documentation.png similarity index 100% rename from platform/icons/src/general/documentation.png rename to platform/icons/src/toolwindows/documentation.png diff --git a/platform/icons/src/general/toolWindowAnt.png b/platform/icons/src/toolwindows/toolWindowAnt.png similarity index 100% rename from platform/icons/src/general/toolWindowAnt.png rename to platform/icons/src/toolwindows/toolWindowAnt.png diff --git a/platform/icons/src/general/toolWindowChanges.png b/platform/icons/src/toolwindows/toolWindowChanges.png similarity index 100% rename from platform/icons/src/general/toolWindowChanges.png rename to platform/icons/src/toolwindows/toolWindowChanges.png diff --git a/platform/icons/src/general/toolWindowCommander.png b/platform/icons/src/toolwindows/toolWindowCommander.png similarity index 100% rename from platform/icons/src/general/toolWindowCommander.png rename to platform/icons/src/toolwindows/toolWindowCommander.png diff --git a/platform/icons/src/general/toolWindowCoverage.png b/platform/icons/src/toolwindows/toolWindowCoverage.png similarity index 100% rename from platform/icons/src/general/toolWindowCoverage.png rename to platform/icons/src/toolwindows/toolWindowCoverage.png diff --git a/platform/icons/src/general/toolWindowCvs.png b/platform/icons/src/toolwindows/toolWindowCvs.png similarity index 100% rename from platform/icons/src/general/toolWindowCvs.png rename to platform/icons/src/toolwindows/toolWindowCvs.png diff --git a/platform/icons/src/general/toolWindowDebugger.png b/platform/icons/src/toolwindows/toolWindowDebugger.png similarity index 100% rename from platform/icons/src/general/toolWindowDebugger.png rename to platform/icons/src/toolwindows/toolWindowDebugger.png diff --git a/platform/icons/src/general/toolWindowFavorites.png b/platform/icons/src/toolwindows/toolWindowFavorites.png similarity index 100% rename from platform/icons/src/general/toolWindowFavorites.png rename to platform/icons/src/toolwindows/toolWindowFavorites.png diff --git a/platform/icons/src/general/toolWindowFind.png b/platform/icons/src/toolwindows/toolWindowFind.png similarity index 100% rename from platform/icons/src/general/toolWindowFind.png rename to platform/icons/src/toolwindows/toolWindowFind.png diff --git a/platform/icons/src/general/toolWindowHierarchy.png b/platform/icons/src/toolwindows/toolWindowHierarchy.png similarity index 100% rename from platform/icons/src/general/toolWindowHierarchy.png rename to platform/icons/src/toolwindows/toolWindowHierarchy.png diff --git a/platform/icons/src/general/toolWindowInspection.png b/platform/icons/src/toolwindows/toolWindowInspection.png similarity index 100% rename from platform/icons/src/general/toolWindowInspection.png rename to platform/icons/src/toolwindows/toolWindowInspection.png diff --git a/platform/icons/src/general/toolWindowMessages.png b/platform/icons/src/toolwindows/toolWindowMessages.png similarity index 100% rename from platform/icons/src/general/toolWindowMessages.png rename to platform/icons/src/toolwindows/toolWindowMessages.png diff --git a/platform/icons/src/general/toolWindowModuleDependencies.png b/platform/icons/src/toolwindows/toolWindowModuleDependencies.png similarity index 100% rename from platform/icons/src/general/toolWindowModuleDependencies.png rename to platform/icons/src/toolwindows/toolWindowModuleDependencies.png diff --git a/platform/icons/src/general/toolWindowPalette.png b/platform/icons/src/toolwindows/toolWindowPalette.png similarity index 100% rename from platform/icons/src/general/toolWindowPalette.png rename to platform/icons/src/toolwindows/toolWindowPalette.png diff --git a/platform/icons/src/general/toolWindowProject.png b/platform/icons/src/toolwindows/toolWindowProject.png similarity index 100% rename from platform/icons/src/general/toolWindowProject.png rename to platform/icons/src/toolwindows/toolWindowProject.png diff --git a/platform/icons/src/general/toolWindowRun.png b/platform/icons/src/toolwindows/toolWindowRun.png similarity index 100% rename from platform/icons/src/general/toolWindowRun.png rename to platform/icons/src/toolwindows/toolWindowRun.png diff --git a/platform/icons/src/general/toolWindowStructure.png b/platform/icons/src/toolwindows/toolWindowStructure.png similarity index 100% rename from platform/icons/src/general/toolWindowStructure.png rename to platform/icons/src/toolwindows/toolWindowStructure.png diff --git a/platform/icons/src/general/toolWindowTodo.png b/platform/icons/src/toolwindows/toolWindowTodo.png similarity index 100% rename from platform/icons/src/general/toolWindowTodo.png rename to platform/icons/src/toolwindows/toolWindowTodo.png diff --git a/platform/icons/src/general/vcsSmallTab.png b/platform/icons/src/toolwindows/vcsSmallTab.png similarity index 100% rename from platform/icons/src/general/vcsSmallTab.png rename to platform/icons/src/toolwindows/vcsSmallTab.png diff --git a/platform/icons/src/javaee/webToolWindow.png b/platform/icons/src/toolwindows/webToolWindow.png similarity index 100% rename from platform/icons/src/javaee/webToolWindow.png rename to platform/icons/src/toolwindows/webToolWindow.png diff --git a/platform/lang-api/src/com/intellij/execution/executors/DefaultRunExecutor.java b/platform/lang-api/src/com/intellij/execution/executors/DefaultRunExecutor.java index 8ba013dc13f0..78d829f05048 100644 --- a/platform/lang-api/src/com/intellij/execution/executors/DefaultRunExecutor.java +++ b/platform/lang-api/src/com/intellij/execution/executors/DefaultRunExecutor.java @@ -34,7 +34,7 @@ public class DefaultRunExecutor extends Executor { @NonNls public static final String EXECUTOR_ID = ToolWindowId.RUN; private static final Icon ICON = AllIcons.Actions.Execute; - private static final Icon TOOLWINDOW_ICON = AllIcons.General.ToolWindowRun; + private static final Icon TOOLWINDOW_ICON = AllIcons.Toolwindows.ToolWindowRun; private static final Icon DISABLED_ICON = AllIcons.Process.DisabledRun; @NotNull diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DockablePopupManager.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DockablePopupManager.java index 066fffe385d1..27c439543dee 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DockablePopupManager.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DockablePopupManager.java @@ -83,7 +83,7 @@ public abstract class DockablePopupManager { myToolWindow = toolWindow == null ? toolWindowManagerEx.registerToolWindow(getToolwindowId(), true, ToolWindowAnchor.RIGHT, myProject) : toolWindow; - myToolWindow.setIcon(AllIcons.General.Documentation); + myToolWindow.setIcon(AllIcons.Toolwindows.Documentation); myToolWindow.setAvailable(true, null); myToolWindow.setToHideOnEmptyContent(false); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java index 093045ec662f..8346f8939ce6 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java @@ -68,7 +68,7 @@ public class InspectionManagerEx extends InspectionManager { ToolWindow toolWindow = toolWindowManager.registerToolWindow(ToolWindowId.INSPECTION, true, ToolWindowAnchor.BOTTOM, myProject); ContentManager contentManager = toolWindow.getContentManager(); - toolWindow.setIcon(AllIcons.General.ToolWindowInspection); + toolWindow.setIcon(AllIcons.Toolwindows.ToolWindowInspection); new ContentManagerWatcher(toolWindow, contentManager); return contentManager; } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNode.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNode.java index f3bdab06ee0c..14d04e1691a7 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNode.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNode.java @@ -31,7 +31,7 @@ public class InspectionNode extends InspectionTreeNode { public static final Icon TOOL; static { - TOOL = LayeredIcon.create(AllIcons.General.ToolWindowInspection, IconUtil.getEmptyIcon(false)); + TOOL = LayeredIcon.create(AllIcons.Toolwindows.ToolWindowInspection, IconUtil.getEmptyIcon(false)); } public InspectionNode(InspectionTool tool) { diff --git a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java index 4dffeb5f5e5e..f522efea13fc 100644 --- a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java +++ b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java @@ -501,7 +501,7 @@ public class ShowUsagesAction extends AnAction implements PopupAction { usageView.addFilteringActions(toolbar); toolbar.add(UsageGroupingRuleProviderImpl.createGroupByFileStructureAction(usageView)); - toolbar.add(new AnAction("Open Find Usages Toolwindow", "Show all usages in a separate toolwindow", AllIcons.General.ToolWindowFind) { + toolbar.add(new AnAction("Open Find Usages Toolwindow", "Show all usages in a separate toolwindow", AllIcons.Toolwindows.ToolWindowFind) { { AnAction action = ActionManager.getInstance().getAction(IdeActions.ACTION_FIND_USAGES); setShortcutSet(action.getShortcutSet()); diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesListNode.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesListNode.java index ea14a7a7d644..a667fcc1a413 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesListNode.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesListNode.java @@ -50,7 +50,7 @@ public class FavoritesListNode extends AbstractTreeNode { @Override protected void update(PresentationData presentation) { - presentation.setIcons(AllIcons.General.ToolWindowFavorites); + presentation.setIcons(AllIcons.Toolwindows.ToolWindowFavorites); presentation.setPresentableText(myListName); } diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesProjectViewPane.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesProjectViewPane.java index d8e95c715fcd..3965f1a6cc87 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesProjectViewPane.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesProjectViewPane.java @@ -83,7 +83,7 @@ public class FavoritesProjectViewPane extends AbstractProjectViewPane { } public Icon getIcon() { - return AllIcons.General.ToolWindowFavorites; + return AllIcons.Toolwindows.ToolWindowFavorites; } @NotNull diff --git a/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserManager.java b/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserManager.java index b6e24d3aa25b..f690b338d76b 100644 --- a/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserManager.java +++ b/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserManager.java @@ -49,7 +49,7 @@ public final class HierarchyBrowserManager implements PersistentStateComponent(); ourId2Text.put(ToolWindowId.COMMANDER, new MyDescriptor(IdeBundle.message("action.toolwindow.commander"), - AllIcons.General.ToolWindowCommander)); + AllIcons.Toolwindows.ToolWindowCommander)); ourId2Text.put(ToolWindowId.MESSAGES_WINDOW, new MyDescriptor(IdeBundle.message("action.toolwindow.messages"), - AllIcons.General.ToolWindowMessages)); + AllIcons.Toolwindows.ToolWindowMessages)); ourId2Text.put(ToolWindowId.PROJECT_VIEW, new MyDescriptor(IdeBundle.message("action.toolwindow.project"), - AllIcons.General.ToolWindowProject)); + AllIcons.Toolwindows.ToolWindowProject)); ourId2Text.put(ToolWindowId.STRUCTURE_VIEW, new MyDescriptor(IdeBundle.message("action.toolwindow.structure"), - AllIcons.General.ToolWindowStructure)); + AllIcons.Toolwindows.ToolWindowStructure)); ourId2Text.put(ToolWindowId.ANT_BUILD, new MyDescriptor(IdeBundle.message("action.toolwindow.ant.build"), - AllIcons.General.ToolWindowAnt)); - ourId2Text.put(ToolWindowId.DEBUG, new MyDescriptor(IdeBundle.message("action.toolwindow.debug"), AllIcons.General.ToolWindowDebugger)); - ourId2Text.put(ToolWindowId.RUN, new MyDescriptor(IdeBundle.message("action.toolwindow.run"), AllIcons.General.ToolWindowRun)); - ourId2Text.put(ToolWindowId.FIND, new MyDescriptor(IdeBundle.message("action.toolwindow.find"), AllIcons.General.ToolWindowFind)); - ourId2Text.put(ToolWindowId.CVS, new MyDescriptor(IdeBundle.message("action.toolwindow.cvs"), AllIcons.General.ToolWindowCvs)); + AllIcons.Toolwindows.ToolWindowAnt)); + ourId2Text.put(ToolWindowId.DEBUG, new MyDescriptor(IdeBundle.message("action.toolwindow.debug"), AllIcons.Toolwindows.ToolWindowDebugger)); + ourId2Text.put(ToolWindowId.RUN, new MyDescriptor(IdeBundle.message("action.toolwindow.run"), AllIcons.Toolwindows.ToolWindowRun)); + ourId2Text.put(ToolWindowId.FIND, new MyDescriptor(IdeBundle.message("action.toolwindow.find"), AllIcons.Toolwindows.ToolWindowFind)); + ourId2Text.put(ToolWindowId.CVS, new MyDescriptor(IdeBundle.message("action.toolwindow.cvs"), AllIcons.Toolwindows.ToolWindowCvs)); ourId2Text.put(ToolWindowId.HIERARCHY, new MyDescriptor(IdeBundle.message("action.toolwindow.hierarchy"), - AllIcons.General.ToolWindowHierarchy)); - ourId2Text.put(ToolWindowId.TODO_VIEW, new MyDescriptor(IdeBundle.message("action.toolwindow.todo"), AllIcons.General.ToolWindowTodo)); + AllIcons.Toolwindows.ToolWindowHierarchy)); + ourId2Text.put(ToolWindowId.TODO_VIEW, new MyDescriptor(IdeBundle.message("action.toolwindow.todo"), AllIcons.Toolwindows.ToolWindowTodo)); ourId2Text.put(ToolWindowId.INSPECTION, new MyDescriptor(IdeBundle.message("action.toolwindow.inspection"), - AllIcons.General.ToolWindowInspection)); + AllIcons.Toolwindows.ToolWindowInspection)); ourId2Text.put(ToolWindowId.FAVORITES_VIEW, new MyDescriptor(IdeBundle.message("action.toolwindow.favorites"), - AllIcons.General.ToolWindowFavorites)); + AllIcons.Toolwindows.ToolWindowFavorites)); } private final ArrayList myChildren; diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationInfoImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationInfoImpl.java index 45e932f8399f..e8d503e2f35d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationInfoImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationInfoImpl.java @@ -55,7 +55,7 @@ public class ApplicationInfoImpl extends ApplicationInfoEx implements JDOMExtern @NonNls private String myIconUrl = "/icon.png"; @NonNls private String mySmallIconUrl = "/icon_small.png"; @NonNls private String myOpaqueIconUrl = "/icon.png"; - @NonNls private String myToolWindowIconUrl = "/general/toolWindowProject.png"; + @NonNls private String myToolWindowIconUrl = "/toolwindows/toolWindowProject.png"; private Calendar myBuildDate = null; private Calendar myMajorReleaseBuildDate = null; private String myPackageCode = null; diff --git a/platform/platform-impl/src/com/intellij/ui/content/impl/MessageViewImpl.java b/platform/platform-impl/src/com/intellij/ui/content/impl/MessageViewImpl.java index 599460ff26ff..c5f46efcff4f 100644 --- a/platform/platform-impl/src/com/intellij/ui/content/impl/MessageViewImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/content/impl/MessageViewImpl.java @@ -41,7 +41,7 @@ public class MessageViewImpl implements MessageView { final Runnable runnable = new Runnable() { public void run() { myToolWindow = toolWindowManager.registerToolWindow(ToolWindowId.MESSAGES_WINDOW, true, ToolWindowAnchor.BOTTOM, project, true); - myToolWindow.setIcon(AllIcons.General.ToolWindowMessages); + myToolWindow.setIcon(AllIcons.Toolwindows.ToolWindowMessages); new ContentManagerWatcher(myToolWindow, getContentManager()); for (Runnable postponedRunnable : myPostponedRunnables) { postponedRunnable.run(); diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index 34444adf12f5..0061d237eaf9 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -669,13 +669,13 @@ - - - - diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml index f40439bc8f26..900de7e35567 100644 --- a/platform/platform-resources/src/idea/LangActions.xml +++ b/platform/platform-resources/src/idea/LangActions.xml @@ -8,7 +8,7 @@ - + diff --git a/platform/util/src/com/intellij/icons/AllIcons.java b/platform/util/src/com/intellij/icons/AllIcons.java index ff4d51d7d0b2..41e77f38dad4 100644 --- a/platform/util/src/com/intellij/icons/AllIcons.java +++ b/platform/util/src/com/intellij/icons/AllIcons.java @@ -1,524 +1,503 @@ package com.intellij.icons; -import com.intellij.openapi.util.IconLoader; - import javax.swing.*; +import com.intellij.openapi.util.IconLoader; public class AllIcons { public static class Actions { - public static final Icon AddFacesSupport = IconLoader.getIcon("/actions/addFacesSupport.png"); - public static final Icon Annotate = IconLoader.getIcon("/actions/annotate.png"); - public static final Icon Back = IconLoader.getIcon("/actions/back.png"); - public static final Icon Browser_externalJavaDoc = IconLoader.getIcon("/actions/browser-externalJavaDoc.png"); - public static final Icon Cancel = IconLoader.getIcon("/actions/cancel.png"); - public static final Icon Checked = IconLoader.getIcon("/actions/checked.png"); - public static final Icon Checked_selected = IconLoader.getIcon("/actions/checked_selected.png"); - public static final Icon Checked_small = IconLoader.getIcon("/actions/checked_small.png"); - public static final Icon Checked_small_selected = IconLoader.getIcon("/actions/checked_small_selected.png"); - public static final Icon CheckOut = IconLoader.getIcon("/actions/checkOut.png"); - public static final Icon Clean = IconLoader.getIcon("/actions/clean.png"); - public static final Icon CleanLight = IconLoader.getIcon("/actions/cleanLight.png"); - public static final Icon Close = IconLoader.getIcon("/actions/close.png"); - public static final Icon CloseHovered = IconLoader.getIcon("/actions/closeHovered.png"); - public static final Icon CloseNew = IconLoader.getIcon("/actions/closeNew.png"); - public static final Icon CloseNewHovered = IconLoader.getIcon("/actions/closeNewHovered.png"); - public static final Icon Collapseall = IconLoader.getIcon("/actions/collapseall.png"); - public static final Icon Commit = IconLoader.getIcon("/actions/commit.png"); - public static final Icon Compile = IconLoader.getIcon("/actions/compile.png"); - public static final Icon ConsoleHistory = IconLoader.getIcon("/actions/consoleHistory.png"); - public static final Icon Copy = IconLoader.getIcon("/actions/copy.png"); - public static final Icon CreateFromUsage = IconLoader.getIcon("/actions/createFromUsage.png"); - public static final Icon CreatePatch = IconLoader.getIcon("/actions/createPatch.png"); - public static final Icon Cross = IconLoader.getIcon("/actions/cross.png"); - public static final Icon Delete = IconLoader.getIcon("/actions/delete.png"); - public static final Icon Diff = IconLoader.getIcon("/actions/diff.png"); - public static final Icon DiffWithCurrent = IconLoader.getIcon("/actions/diffWithCurrent.png"); - public static final Icon Dump = IconLoader.getIcon("/actions/dump.png"); - public static final Icon Edit = IconLoader.getIcon("/actions/edit.png"); - public static final Icon EditSource = IconLoader.getIcon("/actions/editSource.png"); - public static final Icon ErDiagram = IconLoader.getIcon("/actions/erDiagram.png"); - public static final Icon Exclude = IconLoader.getIcon("/actions/exclude.png"); - public static final Icon Execute = IconLoader.getIcon("/actions/execute.png"); - public static final Icon Exit = IconLoader.getIcon("/actions/exit.png"); - public static final Icon Expandall = IconLoader.getIcon("/actions/expandall.png"); - public static final Icon Export = IconLoader.getIcon("/actions/export.png"); - public static final Icon FileStatus = IconLoader.getIcon("/actions/fileStatus.png"); - public static final Icon Filter_small = IconLoader.getIcon("/actions/filter_small.png"); - public static final Icon Find = IconLoader.getIcon("/actions/find.png"); - public static final Icon Forward = IconLoader.getIcon("/actions/forward.png"); - public static final Icon GC = IconLoader.getIcon("/actions/gc.png"); - public static final Icon Get = IconLoader.getIcon("/actions/get.png"); - public static final Icon GroupByMethod = IconLoader.getIcon("/actions/groupByMethod.png"); - public static final Icon Help = IconLoader.getIcon("/actions/help.png"); - public static final Icon Install = IconLoader.getIcon("/actions/install.png"); - public static final Icon IntentionBulb = IconLoader.getIcon("/actions/intentionBulb.png"); - public static final Icon Lightning = IconLoader.getIcon("/actions/lightning.png"); - public static final Icon Menu_cut = IconLoader.getIcon("/actions/menu-cut.png"); - public static final Icon Menu_find = IconLoader.getIcon("/actions/menu-find.png"); - public static final Icon Menu_help = IconLoader.getIcon("/actions/menu-help.png"); - public static final Icon Menu_open = IconLoader.getIcon("/actions/menu-open.png"); - public static final Icon Menu_paste = IconLoader.getIcon("/actions/menu-paste.png"); - public static final Icon Menu_replace = IconLoader.getIcon("/actions/menu-replace.png"); - public static final Icon Menu_saveall = IconLoader.getIcon("/actions/menu-saveall.png"); - public static final Icon Minimize = IconLoader.getIcon("/actions/minimize.png"); - public static final Icon Module = IconLoader.getIcon("/actions/module.png"); - public static final Icon Move_to_button_top = IconLoader.getIcon("/actions/move-to-button-top.png"); - public static final Icon Move_to_button = IconLoader.getIcon("/actions/move-to-button.png"); - public static final Icon MoveDown = IconLoader.getIcon("/actions/moveDown.png"); - public static final Icon MoveUp = IconLoader.getIcon("/actions/moveUp.png"); - public static final Icon New = IconLoader.getIcon("/actions/new.png"); - public static final Icon NewFolder = IconLoader.getIcon("/actions/newFolder.png"); - public static final Icon Nextfile = IconLoader.getIcon("/actions/nextfile.png"); - public static final Icon NextOccurence = IconLoader.getIcon("/actions/nextOccurence.png"); - public static final Icon Pause = IconLoader.getIcon("/actions/pause.png"); - public static final Icon PopFrame = IconLoader.getIcon("/actions/popFrame.png"); - public static final Icon Prevfile = IconLoader.getIcon("/actions/prevfile.png"); - public static final Icon Preview = IconLoader.getIcon("/actions/preview.png"); - public static final Icon PreviousOccurence = IconLoader.getIcon("/actions/previousOccurence.png"); - public static final Icon ProfileCPU = IconLoader.getIcon("/actions/profileCPU.png"); - public static final Icon ProfileMemory = IconLoader.getIcon("/actions/profileMemory.png"); - public static final Icon Properties = IconLoader.getIcon("/actions/properties.png"); - public static final Icon QuickfixBulb = IconLoader.getIcon("/actions/quickfixBulb.png"); - public static final Icon QuickfixOffBulb = IconLoader.getIcon("/actions/quickfixOffBulb.png"); - public static final Icon QuickList = IconLoader.getIcon("/actions/quickList.png"); - public static final Icon RealIntentionBulb = IconLoader.getIcon("/actions/realIntentionBulb.png"); - public static final Icon RealIntentionOffBulb = IconLoader.getIcon("/actions/realIntentionOffBulb.png"); - public static final Icon Redo = IconLoader.getIcon("/actions/redo.png"); - public static final Icon RefactoringBulb = IconLoader.getIcon("/actions/refactoringBulb.png"); - public static final Icon Refresh = IconLoader.getIcon("/actions/refresh.png"); - public static final Icon RefreshUsages = IconLoader.getIcon("/actions/refreshUsages.png"); - public static final Icon Replace = IconLoader.getIcon("/actions/replace.png"); - public static final Icon Reset_to_default = IconLoader.getIcon("/actions/reset-to-default.png"); - public static final Icon Reset = IconLoader.getIcon("/actions/reset.png"); - public static final Icon Restart = IconLoader.getIcon("/actions/restart.png"); - public static final Icon Resume = IconLoader.getIcon("/actions/resume.png"); - public static final Icon Rollback = IconLoader.getIcon("/actions/rollback.png"); - public static final Icon RunToCursor = IconLoader.getIcon("/actions/runToCursor.png"); - public static final Icon Search = IconLoader.getIcon("/actions/search.png"); - public static final Icon Selectall = IconLoader.getIcon("/actions/selectall.png"); - public static final Icon Share = IconLoader.getIcon("/actions/share.png"); - public static final Icon ShowAsTree = IconLoader.getIcon("/actions/showAsTree.png"); - public static final Icon ShowChangesOnly = IconLoader.getIcon("/actions/showChangesOnly.png"); - public static final Icon ShowHiddens = IconLoader.getIcon("/actions/showHiddens.png"); - public static final Icon ShowImportStatements = IconLoader.getIcon("/actions/showImportStatements.png"); - public static final Icon ShowReadAccess = IconLoader.getIcon("/actions/showReadAccess.png"); - public static final Icon ShowSettings = IconLoader.getIcon("/actions/showSettings.png"); - public static final Icon ShowSource = IconLoader.getIcon("/actions/showSource.png"); - public static final Icon ShowViewer = IconLoader.getIcon("/actions/showViewer.png"); - public static final Icon ShowWriteAccess = IconLoader.getIcon("/actions/showWriteAccess.png"); - public static final Icon SortAsc = IconLoader.getIcon("/actions/sortAsc.png"); - public static final Icon SortDesc = IconLoader.getIcon("/actions/sortDesc.png"); - public static final Icon SplitHorizontally = IconLoader.getIcon("/actions/splitHorizontally.png"); - public static final Icon SplitVertically = IconLoader.getIcon("/actions/splitVertically.png"); - public static final Icon StartDebugger = IconLoader.getIcon("/actions/startDebugger.png"); - public static final Icon StepOut = IconLoader.getIcon("/actions/stepOut.png"); - public static final Icon Submit1 = IconLoader.getIcon("/actions/submit1.png"); - public static final Icon Suspend = IconLoader.getIcon("/actions/suspend.png"); - public static final Icon SwapPanels = IconLoader.getIcon("/actions/swapPanels.png"); - public static final Icon Sync = IconLoader.getIcon("/actions/sync.png"); - public static final Icon SyncPanels = IconLoader.getIcon("/actions/syncPanels.png"); - public static final Icon ToggleSoftWrap = IconLoader.getIcon("/actions/toggleSoftWrap.png"); - public static final Icon TraceInto = IconLoader.getIcon("/actions/traceInto.png"); - public static final Icon TraceOver = IconLoader.getIcon("/actions/traceOver.png"); - public static final Icon Undo = IconLoader.getIcon("/actions/undo.png"); - public static final Icon Uninstall = IconLoader.getIcon("/actions/uninstall.png"); - public static final Icon Unselectall = IconLoader.getIcon("/actions/unselectall.png"); - public static final Icon Unshare = IconLoader.getIcon("/actions/unshare.png"); + public static final Icon AddFacesSupport = IconLoader.getIcon("/actions/addFacesSupport.png"); // 16x16 + public static final Icon Annotate = IconLoader.getIcon("/actions/annotate.png"); // 16x16 + public static final Icon Back = IconLoader.getIcon("/actions/back.png"); // 16x16 + public static final Icon Browser_externalJavaDoc = IconLoader.getIcon("/actions/browser-externalJavaDoc.png"); // 16x16 + public static final Icon Cancel = IconLoader.getIcon("/actions/cancel.png"); // 16x16 + public static final Icon Checked = IconLoader.getIcon("/actions/checked.png"); // 12x12 + public static final Icon Checked_selected = IconLoader.getIcon("/actions/checked_selected.png"); // 12x12 + public static final Icon Checked_small = IconLoader.getIcon("/actions/checked_small.png"); // 11x11 + public static final Icon Checked_small_selected = IconLoader.getIcon("/actions/checked_small_selected.png"); // 11x11 + public static final Icon CheckOut = IconLoader.getIcon("/actions/checkOut.png"); // 16x16 + public static final Icon Clean = IconLoader.getIcon("/actions/clean.png"); // 16x16 + public static final Icon CleanLight = IconLoader.getIcon("/actions/cleanLight.png"); // 16x16 + public static final Icon Close = IconLoader.getIcon("/actions/close.png"); // 16x16 + public static final Icon CloseHovered = IconLoader.getIcon("/actions/closeHovered.png"); // 16x16 + public static final Icon CloseNew = IconLoader.getIcon("/actions/closeNew.png"); // 16x16 + public static final Icon CloseNewHovered = IconLoader.getIcon("/actions/closeNewHovered.png"); // 16x16 + public static final Icon Collapseall = IconLoader.getIcon("/actions/collapseall.png"); // 16x16 + public static final Icon Commit = IconLoader.getIcon("/actions/commit.png"); // 16x16 + public static final Icon Compile = IconLoader.getIcon("/actions/compile.png"); // 16x16 + public static final Icon ConsoleHistory = IconLoader.getIcon("/actions/consoleHistory.png"); // 16x16 + public static final Icon Copy = IconLoader.getIcon("/actions/copy.png"); // 16x16 + public static final Icon CreateFromUsage = IconLoader.getIcon("/actions/createFromUsage.png"); // 16x16 + public static final Icon CreatePatch = IconLoader.getIcon("/actions/createPatch.png"); // 16x16 + public static final Icon Cross = IconLoader.getIcon("/actions/cross.png"); // 12x12 + public static final Icon Delete = IconLoader.getIcon("/actions/delete.png"); // 16x16 + public static final Icon Diff = IconLoader.getIcon("/actions/diff.png"); // 16x16 + public static final Icon DiffWithCurrent = IconLoader.getIcon("/actions/diffWithCurrent.png"); // 16x16 + public static final Icon Dump = IconLoader.getIcon("/actions/dump.png"); // 16x16 + public static final Icon Edit = IconLoader.getIcon("/actions/edit.png"); // 14x14 + public static final Icon EditSource = IconLoader.getIcon("/actions/editSource.png"); // 16x16 + public static final Icon ErDiagram = IconLoader.getIcon("/actions/erDiagram.png"); // 16x16 + public static final Icon Exclude = IconLoader.getIcon("/actions/exclude.png"); // 14x14 + public static final Icon Execute = IconLoader.getIcon("/actions/execute.png"); // 16x16 + public static final Icon Exit = IconLoader.getIcon("/actions/exit.png"); // 16x16 + public static final Icon Expandall = IconLoader.getIcon("/actions/expandall.png"); // 16x16 + public static final Icon Export = IconLoader.getIcon("/actions/export.png"); // 16x16 + public static final Icon FileStatus = IconLoader.getIcon("/actions/fileStatus.png"); // 16x16 + public static final Icon Filter_small = IconLoader.getIcon("/actions/filter_small.png"); // 16x16 + public static final Icon Find = IconLoader.getIcon("/actions/find.png"); // 16x16 + public static final Icon Forward = IconLoader.getIcon("/actions/forward.png"); // 16x16 + public static final Icon GC = IconLoader.getIcon("/actions/gc.png"); // 16x16 + public static final Icon Get = IconLoader.getIcon("/actions/get.png"); // 16x16 + public static final Icon GroupByMethod = IconLoader.getIcon("/actions/groupByMethod.png"); // 16x16 + public static final Icon Help = IconLoader.getIcon("/actions/help.png"); // 16x16 + public static final Icon Install = IconLoader.getIcon("/actions/install.png"); // 16x16 + public static final Icon IntentionBulb = IconLoader.getIcon("/actions/intentionBulb.png"); // 16x16 + public static final Icon Lightning = IconLoader.getIcon("/actions/lightning.png"); // 16x16 + public static final Icon Menu_cut = IconLoader.getIcon("/actions/menu-cut.png"); // 16x16 + public static final Icon Menu_find = IconLoader.getIcon("/actions/menu-find.png"); // 16x16 + public static final Icon Menu_help = IconLoader.getIcon("/actions/menu-help.png"); // 16x16 + public static final Icon Menu_open = IconLoader.getIcon("/actions/menu-open.png"); // 16x16 + public static final Icon Menu_paste = IconLoader.getIcon("/actions/menu-paste.png"); // 16x16 + public static final Icon Menu_replace = IconLoader.getIcon("/actions/menu-replace.png"); // 16x16 + public static final Icon Menu_saveall = IconLoader.getIcon("/actions/menu-saveall.png"); // 16x16 + public static final Icon Minimize = IconLoader.getIcon("/actions/minimize.png"); // 16x16 + public static final Icon Module = IconLoader.getIcon("/actions/module.png"); // 16x16 + public static final Icon Move_to_button_top = IconLoader.getIcon("/actions/move-to-button-top.png"); // 11x12 + public static final Icon Move_to_button = IconLoader.getIcon("/actions/move-to-button.png"); // 11x10 + public static final Icon MoveDown = IconLoader.getIcon("/actions/moveDown.png"); // 14x14 + public static final Icon MoveUp = IconLoader.getIcon("/actions/moveUp.png"); // 14x14 + public static final Icon New = IconLoader.getIcon("/actions/new.png"); // 16x16 + public static final Icon NewFolder = IconLoader.getIcon("/actions/newFolder.png"); // 16x16 + public static final Icon Nextfile = IconLoader.getIcon("/actions/nextfile.png"); // 16x16 + public static final Icon NextOccurence = IconLoader.getIcon("/actions/nextOccurence.png"); // 16x16 + public static final Icon Pause = IconLoader.getIcon("/actions/pause.png"); // 16x16 + public static final Icon PopFrame = IconLoader.getIcon("/actions/popFrame.png"); // 16x16 + public static final Icon Prevfile = IconLoader.getIcon("/actions/prevfile.png"); // 16x16 + public static final Icon Preview = IconLoader.getIcon("/actions/preview.png"); // 16x16 + public static final Icon PreviousOccurence = IconLoader.getIcon("/actions/previousOccurence.png"); // 16x16 + public static final Icon ProfileCPU = IconLoader.getIcon("/actions/profileCPU.png"); // 16x16 + public static final Icon ProfileMemory = IconLoader.getIcon("/actions/profileMemory.png"); // 16x16 + public static final Icon Properties = IconLoader.getIcon("/actions/properties.png"); // 16x16 + public static final Icon QuickfixBulb = IconLoader.getIcon("/actions/quickfixBulb.png"); // 16x16 + public static final Icon QuickfixOffBulb = IconLoader.getIcon("/actions/quickfixOffBulb.png"); // 16x16 + public static final Icon QuickList = IconLoader.getIcon("/actions/quickList.png"); // 16x16 + public static final Icon RealIntentionBulb = IconLoader.getIcon("/actions/realIntentionBulb.png"); // 16x16 + public static final Icon RealIntentionOffBulb = IconLoader.getIcon("/actions/realIntentionOffBulb.png"); // 16x16 + public static final Icon Redo = IconLoader.getIcon("/actions/redo.png"); // 16x16 + public static final Icon RefactoringBulb = IconLoader.getIcon("/actions/refactoringBulb.png"); // 16x16 + public static final Icon Refresh = IconLoader.getIcon("/actions/refresh.png"); // 16x16 + public static final Icon RefreshUsages = IconLoader.getIcon("/actions/refreshUsages.png"); // 16x16 + public static final Icon Replace = IconLoader.getIcon("/actions/replace.png"); // 16x16 + public static final Icon Reset_to_default = IconLoader.getIcon("/actions/reset-to-default.png"); // 16x16 + public static final Icon Reset = IconLoader.getIcon("/actions/reset.png"); // 16x16 + public static final Icon Restart = IconLoader.getIcon("/actions/restart.png"); // 16x16 + public static final Icon Resume = IconLoader.getIcon("/actions/resume.png"); // 16x16 + public static final Icon Rollback = IconLoader.getIcon("/actions/rollback.png"); // 16x16 + public static final Icon RunToCursor = IconLoader.getIcon("/actions/runToCursor.png"); // 16x16 + public static final Icon Search = IconLoader.getIcon("/actions/search.png"); // 16x16 + public static final Icon Selectall = IconLoader.getIcon("/actions/selectall.png"); // 16x16 + public static final Icon Share = IconLoader.getIcon("/actions/share.png"); // 14x14 + public static final Icon ShowAsTree = IconLoader.getIcon("/actions/showAsTree.png"); // 16x16 + public static final Icon ShowChangesOnly = IconLoader.getIcon("/actions/showChangesOnly.png"); // 16x16 + public static final Icon ShowHiddens = IconLoader.getIcon("/actions/showHiddens.png"); // 16x16 + public static final Icon ShowImportStatements = IconLoader.getIcon("/actions/showImportStatements.png"); // 16x16 + public static final Icon ShowReadAccess = IconLoader.getIcon("/actions/showReadAccess.png"); // 16x16 + public static final Icon ShowSettings = IconLoader.getIcon("/actions/showSettings.png"); // 16x16 + public static final Icon ShowSource = IconLoader.getIcon("/actions/showSource.png"); // 16x16 + public static final Icon ShowViewer = IconLoader.getIcon("/actions/showViewer.png"); // 16x16 + public static final Icon ShowWriteAccess = IconLoader.getIcon("/actions/showWriteAccess.png"); // 16x16 + public static final Icon SortAsc = IconLoader.getIcon("/actions/sortAsc.png"); // 9x8 + public static final Icon SortDesc = IconLoader.getIcon("/actions/sortDesc.png"); // 9x8 + public static final Icon SplitHorizontally = IconLoader.getIcon("/actions/splitHorizontally.png"); // 16x16 + public static final Icon SplitVertically = IconLoader.getIcon("/actions/splitVertically.png"); // 16x16 + public static final Icon StartDebugger = IconLoader.getIcon("/actions/startDebugger.png"); // 16x16 + public static final Icon StepOut = IconLoader.getIcon("/actions/stepOut.png"); // 16x16 + public static final Icon Submit1 = IconLoader.getIcon("/actions/submit1.png"); // 11x11 + public static final Icon Suspend = IconLoader.getIcon("/actions/suspend.png"); // 16x16 + public static final Icon SwapPanels = IconLoader.getIcon("/actions/swapPanels.png"); // 16x16 + public static final Icon Sync = IconLoader.getIcon("/actions/sync.png"); // 16x16 + public static final Icon SyncPanels = IconLoader.getIcon("/actions/syncPanels.png"); // 16x16 + public static final Icon ToggleSoftWrap = IconLoader.getIcon("/actions/toggleSoftWrap.png"); // 16x16 + public static final Icon TraceInto = IconLoader.getIcon("/actions/traceInto.png"); // 16x16 + public static final Icon TraceOver = IconLoader.getIcon("/actions/traceOver.png"); // 16x16 + public static final Icon Undo = IconLoader.getIcon("/actions/undo.png"); // 16x16 + public static final Icon Uninstall = IconLoader.getIcon("/actions/uninstall.png"); // 16x16 + public static final Icon Unselectall = IconLoader.getIcon("/actions/unselectall.png"); // 16x16 + public static final Icon Unshare = IconLoader.getIcon("/actions/unshare.png"); // 14x14 } public static class Ant { - public static final Icon AllJarsInDir = IconLoader.getIcon("/ant/allJarsInDir.png"); - public static final Icon AntInstallation = IconLoader.getIcon("/ant/antInstallation.png"); - public static final Icon Build = IconLoader.getIcon("/ant/build.png"); - public static final Icon ChangeView = IconLoader.getIcon("/ant/changeView.png"); - public static final Icon Filter = IconLoader.getIcon("/ant/filter.png"); - public static final Icon Message = IconLoader.getIcon("/ant/message.png"); - public static final Icon MetaTarget = IconLoader.getIcon("/ant/metaTarget.png"); - public static final Icon Properties = IconLoader.getIcon("/ant/properties.png"); - public static final Icon ShortcutFilter = IconLoader.getIcon("/ant/shortcutFilter.png"); - public static final Icon Target = IconLoader.getIcon("/ant/target.png"); - public static final Icon Task = IconLoader.getIcon("/ant/task.png"); - public static final Icon Verbose = IconLoader.getIcon("/ant/verbose.png"); + public static final Icon AntInstallation = IconLoader.getIcon("/ant/antInstallation.png"); // 16x16 + public static final Icon Build = IconLoader.getIcon("/ant/build.png"); // 16x16 + public static final Icon ChangeView = IconLoader.getIcon("/ant/changeView.png"); // 16x16 + public static final Icon Filter = IconLoader.getIcon("/ant/filter.png"); // 16x16 + public static final Icon Message = IconLoader.getIcon("/ant/message.png"); // 16x16 + public static final Icon MetaTarget = IconLoader.getIcon("/ant/metaTarget.png"); // 16x16 + public static final Icon Properties = IconLoader.getIcon("/ant/properties.png"); // 16x16 + public static final Icon ShortcutFilter = IconLoader.getIcon("/ant/shortcutFilter.png"); // 16x16 + public static final Icon Target = IconLoader.getIcon("/ant/target.png"); // 16x16 + public static final Icon Task = IconLoader.getIcon("/ant/task.png"); // 16x16 + public static final Icon Verbose = IconLoader.getIcon("/ant/verbose.png"); // 16x16 } public static class Compiler { - public static final Icon Error = IconLoader.getIcon("/compiler/error.png"); - public static final Icon HideWarnings = IconLoader.getIcon("/compiler/hideWarnings.png"); - public static final Icon Information = IconLoader.getIcon("/compiler/information.png"); - public static final Icon Warning = IconLoader.getIcon("/compiler/warning.png"); + public static final Icon Error = IconLoader.getIcon("/compiler/error.png"); // 16x16 + public static final Icon HideWarnings = IconLoader.getIcon("/compiler/hideWarnings.png"); // 16x16 + public static final Icon Information = IconLoader.getIcon("/compiler/information.png"); // 16x16 + public static final Icon Warning = IconLoader.getIcon("/compiler/warning.png"); // 16x16 } public static class Css { - public static final Icon Property = IconLoader.getIcon("/css/property.png"); - public static final Icon Pseudo_element = IconLoader.getIcon("/css/pseudo-element.png"); + public static final Icon Property = IconLoader.getIcon("/css/property.png"); // 16x16 + public static final Icon Pseudo_element = IconLoader.getIcon("/css/pseudo-element.png"); // 16x16 } public static class Debugger { public static class Actions { - public static final Icon Force_run_to_cursor = IconLoader.getIcon("/debugger/actions/force_run_to_cursor.png"); - public static final Icon Force_step_into = IconLoader.getIcon("/debugger/actions/force_step_into.png"); - public static final Icon Force_step_over = IconLoader.getIcon("/debugger/actions/force_step_over.png"); + public static final Icon Force_run_to_cursor = IconLoader.getIcon("/debugger/actions/force_run_to_cursor.png"); // 16x16 + public static final Icon Force_step_into = IconLoader.getIcon("/debugger/actions/force_step_into.png"); // 16x16 + public static final Icon Force_step_over = IconLoader.getIcon("/debugger/actions/force_step_over.png"); // 16x16 } - public static final Icon AddToWatch = IconLoader.getIcon("/debugger/addToWatch.png"); - public static final Icon AutoVariablesMode = IconLoader.getIcon("/debugger/autoVariablesMode.png"); - public static final Icon BreakpointAlert = IconLoader.getIcon("/debugger/breakpointAlert.png"); - public static final Icon Class_filter = IconLoader.getIcon("/debugger/class_filter.png"); - public static final Icon Console = IconLoader.getIcon("/debugger/console.png"); - public static final Icon Db_array = IconLoader.getIcon("/debugger/db_array.png"); - public static final Icon Db_dep_exception_breakpoint = IconLoader.getIcon("/debugger/db_dep_exception_breakpoint.png"); - public static final Icon Db_dep_field_breakpoint = IconLoader.getIcon("/debugger/db_dep_field_breakpoint.png"); - public static final Icon Db_dep_line_breakpoint = IconLoader.getIcon("/debugger/db_dep_line_breakpoint.png"); - public static final Icon Db_dep_method_breakpoint = IconLoader.getIcon("/debugger/db_dep_method_breakpoint.png"); - public static final Icon Db_disabled_breakpoint = IconLoader.getIcon("/debugger/db_disabled_breakpoint.png"); - public static final Icon Db_disabled_breakpoint_process = IconLoader.getIcon("/debugger/db_disabled_breakpoint_process.png"); - public static final Icon Db_disabled_exception_breakpoint = IconLoader.getIcon("/debugger/db_disabled_exception_breakpoint.png"); - public static final Icon Db_disabled_field_breakpoint = IconLoader.getIcon("/debugger/db_disabled_field_breakpoint.png"); - public static final Icon Db_disabled_method_breakpoint = IconLoader.getIcon("/debugger/db_disabled_method_breakpoint.png"); - public static final Icon Db_error = IconLoader.getIcon("/debugger/db_error.png"); - public static final Icon Db_exception_breakpoint = IconLoader.getIcon("/debugger/db_exception_breakpoint.png"); - public static final Icon Db_field_breakpoint = IconLoader.getIcon("/debugger/db_field_breakpoint.png"); - public static final Icon Db_field_warning_breakpoint = IconLoader.getIcon("/debugger/db_field_warning_breakpoint.png"); - public static final Icon Db_invalid_breakpoint = IconLoader.getIcon("/debugger/db_invalid_breakpoint.png"); - public static final Icon Db_invalid_field_breakpoint = IconLoader.getIcon("/debugger/db_invalid_field_breakpoint.png"); - public static final Icon Db_invalid_method_breakpoint = IconLoader.getIcon("/debugger/db_invalid_method_breakpoint.png"); - public static final Icon Db_method_breakpoint = IconLoader.getIcon("/debugger/db_method_breakpoint.png"); - public static final Icon Db_method_warning_breakpoint = IconLoader.getIcon("/debugger/db_method_warning_breakpoint.png"); - public static final Icon Db_muted_breakpoint = IconLoader.getIcon("/debugger/db_muted_breakpoint.png"); - public static final Icon Db_muted_dep_exception_breakpoint = IconLoader.getIcon("/debugger/db_muted_dep_exception_breakpoint.png"); - public static final Icon Db_muted_dep_field_breakpoint = IconLoader.getIcon("/debugger/db_muted_dep_field_breakpoint.png"); - public static final Icon Db_muted_dep_line_breakpoint = IconLoader.getIcon("/debugger/db_muted_dep_line_breakpoint.png"); - public static final Icon Db_muted_dep_method_breakpoint = IconLoader.getIcon("/debugger/db_muted_dep_method_breakpoint.png"); - public static final Icon Db_muted_disabled_breakpoint = IconLoader.getIcon("/debugger/db_muted_disabled_breakpoint.png"); - public static final Icon Db_muted_disabled_breakpoint_process = IconLoader.getIcon("/debugger/db_muted_disabled_breakpoint_process.png"); - public static final Icon Db_muted_disabled_exception_breakpoint = IconLoader.getIcon("/debugger/db_muted_disabled_exception_breakpoint.png"); - public static final Icon Db_muted_disabled_field_breakpoint = IconLoader.getIcon("/debugger/db_muted_disabled_field_breakpoint.png"); - public static final Icon Db_muted_disabled_method_breakpoint = IconLoader.getIcon("/debugger/db_muted_disabled_method_breakpoint.png"); - public static final Icon Db_muted_exception_breakpoint = IconLoader.getIcon("/debugger/db_muted_exception_breakpoint.png"); - public static final Icon Db_muted_field_breakpoint = IconLoader.getIcon("/debugger/db_muted_field_breakpoint.png"); - public static final Icon Db_muted_field_warning_breakpoint = IconLoader.getIcon("/debugger/db_muted_field_warning_breakpoint.png"); - public static final Icon Db_muted_invalid_breakpoint = IconLoader.getIcon("/debugger/db_muted_invalid_breakpoint.png"); - public static final Icon Db_muted_invalid_field_breakpoint = IconLoader.getIcon("/debugger/db_muted_invalid_field_breakpoint.png"); - public static final Icon Db_muted_invalid_method_breakpoint = IconLoader.getIcon("/debugger/db_muted_invalid_method_breakpoint.png"); - public static final Icon Db_muted_method_breakpoint = IconLoader.getIcon("/debugger/db_muted_method_breakpoint.png"); - public static final Icon Db_muted_method_warning_breakpoint = IconLoader.getIcon("/debugger/db_muted_method_warning_breakpoint.png"); - public static final Icon Db_muted_verified_breakpoint = IconLoader.getIcon("/debugger/db_muted_verified_breakpoint.png"); - public static final Icon Db_muted_verified_field_breakpoint = IconLoader.getIcon("/debugger/db_muted_verified_field_breakpoint.png"); - public static final Icon Db_muted_verified_method_breakpoint = IconLoader.getIcon("/debugger/db_muted_verified_method_breakpoint.png"); - public static final Icon Db_muted_verified_warning_breakpoint = IconLoader.getIcon("/debugger/db_muted_verified_warning_breakpoint.png"); - public static final Icon Db_obsolete = IconLoader.getIcon("/debugger/db_obsolete.png"); - public static final Icon Db_primitive = IconLoader.getIcon("/debugger/db_primitive.png"); - public static final Icon Db_set_breakpoint = IconLoader.getIcon("/debugger/db_set_breakpoint.png"); - public static final Icon Db_verified_breakpoint = IconLoader.getIcon("/debugger/db_verified_breakpoint.png"); - public static final Icon Db_verified_field_breakpoint = IconLoader.getIcon("/debugger/db_verified_field_breakpoint.png"); - public static final Icon Db_verified_method_breakpoint = IconLoader.getIcon("/debugger/db_verified_method_breakpoint.png"); - public static final Icon Db_verified_warning_breakpoint = IconLoader.getIcon("/debugger/db_verified_warning_breakpoint.png"); - public static final Icon Disable_value_calculation = IconLoader.getIcon("/debugger/disable_value_calculation.png"); - public static final Icon EvaluateExpression = IconLoader.getIcon("/debugger/evaluateExpression.png"); - public static final Icon Frame = IconLoader.getIcon("/debugger/frame.png"); - public static final Icon KillProcess = IconLoader.getIcon("/debugger/killProcess.png"); - public static final Icon MuteBreakpoints = IconLoader.getIcon("/debugger/muteBreakpoints.png"); - public static final Icon NewWatch = IconLoader.getIcon("/debugger/newWatch.png"); - public static final Icon RestoreLayout = IconLoader.getIcon("/debugger/restoreLayout.png"); - public static final Icon ShowCurrentFrame = IconLoader.getIcon("/debugger/showCurrentFrame.png"); - public static final Icon StackFrame = IconLoader.getIcon("/debugger/stackFrame.png"); - public static final Icon ThreadAtBreakpoint = IconLoader.getIcon("/debugger/threadAtBreakpoint.png"); - public static final Icon ThreadCurrent = IconLoader.getIcon("/debugger/threadCurrent.png"); - public static final Icon ThreadFrozen = IconLoader.getIcon("/debugger/threadFrozen.png"); - public static final Icon ThreadGroup = IconLoader.getIcon("/debugger/threadGroup.png"); - public static final Icon ThreadGroupCurrent = IconLoader.getIcon("/debugger/threadGroupCurrent.png"); - public static final Icon ThreadRunning = IconLoader.getIcon("/debugger/threadRunning.png"); - public static final Icon Threads = IconLoader.getIcon("/debugger/threads.png"); + public static final Icon AddToWatch = IconLoader.getIcon("/debugger/addToWatch.png"); // 16x16 + public static final Icon AutoVariablesMode = IconLoader.getIcon("/debugger/autoVariablesMode.png"); // 16x16 + public static final Icon BreakpointAlert = IconLoader.getIcon("/debugger/breakpointAlert.png"); // 16x16 + public static final Icon Class_filter = IconLoader.getIcon("/debugger/class_filter.png"); // 16x16 + public static final Icon Console = IconLoader.getIcon("/debugger/console.png"); // 16x16 + public static final Icon Db_array = IconLoader.getIcon("/debugger/db_array.png"); // 16x16 + public static final Icon Db_dep_exception_breakpoint = IconLoader.getIcon("/debugger/db_dep_exception_breakpoint.png"); // 12x12 + public static final Icon Db_dep_field_breakpoint = IconLoader.getIcon("/debugger/db_dep_field_breakpoint.png"); // 12x12 + public static final Icon Db_dep_line_breakpoint = IconLoader.getIcon("/debugger/db_dep_line_breakpoint.png"); // 12x12 + public static final Icon Db_dep_method_breakpoint = IconLoader.getIcon("/debugger/db_dep_method_breakpoint.png"); // 12x12 + public static final Icon Db_disabled_breakpoint = IconLoader.getIcon("/debugger/db_disabled_breakpoint.png"); // 12x12 + public static final Icon Db_disabled_breakpoint_process = IconLoader.getIcon("/debugger/db_disabled_breakpoint_process.png"); // 16x16 + public static final Icon Db_disabled_exception_breakpoint = IconLoader.getIcon("/debugger/db_disabled_exception_breakpoint.png"); // 12x12 + public static final Icon Db_disabled_field_breakpoint = IconLoader.getIcon("/debugger/db_disabled_field_breakpoint.png"); // 12x12 + public static final Icon Db_disabled_method_breakpoint = IconLoader.getIcon("/debugger/db_disabled_method_breakpoint.png"); // 12x12 + public static final Icon Db_error = IconLoader.getIcon("/debugger/db_error.png"); // 16x16 + public static final Icon Db_exception_breakpoint = IconLoader.getIcon("/debugger/db_exception_breakpoint.png"); // 12x12 + public static final Icon Db_field_breakpoint = IconLoader.getIcon("/debugger/db_field_breakpoint.png"); // 12x12 + public static final Icon Db_field_warning_breakpoint = IconLoader.getIcon("/debugger/db_field_warning_breakpoint.png"); // 16x16 + public static final Icon Db_invalid_breakpoint = IconLoader.getIcon("/debugger/db_invalid_breakpoint.png"); // 12x12 + public static final Icon Db_invalid_field_breakpoint = IconLoader.getIcon("/debugger/db_invalid_field_breakpoint.png"); // 12x12 + public static final Icon Db_invalid_method_breakpoint = IconLoader.getIcon("/debugger/db_invalid_method_breakpoint.png"); // 12x12 + public static final Icon Db_method_breakpoint = IconLoader.getIcon("/debugger/db_method_breakpoint.png"); // 12x12 + public static final Icon Db_method_warning_breakpoint = IconLoader.getIcon("/debugger/db_method_warning_breakpoint.png"); // 16x16 + public static final Icon Db_muted_breakpoint = IconLoader.getIcon("/debugger/db_muted_breakpoint.png"); // 12x12 + public static final Icon Db_muted_dep_exception_breakpoint = IconLoader.getIcon("/debugger/db_muted_dep_exception_breakpoint.png"); // 12x12 + public static final Icon Db_muted_dep_field_breakpoint = IconLoader.getIcon("/debugger/db_muted_dep_field_breakpoint.png"); // 12x12 + public static final Icon Db_muted_dep_line_breakpoint = IconLoader.getIcon("/debugger/db_muted_dep_line_breakpoint.png"); // 12x12 + public static final Icon Db_muted_dep_method_breakpoint = IconLoader.getIcon("/debugger/db_muted_dep_method_breakpoint.png"); // 12x12 + public static final Icon Db_muted_disabled_breakpoint = IconLoader.getIcon("/debugger/db_muted_disabled_breakpoint.png"); // 12x12 + public static final Icon Db_muted_disabled_breakpoint_process = IconLoader.getIcon("/debugger/db_muted_disabled_breakpoint_process.png"); // 16x16 + public static final Icon Db_muted_disabled_exception_breakpoint = IconLoader.getIcon("/debugger/db_muted_disabled_exception_breakpoint.png"); // 12x12 + public static final Icon Db_muted_disabled_field_breakpoint = IconLoader.getIcon("/debugger/db_muted_disabled_field_breakpoint.png"); // 12x12 + public static final Icon Db_muted_disabled_method_breakpoint = IconLoader.getIcon("/debugger/db_muted_disabled_method_breakpoint.png"); // 12x12 + public static final Icon Db_muted_exception_breakpoint = IconLoader.getIcon("/debugger/db_muted_exception_breakpoint.png"); // 12x12 + public static final Icon Db_muted_field_breakpoint = IconLoader.getIcon("/debugger/db_muted_field_breakpoint.png"); // 12x12 + public static final Icon Db_muted_field_warning_breakpoint = IconLoader.getIcon("/debugger/db_muted_field_warning_breakpoint.png"); // 16x16 + public static final Icon Db_muted_invalid_breakpoint = IconLoader.getIcon("/debugger/db_muted_invalid_breakpoint.png"); // 12x12 + public static final Icon Db_muted_invalid_field_breakpoint = IconLoader.getIcon("/debugger/db_muted_invalid_field_breakpoint.png"); // 12x12 + public static final Icon Db_muted_invalid_method_breakpoint = IconLoader.getIcon("/debugger/db_muted_invalid_method_breakpoint.png"); // 12x12 + public static final Icon Db_muted_method_breakpoint = IconLoader.getIcon("/debugger/db_muted_method_breakpoint.png"); // 12x12 + public static final Icon Db_muted_method_warning_breakpoint = IconLoader.getIcon("/debugger/db_muted_method_warning_breakpoint.png"); // 16x16 + public static final Icon Db_muted_verified_breakpoint = IconLoader.getIcon("/debugger/db_muted_verified_breakpoint.png"); // 12x12 + public static final Icon Db_muted_verified_field_breakpoint = IconLoader.getIcon("/debugger/db_muted_verified_field_breakpoint.png"); // 12x12 + public static final Icon Db_muted_verified_method_breakpoint = IconLoader.getIcon("/debugger/db_muted_verified_method_breakpoint.png"); // 12x12 + public static final Icon Db_muted_verified_warning_breakpoint = IconLoader.getIcon("/debugger/db_muted_verified_warning_breakpoint.png"); // 16x16 + public static final Icon Db_obsolete = IconLoader.getIcon("/debugger/db_obsolete.png"); // 12x12 + public static final Icon Db_primitive = IconLoader.getIcon("/debugger/db_primitive.png"); // 16x16 + public static final Icon Db_set_breakpoint = IconLoader.getIcon("/debugger/db_set_breakpoint.png"); // 12x12 + public static final Icon Db_verified_breakpoint = IconLoader.getIcon("/debugger/db_verified_breakpoint.png"); // 12x12 + public static final Icon Db_verified_field_breakpoint = IconLoader.getIcon("/debugger/db_verified_field_breakpoint.png"); // 12x12 + public static final Icon Db_verified_method_breakpoint = IconLoader.getIcon("/debugger/db_verified_method_breakpoint.png"); // 12x12 + public static final Icon Db_verified_warning_breakpoint = IconLoader.getIcon("/debugger/db_verified_warning_breakpoint.png"); // 16x16 + public static final Icon Disable_value_calculation = IconLoader.getIcon("/debugger/disable_value_calculation.png"); // 16x16 + public static final Icon EvaluateExpression = IconLoader.getIcon("/debugger/evaluateExpression.png"); // 16x16 + public static final Icon Frame = IconLoader.getIcon("/debugger/frame.png"); // 16x16 + public static final Icon KillProcess = IconLoader.getIcon("/debugger/killProcess.png"); // 16x16 + public static final Icon MuteBreakpoints = IconLoader.getIcon("/debugger/muteBreakpoints.png"); // 16x16 + public static final Icon NewWatch = IconLoader.getIcon("/debugger/newWatch.png"); // 16x16 + public static final Icon RestoreLayout = IconLoader.getIcon("/debugger/restoreLayout.png"); // 16x16 + public static final Icon ShowCurrentFrame = IconLoader.getIcon("/debugger/showCurrentFrame.png"); // 16x16 + public static final Icon StackFrame = IconLoader.getIcon("/debugger/stackFrame.png"); // 16x16 + public static final Icon ThreadAtBreakpoint = IconLoader.getIcon("/debugger/threadAtBreakpoint.png"); // 16x16 + public static final Icon ThreadCurrent = IconLoader.getIcon("/debugger/threadCurrent.png"); // 16x16 + public static final Icon ThreadFrozen = IconLoader.getIcon("/debugger/threadFrozen.png"); // 16x16 + public static final Icon ThreadGroup = IconLoader.getIcon("/debugger/threadGroup.png"); // 16x16 + public static final Icon ThreadGroupCurrent = IconLoader.getIcon("/debugger/threadGroupCurrent.png"); // 16x16 + public static final Icon ThreadRunning = IconLoader.getIcon("/debugger/threadRunning.png"); // 16x16 + public static final Icon Threads = IconLoader.getIcon("/debugger/threads.png"); // 16x16 public static class ThreadStates { - public static final Icon Daemon_sign = IconLoader.getIcon("/debugger/threadStates/daemon_sign.png"); - public static final Icon EdtBusy = IconLoader.getIcon("/debugger/threadStates/edtBusy.png"); - public static final Icon Exception = IconLoader.getIcon("/debugger/threadStates/exception.png"); - public static final Icon Idle = IconLoader.getIcon("/debugger/threadStates/idle.png"); - public static final Icon IO = IconLoader.getIcon("/debugger/threadStates/io.png"); - public static final Icon Locked = IconLoader.getIcon("/debugger/threadStates/locked.png"); - public static final Icon Paused = IconLoader.getIcon("/debugger/threadStates/paused.png"); - public static final Icon Running = IconLoader.getIcon("/debugger/threadStates/running.png"); - public static final Icon Socket = IconLoader.getIcon("/debugger/threadStates/socket.png"); - public static final Icon Threaddump = IconLoader.getIcon("/debugger/threadStates/threaddump.png"); + public static final Icon Daemon_sign = IconLoader.getIcon("/debugger/threadStates/daemon_sign.png"); // 16x16 + public static final Icon EdtBusy = IconLoader.getIcon("/debugger/threadStates/edtBusy.png"); // 16x16 + public static final Icon Exception = IconLoader.getIcon("/debugger/threadStates/exception.png"); // 16x16 + public static final Icon Idle = IconLoader.getIcon("/debugger/threadStates/idle.png"); // 16x16 + public static final Icon IO = IconLoader.getIcon("/debugger/threadStates/io.png"); // 16x16 + public static final Icon Locked = IconLoader.getIcon("/debugger/threadStates/locked.png"); // 16x16 + public static final Icon Paused = IconLoader.getIcon("/debugger/threadStates/paused.png"); // 16x16 + public static final Icon Running = IconLoader.getIcon("/debugger/threadStates/running.png"); // 16x16 + public static final Icon Socket = IconLoader.getIcon("/debugger/threadStates/socket.png"); // 16x16 + public static final Icon Threaddump = IconLoader.getIcon("/debugger/threadStates/threaddump.png"); // 16x16 } - public static final Icon ThreadSuspended = IconLoader.getIcon("/debugger/threadSuspended.png"); - public static final Icon ToolConsole = IconLoader.getIcon("/debugger/toolConsole.png"); - public static final Icon Value = IconLoader.getIcon("/debugger/value.png"); - public static final Icon ViewBreakpoints = IconLoader.getIcon("/debugger/viewBreakpoints.png"); - public static final Icon Watch = IconLoader.getIcon("/debugger/watch.png"); - public static final Icon Watches = IconLoader.getIcon("/debugger/watches.png"); - public static final Icon WatchLastReturnValue = IconLoader.getIcon("/debugger/watchLastReturnValue.png"); + public static final Icon ThreadSuspended = IconLoader.getIcon("/debugger/threadSuspended.png"); // 16x16 + public static final Icon ToolConsole = IconLoader.getIcon("/debugger/toolConsole.png"); // 16x16 + public static final Icon Value = IconLoader.getIcon("/debugger/value.png"); // 16x16 + public static final Icon ViewBreakpoints = IconLoader.getIcon("/debugger/viewBreakpoints.png"); // 16x16 + public static final Icon Watch = IconLoader.getIcon("/debugger/watch.png"); // 16x16 + public static final Icon Watches = IconLoader.getIcon("/debugger/watches.png"); // 16x16 + public static final Icon WatchLastReturnValue = IconLoader.getIcon("/debugger/watchLastReturnValue.png"); // 16x16 } public static class Diff { - public static final Icon ApplyNotConflicts = IconLoader.getIcon("/diff/applyNotConflicts.png"); - public static final Icon Arrow = IconLoader.getIcon("/diff/arrow.png"); - public static final Icon BranchDiff = IconLoader.getIcon("/diff/branchDiff.png"); - public static final Icon CurrentLine = IconLoader.getIcon("/diff/currentLine.png"); - public static final Icon Diff = IconLoader.getIcon("/diff/Diff.png"); - public static final Icon LeftDiff = IconLoader.getIcon("/diff/leftDiff.png"); - public static final Icon Remove = IconLoader.getIcon("/diff/remove.png"); - public static final Icon RightDiff = IconLoader.getIcon("/diff/rightDiff.png"); + public static final Icon ApplyNotConflicts = IconLoader.getIcon("/diff/applyNotConflicts.png"); // 16x16 + public static final Icon Arrow = IconLoader.getIcon("/diff/arrow.png"); // 11x11 + public static final Icon BranchDiff = IconLoader.getIcon("/diff/branchDiff.png"); // 16x16 + public static final Icon CurrentLine = IconLoader.getIcon("/diff/currentLine.png"); // 16x16 + public static final Icon Diff = IconLoader.getIcon("/diff/Diff.png"); // 16x16 + public static final Icon LeftDiff = IconLoader.getIcon("/diff/leftDiff.png"); // 16x16 + public static final Icon Remove = IconLoader.getIcon("/diff/remove.png"); // 11x11 + public static final Icon RightDiff = IconLoader.getIcon("/diff/rightDiff.png"); // 16x16 } public static class Duplicates { - public static final Icon SendToTheLeft = IconLoader.getIcon("/duplicates/sendToTheLeft.png"); - public static final Icon SendToTheLeftGrayed = IconLoader.getIcon("/duplicates/sendToTheLeftGrayed.png"); - public static final Icon SendToTheRight = IconLoader.getIcon("/duplicates/sendToTheRight.png"); - public static final Icon SendToTheRightGrayed = IconLoader.getIcon("/duplicates/sendToTheRightGrayed.png"); + public static final Icon SendToTheLeft = IconLoader.getIcon("/duplicates/sendToTheLeft.png"); // 16x16 + public static final Icon SendToTheLeftGrayed = IconLoader.getIcon("/duplicates/sendToTheLeftGrayed.png"); // 16x16 + public static final Icon SendToTheRight = IconLoader.getIcon("/duplicates/sendToTheRight.png"); // 16x16 + public static final Icon SendToTheRightGrayed = IconLoader.getIcon("/duplicates/sendToTheRightGrayed.png"); // 16x16 } public static class FileTypes { - public static final Icon Any_type = IconLoader.getIcon("/fileTypes/any_type.png"); - public static final Icon Archive = IconLoader.getIcon("/fileTypes/archive.png"); - public static final Icon Aspectj = IconLoader.getIcon("/fileTypes/aspectj.png"); - public static final Icon Css = IconLoader.getIcon("/fileTypes/css.png"); - public static final Icon Custom = IconLoader.getIcon("/fileTypes/custom.png"); - public static final Icon Dtd = IconLoader.getIcon("/fileTypes/dtd.png"); - public static final Icon Facelets = IconLoader.getIcon("/fileTypes/facelets.png"); - public static final Icon FacesConfig = IconLoader.getIcon("/fileTypes/facesConfig.png"); - public static final Icon Html = IconLoader.getIcon("/fileTypes/html.png"); - public static final Icon Idl = IconLoader.getIcon("/fileTypes/idl.png"); - public static final Icon Java = IconLoader.getIcon("/fileTypes/java.png"); - public static final Icon JavaClass = IconLoader.getIcon("/fileTypes/javaClass.png"); - public static final Icon JavaOutsideSource = IconLoader.getIcon("/fileTypes/javaOutsideSource.png"); - public static final Icon JavaScript = IconLoader.getIcon("/fileTypes/javaScript.png"); - public static final Icon Jsp = IconLoader.getIcon("/fileTypes/jsp.png"); - public static final Icon Jspx = IconLoader.getIcon("/fileTypes/jspx.png"); - public static final Icon Properties = IconLoader.getIcon("/fileTypes/properties.png"); - public static final Icon Text = IconLoader.getIcon("/fileTypes/text.png"); - public static final Icon UiForm = IconLoader.getIcon("/fileTypes/uiForm.png"); - public static final Icon Unknown = IconLoader.getIcon("/fileTypes/unknown.png"); - public static final Icon WsdlFile = IconLoader.getIcon("/fileTypes/wsdlFile.png"); - public static final Icon Xhtml = IconLoader.getIcon("/fileTypes/xhtml.png"); - public static final Icon Xml = IconLoader.getIcon("/fileTypes/xml.png"); - public static final Icon XsdFile = IconLoader.getIcon("/fileTypes/xsdFile.png"); + public static final Icon Any_type = IconLoader.getIcon("/fileTypes/any_type.png"); // 16x16 + public static final Icon Archive = IconLoader.getIcon("/fileTypes/archive.png"); // 16x16 + public static final Icon Aspectj = IconLoader.getIcon("/fileTypes/aspectj.png"); // 16x16 + public static final Icon Css = IconLoader.getIcon("/fileTypes/css.png"); // 16x16 + public static final Icon Custom = IconLoader.getIcon("/fileTypes/custom.png"); // 16x16 + public static final Icon Dtd = IconLoader.getIcon("/fileTypes/dtd.png"); // 16x16 + public static final Icon Facelets = IconLoader.getIcon("/fileTypes/facelets.png"); // 16x16 + public static final Icon FacesConfig = IconLoader.getIcon("/fileTypes/facesConfig.png"); // 16x16 + public static final Icon Html = IconLoader.getIcon("/fileTypes/html.png"); // 16x16 + public static final Icon Idl = IconLoader.getIcon("/fileTypes/idl.png"); // 16x16 + public static final Icon Java = IconLoader.getIcon("/fileTypes/java.png"); // 16x16 + public static final Icon JavaClass = IconLoader.getIcon("/fileTypes/javaClass.png"); // 16x16 + public static final Icon JavaOutsideSource = IconLoader.getIcon("/fileTypes/javaOutsideSource.png"); // 16x16 + public static final Icon JavaScript = IconLoader.getIcon("/fileTypes/javaScript.png"); // 16x16 + public static final Icon Jsp = IconLoader.getIcon("/fileTypes/jsp.png"); // 16x16 + public static final Icon Jspx = IconLoader.getIcon("/fileTypes/jspx.png"); // 16x16 + public static final Icon Properties = IconLoader.getIcon("/fileTypes/properties.png"); // 16x16 + public static final Icon Text = IconLoader.getIcon("/fileTypes/text.png"); // 16x16 + public static final Icon UiForm = IconLoader.getIcon("/fileTypes/uiForm.png"); // 16x16 + public static final Icon Unknown = IconLoader.getIcon("/fileTypes/unknown.png"); // 16x16 + public static final Icon WsdlFile = IconLoader.getIcon("/fileTypes/wsdlFile.png"); // 16x16 + public static final Icon Xhtml = IconLoader.getIcon("/fileTypes/xhtml.png"); // 16x16 + public static final Icon Xml = IconLoader.getIcon("/fileTypes/xml.png"); // 16x16 + public static final Icon XsdFile = IconLoader.getIcon("/fileTypes/xsdFile.png"); // 16x16 } public static class General { - public static final Icon Add = IconLoader.getIcon("/general/add.png"); - public static final Icon AddFavoritesList = IconLoader.getIcon("/general/addFavoritesList.png"); - public static final Icon AddJdk = IconLoader.getIcon("/general/addJdk.png"); - public static final Icon ApplicationSettings = IconLoader.getIcon("/general/applicationSettings.png"); - public static final Icon ArrowDown = IconLoader.getIcon("/general/arrowDown.png"); - public static final Icon AutohideOff = IconLoader.getIcon("/general/autohideOff.png"); - public static final Icon AutohideOffInactive = IconLoader.getIcon("/general/autohideOffInactive.png"); - public static final Icon AutoscrollFromSource = IconLoader.getIcon("/general/autoscrollFromSource.png"); - public static final Icon AutoscrollToSource = IconLoader.getIcon("/general/autoscrollToSource.png"); - public static final Icon Balloon = IconLoader.getIcon("/general/balloon.png"); - public static final Icon BalloonClose = IconLoader.getIcon("/general/balloonClose.png"); - public static final Icon BalloonError = IconLoader.getIcon("/general/balloonError.png"); - public static final Icon BalloonInformation = IconLoader.getIcon("/general/balloonInformation.png"); - public static final Icon BalloonWarning = IconLoader.getIcon("/general/balloonWarning.png"); - public static final Icon Bullet = IconLoader.getIcon("/general/bullet.png"); - public static final Icon CollapseAll = IconLoader.getIcon("/general/collapseAll.png"); - public static final Icon CollapseAllHover = IconLoader.getIcon("/general/collapseAllHover.png"); - public static final Icon Combo = IconLoader.getIcon("/general/combo.png"); - public static final Icon Combo2 = IconLoader.getIcon("/general/combo2.png"); - public static final Icon ComboArrow = IconLoader.getIcon("/general/comboArrow.png"); - public static final Icon ComboArrowDown = IconLoader.getIcon("/general/comboArrowDown.png"); - public static final Icon ComboArrowLeft = IconLoader.getIcon("/general/comboArrowLeft.png"); - public static final Icon ComboArrowLeftPassive = IconLoader.getIcon("/general/comboArrowLeftPassive.png"); - public static final Icon ComboArrowRight = IconLoader.getIcon("/general/comboArrowRight.png"); - public static final Icon ComboArrowRightPassive = IconLoader.getIcon("/general/comboArrowRightPassive.png"); - public static final Icon ComboUpPassive = IconLoader.getIcon("/general/comboUpPassive.png"); - public static final Icon ConfigurableDefault = IconLoader.getIcon("/general/configurableDefault.png"); - public static final Icon CreateNewProject = IconLoader.getIcon("/general/createNewProject.png"); - public static final Icon Debug = IconLoader.getIcon("/general/debug.png"); - public static final Icon DefaultKeymap = IconLoader.getIcon("/general/defaultKeymap.png"); - public static final Icon Divider = IconLoader.getIcon("/general/divider.png"); - public static final Icon Documentation = IconLoader.getIcon("/general/documentation.png"); - public static final Icon Dropdown = IconLoader.getIcon("/general/dropdown.png"); - public static final Icon EditColors = IconLoader.getIcon("/general/editColors.png"); - public static final Icon EditItemInSection = IconLoader.getIcon("/general/editItemInSection.png"); - public static final Icon Ellipsis = IconLoader.getIcon("/general/ellipsis.png"); - public static final Icon ErrorDialog = IconLoader.getIcon("/general/errorDialog.png"); - public static final Icon ErrorsFound = IconLoader.getIcon("/general/errorsFound.png"); - public static final Icon ErrorsInProgress = IconLoader.getIcon("/general/errorsInProgress.png"); - public static final Icon ExclMark = IconLoader.getIcon("/general/exclMark.png"); - public static final Icon ExpandAll = IconLoader.getIcon("/general/expandAll.png"); - public static final Icon ExpandAllHover = IconLoader.getIcon("/general/expandAllHover.png"); - public static final Icon ExternalTools = IconLoader.getIcon("/general/externalTools.png"); - public static final Icon Floating = IconLoader.getIcon("/general/floating.png"); - public static final Icon Gear = IconLoader.getIcon("/general/gear.png"); - public static final Icon GearHover = IconLoader.getIcon("/general/gearHover.png"); - public static final Icon GetProjectfromVCS = IconLoader.getIcon("/general/getProjectfromVCS.png"); - public static final Icon Help = IconLoader.getIcon("/general/help.png"); - public static final Icon HideDown = IconLoader.getIcon("/general/hideDown.png"); - public static final Icon HideDownHover = IconLoader.getIcon("/general/hideDownHover.png"); - public static final Icon HideDownPart = IconLoader.getIcon("/general/hideDownPart.png"); - public static final Icon HideDownPartHover = IconLoader.getIcon("/general/hideDownPartHover.png"); - public static final Icon HideLeft = IconLoader.getIcon("/general/hideLeft.png"); - public static final Icon HideLeftHover = IconLoader.getIcon("/general/hideLeftHover.png"); - public static final Icon HideLeftPart = IconLoader.getIcon("/general/hideLeftPart.png"); - public static final Icon HideLeftPartHover = IconLoader.getIcon("/general/hideLeftPartHover.png"); - public static final Icon HideRight = IconLoader.getIcon("/general/hideRight.png"); - public static final Icon HideRightHover = IconLoader.getIcon("/general/hideRightHover.png"); - public static final Icon HideRightPart = IconLoader.getIcon("/general/hideRightPart.png"); - public static final Icon HideRightPartHover = IconLoader.getIcon("/general/hideRightPartHover.png"); - public static final Icon HideToolWindow = IconLoader.getIcon("/general/hideToolWindow.png"); - public static final Icon HideToolWindowInactive = IconLoader.getIcon("/general/hideToolWindowInactive.png"); - public static final Icon IdeOptions = IconLoader.getIcon("/general/ideOptions.png"); - public static final Icon IjLogo = IconLoader.getIcon("/general/ijLogo.png"); - public static final Icon ImplementingMethod = IconLoader.getIcon("/general/implementingMethod.png"); - public static final Icon InformationDialog = IconLoader.getIcon("/general/informationDialog.png"); - public static final Icon InheritedMethod = IconLoader.getIcon("/general/inheritedMethod.png"); - public static final Icon InspectionInProgress = IconLoader.getIcon("/general/inspectionInProgress.png"); - public static final Icon InspectionsOff = IconLoader.getIcon("/general/inspectionsOff.png"); - public static final Icon Jdk = IconLoader.getIcon("/general/jdk.png"); - public static final Icon JetbrainsTvIdea = IconLoader.getIcon("/general/jetbrainsTvIdea.png"); - public static final Icon KeyboardShortcut = IconLoader.getIcon("/general/keyboardShortcut.png"); - public static final Icon Keymap = IconLoader.getIcon("/general/keymap.png"); - public static final Icon Locate = IconLoader.getIcon("/general/locate.png"); - public static final Icon LocateHover = IconLoader.getIcon("/general/locateHover.png"); - public static final Icon MacCorner = IconLoader.getIcon("/general/macCorner.png"); - public static final Icon Mdot_empty = IconLoader.getIcon("/general/mdot-empty.png"); - public static final Icon Mdot_white = IconLoader.getIcon("/general/mdot-white.png"); - public static final Icon Mdot = IconLoader.getIcon("/general/mdot.png"); - public static final Icon Modified = IconLoader.getIcon("/general/modified.png"); - public static final Icon MoreTabs = IconLoader.getIcon("/general/moreTabs.png"); - public static final Icon Mouse = IconLoader.getIcon("/general/mouse.png"); - public static final Icon MouseShortcut = IconLoader.getIcon("/general/mouseShortcut.png"); - public static final Icon NoAnalysis = IconLoader.getIcon("/general/noAnalysis.png"); - public static final Icon OpenProject = IconLoader.getIcon("/general/openProject.png"); - public static final Icon OverridenMethod = IconLoader.getIcon("/general/overridenMethod.png"); - public static final Icon OverridingMethod = IconLoader.getIcon("/general/overridingMethod.png"); - public static final Icon PackagesTab = IconLoader.getIcon("/general/packagesTab.png"); - public static final Icon PathVariables = IconLoader.getIcon("/general/pathVariables.png"); - public static final Icon Pin_tab = IconLoader.getIcon("/general/pin_tab.png"); - public static final Icon PluginManager = IconLoader.getIcon("/general/pluginManager.png"); - public static final Icon Progress = IconLoader.getIcon("/general/progress.png"); - public static final Icon ProjectSettings = IconLoader.getIcon("/general/projectSettings.png"); - public static final Icon ProjectStructure = IconLoader.getIcon("/general/projectStructure.png"); - public static final Icon ProjectTab = IconLoader.getIcon("/general/projectTab.png"); - public static final Icon QuestionDialog = IconLoader.getIcon("/general/questionDialog.png"); - public static final Icon ReadHelp = IconLoader.getIcon("/general/readHelp.png"); - public static final Icon Remove = IconLoader.getIcon("/general/remove.png"); - public static final Icon ReopenRecentProject = IconLoader.getIcon("/general/reopenRecentProject.png"); - public static final Icon Reset = IconLoader.getIcon("/general/reset.png"); - public static final Icon Run = IconLoader.getIcon("/general/run.png"); - public static final Icon RunWithCoverage = IconLoader.getIcon("/general/runWithCoverage.png"); - public static final Icon SecondaryGroup = IconLoader.getIcon("/general/secondaryGroup.png"); - public static final Icon SeparatorH = IconLoader.getIcon("/general/separatorH.png"); - public static final Icon Show_to_implement = IconLoader.getIcon("/general/show_to_implement.png"); - public static final Icon Show_to_override = IconLoader.getIcon("/general/show_to_override.png"); - public static final Icon SmallConfigurableVcs = IconLoader.getIcon("/general/smallConfigurableVcs.png"); - public static final Icon SplitCenterH = IconLoader.getIcon("/general/splitCenterH.png"); - public static final Icon SplitCenterV = IconLoader.getIcon("/general/splitCenterV.png"); - public static final Icon SplitDown = IconLoader.getIcon("/general/splitDown.png"); - public static final Icon SplitGlueH = IconLoader.getIcon("/general/splitGlueH.png"); - public static final Icon SplitGlueV = IconLoader.getIcon("/general/splitGlueV.png"); - public static final Icon SplitLeft = IconLoader.getIcon("/general/splitLeft.png"); - public static final Icon SplitRight = IconLoader.getIcon("/general/splitRight.png"); - public static final Icon SplitUp = IconLoader.getIcon("/general/splitUp.png"); - public static final Icon Tab_white_center = IconLoader.getIcon("/general/tab-white-center.png"); - public static final Icon Tab_white_left = IconLoader.getIcon("/general/tab-white-left.png"); - public static final Icon Tab_white_right = IconLoader.getIcon("/general/tab-white-right.png"); - public static final Icon Tab_grey_bckgrnd = IconLoader.getIcon("/general/tab_grey_bckgrnd.png"); - public static final Icon Tab_grey_left = IconLoader.getIcon("/general/tab_grey_left.png"); - public static final Icon Tab_grey_left_inner = IconLoader.getIcon("/general/tab_grey_left_inner.png"); - public static final Icon Tab_grey_right = IconLoader.getIcon("/general/tab_grey_right.png"); - public static final Icon Tab_grey_right_inner = IconLoader.getIcon("/general/tab_grey_right_inner.png"); - public static final Icon TbHidden = IconLoader.getIcon("/general/tbHidden.png"); - public static final Icon TbShown = IconLoader.getIcon("/general/tbShown.png"); - public static final Icon Tip = IconLoader.getIcon("/general/tip.png"); - public static final Icon TipsOfTheDay = IconLoader.getIcon("/general/tipsOfTheDay.png"); - public static final Icon TodoDefault = IconLoader.getIcon("/general/todoDefault.png"); - public static final Icon TodoImportant = IconLoader.getIcon("/general/todoImportant.png"); - public static final Icon TodoQuestion = IconLoader.getIcon("/general/todoQuestion.png"); - public static final Icon ToolWindowAnt = IconLoader.getIcon("/general/toolWindowAnt.png"); - public static final Icon ToolWindowChanges = IconLoader.getIcon("/general/toolWindowChanges.png"); - public static final Icon ToolWindowCommander = IconLoader.getIcon("/general/toolWindowCommander.png"); - public static final Icon ToolWindowCoverage = IconLoader.getIcon("/general/toolWindowCoverage.png"); - public static final Icon ToolWindowCvs = IconLoader.getIcon("/general/toolWindowCvs.png"); - public static final Icon ToolWindowDebugger = IconLoader.getIcon("/general/toolWindowDebugger.png"); - public static final Icon ToolWindowFavorites = IconLoader.getIcon("/general/toolWindowFavorites.png"); - public static final Icon ToolWindowFind = IconLoader.getIcon("/general/toolWindowFind.png"); - public static final Icon ToolWindowHierarchy = IconLoader.getIcon("/general/toolWindowHierarchy.png"); - public static final Icon ToolWindowInspection = IconLoader.getIcon("/general/toolWindowInspection.png"); - public static final Icon ToolWindowMessages = IconLoader.getIcon("/general/toolWindowMessages.png"); - public static final Icon ToolWindowModuleDependencies = IconLoader.getIcon("/general/toolWindowModuleDependencies.png"); - public static final Icon ToolWindowPalette = IconLoader.getIcon("/general/toolWindowPalette.png"); - public static final Icon ToolWindowProject = IconLoader.getIcon("/general/toolWindowProject.png"); - public static final Icon ToolWindowRun = IconLoader.getIcon("/general/toolWindowRun.png"); - public static final Icon ToolWindowStructure = IconLoader.getIcon("/general/toolWindowStructure.png"); - public static final Icon ToolWindowTodo = IconLoader.getIcon("/general/toolWindowTodo.png"); - public static final Icon VcsSmallTab = IconLoader.getIcon("/general/vcsSmallTab.png"); - public static final Icon WarningDialog = IconLoader.getIcon("/general/warningDialog.png"); - public static final Icon Web = IconLoader.getIcon("/general/web.png"); + public static final Icon Add = IconLoader.getIcon("/general/add.png"); // 16x16 + public static final Icon AddFavoritesList = IconLoader.getIcon("/general/addFavoritesList.png"); // 16x16 + public static final Icon AddJdk = IconLoader.getIcon("/general/addJdk.png"); // 16x16 + public static final Icon ApplicationSettings = IconLoader.getIcon("/general/applicationSettings.png"); // 16x16 + public static final Icon ArrowDown = IconLoader.getIcon("/general/arrowDown.png"); // 7x6 + public static final Icon AutohideOff = IconLoader.getIcon("/general/autohideOff.png"); // 14x14 + public static final Icon AutohideOffInactive = IconLoader.getIcon("/general/autohideOffInactive.png"); // 14x14 + public static final Icon AutoscrollFromSource = IconLoader.getIcon("/general/autoscrollFromSource.png"); // 16x16 + public static final Icon AutoscrollToSource = IconLoader.getIcon("/general/autoscrollToSource.png"); // 16x16 + public static final Icon Balloon = IconLoader.getIcon("/general/balloon.png"); // 16x16 + public static final Icon BalloonClose = IconLoader.getIcon("/general/balloonClose.png"); // 30x30 + public static final Icon BalloonError = IconLoader.getIcon("/general/balloonError.png"); // 16x16 + public static final Icon BalloonInformation = IconLoader.getIcon("/general/balloonInformation.png"); // 16x16 + public static final Icon BalloonWarning = IconLoader.getIcon("/general/balloonWarning.png"); // 16x16 + public static final Icon Bullet = IconLoader.getIcon("/general/bullet.png"); // 16x16 + public static final Icon CollapseAll = IconLoader.getIcon("/general/collapseAll.png"); // 11x16 + public static final Icon CollapseAllHover = IconLoader.getIcon("/general/collapseAllHover.png"); // 11x16 + public static final Icon Combo = IconLoader.getIcon("/general/combo.png"); // 16x16 + public static final Icon Combo2 = IconLoader.getIcon("/general/combo2.png"); // 16x16 + public static final Icon ComboArrow = IconLoader.getIcon("/general/comboArrow.png"); // 16x16 + public static final Icon ComboArrowDown = IconLoader.getIcon("/general/comboArrowDown.png"); // 9x5 + public static final Icon ComboArrowLeft = IconLoader.getIcon("/general/comboArrowLeft.png"); // 5x9 + public static final Icon ComboArrowLeftPassive = IconLoader.getIcon("/general/comboArrowLeftPassive.png"); // 5x9 + public static final Icon ComboArrowRight = IconLoader.getIcon("/general/comboArrowRight.png"); // 5x9 + public static final Icon ComboArrowRightPassive = IconLoader.getIcon("/general/comboArrowRightPassive.png"); // 5x9 + public static final Icon ComboUpPassive = IconLoader.getIcon("/general/comboUpPassive.png"); // 16x16 + public static final Icon ConfigurableDefault = IconLoader.getIcon("/general/configurableDefault.png"); // 32x32 + public static final Icon CreateNewProject = IconLoader.getIcon("/general/createNewProject.png"); // 48x48 + public static final Icon Debug = IconLoader.getIcon("/general/debug.png"); // 16x16 + public static final Icon DefaultKeymap = IconLoader.getIcon("/general/defaultKeymap.png"); // 48x48 + public static final Icon Divider = IconLoader.getIcon("/general/divider.png"); // 2x19 + public static final Icon Dropdown = IconLoader.getIcon("/general/dropdown.png"); // 16x16 + public static final Icon EditColors = IconLoader.getIcon("/general/editColors.png"); // 16x16 + public static final Icon EditItemInSection = IconLoader.getIcon("/general/editItemInSection.png"); // 16x16 + public static final Icon Ellipsis = IconLoader.getIcon("/general/ellipsis.png"); // 9x9 + public static final Icon ErrorDialog = IconLoader.getIcon("/general/errorDialog.png"); // 32x32 + public static final Icon ErrorsFound = IconLoader.getIcon("/general/errorsFound.png"); // 12x12 + public static final Icon ErrorsInProgress = IconLoader.getIcon("/general/errorsInProgress.png"); // 12x12 + public static final Icon ExclMark = IconLoader.getIcon("/general/exclMark.png"); // 16x16 + public static final Icon ExpandAll = IconLoader.getIcon("/general/expandAll.png"); // 11x16 + public static final Icon ExpandAllHover = IconLoader.getIcon("/general/expandAllHover.png"); // 11x16 + public static final Icon ExternalTools = IconLoader.getIcon("/general/externalTools.png"); // 32x32 + public static final Icon Floating = IconLoader.getIcon("/general/floating.png"); // 14x14 + public static final Icon Gear = IconLoader.getIcon("/general/gear.png"); // 21x16 + public static final Icon GearHover = IconLoader.getIcon("/general/gearHover.png"); // 21x16 + public static final Icon GetProjectfromVCS = IconLoader.getIcon("/general/getProjectfromVCS.png"); // 48x48 + public static final Icon Help = IconLoader.getIcon("/general/help.png"); // 10x10 + public static final Icon HideDown = IconLoader.getIcon("/general/hideDown.png"); // 16x16 + public static final Icon HideDownHover = IconLoader.getIcon("/general/hideDownHover.png"); // 16x16 + public static final Icon HideDownPart = IconLoader.getIcon("/general/hideDownPart.png"); // 16x16 + public static final Icon HideDownPartHover = IconLoader.getIcon("/general/hideDownPartHover.png"); // 16x16 + public static final Icon HideLeft = IconLoader.getIcon("/general/hideLeft.png"); // 16x16 + public static final Icon HideLeftHover = IconLoader.getIcon("/general/hideLeftHover.png"); // 16x16 + public static final Icon HideLeftPart = IconLoader.getIcon("/general/hideLeftPart.png"); // 16x16 + public static final Icon HideLeftPartHover = IconLoader.getIcon("/general/hideLeftPartHover.png"); // 16x16 + public static final Icon HideRight = IconLoader.getIcon("/general/hideRight.png"); // 16x16 + public static final Icon HideRightHover = IconLoader.getIcon("/general/hideRightHover.png"); // 16x16 + public static final Icon HideRightPart = IconLoader.getIcon("/general/hideRightPart.png"); // 16x16 + public static final Icon HideRightPartHover = IconLoader.getIcon("/general/hideRightPartHover.png"); // 16x16 + public static final Icon HideToolWindow = IconLoader.getIcon("/general/hideToolWindow.png"); // 14x14 + public static final Icon HideToolWindowInactive = IconLoader.getIcon("/general/hideToolWindowInactive.png"); // 14x14 + public static final Icon IdeOptions = IconLoader.getIcon("/general/ideOptions.png"); // 16x16 + public static final Icon IjLogo = IconLoader.getIcon("/general/ijLogo.png"); // 16x16 + public static final Icon ImplementingMethod = IconLoader.getIcon("/general/implementingMethod.png"); // 10x14 + public static final Icon InformationDialog = IconLoader.getIcon("/general/informationDialog.png"); // 32x32 + public static final Icon InheritedMethod = IconLoader.getIcon("/general/inheritedMethod.png"); // 11x14 + public static final Icon InspectionInProgress = IconLoader.getIcon("/general/inspectionInProgress.png"); // 11x11 + public static final Icon InspectionsOff = IconLoader.getIcon("/general/inspectionsOff.png"); // 16x16 + public static final Icon Jdk = IconLoader.getIcon("/general/jdk.png"); // 16x16 + public static final Icon JetbrainsTvIdea = IconLoader.getIcon("/general/jetbrainsTvIdea.png"); // 48x48 + public static final Icon KeyboardShortcut = IconLoader.getIcon("/general/keyboardShortcut.png"); // 13x13 + public static final Icon Keymap = IconLoader.getIcon("/general/keymap.png"); // 32x32 + public static final Icon Locate = IconLoader.getIcon("/general/locate.png"); // 14x16 + public static final Icon LocateHover = IconLoader.getIcon("/general/locateHover.png"); // 14x16 + public static final Icon MacCorner = IconLoader.getIcon("/general/macCorner.png"); // 16x16 + public static final Icon Mdot_empty = IconLoader.getIcon("/general/mdot-empty.png"); // 8x8 + public static final Icon Mdot_white = IconLoader.getIcon("/general/mdot-white.png"); // 8x8 + public static final Icon Mdot = IconLoader.getIcon("/general/mdot.png"); // 8x8 + public static final Icon Modified = IconLoader.getIcon("/general/modified.png"); // 24x16 + public static final Icon MoreTabs = IconLoader.getIcon("/general/moreTabs.png"); // 16x16 + public static final Icon Mouse = IconLoader.getIcon("/general/mouse.png"); // 32x32 + public static final Icon MouseShortcut = IconLoader.getIcon("/general/mouseShortcut.png"); // 13x13 + public static final Icon NoAnalysis = IconLoader.getIcon("/general/noAnalysis.png"); // 12x12 + public static final Icon OpenProject = IconLoader.getIcon("/general/openProject.png"); // 48x48 + public static final Icon OverridenMethod = IconLoader.getIcon("/general/overridenMethod.png"); // 10x14 + public static final Icon OverridingMethod = IconLoader.getIcon("/general/overridingMethod.png"); // 10x14 + public static final Icon PackagesTab = IconLoader.getIcon("/general/packagesTab.png"); // 16x16 + public static final Icon PathVariables = IconLoader.getIcon("/general/pathVariables.png"); // 32x32 + public static final Icon Pin_tab = IconLoader.getIcon("/general/pin_tab.png"); // 16x16 + public static final Icon PluginManager = IconLoader.getIcon("/general/pluginManager.png"); // 48x48 + public static final Icon Progress = IconLoader.getIcon("/general/progress.png"); // 8x10 + public static final Icon ProjectSettings = IconLoader.getIcon("/general/projectSettings.png"); // 16x16 + public static final Icon ProjectStructure = IconLoader.getIcon("/general/projectStructure.png"); // 16x16 + public static final Icon ProjectTab = IconLoader.getIcon("/general/projectTab.png"); // 16x16 + public static final Icon QuestionDialog = IconLoader.getIcon("/general/questionDialog.png"); // 32x32 + public static final Icon ReadHelp = IconLoader.getIcon("/general/readHelp.png"); // 48x48 + public static final Icon Remove = IconLoader.getIcon("/general/remove.png"); // 16x16 + public static final Icon ReopenRecentProject = IconLoader.getIcon("/general/reopenRecentProject.png"); // 48x48 + public static final Icon Reset = IconLoader.getIcon("/general/reset.png"); // 16x16 + public static final Icon Run = IconLoader.getIcon("/general/run.png"); // 7x10 + public static final Icon RunWithCoverage = IconLoader.getIcon("/general/runWithCoverage.png"); // 16x16 + public static final Icon SecondaryGroup = IconLoader.getIcon("/general/secondaryGroup.png"); // 16x16 + public static final Icon SeparatorH = IconLoader.getIcon("/general/separatorH.png"); // 17x11 + public static final Icon Show_to_implement = IconLoader.getIcon("/general/show_to_implement.png"); // 16x16 + public static final Icon Show_to_override = IconLoader.getIcon("/general/show_to_override.png"); // 16x16 + public static final Icon SmallConfigurableVcs = IconLoader.getIcon("/general/smallConfigurableVcs.png"); // 16x16 + public static final Icon SplitCenterH = IconLoader.getIcon("/general/splitCenterH.png"); // 7x7 + public static final Icon SplitCenterV = IconLoader.getIcon("/general/splitCenterV.png"); // 6x7 + public static final Icon SplitDown = IconLoader.getIcon("/general/splitDown.png"); // 7x7 + public static final Icon SplitGlueH = IconLoader.getIcon("/general/splitGlueH.png"); // 6x17 + public static final Icon SplitGlueV = IconLoader.getIcon("/general/splitGlueV.png"); // 17x6 + public static final Icon SplitLeft = IconLoader.getIcon("/general/splitLeft.png"); // 7x7 + public static final Icon SplitRight = IconLoader.getIcon("/general/splitRight.png"); // 7x7 + public static final Icon SplitUp = IconLoader.getIcon("/general/splitUp.png"); // 7x7 + public static final Icon Tab_white_center = IconLoader.getIcon("/general/tab-white-center.png"); // 1x17 + public static final Icon Tab_white_left = IconLoader.getIcon("/general/tab-white-left.png"); // 4x17 + public static final Icon Tab_white_right = IconLoader.getIcon("/general/tab-white-right.png"); // 4x17 + public static final Icon Tab_grey_bckgrnd = IconLoader.getIcon("/general/tab_grey_bckgrnd.png"); // 1x17 + public static final Icon Tab_grey_left = IconLoader.getIcon("/general/tab_grey_left.png"); // 4x17 + public static final Icon Tab_grey_left_inner = IconLoader.getIcon("/general/tab_grey_left_inner.png"); // 4x17 + public static final Icon Tab_grey_right = IconLoader.getIcon("/general/tab_grey_right.png"); // 4x17 + public static final Icon Tab_grey_right_inner = IconLoader.getIcon("/general/tab_grey_right_inner.png"); // 4x17 + public static final Icon TbHidden = IconLoader.getIcon("/general/tbHidden.png"); // 16x16 + public static final Icon TbShown = IconLoader.getIcon("/general/tbShown.png"); // 16x16 + public static final Icon Tip = IconLoader.getIcon("/general/tip.png"); // 32x32 + public static final Icon TipsOfTheDay = IconLoader.getIcon("/general/tipsOfTheDay.png"); // 48x48 + public static final Icon TodoDefault = IconLoader.getIcon("/general/todoDefault.png"); // 12x12 + public static final Icon TodoImportant = IconLoader.getIcon("/general/todoImportant.png"); // 12x12 + public static final Icon TodoQuestion = IconLoader.getIcon("/general/todoQuestion.png"); // 12x12 + public static final Icon WarningDialog = IconLoader.getIcon("/general/warningDialog.png"); // 32x32 + public static final Icon Web = IconLoader.getIcon("/general/web.png"); // 13x13 } public static class Graph { - public static final Icon ActualZoom = IconLoader.getIcon("/graph/actualZoom.png"); - public static final Icon Export = IconLoader.getIcon("/graph/export.png"); - public static final Icon FitContent = IconLoader.getIcon("/graph/fitContent.png"); - public static final Icon Grid = IconLoader.getIcon("/graph/grid.png"); - public static final Icon Layout = IconLoader.getIcon("/graph/layout.png"); - public static final Icon NodeSelectionMode = IconLoader.getIcon("/graph/nodeSelectionMode.png"); - public static final Icon Print = IconLoader.getIcon("/graph/print.png"); - public static final Icon PrintPreview = IconLoader.getIcon("/graph/printPreview.png"); - public static final Icon SnapToGrid = IconLoader.getIcon("/graph/snapToGrid.png"); - public static final Icon ZoomIn = IconLoader.getIcon("/graph/zoomIn.png"); - public static final Icon ZoomOut = IconLoader.getIcon("/graph/zoomOut.png"); + public static final Icon ActualZoom = IconLoader.getIcon("/graph/actualZoom.png"); // 16x16 + public static final Icon Export = IconLoader.getIcon("/graph/export.png"); // 16x16 + public static final Icon FitContent = IconLoader.getIcon("/graph/fitContent.png"); // 16x16 + public static final Icon Grid = IconLoader.getIcon("/graph/grid.png"); // 16x16 + public static final Icon Layout = IconLoader.getIcon("/graph/layout.png"); // 16x16 + public static final Icon NodeSelectionMode = IconLoader.getIcon("/graph/nodeSelectionMode.png"); // 16x16 + public static final Icon Print = IconLoader.getIcon("/graph/print.png"); // 16x16 + public static final Icon PrintPreview = IconLoader.getIcon("/graph/printPreview.png"); // 16x16 + public static final Icon SnapToGrid = IconLoader.getIcon("/graph/snapToGrid.png"); // 16x16 + public static final Icon ZoomIn = IconLoader.getIcon("/graph/zoomIn.png"); // 16x16 + public static final Icon ZoomOut = IconLoader.getIcon("/graph/zoomOut.png"); // 16x16 } public static class Gutter { - public static final Icon Colors = IconLoader.getIcon("/gutter/colors.png"); - public static final Icon ImplementedMethod = IconLoader.getIcon("/gutter/implementedMethod.png"); - public static final Icon ImplementingMethod = IconLoader.getIcon("/gutter/implementingMethod.png"); - public static final Icon OverridenMethod = IconLoader.getIcon("/gutter/overridenMethod.png"); - public static final Icon OverridingMethod = IconLoader.getIcon("/gutter/overridingMethod.png"); - public static final Icon RecursiveMethod = IconLoader.getIcon("/gutter/recursiveMethod.png"); + public static final Icon Colors = IconLoader.getIcon("/gutter/colors.png"); // 12x12 + public static final Icon ImplementedMethod = IconLoader.getIcon("/gutter/implementedMethod.png"); // 12x12 + public static final Icon ImplementingMethod = IconLoader.getIcon("/gutter/implementingMethod.png"); // 12x12 + public static final Icon OverridenMethod = IconLoader.getIcon("/gutter/overridenMethod.png"); // 12x12 + public static final Icon OverridingMethod = IconLoader.getIcon("/gutter/overridingMethod.png"); // 12x12 + public static final Icon RecursiveMethod = IconLoader.getIcon("/gutter/recursiveMethod.png"); // 12x12 } public static class Hierarchy { - public static final Icon Base = IconLoader.getIcon("/hierarchy/base.png"); - public static final Icon Callee = IconLoader.getIcon("/hierarchy/callee.png"); - public static final Icon Caller = IconLoader.getIcon("/hierarchy/caller.png"); - public static final Icon Class = IconLoader.getIcon("/hierarchy/class.png"); - public static final Icon MethodDefined = IconLoader.getIcon("/hierarchy/methodDefined.png"); - public static final Icon MethodNotDefined = IconLoader.getIcon("/hierarchy/methodNotDefined.png"); - public static final Icon ShouldDefineMethod = IconLoader.getIcon("/hierarchy/shouldDefineMethod.png"); - public static final Icon Subtypes = IconLoader.getIcon("/hierarchy/subtypes.png"); - public static final Icon Supertypes = IconLoader.getIcon("/hierarchy/supertypes.png"); + public static final Icon Base = IconLoader.getIcon("/hierarchy/base.png"); // 16x16 + public static final Icon Callee = IconLoader.getIcon("/hierarchy/callee.png"); // 16x16 + public static final Icon Caller = IconLoader.getIcon("/hierarchy/caller.png"); // 16x16 + public static final Icon Class = IconLoader.getIcon("/hierarchy/class.png"); // 16x16 + public static final Icon MethodDefined = IconLoader.getIcon("/hierarchy/methodDefined.png"); // 9x9 + public static final Icon MethodNotDefined = IconLoader.getIcon("/hierarchy/methodNotDefined.png"); // 8x8 + public static final Icon ShouldDefineMethod = IconLoader.getIcon("/hierarchy/shouldDefineMethod.png"); // 9x9 + public static final Icon Subtypes = IconLoader.getIcon("/hierarchy/subtypes.png"); // 16x16 + public static final Icon Supertypes = IconLoader.getIcon("/hierarchy/supertypes.png"); // 16x16 } - public static final Icon Icon = IconLoader.getIcon("/icon.png"); - public static final Icon Icon_CE = IconLoader.getIcon("/icon_CE.png"); - public static final Icon Icon_CEsmall = IconLoader.getIcon("/icon_CEsmall.png"); - public static final Icon Icon_CEwhite = IconLoader.getIcon("/icon_CEwhite.png"); - public static final Icon Icon_small = IconLoader.getIcon("/icon_small.png"); - public static final Icon Icon_white = IconLoader.getIcon("/icon_white.png"); + public static final Icon Icon = IconLoader.getIcon("/icon.png"); // 128x128 + public static final Icon Icon_CE = IconLoader.getIcon("/icon_CE.png"); // 128x128 + public static final Icon Icon_CEsmall = IconLoader.getIcon("/icon_CEsmall.png"); // 16x16 + public static final Icon Icon_CEwhite = IconLoader.getIcon("/icon_CEwhite.png"); // 32x32 + public static final Icon Icon_small = IconLoader.getIcon("/icon_small.png"); // 16x16 + public static final Icon Icon_white = IconLoader.getIcon("/icon_white.png"); // 32x32 public static class Icons { public static class Ide { - public static final Icon NextStep = IconLoader.getIcon("/icons/ide/nextStep.png"); - public static final Icon NextStepGrayed = IconLoader.getIcon("/icons/ide/nextStepGrayed.png"); - public static final Icon NextStepInverted = IconLoader.getIcon("/icons/ide/nextStepInverted.png"); - public static final Icon SpeedSearchPrompt = IconLoader.getIcon("/icons/ide/speedSearchPrompt.png"); + public static final Icon NextStep = IconLoader.getIcon("/icons/ide/nextStep.png"); // 12x12 + public static final Icon NextStepGrayed = IconLoader.getIcon("/icons/ide/nextStepGrayed.png"); // 12x12 + public static final Icon NextStepInverted = IconLoader.getIcon("/icons/ide/nextStepInverted.png"); // 12x12 + public static final Icon SpeedSearchPrompt = IconLoader.getIcon("/icons/ide/speedSearchPrompt.png"); // 16x16 } public static class Inspector { - public static final Icon SortByCategory = IconLoader.getIcon("/icons/inspector/sortByCategory.png"); - public static final Icon SortByName = IconLoader.getIcon("/icons/inspector/sortByName.png"); - public static final Icon UseFilter = IconLoader.getIcon("/icons/inspector/useFilter.png"); + public static final Icon SortByCategory = IconLoader.getIcon("/icons/inspector/sortByCategory.png"); // 16x16 + public static final Icon SortByName = IconLoader.getIcon("/icons/inspector/sortByName.png"); // 16x16 + public static final Icon UseFilter = IconLoader.getIcon("/icons/inspector/useFilter.png"); // 16x16 } @@ -527,550 +506,573 @@ public class AllIcons { public static class Ide { public static class Dnd { - public static final Icon Bottom = IconLoader.getIcon("/ide/dnd/bottom.png"); - public static final Icon Left = IconLoader.getIcon("/ide/dnd/left.png"); - public static final Icon Right = IconLoader.getIcon("/ide/dnd/right.png"); - public static final Icon Top = IconLoader.getIcon("/ide/dnd/top.png"); + public static final Icon Bottom = IconLoader.getIcon("/ide/dnd/bottom.png"); // 17x17 + public static final Icon Left = IconLoader.getIcon("/ide/dnd/left.png"); // 17x17 + public static final Icon Right = IconLoader.getIcon("/ide/dnd/right.png"); // 17x17 + public static final Icon Top = IconLoader.getIcon("/ide/dnd/top.png"); // 17x17 } - public static final Icon EmptyFatalError = IconLoader.getIcon("/ide/emptyFatalError.png"); - public static final Icon Error_notifications = IconLoader.getIcon("/ide/error_notifications.png"); - public static final Icon ErrorPoint = IconLoader.getIcon("/ide/errorPoint.png"); - public static final Icon ErrorSign = IconLoader.getIcon("/ide/errorSign.png"); - public static final Icon FatalError_read = IconLoader.getIcon("/ide/fatalError-read.png"); - public static final Icon FatalError = IconLoader.getIcon("/ide/fatalError.png"); - public static final Icon HectorNo = IconLoader.getIcon("/ide/hectorNo.png"); - public static final Icon HectorOff = IconLoader.getIcon("/ide/hectorOff.png"); - public static final Icon HectorOn = IconLoader.getIcon("/ide/hectorOn.png"); - public static final Icon HectorSyntax = IconLoader.getIcon("/ide/hectorSyntax.png"); - public static final Icon IncomingChangesOff = IconLoader.getIcon("/ide/incomingChangesOff.png"); - public static final Icon IncomingChangesOn = IconLoader.getIcon("/ide/incomingChangesOn.png"); - public static final Icon Info_notifications = IconLoader.getIcon("/ide/info_notifications.png"); - public static final Icon Link = IconLoader.getIcon("/ide/link.png"); - public static final Icon LocalScope = IconLoader.getIcon("/ide/localScope.png"); - public static final Icon LookupAlphanumeric = IconLoader.getIcon("/ide/lookupAlphanumeric.png"); - public static final Icon LookupRelevance = IconLoader.getIcon("/ide/lookupRelevance.png"); + public static final Icon EmptyFatalError = IconLoader.getIcon("/ide/emptyFatalError.png"); // 16x16 + public static final Icon Error_notifications = IconLoader.getIcon("/ide/error_notifications.png"); // 16x16 + public static final Icon ErrorPoint = IconLoader.getIcon("/ide/errorPoint.png"); // 6x6 + public static final Icon ErrorSign = IconLoader.getIcon("/ide/errorSign.png"); // 16x16 + public static final Icon FatalError_read = IconLoader.getIcon("/ide/fatalError-read.png"); // 16x16 + public static final Icon FatalError = IconLoader.getIcon("/ide/fatalError.png"); // 16x16 + public static final Icon HectorNo = IconLoader.getIcon("/ide/hectorNo.png"); // 16x16 + public static final Icon HectorOff = IconLoader.getIcon("/ide/hectorOff.png"); // 16x16 + public static final Icon HectorOn = IconLoader.getIcon("/ide/hectorOn.png"); // 16x16 + public static final Icon HectorSyntax = IconLoader.getIcon("/ide/hectorSyntax.png"); // 16x16 + public static final Icon IncomingChangesOff = IconLoader.getIcon("/ide/incomingChangesOff.png"); // 16x16 + public static final Icon IncomingChangesOn = IconLoader.getIcon("/ide/incomingChangesOn.png"); // 16x16 + public static final Icon Info_notifications = IconLoader.getIcon("/ide/info_notifications.png"); // 16x16 + public static final Icon Link = IconLoader.getIcon("/ide/link.png"); // 12x12 + public static final Icon LocalScope = IconLoader.getIcon("/ide/localScope.png"); // 16x16 + public static final Icon LookupAlphanumeric = IconLoader.getIcon("/ide/lookupAlphanumeric.png"); // 12x12 + public static final Icon LookupRelevance = IconLoader.getIcon("/ide/lookupRelevance.png"); // 12x12 public static class Macro { - public static final Icon Recording_1 = IconLoader.getIcon("/ide/macro/recording_1.png"); - public static final Icon Recording_2 = IconLoader.getIcon("/ide/macro/recording_2.png"); - public static final Icon Recording_3 = IconLoader.getIcon("/ide/macro/recording_3.png"); - public static final Icon Recording_4 = IconLoader.getIcon("/ide/macro/recording_4.png"); - public static final Icon Recording_stop = IconLoader.getIcon("/ide/macro/recording_stop.png"); + public static final Icon Recording_1 = IconLoader.getIcon("/ide/macro/recording_1.png"); // 16x16 + public static final Icon Recording_2 = IconLoader.getIcon("/ide/macro/recording_2.png"); // 16x16 + public static final Icon Recording_3 = IconLoader.getIcon("/ide/macro/recording_3.png"); // 16x16 + public static final Icon Recording_4 = IconLoader.getIcon("/ide/macro/recording_4.png"); // 16x16 + public static final Icon Recording_stop = IconLoader.getIcon("/ide/macro/recording_stop.png"); // 16x16 } - public static final Icon Notifications = IconLoader.getIcon("/ide/notifications.png"); - public static final Icon Pipette = IconLoader.getIcon("/ide/pipette.png"); - public static final Icon Pipette_rollover = IconLoader.getIcon("/ide/pipette_rollover.png"); - public static final Icon Rating = IconLoader.getIcon("/ide/rating.png"); - public static final Icon Rating1 = IconLoader.getIcon("/ide/rating1.png"); - public static final Icon Rating2 = IconLoader.getIcon("/ide/rating2.png"); - public static final Icon Rating3 = IconLoader.getIcon("/ide/rating3.png"); - public static final Icon Rating4 = IconLoader.getIcon("/ide/rating4.png"); - public static final Icon Readonly = IconLoader.getIcon("/ide/readonly.png"); - public static final Icon Readwrite = IconLoader.getIcon("/ide/readwrite.png"); + public static final Icon Notifications = IconLoader.getIcon("/ide/notifications.png"); // 16x16 + public static final Icon Pipette = IconLoader.getIcon("/ide/pipette.png"); // 18x18 + public static final Icon Pipette_rollover = IconLoader.getIcon("/ide/pipette_rollover.png"); // 18x18 + public static final Icon Rating = IconLoader.getIcon("/ide/rating.png"); // 11x11 + public static final Icon Rating1 = IconLoader.getIcon("/ide/rating1.png"); // 11x11 + public static final Icon Rating2 = IconLoader.getIcon("/ide/rating2.png"); // 11x11 + public static final Icon Rating3 = IconLoader.getIcon("/ide/rating3.png"); // 11x11 + public static final Icon Rating4 = IconLoader.getIcon("/ide/rating4.png"); // 11x11 + public static final Icon Readonly = IconLoader.getIcon("/ide/readonly.png"); // 16x16 + public static final Icon Readwrite = IconLoader.getIcon("/ide/readwrite.png"); // 16x16 public static class Shadow { - public static final Icon Bottom_left = IconLoader.getIcon("/ide/shadow/bottom-left.png"); - public static final Icon Bottom_right = IconLoader.getIcon("/ide/shadow/bottom-right.png"); - public static final Icon Bottom = IconLoader.getIcon("/ide/shadow/bottom.png"); - public static final Icon Left = IconLoader.getIcon("/ide/shadow/left.png"); + public static final Icon Bottom_left = IconLoader.getIcon("/ide/shadow/bottom-left.png"); // 70x70 + public static final Icon Bottom_right = IconLoader.getIcon("/ide/shadow/bottom-right.png"); // 70x70 + public static final Icon Bottom = IconLoader.getIcon("/ide/shadow/bottom.png"); // 1x49 + public static final Icon Left = IconLoader.getIcon("/ide/shadow/left.png"); // 35x1 public static class Popup { - public static final Icon Bottom_left = IconLoader.getIcon("/ide/shadow/popup/bottom-left.png"); - public static final Icon Bottom_right = IconLoader.getIcon("/ide/shadow/popup/bottom-right.png"); - public static final Icon Bottom = IconLoader.getIcon("/ide/shadow/popup/bottom.png"); - public static final Icon Left = IconLoader.getIcon("/ide/shadow/popup/left.png"); - public static final Icon Right = IconLoader.getIcon("/ide/shadow/popup/right.png"); - public static final Icon Top_left = IconLoader.getIcon("/ide/shadow/popup/top-left.png"); - public static final Icon Top_right = IconLoader.getIcon("/ide/shadow/popup/top-right.png"); - public static final Icon Top = IconLoader.getIcon("/ide/shadow/popup/top.png"); + public static final Icon Bottom_left = IconLoader.getIcon("/ide/shadow/popup/bottom-left.png"); // 20x20 + public static final Icon Bottom_right = IconLoader.getIcon("/ide/shadow/popup/bottom-right.png"); // 20x20 + public static final Icon Bottom = IconLoader.getIcon("/ide/shadow/popup/bottom.png"); // 1x10 + public static final Icon Left = IconLoader.getIcon("/ide/shadow/popup/left.png"); // 7x1 + public static final Icon Right = IconLoader.getIcon("/ide/shadow/popup/right.png"); // 7x1 + public static final Icon Top_left = IconLoader.getIcon("/ide/shadow/popup/top-left.png"); // 14x14 + public static final Icon Top_right = IconLoader.getIcon("/ide/shadow/popup/top-right.png"); // 14x14 + public static final Icon Top = IconLoader.getIcon("/ide/shadow/popup/top.png"); // 1x4 } - public static final Icon Right = IconLoader.getIcon("/ide/shadow/right.png"); - public static final Icon Top_left = IconLoader.getIcon("/ide/shadow/top-left.png"); - public static final Icon Top_right = IconLoader.getIcon("/ide/shadow/top-right.png"); - public static final Icon Top = IconLoader.getIcon("/ide/shadow/top.png"); + public static final Icon Right = IconLoader.getIcon("/ide/shadow/right.png"); // 35x1 + public static final Icon Top_left = IconLoader.getIcon("/ide/shadow/top-left.png"); // 70x70 + public static final Icon Top_right = IconLoader.getIcon("/ide/shadow/top-right.png"); // 70x70 + public static final Icon Top = IconLoader.getIcon("/ide/shadow/top.png"); // 1x20 } - public static final Icon SharedScope = IconLoader.getIcon("/ide/sharedScope.png"); - public static final Icon Statusbar_arrows = IconLoader.getIcon("/ide/statusbar_arrows.png"); - public static final Icon UpDown = IconLoader.getIcon("/ide/upDown.png"); - public static final Icon Warning_notifications = IconLoader.getIcon("/ide/warning_notifications.png"); + public static final Icon SharedScope = IconLoader.getIcon("/ide/sharedScope.png"); // 16x16 + public static final Icon Statusbar_arrows = IconLoader.getIcon("/ide/statusbar_arrows.png"); // 7x10 + public static final Icon UpDown = IconLoader.getIcon("/ide/upDown.png"); // 16x16 + public static final Icon Warning_notifications = IconLoader.getIcon("/ide/warning_notifications.png"); // 16x16 } public static class Javaee { - public static final Icon Application_xml = IconLoader.getIcon("/javaee/application_xml.png"); - public static final Icon BuildOnFrameDeactivation = IconLoader.getIcon("/javaee/buildOnFrameDeactivation.png"); - public static final Icon DatabaseSchemaImportLegend = IconLoader.getIcon("/javaee/databaseSchemaImportLegend.png"); - public static final Icon DataSourceImport = IconLoader.getIcon("/javaee/dataSourceImport.png"); - public static final Icon DbSchemaImportBig = IconLoader.getIcon("/javaee/dbSchemaImportBig.png"); - public static final Icon Ejb_jar_xml = IconLoader.getIcon("/javaee/ejb-jar_xml.png"); - public static final Icon EjbClass = IconLoader.getIcon("/javaee/ejbClass.png"); - public static final Icon EjbModule = IconLoader.getIcon("/javaee/ejbModule.png"); - public static final Icon EmbeddedAttributeOverlay = IconLoader.getIcon("/javaee/embeddedAttributeOverlay.png"); - public static final Icon EntityBean = IconLoader.getIcon("/javaee/entityBean.png"); - public static final Icon EntityBeanBig = IconLoader.getIcon("/javaee/entityBeanBig.png"); - public static final Icon Home = IconLoader.getIcon("/javaee/home.png"); - public static final Icon InheritedAttributeOverlay = IconLoader.getIcon("/javaee/inheritedAttributeOverlay.png"); - public static final Icon InterceptorClass = IconLoader.getIcon("/javaee/interceptorClass.png"); - public static final Icon InterceptorMethod = IconLoader.getIcon("/javaee/interceptorMethod.png"); - public static final Icon JavaeeAppModule = IconLoader.getIcon("/javaee/JavaeeAppModule.png"); - public static final Icon JpaFacet = IconLoader.getIcon("/javaee/jpaFacet.png"); - public static final Icon Local = IconLoader.getIcon("/javaee/local.png"); - public static final Icon LocalHome = IconLoader.getIcon("/javaee/localHome.png"); - public static final Icon MessageBean = IconLoader.getIcon("/javaee/messageBean.png"); - public static final Icon PersistenceAttribute = IconLoader.getIcon("/javaee/persistenceAttribute.png"); - public static final Icon PersistenceEmbeddable = IconLoader.getIcon("/javaee/persistenceEmbeddable.png"); - public static final Icon PersistenceEntity = IconLoader.getIcon("/javaee/persistenceEntity.png"); - public static final Icon PersistenceEntityListener = IconLoader.getIcon("/javaee/persistenceEntityListener.png"); - public static final Icon PersistenceId = IconLoader.getIcon("/javaee/persistenceId.png"); - public static final Icon PersistenceIdRelationship = IconLoader.getIcon("/javaee/persistenceIdRelationship.png"); - public static final Icon PersistenceMappedSuperclass = IconLoader.getIcon("/javaee/persistenceMappedSuperclass.png"); - public static final Icon PersistenceRelationship = IconLoader.getIcon("/javaee/persistenceRelationship.png"); - public static final Icon PersistenceUnit = IconLoader.getIcon("/javaee/persistenceUnit.png"); - public static final Icon Remote = IconLoader.getIcon("/javaee/remote.png"); - public static final Icon SessionBean = IconLoader.getIcon("/javaee/sessionBean.png"); - public static final Icon UpdateRunningApplication = IconLoader.getIcon("/javaee/updateRunningApplication.png"); - public static final Icon Web_xml = IconLoader.getIcon("/javaee/web_xml.png"); - public static final Icon WebModule = IconLoader.getIcon("/javaee/webModule.png"); - public static final Icon WebModuleGroup = IconLoader.getIcon("/javaee/webModuleGroup.png"); - public static final Icon WebService = IconLoader.getIcon("/javaee/WebService.png"); - public static final Icon WebServiceClient = IconLoader.getIcon("/javaee/WebServiceClient.png"); - public static final Icon WebToolWindow = IconLoader.getIcon("/javaee/webToolWindow.png"); + public static final Icon Application_xml = IconLoader.getIcon("/javaee/application_xml.png"); // 16x16 + public static final Icon BuildOnFrameDeactivation = IconLoader.getIcon("/javaee/buildOnFrameDeactivation.png"); // 16x16 + public static final Icon DatabaseSchemaImportLegend = IconLoader.getIcon("/javaee/databaseSchemaImportLegend.png"); // 500x20 + public static final Icon DataSourceImport = IconLoader.getIcon("/javaee/dataSourceImport.png"); // 16x16 + public static final Icon DbSchemaImportBig = IconLoader.getIcon("/javaee/dbSchemaImportBig.png"); // 32x32 + public static final Icon Ejb_jar_xml = IconLoader.getIcon("/javaee/ejb-jar_xml.png"); // 16x16 + public static final Icon EjbClass = IconLoader.getIcon("/javaee/ejbClass.png"); // 16x16 + public static final Icon EjbModule = IconLoader.getIcon("/javaee/ejbModule.png"); // 16x16 + public static final Icon EmbeddedAttributeOverlay = IconLoader.getIcon("/javaee/embeddedAttributeOverlay.png"); // 16x16 + public static final Icon EntityBean = IconLoader.getIcon("/javaee/entityBean.png"); // 16x16 + public static final Icon EntityBeanBig = IconLoader.getIcon("/javaee/entityBeanBig.png"); // 24x24 + public static final Icon Home = IconLoader.getIcon("/javaee/home.png"); // 16x16 + public static final Icon InheritedAttributeOverlay = IconLoader.getIcon("/javaee/inheritedAttributeOverlay.png"); // 16x16 + public static final Icon InterceptorClass = IconLoader.getIcon("/javaee/interceptorClass.png"); // 16x16 + public static final Icon InterceptorMethod = IconLoader.getIcon("/javaee/interceptorMethod.png"); // 16x16 + public static final Icon JavaeeAppModule = IconLoader.getIcon("/javaee/JavaeeAppModule.png"); // 16x16 + public static final Icon JpaFacet = IconLoader.getIcon("/javaee/jpaFacet.png"); // 16x16 + public static final Icon Local = IconLoader.getIcon("/javaee/local.png"); // 16x16 + public static final Icon LocalHome = IconLoader.getIcon("/javaee/localHome.png"); // 16x16 + public static final Icon MessageBean = IconLoader.getIcon("/javaee/messageBean.png"); // 16x16 + public static final Icon PersistenceAttribute = IconLoader.getIcon("/javaee/persistenceAttribute.png"); // 16x16 + public static final Icon PersistenceEmbeddable = IconLoader.getIcon("/javaee/persistenceEmbeddable.png"); // 16x16 + public static final Icon PersistenceEntity = IconLoader.getIcon("/javaee/persistenceEntity.png"); // 16x16 + public static final Icon PersistenceEntityListener = IconLoader.getIcon("/javaee/persistenceEntityListener.png"); // 16x16 + public static final Icon PersistenceId = IconLoader.getIcon("/javaee/persistenceId.png"); // 16x16 + public static final Icon PersistenceIdRelationship = IconLoader.getIcon("/javaee/persistenceIdRelationship.png"); // 16x16 + public static final Icon PersistenceMappedSuperclass = IconLoader.getIcon("/javaee/persistenceMappedSuperclass.png"); // 16x16 + public static final Icon PersistenceRelationship = IconLoader.getIcon("/javaee/persistenceRelationship.png"); // 16x16 + public static final Icon PersistenceUnit = IconLoader.getIcon("/javaee/persistenceUnit.png"); // 16x16 + public static final Icon Remote = IconLoader.getIcon("/javaee/remote.png"); // 16x16 + public static final Icon SessionBean = IconLoader.getIcon("/javaee/sessionBean.png"); // 16x16 + public static final Icon UpdateRunningApplication = IconLoader.getIcon("/javaee/updateRunningApplication.png"); // 16x16 + public static final Icon Web_xml = IconLoader.getIcon("/javaee/web_xml.png"); // 16x16 + public static final Icon WebModule = IconLoader.getIcon("/javaee/webModule.png"); // 16x16 + public static final Icon WebModuleGroup = IconLoader.getIcon("/javaee/webModuleGroup.png"); // 16x16 + public static final Icon WebService = IconLoader.getIcon("/javaee/WebService.png"); // 16x16 + public static final Icon WebServiceClient = IconLoader.getIcon("/javaee/WebServiceClient.png"); // 16x16 } public static class Mac { - public static final Icon AppIconOk512 = IconLoader.getIcon("/mac/appIconOk512.png"); - public static final Icon Tree_white_down_arrow = IconLoader.getIcon("/mac/tree_white_down_arrow.png"); - public static final Icon Tree_white_right_arrow = IconLoader.getIcon("/mac/tree_white_right_arrow.png"); + public static final Icon AppIconOk512 = IconLoader.getIcon("/mac/appIconOk512.png"); // 55x55 + public static final Icon Tree_white_down_arrow = IconLoader.getIcon("/mac/tree_white_down_arrow.png"); // 11x11 + public static final Icon Tree_white_right_arrow = IconLoader.getIcon("/mac/tree_white_right_arrow.png"); // 11x11 } public static class Modules { - public static final Icon AddContentEntry = IconLoader.getIcon("/modules/addContentEntry.png"); - public static final Icon Annotation = IconLoader.getIcon("/modules/annotation.png"); - public static final Icon DeleteContentFolder = IconLoader.getIcon("/modules/deleteContentFolder.png"); - public static final Icon DeleteContentFolderRollover = IconLoader.getIcon("/modules/deleteContentFolderRollover.png"); - public static final Icon DeleteContentRoot = IconLoader.getIcon("/modules/deleteContentRoot.png"); - public static final Icon DeleteContentRootRollover = IconLoader.getIcon("/modules/deleteContentRootRollover.png"); - public static final Icon Edit = IconLoader.getIcon("/modules/edit.png"); - public static final Icon ExcludeRootClosed = IconLoader.getIcon("/modules/excludeRootClosed.png"); - public static final Icon ExcludeRootOpened = IconLoader.getIcon("/modules/excludeRootOpened.png"); - public static final Icon Library = IconLoader.getIcon("/modules/library.png"); - public static final Icon Merge = IconLoader.getIcon("/modules/merge.png"); - public static final Icon ModulesNode = IconLoader.getIcon("/modules/modulesNode.png"); - public static final Icon Output = IconLoader.getIcon("/modules/output.png"); - public static final Icon SetPackagePrefix = IconLoader.getIcon("/modules/setPackagePrefix.png"); - public static final Icon SetPackagePrefixRollover = IconLoader.getIcon("/modules/setPackagePrefixRollover.png"); - public static final Icon SourceClosed = IconLoader.getIcon("/modules/sourceClosed.png"); - public static final Icon SourceOpened = IconLoader.getIcon("/modules/sourceOpened.png"); - public static final Icon SourceRootClosed = IconLoader.getIcon("/modules/sourceRootClosed.png"); - public static final Icon SourceRootOpened = IconLoader.getIcon("/modules/sourceRootOpened.png"); - public static final Icon Sources = IconLoader.getIcon("/modules/sources.png"); - public static final Icon Split = IconLoader.getIcon("/modules/split.png"); - public static final Icon TestRootClosed = IconLoader.getIcon("/modules/testRootClosed.png"); - public static final Icon TestRootOpened = IconLoader.getIcon("/modules/testRootOpened.png"); - public static final Icon TestSourceClosed = IconLoader.getIcon("/modules/testSourceClosed.png"); - public static final Icon TestSourceOpened = IconLoader.getIcon("/modules/testSourceOpened.png"); + public static final Icon AddContentEntry = IconLoader.getIcon("/modules/addContentEntry.png"); // 16x16 + public static final Icon Annotation = IconLoader.getIcon("/modules/annotation.png"); // 16x16 + public static final Icon DeleteContentFolder = IconLoader.getIcon("/modules/deleteContentFolder.png"); // 9x9 + public static final Icon DeleteContentFolderRollover = IconLoader.getIcon("/modules/deleteContentFolderRollover.png"); // 9x9 + public static final Icon DeleteContentRoot = IconLoader.getIcon("/modules/deleteContentRoot.png"); // 11x11 + public static final Icon DeleteContentRootRollover = IconLoader.getIcon("/modules/deleteContentRootRollover.png"); // 11x11 + public static final Icon Edit = IconLoader.getIcon("/modules/edit.png"); // 16x16 + public static final Icon ExcludeRootClosed = IconLoader.getIcon("/modules/excludeRootClosed.png"); // 16x16 + public static final Icon ExcludeRootOpened = IconLoader.getIcon("/modules/excludeRootOpened.png"); // 16x16 + public static final Icon Library = IconLoader.getIcon("/modules/library.png"); // 16x16 + public static final Icon Merge = IconLoader.getIcon("/modules/merge.png"); // 16x16 + public static final Icon ModulesNode = IconLoader.getIcon("/modules/modulesNode.png"); // 16x16 + public static final Icon Output = IconLoader.getIcon("/modules/output.png"); // 16x16 + public static final Icon SetPackagePrefix = IconLoader.getIcon("/modules/setPackagePrefix.png"); // 9x9 + public static final Icon SetPackagePrefixRollover = IconLoader.getIcon("/modules/setPackagePrefixRollover.png"); // 9x9 + public static final Icon SourceClosed = IconLoader.getIcon("/modules/sourceClosed.png"); // 16x16 + public static final Icon SourceOpened = IconLoader.getIcon("/modules/sourceOpened.png"); // 16x16 + public static final Icon SourceRootClosed = IconLoader.getIcon("/modules/sourceRootClosed.png"); // 16x16 + public static final Icon SourceRootOpened = IconLoader.getIcon("/modules/sourceRootOpened.png"); // 16x16 + public static final Icon Sources = IconLoader.getIcon("/modules/sources.png"); // 16x16 + public static final Icon Split = IconLoader.getIcon("/modules/split.png"); // 16x16 + public static final Icon TestRootClosed = IconLoader.getIcon("/modules/testRootClosed.png"); // 16x16 + public static final Icon TestRootOpened = IconLoader.getIcon("/modules/testRootOpened.png"); // 16x16 + public static final Icon TestSourceClosed = IconLoader.getIcon("/modules/testSourceClosed.png"); // 16x16 + public static final Icon TestSourceOpened = IconLoader.getIcon("/modules/testSourceOpened.png"); // 16x16 public static class Types { - public static final Icon EjbModule = IconLoader.getIcon("/modules/types/ejbModule.png"); - public static final Icon EmptyProjectType = IconLoader.getIcon("/modules/types/emptyProjectType.png"); - public static final Icon JavaeeAppModule = IconLoader.getIcon("/modules/types/JavaeeAppModule.png"); - public static final Icon JavaModule = IconLoader.getIcon("/modules/types/javaModule.png"); - public static final Icon PluginModule = IconLoader.getIcon("/modules/types/pluginModule.png"); - public static final Icon WebModule = IconLoader.getIcon("/modules/types/webModule.png"); + public static final Icon EjbModule = IconLoader.getIcon("/modules/types/ejbModule.png"); // 24x24 + public static final Icon EmptyProjectType = IconLoader.getIcon("/modules/types/emptyProjectType.png"); // 24x24 + public static final Icon JavaeeAppModule = IconLoader.getIcon("/modules/types/JavaeeAppModule.png"); // 24x24 + public static final Icon JavaModule = IconLoader.getIcon("/modules/types/javaModule.png"); // 24x24 + public static final Icon PluginModule = IconLoader.getIcon("/modules/types/pluginModule.png"); // 24x24 + public static final Icon WebModule = IconLoader.getIcon("/modules/types/webModule.png"); // 24x24 } - public static final Icon UnmarkWebroot = IconLoader.getIcon("/modules/unmarkWebroot.png"); - public static final Icon WebRoot = IconLoader.getIcon("/modules/webRoot.png"); + public static final Icon UnmarkWebroot = IconLoader.getIcon("/modules/unmarkWebroot.png"); // 16x16 + public static final Icon WebRoot = IconLoader.getIcon("/modules/webRoot.png"); // 16x16 } public static class Nodes { - public static final Icon AbstractClass = IconLoader.getIcon("/nodes/abstractClass.png"); - public static final Icon AbstractException = IconLoader.getIcon("/nodes/abstractException.png"); - public static final Icon AbstractMethod = IconLoader.getIcon("/nodes/abstractMethod.png"); - public static final Icon Advice = IconLoader.getIcon("/nodes/advice.png"); - public static final Icon Annotationtype = IconLoader.getIcon("/nodes/annotationtype.png"); - public static final Icon AnonymousClass = IconLoader.getIcon("/nodes/anonymousClass.png"); - public static final Icon Artifact = IconLoader.getIcon("/nodes/artifact.png"); - public static final Icon Aspect = IconLoader.getIcon("/nodes/aspect.png"); - public static final Icon C_plocal = IconLoader.getIcon("/nodes/c_plocal.png"); - public static final Icon C_private = IconLoader.getIcon("/nodes/c_private.png"); - public static final Icon C_protected = IconLoader.getIcon("/nodes/c_protected.png"); - public static final Icon C_public = IconLoader.getIcon("/nodes/c_public.png"); - public static final Icon Class = IconLoader.getIcon("/nodes/class.png"); - public static final Icon ClassInitializer = IconLoader.getIcon("/nodes/classInitializer.png"); - public static final Icon CollapseNode = IconLoader.getIcon("/nodes/collapseNode.png"); - public static final Icon CompiledClassesFolder = IconLoader.getIcon("/nodes/compiledClassesFolder.png"); - public static final Icon CopyOfFolder = IconLoader.getIcon("/nodes/copyOfFolder.png"); - public static final Icon Cvs_global = IconLoader.getIcon("/nodes/cvs_global.png"); - public static final Icon Cvs_roots = IconLoader.getIcon("/nodes/cvs_roots.png"); - public static final Icon DataColumn = IconLoader.getIcon("/nodes/dataColumn.png"); - public static final Icon DataSchema = IconLoader.getIcon("/nodes/dataSchema.png"); - public static final Icon DataSource = IconLoader.getIcon("/nodes/DataSource.png"); - public static final Icon DataTables = IconLoader.getIcon("/nodes/DataTables.png"); - public static final Icon DataView = IconLoader.getIcon("/nodes/dataView.png"); - public static final Icon Deploy = IconLoader.getIcon("/nodes/deploy.png"); - public static final Icon Ejb = IconLoader.getIcon("/nodes/ejb.png"); - public static final Icon EjbBusinessMethod = IconLoader.getIcon("/nodes/ejbBusinessMethod.png"); - public static final Icon EjbCmpField = IconLoader.getIcon("/nodes/ejbCmpField.png"); - public static final Icon EjbCmrField = IconLoader.getIcon("/nodes/ejbCmrField.png"); - public static final Icon EjbCreateMethod = IconLoader.getIcon("/nodes/ejbCreateMethod.png"); - public static final Icon EjbFinderMethod = IconLoader.getIcon("/nodes/ejbFinderMethod.png"); - public static final Icon EjbPrimaryKeyClass = IconLoader.getIcon("/nodes/ejbPrimaryKeyClass.png"); - public static final Icon EjbReference = IconLoader.getIcon("/nodes/ejbReference.png"); - public static final Icon EmptyNode = IconLoader.getIcon("/nodes/emptyNode.png"); - public static final Icon EnterpriseProject = IconLoader.getIcon("/nodes/enterpriseProject.png"); - public static final Icon EntryPoints = IconLoader.getIcon("/nodes/entryPoints.png"); - public static final Icon Enum = IconLoader.getIcon("/nodes/enum.png"); - public static final Icon ErrorIntroduction = IconLoader.getIcon("/nodes/errorIntroduction.png"); - public static final Icon ErrorMark = IconLoader.getIcon("/nodes/errorMark.png"); - public static final Icon ExceptionClass = IconLoader.getIcon("/nodes/exceptionClass.png"); - public static final Icon ExcludedFromCompile = IconLoader.getIcon("/nodes/excludedFromCompile.png"); - public static final Icon ExpandNode = IconLoader.getIcon("/nodes/expandNode.png"); - public static final Icon ExtractedFolder = IconLoader.getIcon("/nodes/extractedFolder.png"); - public static final Icon Field = IconLoader.getIcon("/nodes/field.png"); - public static final Icon FieldPK = IconLoader.getIcon("/nodes/fieldPK.png"); - public static final Icon FinalMark = IconLoader.getIcon("/nodes/finalMark.png"); - public static final Icon Folder = IconLoader.getIcon("/nodes/folder.png"); - public static final Icon FolderOpen = IconLoader.getIcon("/nodes/folderOpen.png"); - public static final Icon Function = IconLoader.getIcon("/nodes/function.png"); - public static final Icon HomeFolder = IconLoader.getIcon("/nodes/homeFolder.png"); - public static final Icon IdeaModule = IconLoader.getIcon("/nodes/ideaModule.png"); - public static final Icon IdeaProject = IconLoader.getIcon("/nodes/ideaProject.png"); - public static final Icon IdeaWorkspace = IconLoader.getIcon("/nodes/ideaWorkspace.png"); - public static final Icon Interface = IconLoader.getIcon("/nodes/interface.png"); - public static final Icon J2eeParameter = IconLoader.getIcon("/nodes/j2eeParameter.png"); - public static final Icon JarDirectory = IconLoader.getIcon("/nodes/jarDirectory.png"); - public static final Icon JavaDocFolder = IconLoader.getIcon("/nodes/javaDocFolder.png"); + public static final Icon AbstractClass = IconLoader.getIcon("/nodes/abstractClass.png"); // 16x16 + public static final Icon AbstractException = IconLoader.getIcon("/nodes/abstractException.png"); // 16x16 + public static final Icon AbstractMethod = IconLoader.getIcon("/nodes/abstractMethod.png"); // 16x16 + public static final Icon Advice = IconLoader.getIcon("/nodes/advice.png"); // 16x16 + public static final Icon Annotationtype = IconLoader.getIcon("/nodes/annotationtype.png"); // 16x16 + public static final Icon AnonymousClass = IconLoader.getIcon("/nodes/anonymousClass.png"); // 16x16 + public static final Icon Artifact = IconLoader.getIcon("/nodes/artifact.png"); // 16x16 + public static final Icon Aspect = IconLoader.getIcon("/nodes/aspect.png"); // 14x14 + public static final Icon C_plocal = IconLoader.getIcon("/nodes/c_plocal.png"); // 16x16 + public static final Icon C_private = IconLoader.getIcon("/nodes/c_private.png"); // 16x16 + public static final Icon C_protected = IconLoader.getIcon("/nodes/c_protected.png"); // 16x16 + public static final Icon C_public = IconLoader.getIcon("/nodes/c_public.png"); // 16x16 + public static final Icon Class = IconLoader.getIcon("/nodes/class.png"); // 16x16 + public static final Icon ClassInitializer = IconLoader.getIcon("/nodes/classInitializer.png"); // 16x16 + public static final Icon CollapseNode = IconLoader.getIcon("/nodes/collapseNode.png"); // 9x9 + public static final Icon CompiledClassesFolder = IconLoader.getIcon("/nodes/compiledClassesFolder.png"); // 16x16 + public static final Icon CopyOfFolder = IconLoader.getIcon("/nodes/copyOfFolder.png"); // 16x16 + public static final Icon Cvs_global = IconLoader.getIcon("/nodes/cvs_global.png"); // 16x16 + public static final Icon Cvs_roots = IconLoader.getIcon("/nodes/cvs_roots.png"); // 16x16 + public static final Icon DataColumn = IconLoader.getIcon("/nodes/dataColumn.png"); // 16x16 + public static final Icon DataSchema = IconLoader.getIcon("/nodes/dataSchema.png"); // 16x16 + public static final Icon DataSource = IconLoader.getIcon("/nodes/DataSource.png"); // 16x16 + public static final Icon DataTables = IconLoader.getIcon("/nodes/DataTables.png"); // 16x16 + public static final Icon DataView = IconLoader.getIcon("/nodes/dataView.png"); // 16x16 + public static final Icon Deploy = IconLoader.getIcon("/nodes/deploy.png"); // 16x16 + public static final Icon Ejb = IconLoader.getIcon("/nodes/ejb.png"); // 16x16 + public static final Icon EjbBusinessMethod = IconLoader.getIcon("/nodes/ejbBusinessMethod.png"); // 16x16 + public static final Icon EjbCmpField = IconLoader.getIcon("/nodes/ejbCmpField.png"); // 16x16 + public static final Icon EjbCmrField = IconLoader.getIcon("/nodes/ejbCmrField.png"); // 16x16 + public static final Icon EjbCreateMethod = IconLoader.getIcon("/nodes/ejbCreateMethod.png"); // 16x16 + public static final Icon EjbFinderMethod = IconLoader.getIcon("/nodes/ejbFinderMethod.png"); // 16x16 + public static final Icon EjbPrimaryKeyClass = IconLoader.getIcon("/nodes/ejbPrimaryKeyClass.png"); // 16x16 + public static final Icon EjbReference = IconLoader.getIcon("/nodes/ejbReference.png"); // 16x16 + public static final Icon EmptyNode = IconLoader.getIcon("/nodes/emptyNode.png"); // 18x18 + public static final Icon EnterpriseProject = IconLoader.getIcon("/nodes/enterpriseProject.png"); // 16x16 + public static final Icon EntryPoints = IconLoader.getIcon("/nodes/entryPoints.png"); // 16x16 + public static final Icon Enum = IconLoader.getIcon("/nodes/enum.png"); // 16x16 + public static final Icon ErrorIntroduction = IconLoader.getIcon("/nodes/errorIntroduction.png"); // 16x16 + public static final Icon ErrorMark = IconLoader.getIcon("/nodes/errorMark.png"); // 16x16 + public static final Icon ExceptionClass = IconLoader.getIcon("/nodes/exceptionClass.png"); // 16x16 + public static final Icon ExcludedFromCompile = IconLoader.getIcon("/nodes/excludedFromCompile.png"); // 16x16 + public static final Icon ExpandNode = IconLoader.getIcon("/nodes/expandNode.png"); // 9x9 + public static final Icon ExtractedFolder = IconLoader.getIcon("/nodes/extractedFolder.png"); // 16x16 + public static final Icon Field = IconLoader.getIcon("/nodes/field.png"); // 16x16 + public static final Icon FieldPK = IconLoader.getIcon("/nodes/fieldPK.png"); // 16x16 + public static final Icon FinalMark = IconLoader.getIcon("/nodes/finalMark.png"); // 16x16 + public static final Icon Folder = IconLoader.getIcon("/nodes/folder.png"); // 16x16 + public static final Icon FolderOpen = IconLoader.getIcon("/nodes/folderOpen.png"); // 16x16 + public static final Icon Function = IconLoader.getIcon("/nodes/function.png"); // 16x16 + public static final Icon HomeFolder = IconLoader.getIcon("/nodes/homeFolder.png"); // 16x16 + public static final Icon IdeaModule = IconLoader.getIcon("/nodes/ideaModule.png"); // 16x16 + public static final Icon IdeaProject = IconLoader.getIcon("/nodes/ideaProject.png"); // 16x16 + public static final Icon IdeaWorkspace = IconLoader.getIcon("/nodes/ideaWorkspace.png"); // 16x16 + public static final Icon Interface = IconLoader.getIcon("/nodes/interface.png"); // 16x16 + public static final Icon J2eeParameter = IconLoader.getIcon("/nodes/j2eeParameter.png"); // 16x16 + public static final Icon JarDirectory = IconLoader.getIcon("/nodes/jarDirectory.png"); // 16x16 + public static final Icon JavaDocFolder = IconLoader.getIcon("/nodes/javaDocFolder.png"); // 16x16 public static class Jsf { - public static final Icon Component = IconLoader.getIcon("/nodes/jsf/component.png"); - public static final Icon Converter = IconLoader.getIcon("/nodes/jsf/converter.png"); - public static final Icon General = IconLoader.getIcon("/nodes/jsf/general.png"); - public static final Icon GenericValue = IconLoader.getIcon("/nodes/jsf/genericValue.png"); - public static final Icon ManagedBean = IconLoader.getIcon("/nodes/jsf/managedBean.png"); - public static final Icon NavigationCase = IconLoader.getIcon("/nodes/jsf/navigationCase.png"); - public static final Icon NavigationRule = IconLoader.getIcon("/nodes/jsf/navigationRule.png"); - public static final Icon Renderer = IconLoader.getIcon("/nodes/jsf/renderer.png"); - public static final Icon RenderKit = IconLoader.getIcon("/nodes/jsf/renderKit.png"); - public static final Icon Validator = IconLoader.getIcon("/nodes/jsf/validator.png"); + public static final Icon Component = IconLoader.getIcon("/nodes/jsf/component.png"); // 16x16 + public static final Icon Converter = IconLoader.getIcon("/nodes/jsf/converter.png"); // 16x16 + public static final Icon General = IconLoader.getIcon("/nodes/jsf/general.png"); // 16x16 + public static final Icon GenericValue = IconLoader.getIcon("/nodes/jsf/genericValue.png"); // 18x18 + public static final Icon ManagedBean = IconLoader.getIcon("/nodes/jsf/managedBean.png"); // 16x16 + public static final Icon NavigationCase = IconLoader.getIcon("/nodes/jsf/navigationCase.png"); // 18x18 + public static final Icon NavigationRule = IconLoader.getIcon("/nodes/jsf/navigationRule.png"); // 16x16 + public static final Icon Renderer = IconLoader.getIcon("/nodes/jsf/renderer.png"); // 16x16 + public static final Icon RenderKit = IconLoader.getIcon("/nodes/jsf/renderKit.png"); // 16x16 + public static final Icon Validator = IconLoader.getIcon("/nodes/jsf/validator.png"); // 16x16 } - public static final Icon Jsr45 = IconLoader.getIcon("/nodes/jsr45.png"); - public static final Icon JunitTestMark = IconLoader.getIcon("/nodes/junitTestMark.png"); - public static final Icon KeymapAnt = IconLoader.getIcon("/nodes/keymapAnt.png"); - public static final Icon KeymapAntOpen = IconLoader.getIcon("/nodes/keymapAntOpen.png"); - public static final Icon KeymapEditor = IconLoader.getIcon("/nodes/keymapEditor.png"); - public static final Icon KeymapEditorOpen = IconLoader.getIcon("/nodes/keymapEditorOpen.png"); - public static final Icon KeymapMainMenu = IconLoader.getIcon("/nodes/keymapMainMenu.png"); - public static final Icon KeymapOther = IconLoader.getIcon("/nodes/keymapOther.png"); - public static final Icon KeymapTools = IconLoader.getIcon("/nodes/keymapTools.png"); - public static final Icon KeymapToolsOpen = IconLoader.getIcon("/nodes/keymapToolsOpen.png"); - public static final Icon Locked = IconLoader.getIcon("/nodes/locked.png"); - public static final Icon Method = IconLoader.getIcon("/nodes/method.png"); - public static final Icon ModuleClosed = IconLoader.getIcon("/nodes/ModuleClosed.png"); - public static final Icon ModuleGroupClosed = IconLoader.getIcon("/nodes/moduleGroupClosed.png"); - public static final Icon ModuleGroupOpen = IconLoader.getIcon("/nodes/moduleGroupOpen.png"); - public static final Icon ModuleOpen = IconLoader.getIcon("/nodes/ModuleOpen.png"); - public static final Icon NewException = IconLoader.getIcon("/nodes/newException.png"); - public static final Icon NewFolder = IconLoader.getIcon("/nodes/newFolder.png"); - public static final Icon NewParameter = IconLoader.getIcon("/nodes/newParameter.png"); - public static final Icon NodePlaceholder = IconLoader.getIcon("/nodes/nodePlaceholder.png"); - public static final Icon PackageClosed = IconLoader.getIcon("/nodes/packageClosed.png"); - public static final Icon PackageOpen = IconLoader.getIcon("/nodes/packageOpen.png"); - public static final Icon Padlock = IconLoader.getIcon("/nodes/padlock.png"); - public static final Icon Parameter = IconLoader.getIcon("/nodes/parameter.png"); - public static final Icon PinToolWindow = IconLoader.getIcon("/nodes/pinToolWindow.png"); - public static final Icon Plugin = IconLoader.getIcon("/nodes/plugin.png"); - public static final Icon Pluginnotinstalled = IconLoader.getIcon("/nodes/pluginnotinstalled.png"); - public static final Icon Pluginobsolete = IconLoader.getIcon("/nodes/pluginobsolete.png"); - public static final Icon Pointcut = IconLoader.getIcon("/nodes/pointcut.png"); - public static final Icon PpFile = IconLoader.getIcon("/nodes/ppFile.png"); - public static final Icon PpInvalid = IconLoader.getIcon("/nodes/ppInvalid.png"); - public static final Icon PpJar = IconLoader.getIcon("/nodes/ppJar.png"); - public static final Icon PpJdkClosed = IconLoader.getIcon("/nodes/ppJdkClosed.png"); - public static final Icon PpJdkOpen = IconLoader.getIcon("/nodes/ppJdkOpen.png"); - public static final Icon PpLib = IconLoader.getIcon("/nodes/ppLib.png"); - public static final Icon PpLibClosed = IconLoader.getIcon("/nodes/ppLibClosed.png"); - public static final Icon PpLibOpen = IconLoader.getIcon("/nodes/ppLibOpen.png"); - public static final Icon PpWeb = IconLoader.getIcon("/nodes/ppWeb.png"); - public static final Icon Project = IconLoader.getIcon("/nodes/project.png"); - public static final Icon Property = IconLoader.getIcon("/nodes/property.png"); - public static final Icon PropertyRead = IconLoader.getIcon("/nodes/propertyRead.png"); - public static final Icon PropertyReadStatic = IconLoader.getIcon("/nodes/propertyReadStatic.png"); - public static final Icon PropertyReadWrite = IconLoader.getIcon("/nodes/propertyReadWrite.png"); - public static final Icon PropertyReadWriteStatic = IconLoader.getIcon("/nodes/propertyReadWriteStatic.png"); - public static final Icon PropertyWrite = IconLoader.getIcon("/nodes/propertyWrite.png"); - public static final Icon PropertyWriteStatic = IconLoader.getIcon("/nodes/propertyWriteStatic.png"); - public static final Icon Read_access = IconLoader.getIcon("/nodes/read-access.png"); - public static final Icon ResourceBundleClosed = IconLoader.getIcon("/nodes/resourceBundleClosed.png"); - public static final Icon ResourceBundleOpen = IconLoader.getIcon("/nodes/resourceBundleOpen.png"); - public static final Icon RunnableMark = IconLoader.getIcon("/nodes/runnableMark.png"); - public static final Icon Rw_access = IconLoader.getIcon("/nodes/rw-access.png"); - public static final Icon SecurityRole = IconLoader.getIcon("/nodes/SecurityRole.png"); - public static final Icon Servlet = IconLoader.getIcon("/nodes/servlet.png"); - public static final Icon SortBySeverity = IconLoader.getIcon("/nodes/sortBySeverity.png"); - public static final Icon SourceFolder = IconLoader.getIcon("/nodes/sourceFolder.png"); - public static final Icon Static = IconLoader.getIcon("/nodes/static.png"); - public static final Icon StaticMark = IconLoader.getIcon("/nodes/staticMark.png"); - public static final Icon Symlink = IconLoader.getIcon("/nodes/symlink.png"); - public static final Icon TabAlert = IconLoader.getIcon("/nodes/tabAlert.png"); - public static final Icon TabPin = IconLoader.getIcon("/nodes/tabPin.png"); - public static final Icon Tag = IconLoader.getIcon("/nodes/tag.png"); - public static final Icon TestSourceFolder = IconLoader.getIcon("/nodes/testSourceFolder.png"); - public static final Icon TreeClosed = IconLoader.getIcon("/nodes/TreeClosed.png"); - public static final Icon TreeOpen = IconLoader.getIcon("/nodes/TreeOpen.png"); - public static final Icon Undeploy = IconLoader.getIcon("/nodes/undeploy.png"); - public static final Icon UnknownJdkClosed = IconLoader.getIcon("/nodes/unknownJdkClosed.png"); - public static final Icon UnknownJdkOpen = IconLoader.getIcon("/nodes/unknownJdkOpen.png"); - public static final Icon UpFolder = IconLoader.getIcon("/nodes/upFolder.png"); - public static final Icon UpLevel = IconLoader.getIcon("/nodes/upLevel.png"); - public static final Icon Variable = IconLoader.getIcon("/nodes/variable.png"); - public static final Icon WarningIntroduction = IconLoader.getIcon("/nodes/warningIntroduction.png"); - public static final Icon WebFolderClosed = IconLoader.getIcon("/nodes/webFolderClosed.png"); - public static final Icon WebFolderOpen = IconLoader.getIcon("/nodes/webFolderOpen.png"); - public static final Icon Weblistener = IconLoader.getIcon("/nodes/weblistener.png"); - public static final Icon Write_access = IconLoader.getIcon("/nodes/write-access.png"); + public static final Icon Jsr45 = IconLoader.getIcon("/nodes/jsr45.png"); // 16x16 + public static final Icon JunitTestMark = IconLoader.getIcon("/nodes/junitTestMark.png"); // 16x16 + public static final Icon KeymapAnt = IconLoader.getIcon("/nodes/keymapAnt.png"); // 16x16 + public static final Icon KeymapAntOpen = IconLoader.getIcon("/nodes/keymapAntOpen.png"); // 16x16 + public static final Icon KeymapEditor = IconLoader.getIcon("/nodes/keymapEditor.png"); // 16x16 + public static final Icon KeymapEditorOpen = IconLoader.getIcon("/nodes/keymapEditorOpen.png"); // 16x16 + public static final Icon KeymapMainMenu = IconLoader.getIcon("/nodes/keymapMainMenu.png"); // 16x16 + public static final Icon KeymapOther = IconLoader.getIcon("/nodes/keymapOther.png"); // 16x16 + public static final Icon KeymapTools = IconLoader.getIcon("/nodes/keymapTools.png"); // 16x16 + public static final Icon KeymapToolsOpen = IconLoader.getIcon("/nodes/keymapToolsOpen.png"); // 16x16 + public static final Icon Locked = IconLoader.getIcon("/nodes/locked.png"); // 16x16 + public static final Icon Method = IconLoader.getIcon("/nodes/method.png"); // 16x16 + public static final Icon ModuleClosed = IconLoader.getIcon("/nodes/ModuleClosed.png"); // 16x16 + public static final Icon ModuleGroupClosed = IconLoader.getIcon("/nodes/moduleGroupClosed.png"); // 16x16 + public static final Icon ModuleGroupOpen = IconLoader.getIcon("/nodes/moduleGroupOpen.png"); // 16x16 + public static final Icon ModuleOpen = IconLoader.getIcon("/nodes/ModuleOpen.png"); // 16x16 + public static final Icon NewException = IconLoader.getIcon("/nodes/newException.png"); // 14x14 + public static final Icon NewFolder = IconLoader.getIcon("/nodes/newFolder.png"); // 16x16 + public static final Icon NewParameter = IconLoader.getIcon("/nodes/newParameter.png"); // 14x14 + public static final Icon NodePlaceholder = IconLoader.getIcon("/nodes/nodePlaceholder.png"); // 16x16 + public static final Icon PackageClosed = IconLoader.getIcon("/nodes/packageClosed.png"); // 16x16 + public static final Icon PackageOpen = IconLoader.getIcon("/nodes/packageOpen.png"); // 16x16 + public static final Icon Padlock = IconLoader.getIcon("/nodes/padlock.png"); // 16x16 + public static final Icon Parameter = IconLoader.getIcon("/nodes/parameter.png"); // 16x16 + public static final Icon PinToolWindow = IconLoader.getIcon("/nodes/pinToolWindow.png"); // 13x13 + public static final Icon Plugin = IconLoader.getIcon("/nodes/plugin.png"); // 16x16 + public static final Icon Pluginnotinstalled = IconLoader.getIcon("/nodes/pluginnotinstalled.png"); // 16x16 + public static final Icon Pluginobsolete = IconLoader.getIcon("/nodes/pluginobsolete.png"); // 16x16 + public static final Icon Pointcut = IconLoader.getIcon("/nodes/pointcut.png"); // 16x16 + public static final Icon PpFile = IconLoader.getIcon("/nodes/ppFile.png"); // 16x16 + public static final Icon PpInvalid = IconLoader.getIcon("/nodes/ppInvalid.png"); // 16x16 + public static final Icon PpJar = IconLoader.getIcon("/nodes/ppJar.png"); // 16x16 + public static final Icon PpJdkClosed = IconLoader.getIcon("/nodes/ppJdkClosed.png"); // 16x16 + public static final Icon PpJdkOpen = IconLoader.getIcon("/nodes/ppJdkOpen.png"); // 16x16 + public static final Icon PpLib = IconLoader.getIcon("/nodes/ppLib.png"); // 16x16 + public static final Icon PpLibClosed = IconLoader.getIcon("/nodes/ppLibClosed.png"); // 16x16 + public static final Icon PpLibOpen = IconLoader.getIcon("/nodes/ppLibOpen.png"); // 16x16 + public static final Icon PpWeb = IconLoader.getIcon("/nodes/ppWeb.png"); // 16x16 + public static final Icon Project = IconLoader.getIcon("/nodes/project.png"); // 16x16 + public static final Icon Property = IconLoader.getIcon("/nodes/property.png"); // 16x16 + public static final Icon PropertyRead = IconLoader.getIcon("/nodes/propertyRead.png"); // 16x16 + public static final Icon PropertyReadStatic = IconLoader.getIcon("/nodes/propertyReadStatic.png"); // 16x16 + public static final Icon PropertyReadWrite = IconLoader.getIcon("/nodes/propertyReadWrite.png"); // 16x16 + public static final Icon PropertyReadWriteStatic = IconLoader.getIcon("/nodes/propertyReadWriteStatic.png"); // 16x16 + public static final Icon PropertyWrite = IconLoader.getIcon("/nodes/propertyWrite.png"); // 16x16 + public static final Icon PropertyWriteStatic = IconLoader.getIcon("/nodes/propertyWriteStatic.png"); // 16x16 + public static final Icon Read_access = IconLoader.getIcon("/nodes/read-access.png"); // 13x9 + public static final Icon ResourceBundleClosed = IconLoader.getIcon("/nodes/resourceBundleClosed.png"); // 16x16 + public static final Icon ResourceBundleOpen = IconLoader.getIcon("/nodes/resourceBundleOpen.png"); // 16x16 + public static final Icon RunnableMark = IconLoader.getIcon("/nodes/runnableMark.png"); // 16x16 + public static final Icon Rw_access = IconLoader.getIcon("/nodes/rw-access.png"); // 13x9 + public static final Icon SecurityRole = IconLoader.getIcon("/nodes/SecurityRole.png"); // 16x16 + public static final Icon Servlet = IconLoader.getIcon("/nodes/servlet.png"); // 16x16 + public static final Icon SortBySeverity = IconLoader.getIcon("/nodes/sortBySeverity.png"); // 16x16 + public static final Icon SourceFolder = IconLoader.getIcon("/nodes/sourceFolder.png"); // 16x16 + public static final Icon Static = IconLoader.getIcon("/nodes/static.png"); // 16x16 + public static final Icon StaticMark = IconLoader.getIcon("/nodes/staticMark.png"); // 16x16 + public static final Icon Symlink = IconLoader.getIcon("/nodes/symlink.png"); // 16x16 + public static final Icon TabAlert = IconLoader.getIcon("/nodes/tabAlert.png"); // 16x16 + public static final Icon TabPin = IconLoader.getIcon("/nodes/tabPin.png"); // 16x16 + public static final Icon Tag = IconLoader.getIcon("/nodes/tag.png"); // 16x16 + public static final Icon TestSourceFolder = IconLoader.getIcon("/nodes/testSourceFolder.png"); // 16x16 + public static final Icon TreeClosed = IconLoader.getIcon("/nodes/TreeClosed.png"); // 16x16 + public static final Icon TreeOpen = IconLoader.getIcon("/nodes/TreeOpen.png"); // 16x16 + public static final Icon Undeploy = IconLoader.getIcon("/nodes/undeploy.png"); // 16x16 + public static final Icon UnknownJdkClosed = IconLoader.getIcon("/nodes/unknownJdkClosed.png"); // 16x16 + public static final Icon UnknownJdkOpen = IconLoader.getIcon("/nodes/unknownJdkOpen.png"); // 16x16 + public static final Icon UpFolder = IconLoader.getIcon("/nodes/upFolder.png"); // 16x16 + public static final Icon UpLevel = IconLoader.getIcon("/nodes/upLevel.png"); // 16x16 + public static final Icon Variable = IconLoader.getIcon("/nodes/variable.png"); // 16x16 + public static final Icon WarningIntroduction = IconLoader.getIcon("/nodes/warningIntroduction.png"); // 16x16 + public static final Icon WebFolderClosed = IconLoader.getIcon("/nodes/webFolderClosed.png"); // 16x16 + public static final Icon WebFolderOpen = IconLoader.getIcon("/nodes/webFolderOpen.png"); // 16x16 + public static final Icon Weblistener = IconLoader.getIcon("/nodes/weblistener.png"); // 16x16 + public static final Icon Write_access = IconLoader.getIcon("/nodes/write-access.png"); // 13x9 } public static class ObjectBrowser { - public static final Icon AbbreviatePackageNames = IconLoader.getIcon("/objectBrowser/abbreviatePackageNames.png"); - public static final Icon Browser = IconLoader.getIcon("/objectBrowser/browser.png"); - public static final Icon CompactEmptyPackages = IconLoader.getIcon("/objectBrowser/compactEmptyPackages.png"); - public static final Icon FlattenPackages = IconLoader.getIcon("/objectBrowser/flattenPackages.png"); - public static final Icon ShowEditorHighlighting = IconLoader.getIcon("/objectBrowser/showEditorHighlighting.png"); - public static final Icon ShowLibraryContents = IconLoader.getIcon("/objectBrowser/showLibraryContents.png"); - public static final Icon ShowMembers = IconLoader.getIcon("/objectBrowser/showMembers.png"); - public static final Icon ShowModules = IconLoader.getIcon("/objectBrowser/showModules.png"); - public static final Icon SortByType = IconLoader.getIcon("/objectBrowser/sortByType.png"); - public static final Icon Sorted = IconLoader.getIcon("/objectBrowser/sorted.png"); - public static final Icon VisibilitySort = IconLoader.getIcon("/objectBrowser/visibilitySort.png"); + public static final Icon AbbreviatePackageNames = IconLoader.getIcon("/objectBrowser/abbreviatePackageNames.png"); // 16x16 + public static final Icon Browser = IconLoader.getIcon("/objectBrowser/browser.png"); // 16x16 + public static final Icon CompactEmptyPackages = IconLoader.getIcon("/objectBrowser/compactEmptyPackages.png"); // 16x16 + public static final Icon FlattenPackages = IconLoader.getIcon("/objectBrowser/flattenPackages.png"); // 16x16 + public static final Icon ShowEditorHighlighting = IconLoader.getIcon("/objectBrowser/showEditorHighlighting.png"); // 16x16 + public static final Icon ShowLibraryContents = IconLoader.getIcon("/objectBrowser/showLibraryContents.png"); // 16x16 + public static final Icon ShowMembers = IconLoader.getIcon("/objectBrowser/showMembers.png"); // 16x16 + public static final Icon ShowModules = IconLoader.getIcon("/objectBrowser/showModules.png"); // 16x16 + public static final Icon SortByType = IconLoader.getIcon("/objectBrowser/sortByType.png"); // 16x16 + public static final Icon Sorted = IconLoader.getIcon("/objectBrowser/sorted.png"); // 16x16 + public static final Icon VisibilitySort = IconLoader.getIcon("/objectBrowser/visibilitySort.png"); // 16x16 } public static class Process { public static class Big { - public static final Icon Step_1 = IconLoader.getIcon("/process/big/step_1.png"); - public static final Icon Step_10 = IconLoader.getIcon("/process/big/step_10.png"); - public static final Icon Step_11 = IconLoader.getIcon("/process/big/step_11.png"); - public static final Icon Step_12 = IconLoader.getIcon("/process/big/step_12.png"); - public static final Icon Step_2 = IconLoader.getIcon("/process/big/step_2.png"); - public static final Icon Step_3 = IconLoader.getIcon("/process/big/step_3.png"); - public static final Icon Step_4 = IconLoader.getIcon("/process/big/step_4.png"); - public static final Icon Step_5 = IconLoader.getIcon("/process/big/step_5.png"); - public static final Icon Step_6 = IconLoader.getIcon("/process/big/step_6.png"); - public static final Icon Step_7 = IconLoader.getIcon("/process/big/step_7.png"); - public static final Icon Step_8 = IconLoader.getIcon("/process/big/step_8.png"); - public static final Icon Step_9 = IconLoader.getIcon("/process/big/step_9.png"); - public static final Icon Step_passive = IconLoader.getIcon("/process/big/step_passive.png"); + public static final Icon Step_1 = IconLoader.getIcon("/process/big/step_1.png"); // 32x32 + public static final Icon Step_10 = IconLoader.getIcon("/process/big/step_10.png"); // 32x32 + public static final Icon Step_11 = IconLoader.getIcon("/process/big/step_11.png"); // 32x32 + public static final Icon Step_12 = IconLoader.getIcon("/process/big/step_12.png"); // 32x32 + public static final Icon Step_2 = IconLoader.getIcon("/process/big/step_2.png"); // 32x32 + public static final Icon Step_3 = IconLoader.getIcon("/process/big/step_3.png"); // 32x32 + public static final Icon Step_4 = IconLoader.getIcon("/process/big/step_4.png"); // 32x32 + public static final Icon Step_5 = IconLoader.getIcon("/process/big/step_5.png"); // 32x32 + public static final Icon Step_6 = IconLoader.getIcon("/process/big/step_6.png"); // 32x32 + public static final Icon Step_7 = IconLoader.getIcon("/process/big/step_7.png"); // 32x32 + public static final Icon Step_8 = IconLoader.getIcon("/process/big/step_8.png"); // 32x32 + public static final Icon Step_9 = IconLoader.getIcon("/process/big/step_9.png"); // 32x32 + public static final Icon Step_passive = IconLoader.getIcon("/process/big/step_passive.png"); // 32x32 } - public static final Icon DisabledDebug = IconLoader.getIcon("/process/disabledDebug.png"); - public static final Icon DisabledRun = IconLoader.getIcon("/process/disabledRun.png"); + public static final Icon DisabledDebug = IconLoader.getIcon("/process/disabledDebug.png"); // 13x13 + public static final Icon DisabledRun = IconLoader.getIcon("/process/disabledRun.png"); // 13x13 public static class FS { - public static final Icon Step_1 = IconLoader.getIcon("/process/fs/step_1.png"); - public static final Icon Step_10 = IconLoader.getIcon("/process/fs/step_10.png"); - public static final Icon Step_11 = IconLoader.getIcon("/process/fs/step_11.png"); - public static final Icon Step_12 = IconLoader.getIcon("/process/fs/step_12.png"); - public static final Icon Step_13 = IconLoader.getIcon("/process/fs/step_13.png"); - public static final Icon Step_14 = IconLoader.getIcon("/process/fs/step_14.png"); - public static final Icon Step_15 = IconLoader.getIcon("/process/fs/step_15.png"); - public static final Icon Step_16 = IconLoader.getIcon("/process/fs/step_16.png"); - public static final Icon Step_17 = IconLoader.getIcon("/process/fs/step_17.png"); - public static final Icon Step_18 = IconLoader.getIcon("/process/fs/step_18.png"); - public static final Icon Step_2 = IconLoader.getIcon("/process/fs/step_2.png"); - public static final Icon Step_3 = IconLoader.getIcon("/process/fs/step_3.png"); - public static final Icon Step_4 = IconLoader.getIcon("/process/fs/step_4.png"); - public static final Icon Step_5 = IconLoader.getIcon("/process/fs/step_5.png"); - public static final Icon Step_6 = IconLoader.getIcon("/process/fs/step_6.png"); - public static final Icon Step_7 = IconLoader.getIcon("/process/fs/step_7.png"); - public static final Icon Step_8 = IconLoader.getIcon("/process/fs/step_8.png"); - public static final Icon Step_9 = IconLoader.getIcon("/process/fs/step_9.png"); - public static final Icon Step_mask = IconLoader.getIcon("/process/fs/step_mask.png"); - public static final Icon Step_passive = IconLoader.getIcon("/process/fs/step_passive.png"); + public static final Icon Step_1 = IconLoader.getIcon("/process/fs/step_1.png"); // 16x16 + public static final Icon Step_10 = IconLoader.getIcon("/process/fs/step_10.png"); // 16x16 + public static final Icon Step_11 = IconLoader.getIcon("/process/fs/step_11.png"); // 16x16 + public static final Icon Step_12 = IconLoader.getIcon("/process/fs/step_12.png"); // 16x16 + public static final Icon Step_13 = IconLoader.getIcon("/process/fs/step_13.png"); // 16x16 + public static final Icon Step_14 = IconLoader.getIcon("/process/fs/step_14.png"); // 16x16 + public static final Icon Step_15 = IconLoader.getIcon("/process/fs/step_15.png"); // 16x16 + public static final Icon Step_16 = IconLoader.getIcon("/process/fs/step_16.png"); // 16x16 + public static final Icon Step_17 = IconLoader.getIcon("/process/fs/step_17.png"); // 16x16 + public static final Icon Step_18 = IconLoader.getIcon("/process/fs/step_18.png"); // 16x16 + public static final Icon Step_2 = IconLoader.getIcon("/process/fs/step_2.png"); // 16x16 + public static final Icon Step_3 = IconLoader.getIcon("/process/fs/step_3.png"); // 16x16 + public static final Icon Step_4 = IconLoader.getIcon("/process/fs/step_4.png"); // 16x16 + public static final Icon Step_5 = IconLoader.getIcon("/process/fs/step_5.png"); // 16x16 + public static final Icon Step_6 = IconLoader.getIcon("/process/fs/step_6.png"); // 16x16 + public static final Icon Step_7 = IconLoader.getIcon("/process/fs/step_7.png"); // 16x16 + public static final Icon Step_8 = IconLoader.getIcon("/process/fs/step_8.png"); // 16x16 + public static final Icon Step_9 = IconLoader.getIcon("/process/fs/step_9.png"); // 16x16 + public static final Icon Step_mask = IconLoader.getIcon("/process/fs/step_mask.png"); // 16x16 + public static final Icon Step_passive = IconLoader.getIcon("/process/fs/step_passive.png"); // 16x16 } - public static final Icon Step_1 = IconLoader.getIcon("/process/step_1.png"); - public static final Icon Step_10 = IconLoader.getIcon("/process/step_10.png"); - public static final Icon Step_11 = IconLoader.getIcon("/process/step_11.png"); - public static final Icon Step_12 = IconLoader.getIcon("/process/step_12.png"); - public static final Icon Step_2 = IconLoader.getIcon("/process/step_2.png"); - public static final Icon Step_3 = IconLoader.getIcon("/process/step_3.png"); - public static final Icon Step_4 = IconLoader.getIcon("/process/step_4.png"); - public static final Icon Step_5 = IconLoader.getIcon("/process/step_5.png"); - public static final Icon Step_6 = IconLoader.getIcon("/process/step_6.png"); - public static final Icon Step_7 = IconLoader.getIcon("/process/step_7.png"); - public static final Icon Step_8 = IconLoader.getIcon("/process/step_8.png"); - public static final Icon Step_9 = IconLoader.getIcon("/process/step_9.png"); - public static final Icon Step_mask = IconLoader.getIcon("/process/step_mask.png"); - public static final Icon Step_passive = IconLoader.getIcon("/process/step_passive.png"); - public static final Icon Stop = IconLoader.getIcon("/process/stop.png"); - public static final Icon StopHovered = IconLoader.getIcon("/process/stopHovered.png"); + public static final Icon Step_1 = IconLoader.getIcon("/process/step_1.png"); // 16x16 + public static final Icon Step_10 = IconLoader.getIcon("/process/step_10.png"); // 16x16 + public static final Icon Step_11 = IconLoader.getIcon("/process/step_11.png"); // 16x16 + public static final Icon Step_12 = IconLoader.getIcon("/process/step_12.png"); // 16x16 + public static final Icon Step_2 = IconLoader.getIcon("/process/step_2.png"); // 16x16 + public static final Icon Step_3 = IconLoader.getIcon("/process/step_3.png"); // 16x16 + public static final Icon Step_4 = IconLoader.getIcon("/process/step_4.png"); // 16x16 + public static final Icon Step_5 = IconLoader.getIcon("/process/step_5.png"); // 16x16 + public static final Icon Step_6 = IconLoader.getIcon("/process/step_6.png"); // 16x16 + public static final Icon Step_7 = IconLoader.getIcon("/process/step_7.png"); // 16x16 + public static final Icon Step_8 = IconLoader.getIcon("/process/step_8.png"); // 16x16 + public static final Icon Step_9 = IconLoader.getIcon("/process/step_9.png"); // 16x16 + public static final Icon Step_mask = IconLoader.getIcon("/process/step_mask.png"); // 16x16 + public static final Icon Step_passive = IconLoader.getIcon("/process/step_passive.png"); // 16x16 + public static final Icon Stop = IconLoader.getIcon("/process/stop.png"); // 16x16 + public static final Icon StopHovered = IconLoader.getIcon("/process/stopHovered.png"); // 16x16 } public static class Providers { - public static final Icon Apache = IconLoader.getIcon("/providers/apache.png"); - public static final Icon Bea = IconLoader.getIcon("/providers/bea.png"); - public static final Icon Cvs = IconLoader.getIcon("/providers/cvs.png"); - public static final Icon Eclipse = IconLoader.getIcon("/providers/eclipse.png"); - public static final Icon Hibernate = IconLoader.getIcon("/providers/hibernate.png"); - public static final Icon Ibm = IconLoader.getIcon("/providers/ibm.png"); - public static final Icon Microsoft = IconLoader.getIcon("/providers/microsoft.png"); - public static final Icon Mysql = IconLoader.getIcon("/providers/mysql.png"); - public static final Icon Oracle = IconLoader.getIcon("/providers/oracle.png"); - public static final Icon Postgresql = IconLoader.getIcon("/providers/postgresql.png"); - public static final Icon Sqlite = IconLoader.getIcon("/providers/sqlite.png"); - public static final Icon Sun = IconLoader.getIcon("/providers/sun.png"); + public static final Icon Apache = IconLoader.getIcon("/providers/apache.png"); // 16x16 + public static final Icon Bea = IconLoader.getIcon("/providers/bea.png"); // 16x16 + public static final Icon Cvs = IconLoader.getIcon("/providers/cvs.png"); // 13x13 + public static final Icon Eclipse = IconLoader.getIcon("/providers/eclipse.png"); // 16x16 + public static final Icon Hibernate = IconLoader.getIcon("/providers/hibernate.png"); // 16x16 + public static final Icon Ibm = IconLoader.getIcon("/providers/ibm.png"); // 16x16 + public static final Icon Microsoft = IconLoader.getIcon("/providers/microsoft.png"); // 16x16 + public static final Icon Mysql = IconLoader.getIcon("/providers/mysql.png"); // 16x16 + public static final Icon Oracle = IconLoader.getIcon("/providers/oracle.png"); // 16x16 + public static final Icon Postgresql = IconLoader.getIcon("/providers/postgresql.png"); // 16x16 + public static final Icon Sqlite = IconLoader.getIcon("/providers/sqlite.png"); // 16x16 + public static final Icon Sun = IconLoader.getIcon("/providers/sun.png"); // 16x16 } public static class RunConfigurations { - public static final Icon Applet = IconLoader.getIcon("/runConfigurations/applet.png"); - public static final Icon Application = IconLoader.getIcon("/runConfigurations/application.png"); - public static final Icon ConfigurationWarning = IconLoader.getIcon("/runConfigurations/configurationWarning.png"); - public static final Icon HidePassed = IconLoader.getIcon("/runConfigurations/hidePassed.png"); - public static final Icon IgnoredTest = IconLoader.getIcon("/runConfigurations/ignoredTest.png"); - public static final Icon InvalidConfigurationLayer = IconLoader.getIcon("/runConfigurations/invalidConfigurationLayer.png"); - public static final Icon Junit = IconLoader.getIcon("/runConfigurations/junit.png"); - public static final Icon LoadingTree = IconLoader.getIcon("/runConfigurations/loadingTree.png"); - public static final Icon Ql_console = IconLoader.getIcon("/runConfigurations/ql_console.png"); - public static final Icon Remote = IconLoader.getIcon("/runConfigurations/remote.png"); - public static final Icon RerunFailedTests = IconLoader.getIcon("/runConfigurations/rerunFailedTests.png"); - public static final Icon SaveTempConfig = IconLoader.getIcon("/runConfigurations/saveTempConfig.png"); - public static final Icon Scroll_down = IconLoader.getIcon("/runConfigurations/scroll_down.png"); - public static final Icon ScrollToStackTrace = IconLoader.getIcon("/runConfigurations/scrollToStackTrace.png"); - public static final Icon SelectFirstDefect = IconLoader.getIcon("/runConfigurations/selectFirstDefect.png"); - public static final Icon SourceAtException = IconLoader.getIcon("/runConfigurations/sourceAtException.png"); - public static final Icon TestError = IconLoader.getIcon("/runConfigurations/testError.png"); - public static final Icon TestFailed = IconLoader.getIcon("/runConfigurations/testFailed.png"); - public static final Icon TestIgnored = IconLoader.getIcon("/runConfigurations/testIgnored.png"); - public static final Icon TestInProgress1 = IconLoader.getIcon("/runConfigurations/testInProgress1.png"); - public static final Icon TestInProgress2 = IconLoader.getIcon("/runConfigurations/testInProgress2.png"); - public static final Icon TestInProgress3 = IconLoader.getIcon("/runConfigurations/testInProgress3.png"); - public static final Icon TestInProgress4 = IconLoader.getIcon("/runConfigurations/testInProgress4.png"); - public static final Icon TestInProgress5 = IconLoader.getIcon("/runConfigurations/testInProgress5.png"); - public static final Icon TestInProgress6 = IconLoader.getIcon("/runConfigurations/testInProgress6.png"); - public static final Icon TestInProgress7 = IconLoader.getIcon("/runConfigurations/testInProgress7.png"); - public static final Icon TestInProgress8 = IconLoader.getIcon("/runConfigurations/testInProgress8.png"); - public static final Icon TestMark = IconLoader.getIcon("/runConfigurations/testMark.png"); - public static final Icon TestNotRan = IconLoader.getIcon("/runConfigurations/testNotRan.png"); - public static final Icon TestPassed = IconLoader.getIcon("/runConfigurations/testPassed.png"); - public static final Icon TestPaused = IconLoader.getIcon("/runConfigurations/testPaused.png"); - public static final Icon TestSkipped = IconLoader.getIcon("/runConfigurations/testSkipped.png"); - public static final Icon TestTerminated = IconLoader.getIcon("/runConfigurations/testTerminated.png"); - public static final Icon Tomcat = IconLoader.getIcon("/runConfigurations/tomcat.png"); - public static final Icon TrackCoverage = IconLoader.getIcon("/runConfigurations/trackCoverage.png"); - public static final Icon TrackTests = IconLoader.getIcon("/runConfigurations/trackTests.png"); - public static final Icon Unknown = IconLoader.getIcon("/runConfigurations/unknown.png"); - public static final Icon Variables = IconLoader.getIcon("/runConfigurations/variables.png"); - public static final Icon Web_app = IconLoader.getIcon("/runConfigurations/web_app.png"); - public static final Icon WithCoverageLayer = IconLoader.getIcon("/runConfigurations/withCoverageLayer.png"); + public static final Icon Applet = IconLoader.getIcon("/runConfigurations/applet.png"); // 16x16 + public static final Icon Application = IconLoader.getIcon("/runConfigurations/application.png"); // 16x16 + public static final Icon ConfigurationWarning = IconLoader.getIcon("/runConfigurations/configurationWarning.png"); // 16x16 + public static final Icon HidePassed = IconLoader.getIcon("/runConfigurations/hidePassed.png"); // 16x16 + public static final Icon IgnoredTest = IconLoader.getIcon("/runConfigurations/ignoredTest.png"); // 16x16 + public static final Icon InvalidConfigurationLayer = IconLoader.getIcon("/runConfigurations/invalidConfigurationLayer.png"); // 16x16 + public static final Icon Junit = IconLoader.getIcon("/runConfigurations/junit.png"); // 16x16 + public static final Icon LoadingTree = IconLoader.getIcon("/runConfigurations/loadingTree.png"); // 16x16 + public static final Icon Ql_console = IconLoader.getIcon("/runConfigurations/ql_console.png"); // 16x16 + public static final Icon Remote = IconLoader.getIcon("/runConfigurations/remote.png"); // 16x16 + public static final Icon RerunFailedTests = IconLoader.getIcon("/runConfigurations/rerunFailedTests.png"); // 16x16 + public static final Icon SaveTempConfig = IconLoader.getIcon("/runConfigurations/saveTempConfig.png"); // 16x16 + public static final Icon Scroll_down = IconLoader.getIcon("/runConfigurations/scroll_down.png"); // 16x16 + public static final Icon ScrollToStackTrace = IconLoader.getIcon("/runConfigurations/scrollToStackTrace.png"); // 16x16 + public static final Icon SelectFirstDefect = IconLoader.getIcon("/runConfigurations/selectFirstDefect.png"); // 16x16 + public static final Icon SourceAtException = IconLoader.getIcon("/runConfigurations/sourceAtException.png"); // 16x16 + public static final Icon TestError = IconLoader.getIcon("/runConfigurations/testError.png"); // 16x16 + public static final Icon TestFailed = IconLoader.getIcon("/runConfigurations/testFailed.png"); // 16x16 + public static final Icon TestIgnored = IconLoader.getIcon("/runConfigurations/testIgnored.png"); // 16x16 + public static final Icon TestInProgress1 = IconLoader.getIcon("/runConfigurations/testInProgress1.png"); // 16x16 + public static final Icon TestInProgress2 = IconLoader.getIcon("/runConfigurations/testInProgress2.png"); // 16x16 + public static final Icon TestInProgress3 = IconLoader.getIcon("/runConfigurations/testInProgress3.png"); // 16x16 + public static final Icon TestInProgress4 = IconLoader.getIcon("/runConfigurations/testInProgress4.png"); // 16x16 + public static final Icon TestInProgress5 = IconLoader.getIcon("/runConfigurations/testInProgress5.png"); // 16x16 + public static final Icon TestInProgress6 = IconLoader.getIcon("/runConfigurations/testInProgress6.png"); // 16x16 + public static final Icon TestInProgress7 = IconLoader.getIcon("/runConfigurations/testInProgress7.png"); // 16x16 + public static final Icon TestInProgress8 = IconLoader.getIcon("/runConfigurations/testInProgress8.png"); // 16x16 + public static final Icon TestMark = IconLoader.getIcon("/runConfigurations/testMark.png"); // 16x16 + public static final Icon TestNotRan = IconLoader.getIcon("/runConfigurations/testNotRan.png"); // 16x16 + public static final Icon TestPassed = IconLoader.getIcon("/runConfigurations/testPassed.png"); // 16x16 + public static final Icon TestPaused = IconLoader.getIcon("/runConfigurations/testPaused.png"); // 16x16 + public static final Icon TestSkipped = IconLoader.getIcon("/runConfigurations/testSkipped.png"); // 16x16 + public static final Icon TestTerminated = IconLoader.getIcon("/runConfigurations/testTerminated.png"); // 16x16 + public static final Icon Tomcat = IconLoader.getIcon("/runConfigurations/tomcat.png"); // 16x16 + public static final Icon TrackCoverage = IconLoader.getIcon("/runConfigurations/trackCoverage.png"); // 16x16 + public static final Icon TrackTests = IconLoader.getIcon("/runConfigurations/trackTests.png"); // 16x16 + public static final Icon Unknown = IconLoader.getIcon("/runConfigurations/unknown.png"); // 16x16 + public static final Icon Variables = IconLoader.getIcon("/runConfigurations/variables.png"); // 16x16 + public static final Icon Web_app = IconLoader.getIcon("/runConfigurations/web_app.png"); // 16x16 + public static final Icon WithCoverageLayer = IconLoader.getIcon("/runConfigurations/withCoverageLayer.png"); // 16x16 } public static class Toolbar { - public static final Icon Filterdups = IconLoader.getIcon("/toolbar/filterdups.png"); - public static final Icon Folders = IconLoader.getIcon("/toolbar/folders.png"); - public static final Icon Unknown = IconLoader.getIcon("/toolbar/unknown.png"); + public static final Icon Filterdups = IconLoader.getIcon("/toolbar/filterdups.png"); // 16x16 + public static final Icon Folders = IconLoader.getIcon("/toolbar/folders.png"); // 16x16 + public static final Icon Unknown = IconLoader.getIcon("/toolbar/unknown.png"); // 16x16 } public static class ToolbarDecorator { - public static final Icon Add = IconLoader.getIcon("/toolbarDecorator/add.png"); - public static final Icon AddBlankLine = IconLoader.getIcon("/toolbarDecorator/addBlankLine.png"); - public static final Icon AddClass = IconLoader.getIcon("/toolbarDecorator/addClass.png"); - public static final Icon AddFolder = IconLoader.getIcon("/toolbarDecorator/addFolder.png"); - public static final Icon AddIcon = IconLoader.getIcon("/toolbarDecorator/addIcon.png"); - public static final Icon AddJira = IconLoader.getIcon("/toolbarDecorator/addJira.png"); - public static final Icon AddLink = IconLoader.getIcon("/toolbarDecorator/addLink.png"); - public static final Icon AddPackage = IconLoader.getIcon("/toolbarDecorator/addPackage.png"); - public static final Icon AddPattern = IconLoader.getIcon("/toolbarDecorator/addPattern.png"); - public static final Icon AddRemoteDatasource = IconLoader.getIcon("/toolbarDecorator/addRemoteDatasource.png"); - public static final Icon AddYouTrack = IconLoader.getIcon("/toolbarDecorator/addYouTrack.png"); - public static final Icon Analyze = IconLoader.getIcon("/toolbarDecorator/analyze.png"); - public static final Icon Edit = IconLoader.getIcon("/toolbarDecorator/edit.png"); - public static final Icon Export = IconLoader.getIcon("/toolbarDecorator/export.png"); - public static final Icon Import = IconLoader.getIcon("/toolbarDecorator/import.png"); + public static final Icon Add = IconLoader.getIcon("/toolbarDecorator/add.png"); // 14x14 + public static final Icon AddBlankLine = IconLoader.getIcon("/toolbarDecorator/addBlankLine.png"); // 16x16 + public static final Icon AddClass = IconLoader.getIcon("/toolbarDecorator/addClass.png"); // 16x16 + public static final Icon AddFolder = IconLoader.getIcon("/toolbarDecorator/addFolder.png"); // 16x16 + public static final Icon AddIcon = IconLoader.getIcon("/toolbarDecorator/addIcon.png"); // 16x16 + public static final Icon AddJira = IconLoader.getIcon("/toolbarDecorator/addJira.png"); // 16x16 + public static final Icon AddLink = IconLoader.getIcon("/toolbarDecorator/addLink.png"); // 16x16 + public static final Icon AddPackage = IconLoader.getIcon("/toolbarDecorator/addPackage.png"); // 16x16 + public static final Icon AddPattern = IconLoader.getIcon("/toolbarDecorator/addPattern.png"); // 16x16 + public static final Icon AddRemoteDatasource = IconLoader.getIcon("/toolbarDecorator/addRemoteDatasource.png"); // 16x16 + public static final Icon AddYouTrack = IconLoader.getIcon("/toolbarDecorator/addYouTrack.png"); // 16x16 + public static final Icon Analyze = IconLoader.getIcon("/toolbarDecorator/analyze.png"); // 14x14 + public static final Icon Edit = IconLoader.getIcon("/toolbarDecorator/edit.png"); // 14x14 + public static final Icon Export = IconLoader.getIcon("/toolbarDecorator/export.png"); // 16x16 + public static final Icon Import = IconLoader.getIcon("/toolbarDecorator/import.png"); // 16x16 public static class Mac { - public static final Icon Add = IconLoader.getIcon("/toolbarDecorator/mac/add.png"); - public static final Icon AddBlankLine = IconLoader.getIcon("/toolbarDecorator/mac/addBlankLine.png"); - public static final Icon AddClass = IconLoader.getIcon("/toolbarDecorator/mac/addClass.png"); - public static final Icon AddFolder = IconLoader.getIcon("/toolbarDecorator/mac/addFolder.png"); - public static final Icon AddIcon = IconLoader.getIcon("/toolbarDecorator/mac/addIcon.png"); - public static final Icon AddJira = IconLoader.getIcon("/toolbarDecorator/mac/addJira.png"); - public static final Icon AddLink = IconLoader.getIcon("/toolbarDecorator/mac/addLink.png"); - public static final Icon AddPackage = IconLoader.getIcon("/toolbarDecorator/mac/addPackage.png"); - public static final Icon AddPattern = IconLoader.getIcon("/toolbarDecorator/mac/addPattern.png"); - public static final Icon AddYouTrack = IconLoader.getIcon("/toolbarDecorator/mac/addYouTrack.png"); - public static final Icon Analyze = IconLoader.getIcon("/toolbarDecorator/mac/analyze.png"); - public static final Icon Edit = IconLoader.getIcon("/toolbarDecorator/mac/edit.png"); - public static final Icon MoveDown = IconLoader.getIcon("/toolbarDecorator/mac/moveDown.png"); - public static final Icon MoveUp = IconLoader.getIcon("/toolbarDecorator/mac/moveUp.png"); - public static final Icon Remove = IconLoader.getIcon("/toolbarDecorator/mac/remove.png"); + public static final Icon Add = IconLoader.getIcon("/toolbarDecorator/mac/add.png"); // 14x14 + public static final Icon AddBlankLine = IconLoader.getIcon("/toolbarDecorator/mac/addBlankLine.png"); // 16x16 + public static final Icon AddClass = IconLoader.getIcon("/toolbarDecorator/mac/addClass.png"); // 16x16 + public static final Icon AddFolder = IconLoader.getIcon("/toolbarDecorator/mac/addFolder.png"); // 16x16 + public static final Icon AddIcon = IconLoader.getIcon("/toolbarDecorator/mac/addIcon.png"); // 16x16 + public static final Icon AddJira = IconLoader.getIcon("/toolbarDecorator/mac/addJira.png"); // 16x16 + public static final Icon AddLink = IconLoader.getIcon("/toolbarDecorator/mac/addLink.png"); // 16x16 + public static final Icon AddPackage = IconLoader.getIcon("/toolbarDecorator/mac/addPackage.png"); // 16x16 + public static final Icon AddPattern = IconLoader.getIcon("/toolbarDecorator/mac/addPattern.png"); // 16x16 + public static final Icon AddYouTrack = IconLoader.getIcon("/toolbarDecorator/mac/addYouTrack.png"); // 16x16 + public static final Icon Analyze = IconLoader.getIcon("/toolbarDecorator/mac/analyze.png"); // 14x14 + public static final Icon Edit = IconLoader.getIcon("/toolbarDecorator/mac/edit.png"); // 14x14 + public static final Icon MoveDown = IconLoader.getIcon("/toolbarDecorator/mac/moveDown.png"); // 14x14 + public static final Icon MoveUp = IconLoader.getIcon("/toolbarDecorator/mac/moveUp.png"); // 14x14 + public static final Icon Remove = IconLoader.getIcon("/toolbarDecorator/mac/remove.png"); // 14x14 } - public static final Icon MoveDown = IconLoader.getIcon("/toolbarDecorator/moveDown.png"); - public static final Icon MoveUp = IconLoader.getIcon("/toolbarDecorator/moveUp.png"); - public static final Icon Remove = IconLoader.getIcon("/toolbarDecorator/remove.png"); + public static final Icon MoveDown = IconLoader.getIcon("/toolbarDecorator/moveDown.png"); // 14x14 + public static final Icon MoveUp = IconLoader.getIcon("/toolbarDecorator/moveUp.png"); // 14x14 + public static final Icon Remove = IconLoader.getIcon("/toolbarDecorator/remove.png"); // 14x14 + + } + + public static class Toolwindows { + public static final Icon Documentation = IconLoader.getIcon("/toolwindows/documentation.png"); // 13x13 + public static final Icon ToolWindowAnt = IconLoader.getIcon("/toolwindows/toolWindowAnt.png"); // 13x13 + public static final Icon ToolWindowChanges = IconLoader.getIcon("/toolwindows/toolWindowChanges.png"); // 13x13 + public static final Icon ToolWindowCommander = IconLoader.getIcon("/toolwindows/toolWindowCommander.png"); // 13x13 + public static final Icon ToolWindowCoverage = IconLoader.getIcon("/toolwindows/toolWindowCoverage.png"); // 13x13 + public static final Icon ToolWindowCvs = IconLoader.getIcon("/toolwindows/toolWindowCvs.png"); // 13x13 + public static final Icon ToolWindowDebugger = IconLoader.getIcon("/toolwindows/toolWindowDebugger.png"); // 13x13 + public static final Icon ToolWindowFavorites = IconLoader.getIcon("/toolwindows/toolWindowFavorites.png"); // 13x13 + public static final Icon ToolWindowFind = IconLoader.getIcon("/toolwindows/toolWindowFind.png"); // 13x13 + public static final Icon ToolWindowHierarchy = IconLoader.getIcon("/toolwindows/toolWindowHierarchy.png"); // 13x13 + public static final Icon ToolWindowInspection = IconLoader.getIcon("/toolwindows/toolWindowInspection.png"); // 13x13 + public static final Icon ToolWindowMessages = IconLoader.getIcon("/toolwindows/toolWindowMessages.png"); // 13x13 + public static final Icon ToolWindowModuleDependencies = IconLoader.getIcon("/toolwindows/toolWindowModuleDependencies.png"); // 13x13 + public static final Icon ToolWindowPalette = IconLoader.getIcon("/toolwindows/toolWindowPalette.png"); // 13x13 + public static final Icon ToolWindowProject = IconLoader.getIcon("/toolwindows/toolWindowProject.png"); // 13x13 + public static final Icon ToolWindowRun = IconLoader.getIcon("/toolwindows/toolWindowRun.png"); // 13x13 + public static final Icon ToolWindowStructure = IconLoader.getIcon("/toolwindows/toolWindowStructure.png"); // 13x13 + public static final Icon ToolWindowTodo = IconLoader.getIcon("/toolwindows/toolWindowTodo.png"); // 13x13 + public static final Icon VcsSmallTab = IconLoader.getIcon("/toolwindows/vcsSmallTab.png"); // 13x13 + public static final Icon WebToolWindow = IconLoader.getIcon("/toolwindows/webToolWindow.png"); // 13x13 } public static class Vcs { - public static final Icon AllRevisions = IconLoader.getIcon("/vcs/allRevisions.png"); - public static final Icon Arrow_left = IconLoader.getIcon("/vcs/arrow_left.png"); - public static final Icon Arrow_right = IconLoader.getIcon("/vcs/arrow_right.png"); - public static final Icon CheckSpelling = IconLoader.getIcon("/vcs/checkSpelling.png"); - public static final Icon CustomizeView = IconLoader.getIcon("/vcs/customizeView.png"); - public static final Icon Equal = IconLoader.getIcon("/vcs/equal.png"); - public static final Icon MapBase = IconLoader.getIcon("/vcs/mapBase.png"); - public static final Icon Merge = IconLoader.getIcon("/vcs/merge.png"); - public static final Icon MergeSourcesTree = IconLoader.getIcon("/vcs/mergeSourcesTree.png"); - public static final Icon MessageHistory = IconLoader.getIcon("/vcs/messageHistory.png"); - public static final Icon Not_equal = IconLoader.getIcon("/vcs/not_equal.png"); - public static final Icon Refresh = IconLoader.getIcon("/vcs/refresh.png"); - public static final Icon Remove = IconLoader.getIcon("/vcs/remove.png"); - public static final Icon ResetStrip = IconLoader.getIcon("/vcs/resetStrip.png"); - public static final Icon StripDown = IconLoader.getIcon("/vcs/stripDown.png"); - public static final Icon StripNull = IconLoader.getIcon("/vcs/stripNull.png"); - public static final Icon StripUp = IconLoader.getIcon("/vcs/stripUp.png"); - public static final Icon Volute = IconLoader.getIcon("/vcs/volute.png"); + public static final Icon AllRevisions = IconLoader.getIcon("/vcs/allRevisions.png"); // 16x16 + public static final Icon Arrow_left = IconLoader.getIcon("/vcs/arrow_left.png"); // 12x12 + public static final Icon Arrow_right = IconLoader.getIcon("/vcs/arrow_right.png"); // 12x12 + public static final Icon CheckSpelling = IconLoader.getIcon("/vcs/checkSpelling.png"); // 16x16 + public static final Icon CustomizeView = IconLoader.getIcon("/vcs/customizeView.png"); // 16x16 + public static final Icon Equal = IconLoader.getIcon("/vcs/equal.png"); // 12x12 + public static final Icon MapBase = IconLoader.getIcon("/vcs/mapBase.png"); // 16x16 + public static final Icon Merge = IconLoader.getIcon("/vcs/merge.png"); // 12x12 + public static final Icon MergeSourcesTree = IconLoader.getIcon("/vcs/mergeSourcesTree.png"); // 16x16 + public static final Icon MessageHistory = IconLoader.getIcon("/vcs/messageHistory.png"); // 16x16 + public static final Icon Not_equal = IconLoader.getIcon("/vcs/not_equal.png"); // 12x12 + public static final Icon Refresh = IconLoader.getIcon("/vcs/refresh.png"); // 16x16 + public static final Icon Remove = IconLoader.getIcon("/vcs/remove.png"); // 16x16 + public static final Icon ResetStrip = IconLoader.getIcon("/vcs/resetStrip.png"); // 16x16 + public static final Icon StripDown = IconLoader.getIcon("/vcs/stripDown.png"); // 16x16 + public static final Icon StripNull = IconLoader.getIcon("/vcs/stripNull.png"); // 16x16 + public static final Icon StripUp = IconLoader.getIcon("/vcs/stripUp.png"); // 16x16 + public static final Icon Volute = IconLoader.getIcon("/vcs/volute.png"); // 16x16 } public static class Webreferences { - public static final Icon Server = IconLoader.getIcon("/webreferences/server.png"); + public static final Icon Server = IconLoader.getIcon("/webreferences/server.png"); // 16x16 } public static class Xml { public static class Actions { - public static final Icon Add_column_after = IconLoader.getIcon("/xml/actions/add_column_after.png"); - public static final Icon Add_column_before = IconLoader.getIcon("/xml/actions/add_column_before.png"); + public static final Icon Add_column_after = IconLoader.getIcon("/xml/actions/add_column_after.png"); // -1x-1 + public static final Icon Add_column_before = IconLoader.getIcon("/xml/actions/add_column_before.png"); // -1x-1 } public static class Browsers { - public static final Icon Chrome16 = IconLoader.getIcon("/xml/browsers/chrome16.png"); - public static final Icon Explorer16 = IconLoader.getIcon("/xml/browsers/explorer16.png"); - public static final Icon Firefox16 = IconLoader.getIcon("/xml/browsers/firefox16.png"); - public static final Icon Opera16 = IconLoader.getIcon("/xml/browsers/opera16.png"); - public static final Icon Safari16 = IconLoader.getIcon("/xml/browsers/safari16.png"); + public static final Icon Chrome16 = IconLoader.getIcon("/xml/browsers/chrome16.png"); // 16x16 + public static final Icon Explorer16 = IconLoader.getIcon("/xml/browsers/explorer16.png"); // 16x16 + public static final Icon Firefox16 = IconLoader.getIcon("/xml/browsers/firefox16.png"); // 16x16 + public static final Icon Opera16 = IconLoader.getIcon("/xml/browsers/opera16.png"); // 16x16 + public static final Icon Safari16 = IconLoader.getIcon("/xml/browsers/safari16.png"); // 16x16 } - public static final Icon Css_class = IconLoader.getIcon("/xml/css_class.png"); - public static final Icon Html_id = IconLoader.getIcon("/xml/html_id.png"); + public static final Icon Css_class = IconLoader.getIcon("/xml/css_class.png"); // 16x16 + public static final Icon Html_id = IconLoader.getIcon("/xml/html_id.png"); // 16x16 } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesViewContentManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesViewContentManager.java index d34fb8800a31..09eeca37fb6c 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesViewContentManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesViewContentManager.java @@ -77,7 +77,7 @@ public class ChangesViewContentManager extends AbstractProjectComponent implemen final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject); if (toolWindowManager != null) { myToolWindow = toolWindowManager.registerToolWindow(TOOLWINDOW_ID, true, ToolWindowAnchor.BOTTOM, myProject, true); - myToolWindow.setIcon(AllIcons.General.ToolWindowChanges); + myToolWindow.setIcon(AllIcons.Toolwindows.ToolWindowChanges); updateToolWindowAvailability(); final ContentManager contentManager = myToolWindow.getContentManager(); myContentManagerListener = new MyContentManagerListener(); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java index de48dedf80fe..d4aebdebbc8b 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.vcs.impl; +import com.intellij.icons.AllIcons; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.components.ProjectComponent; @@ -56,7 +57,6 @@ import com.intellij.ui.content.ContentFactory; import com.intellij.ui.content.ContentManager; import com.intellij.util.ContentsUtil; import com.intellij.util.PairProcessor; -import com.intellij.util.PlatformIcons; import com.intellij.util.Processor; import com.intellij.util.containers.Convertor; import com.intellij.util.messages.MessageBus; @@ -219,7 +219,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme ToolWindow toolWindow = toolWindowManager.registerToolWindow(ToolWindowId.VCS, true, ToolWindowAnchor.BOTTOM, myProject, true); myContentManager = toolWindow.getContentManager(); - toolWindow.setIcon(PlatformIcons.VCS_SMALL_TAB); + toolWindow.setIcon(AllIcons.Toolwindows.VcsSmallTab); toolWindow.installWatcher(myContentManager); } else { myContentManager = ContentFactory.SERVICE.getInstance().createContentManager(true, myProject); diff --git a/platform/xdebugger-api/src/com/intellij/execution/executors/DefaultDebugExecutor.java b/platform/xdebugger-api/src/com/intellij/execution/executors/DefaultDebugExecutor.java index bae8f1a422f9..f8b9ea4294b8 100644 --- a/platform/xdebugger-api/src/com/intellij/execution/executors/DefaultDebugExecutor.java +++ b/platform/xdebugger-api/src/com/intellij/execution/executors/DefaultDebugExecutor.java @@ -31,7 +31,7 @@ import javax.swing.*; */ public class DefaultDebugExecutor extends Executor { @NonNls public static final String EXECUTOR_ID = ToolWindowId.DEBUG; - private static final Icon TOOL_WINDOW_ICON = AllIcons.General.ToolWindowDebugger; + private static final Icon TOOL_WINDOW_ICON = AllIcons.Toolwindows.ToolWindowDebugger; private static final Icon ICON = AllIcons.Actions.StartDebugger; private static final Icon DISABLED_ICON = AllIcons.Process.DisabledDebug; private final String myStartActionText = XDebuggerBundle.message("debugger.runner.start.action.text"); diff --git a/plugins/ant/src/META-INF/plugin.xml b/plugins/ant/src/META-INF/plugin.xml index 3ca059d1f592..d86c7f03df0c 100644 --- a/plugins/ant/src/META-INF/plugin.xml +++ b/plugins/ant/src/META-INF/plugin.xml @@ -70,7 +70,7 @@ - diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/AllJarsUnderDirEntry.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/AllJarsUnderDirEntry.java index 5a2f87fab539..08748de5af2d 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/AllJarsUnderDirEntry.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/AllJarsUnderDirEntry.java @@ -35,7 +35,6 @@ import java.io.FileFilter; import java.util.List; public class AllJarsUnderDirEntry implements AntClasspathEntry { - private static final Icon ALL_JARS_IN_DIR_ICON = AllIcons.Ant.AllJarsInDir; @NonNls private static final String JAR_SUFFIX = ".jar"; private static final Function CREATE_FROM_VIRTUAL_FILE = new Function() { @@ -56,10 +55,6 @@ public class AllJarsUnderDirEntry implements AntClasspathEntry { this(new File(osPath)); } - public String getPresentablePath() { - return myDir.getAbsolutePath(); - } - public void writeExternal(final Element dataElement) throws WriteExternalException { String url = VirtualFileManager.constructUrl(LocalFileSystem.PROTOCOL, myDir.getAbsolutePath().replace(File.separatorChar, '/')); dataElement.setAttribute(DIR, url); @@ -77,7 +72,7 @@ public class AllJarsUnderDirEntry implements AntClasspathEntry { public CellAppearanceEx getAppearance() { CellAppearanceEx appearance = FileAppearanceService.getInstance().forIoFile(myDir); if (appearance instanceof ModifiableCellAppearanceEx) { - ((ModifiableCellAppearanceEx)appearance).setIcon(ALL_JARS_IN_DIR_ICON); + ((ModifiableCellAppearanceEx)appearance).setIcon(AllIcons.Nodes.JarDirectory); } return appearance; } diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/AntClasspathEntry.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/AntClasspathEntry.java index a109fa1a4d8e..33458e0a11ff 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/AntClasspathEntry.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/AntClasspathEntry.java @@ -49,8 +49,6 @@ public interface AntClasspathEntry { } }; - String getPresentablePath(); - void writeExternal(Element dataElement) throws WriteExternalException; void addFilesTo(List files); diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/SinglePathEntry.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/SinglePathEntry.java index 7c58f5386368..76581fd86f0c 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/SinglePathEntry.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/SinglePathEntry.java @@ -69,10 +69,6 @@ public class SinglePathEntry implements AntClasspathEntry { return FileAppearanceService.getInstance().forIoFile(myFile); } - public String getPresentablePath() { - return myFile.getAbsolutePath(); - } - private static SinglePathEntry fromVirtualFile(VirtualFile file) { return new SinglePathEntry(file.getPresentableUrl()); } diff --git a/plugins/commander/src/META-INF/plugin.xml b/plugins/commander/src/META-INF/plugin.xml index 6e37f68043c2..933fd487d073 100644 --- a/plugins/commander/src/META-INF/plugin.xml +++ b/plugins/commander/src/META-INF/plugin.xml @@ -9,7 +9,7 @@ - From caa8bee9a311a3033cf73a450739ea8a95767cfc Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Fri, 8 Jun 2012 21:41:30 +0400 Subject: [PATCH 030/172] Remove broken icons --- .../icons/src/xml/actions/add_column_after.png | Bin 522 -> 0 bytes .../icons/src/xml/actions/add_column_before.png | Bin 524 -> 0 bytes .../util/src/com/intellij/icons/AllIcons.java | 9 ++------- 3 files changed, 2 insertions(+), 7 deletions(-) delete mode 100644 platform/icons/src/xml/actions/add_column_after.png delete mode 100644 platform/icons/src/xml/actions/add_column_before.png diff --git a/platform/icons/src/xml/actions/add_column_after.png b/platform/icons/src/xml/actions/add_column_after.png deleted file mode 100644 index 4628f00f025bcae0165cf4b94ee6c40be78868a8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 522 zcmV+l0`>igP)dg1K4ZWEF6@~v zg;fG%03odJobU{n97|S3?-`h3d#?O7=HL}VvEb736h;^uSuG5(fQXjr9OLglzA@}i zTg*_JAI0$L(`T^clo_i~6!Y=%7&n!rFuZyXk@tx#JPS79@cHKq$B*s;3$}I50g{Zk zf`Xy0doHF6YzieAOf*9oHlA9{PzAIBmkU6ksWchxf*pI0Lks|cPai)p{QLV0i2pKd zIsFDK_V3Rx6wSYWLF7Mu`he;JMn)zEadB}5W>!uHW@c7~AZux`WdC_i6azRpIT=`3 zSr{aMYEcXTdHLh}_dwHsGW`4ZhhgK%S5O!HM03GUhQELQGJO2-9^C~D45Ff<49qMX zU>DfwNq{BqpFwp22L}fOD+>#QsE7!r3z(T0AtnKVI6pH3%wS}|2oeCRWkNFmDEi_3 zJBEM1AzoN_9J?2O{(yMl!~6H>1~4!P3kx$av9dETF|#m)SVO$fb&3PU0Co;`1{R diff --git a/platform/icons/src/xml/actions/add_column_before.png b/platform/icons/src/xml/actions/add_column_before.png deleted file mode 100644 index 95f08d75ce015dd762f8df161769d90676f83078..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 524 zcmV+n0`vWeP)YOa1H-Rhzfd&)`}+%s|1xYj{RYDS z1L1%A^a0fcjEqbS;^N{AoSd8}1~9X7GB7iE2s;8GW`AXm*L}w_vkKQU=S4*W#Hi8Ky?8N2iOI6dJX&@bd?n7k)#$uXM3aR%GdJSO(&)JqAiw} Date: Fri, 8 Jun 2012 22:29:31 +0400 Subject: [PATCH 031/172] Long deprecated method dropped --- .../psi/impl/light/LightParameter.java | 23 +++++++++++++------ .../src/com/intellij/psi/PsiParameter.java | 9 +------- .../psi/impl/compiled/ClsParameterImpl.java | 8 +------ .../psi/impl/source/PsiParameterImpl.java | 6 ----- .../statements/params/GrParameterImpl.java | 8 +------ .../psi/impl/synthetic/GrLightParameter.java | 8 +------ 6 files changed, 20 insertions(+), 42 deletions(-) diff --git a/java/java-impl/src/com/intellij/psi/impl/light/LightParameter.java b/java/java-impl/src/com/intellij/psi/impl/light/LightParameter.java index b78e9cd0e11e..611992bd2914 100644 --- a/java/java-impl/src/com/intellij/psi/impl/light/LightParameter.java +++ b/java/java-impl/src/com/intellij/psi/impl/light/LightParameter.java @@ -1,3 +1,18 @@ +/* + * 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.psi.impl.light; import com.intellij.lang.Language; @@ -9,6 +24,7 @@ import org.jetbrains.annotations.NotNull; */ public class LightParameter extends LightVariableBuilder implements PsiParameter { public static final LightParameter[] EMPTY_ARRAY = new LightParameter[0]; + private final String myName; private final PsiElement myDeclarationScope; private final boolean myVarArgs; @@ -46,16 +62,9 @@ public class LightParameter extends LightVariableBuilder i return myVarArgs; } - @Override - @NotNull - public PsiAnnotation[] getAnnotations() { - return PsiAnnotation.EMPTY_ARRAY; - } - @Override @NotNull public String getName() { return myName; } - } diff --git a/java/java-psi-api/src/com/intellij/psi/PsiParameter.java b/java/java-psi-api/src/com/intellij/psi/PsiParameter.java index 5ea7e84e2fca..025d37ff5b37 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiParameter.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiParameter.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. @@ -51,13 +51,6 @@ public interface PsiParameter extends PsiVariable { */ boolean isVarArgs(); - /** - * @return the list of annotations. - * @use getModifierList().getAnnotations() - */ - @Deprecated - @NotNull PsiAnnotation[] getAnnotations(); - /** * {@inheritDoc} */ diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsParameterImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsParameterImpl.java index 593fd3ac4180..6e2856937e46 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsParameterImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsParameterImpl.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. @@ -253,12 +253,6 @@ public class ClsParameterImpl extends ClsRepositoryPsiElement return method.isVarArgs() && getIndex() == paramList.getParametersCount() - 1; } - @Override - @NotNull - public PsiAnnotation[] getAnnotations() { - return getModifierList().getAnnotations(); - } - @Override protected boolean isVisibilitySupported() { return true; diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java index 0a569cf4a33e..fd0b61ab31c1 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java @@ -251,12 +251,6 @@ public class PsiParameterImpl extends JavaStubPsiElement imple return typeElement != null && SourceTreeToPsiMap.psiToTreeNotNull(typeElement).findChildByType(JavaTokenType.ELLIPSIS) != null; } - @Override - @NotNull - public PsiAnnotation[] getAnnotations() { - return getModifierList().getAnnotations(); - } - @Override public ItemPresentation getPresentation() { return ItemPresentationProviders.getItemPresentation(this); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/params/GrParameterImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/params/GrParameterImpl.java index ba494008c2ca..f8b30c36c63f 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/params/GrParameterImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/params/GrParameterImpl.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. @@ -218,10 +218,4 @@ public class GrParameterImpl extends GrVariableBaseImpl impleme PsiElement dots = findChildByType(GroovyTokenTypes.mTRIPLE_DOT); return dots != null; } - - @NotNull - public PsiAnnotation[] getAnnotations() { - return PsiAnnotation.EMPTY_ARRAY; - } - } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightParameter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightParameter.java index 66b6579aec7e..80f7dd62edc9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightParameter.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightParameter.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. @@ -53,12 +53,6 @@ public class GrLightParameter extends LightVariableBuilder imp return getType() instanceof PsiEllipsisType; } - @NotNull - @Override - public PsiAnnotation[] getAnnotations() { - return PsiAnnotation.EMPTY_ARRAY; - } - @Override public GrTypeElement getTypeElementGroovy() { return null; From ba2174dbaac42e6bba8df1e37cc8cf4951b4643a Mon Sep 17 00:00:00 2001 From: nik Date: Sat, 9 Jun 2012 12:26:08 +0400 Subject: [PATCH 032/172] new project model: toString for element kinds --- .../model/impl/JpsElementCollectionKind.java | 3 ++- .../jps/model/impl/JpsElementKindBase.java | 20 +++++++++++++++++++ .../impl/JpsNamedElementReferenceBase.java | 2 +- .../jps/model/impl/JpsProjectImpl.java | 2 +- .../jps/model/impl/JpsTypedDataKind.java | 6 ++++-- .../jps/model/impl/SimpleJpsElementKind.java | 6 ++++-- .../java/impl/JavaModuleExtensionKind.java | 7 ++++++- .../impl/JpsJavaDependencyExtensionKind.java | 7 ++++++- .../model/library/impl/JpsLibraryKind.java | 5 +++-- .../library/impl/JpsLibraryRootKind.java | 8 ++++++-- .../module/impl/JpsDependenciesListImpl.java | 6 +++--- .../module/impl/JpsLibraryDependencyImpl.java | 3 ++- .../module/impl/JpsModuleDependencyImpl.java | 3 ++- .../jps/model/module/impl/JpsModuleImpl.java | 6 +++--- .../jps/model/module/impl/JpsModuleKind.java | 7 ++++++- .../module/impl/JpsModuleSourceRootKind.java | 8 ++++++-- .../impl/JpsSdkReferencesTableImpl.java | 6 ++++-- 17 files changed, 79 insertions(+), 26 deletions(-) create mode 100644 jps/model-impl/src/org/jetbrains/jps/model/impl/JpsElementKindBase.java diff --git a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsElementCollectionKind.java b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsElementCollectionKind.java index aae141b3b861..288f33e97dc2 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsElementCollectionKind.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsElementCollectionKind.java @@ -6,11 +6,12 @@ import org.jetbrains.jps.model.*; /** * @author nik */ -public class JpsElementCollectionKind extends JpsElementKind> +public class JpsElementCollectionKind extends JpsElementKindBase> implements JpsElementCreator> { private final JpsElementKind myElementKind; public JpsElementCollectionKind(JpsElementKind elementKind) { + super("collection of " + elementKind); myElementKind = elementKind; } diff --git a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsElementKindBase.java b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsElementKindBase.java new file mode 100644 index 000000000000..faf964675b97 --- /dev/null +++ b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsElementKindBase.java @@ -0,0 +1,20 @@ +package org.jetbrains.jps.model.impl; + +import org.jetbrains.jps.model.JpsElement; +import org.jetbrains.jps.model.JpsElementKind; + +/** + * @author nik + */ +public class JpsElementKindBase extends JpsElementKind { + private String myDebugName; + + public JpsElementKindBase(String debugName) { + myDebugName = debugName; + } + + @Override + public String toString() { + return myDebugName; + } +} diff --git a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsNamedElementReferenceBase.java b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsNamedElementReferenceBase.java index 3e00ac907e7e..94bbe930b864 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsNamedElementReferenceBase.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsNamedElementReferenceBase.java @@ -9,7 +9,7 @@ import java.util.List; * @author nik */ public abstract class JpsNamedElementReferenceBase> extends JpsCompositeElementBase implements JpsElementReference { - private static final JpsElementKind> PARENT_REFERENCE_KIND = new JpsElementKind>(); + private static final JpsElementKind> PARENT_REFERENCE_KIND = new JpsElementKindBase>("parent"); private final JpsElementCollectionKind myCollectionKind; protected final String myElementName; diff --git a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsProjectImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsProjectImpl.java index 3720c0ba1190..ff8d13885d40 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsProjectImpl.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsProjectImpl.java @@ -17,7 +17,7 @@ import java.util.List; * @author nik */ public class JpsProjectImpl extends JpsRootElementBase implements JpsProject { - private static final JpsElementCollectionKind> EXTERNAL_REFERENCES_COLLECTION_KIND = new JpsElementCollectionKind>(new JpsElementKind>()); + private static final JpsElementCollectionKind> EXTERNAL_REFERENCES_COLLECTION_KIND = new JpsElementCollectionKind>(new JpsElementKindBase>("external reference")); public JpsProjectImpl(JpsModel model, JpsEventDispatcher eventDispatcher) { super(model, eventDispatcher); diff --git a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsTypedDataKind.java b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsTypedDataKind.java index 16805bb40611..7033d720cda2 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsTypedDataKind.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsTypedDataKind.java @@ -1,10 +1,12 @@ package org.jetbrains.jps.model.impl; -import org.jetbrains.jps.model.JpsElementKind; import org.jetbrains.jps.model.JpsElementType; /** * @author nik */ -public class JpsTypedDataKind> extends JpsElementKind> { +public class JpsTypedDataKind> extends JpsElementKindBase> { + public JpsTypedDataKind() { + super("typed data"); + } } diff --git a/jps/model-impl/src/org/jetbrains/jps/model/impl/SimpleJpsElementKind.java b/jps/model-impl/src/org/jetbrains/jps/model/impl/SimpleJpsElementKind.java index 9e670f918f04..d7bd4ea531b6 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/impl/SimpleJpsElementKind.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/impl/SimpleJpsElementKind.java @@ -1,11 +1,13 @@ package org.jetbrains.jps.model.impl; -import org.jetbrains.jps.model.JpsElementKind; import org.jetbrains.jps.model.JpsElementProperties; /** * @author nik */ public class SimpleJpsElementKind

> extends - JpsElementKind> { + JpsElementKindBase> { + public SimpleJpsElementKind(String debugName) { + super(debugName); + } } diff --git a/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaModuleExtensionKind.java b/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaModuleExtensionKind.java index 2bf771e90fc1..5425a5521da4 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaModuleExtensionKind.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaModuleExtensionKind.java @@ -2,15 +2,20 @@ package org.jetbrains.jps.model.java.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.model.*; +import org.jetbrains.jps.model.impl.JpsElementKindBase; import org.jetbrains.jps.model.java.JavaModuleExtension; import org.jetbrains.jps.model.module.JpsModule; /** * @author nik */ -public class JavaModuleExtensionKind extends JpsElementKind implements JpsElementCreator { +public class JavaModuleExtensionKind extends JpsElementKindBase implements JpsElementCreator { private static final JavaModuleExtensionKind INSTANCE = new JavaModuleExtensionKind(); + public JavaModuleExtensionKind() { + super("java module extension"); + } + @NotNull @Override public JavaModuleExtensionImpl create() { diff --git a/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JpsJavaDependencyExtensionKind.java b/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JpsJavaDependencyExtensionKind.java index c15df483d74e..0319b55211ca 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JpsJavaDependencyExtensionKind.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JpsJavaDependencyExtensionKind.java @@ -2,6 +2,7 @@ package org.jetbrains.jps.model.java.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.model.*; +import org.jetbrains.jps.model.impl.JpsElementKindBase; import org.jetbrains.jps.model.java.JpsJavaDependencyExtension; import org.jetbrains.jps.model.java.JpsJavaDependencyScope; import org.jetbrains.jps.model.module.JpsDependencyElement; @@ -9,9 +10,13 @@ import org.jetbrains.jps.model.module.JpsDependencyElement; /** * @author nik */ -public class JpsJavaDependencyExtensionKind extends JpsElementKind implements JpsElementCreator { +public class JpsJavaDependencyExtensionKind extends JpsElementKindBase implements JpsElementCreator { public static final JpsJavaDependencyExtensionKind INSTANCE = new JpsJavaDependencyExtensionKind(); + public JpsJavaDependencyExtensionKind() { + super("java dependency extension"); + } + @NotNull @Override public JpsJavaDependencyExtensionImpl create() { diff --git a/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryKind.java b/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryKind.java index 834ada9984fb..9e09aa2d9ec1 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryKind.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryKind.java @@ -1,7 +1,7 @@ package org.jetbrains.jps.model.library.impl; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jps.model.JpsElementKind; +import org.jetbrains.jps.model.impl.JpsElementKindBase; import org.jetbrains.jps.model.JpsEventDispatcher; import org.jetbrains.jps.model.impl.JpsElementCollectionKind; import org.jetbrains.jps.model.library.JpsLibraryListener; @@ -9,11 +9,12 @@ import org.jetbrains.jps.model.library.JpsLibraryListener; /** * @author nik */ -public class JpsLibraryKind extends JpsElementKind { +public class JpsLibraryKind extends JpsElementKindBase { public static final JpsLibraryKind INSTANCE = new JpsLibraryKind(); public static final JpsElementCollectionKind LIBRARIES_COLLECTION_KIND = new JpsElementCollectionKind(INSTANCE); private JpsLibraryKind() { + super("library"); } @Override diff --git a/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryRootKind.java b/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryRootKind.java index 4043b76287ce..f01d8cc843c6 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryRootKind.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryRootKind.java @@ -1,16 +1,20 @@ package org.jetbrains.jps.model.library.impl; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jps.model.JpsElementKind; +import org.jetbrains.jps.model.impl.JpsElementKindBase; import org.jetbrains.jps.model.JpsEventDispatcher; import org.jetbrains.jps.model.library.JpsLibraryRootListener; /** * @author nik */ -public class JpsLibraryRootKind extends JpsElementKind { +public class JpsLibraryRootKind extends JpsElementKindBase { public static final JpsLibraryRootKind INSTANCE = new JpsLibraryRootKind(); + public JpsLibraryRootKind() { + super("library root"); + } + @Override public void fireElementAdded(@NotNull JpsEventDispatcher dispatcher, @NotNull JpsLibraryRootImpl element) { dispatcher.getPublisher(JpsLibraryRootListener.class).rootAdded(element); diff --git a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsDependenciesListImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsDependenciesListImpl.java index e5c04b68cacb..6281eb2ed117 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsDependenciesListImpl.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsDependenciesListImpl.java @@ -1,7 +1,7 @@ package org.jetbrains.jps.model.module.impl; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jps.model.JpsElementKind; +import org.jetbrains.jps.model.impl.JpsElementKindBase; import org.jetbrains.jps.model.impl.JpsCompositeElementBase; import org.jetbrains.jps.model.impl.JpsElementCollectionKind; import org.jetbrains.jps.model.library.JpsLibrary; @@ -15,8 +15,8 @@ import java.util.List; * @author nik */ public class JpsDependenciesListImpl extends JpsCompositeElementBase implements JpsDependenciesList { - public static final JpsElementKind> DEPENDENCY_ELEMENT_KIND = new JpsElementKind>(); - public static final JpsElementCollectionKind> DEPENDENCY_COLLECTION_KIND = new JpsElementCollectionKind>(DEPENDENCY_ELEMENT_KIND); + public static final JpsElementCollectionKind> DEPENDENCY_COLLECTION_KIND = + new JpsElementCollectionKind>(new JpsElementKindBase>("dependency")); public JpsDependenciesListImpl() { super(); diff --git a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsLibraryDependencyImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsLibraryDependencyImpl.java index 7e2eba50a317..d9586addd602 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsLibraryDependencyImpl.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsLibraryDependencyImpl.java @@ -2,6 +2,7 @@ package org.jetbrains.jps.model.module.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.model.*; +import org.jetbrains.jps.model.impl.JpsElementKindBase; import org.jetbrains.jps.model.library.JpsLibraryReference; import org.jetbrains.jps.model.module.JpsLibraryDependency; @@ -9,7 +10,7 @@ import org.jetbrains.jps.model.module.JpsLibraryDependency; * @author nik */ public class JpsLibraryDependencyImpl extends JpsDependencyElementBase implements JpsLibraryDependency { - public static final JpsElementKind LIBRARY_REFERENCE_KIND = new JpsElementKind(); + public static final JpsElementKind LIBRARY_REFERENCE_KIND = new JpsElementKindBase("library reference"); public JpsLibraryDependencyImpl(final JpsLibraryReference reference) { super(); diff --git a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleDependencyImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleDependencyImpl.java index 6fe796883168..143702c104cf 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleDependencyImpl.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleDependencyImpl.java @@ -2,6 +2,7 @@ package org.jetbrains.jps.model.module.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.model.*; +import org.jetbrains.jps.model.impl.JpsElementKindBase; import org.jetbrains.jps.model.module.JpsModuleDependency; import org.jetbrains.jps.model.module.JpsModuleReference; @@ -9,7 +10,7 @@ import org.jetbrains.jps.model.module.JpsModuleReference; * @author nik */ public class JpsModuleDependencyImpl extends JpsDependencyElementBase implements JpsModuleDependency { - private static final JpsElementKind MODULE_REFERENCE_KIND = new JpsElementKind(); + private static final JpsElementKind MODULE_REFERENCE_KIND = new JpsElementKindBase("module reference"); public JpsModuleDependencyImpl(final JpsModuleReference moduleReference) { super(); diff --git a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleImpl.java index 7aabc147cae2..49fc525c5ee0 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleImpl.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleImpl.java @@ -16,9 +16,9 @@ import java.util.List; */ public class JpsModuleImpl extends JpsNamedCompositeElementBase implements JpsModule { private static final JpsTypedDataKind> TYPED_DATA_KIND = new JpsTypedDataKind>(); - private static final JpsElementKind CONTENT_ROOTS_KIND = new JpsElementKind(); - private static final JpsElementKind EXCLUDED_ROOTS_KIND = new JpsElementKind(); - public static final JpsElementKind DEPENDENCIES_LIST_KIND = new JpsElementKind(); + private static final JpsElementKind CONTENT_ROOTS_KIND = new JpsElementKindBase("content roots"); + private static final JpsElementKind EXCLUDED_ROOTS_KIND = new JpsElementKindBase("excluded roots"); + public static final JpsElementKind DEPENDENCIES_LIST_KIND = new JpsElementKindBase("dependencies"); public JpsModuleImpl(JpsModuleType type, @NotNull String name) { diff --git a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleKind.java b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleKind.java index 74621d367f0c..9fe135efa227 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleKind.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleKind.java @@ -2,6 +2,7 @@ package org.jetbrains.jps.model.module.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.model.JpsElementKind; +import org.jetbrains.jps.model.impl.JpsElementKindBase; import org.jetbrains.jps.model.JpsEventDispatcher; import org.jetbrains.jps.model.impl.JpsElementCollectionKind; import org.jetbrains.jps.model.module.JpsModuleListener; @@ -9,10 +10,14 @@ import org.jetbrains.jps.model.module.JpsModuleListener; /** * @author nik */ -public class JpsModuleKind extends JpsElementKind { +public class JpsModuleKind extends JpsElementKindBase { public static final JpsElementKind INSTANCE = new JpsModuleKind(); public static final JpsElementCollectionKind MODULE_COLLECTION_KIND = new JpsElementCollectionKind(INSTANCE); + public JpsModuleKind() { + super("module"); + } + @Override public void fireElementAdded(@NotNull JpsEventDispatcher dispatcher, @NotNull JpsModuleImpl element) { dispatcher.getPublisher(JpsModuleListener.class).moduleAdded(element); diff --git a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleSourceRootKind.java b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleSourceRootKind.java index 70e25abff2dc..11532f8a5f1b 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleSourceRootKind.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleSourceRootKind.java @@ -1,7 +1,7 @@ package org.jetbrains.jps.model.module.impl; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jps.model.JpsElementKind; +import org.jetbrains.jps.model.impl.JpsElementKindBase; import org.jetbrains.jps.model.JpsEventDispatcher; import org.jetbrains.jps.model.impl.JpsElementCollectionKind; import org.jetbrains.jps.model.module.JpsModuleSourceRootListener; @@ -9,10 +9,14 @@ import org.jetbrains.jps.model.module.JpsModuleSourceRootListener; /** * @author nik */ -public class JpsModuleSourceRootKind extends JpsElementKind { +public class JpsModuleSourceRootKind extends JpsElementKindBase { public static final JpsModuleSourceRootKind INSTANCE = new JpsModuleSourceRootKind(); public static final JpsElementCollectionKind ROOT_COLLECTION_KIND = new JpsElementCollectionKind(INSTANCE); + public JpsModuleSourceRootKind() { + super("module source root"); + } + @Override public void fireElementAdded(@NotNull JpsEventDispatcher dispatcher, @NotNull JpsModuleSourceRootImpl element) { dispatcher.getPublisher(JpsModuleSourceRootListener.class).sourceRootAdded(element); diff --git a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsSdkReferencesTableImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsSdkReferencesTableImpl.java index 4b7c81cbecd6..b8c0462ffcb7 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsSdkReferencesTableImpl.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsSdkReferencesTableImpl.java @@ -2,6 +2,7 @@ package org.jetbrains.jps.model.module.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.model.JpsElementKind; +import org.jetbrains.jps.model.impl.JpsElementKindBase; import org.jetbrains.jps.model.impl.JpsCompositeElementBase; import org.jetbrains.jps.model.library.JpsLibraryReference; import org.jetbrains.jps.model.library.JpsSdkType; @@ -11,7 +12,7 @@ import org.jetbrains.jps.model.module.JpsSdkReferencesTable; * @author nik */ public class JpsSdkReferencesTableImpl extends JpsCompositeElementBase implements JpsSdkReferencesTable { - public static final JpsElementKind KIND = new JpsElementKind(); + public static final JpsElementKind KIND = new JpsElementKindBase("sdk references"); public JpsSdkReferencesTableImpl() { super(); @@ -37,10 +38,11 @@ public class JpsSdkReferencesTableImpl extends JpsCompositeElementBase { + private static class JpsSdkReferenceKind extends JpsElementKindBase { private final JpsSdkType myType; private JpsSdkReferenceKind(@NotNull JpsSdkType type) { + super("sdk reference " + type); myType = type; } From e28f99ef0026b08a129af09e9c73cbd1e3b2d3ed Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Sat, 9 Jun 2012 12:34:07 +0400 Subject: [PATCH 033/172] refactoring missed reference --- community-resources/src/idea/IdeaApplicationInfo.xml | 2 +- community-resources/src/idea/PlatformLangXmlApplicationInfo.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/community-resources/src/idea/IdeaApplicationInfo.xml b/community-resources/src/idea/IdeaApplicationInfo.xml index 035e49f13af7..081eac6c941c 100644 --- a/community-resources/src/idea/IdeaApplicationInfo.xml +++ b/community-resources/src/idea/IdeaApplicationInfo.xml @@ -5,7 +5,7 @@ - + diff --git a/community-resources/src/idea/PlatformLangXmlApplicationInfo.xml b/community-resources/src/idea/PlatformLangXmlApplicationInfo.xml index 1bcdca8d3b40..4b701bebb5cd 100644 --- a/community-resources/src/idea/PlatformLangXmlApplicationInfo.xml +++ b/community-resources/src/idea/PlatformLangXmlApplicationInfo.xml @@ -4,7 +4,7 @@ - + From bc84d3b85f06dff366b892936b4b6e32f60312b0 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Sat, 9 Jun 2012 12:37:02 +0400 Subject: [PATCH 034/172] synchronized by read-write lock --- .../vfs/newvfs/persistent/FSRecords.java | 478 +++++++++++------- 1 file changed, 291 insertions(+), 187 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java index 35c0315ed446..5e29cb4ae0e1 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java @@ -30,6 +30,9 @@ import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream; import com.intellij.openapi.util.io.ByteSequence; import com.intellij.openapi.util.io.FileUtil; import com.intellij.util.ArrayUtil; +import com.intellij.util.concurrency.JBLock; +import com.intellij.util.concurrency.JBReentrantReadWriteLock; +import com.intellij.util.concurrency.LockFactory; import com.intellij.util.containers.IntArrayList; import com.intellij.util.io.PagedFileStorage; import com.intellij.util.io.PersistentStringEnumerator; @@ -88,7 +91,9 @@ public class FSRecords implements Forceable { private static final int CORRUPTED_MAGIC = 0xabcf7f7f; private static final String CHILDREN_ATT = "FsRecords.DIRECTORY_CHILDREN"; - private static final Object lock = new Object(); + + private static final JBLock r; + private static final JBLock w; private static volatile int ourLocalModificationCount = 0; private static volatile boolean ourIsDisposed; @@ -99,6 +104,10 @@ public class FSRecords implements Forceable { static { //noinspection ConstantConditions assert HEADER_SIZE <= RECORD_SIZE; + + JBReentrantReadWriteLock lock = LockFactory.createReadWriteLock(); + r = lock.readLock(); + w = lock.writeLock(); } private static class DbConnection { @@ -116,7 +125,8 @@ public class FSRecords implements Forceable { private static boolean myCorrupted = false; public static void connect() { - synchronized (lock) { + try { + w.lock(); if (!ourInitialized) { init(); scanFreeRecords(); @@ -124,6 +134,9 @@ public class FSRecords implements Forceable { ourInitialized = true; } } + finally { + w.unlock(); + } } private static void scanFreeRecords() { @@ -337,7 +350,8 @@ public class FSRecords implements Forceable { } public static void force() { - synchronized (lock) { + try { + w.lock(); if (myRecords != null) { markClean(); } @@ -348,12 +362,16 @@ public class FSRecords implements Forceable { myRecords.force(); } } + finally { + w.unlock(); + } } public static void flushSome() { if (!isDirty() || HeavyProcessLatch.INSTANCE.isRunning()) return; - synchronized (lock) { + try { + w.lock(); if (myFlushingFuture == null) { return; // avoid NPE when close has already taken place } @@ -366,6 +384,9 @@ public class FSRecords implements Forceable { myRecords.force(); } } + finally { + w.unlock(); + } } public static boolean isDirty() { @@ -477,9 +498,13 @@ public class FSRecords implements Forceable { } public static long getCreationTimestamp() { - synchronized (lock) { + try { + r.lock(); return DbConnection.getTimestamp(); } + finally { + r.unlock(); + } } private static ResizeableMappedFile getRecords() { @@ -499,39 +524,43 @@ public class FSRecords implements Forceable { } public static int createRecord() { - synchronized (lock) { - try { - DbConnection.markDirty(); + try { + w.lock(); + DbConnection.markDirty(); - final int free = DbConnection.getFreeRecord(); - if (free == 0) { - final int filelength = (int)getRecords().length(); - LOG.assertTrue(filelength % RECORD_SIZE == 0); - int newrecord = filelength / RECORD_SIZE; - DbConnection.cleanRecord(newrecord); - assert filelength + RECORD_SIZE == getRecords().length(); - return newrecord; - } - else { - DbConnection.cleanRecord(free); - return free; - } + final int free = DbConnection.getFreeRecord(); + if (free == 0) { + final int filelength = (int)getRecords().length(); + LOG.assertTrue(filelength % RECORD_SIZE == 0); + int newrecord = filelength / RECORD_SIZE; + DbConnection.cleanRecord(newrecord); + assert filelength + RECORD_SIZE == getRecords().length(); + return newrecord; } - catch (Throwable e) { - throw DbConnection.handleError(e); + else { + DbConnection.cleanRecord(free); + return free; } } + catch (Throwable e) { + throw DbConnection.handleError(e); + } + finally { + w.unlock(); + } } public static void deleteRecordRecursively(int id) { - synchronized (lock) { - try { - incModCount(id); - doDeleteRecursively(id); - } - catch (Throwable e) { - throw DbConnection.handleError(e); - } + try { + w.lock(); + incModCount(id); + doDeleteRecursively(id); + } + catch (Throwable e) { + throw DbConnection.handleError(e); + } + finally { + w.unlock(); } } @@ -544,17 +573,19 @@ public class FSRecords implements Forceable { } private static void deleteRecord(final int id) { - synchronized (lock) { - try { - DbConnection.markDirty(); - deleteContentAndAttributes(id); + try { + w.lock(); + DbConnection.markDirty(); + deleteContentAndAttributes(id); - DbConnection.cleanRecord(id); - addToFreeRecordsList(id); - } - catch (Throwable e) { - throw DbConnection.handleError(e); - } + DbConnection.cleanRecord(id); + addToFreeRecordsList(id); + } + catch (Throwable e) { + throw DbConnection.handleError(e); + } + finally { + w.unlock(); } } @@ -583,8 +614,8 @@ public class FSRecords implements Forceable { } public static int[] listRoots() throws IOException { - synchronized (lock) { - DbConnection.markDirty(); + try { + r.lock(); final DataInputStream input = readAttribute(1, CHILDREN_ATT); if (input == null) return ArrayUtil.EMPTY_INT_ARRAY; @@ -596,12 +627,14 @@ public class FSRecords implements Forceable { input.readInt(); // Name result[i] = input.readInt(); // Id } + return result; } finally { input.close(); } - - return result; + } + finally { + r.unlock(); } } @@ -616,7 +649,8 @@ public class FSRecords implements Forceable { } public static int findRootRecord(String rootUrl) throws IOException { - synchronized (lock) { + try { + w.lock(); DbConnection.markDirty(); final int root = getNames().enumerate(rootUrl); @@ -663,10 +697,14 @@ public class FSRecords implements Forceable { return id; } + finally { + w.unlock(); + } } public static void deleteRootRecord(int id) throws IOException { - synchronized (lock) { + try { + w.lock(); DbConnection.markDirty(); final DataInputStream input = readAttribute(1, CHILDREN_ATT); assert input != null; @@ -705,80 +743,92 @@ public class FSRecords implements Forceable { output.close(); } } + finally { + w.unlock(); + } } public static int[] list(int id) { - synchronized (lock) { - try { - final DataInputStream input = readAttribute(id, CHILDREN_ATT); - if (input == null) return ArrayUtil.EMPTY_INT_ARRAY; + try { + r.lock(); + final DataInputStream input = readAttribute(id, CHILDREN_ATT); + if (input == null) return ArrayUtil.EMPTY_INT_ARRAY; - final int count = input.readInt(); - final int[] result = ArrayUtil.newIntArray(count); - for (int i = 0; i < count; i++) { - result[i] = input.readInt(); - } - input.close(); - return result; - } - catch (Throwable e) { - throw DbConnection.handleError(e); + final int count = input.readInt(); + final int[] result = ArrayUtil.newIntArray(count); + for (int i = 0; i < count; i++) { + result[i] = input.readInt(); } + input.close(); + return result; + } + catch (Throwable e) { + throw DbConnection.handleError(e); + } + finally { + r.unlock(); } } - public static Pair listAll(int parentId) { - synchronized (lock) { - try { - final DataInputStream input = readAttribute(parentId, CHILDREN_ATT); - if (input == null) return Pair.create(ArrayUtil.EMPTY_STRING_ARRAY, ArrayUtil.EMPTY_INT_ARRAY); - final int count = input.readInt(); - final int[] ids = ArrayUtil.newIntArray(count); - final String[] names = ArrayUtil.newStringArray(count); - for (int i = 0; i < count; i++) { - int id = input.readInt(); - ids[i] = id; - names[i] = getName(id); - } - input.close(); - return Pair.create(names, ids); - } - catch (Throwable e) { - throw DbConnection.handleError(e); + public static Pair listAll(int parentId) { + try { + r.lock(); + final DataInputStream input = readAttribute(parentId, CHILDREN_ATT); + if (input == null) return Pair.create(ArrayUtil.EMPTY_STRING_ARRAY, ArrayUtil.EMPTY_INT_ARRAY); + + final int count = input.readInt(); + final int[] ids = ArrayUtil.newIntArray(count); + final String[] names = ArrayUtil.newStringArray(count); + for (int i = 0; i < count; i++) { + int id = input.readInt(); + ids[i] = id; + names[i] = getName(id); } + input.close(); + return Pair.create(names, ids); + } + catch (Throwable e) { + throw DbConnection.handleError(e); + } + finally { + r.unlock(); } } public static boolean wereChildrenAccessed(int id) { try { - synchronized (lock) { - return findAttributePage(id, CHILDREN_ATT, false) != 0; - } + r.lock(); + return findAttributePage(id, CHILDREN_ATT, false) != 0; } catch (Throwable e) { throw DbConnection.handleError(e); } + finally { + r.unlock(); + } } public static void updateList(int id, int[] children) { - synchronized (lock) { - try { - DbConnection.markDirty(); - final DataOutputStream record = writeAttribute(id, CHILDREN_ATT, false); - record.writeInt(children.length); - for (int child : children) { - if (child == id) { - LOG.error("Cyclic parent child relations"); - } - else { - record.writeInt(child); - } + try { + w.lock(); + DbConnection.markDirty(); + final DataOutputStream record = writeAttribute(id, CHILDREN_ATT, false); + record.writeInt(children.length); + for (int child : children) { + if (child == id) { + LOG.error("Cyclic parent child relations"); + } + else { + record.writeInt(child); } - record.close(); - } - catch (Throwable e) { - throw DbConnection.handleError(e); } + record.close(); + } + catch (Throwable e) { + throw DbConnection.handleError(e); + } + finally { + w.unlock(); } } @@ -800,25 +850,31 @@ public class FSRecords implements Forceable { } public static int getModCount() { - synchronized (lock) { + try { + r.lock(); return getRecords().getInt(HEADER_GLOBAL_MOD_COUNT_OFFSET); } + finally { + r.unlock(); + } } public static int getParent(int id) { - synchronized (lock) { - try { - final int parentId = getRecordInt(id, PARENT_OFFSET); - if (parentId == id) { - LOG.error("Cyclic parent child relations in the database. id = " + id); - return 0; - } + try { + r.lock(); + final int parentId = getRecordInt(id, PARENT_OFFSET); + if (parentId == id) { + LOG.error("Cyclic parent child relations in the database. id = " + id); + return 0; + } - return parentId; - } - catch (Throwable e) { - throw DbConnection.handleError(e); - } + return parentId; + } + catch (Throwable e) { + throw DbConnection.handleError(e); + } + finally { + r.unlock(); } } @@ -828,101 +884,129 @@ public class FSRecords implements Forceable { return; } - synchronized (lock) { - try { - incModCount(id); - putRecordInt(id, PARENT_OFFSET, parent); - } - catch (Throwable e) { - throw DbConnection.handleError(e); - } + try { + w.lock(); + incModCount(id); + putRecordInt(id, PARENT_OFFSET, parent); + } + catch (Throwable e) { + throw DbConnection.handleError(e); + } + finally { + w.unlock(); } } public static String getName(int id) { - synchronized (lock) { - try { - final int nameId = getRecordInt(id, NAME_OFFSET); - return nameId != 0 ? getNames().valueOf(nameId) : ""; - } - catch (Throwable e) { - throw DbConnection.handleError(e); - } + try { + r.lock(); + final int nameId = getRecordInt(id, NAME_OFFSET); + return nameId != 0 ? getNames().valueOf(nameId) : ""; + } + catch (Throwable e) { + throw DbConnection.handleError(e); + } + finally { + r.unlock(); } } public static void setName(int id, String name) { - synchronized (lock) { - try { - incModCount(id); - putRecordInt(id, NAME_OFFSET, getNames().enumerate(name)); - } - catch (Throwable e) { - throw DbConnection.handleError(e); - } + try { + w.lock(); + incModCount(id); + putRecordInt(id, NAME_OFFSET, getNames().enumerate(name)); + } + catch (Throwable e) { + throw DbConnection.handleError(e); + } + finally { + w.unlock(); } } public static int getFlags(int id) { - synchronized (lock) { + try { + r.lock(); return getRecordInt(id, FLAGS_OFFSET); } + finally { + r.unlock(); + } } public static void setFlags(int id, int flags, final boolean markAsChange) { - synchronized (lock) { - try { - if (markAsChange) { - incModCount(id); - } - putRecordInt(id, FLAGS_OFFSET, flags); - } - catch (Throwable e) { - throw DbConnection.handleError(e); + try { + w.lock(); + if (markAsChange) { + incModCount(id); } + putRecordInt(id, FLAGS_OFFSET, flags); + } + catch (Throwable e) { + throw DbConnection.handleError(e); + } + finally { + w.unlock(); } } public static long getLength(int id) { - synchronized (lock) { + try { + r.lock(); return getRecords().getLong(getOffset(id, LENGTH_OFFSET)); } + finally { + r.unlock(); + } } public static void setLength(int id, long len) { - synchronized (lock) { - try { - incModCount(id); - getRecords().putLong(getOffset(id, LENGTH_OFFSET), len); - } - catch (Throwable e) { - throw DbConnection.handleError(e); - } + try { + w.lock(); + incModCount(id); + getRecords().putLong(getOffset(id, LENGTH_OFFSET), len); + } + catch (Throwable e) { + throw DbConnection.handleError(e); + } + finally { + w.unlock(); } } public static long getTimestamp(int id) { - synchronized (lock) { + try { + r.lock(); return getRecords().getLong(getOffset(id, TIMESTAMP_OFFSET)); } + finally { + r.unlock(); + } } public static void setTimestamp(int id, long value) { - synchronized (lock) { - try { - incModCount(id); - getRecords().putLong(getOffset(id, TIMESTAMP_OFFSET), value); - } - catch (Throwable e) { - throw DbConnection.handleError(e); - } + try { + w.lock(); + incModCount(id); + getRecords().putLong(getOffset(id, TIMESTAMP_OFFSET), value); + } + catch (Throwable e) { + throw DbConnection.handleError(e); + } + finally { + w.unlock(); } } public static int getModCount(int id) { - synchronized (lock) { + try { + r.lock(); return getRecordInt(id, MOD_COUNT_OFFSET); } + finally { + r.unlock(); + } } private static void setModCount(int id, int value) { @@ -961,10 +1045,14 @@ public class FSRecords implements Forceable { public static DataInputStream readContent(int fileId) { try { int page; - synchronized (lock) { + try { + r.lock(); page = findContentPage(fileId, false); if (page == 0) return null; } + finally { + r.unlock(); + } return getContentStorage().readStream(page); } catch (Throwable e) { @@ -987,10 +1075,14 @@ public class FSRecords implements Forceable { try { synchronized (attId) { int page; - synchronized (lock) { + try { + r.lock(); page = findAttributePage(fileId, attId, false); if (page == 0) return null; } + finally { + r.unlock(); + } return getAttributesStorage().readStream(page); } } @@ -1062,15 +1154,17 @@ public class FSRecords implements Forceable { public static int acquireFileContent(int fileId) { try { - synchronized (lock) { - int record = getContentRecordId(fileId); - if (record > 0) getContentStorage().acquireRecord(record); - return record; - } + w.lock(); + int record = getContentRecordId(fileId); + if (record > 0) getContentStorage().acquireRecord(record); + return record; } catch (Throwable e) { throw DbConnection.handleError(e); } + finally { + w.unlock(); + } } public static void releaseContent(int contentId) { @@ -1084,13 +1178,15 @@ public class FSRecords implements Forceable { public static int getContentId(int fileId) { try { - synchronized (lock) { - return getContentRecordId(fileId); - } + r.lock(); + return getContentRecordId(fileId); } catch (Throwable e) { throw DbConnection.handleError(e); } + finally { + r.unlock(); + } } @NotNull @@ -1191,10 +1287,14 @@ public class FSRecords implements Forceable { public void writeBytes(ByteSequence bytes, int fileId) throws IOException { final int page; - synchronized (lock) { + try { + w.lock(); incModCount(fileId); page = findOrCreatePage(); } + finally { + w.unlock(); + } getStorage().writeBytes(page, bytes, myFixedSize); } @@ -1205,17 +1305,17 @@ public class FSRecords implements Forceable { } public static void dispose() { - synchronized (lock) { - try { - DbConnection.force(); - DbConnection.closeFiles(); - } - catch (Throwable e) { - throw DbConnection.handleError(e); - } - finally { - ourIsDisposed = true; - } + try { + w.lock(); + DbConnection.force(); + DbConnection.closeFiles(); + } + catch (Throwable e) { + throw DbConnection.handleError(e); + } + finally { + ourIsDisposed = true; + w.unlock(); } } @@ -1226,7 +1326,8 @@ public class FSRecords implements Forceable { public static void checkSanity() { long t = System.currentTimeMillis(); - synchronized (lock) { + try { + r.lock(); final int fileLength = (int)getRecords().length(); assert fileLength % RECORD_SIZE == 0; int recordCount = fileLength / RECORD_SIZE; @@ -1245,6 +1346,9 @@ public class FSRecords implements Forceable { } } } + finally { + r.unlock(); + } t = System.currentTimeMillis() - t; LOG.info("Sanity check took " + t + " ms"); From 3b81035b0cf9545277574a5c2e2c04cd138fb1fc Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Sat, 9 Jun 2012 13:45:33 +0400 Subject: [PATCH 035/172] ClickListener - helper class to avoid default mouseClicked() sensitivity problem. Reports onClick() if there was minor mouse movement between press and release events. --- .../src/com/intellij/ui/ClickListener.java | 60 +++++++++++++++++++ .../ui/components/labels/LinkLabel.java | 9 +-- .../welcomeScreen/DefaultWelcomeScreen.java | 25 ++++---- 3 files changed, 78 insertions(+), 16 deletions(-) create mode 100644 platform/platform-api/src/com/intellij/ui/ClickListener.java diff --git a/platform/platform-api/src/com/intellij/ui/ClickListener.java b/platform/platform-api/src/com/intellij/ui/ClickListener.java new file mode 100644 index 000000000000..0b1a371ede18 --- /dev/null +++ b/platform/platform-api/src/com/intellij/ui/ClickListener.java @@ -0,0 +1,60 @@ +/* + * 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. + */ + +/* + * @author max + */ +package com.intellij.ui; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +public abstract class ClickListener { + + private static final int EPS = 4; + + public abstract void onClick(MouseEvent event); + + public void installOn(final JComponent c) { + MouseAdapter adapter = new MouseAdapter() { + Point clickPoint; + + @Override + public void mousePressed(MouseEvent e) { + clickPoint = e.getPoint(); + } + + @Override + public void mouseReleased(MouseEvent e) { + Point releasedAt = e.getPoint(); + Point clickedAt = clickPoint; + clickPoint = null; + + if (releasedAt.x < 0 || releasedAt.y < 0 || releasedAt.x >= c.getWidth() || releasedAt.y >= c.getWidth()) return; + if (clickedAt == null) return; + + if (Math.abs(clickedAt.x - releasedAt.x) < EPS && Math.abs(clickedAt.y - releasedAt.y) < EPS) { + onClick(e); + } + } + }; + + c.addMouseListener(adapter); + c.addMouseMotionListener(adapter); + } +} diff --git a/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java b/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java index 78707b3d12c0..a0541e4dc1be 100644 --- a/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java +++ b/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java @@ -288,12 +288,6 @@ public class LinkLabel extends JLabel { } private class MyMouseHandler extends MouseAdapter implements MouseMotionListener { - public void mouseClicked(MouseEvent e) { - if (isInClickableArea(e.getPoint()) && e.getClickCount() == 1) { - doClick(e); - } - } - public void mousePressed(MouseEvent e) { if (isInClickableArea(e.getPoint())) { setActive(true); @@ -301,6 +295,9 @@ public class LinkLabel extends JLabel { } public void mouseReleased(MouseEvent e) { + if (myIsLinkActive && isInClickableArea(e.getPoint())) { + doClick(e); + } setActive(false); } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/DefaultWelcomeScreen.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/DefaultWelcomeScreen.java index 270a078d8970..a52109f5bd97 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/DefaultWelcomeScreen.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/DefaultWelcomeScreen.java @@ -275,18 +275,19 @@ public class DefaultWelcomeScreen implements WelcomeScreen { actionLabel.setFont(new Font(CAPTION_FONT_NAME, Font.PLAIN, 12)); actionLabel.setForeground(CAPTION_COLOR); actionLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - actionLabel.addMouseListener(new MouseAdapter() { + + new ClickListener() { @Override - public void mouseClicked(MouseEvent e) { + public void onClick(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { DataContext dataContext = DataManager.getInstance().getDataContext(myWelcomePanel); int fragment = actionLabel.findFragmentAt(e.getX()); if (fragment == SimpleColoredComponent.FRAGMENT_ICON) { final int rc = Messages.showOkCancelDialog(PlatformDataKeys.PROJECT.getData(dataContext), - "Remove '" + action.getTemplatePresentation().getText() + - "' from recent projects list?", - "Remove Recent Project", - Messages.getQuestionIcon()); + "Remove '" + action.getTemplatePresentation().getText() + + "' from recent projects list?", + "Remove Recent Project", + Messages.getQuestionIcon()); if (rc == 0) { final RecentProjectsManagerBase manager = RecentProjectsManagerBase.getInstance(); assert action instanceof ReopenProjectAction : action; @@ -310,7 +311,9 @@ public class DefaultWelcomeScreen implements WelcomeScreen { } } } + }.installOn(actionLabel); + actionLabel.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { actionLabel.setIcon(ICON); @@ -695,11 +698,13 @@ public class DefaultWelcomeScreen implements WelcomeScreen { myCount++; JLabel name = new JLabel(underlineHtmlText(commandLink)); - name.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - button.onPress(e); + new ClickListener() { + @Override + public void onClick(MouseEvent event) { + button.onPress(event); } - }); + }.installOn(name); + name.setForeground(CAPTION_COLOR); name.setFont(LINK_FONT); name.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); From 4865aec947fde982997bc260a190d988510de51c Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Sat, 9 Jun 2012 13:15:17 +0400 Subject: [PATCH 036/172] Typos --- .../JavaMemberNameCompletionContributor.java | 4 ++-- .../impl/CreateFieldFromParameterAction.java | 4 ++-- .../codeStyle/JavaCodeStyleManagerImpl.java | 6 ++--- .../move/moveInner/MoveInnerDialog.java | 4 ++-- .../ui/NameSuggestionsManager.java | 4 ++-- .../psi/codeStyle/SuggestedNameInfo.java | 23 +++++++++++-------- .../refactoring/rename/RenameDialog.java | 4 ++-- .../GroovyNameSuggestionProvider.java | 4 ++-- 8 files changed, 29 insertions(+), 24 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.java index 5bb12243485f..b9b531f20153 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.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. @@ -417,7 +417,7 @@ public class JavaMemberNameCompletionContributor extends CompletionContributor { element = LookupElementDecorator.withInsertHandler(element, new InsertHandler>() { @Override public void handleInsert(InsertionContext context, LookupElementDecorator item) { - callback.nameChoosen(item.getLookupString()); + callback.nameChosen(item.getLookupString()); } }); } diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/CreateFieldFromParameterAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/CreateFieldFromParameterAction.java index 5cefd9fbfd20..20ee44b6ee3a 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/CreateFieldFromParameterAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/CreateFieldFromParameterAction.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. @@ -351,7 +351,7 @@ public class CreateFieldFromParameterAction implements IntentionAction { fieldNameToCalc = dialog.getEnteredName(); isFinalToCalc = dialog.isDeclareFinal(); - suggestedNameInfo.nameChoosen(fieldNameToCalc); + suggestedNameInfo.nameChosen(fieldNameToCalc); } else { isFinalToCalc = !isMethodStatic && method.isConstructor(); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java index 55d19be86fc5..5047b0f7c4e2 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java @@ -245,7 +245,7 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager { final PsiType _type = type; return new SuggestedNameInfo(namesArray) { @Override - public void nameChoosen(String name) { + public void nameChosen(String name) { if (_propertyName != null || _type != null && _type.isValid()) { JavaStatisticsManager.incVariableNameUseCount(name, kind, _propertyName, _type); } @@ -862,8 +862,8 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager { return new SuggestedNameInfo(ArrayUtil.toStringArray(uniqueNames)) { @Override - public void nameChoosen(String name) { - baseNameInfo.nameChoosen(name); + public void nameChosen(String name) { + baseNameInfo.nameChosen(name); } }; } diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerDialog.java b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerDialog.java index c2e1399893ab..1d4afb77e665 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerDialog.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. @@ -288,7 +288,7 @@ public class MoveInnerDialog extends RefactoringDialog { JavaRefactoringSettings.getInstance().MOVE_INNER_PREVIEW_USAGES = isPreviewUsages(); if (myCbPassOuterClass.isSelected() && mySuggestedNameInfo != null) { - mySuggestedNameInfo.nameChoosen(getParameterName()); + mySuggestedNameInfo.nameChosen(getParameterName()); } final PsiElement target = getTargetContainer(); diff --git a/java/java-impl/src/com/intellij/refactoring/ui/NameSuggestionsManager.java b/java/java-impl/src/com/intellij/refactoring/ui/NameSuggestionsManager.java index dd3673b0e1cf..95377dccfa91 100644 --- a/java/java-impl/src/com/intellij/refactoring/ui/NameSuggestionsManager.java +++ b/java/java-impl/src/com/intellij/refactoring/ui/NameSuggestionsManager.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. @@ -53,7 +53,7 @@ public class NameSuggestionsManager { SuggestedNameInfo nameInfo = myTypesToSuggestions.get(myTypeSelector.getSelectedType()); if (nameInfo != null) { - nameInfo.nameChoosen(myNameField.getEnteredName()); + nameInfo.nameChosen(myNameField.getEnteredName()); } } diff --git a/platform/core-api/src/com/intellij/psi/codeStyle/SuggestedNameInfo.java b/platform/core-api/src/com/intellij/psi/codeStyle/SuggestedNameInfo.java index 8aa64bbac7b2..a68e7ccb59b0 100644 --- a/platform/core-api/src/com/intellij/psi/codeStyle/SuggestedNameInfo.java +++ b/platform/core-api/src/com/intellij/psi/codeStyle/SuggestedNameInfo.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. @@ -22,13 +22,15 @@ import com.intellij.util.ArrayUtil; * Represents an array of suggested variable names and allows to keep statistics on * which of the suggestions has been accepted. * - * @see JavaCodeStyleManager#suggestVariableName(VariableKind, String, com.intellij.psi.PsiExpression, com.intellij.psi.PsiType) + * (see JavaCodeStyleManager.suggestVariableName() methods). */ public abstract class SuggestedNameInfo { + @SuppressWarnings("UnusedDeclaration") public static final Key SUGGESTED_NAME_INFO_KEY = Key.create("SUGGESTED_NAME_INFO_KEY"); + public static final SuggestedNameInfo NULL_INFO = new SuggestedNameInfo(ArrayUtil.EMPTY_STRING_ARRAY) { @Override - public void nameChoosen(String name) {} + public void nameChosen(String name) {} }; /** @@ -41,13 +43,17 @@ public abstract class SuggestedNameInfo { } /** - * Should be called when one of the suggested names has been chosen by the user, to - * update the statistics on name usage. + *

Should be called when one of the suggested names has been chosen by the user, to + * update the statistics on name usage.

+ *

Note to implementers: do not leave this method non-overridden as it going to be abstract.

* * @param name the accepted suggestion. */ - public abstract void nameChoosen(String name); + public void nameChosen(String name) { } + /** @deprecated override {@linkplain #nameChosen(String)} instead (to remove in IDEA 13) */ + @SuppressWarnings("UnusedDeclaration") + public void nameChoosen(String name) { nameChosen(name); } public static class Delegate extends SuggestedNameInfo { SuggestedNameInfo myDelegate; @@ -58,9 +64,8 @@ public abstract class SuggestedNameInfo { } @Override - public void nameChoosen(final String name) { - myDelegate.nameChoosen(name); + public void nameChosen(final String name) { + myDelegate.nameChosen(name); } } - } diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java index 00a7d80e3a66..0c759ca07580 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.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. @@ -265,7 +265,7 @@ public class RenameDialog extends RefactoringDialog { elementProcessor.setToSearchForTextOccurrences(myPsiElement, isSearchInNonJavaFiles()); } if (mySuggestedNameInfo != null) { - mySuggestedNameInfo.nameChoosen(newName); + mySuggestedNameInfo.nameChosen(newName); } final RenameProcessor processor = new RenameProcessor(getProject(), myPsiElement, newName, isSearchInComments(), diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyNameSuggestionProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyNameSuggestionProvider.java index 50cac8e33891..0f31267c0207 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyNameSuggestionProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyNameSuggestionProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 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. @@ -43,7 +43,7 @@ public class GroovyNameSuggestionProvider implements NameSuggestionProvider { result.addAll(Arrays.asList(names)); return new SuggestedNameInfo(names) { @Override - public void nameChoosen(String name) { + public void nameChosen(String name) { JavaStatisticsManager .incVariableNameUseCount(name, JavaCodeStyleManager.getInstance(element.getProject()).getVariableKind((GrVariable)element), ((GrVariable)element).getName(), type); From 721229a05ddeddfc8622869e3d2d89230f3eae26 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Sat, 9 Jun 2012 14:13:34 +0400 Subject: [PATCH 037/172] Don't issue clicks on popup triggers --- .../platform-api/src/com/intellij/ui/ClickListener.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/ClickListener.java b/platform/platform-api/src/com/intellij/ui/ClickListener.java index 0b1a371ede18..00c8b16bb304 100644 --- a/platform/platform-api/src/com/intellij/ui/ClickListener.java +++ b/platform/platform-api/src/com/intellij/ui/ClickListener.java @@ -36,7 +36,9 @@ public abstract class ClickListener { @Override public void mousePressed(MouseEvent e) { - clickPoint = e.getPoint(); + if (!e.isPopupTrigger()) { + clickPoint = e.getPoint(); + } } @Override @@ -45,8 +47,9 @@ public abstract class ClickListener { Point clickedAt = clickPoint; clickPoint = null; - if (releasedAt.x < 0 || releasedAt.y < 0 || releasedAt.x >= c.getWidth() || releasedAt.y >= c.getWidth()) return; if (clickedAt == null) return; + if (e.isPopupTrigger()) return; + if (releasedAt.x < 0 || releasedAt.y < 0 || releasedAt.x >= c.getWidth() || releasedAt.y >= c.getWidth()) return; if (Math.abs(clickedAt.x - releasedAt.x) < EPS && Math.abs(clickedAt.y - releasedAt.y) < EPS) { onClick(e); From 93488641f85acf68533ca77d85d475605464a5ce Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Sat, 9 Jun 2012 14:25:41 +0400 Subject: [PATCH 038/172] Lambda expressions support: drop generic lambda expressions --- .../com/intellij/psi/PsiLambdaExpression.java | 8 --- .../lang/java/parser/ExpressionParser.java | 64 ++++++------------- .../lang/java/parser/ReferenceParser.java | 16 ----- .../com/intellij/psi/impl/PsiImplUtil.java | 15 +++-- .../tree/java/PsiLambdaExpressionImpl.java | 6 -- .../advHighlighting7/LambdaExpressions.java | 5 -- .../expressions/LambdaExpression12.txt | 43 ++++--------- .../expressions/LambdaExpression13.txt | 23 ++----- .../parser/partial/ExpressionParserTest.java | 4 +- 9 files changed, 49 insertions(+), 135 deletions(-) diff --git a/java/java-psi-api/src/com/intellij/psi/PsiLambdaExpression.java b/java/java-psi-api/src/com/intellij/psi/PsiLambdaExpression.java index 43633328c66d..471597a0a529 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiLambdaExpression.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiLambdaExpression.java @@ -22,14 +22,6 @@ import org.jetbrains.annotations.Nullable; * Represents a Java lambda expression. */ public interface PsiLambdaExpression extends PsiExpression { - /** - * Returns this lambda expression's type parameter list (if any). - * - * @return type parameter list or null. - */ - @Nullable - PsiTypeParameterList getTypeParameterList(); - /** * Returns this lambda expression's parameter list. * diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java index a0cc7a36a34c..ff2f21a5e07d 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java @@ -163,7 +163,7 @@ public class ExpressionParser { return parseBinary(builder, ExprType.UNARY, MULTIPLICATIVE_OPS); case UNARY: - return parseUnary(builder, false); + return parseUnary(builder); case TYPE: return myParser.getReferenceParser().parseType(builder, ReferenceParser.EAT_LAST_DOT | ReferenceParser.WILDCARD); @@ -246,14 +246,14 @@ public class ExpressionParser { } @Nullable - private PsiBuilder.Marker parseUnary(final PsiBuilder builder, final boolean afterCast) { + private PsiBuilder.Marker parseUnary(final PsiBuilder builder) { final IElementType tokenType = builder.getTokenType(); if (PREFIX_OPS.contains(tokenType)) { final PsiBuilder.Marker unary = builder.mark(); builder.advanceLexer(); - final PsiBuilder.Marker operand = parseUnary(builder, false); + final PsiBuilder.Marker operand = parseUnary(builder); if (operand == null) { error(builder, JavaErrorMessages.message("expected.expression")); } @@ -269,19 +269,19 @@ public class ExpressionParser { myParser.getReferenceParser().parseTypeInfo(builder, ReferenceParser.EAT_LAST_DOT | ReferenceParser.WILDCARD); if (typeInfo == null || !expect(builder, JavaTokenType.RPARENTH)) { typeCast.rollbackTo(); - return parsePostfix(builder, false); + return parsePostfix(builder); } if (PREF_ARITHMETIC_OPS.contains(builder.getTokenType()) && !typeInfo.isPrimitive) { typeCast.rollbackTo(); - return parsePostfix(builder, false); + return parsePostfix(builder); } - final PsiBuilder.Marker expr = parseUnary(builder, true); + final PsiBuilder.Marker expr = parseUnary(builder); if (expr == null) { if (!typeInfo.isParameterized) { // cannot parse correct parenthesized expression after correct parameterized type typeCast.rollbackTo(); - return parsePostfix(builder, false); + return parsePostfix(builder); } else { error(builder, JavaErrorMessages.message("expected.expression")); @@ -292,13 +292,13 @@ public class ExpressionParser { return typeCast; } else { - return parsePostfix(builder, afterCast); + return parsePostfix(builder); } } @Nullable - private PsiBuilder.Marker parsePostfix(final PsiBuilder builder, final boolean afterCast) { - PsiBuilder.Marker operand = parsePrimary(builder, null, -1, afterCast); + private PsiBuilder.Marker parsePostfix(final PsiBuilder builder) { + PsiBuilder.Marker operand = parsePrimary(builder, null, -1); if (operand == null) return null; while (POSTFIX_OPS.contains(builder.getTokenType())) { @@ -315,13 +315,10 @@ public class ExpressionParser { // todo[r.sh] make 'this', 'super' and 'class' reference expressions @Nullable - private PsiBuilder.Marker parsePrimary(final PsiBuilder builder, - @Nullable final BreakPoint breakPoint, - final int breakOffset, - final boolean afterCast) { + private PsiBuilder.Marker parsePrimary(final PsiBuilder builder, @Nullable final BreakPoint breakPoint, final int breakOffset) { PsiBuilder.Marker startMarker = builder.mark(); - PsiBuilder.Marker expr = parsePrimaryExpressionStart(builder, afterCast); + PsiBuilder.Marker expr = parsePrimaryExpressionStart(builder); if (expr == null) { startMarker.drop(); return null; @@ -349,7 +346,7 @@ public class ExpressionParser { final PsiBuilder.Marker classObjAccess = parseClassAccessOrMethodReference(builder); if (classObjAccess == null || builder.getCurrentOffset() < offset) { copy.rollbackTo(); - return parsePrimary(builder, BreakPoint.P1, offset, false); + return parsePrimary(builder, BreakPoint.P1, offset); } startMarker = copy; @@ -373,13 +370,13 @@ public class ExpressionParser { final PsiBuilder.Marker ref = myParser.getReferenceParser().parseJavaCodeReference(builder, false, true, false, false, false); if (ref == null || builder.getTokenType() != JavaTokenType.DOT || builder.getCurrentOffset() != dotOffset) { copy.rollbackTo(); - return parsePrimary(builder, BreakPoint.P2, offset, false); + return parsePrimary(builder, BreakPoint.P2, offset); } builder.advanceLexer(); if (builder.getTokenType() != dotTokenType) { copy.rollbackTo(); - return parsePrimary(builder, BreakPoint.P2, offset, false); + return parsePrimary(builder, BreakPoint.P2, offset); } builder.advanceLexer(); @@ -420,7 +417,7 @@ public class ExpressionParser { final PsiBuilder.Marker copy = startMarker.precede(); startMarker.rollbackTo(); - final PsiBuilder.Marker qualifier = parsePrimaryExpressionStart(builder, false); + final PsiBuilder.Marker qualifier = parsePrimaryExpressionStart(builder); if (qualifier != null) { final PsiBuilder.Marker refExpr = qualifier.precede(); if (builder.getTokenType() == JavaTokenType.DOT) { @@ -436,7 +433,7 @@ public class ExpressionParser { } copy.rollbackTo(); - return parsePrimary(builder, BreakPoint.P3, -1, false); + return parsePrimary(builder, BreakPoint.P3, -1); } else { startMarker.drop(); @@ -465,7 +462,7 @@ public class ExpressionParser { final PsiBuilder.Marker classObjAccess = parseClassAccessOrMethodReference(builder); if (classObjAccess == null || builder.getCurrentOffset() <= pos) { copy.rollbackTo(); - return parsePrimary(builder, BreakPoint.P4, -1, false); + return parsePrimary(builder, BreakPoint.P4, -1); } startMarker = copy; @@ -505,7 +502,7 @@ public class ExpressionParser { } @Nullable - private PsiBuilder.Marker parsePrimaryExpressionStart(final PsiBuilder builder, final boolean afterCast) { + private PsiBuilder.Marker parsePrimaryExpressionStart(final PsiBuilder builder) { IElementType tokenType = builder.getTokenType(); if (LITERALS.contains(tokenType)) { @@ -597,29 +594,6 @@ public class ExpressionParser { if (tokenType == JavaTokenType.LT) { expr = builder.mark(); - if (!afterCast) { - final PsiBuilder.Marker typeParams = myParser.getReferenceParser().parseTypeParameters(builder, true); - - if (typeParams != null) { - tokenType = builder.getTokenType(); - - PsiBuilder.Marker lambda = null; - if (tokenType == JavaTokenType.LPARENTH) { - lambda = parseLambdaAfterParenth(builder, typeParams); - } - else if (tokenType == JavaTokenType.IDENTIFIER && builder.lookAhead(1) == JavaTokenType.ARROW) { - lambda = parseLambdaExpression(builder, false, typeParams); - } - if (lambda != null) { - expr.drop(); - return lambda; - } - - expr.rollbackTo(); - expr = builder.mark(); - } - } - if (!myParser.getReferenceParser().parseReferenceParameterList(builder, false, false)) { expr.rollbackTo(); return null; diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/ReferenceParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/ReferenceParser.java index 1eca52592faa..0555b567fcaa 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/ReferenceParser.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/ReferenceParser.java @@ -297,13 +297,6 @@ public class ReferenceParser { @NotNull public PsiBuilder.Marker parseTypeParameters(final PsiBuilder builder) { - final PsiBuilder.Marker marker = parseTypeParameters(builder, false); - assert marker != null; - return marker; - } - - @Nullable - public PsiBuilder.Marker parseTypeParameters(final PsiBuilder builder, final boolean stopOnErrors) { final PsiBuilder.Marker list = builder.mark(); if (!expect(builder, JavaTokenType.LT)) { list.done(JavaElementType.TYPE_PARAMETER_LIST); @@ -313,10 +306,6 @@ public class ReferenceParser { while (true) { final PsiBuilder.Marker param = parseTypeParameter(builder); if (param == null) { - if (stopOnErrors) { - list.rollbackTo(); - return null; - } error(builder, JavaErrorMessages.message("expected.type.parameter")); } if (!expect(builder, JavaTokenType.COMMA)) { @@ -325,11 +314,6 @@ public class ReferenceParser { } if (!expect(builder, JavaTokenType.GT)) { - if (stopOnErrors) { - list.rollbackTo(); - return null; - } - // hack for completion if (builder.getTokenType() == JavaTokenType.IDENTIFIER) { if (builder.lookAhead(1) == JavaTokenType.GT) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java index 102087ed75c0..0187be53a9fa 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java @@ -187,7 +187,7 @@ public class PsiImplUtil { final boolean fromBody = lastParent instanceof PsiCodeBlock; final PsiTypeParameterList typeParameterList = method.getTypeParameterList(); final PsiParameterList parameterList = method.getParameterList(); - return processDeclarationsInMethodLike(method, processor, state, fromBody, place, typeParameterList, parameterList); + return processDeclarationsInMethodLike(method, processor, state, place, fromBody, typeParameterList, parameterList); } public static boolean processDeclarationsInLambda(@NotNull final PsiLambdaExpression lambda, @@ -196,23 +196,24 @@ public class PsiImplUtil { final PsiElement lastParent, @NotNull final PsiElement place) { final boolean fromBody = lastParent != null && lastParent == lambda.getBody(); - final PsiTypeParameterList typeParameterList = lambda.getTypeParameterList(); final PsiParameterList parameterList = lambda.getParameterList(); - return processDeclarationsInMethodLike(lambda, processor, state, fromBody, place, typeParameterList, parameterList); + return processDeclarationsInMethodLike(lambda, processor, state, place, fromBody, null, parameterList); } private static boolean processDeclarationsInMethodLike(@NotNull final PsiElement element, @NotNull final PsiScopeProcessor processor, @NotNull final ResolveState state, - final boolean fromBody, @NotNull final PsiElement place, + final boolean fromBody, @Nullable final PsiTypeParameterList typeParameterList, @NotNull final PsiParameterList parameterList) { processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, element); - final ElementClassHint hint = processor.getHint(ElementClassHint.KEY); - if (hint == null || hint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) { - if (typeParameterList != null && !typeParameterList.processDeclarations(processor, state, null, place)) return false; + if (typeParameterList != null) { + final ElementClassHint hint = processor.getHint(ElementClassHint.KEY); + if (hint == null || hint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) { + if (!typeParameterList.processDeclarations(processor, state, null, place)) return false; + } } if (fromBody) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java index 3d80882b8d53..8ca6fce91d88 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java @@ -27,12 +27,6 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi super(JavaElementType.LAMBDA_EXPRESSION); } - @Override - public PsiTypeParameterList getTypeParameterList() { - final PsiElement element = getFirstChild(); - return element instanceof PsiTypeParameterList ? (PsiTypeParameterList)element : null; - } - @NotNull @Override public PsiParameterList getParameterList() { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/LambdaExpressions.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/LambdaExpressions.java index 129b60a46457..9a979bf22893 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/LambdaExpressions.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/LambdaExpressions.java @@ -26,16 +26,11 @@ class C { int parse(String s); } - interface ListProducer { - List produce(); - } - void test() { Simplest simplest = () -> { }; use(() -> { }); IntParser intParser = (String s) -> Integer.parseInt(s); - ListProducer listProducer = () -> new ArrayList(); } Runnable foo() { diff --git a/java/java-tests/testData/psi/parser-partial/expressions/LambdaExpression12.txt b/java/java-tests/testData/psi/parser-partial/expressions/LambdaExpression12.txt index ca651c993104..576a40ebec84 100644 --- a/java/java-tests/testData/psi/parser-partial/expressions/LambdaExpression12.txt +++ b/java/java-tests/testData/psi/parser-partial/expressions/LambdaExpression12.txt @@ -1,33 +1,18 @@ PsiJavaFile:LambdaExpression12.java - PsiLambdaExpression:() -> new C() - PsiTypeParameterList - PsiJavaToken:LT('<') - PsiTypeParameter:T - PsiIdentifier:T('T') - PsiElement(EXTENDS_BOUND_LIST) - - PsiJavaToken:GT('>') - PsiParameterList:() - PsiJavaToken:LPARENTH('(') - PsiJavaToken:RPARENTH(')') + PsiErrorElement:Unparsed tokens + PsiJavaToken:LT('<') + PsiIdentifier:T('T') + PsiJavaToken:GT('>') + PsiJavaToken:LPARENTH('(') + PsiJavaToken:RPARENTH(')') PsiWhiteSpace(' ') PsiJavaToken:ARROW('->') PsiWhiteSpace(' ') - PsiNewExpression:new C() - PsiKeyword:new('new') - PsiReferenceParameterList - - PsiWhiteSpace(' ') - PsiJavaCodeReferenceElement:C - PsiIdentifier:C('C') - PsiReferenceParameterList - PsiJavaToken:LT('<') - PsiTypeElement:T - PsiJavaCodeReferenceElement:T - PsiIdentifier:T('T') - PsiReferenceParameterList - - PsiJavaToken:GT('>') - PsiExpressionList - PsiJavaToken:LPARENTH('(') - PsiJavaToken:RPARENTH(')') \ No newline at end of file + PsiKeyword:new('new') + PsiWhiteSpace(' ') + PsiIdentifier:C('C') + PsiJavaToken:LT('<') + PsiIdentifier:T('T') + PsiJavaToken:GT('>') + PsiJavaToken:LPARENTH('(') + PsiJavaToken:RPARENTH(')') \ No newline at end of file diff --git a/java/java-tests/testData/psi/parser-partial/expressions/LambdaExpression13.txt b/java/java-tests/testData/psi/parser-partial/expressions/LambdaExpression13.txt index 2d0cfcd4ed32..2b6c6786cfbb 100644 --- a/java/java-tests/testData/psi/parser-partial/expressions/LambdaExpression13.txt +++ b/java/java-tests/testData/psi/parser-partial/expressions/LambdaExpression13.txt @@ -1,21 +1,10 @@ PsiJavaFile:LambdaExpression13.java - PsiLambdaExpression:t -> t - PsiTypeParameterList - PsiJavaToken:LT('<') - PsiTypeParameter:T - PsiIdentifier:T('T') - PsiElement(EXTENDS_BOUND_LIST) - - PsiJavaToken:GT('>') - PsiParameterList:t - PsiParameter:t - PsiModifierList: - - PsiIdentifier:t('t') + PsiErrorElement:Unparsed tokens + PsiJavaToken:LT('<') + PsiIdentifier:T('T') + PsiJavaToken:GT('>') + PsiIdentifier:t('t') PsiWhiteSpace(' ') PsiJavaToken:ARROW('->') PsiWhiteSpace(' ') - PsiReferenceExpression:t - PsiReferenceParameterList - - PsiIdentifier:t('t') \ No newline at end of file + PsiIdentifier:t('t') \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java index f54cc3443386..8f5726aba7f3 100644 --- a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java +++ b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java @@ -134,8 +134,8 @@ public class ExpressionParserTest extends JavaParsingTestCase { public void testLambdaExpression9() { doParserTest("(I)p -> null"); } public void testLambdaExpression10() { doParserTest("(I)(p -> null)"); } public void testLambdaExpression11() { doParserTest("() -> { }"); } - public void testLambdaExpression12() { doParserTest("() -> new C()"); } - public void testLambdaExpression13() { doParserTest("t -> t"); } + public void testLambdaExpression12() { doParserTest("() -> new C()"); } // these two expressions + public void testLambdaExpression13() { doParserTest("t -> t"); } // should no longer be parsed public void testLambdaExpression14() { doParserTest("(String t) -> t"); } public void testLambdaExpression15() { doParserTest("(int a, int b) -> a + b"); } public void testLambdaExpression16() { doParserTest("(final int x) -> x"); } From a91a4423e428798f437b5c3c9e2f4732fd355086 Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Sat, 9 Jun 2012 15:10:06 +0400 Subject: [PATCH 039/172] EA-36364 (dispose module after external modify project structure) --- .../designer/AndroidDesignerEditor.java | 4 +- .../designer/actions/ProfileAction.java | 4 +- .../AndroidDesignerEditorPanel.java | 23 ++++---- .../model/RadCustomViewComponent.java | 12 ++-- .../android/designer/model/RadFragment.java | 6 +- .../designer/model/RadIncludeLayout.java | 6 +- .../designer/profile/ProfileDialog.java | 8 +-- .../designer/profile/ProfileManager.java | 17 +++--- .../propertyTable/editors/ResourceEditor.java | 6 +- .../uiDesigner/CutCopyPasteSupport.java | 6 +- .../intellij/uiDesigner/FormEditingUtil.java | 2 +- .../intellij/uiDesigner/GridBuildUtil.java | 2 +- .../intellij/uiDesigner/ModuleProvider.java | 28 ++++++++++ .../uiDesigner/StringDescriptorManager.java | 8 ++- .../com/intellij/uiDesigner/XmlReader.java | 9 ++- .../componentTree/ComponentTree.java | 2 +- .../designSurface/CachedGridImage.java | 2 +- .../uiDesigner/designSurface/GuiEditor.java | 55 +++++++++++-------- .../InsertComponentProcessor.java | 16 +++--- .../uiDesigner/editor/UIFormEditor.java | 4 +- .../editors/BindingEditor.java | 2 +- .../editors/ColorEditor.java | 2 +- .../propertyInspector/editors/FontEditor.java | 2 +- .../propertyInspector/editors/IconEditor.java | 30 +++++----- .../properties/BindingProperty.java | 2 +- .../properties/ClassToBindProperty.java | 13 ++--- .../radComponents/RadAtomicComponent.java | 4 +- .../radComponents/RadComponent.java | 29 +++++----- .../radComponents/RadComponentFactory.java | 8 ++- .../radComponents/RadContainer.java | 11 ++-- .../radComponents/RadErrorComponent.java | 32 +++++------ .../uiDesigner/radComponents/RadHSpacer.java | 28 +++++----- .../radComponents/RadNestedForm.java | 22 ++++---- .../radComponents/RadRootContainer.java | 4 +- .../radComponents/RadScrollPane.java | 6 +- .../radComponents/RadSplitPane.java | 6 +- .../radComponents/RadTabbedPane.java | 7 +-- .../uiDesigner/radComponents/RadTable.java | 6 +- .../uiDesigner/radComponents/RadToolBar.java | 10 ++-- .../uiDesigner/radComponents/RadVSpacer.java | 20 ++++--- .../com/intellij/designer/DesignerEditor.java | 4 +- .../com/intellij/designer/ModuleProvider.java | 28 ++++++++++ .../designSurface/DesignerEditorPanel.java | 24 ++++++-- 43 files changed, 304 insertions(+), 216 deletions(-) create mode 100644 plugins/ui-designer/src/com/intellij/uiDesigner/ModuleProvider.java create mode 100644 plugins/ui-designer/ui-designer-new/src/com/intellij/designer/ModuleProvider.java diff --git a/plugins/android-designer/src/com/intellij/android/designer/AndroidDesignerEditor.java b/plugins/android-designer/src/com/intellij/android/designer/AndroidDesignerEditor.java index 246ed81854ac..8be4d3416681 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/AndroidDesignerEditor.java +++ b/plugins/android-designer/src/com/intellij/android/designer/AndroidDesignerEditor.java @@ -37,8 +37,8 @@ public final class AndroidDesignerEditor extends DesignerEditor { @Override @NotNull - protected DesignerEditorPanel createDesignerPanel(Module module, VirtualFile file) { - return new AndroidDesignerEditorPanel(module, file); + protected DesignerEditorPanel createDesignerPanel(Project project, Module module, VirtualFile file) { + return new AndroidDesignerEditorPanel(project, module, file); } @NotNull diff --git a/plugins/android-designer/src/com/intellij/android/designer/actions/ProfileAction.java b/plugins/android-designer/src/com/intellij/android/designer/actions/ProfileAction.java index 1285214bf511..1292a9265554 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/actions/ProfileAction.java +++ b/plugins/android-designer/src/com/intellij/android/designer/actions/ProfileAction.java @@ -52,7 +52,7 @@ public class ProfileAction { myProfileList = ProfileList.getInstance(myDesigner.getProject()); - myProfileManager = new ProfileManager(myDesigner.getModule(), refreshAction, new Runnable() { + myProfileManager = new ProfileManager(myDesigner, refreshAction, new Runnable() { @Override public void run() { myProfileList.addVersion(); @@ -142,7 +142,7 @@ public class ProfileAction { } private void editProfiles() { - ProfileDialog dialog = new ProfileDialog(myDesigner.getModule(), myProfileList.getProfiles()); + ProfileDialog dialog = new ProfileDialog(myDesigner, myProfileList.getProfiles()); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { diff --git a/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java b/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java index c80cc39e88b6..dd22f60250d4 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java +++ b/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java @@ -42,6 +42,7 @@ import com.intellij.openapi.application.ex.ApplicationManagerEx; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.EmptyProgressIndicator; import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -76,8 +77,8 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel { private boolean myParseTime; private int myProfileLastVersion; - public AndroidDesignerEditorPanel(@NotNull Module module, @NotNull VirtualFile file) { - super(module, file); + public AndroidDesignerEditorPanel(@NotNull Project project, @NotNull Module module, @NotNull VirtualFile file) { + super(project, module, file); myXmlFile = (XmlFile)ApplicationManager.getApplication().runReadAction(new Computable() { @Override @@ -151,10 +152,10 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel { RadViewComponent newRootComponent = parser.getRootComponent(); newRootComponent.setClientProperty(ModelParser.XML_FILE_KEY, myXmlFile); - newRootComponent.setClientProperty(ModelParser.MODULE_KEY, getModule()); + newRootComponent.setClientProperty(ModelParser.MODULE_KEY, AndroidDesignerEditorPanel.this); newRootComponent.setClientProperty(TreeComponentDecorator.KEY, myTreeDecorator); - PropertyParser propertyParser = new PropertyParser(myModule, myProfileAction.getProfileManager().getSelectedTarget()); + PropertyParser propertyParser = new PropertyParser(getModule(), myProfileAction.getProfileManager().getSelectedTarget()); newRootComponent.setClientProperty(PropertyParser.KEY, propertyParser); propertyParser.loadRecursive(newRootComponent); @@ -195,12 +196,12 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel { myProfileLastVersion = myProfileAction.getVersion(); - AndroidPlatform platform = AndroidPlatform.getInstance(myModule); + AndroidPlatform platform = AndroidPlatform.getInstance(getModule()); if (platform == null) { throw new AndroidSdkNotConfiguredException(); } - AndroidFacet facet = AndroidFacet.getInstance(myModule); + AndroidFacet facet = AndroidFacet.getInstance(getModule()); ProfileManager manager = myProfileAction.getProfileManager(); LayoutDeviceConfiguration deviceConfiguration = manager.getSelectedDeviceConfiguration(); @@ -231,7 +232,7 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel { } RenderingResult result = - RenderUtil.renderLayout(myModule, layoutXmlText, myFile, null, target, facet, config, xdpi, ydpi, theme, 10000, true); + RenderUtil.renderLayout(getModule(), layoutXmlText, myFile, null, target, facet, config, xdpi, ydpi, theme, 10000, true); if (ApplicationManagerEx.getApplicationEx().isInternal()) { System.out.println("Render time: " + (System.currentTimeMillis() - time)); // XXX @@ -327,15 +328,15 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel { info.myShowLog = false; info.myShowStack = false; - if (AndroidMavenUtil.isMavenizedModule(myModule)) { + if (AndroidMavenUtil.isMavenizedModule(getModule())) { info.myMessages.add(new FixableMessageInfo(true, AndroidBundle.message("android.maven.cannot.parse.android.sdk.error", - myModule.getName()), "", "", null, null)); + getModule().getName()), "", "", null, null)); } else { info.myMessages.add(new FixableMessageInfo(true, "Please ", "configure", " Android SDK", new Runnable() { @Override public void run() { - AndroidSdkUtils.openModuleDependenciesConfigurable(myModule); + AndroidSdkUtils.openModuleDependenciesConfigurable(getModule()); } }, null)); } @@ -381,7 +382,7 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel { StringBuilder builder = new StringBuilder("SDK: "); try { - AndroidPlatform platform = AndroidPlatform.getInstance(myModule); + AndroidPlatform platform = AndroidPlatform.getInstance(getModule()); IAndroidTarget target = platform.getTarget(); builder.append(target.getFullName()).append(" - ").append(target.getVersion()); } diff --git a/plugins/android-designer/src/com/intellij/android/designer/model/RadCustomViewComponent.java b/plugins/android-designer/src/com/intellij/android/designer/model/RadCustomViewComponent.java index cf37b15395ff..1457f4b4661d 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/model/RadCustomViewComponent.java +++ b/plugins/android-designer/src/com/intellij/android/designer/model/RadCustomViewComponent.java @@ -17,6 +17,7 @@ package com.intellij.android.designer.model; import com.intellij.android.designer.propertyTable.CustomViewProperty; import com.intellij.android.designer.propertyTable.editors.ChooseClassDialog; +import com.intellij.designer.ModuleProvider; import com.intellij.designer.componentTree.AttributeWrapper; import com.intellij.designer.model.IComponentDecorator; import com.intellij.designer.model.MetaManager; @@ -24,7 +25,6 @@ import com.intellij.designer.model.MetaModel; import com.intellij.designer.model.RadComponent; import com.intellij.designer.propertyTable.Property; import com.intellij.designer.propertyTable.PropertyTable; -import com.intellij.openapi.module.Module; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiClass; @@ -66,9 +66,9 @@ public class RadCustomViewComponent extends RadViewComponent implements IConfigu @Nullable public static String chooseView(RadComponent rootComponent) { - Module module = rootComponent.getClientProperty(ModelParser.MODULE_KEY); + ModuleProvider moduleProvider = rootComponent.getClientProperty(ModelParser.MODULE_KEY); ChooseClassDialog dialog = - new ChooseClassDialog(module, "View Dialog", false, "android.view.View"); + new ChooseClassDialog(moduleProvider.getModule(), "View Dialog", false, "android.view.View"); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { @@ -108,9 +108,9 @@ public class RadCustomViewComponent extends RadViewComponent implements IConfigu MetaModel metaModel = getClientProperty(MODEL_KEY); if (metaModel == null) { - Module module = getRoot().getClientProperty(ModelParser.MODULE_KEY); - MetaManager metaManager = ViewsMetaManager.getInstance(module.getProject()); - PsiClass viewClass = ChooseClassDialog.findClass(module, getViewClass()); + ModuleProvider moduleProvider = getRoot().getClientProperty(ModelParser.MODULE_KEY); + MetaManager metaManager = ViewsMetaManager.getInstance(moduleProvider.getProject()); + PsiClass viewClass = ChooseClassDialog.findClass(moduleProvider.getModule(), getViewClass()); while (viewClass != null) { metaModel = metaManager.getModelByTarget(viewClass.getQualifiedName()); diff --git a/plugins/android-designer/src/com/intellij/android/designer/model/RadFragment.java b/plugins/android-designer/src/com/intellij/android/designer/model/RadFragment.java index 7a3ff434924f..1a2a586b8058 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/model/RadFragment.java +++ b/plugins/android-designer/src/com/intellij/android/designer/model/RadFragment.java @@ -20,10 +20,10 @@ import com.intellij.android.designer.propertyTable.IdProperty; import com.intellij.android.designer.propertyTable.JavadocParser; import com.intellij.android.designer.propertyTable.editors.ChooseClassDialog; import com.intellij.android.designer.propertyTable.editors.ResourceEditor; +import com.intellij.designer.ModuleProvider; import com.intellij.designer.model.RadComponent; import com.intellij.designer.propertyTable.Property; import com.intellij.designer.propertyTable.editors.TextEditor; -import com.intellij.openapi.module.Module; import com.intellij.openapi.ui.DialogWrapper; import org.jetbrains.android.dom.attrs.AttributeFormat; import org.jetbrains.annotations.Nullable; @@ -81,9 +81,9 @@ public class RadFragment extends RadViewComponent implements IConfigurableCompon @Nullable private static String chooseFragment(RadComponent rootComponent) { - Module module = rootComponent.getClientProperty(ModelParser.MODULE_KEY); + ModuleProvider moduleProvider = rootComponent.getClientProperty(ModelParser.MODULE_KEY); ChooseClassDialog dialog = - new ChooseClassDialog(module, "Fragment Dialog", true, "android.app.Fragment", "android.support.v4.app.Fragment"); + new ChooseClassDialog(moduleProvider.getModule(), "Fragment Dialog", true, "android.app.Fragment", "android.support.v4.app.Fragment"); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { diff --git a/plugins/android-designer/src/com/intellij/android/designer/model/RadIncludeLayout.java b/plugins/android-designer/src/com/intellij/android/designer/model/RadIncludeLayout.java index 2f1b1b402fcf..d61aea00f29a 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/model/RadIncludeLayout.java +++ b/plugins/android-designer/src/com/intellij/android/designer/model/RadIncludeLayout.java @@ -18,9 +18,9 @@ package com.intellij.android.designer.model; import com.intellij.android.designer.propertyTable.IdProperty; import com.intellij.android.designer.propertyTable.IncludeLayoutProperty; import com.intellij.android.designer.propertyTable.editors.ResourceDialog; +import com.intellij.designer.ModuleProvider; import com.intellij.designer.model.RadComponent; import com.intellij.designer.propertyTable.Property; -import com.intellij.openapi.module.Module; import com.intellij.openapi.ui.DialogWrapper; import java.util.ArrayList; @@ -40,8 +40,8 @@ public class RadIncludeLayout extends RadViewComponent implements IConfigurableC } public void configure(RadComponent rootComponent) throws Exception { - Module module = rootComponent.getClientProperty(ModelParser.MODULE_KEY); - ResourceDialog dialog = new ResourceDialog(module, IncludeLayoutProperty.TYPES); + ModuleProvider moduleProvider = rootComponent.getClientProperty(ModelParser.MODULE_KEY); + ResourceDialog dialog = new ResourceDialog(moduleProvider.getModule(), IncludeLayoutProperty.TYPES); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { diff --git a/plugins/android-designer/src/com/intellij/android/designer/profile/ProfileDialog.java b/plugins/android-designer/src/com/intellij/android/designer/profile/ProfileDialog.java index a7f1283c8f02..0da561885b3a 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/profile/ProfileDialog.java +++ b/plugins/android-designer/src/com/intellij/android/designer/profile/ProfileDialog.java @@ -15,8 +15,8 @@ */ package com.intellij.android.designer.profile; +import com.intellij.designer.ModuleProvider; import com.intellij.openapi.actionSystem.ex.ComboBoxAction; -import com.intellij.openapi.module.Module; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.ValidationInfo; import com.intellij.openapi.util.EmptyRunnable; @@ -63,8 +63,8 @@ public class ProfileDialog extends DialogWrapper { private final ProfileManager myProfileManager; - public ProfileDialog(Module module, List profiles) { - super(module.getProject(), false); + public ProfileDialog(ModuleProvider moduleProvider, List profiles) { + super(moduleProvider.getProject(), false); setTitle("Edit Profiles"); getOKAction().putValue(DEFAULT_ACTION, null); @@ -113,7 +113,7 @@ public class ProfileDialog extends DialogWrapper { decorator.setMoveUpAction(null); decorator.setMoveDownAction(null); - myProfileManager = new ProfileManager(module, EmptyRunnable.INSTANCE, EmptyRunnable.INSTANCE); + myProfileManager = new ProfileManager(moduleProvider, EmptyRunnable.INSTANCE, EmptyRunnable.INSTANCE); myContentPanel = new JPanel(new GridBagLayout()); diff --git a/plugins/android-designer/src/com/intellij/android/designer/profile/ProfileManager.java b/plugins/android-designer/src/com/intellij/android/designer/profile/ProfileManager.java index 22f47cedc164..f97c8893180a 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/profile/ProfileManager.java +++ b/plugins/android-designer/src/com/intellij/android/designer/profile/ProfileManager.java @@ -21,6 +21,7 @@ import com.android.ide.common.resources.configuration.RegionQualifier; import com.android.resources.NightMode; import com.android.resources.UiMode; import com.android.sdklib.IAndroidTarget; +import com.intellij.designer.ModuleProvider; import com.intellij.designer.actions.AbstractComboBoxAction; import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.actionSystem.Presentation; @@ -45,7 +46,7 @@ import java.util.*; public class ProfileManager { private static final LayoutDevice CUSTOM_DEVICE = new LayoutDevice("Edit Devices", LayoutDevice.Type.CUSTOM); - private final Module myModule; + private final ModuleProvider myModuleProvider; private final Runnable myRefreshAction; private final Runnable mySelectionRunnable; @@ -65,12 +66,12 @@ public class ProfileManager { private Profile myProfile; - public ProfileManager(Module module, Runnable refreshAction, Runnable selectionRunnable) { - myModule = module; + public ProfileManager(ModuleProvider moduleProvider, Runnable refreshAction, Runnable selectionRunnable) { + myModuleProvider = moduleProvider; myRefreshAction = refreshAction; mySelectionRunnable = selectionRunnable; - myLayoutDeviceManager = ProfileList.getInstance(module.getProject()).getLayoutDeviceManager(); + myLayoutDeviceManager = ProfileList.getInstance(moduleProvider.getProject()).getLayoutDeviceManager(); myDeviceAction = new MyComboBoxAction() { @Override @@ -87,7 +88,7 @@ public class ProfileManager { LayoutDeviceConfiguration configuration = myDeviceConfigurationAction.getSelection(); configuration = configuration != null && configuration.getDevice().getType() == LayoutDevice.Type.CUSTOM ? configuration : null; LayoutDeviceConfigurationsDialog dialog = - new LayoutDeviceConfigurationsDialog(myModule.getProject(), configuration, myLayoutDeviceManager); + new LayoutDeviceConfigurationsDialog(myModuleProvider.getProject(), configuration, myLayoutDeviceManager); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { @@ -264,7 +265,7 @@ public class ProfileManager { } public Module getModule() { - return myModule; + return myModuleProvider.getModule(); } @Nullable @@ -340,7 +341,7 @@ public class ProfileManager { List locales = new ArrayList(); Map> language2Regions = new HashMap>(); - AndroidFacet facet = AndroidFacet.getInstance(myModule); + AndroidFacet facet = AndroidFacet.getInstance(getModule()); if (facet != null) { VirtualFile[] resourceDirs = facet.getLocalResourceManager().getAllResourceDirs(); for (VirtualFile resourceDir : resourceDirs) { @@ -586,7 +587,7 @@ public class ProfileManager { @Nullable private AndroidPlatform getPlatform(@Nullable Sdk sdk) { if (sdk == null) { - sdk = ProfileList.getInstance(myModule.getProject()).getModuleSdk(myModule); + sdk = ProfileList.getInstance(myModuleProvider.getProject()).getModuleSdk(getModule()); } if (isAndroidSdk(sdk)) { AndroidSdkAdditionalData additionalData = (AndroidSdkAdditionalData)sdk.getSdkAdditionalData(); diff --git a/plugins/android-designer/src/com/intellij/android/designer/propertyTable/editors/ResourceEditor.java b/plugins/android-designer/src/com/intellij/android/designer/propertyTable/editors/ResourceEditor.java index 147d4c0638c3..6dd95b4453e5 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/propertyTable/editors/ResourceEditor.java +++ b/plugins/android-designer/src/com/intellij/android/designer/propertyTable/editors/ResourceEditor.java @@ -17,11 +17,11 @@ package com.intellij.android.designer.propertyTable.editors; import com.android.resources.ResourceType; import com.intellij.android.designer.model.ModelParser; +import com.intellij.designer.ModuleProvider; import com.intellij.designer.model.RadComponent; import com.intellij.designer.propertyTable.InplaceContext; import com.intellij.designer.propertyTable.PropertyEditor; import com.intellij.designer.propertyTable.editors.ComboEditor; -import com.intellij.openapi.module.Module; import com.intellij.openapi.ui.ComponentWithBrowseButton; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.TextFieldWithBrowseButton; @@ -204,8 +204,8 @@ public class ResourceEditor extends PropertyEditor { } protected void showDialog() { - Module module = myRootComponent.getClientProperty(ModelParser.MODULE_KEY); - ResourceDialog dialog = new ResourceDialog(module, myTypes); + ModuleProvider moduleProvider = myRootComponent.getClientProperty(ModelParser.MODULE_KEY); + ResourceDialog dialog = new ResourceDialog(moduleProvider.getModule(), myTypes); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/CutCopyPasteSupport.java b/plugins/ui-designer/src/com/intellij/uiDesigner/CutCopyPasteSupport.java index 738144a3fce7..4fef2c8fbf4c 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/CutCopyPasteSupport.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/CutCopyPasteSupport.java @@ -23,7 +23,6 @@ import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.ide.CopyPasteManager; -import com.intellij.openapi.module.Module; import com.intellij.uiDesigner.compiler.Utils; import com.intellij.uiDesigner.designSurface.GuiEditor; import com.intellij.uiDesigner.lw.LwComponent; @@ -191,9 +190,8 @@ public final class CutCopyPasteSupport implements CopyProvider, CutProvider, Pas } }); - final Module module = editor.getModule(); - final ClassLoader loader = LoaderFactory.getInstance(module.getProject()).getLoader(editor.getFile()); - final RadComponent radComponent = XmlReader.createComponent(module, lwComponent, loader, editor.getStringDescriptorLocale()); + final ClassLoader loader = LoaderFactory.getInstance(editor.getProject()).getLoader(editor.getFile()); + final RadComponent radComponent = XmlReader.createComponent(editor, lwComponent, loader, editor.getStringDescriptorLocale()); componentsToPaste.add(radComponent); } } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/FormEditingUtil.java b/plugins/ui-designer/src/com/intellij/uiDesigner/FormEditingUtil.java index 1accc693b0b5..faef895aa6d3 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/FormEditingUtil.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/FormEditingUtil.java @@ -442,7 +442,7 @@ public final class FormEditingUtil { } public static GridConstraints getDefaultConstraints(final RadComponent component) { - final Palette palette = Palette.getInstance(component.getModule().getProject()); + final Palette palette = Palette.getInstance(component.getProject()); final ComponentItem item = palette.getItem(component.getComponentClassName()); if (item != null) { return item.getDefaultConstraints(); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/GridBuildUtil.java b/plugins/ui-designer/src/com/intellij/uiDesigner/GridBuildUtil.java index 1af4013dcc73..2d710bf3296a 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/GridBuildUtil.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/GridBuildUtil.java @@ -197,7 +197,7 @@ public class GridBuildUtil { final Module module = editor.getModule(); final ComponentItem panelItem = Palette.getInstance(editor.getProject()).getPanelItem(); - final RadContainer newContainer = new RadContainer(module, FormEditingUtil.generateId(editor.getRootContainer())); + final RadContainer newContainer = new RadContainer(editor, FormEditingUtil.generateId(editor.getRootContainer())); newContainer.setLayout(gridLayoutManager); newContainer.init(editor, panelItem); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/ModuleProvider.java b/plugins/ui-designer/src/com/intellij/uiDesigner/ModuleProvider.java new file mode 100644 index 000000000000..505f02372d7f --- /dev/null +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/ModuleProvider.java @@ -0,0 +1,28 @@ +/* + * 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.uiDesigner; + +import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.Project; + +/** + * @author Alexander Lobas + */ +public interface ModuleProvider { + Module getModule(); + + Project getProject(); +} \ No newline at end of file diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/StringDescriptorManager.java b/plugins/ui-designer/src/com/intellij/uiDesigner/StringDescriptorManager.java index 000224c2ce94..5ab200647121 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/StringDescriptorManager.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/StringDescriptorManager.java @@ -41,7 +41,7 @@ import java.util.Map; * @author yole */ public class StringDescriptorManager { - private final Module myModule; + private Module myModule; private final Map, SoftReference> myPropertiesFileCache = new HashMap, SoftReference>(); public StringDescriptorManager(final Module module, MessageBus bus) { @@ -56,7 +56,11 @@ public class StringDescriptorManager { } public static StringDescriptorManager getInstance(Module module) { - return ModuleServiceManager.getService(module, StringDescriptorManager.class); + StringDescriptorManager service = ModuleServiceManager.getService(module, StringDescriptorManager.class); + if (service != null) { + service.myModule = module; + } + return service; } @Nullable public String resolve(@NotNull RadComponent component, @Nullable StringDescriptor descriptor) { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/XmlReader.java b/plugins/ui-designer/src/com/intellij/uiDesigner/XmlReader.java index 9170490fa324..9e314d6bfd5c 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/XmlReader.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/XmlReader.java @@ -16,7 +16,6 @@ package com.intellij.uiDesigner; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.module.Module; import com.intellij.uiDesigner.compiler.RecursiveFormNestingException; import com.intellij.uiDesigner.compiler.Utils; import com.intellij.uiDesigner.lw.*; @@ -45,13 +44,13 @@ public final class XmlReader { } @NotNull - public static RadRootContainer createRoot(final Module module, final LwRootContainer lwRootContainer, final ClassLoader loader, + public static RadRootContainer createRoot(final ModuleProvider module, final LwRootContainer lwRootContainer, final ClassLoader loader, final Locale stringDescriptorLocale) throws Exception{ return (RadRootContainer)createComponent(module, lwRootContainer, loader, stringDescriptorLocale); } @NotNull - public static RadComponent createComponent(@NotNull final Module module, + public static RadComponent createComponent(@NotNull final ModuleProvider module, @NotNull final LwComponent lwComponent, @NotNull final ClassLoader loader, final Locale stringDescriptorLocale) throws Exception{ @@ -64,7 +63,7 @@ public final class XmlReader { LwNestedForm nestedForm = (LwNestedForm) lwComponent; boolean recursiveNesting = false; try { - Utils.validateNestedFormLoop(nestedForm.getFormFileName(), new PsiNestedFormLoader(module)); + Utils.validateNestedFormLoop(nestedForm.getFormFileName(), new PsiNestedFormLoader(module.getModule())); } catch(RecursiveFormNestingException ex) { recursiveNesting = true; @@ -258,7 +257,7 @@ public final class XmlReader { container.setBorderColor(lwContainer.getBorderColor()); } - private static RadErrorComponent createErrorComponent(final Module module, final String id, final LwComponent lwComponent, final ClassLoader loader) { + private static RadErrorComponent createErrorComponent(final ModuleProvider module, final String id, final LwComponent lwComponent, final ClassLoader loader) { final String componentClassName = lwComponent.getComponentClassName(); final String errorDescription = Utils.validateJComponentClass(loader, componentClassName, true); return RadErrorComponent.create( diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/componentTree/ComponentTree.java b/plugins/ui-designer/src/com/intellij/uiDesigner/componentTree/ComponentTree.java index 341614d59ad6..7341d7a65afa 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/componentTree/ComponentTree.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/componentTree/ComponentTree.java @@ -358,7 +358,7 @@ public final class ComponentTree extends Tree implements DataProvider { public static Icon getComponentIcon(final RadComponent component) { if (!(component instanceof RadErrorComponent)) { - final Palette palette = Palette.getInstance(component.getModule().getProject()); + final Palette palette = Palette.getInstance(component.getProject()); final ComponentItem item = palette.getItem(component.getComponentClassName()); final Icon icon; if (item != null) { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/CachedGridImage.java b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/CachedGridImage.java index c0c824deed17..e570bdb49eb5 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/CachedGridImage.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/CachedGridImage.java @@ -41,7 +41,7 @@ public class CachedGridImage { private CachedGridImage(final RadContainer container) { final GraphicsConfiguration graphicsConfiguration = - WindowManagerEx.getInstanceEx().getFrame(container.getModule().getProject()).getGraphicsConfiguration(); + WindowManagerEx.getInstanceEx().getFrame(container.getProject()).getGraphicsConfiguration(); if (container.getWidth() * container.getHeight() < 4096*4096) { myImage = graphicsConfiguration.createCompatibleImage(container.getWidth(), container.getHeight(), Transparency.BITMASK); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java index 6e59ddc09207..d5e8dbbc09db 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java @@ -32,6 +32,7 @@ import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; import com.intellij.openapi.vfs.ReadonlyStatusHandler; @@ -82,10 +83,11 @@ import java.util.Map; * @author Anton Katilin * @author Vladimir Kondratyev */ -public final class GuiEditor extends JPanel implements DataProvider { +public final class GuiEditor extends JPanel implements DataProvider, ModuleProvider { private static final Logger LOG = Logger.getInstance("#com.intellij.uiDesigner.GuiEditor"); - @NotNull private final Module myModule; + private final Project myProject; + private Module myModule; @NotNull private final VirtualFile myFile; /** @@ -212,9 +214,10 @@ public final class GuiEditor extends JPanel implements DataProvider { * if the file * is null or file is not valid PsiFile */ - public GuiEditor(@NotNull final Module module, @NotNull final VirtualFile file) { + public GuiEditor(Project project, @NotNull final Module module, @NotNull final VirtualFile file) { LOG.assertTrue(file.isValid()); + myProject = project; myModule = module; myFile = file; @@ -265,9 +268,9 @@ public final class GuiEditor extends JPanel implements DataProvider { myDocumentListener = new DocumentAdapter() { public void documentChanged(final DocumentEvent e) { if (!myInsideChange) { - UndoManager undoManager = UndoManager.getInstance(module.getProject()); + UndoManager undoManager = UndoManager.getInstance(getProject()); alarm.cancelAllRequests(); - alarm.addRequest(new MySynchronizeRequest(module, undoManager.isUndoInProgress() || undoManager.isRedoInProgress()), + alarm.addRequest(new MySynchronizeRequest(undoManager.isUndoInProgress() || undoManager.isRedoInProgress()), 100/*any arbitrary delay*/, ModalityState.stateForComponent(GuiEditor.this)); } } @@ -318,7 +321,7 @@ public final class GuiEditor extends JPanel implements DataProvider { // PSI listener to restart error highlighter myPsiTreeChangeListener = new MyPsiTreeChangeListener(); - PsiManager.getInstance(module.getProject()).addPsiTreeChangeListener(myPsiTreeChangeListener); + PsiManager.getInstance(getProject()).addPsiTreeChangeListener(myPsiTreeChangeListener); myQuickFixManager = new QuickFixManagerImpl(this, myGlassLayer, myScrollPane.getViewport()); @@ -364,18 +367,26 @@ public final class GuiEditor extends JPanel implements DataProvider { paletteManager.removeDragEventListener(myPaletteDragListener); paletteManager.removeSelectionListener(myPaletteSelectionListener); myDocument.removeDocumentListener(myDocumentListener); - PsiManager.getInstance(myModule.getProject()).removePsiTreeChangeListener(myPsiTreeChangeListener); + PsiManager.getInstance(getProject()).removePsiTreeChangeListener(myPsiTreeChangeListener); myPsiTreeChangeListener.dispose(); } @NotNull - public Project getProject() { - return myModule.getProject(); + @Override + public Module getModule() { + if (myModule.isDisposed()) { + myModule = ModuleUtil.findModuleForFile(myFile, myProject); + if (myModule == null) { + throw new IllegalArgumentException("No module for file " + myFile + " in project " + myModule); + } + } + return myModule; } @NotNull - public Module getModule() { - return myModule; + @Override + public Project getProject() { + return myProject; } @NotNull @@ -400,7 +411,7 @@ public final class GuiEditor extends JPanel implements DataProvider { if (!GuiDesignerConfiguration.getInstance(getProject()).INSTRUMENT_CLASSES) { final String classToBind = myRootContainer.getClassToBind(); if (classToBind != null && classToBind.length() > 0) { - PsiClass psiClass = FormEditingUtil.findClassToBind(myModule, classToBind); + PsiClass psiClass = FormEditingUtil.findClassToBind(getModule(), classToBind); if (psiClass != null) { sourceFileToCheckOut = psiClass.getContainingFile().getVirtualFile(); } @@ -589,7 +600,7 @@ public final class GuiEditor extends JPanel implements DataProvider { private void saveToFile() { LOG.debug("GuiEditor.saveToFile(): group ID=" + myNextSaveGroupId); - CommandProcessor.getInstance().executeCommand(myModule.getProject(), new Runnable() { + CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() { public void run() { ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { @@ -825,10 +836,10 @@ public final class GuiEditor extends JPanel implements DataProvider { final String text = myDocument.getText(); - final ClassLoader classLoader = LoaderFactory.getInstance(myModule.getProject()).getLoader(myFile); + final ClassLoader classLoader = LoaderFactory.getInstance(getProject()).getLoader(myFile); final LwRootContainer rootContainer = Utils.getRootContainer(text, new CompiledClassPropertiesProvider(classLoader)); - final RadRootContainer container = XmlReader.createRoot(myModule, rootContainer, classLoader, oldLocale); + final RadRootContainer container = XmlReader.createRoot(this, rootContainer, classLoader, oldLocale); setRootContainer(container); if (keepSelection) { SelectionState.restoreSelection(this, selection); @@ -853,7 +864,7 @@ public final class GuiEditor extends JPanel implements DataProvider { private void showInvalidCard(final Throwable exc) { LOG.info(exc); // setting fictive container - setRootContainer(new RadRootContainer(myModule, "0")); + setRootContainer(new RadRootContainer(this, "0")); myFormInvalidLabel.setText(UIDesignerBundle.message("error.form.file.is.invalid.message", FormEditingUtil.getExceptionMessage(exc))); myInvalid = true; myCardLayout.show(this, CARD_INVALID); @@ -1064,7 +1075,7 @@ public final class GuiEditor extends JPanel implements DataProvider { private final class MyPsiTreeChangeListener extends PsiTreeChangeAdapter { private final Alarm myAlarm; private final MyRefreshPropertiesRequest myRefreshPropertiesRequest = new MyRefreshPropertiesRequest(); - private final MySynchronizeRequest mySynchronizeRequest = new MySynchronizeRequest(myModule, true); + private final MySynchronizeRequest mySynchronizeRequest = new MySynchronizeRequest(true); public MyPsiTreeChangeListener() { myAlarm = new Alarm(); @@ -1128,19 +1139,17 @@ public final class GuiEditor extends JPanel implements DataProvider { } private class MySynchronizeRequest implements Runnable { - private final Module myModule; private final boolean myKeepSelection; - public MySynchronizeRequest(final Module module, final boolean keepSelection) { - myModule = module; + public MySynchronizeRequest(final boolean keepSelection) { myKeepSelection = keepSelection; } public void run() { - if (myModule.isDisposed()) { + if (getModule().isDisposed()) { return; } - Project project = myModule.getProject(); + Project project = getProject(); if (project.isDisposed()) { return; } @@ -1152,7 +1161,7 @@ public final class GuiEditor extends JPanel implements DataProvider { private class MyRefreshPropertiesRequest implements Runnable { public void run() { - if (!myModule.isDisposed() && !getProject().isDisposed()) { + if (!getModule().isDisposed() && !getProject().isDisposed()) { refreshProperties(); } } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/InsertComponentProcessor.java b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/InsertComponentProcessor.java index f3ca9f16f782..1fc39ad60d47 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/InsertComponentProcessor.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/InsertComponentProcessor.java @@ -174,7 +174,7 @@ public final class InsertComponentProcessor extends EventProcessor { //noinspection ForLoopThatDoesntUseLoopVariable for(int i = 0; true; i++){ final String nameCandidate = baseName + (i + 1); - final String binding = JavaCodeStyleManager.getInstance(root.getModule().getProject()).propertyNameToVariableName( + final String binding = JavaCodeStyleManager.getInstance(root.getProject()).propertyNameToVariableName( nameCandidate, VariableKind.FIELD ); @@ -465,7 +465,7 @@ public final class InsertComponentProcessor extends EventProcessor { RadComponentFactory factory = getRadComponentFactory(item.getClassName(), loader); if (factory != null) { try { - result = factory.newInstance(editor.getModule(), item.getClassName(), id); + result = factory.newInstance(editor, item.getClassName(), id); } catch (Exception e) { LOG.error(e); @@ -477,13 +477,13 @@ public final class InsertComponentProcessor extends EventProcessor { if (boundForm != null) { final String formFileName = FormEditingUtil.buildResourceName(boundForm); try { - result = new RadNestedForm(editor.getModule(), formFileName, id); + result = new RadNestedForm(editor, formFileName, id); } catch(Exception ex) { String errorMessage = UIDesignerBundle.message("error.instantiating.nested.form", formFileName, (ex.getMessage() != null ? ex.getMessage() : ex.toString())); result = RadErrorComponent.create( - editor.getModule(), + editor, id, item.getClassName(), null, @@ -496,14 +496,14 @@ public final class InsertComponentProcessor extends EventProcessor { final Class aClass = Class.forName(item.getClassName(), true, loader); if (item.isContainer()) { LOG.debug("Creating custom container instance"); - result = new RadContainer(editor.getModule(), aClass, id); + result = new RadContainer(editor, aClass, id); } else { - result = new RadAtomicComponent(editor.getModule(), aClass, id); + result = new RadAtomicComponent(editor, aClass, id); } } catch(final UnsupportedClassVersionError ucve) { - result = RadErrorComponent.create(editor.getModule(), id, item.getClassName(), null, + result = RadErrorComponent.create(editor, id, item.getClassName(), null, UIDesignerBundle.message("unsupported.component.class.version") ); } @@ -518,7 +518,7 @@ public final class InsertComponentProcessor extends EventProcessor { } } result = RadErrorComponent.create( - editor.getModule(), + editor, id, item.getClassName(), null, diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/editor/UIFormEditor.java b/plugins/ui-designer/src/com/intellij/uiDesigner/editor/UIFormEditor.java index 48d6b9f10b67..796b880b6244 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/editor/UIFormEditor.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/editor/UIFormEditor.java @@ -52,10 +52,10 @@ public final class UIFormEditor extends UserDataHolderBase implements /*Navigata final VirtualFile vf = file instanceof LightVirtualFile ? ((LightVirtualFile)file).getOriginalFile() : file; final Module module = ModuleUtil.findModuleForFile(vf, project); if (module == null) { - throw new IllegalArgumentException("no module for file " + file + " in project " + project); + throw new IllegalArgumentException("No module for file " + file + " in project " + project); } myFile = file; - myEditor = new GuiEditor(module, file); + myEditor = new GuiEditor(project, module, file); } @NotNull diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/BindingEditor.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/BindingEditor.java index c2d23088a6f3..03c65b6640b1 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/BindingEditor.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/BindingEditor.java @@ -124,7 +124,7 @@ public final class BindingEditor extends ComboBoxPropertyEditor { final PsiType componentType; try { componentType = - JavaPsiFacade.getInstance(component.getModule().getProject()).getElementFactory().createTypeFromText(componentClassName, null); + JavaPsiFacade.getInstance(component.getProject()).getElementFactory().createTypeFromText(componentClassName, null); } catch (IncorrectOperationException e) { continue; diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/ColorEditor.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/ColorEditor.java index 9a57f37b4ea7..7e6b94dc4784 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/ColorEditor.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/ColorEditor.java @@ -75,7 +75,7 @@ public class ColorEditor extends PropertyEditor { public JComponent getComponent(RadComponent component, ColorDescriptor value, InplaceContext inplaceContext) { myValue = value != null ? value : new ColorDescriptor(new Color(0)); - myProject = component.getModule().getProject(); + myProject = component.getProject(); updateTextField(); return myTextField; } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/FontEditor.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/FontEditor.java index 2d072bd8118f..5b0644507e89 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/FontEditor.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/FontEditor.java @@ -63,7 +63,7 @@ public class FontEditor extends PropertyEditor { } public JComponent getComponent(RadComponent component, FontDescriptor value, InplaceContext inplaceContext) { - myProject = component.getModule().getProject(); + myProject = component.getProject(); myValue = value != null ? value : new FontDescriptor(null, -1, -1); myTextField.setText(IntroFontProperty.descriptorToString(myValue)); return myTextField; diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/IconEditor.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/IconEditor.java index c80a5ea788d1..c3049b72bb2f 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/IconEditor.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/IconEditor.java @@ -23,14 +23,14 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; -import com.intellij.uiDesigner.ImageFileFilter; -import com.intellij.uiDesigner.radComponents.RadComponent; -import com.intellij.uiDesigner.UIDesignerBundle; import com.intellij.uiDesigner.FormEditingUtil; +import com.intellij.uiDesigner.ImageFileFilter; +import com.intellij.uiDesigner.UIDesignerBundle; import com.intellij.uiDesigner.lw.IconDescriptor; -import com.intellij.uiDesigner.propertyInspector.PropertyEditor; import com.intellij.uiDesigner.propertyInspector.InplaceContext; +import com.intellij.uiDesigner.propertyInspector.PropertyEditor; import com.intellij.uiDesigner.propertyInspector.properties.IntroIconProperty; +import com.intellij.uiDesigner.radComponents.RadComponent; import javax.swing.*; import java.awt.event.ActionEvent; @@ -42,23 +42,24 @@ import java.awt.event.ActionListener; public class IconEditor extends PropertyEditor { private final TextFieldWithBrowseButton myTextField = new TextFieldWithBrowseButton(); private IconDescriptor myValue; - private Module myModule; + private RadComponent myComponent; public IconEditor() { myTextField.getTextField().setBorder(null); myTextField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - final TreeClassChooserFactory factory = TreeClassChooserFactory.getInstance(myModule.getProject()); + final TreeClassChooserFactory factory = TreeClassChooserFactory.getInstance(getModule().getProject()); PsiFile iconFile = null; if (myValue != null) { - VirtualFile iconVFile = ResourceFileUtil.findResourceFileInScope(myValue.getIconPath(), myModule.getProject(), - myModule.getModuleWithDependenciesAndLibrariesScope(true)); + VirtualFile iconVFile = ResourceFileUtil.findResourceFileInScope(myValue.getIconPath(), getModule().getProject(), + getModule() + .getModuleWithDependenciesAndLibrariesScope(true)); if (iconVFile != null) { - iconFile = PsiManager.getInstance(myModule.getProject()).findFile(iconVFile); + iconFile = PsiManager.getInstance(getModule().getProject()).findFile(iconVFile); } } TreeFileChooser fileChooser = factory.createFileChooser(UIDesignerBundle.message("title.choose.icon.file"), iconFile, - null, new ImageFileFilter(myModule), false, true); + null, new ImageFileFilter(getModule()), false, true); fileChooser.showDialog(); PsiFile file = fileChooser.getSelectedFile(); if (file != null) { @@ -74,18 +75,22 @@ public class IconEditor extends PropertyEditor { }); } + private Module getModule() { + return myComponent.getModule(); + } + public IconDescriptor getValue() throws Exception { if (myTextField.getText().length() == 0) { return null; } final IconDescriptor descriptor = new IconDescriptor(myTextField.getText()); - IntroIconProperty.ensureIconLoaded(myModule, descriptor); + IntroIconProperty.ensureIconLoaded(getModule(), descriptor); return descriptor; } public JComponent getComponent(RadComponent component, IconDescriptor value, InplaceContext inplaceContext) { myValue = value; - myModule = component.getModule(); + myComponent = component; if (myValue != null) { myTextField.setText(myValue.getIconPath()); } @@ -98,5 +103,4 @@ public class IconEditor extends PropertyEditor { public void updateUI() { SwingUtilities.updateComponentTreeUI(myTextField); } - } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/BindingProperty.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/BindingProperty.java index 76225e42463a..6ea8ac1087e3 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/BindingProperty.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/BindingProperty.java @@ -317,7 +317,7 @@ public final class BindingProperty extends Property { nameBuilder.append(shortClassName); RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component); - Project project = root.getModule().getProject(); + Project project = root.getProject(); String binding = JavaCodeStyleManager.getInstance(project).propertyNameToVariableName(nameBuilder.toString(), VariableKind.FIELD); if (FormEditingUtil.findComponentWithBinding(root, binding, component) != null) { binding = InsertComponentProcessor.getUniqueBinding(root, nameBuilder.toString()); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/ClassToBindProperty.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/ClassToBindProperty.java index d670980fb472..0a389e15dcdb 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/ClassToBindProperty.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/ClassToBindProperty.java @@ -23,7 +23,6 @@ import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonShortcuts; import com.intellij.openapi.editor.Document; import com.intellij.openapi.fileTypes.StdFileTypes; -import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.roots.ProjectRootManager; @@ -125,7 +124,7 @@ public final class ClassToBindProperty extends Propertyid * should be a unique atring inside the form. */ - public RadComponent(final Module module, @NotNull final Class aClass, @NotNull final String id) { + public RadComponent(final ModuleProvider module, @NotNull final Class aClass, @NotNull final String id) { myModule = module; myClass = aClass; myId = id; @@ -172,7 +170,7 @@ public abstract class RadComponent implements IComponent { myDelegee.putClientProperty(CLIENT_PROP_RAD_COMPONENT, this); } - public RadComponent(final Module module, @NotNull final Class aClass, @NotNull final String id, final Palette palette) { + public RadComponent(final ModuleProvider module, @NotNull final Class aClass, @NotNull final String id, final Palette palette) { this(module, aClass, id); myPalette = palette; } @@ -181,18 +179,17 @@ public abstract class RadComponent implements IComponent { * @return module for the component. */ public final Module getModule() { - return myModule; + return myModule == null ? null : myModule.getModule(); + } + + public final Project getProject() { + return myModule == null ? null : myModule.getProject(); } public boolean isLoadingProperties() { return myLoadingProperties; } - @NotNull - public final Project getProject() { - return myModule.getProject(); - } - public Palette getPalette() { if (myPalette == null) { return Palette.getInstance(getProject()); @@ -630,7 +627,9 @@ public abstract class RadComponent implements IComponent { } private void writeClientProperties(final XmlWriter writer) { - if (myModule == null) return; + if (myModule == null) { + return; + } boolean haveClientProperties = false; try { ClientPropertiesProperty cpp = ClientPropertiesProperty.getInstance(getProject()); @@ -800,7 +799,7 @@ public abstract class RadComponent implements IComponent { @Nullable public String getComponentTitle() { - Palette palette = Palette.getInstance(getModule().getProject()); + Palette palette = Palette.getInstance(getProject()); IntrospectedProperty[] props = palette.getIntrospectedProperties(this); for (IntrospectedProperty prop : props) { if (prop.getName().equals(SwingProperties.TEXT) && prop instanceof IntroStringProperty) { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadComponentFactory.java b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadComponentFactory.java index 7a07d0e62a16..c6960b4e9b3c 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadComponentFactory.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadComponentFactory.java @@ -24,15 +24,17 @@ package com.intellij.uiDesigner.radComponents; import com.intellij.openapi.module.Module; import com.intellij.uiDesigner.LoaderFactory; +import com.intellij.uiDesigner.ModuleProvider; import com.intellij.uiDesigner.palette.Palette; public abstract class RadComponentFactory { - public RadComponent newInstance(Module module, String className, String id) throws ClassNotFoundException { + public RadComponent newInstance(ModuleProvider moduleProvider, String className, String id) throws ClassNotFoundException { + Module module = moduleProvider.getModule(); final Class aClass = Class.forName(className, true, LoaderFactory.getInstance(module.getProject()).getLoader(module)); - return newInstance(module, aClass, id); + return newInstance(moduleProvider, aClass, id); } - protected abstract RadComponent newInstance(Module module, Class aClass, String id); + protected abstract RadComponent newInstance(ModuleProvider moduleProvider, Class aClass, String id); public abstract RadComponent newInstance(final Class componentClass, final String id, final Palette palette); } \ No newline at end of file diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadContainer.java b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadContainer.java index a99eea514c22..663dfc3a724b 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadContainer.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadContainer.java @@ -16,7 +16,6 @@ package com.intellij.uiDesigner.radComponents; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.module.Module; import com.intellij.openapi.util.Comparing; import com.intellij.uiDesigner.*; import com.intellij.uiDesigner.core.AbstractLayout; @@ -47,7 +46,7 @@ public class RadContainer extends RadComponent implements IContainer { private static final Logger LOG = Logger.getInstance("#com.intellij.uiDesigner.radComponents.RadContainer"); public static class Factory extends RadComponentFactory { - public RadComponent newInstance(Module module, Class aClass, String id) { + public RadComponent newInstance(ModuleProvider module, Class aClass, String id) { return new RadContainer(module, aClass, id); } @@ -84,11 +83,11 @@ public class RadContainer extends RadComponent implements IContainer { protected RadLayoutManager myLayoutManager; private LayoutManager myDelegeeLayout; - public RadContainer(final Module module, final String id) { + public RadContainer(final ModuleProvider module, final String id) { this(module, JPanel.class, id); } - public RadContainer(final Module module, final Class aClass, final String id) { + public RadContainer(final ModuleProvider module, final Class aClass, final String id) { super(module, aClass, id); myComponents = new ArrayList(); @@ -114,7 +113,7 @@ public class RadContainer extends RadComponent implements IContainer { protected RadLayoutManager createInitialLayoutManager() { String defaultLayoutManager = UIFormXmlConstants.LAYOUT_INTELLIJ; if (getModule() != null) { - final GuiDesignerConfiguration configuration = GuiDesignerConfiguration.getInstance(getModule().getProject()); + final GuiDesignerConfiguration configuration = GuiDesignerConfiguration.getInstance(getProject()); defaultLayoutManager = configuration.DEFAULT_LAYOUT_MANAGER; } @@ -701,7 +700,7 @@ public class RadContainer extends RadComponent implements IContainer { public MyBorderTitleProperty() { super(null, "Title"); - myEditor = new StringEditor(getModule().getProject()); + myEditor = new StringEditor(getProject()); } public Dimension getPreferredSize() { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadErrorComponent.java b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadErrorComponent.java index 6d86909e588a..fe98768b1e1b 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadErrorComponent.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadErrorComponent.java @@ -16,16 +16,14 @@ package com.intellij.uiDesigner.radComponents; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.module.Module; +import com.intellij.uiDesigner.ModuleProvider; import com.intellij.uiDesigner.XmlWriter; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; +import java.awt.*; /** * @author Anton Katilin @@ -39,17 +37,17 @@ public final class RadErrorComponent extends RadAtomicComponent { private final String myErrorDescription; public static RadErrorComponent create( - final Module module, + final ModuleProvider module, final String id, final String componentClassName, final Element properties, @NotNull final String errorDescription - ){ + ) { return new RadErrorComponent(module, id, componentClassName, properties, errorDescription); } private RadErrorComponent( - final Module module, + final ModuleProvider module, final String id, @NotNull final String componentClassName, @Nullable final Element properties, @@ -63,7 +61,7 @@ public final class RadErrorComponent extends RadAtomicComponent { } @NotNull - public String getComponentClassName(){ + public String getComponentClassName() { return myComponentClassName; } @@ -73,7 +71,7 @@ public final class RadErrorComponent extends RadAtomicComponent { public void write(final XmlWriter writer) { writer.startElement("component"); - try{ + try { writeId(writer); // write class @@ -83,26 +81,28 @@ public final class RadErrorComponent extends RadAtomicComponent { writeConstraints(writer); // write properties (if any) - if(myProperties != null){ + if (myProperties != null) { writer.writeElement(myProperties); } - }finally{ + } + finally { writer.endElement(); // component } } - private static final class MyComponent extends JComponent{ - public MyComponent(){ + private static final class MyComponent extends JComponent { + public MyComponent() { setMinimumSize(new Dimension(20, 20)); } - public void paint(final Graphics g){ + public void paint(final Graphics g) { g.setColor(Color.red); - g.fillRect(0,0,getWidth(),getHeight()); + g.fillRect(0, 0, getWidth(), getHeight()); } } - @Override public boolean hasIntrospectedProperties() { + @Override + public boolean hasIntrospectedProperties() { return false; } } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadHSpacer.java b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadHSpacer.java index f149978d7edb..b5df95978735 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadHSpacer.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadHSpacer.java @@ -15,11 +15,11 @@ */ package com.intellij.uiDesigner.radComponents; -import com.intellij.openapi.module.Module; import com.intellij.uiDesigner.HSpacer; +import com.intellij.uiDesigner.ModuleProvider; import com.intellij.uiDesigner.XmlWriter; -import com.intellij.uiDesigner.palette.Palette; import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.palette.Palette; /** * @author Anton Katilin @@ -27,25 +27,25 @@ import com.intellij.uiDesigner.core.GridConstraints; */ public final class RadHSpacer extends RadAtomicComponent { public static class Factory extends RadComponentFactory { - public RadComponent newInstance(Module module, Class aClass, String id) { - return new RadHSpacer(module, aClass, id); + public RadComponent newInstance(ModuleProvider moduleProvider, Class aClass, String id) { + return new RadHSpacer(moduleProvider, aClass, id); } public RadComponent newInstance(final Class componentClass, final String id, final Palette palette) { throw new UnsupportedOperationException("Spacer instances should not be created by SnapShooter"); } - public RadComponent newInstance(Module module, String className, String id) throws ClassNotFoundException { - return new RadHSpacer(module, HSpacer.class, id); + public RadComponent newInstance(ModuleProvider moduleProvider, String className, String id) throws ClassNotFoundException { + return new RadHSpacer(moduleProvider, HSpacer.class, id); } } - public RadHSpacer(final Module module, final String id) { - super(module, HSpacer.class, id); + public RadHSpacer(final ModuleProvider moduleProvider, final String id) { + super(moduleProvider, HSpacer.class, id); } - public RadHSpacer(final Module module, final Class aClass, final String id) { - super(module, aClass, id); + public RadHSpacer(final ModuleProvider moduleProvider, final Class aClass, final String id) { + super(moduleProvider, aClass, id); } /** @@ -61,15 +61,17 @@ public final class RadHSpacer extends RadAtomicComponent { public void write(final XmlWriter writer) { writer.startElement("hspacer"); - try{ + try { writeId(writer); writeConstraints(writer); - }finally{ + } + finally { writer.endElement(); // hspacer } } - @Override public boolean hasIntrospectedProperties() { + @Override + public boolean hasIntrospectedProperties() { return false; } } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadNestedForm.java b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadNestedForm.java index 00913d2dc02c..4d9597c379b8 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadNestedForm.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadNestedForm.java @@ -19,7 +19,6 @@ package com.intellij.uiDesigner.radComponents; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ResourceFileUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiClass; @@ -42,16 +41,16 @@ public class RadNestedForm extends RadComponent { private final String myFormFileName; private final RadRootContainer myRootContainer; - public RadNestedForm(final Module module, final String formFileName, final String id) throws Exception { + public RadNestedForm(final ModuleProvider module, final String formFileName, final String id) throws Exception { super(module, JPanel.class, id); myFormFileName = formFileName; LOG.debug("Loading nested form " + formFileName); - VirtualFile formFile = ResourceFileUtil.findResourceFileInDependents(module, formFileName); + VirtualFile formFile = ResourceFileUtil.findResourceFileInDependents(getModule(), formFileName); if (formFile == null) { throw new IllegalArgumentException("Couldn't find virtual file for nested form " + formFileName); } Document doc = FileDocumentManager.getInstance().getDocument(formFile); - final ClassLoader classLoader = LoaderFactory.getInstance(module.getProject()).getLoader(formFile); + final ClassLoader classLoader = LoaderFactory.getInstance(getProject()).getLoader(formFile); final LwRootContainer rootContainer = Utils.getRootContainer(doc.getText(), new CompiledClassPropertiesProvider(classLoader)); myRootContainer = XmlReader.createRoot(module, rootContainer, classLoader, null); if (myRootContainer.getComponentCount() > 0) { @@ -69,32 +68,35 @@ public class RadNestedForm extends RadComponent { private void setRadComponentRecursive(final JComponent component) { component.putClientProperty(CLIENT_PROP_RAD_COMPONENT, this); - for(int i=0; i myButtonGroups = new ArrayList(); private final List myInspectionSuppressions = new ArrayList(); - public RadRootContainer(final Module module, final String id) { + public RadRootContainer(final ModuleProvider module, final String id) { super(module, JPanel.class, id); getDelegee().setBackground(Color.WHITE); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadScrollPane.java b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadScrollPane.java index fc92e40880e1..3a7ab9abe1c2 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadScrollPane.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadScrollPane.java @@ -16,7 +16,7 @@ package com.intellij.uiDesigner.radComponents; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.module.Module; +import com.intellij.uiDesigner.ModuleProvider; import com.intellij.uiDesigner.UIFormXmlConstants; import com.intellij.uiDesigner.XmlWriter; import com.intellij.uiDesigner.core.GridConstraints; @@ -41,7 +41,7 @@ public final class RadScrollPane extends RadContainer { private static final Logger LOG = Logger.getInstance("#com.intellij.uiDesigner.radComponents.RadScrollPane"); public static class Factory extends RadComponentFactory { - public RadComponent newInstance(Module module, Class aClass, String id) { + public RadComponent newInstance(ModuleProvider module, Class aClass, String id) { return new RadScrollPane(module, aClass, id); } @@ -50,7 +50,7 @@ public final class RadScrollPane extends RadContainer { } } - public RadScrollPane(final Module module, final Class componentClass, final String id){ + public RadScrollPane(final ModuleProvider module, final Class componentClass, final String id){ super(module, componentClass, id); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadSplitPane.java b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadSplitPane.java index 674cd3f2f99e..50faa6509b02 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadSplitPane.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadSplitPane.java @@ -15,7 +15,7 @@ */ package com.intellij.uiDesigner.radComponents; -import com.intellij.openapi.module.Module; +import com.intellij.uiDesigner.ModuleProvider; import com.intellij.uiDesigner.UIDesignerBundle; import com.intellij.uiDesigner.UIFormXmlConstants; import com.intellij.uiDesigner.XmlWriter; @@ -38,7 +38,7 @@ import java.awt.event.MouseEvent; */ public final class RadSplitPane extends RadContainer { public static class Factory extends RadComponentFactory { - public RadComponent newInstance(Module module, Class aClass, String id) { + public RadComponent newInstance(ModuleProvider module, Class aClass, String id) { return new RadSplitPane(module, aClass, id); } @@ -47,7 +47,7 @@ public final class RadSplitPane extends RadContainer { } } - public RadSplitPane(final Module module, final Class componentClass, final String id) { + public RadSplitPane(final ModuleProvider module, final Class componentClass, final String id) { super(module, componentClass, id); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadTabbedPane.java b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadTabbedPane.java index 4670d2199a38..a285a975a074 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadTabbedPane.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadTabbedPane.java @@ -16,7 +16,6 @@ package com.intellij.uiDesigner.radComponents; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.text.StringUtil; @@ -53,7 +52,7 @@ import java.awt.event.MouseEvent; public final class RadTabbedPane extends RadContainer implements ITabbedPane { public static class Factory extends RadComponentFactory { - public RadComponent newInstance(Module module, Class aClass, String id) { + public RadComponent newInstance(ModuleProvider module, Class aClass, String id) { return new RadTabbedPane(module, aClass, id); } @@ -72,7 +71,7 @@ public final class RadTabbedPane extends RadContainer implements ITabbedPane { private int mySelectedIndex = -1; private IntrospectedProperty mySelectedIndexProperty = null; - public RadTabbedPane(final Module module, Class componentClass, final String id){ + public RadTabbedPane(final ModuleProvider module, Class componentClass, final String id){ super(module, componentClass, id); } @@ -342,7 +341,7 @@ public final class RadTabbedPane extends RadContainer implements ITabbedPane { private class MyTitleProperty extends Property { protected final int myIndex; - private final StringEditor myEditor = new StringEditor(getModule().getProject()); + private final StringEditor myEditor = new StringEditor(getProject()); private final StringRenderer myRenderer = new StringRenderer(); public MyTitleProperty(final Property parent, final int index) { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadTable.java b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadTable.java index f02ca881de36..8f4aee88fa83 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadTable.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadTable.java @@ -16,7 +16,7 @@ package com.intellij.uiDesigner.radComponents; -import com.intellij.openapi.module.Module; +import com.intellij.uiDesigner.ModuleProvider; import com.intellij.uiDesigner.palette.Palette; import org.jetbrains.annotations.NonNls; @@ -28,7 +28,7 @@ import javax.swing.table.DefaultTableModel; */ public class RadTable extends RadAtomicComponent { public static class Factory extends RadComponentFactory { - public RadComponent newInstance(Module module, Class aClass, String id) { + public RadComponent newInstance(ModuleProvider module, Class aClass, String id) { return new RadTable(module, aClass, id); } @@ -37,7 +37,7 @@ public class RadTable extends RadAtomicComponent { } } - public RadTable(final Module module, final Class componentClass, final String id) { + public RadTable(final ModuleProvider module, final Class componentClass, final String id) { super(module, componentClass, id); initDefaultModel(); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadToolBar.java b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadToolBar.java index 5e01cdeaf950..b5635082cb14 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadToolBar.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadToolBar.java @@ -16,13 +16,13 @@ package com.intellij.uiDesigner.radComponents; -import com.intellij.openapi.module.Module; +import com.intellij.uiDesigner.ModuleProvider; import com.intellij.uiDesigner.UIFormXmlConstants; import com.intellij.uiDesigner.XmlWriter; +import com.intellij.uiDesigner.designSurface.ComponentDropLocation; import com.intellij.uiDesigner.palette.Palette; -import com.intellij.uiDesigner.designSurface.*; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; @@ -32,7 +32,7 @@ import java.awt.*; */ public class RadToolBar extends RadContainer { public static class Factory extends RadComponentFactory { - public RadComponent newInstance(Module module, Class aClass, String id) { + public RadComponent newInstance(ModuleProvider module, Class aClass, String id) { return new RadToolBar(module, aClass, id); } @@ -41,7 +41,7 @@ public class RadToolBar extends RadContainer { } } - public RadToolBar(final Module module, final Class componentClass, final String id) { + public RadToolBar(final ModuleProvider module, final Class componentClass, final String id) { super(module, componentClass, id); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadVSpacer.java b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadVSpacer.java index 1e0c24d31854..7b0924a068c2 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadVSpacer.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/radComponents/RadVSpacer.java @@ -15,11 +15,11 @@ */ package com.intellij.uiDesigner.radComponents; -import com.intellij.openapi.module.Module; +import com.intellij.uiDesigner.ModuleProvider; import com.intellij.uiDesigner.VSpacer; import com.intellij.uiDesigner.XmlWriter; -import com.intellij.uiDesigner.palette.Palette; import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.palette.Palette; /** @@ -28,7 +28,7 @@ import com.intellij.uiDesigner.core.GridConstraints; */ public final class RadVSpacer extends RadAtomicComponent { public static class Factory extends RadComponentFactory { - public RadComponent newInstance(Module module, Class aClass, String id) { + public RadComponent newInstance(ModuleProvider module, Class aClass, String id) { return new RadVSpacer(module, aClass, id); } @@ -36,16 +36,16 @@ public final class RadVSpacer extends RadAtomicComponent { throw new UnsupportedOperationException("Spacer instances should not be created by SnapShooter"); } - public RadComponent newInstance(Module module, String className, String id) throws ClassNotFoundException { + public RadComponent newInstance(ModuleProvider module, String className, String id) throws ClassNotFoundException { return new RadVSpacer(module, VSpacer.class, id); } } - public RadVSpacer(final Module module, final String id) { + public RadVSpacer(final ModuleProvider module, final String id) { super(module, VSpacer.class, id); } - public RadVSpacer(final Module module, final Class aClass, final String id) { + public RadVSpacer(final ModuleProvider module, final Class aClass, final String id) { super(module, aClass, id); } @@ -62,15 +62,17 @@ public final class RadVSpacer extends RadAtomicComponent { public void write(final XmlWriter writer) { writer.startElement("vspacer"); - try{ + try { writeId(writer); writeConstraints(writer); - }finally{ + } + finally { writer.endElement(); // vspacer } } - @Override public boolean hasIntrospectedProperties() { + @Override + public boolean hasIntrospectedProperties() { return false; } } diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/DesignerEditor.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/DesignerEditor.java index 846384161682..b56e44db161a 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/DesignerEditor.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/DesignerEditor.java @@ -46,11 +46,11 @@ public abstract class DesignerEditor extends UserDataHolderBase implements FileE if (module == null) { throw new IllegalArgumentException("No module for file " + file + " in project " + project); } - myDesignerPanel = createDesignerPanel(module, file); + myDesignerPanel = createDesignerPanel(project, module, file); } @NotNull - protected abstract DesignerEditorPanel createDesignerPanel(Module module, VirtualFile file); + protected abstract DesignerEditorPanel createDesignerPanel(Project project, Module module, VirtualFile file); public final DesignerEditorPanel getDesignerPanel() { return myDesignerPanel; diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/ModuleProvider.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/ModuleProvider.java new file mode 100644 index 000000000000..91cb46058869 --- /dev/null +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/ModuleProvider.java @@ -0,0 +1,28 @@ +/* + * 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.designer; + +import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.Project; + +/** + * @author Alexander Lobas + */ +public interface ModuleProvider { + Module getModule(); + + Project getProject(); +} \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java index 0b498666fc4c..8921c51e02ec 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java @@ -17,6 +17,7 @@ package com.intellij.designer.designSurface; import com.intellij.designer.DesignerEditorState; import com.intellij.designer.DesignerToolWindowManager; +import com.intellij.designer.ModuleProvider; import com.intellij.designer.actions.DesignerActionPanel; import com.intellij.designer.componentTree.TreeComponentDecorator; import com.intellij.designer.designSurface.tools.*; @@ -34,6 +35,7 @@ import com.intellij.openapi.actionSystem.DataProvider; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; @@ -69,7 +71,7 @@ import java.util.List; /** * @author Alexander Lobas */ -public abstract class DesignerEditorPanel extends JPanel implements DataProvider { +public abstract class DesignerEditorPanel extends JPanel implements DataProvider, ModuleProvider { private static final Logger LOG = Logger.getInstance("#com.intellij.designer.designSurface.DesignerEditorPanel"); protected static final Integer LAYER_COMPONENT = JLayeredPane.DEFAULT_LAYER; @@ -84,7 +86,8 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider private final static String ERROR_STACK_CARD = "stack"; private final static String ERROR_NO_STACK_CARD = "no_stack"; - protected final Module myModule; + private final Project myProject; + private Module myModule; protected final VirtualFile myFile; private final CardLayout myLayout = new CardLayout(); @@ -127,7 +130,8 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider private AsyncProcessIcon myProgressIcon; private JLabel myProgressMessage; - public DesignerEditorPanel(@NotNull Module module, @NotNull VirtualFile file) { + public DesignerEditorPanel(@NotNull Project project, @NotNull Module module, @NotNull VirtualFile file) { + myProject = project; myModule = module; myFile = file; @@ -512,12 +516,20 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider ////////////////////////////////////////////////////////////////////////////////////////// @NotNull - public Module getModule() { + @Override + public final Module getModule() { + if (myModule.isDisposed()) { + myModule = ModuleUtil.findModuleForFile(myFile, myProject); + if (myModule == null) { + throw new IllegalArgumentException("No module for file " + myFile + " in project " + myProject); + } + } return myModule; } - public Project getProject() { - return myModule.getProject(); + @Override + public final Project getProject() { + return myProject; } public EditableArea getSurfaceArea() { From e0e6d48aee59c7cca8e35e018ac59f25d6bc5c61 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Sat, 9 Jun 2012 15:25:06 +0400 Subject: [PATCH 040/172] Click counter --- .../src/com/intellij/ui/ClickListener.java | 15 ++++++++++++--- .../impl/welcomeScreen/DefaultWelcomeScreen.java | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/ClickListener.java b/platform/platform-api/src/com/intellij/ui/ClickListener.java index 00c8b16bb304..f72bfbb13c03 100644 --- a/platform/platform-api/src/com/intellij/ui/ClickListener.java +++ b/platform/platform-api/src/com/intellij/ui/ClickListener.java @@ -27,15 +27,24 @@ import java.awt.event.MouseEvent; public abstract class ClickListener { private static final int EPS = 4; + private static final long TIME_EPS = 500; // TODO: read system mouse sensitivity settings? - public abstract void onClick(MouseEvent event); + public abstract void onClick(MouseEvent event, int clickCount); public void installOn(final JComponent c) { MouseAdapter adapter = new MouseAdapter() { - Point clickPoint; + private Point clickPoint; + private long lastTimeClicked = -1; + private int clickCount = 0; @Override public void mousePressed(MouseEvent e) { + if (Math.abs(lastTimeClicked - e.getWhen()) > TIME_EPS) { + clickCount = 0; + } + clickCount++; + lastTimeClicked = e.getWhen(); + if (!e.isPopupTrigger()) { clickPoint = e.getPoint(); } @@ -52,7 +61,7 @@ public abstract class ClickListener { if (releasedAt.x < 0 || releasedAt.y < 0 || releasedAt.x >= c.getWidth() || releasedAt.y >= c.getWidth()) return; if (Math.abs(clickedAt.x - releasedAt.x) < EPS && Math.abs(clickedAt.y - releasedAt.y) < EPS) { - onClick(e); + onClick(e, clickCount); } } }; diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/DefaultWelcomeScreen.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/DefaultWelcomeScreen.java index a52109f5bd97..34f742e5fa33 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/DefaultWelcomeScreen.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/DefaultWelcomeScreen.java @@ -278,7 +278,7 @@ public class DefaultWelcomeScreen implements WelcomeScreen { new ClickListener() { @Override - public void onClick(MouseEvent e) { + public void onClick(MouseEvent e, int clickCount) { if (e.getButton() == MouseEvent.BUTTON1) { DataContext dataContext = DataManager.getInstance().getDataContext(myWelcomePanel); int fragment = actionLabel.findFragmentAt(e.getX()); @@ -700,7 +700,7 @@ public class DefaultWelcomeScreen implements WelcomeScreen { JLabel name = new JLabel(underlineHtmlText(commandLink)); new ClickListener() { @Override - public void onClick(MouseEvent event) { + public void onClick(MouseEvent event, int clickCount) { button.onPress(event); } }.installOn(name); From 2daf083b180f0519f5e83e0dc17f4923e283c52c Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Sat, 9 Jun 2012 15:33:44 +0400 Subject: [PATCH 041/172] Two incorrectly deleted icons restored --- platform/icons/src/general/errorMask.png | Bin 0 -> 288 bytes platform/icons/src/gutter/unique.png | Bin 0 -> 212 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 platform/icons/src/general/errorMask.png create mode 100644 platform/icons/src/gutter/unique.png diff --git a/platform/icons/src/general/errorMask.png b/platform/icons/src/general/errorMask.png new file mode 100644 index 0000000000000000000000000000000000000000..fcd310abf4179b90f73cc49170e29ddc8233b696 GIT binary patch literal 288 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$0wn*`OvwRKEa{HEjtmUzPnffIy#(?lOI#yL zg7ec#$`gxH85~pclTsBta}(23gHjVyDhp4h+5i=8@^o!EA&@A<}=PZsZzxNi>s^`<{ zy=~H0sDJB|tJB*D*DpqzpLI5Qy{me9L6GID*st4--~|DqhKlobcZ%BJi>r=z0cES3j3^P6t<7Z{`|f?iOq1on+<~ zYw8jW;Nsx$h6j1T9X@84=riqpW`2{l= zZ(3=w$@J*w!wX-&Sa9^q5zAHPo49HU<^UDwc)B=-a6~63I54P*rJ02ZG*6t{JX!F_ ugGXXdAF_6T_{iPhI)kOP#Z|(9kwL+U;jP5af2V=^7(8A5T-G@yGywp=Xhnkn literal 0 HcmV?d00001 From e0015d4888aa15448d8bf398d07fb1b2e8130860 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Sat, 9 Jun 2012 15:39:42 +0400 Subject: [PATCH 042/172] change signature: do not show conflicts about non-changed param names --- .../JavaChangeSignatureUsageSearcher.java | 3 ++- .../changeSignature/ParamNameNoConflict.java | 11 +++++++++++ .../changeSignature/ParamNameNoConflict_after.java | 11 +++++++++++ .../com/intellij/refactoring/ChangeSignatureTest.java | 7 +++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/refactoring/changeSignature/ParamNameNoConflict.java create mode 100644 java/java-tests/testData/refactoring/changeSignature/ParamNameNoConflict_after.java diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageSearcher.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageSearcher.java index 46ca81d384f7..80fd509f233e 100644 --- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageSearcher.java +++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageSearcher.java @@ -116,7 +116,8 @@ class JavaChangeSignatureUsageSearcher { final int oldParameterIndex = parameterInfo.getOldIndex(); final String newName = parameterInfo.getName(); if (oldParameterIndex >= 0 ) { - if (isOriginal&& oldParameterIndex < parameters.length) { //Name changes take place only in primary method + if (isOriginal && oldParameterIndex < parameters.length && !newName.equals(myChangeInfo.getOldParameterNames()[oldParameterIndex])) { + //Name changes take place only in primary method when name was actually changed final PsiParameter parameter = parameters[oldParameterIndex]; if (!newName.equals(parameter.getName())) { JavaUnresolvableLocalCollisionDetector.visitLocalsCollisions( diff --git a/java/java-tests/testData/refactoring/changeSignature/ParamNameNoConflict.java b/java/java-tests/testData/refactoring/changeSignature/ParamNameNoConflict.java new file mode 100644 index 000000000000..a98e37640762 --- /dev/null +++ b/java/java-tests/testData/refactoring/changeSignature/ParamNameNoConflict.java @@ -0,0 +1,11 @@ +class D { + void foo(Object o){} +} + +class DImpl extends D { + void foo(Object o1) { + super.foo(o1); + int o = 0; + System.out.println(o); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/changeSignature/ParamNameNoConflict_after.java b/java/java-tests/testData/refactoring/changeSignature/ParamNameNoConflict_after.java new file mode 100644 index 000000000000..6b29466ed297 --- /dev/null +++ b/java/java-tests/testData/refactoring/changeSignature/ParamNameNoConflict_after.java @@ -0,0 +1,11 @@ +class D { + void foo(Object o, boolean b){} +} + +class DImpl extends D { + void foo(Object o1, boolean b) { + super.foo(o1, b); + int o = 0; + System.out.println(o); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java index 77d7fcdea41e..41acb241a84c 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java @@ -134,6 +134,13 @@ public class ChangeSignatureTest extends LightRefactoringTestCase { }, false); } + public void testParamNameNoConflict() throws Exception { + doTest(null, new ParameterInfoImpl[]{ + new ParameterInfoImpl(0), + new ParameterInfoImpl(-1, "b", PsiType.BOOLEAN) + }, false); + } + public void testParamJavadoc() throws Exception { doTest(null, new ParameterInfoImpl[] { new ParameterInfoImpl(1, "z", PsiType.INT), From 173cb1f7ca663ae682ae7325eb45cd46705036ee Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Sat, 9 Jun 2012 16:10:12 +0400 Subject: [PATCH 043/172] inline this() as method inside the constructor for non chained constructors (IDEA-87111) --- .../inline/InlineMethodHandler.java | 25 ++++++++++++++++--- .../inline/InlineMethodProcessor.java | 2 +- .../inline/InlineToAnonymousClassHandler.java | 9 +++++-- .../inlineMethod/ChainedConstructor.java | 21 ++++++++++++++++ .../ChainedConstructor.java.after | 21 ++++++++++++++++ .../inlineMethod/ChainedConstructor1.java | 21 ++++++++++++++++ .../ChainedConstructor1.java.after | 17 +++++++++++++ .../refactoring/inline/InlineMethodTest.java | 12 +++++++++ .../lang/refactoring/InlineActionHandler.java | 2 +- .../InlineRefactoringActionHandler.java | 2 +- 10 files changed, 123 insertions(+), 9 deletions(-) create mode 100644 java/java-tests/testData/refactoring/inlineMethod/ChainedConstructor.java create mode 100644 java/java-tests/testData/refactoring/inlineMethod/ChainedConstructor.java.after create mode 100644 java/java-tests/testData/refactoring/inlineMethod/ChainedConstructor1.java create mode 100644 java/java-tests/testData/refactoring/inlineMethod/ChainedConstructor1.java.after diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodHandler.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodHandler.java index e56b93ec3f5b..7aef0d8214f1 100644 --- a/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodHandler.java @@ -22,6 +22,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.ReadonlyStatusHandler; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; +import com.intellij.psi.util.PsiTreeUtil; import com.intellij.refactoring.HelpID; import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.util.CommonRefactoringUtil; @@ -87,10 +88,14 @@ class InlineMethodHandler extends JavaInlineActionHandler { CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.INLINE_CONSTRUCTOR); return; } - if (!isChainingConstructor(method)) { - String message = RefactoringBundle.message("refactoring.cannot.be.applied.to.inline.non.chaining.constructors", REFACTORING_NAME); - CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.INLINE_CONSTRUCTOR); - return; + final boolean chainingConstructor = isChainingConstructor(method); + if (!chainingConstructor) { + if (!isThisReference(reference)) { + String message = RefactoringBundle.message("refactoring.cannot.be.applied.to.inline.non.chaining.constructors", REFACTORING_NAME); + CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.INLINE_CONSTRUCTOR); + return; + } + allowInlineThisOnly = true; } if (reference != null) { final PsiElement refElement = reference.getElement(); @@ -148,4 +153,16 @@ class InlineMethodHandler extends JavaInlineActionHandler { return false; } + + public static boolean isThisReference(PsiReference reference) { + if (reference != null) { + final PsiElement referenceElement = reference.getElement(); + if (referenceElement instanceof PsiJavaCodeReferenceElement && + referenceElement.getParent() instanceof PsiMethodCallExpression && + "this".equals(((PsiJavaCodeReferenceElement)referenceElement).getReferenceName())) { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java index ce76e8bc97a0..b069e2fc65c4 100644 --- a/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java @@ -324,7 +324,7 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor { private void doRefactoring(UsageInfo[] usages) { try { if (myInlineThisOnly) { - if (myMethod.isConstructor()) { + if (myMethod.isConstructor() && InlineMethodHandler.isChainingConstructor(myMethod)) { PsiCall constructorCall = RefactoringUtil.getEnclosingConstructorCall(myReference); if (constructorCall != null) { inlineConstructorCall(constructorCall); diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousClassHandler.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousClassHandler.java index 3f5442e637e7..00501d5d6b49 100644 --- a/java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousClassHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousClassHandler.java @@ -83,8 +83,13 @@ public class InlineToAnonymousClassHandler extends JavaInlineActionHandler { return inheritors.size() == 0; } - public boolean canInlineElementInEditor(PsiElement element) { - return canInlineElement(element); + @Override + public boolean canInlineElementInEditor(PsiElement element, Editor editor) { + if (canInlineElement(element)) { + PsiReference reference = editor != null ? TargetElementUtilBase.findReference(editor, editor.getCaretModel().getOffset()) : null; + return !InlineMethodHandler.isThisReference(reference); + } + return false; } public void inlineElement(final Project project, final Editor editor, final PsiElement psiElement) { diff --git a/java/java-tests/testData/refactoring/inlineMethod/ChainedConstructor.java b/java/java-tests/testData/refactoring/inlineMethod/ChainedConstructor.java new file mode 100644 index 000000000000..a64d2759ef10 --- /dev/null +++ b/java/java-tests/testData/refactoring/inlineMethod/ChainedConstructor.java @@ -0,0 +1,21 @@ +public class InlineThis { + public InlineThis() { + System.out.println("code block here"); + } + + public InlineThis(int i) { + this(); + } + + public InlineThis(String str) { + this(Integer.parseInt(str)); + } + + + + + public static void main(String[] args) { + InlineThis aInlineThis = new InlineThis(); + InlineThis aInlineThis1 = new InlineThis(1); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/inlineMethod/ChainedConstructor.java.after b/java/java-tests/testData/refactoring/inlineMethod/ChainedConstructor.java.after new file mode 100644 index 000000000000..104f8b3722a1 --- /dev/null +++ b/java/java-tests/testData/refactoring/inlineMethod/ChainedConstructor.java.after @@ -0,0 +1,21 @@ +public class InlineThis { + public InlineThis() { + System.out.println("code block here"); + } + + public InlineThis(int i) { + System.out.println("code block here"); + } + + public InlineThis(String str) { + this(Integer.parseInt(str)); + } + + + + + public static void main(String[] args) { + InlineThis aInlineThis = new InlineThis(); + InlineThis aInlineThis1 = new InlineThis(1); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/inlineMethod/ChainedConstructor1.java b/java/java-tests/testData/refactoring/inlineMethod/ChainedConstructor1.java new file mode 100644 index 000000000000..a99133cd1594 --- /dev/null +++ b/java/java-tests/testData/refactoring/inlineMethod/ChainedConstructor1.java @@ -0,0 +1,21 @@ +public class InlineThis { + public InlineThis() { + System.out.println("code block here"); + } + + public InlineThis(int i) { + this(); + } + + public InlineThis(String str) { + this(Integer.parseInt(str)); + } + + + + + public static void main(String[] args) { + InlineThis aInlineThis = new InlineThis(); + InlineThis aInlineThis1 = new InlineThis(1); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/inlineMethod/ChainedConstructor1.java.after b/java/java-tests/testData/refactoring/inlineMethod/ChainedConstructor1.java.after new file mode 100644 index 000000000000..5143141fd436 --- /dev/null +++ b/java/java-tests/testData/refactoring/inlineMethod/ChainedConstructor1.java.after @@ -0,0 +1,17 @@ +public class InlineThis { + public InlineThis() { + System.out.println("code block here"); + } + + public InlineThis(String str) { + this(); + } + + + + + public static void main(String[] args) { + InlineThis aInlineThis = new InlineThis(); + InlineThis aInlineThis1 = new InlineThis(); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java index 99b98075ce1d..8870d33c8791 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java @@ -176,6 +176,14 @@ public class InlineMethodTest extends LightRefactoringTestCase { doTest(); } + public void testChainedConstructor() throws Exception { + doTestInlineThisOnly(); + } + + public void testChainedConstructor1() throws Exception { + doTest(); + } + public void testMethodUsedInJavadoc() throws Exception { try { doTest(); @@ -187,6 +195,10 @@ public class InlineMethodTest extends LightRefactoringTestCase { } public void testInlineRunnableRun() throws Exception { + doTestInlineThisOnly(); + } + + private void doTestInlineThisOnly() { @NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java"; configureByFile(fileName); performAction(new MockInlineMethodOptions(){ diff --git a/platform/lang-api/src/com/intellij/lang/refactoring/InlineActionHandler.java b/platform/lang-api/src/com/intellij/lang/refactoring/InlineActionHandler.java index 5cd8c6a6acbf..7bcdfdc5da54 100644 --- a/platform/lang-api/src/com/intellij/lang/refactoring/InlineActionHandler.java +++ b/platform/lang-api/src/com/intellij/lang/refactoring/InlineActionHandler.java @@ -47,7 +47,7 @@ public abstract class InlineActionHandler { public abstract boolean canInlineElement(PsiElement element); - public boolean canInlineElementInEditor(PsiElement element) { + public boolean canInlineElementInEditor(PsiElement element, Editor editor) { return canInlineElement(element); } diff --git a/platform/lang-impl/src/com/intellij/refactoring/inline/InlineRefactoringActionHandler.java b/platform/lang-impl/src/com/intellij/refactoring/inline/InlineRefactoringActionHandler.java index 02099b506a84..564996b61912 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/inline/InlineRefactoringActionHandler.java +++ b/platform/lang-impl/src/com/intellij/refactoring/inline/InlineRefactoringActionHandler.java @@ -72,7 +72,7 @@ public class InlineRefactoringActionHandler implements RefactoringActionHandler } if (element != null) { for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) { - if (handler.canInlineElementInEditor(element)) { + if (handler.canInlineElementInEditor(element, editor)) { handler.inlineElement(project, editor, element); return; } From 077d8315361434a8fc71c569463adbab67509728 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Fri, 8 Jun 2012 16:20:45 +0400 Subject: [PATCH 044/172] use ByteBuffer directly for serialized byte checking --- .../intellij/util/io/PersistentEnumeratorBase.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/platform/util/src/com/intellij/util/io/PersistentEnumeratorBase.java b/platform/util/src/com/intellij/util/io/PersistentEnumeratorBase.java index 23d7aa030ce8..a2efd5061b19 100644 --- a/platform/util/src/com/intellij/util/io/PersistentEnumeratorBase.java +++ b/platform/util/src/com/intellij/util/io/PersistentEnumeratorBase.java @@ -29,6 +29,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; import java.io.*; +import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -395,12 +396,21 @@ abstract class PersistentEnumeratorBase implements Forceable, Closeable { }; } else { comparer = new OutputStream() { - int address = addr; + int base = addr; + int address = myKeyStorage.getPagedFileStorage().getOffsetInPage(addr); boolean same = true; + ByteBuffer buffer = myKeyStorage.getPagedFileStorage().getByteBuffer(addr, false); + final int myPageSize = myKeyStorage.getPagedFileStorage().myPageSize; + @Override public void write(int b) throws IOException { if (same) { - same = address < myKeyStoreFileLength && myKeyStorage.get(address++) == (byte)b; + if (myPageSize == address && address < myKeyStoreFileLength) { // reached end of current byte buffer + base += address; + buffer = myKeyStorage.getPagedFileStorage().getByteBuffer(base, false); + address = 0; + } + same = address < myKeyStoreFileLength && buffer.get(address++) == (byte)b; } } From 9f8f70563dbb80c39896fdffd6576e1a8f5b0312 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Sat, 9 Jun 2012 16:59:16 +0400 Subject: [PATCH 045/172] avoid static final constant values for versions --- platform/util/src/com/intellij/util/io/IntToIntBtree.java | 5 ++++- .../src/com/intellij/util/io/PersistentBTreeEnumerator.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/util/src/com/intellij/util/io/IntToIntBtree.java b/platform/util/src/com/intellij/util/io/IntToIntBtree.java index 6267349eef39..3ddf33ff3a47 100644 --- a/platform/util/src/com/intellij/util/io/IntToIntBtree.java +++ b/platform/util/src/com/intellij/util/io/IntToIntBtree.java @@ -16,7 +16,10 @@ import java.util.Arrays; * Time: 1:34 PM */ class IntToIntBtree { - static final int VERSION = 3; + public static int version() { + return 3; + } + private static final int HAS_ZERO_KEY_MASK = 0xFF000000; static final boolean doSanityCheck = false; static final boolean doDump = false; diff --git a/platform/util/src/com/intellij/util/io/PersistentBTreeEnumerator.java b/platform/util/src/com/intellij/util/io/PersistentBTreeEnumerator.java index c9fe6310e96d..abcd400023e1 100644 --- a/platform/util/src/com/intellij/util/io/PersistentBTreeEnumerator.java +++ b/platform/util/src/com/intellij/util/io/PersistentBTreeEnumerator.java @@ -60,7 +60,7 @@ public class PersistentBTreeEnumerator extends PersistentEnumeratorBase Date: Sat, 9 Jun 2012 17:05:49 +0400 Subject: [PATCH 046/172] calc project files set only in one thread --- .../util/indexing/FileBasedIndexImpl.java | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java index a8349053520a..cfcc046a8114 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java @@ -69,6 +69,7 @@ import com.intellij.util.io.storage.HeavyProcessLatch; import com.intellij.util.messages.MessageBus; import com.intellij.util.messages.MessageBusConnection; import gnu.trove.*; +import jsr166e.SequenceLock; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -81,6 +82,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.locks.Lock; /** * @author Eugene Zhuravlev @@ -1019,6 +1021,8 @@ public class FileBasedIndexImpl extends FileBasedIndex { } } + private final Lock myCalcIndexableFilesLock = new SequenceLock(); + @Nullable public ProjectIndexableFilesFilter projectIndexableFiles(@Nullable Project project) { if (project == null) return null; @@ -1027,17 +1031,29 @@ public class FileBasedIndexImpl extends FileBasedIndex { ProjectIndexableFilesFilter data = reference != null ? reference.get() : null; if (data != null && data.myModificationCount == myFilesModCount) return data; - final TIntHashSet filesSet = new TIntHashSet(); - iterateIndexableFiles(new ContentIterator() { - @Override - public boolean processFile(@NotNull VirtualFile fileOrDir) { - filesSet.add(((VirtualFileWithId)fileOrDir).getId()); - return true; + myCalcIndexableFilesLock.lock(); // since we calculate project file set to avoid extra vfs related io, it is better to wait a little + try { + reference = project.getUserData(ourProjectFilesSetKey); + data = reference != null ? reference.get() : null; + if (data != null && data.myModificationCount == myFilesModCount) { + return data; } - }, project, ProgressManager.getInstance().getProgressIndicator()); - ProjectIndexableFilesFilter files = new ProjectIndexableFilesFilter(filesSet, myFilesModCount); - project.putUserData(ourProjectFilesSetKey, new SoftReference(files)); - return files; + + final TIntHashSet filesSet = new TIntHashSet(); + iterateIndexableFiles(new ContentIterator() { + @Override + public boolean processFile(@NotNull VirtualFile fileOrDir) { + filesSet.add(((VirtualFileWithId)fileOrDir).getId()); + return true; + } + }, project, ProgressManager.getInstance().getProgressIndicator()); + ProjectIndexableFilesFilter files = new ProjectIndexableFilesFilter(filesSet, myFilesModCount); + project.putUserData(ourProjectFilesSetKey, new SoftReference(files)); + return files; + } + finally { + myCalcIndexableFilesLock.unlock(); + } } @Nullable From ec0689888b61193722314aa2dd5731897bdecbd1 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Sat, 9 Jun 2012 17:11:46 +0400 Subject: [PATCH 047/172] avoid deadlock + readContent can returned data of unfinished write --- .../util/io/storage/RefCountingStorage.java | 92 +++++++++++-------- 1 file changed, 52 insertions(+), 40 deletions(-) diff --git a/platform/util/src/com/intellij/util/io/storage/RefCountingStorage.java b/platform/util/src/com/intellij/util/io/storage/RefCountingStorage.java index 675ce786e2d6..b8704c5d2432 100644 --- a/platform/util/src/com/intellij/util/io/storage/RefCountingStorage.java +++ b/platform/util/src/com/intellij/util/io/storage/RefCountingStorage.java @@ -51,7 +51,7 @@ public class RefCountingStorage extends AbstractStorage { private final boolean myDoNotZipCaches = Boolean.valueOf(System.getProperty("idea.doNotZipCaches")).booleanValue(); private static final int MAX_PENDING_ZIP_SIZE = 20 * 1024 * 1024; - private final Map myPendingWriteRequests = new ConcurrentHashMap(); + private final Map myPendingWriteRequests = new ConcurrentHashMap(); private volatile int myPendingWriteRequestsSize; private final LowMemoryWatcher myPendingWritesFlusher = LowMemoryWatcher.register(new Runnable() { @Override @@ -60,19 +60,19 @@ public class RefCountingStorage extends AbstractStorage { } }); - //private static class WriteRequest { - // final byte[] content; - // final int length; - // final int recordId; - // final boolean fixedSize; - // - // WriteRequest(byte[] _content, int _length, int _recordId, boolean _fixedSize) { - // content = _content; - // length = _length; - // recordId = _recordId; - // fixedSize = _fixedSize; - // } - //} + private static class WriteRequest { + final byte[] content; + final int length; + final int recordId; + final boolean fixedSize; + + WriteRequest(byte[] _content, int _length, int _recordId, boolean _fixedSize) { + content = _content; + length = _length; + recordId = _recordId; + fixedSize = _fixedSize; + } + } private static final int MAX_PENDING_WRITE_SIZE = 2 * 1024 * 1024; @@ -93,10 +93,23 @@ public class RefCountingStorage extends AbstractStorage { } private BufferExposingByteArrayOutputStream internalReadStream(int record) throws IOException { - waitForPendingWriteForRecord(record); + waitForZipToFinish(record); + WriteRequest request; + synchronized (myLock) { + request = myPendingWriteRequests.get(record); + } - byte[] result = super.readBytes(record); - InflaterInputStream in = new CustomInflaterInputStream(result); + byte[] bytes; + int length; + if (request != null) { + bytes = request.content; + length = request.length; + } else { + bytes = super.readBytes(record); + length = bytes.length; + } + + InflaterInputStream in = new CustomInflaterInputStream(bytes, length); try { final BufferExposingByteArrayOutputStream outputStream = new BufferExposingByteArrayOutputStream(); StreamUtil.copyStreamContent(in, outputStream); @@ -108,17 +121,20 @@ public class RefCountingStorage extends AbstractStorage { } private static class CustomInflaterInputStream extends InflaterInputStream { - public CustomInflaterInputStream(byte[] compressedData) { - super(new UnsyncByteArrayInputStream(compressedData), new Inflater(), 1); + private int usedBufferLength; + + public CustomInflaterInputStream(byte[] compressedData, int _length) { + super(new UnsyncByteArrayInputStream(compressedData, 0, _length), new Inflater(), 1); // force to directly use compressed data, this ensures less round trips with native extraction code and copy streams this.buf = compressedData; this.len = -1; // ensure one time fill + usedBufferLength = _length; } @Override protected void fill() throws IOException { if (len >= 0) throw new EOFException(); - len = buf.length; + len = usedBufferLength; inf.setInput(buf, 0, len); } @@ -132,13 +148,13 @@ public class RefCountingStorage extends AbstractStorage { private void waitForPendingWriteForRecord(int record) { waitForZipToFinish(record); - Callable action; + WriteRequest request; synchronized (myLock) { - action = myPendingWriteRequests.get(record); + request = myPendingWriteRequests.get(record); } - if (action != null) { + if (request != null) { try { - action.call(); + write(request); } catch (Exception e) { throw new RuntimeException(e); @@ -176,8 +192,9 @@ public class RefCountingStorage extends AbstractStorage { return; } + waitForPendingWriteForRecord(record); // ensure previous write was completed + synchronized (myLock) { - waitForPendingWriteForRecord(record); // ensure previous write was completed myPendingZipRequestsSize += bytes.getLength(); if (myPendingZipRequestsSize > MAX_PENDING_ZIP_SIZE) { // help async thread @@ -201,13 +218,8 @@ public class RefCountingStorage extends AbstractStorage { private void scheduleZippedContentToWrite(final BufferExposingByteArrayOutputStream outputStream, final int record, final boolean fixedSize) { synchronized (myLock) { myPendingWriteRequestsSize += outputStream.size(); - myPendingWriteRequests.put(record, new Callable() { - @Override - public Void call() throws Exception { - write(outputStream, record, fixedSize); - return null; - } - }); + myPendingWriteRequests.put(record, new WriteRequest(outputStream.getInternalBuffer(), outputStream.size(), record, fixedSize)); + if (myPendingWriteRequestsSize > MAX_PENDING_WRITE_SIZE) { // we do it under lock to ensure normally only one thread will bulky flush stuff flushPendingWrites(); } @@ -215,12 +227,12 @@ public class RefCountingStorage extends AbstractStorage { } - private void write(BufferExposingByteArrayOutputStream zippedBytes, int record, boolean fixedSize) throws IOException { + private void write(WriteRequest writeRequest) throws IOException { synchronized (myLock) { - if (!myPendingWriteRequests.containsKey(record)) return; // some thread helped us - super.writeBytes(record, new ByteSequence(zippedBytes.getInternalBuffer(), 0, zippedBytes.size()), fixedSize); - myPendingWriteRequests.remove(record); - myPendingWriteRequestsSize -= zippedBytes.size(); + if (!myPendingWriteRequests.containsKey(writeRequest.recordId)) return; // some thread helped us + super.writeBytes(writeRequest.recordId, new ByteSequence(writeRequest.content, 0, writeRequest.length), writeRequest.fixedSize); + myPendingWriteRequests.remove(writeRequest.recordId); + myPendingWriteRequestsSize -= writeRequest.length; } } @@ -306,10 +318,10 @@ public class RefCountingStorage extends AbstractStorage { } private void flushPendingWrites() { - for(Map.Entry entry: myPendingWriteRequests.entrySet()) { + for(Map.Entry entry: myPendingWriteRequests.entrySet()) { try { - Callable value = entry.getValue(); - if (value != null) value.call(); + WriteRequest value = entry.getValue(); + if (value != null) write(value); } catch (Exception e) { throw new RuntimeException(e); } From 5e7457fa75df2c4cb5053ae41b13027dab21455c Mon Sep 17 00:00:00 2001 From: "andrey.zaytsev" Date: Fri, 8 Jun 2012 19:15:35 +0400 Subject: [PATCH 048/172] breakpoints ui. navigation --- .../ui/breakpoints/JavaBreakpointItem.java | 9 +++++ .../bookmarks/actions/BookmarksAction.java | 3 +- .../popup/util/MasterDetailPopupBuilder.java | 34 +++++++++++++------ .../breakpoints/ui/BreakpointItem.java | 2 ++ .../impl/breakpoints/XBreakpointItem.java | 11 ++++++ .../BreakpointsMasterDetailPopupFactory.java | 9 +++++ .../BreakpointMasterDetailPopupBuilder.java | 13 +++---- 7 files changed, 61 insertions(+), 20 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointItem.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointItem.java index 170eec164c2f..55b7821f7fc7 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointItem.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointItem.java @@ -98,6 +98,15 @@ class JavaBreakpointItem extends BreakpointItem { } } + @Override + public boolean navigate() { + if (myBreakpoint instanceof BreakpointWithHighlighter) { + ((BreakpointWithHighlighter)myBreakpoint).getSourcePosition().navigate(true); + return true; + } + return false; + } + @Override public boolean allowedToRemove() { return myBreakpointFactory != null && myBreakpointFactory.breakpointCanBeRemoved(myBreakpoint); diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/BookmarksAction.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/BookmarksAction.java index 4e513fad4c78..ad17b92a5a15 100644 --- a/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/BookmarksAction.java +++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/actions/BookmarksAction.java @@ -33,7 +33,6 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.ui.components.JBList; -import com.intellij.ui.popup.util.DetailViewImpl; import com.intellij.ui.popup.util.ItemWrapper; import com.intellij.ui.popup.util.MasterDetailPopupBuilder; import com.intellij.ui.speedSearch.FilteringListModel; @@ -125,7 +124,7 @@ public class BookmarksAction extends AnAction implements DumbAware, MasterDetail } @Override - public void itemChosen(ItemWrapper item, Project project, JBPopup popup) { + public void itemChosen(ItemWrapper item, Project project, JBPopup popup, boolean withEnterOrDoubleClick) { if (item instanceof BookmarkItem) { Bookmark bookmark = ((BookmarkItem)item).getBookmark(); popup.cancel(); diff --git a/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java b/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java index 37d4add0c33d..b338b3162e57 100644 --- a/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java +++ b/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java @@ -15,9 +15,7 @@ */ package com.intellij.ui.popup.util; -import com.intellij.openapi.actionSystem.ActionGroup; -import com.intellij.openapi.actionSystem.ActionManager; -import com.intellij.openapi.actionSystem.ActionToolbar; +import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.JBPopup; import com.intellij.openapi.ui.popup.JBPopupListener; @@ -148,12 +146,12 @@ public class MasterDetailPopupBuilder { public void run() { Object[] values = getSelectedItems(); if (values.length == 1) { - myDelegate.itemChosen((ItemWrapper)values[0], myProject, myPopup); + myDelegate.itemChosen((ItemWrapper)values[0], myProject, myPopup, false); } else { for (Object value : values) { if (value instanceof ItemWrapper) { - myDelegate.itemChosen((ItemWrapper)value, myProject, myPopup); + myDelegate.itemChosen((ItemWrapper)value, myProject, myPopup, false); } } } @@ -235,14 +233,20 @@ public class MasterDetailPopupBuilder { return null; } - public Object[] getSelectedItems() { + public ItemWrapper[] getSelectedItems() { + Object[] values = new Object[0]; if (myChooserComponent instanceof JList) { - return ((JList)myChooserComponent).getSelectedValues(); + values = ((JList)myChooserComponent).getSelectedValues(); + } else if (myChooserComponent instanceof JTree) { - return myDelegate.getSelectedItemsInTree(); + values = myDelegate.getSelectedItemsInTree(); } - return new Object[0]; + ItemWrapper[] items = new ItemWrapper[values.length]; + for (int i = 0; i < values.length; i++) { + items[i] = (ItemWrapper)values[i]; + } + return items; } private void updateDetailViewLater() { @@ -357,6 +361,16 @@ public class MasterDetailPopupBuilder { } } }); + new AnAction(){ + @Override + public void actionPerformed(AnActionEvent e) { + ItemWrapper[] items = getSelectedItems(); + if (items.length > 0) { + myDelegate.itemChosen(items[0], myProject, myPopup, true); + } + } + }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)), list); + } public MasterDetailPopupBuilder setDelegate(Delegate delegate) { @@ -380,7 +394,7 @@ public class MasterDetailPopupBuilder { Object[] getSelectedItemsInTree(); - void itemChosen(ItemWrapper item, Project project, JBPopup popup); + void itemChosen(ItemWrapper item, Project project, JBPopup popup, boolean withEnterOrDoubleClick); } public static class ListItemRenderer extends JPanel implements ListCellRenderer { diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/BreakpointItem.java b/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/BreakpointItem.java index c8d0ac85aaa8..0d8a5d38e033 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/BreakpointItem.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/BreakpointItem.java @@ -135,4 +135,6 @@ public abstract class BreakpointItem implements ItemWrapper { public int hashCode() { return getBreakpoint() != null ? getBreakpoint().hashCode() : 0; } + + public abstract boolean navigate(); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointItem.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointItem.java index 9e22e023753f..ed7d0ae1a818 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointItem.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointItem.java @@ -18,6 +18,7 @@ package com.intellij.xdebugger.impl.breakpoints; import com.intellij.openapi.application.Result; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.project.Project; +import com.intellij.pom.Navigatable; import com.intellij.ui.ColoredListCellRenderer; import com.intellij.ui.ColoredTreeCellRenderer; import com.intellij.ui.SimpleColoredComponent; @@ -99,6 +100,16 @@ class XBreakpointItem extends BreakpointItem { panel.setDetailPanel(propertiesPanel.getMainPanel()); } + @Override + public boolean navigate() { + Navigatable navigatable = myBreakpoint.getNavigatable(); + if (navigatable != null) { + navigatable.navigate(true); + return true; + } + return false; + } + private XBreakpointManagerImpl getManager() { return ((XBreakpointBase)myBreakpoint).getBreakpointManager(); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsMasterDetailPopupFactory.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsMasterDetailPopupFactory.java index 8d4bb612ce6c..3debf7781db0 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsMasterDetailPopupFactory.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsMasterDetailPopupFactory.java @@ -21,6 +21,7 @@ import com.intellij.openapi.ui.popup.Balloon; import com.intellij.openapi.ui.popup.JBPopup; import com.intellij.openapi.ui.popup.JBPopupListener; import com.intellij.openapi.ui.popup.LightweightWindowEvent; +import com.intellij.xdebugger.breakpoints.ui.BreakpointItem; import com.intellij.xdebugger.impl.DebuggerSupport; import com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointMasterDetailPopupBuilder; import org.jetbrains.annotations.Nullable; @@ -66,6 +67,14 @@ public class BreakpointsMasterDetailPopupFactory { BreakpointMasterDetailPopupBuilder builder = new BreakpointMasterDetailPopupBuilder(myProject); builder.setInitialBreakpoint(initialBreakpoint); builder.setBreakpointsPanelProviders(collectPanelProviders()); + builder.setCallback(new BreakpointMasterDetailPopupBuilder.BreakpointChosenCallback() { + @Override + public void breakpointChosen(Project project, BreakpointItem breakpointItem, JBPopup popup) { + if (breakpointItem.navigate()) { + popup.cancel(); + } + } + }); final JBPopup popup = builder.createPopup(); popup.addListener(new JBPopupListener() { @Override diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java index 1514342a3546..85a3a2783941 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java @@ -163,7 +163,7 @@ public class BreakpointMasterDetailPopupBuilder { @Nullable @Override public String getTitle() { - return myIsViewer ? null : "Breakpoints"; + return ""; } @Override @@ -182,12 +182,9 @@ public class BreakpointMasterDetailPopupBuilder { } @Override - public void itemChosen(ItemWrapper item, Project project, JBPopup popup) { - if (!(item instanceof BreakpointItem)) { - return; - } - if (myCallback != null){ - myCallback.breakpointChosen(project, (BreakpointItem)item, popup); + public void itemChosen(ItemWrapper item, Project project, JBPopup popup, boolean withEnterOrDoubleClick) { + if (myCallback != null && item instanceof BreakpointItem && withEnterOrDoubleClick) { + myCallback.breakpointChosen(myProject, (BreakpointItem)item, popup); } } }; @@ -203,7 +200,7 @@ public class BreakpointMasterDetailPopupBuilder { myTreeController.setDelegate(new BreakpointItemsTreeController.BreakpointItemsTreeDelegate() { @Override public void execute(BreakpointItem item) { - delegate.itemChosen(item, myProject, popup); + myCallback.breakpointChosen(myProject, item, popup); } }); From 2775e6a672f421b07468faaf432bc99c8997a529 Mon Sep 17 00:00:00 2001 From: "andrey.zaytsev" Date: Sat, 9 Jun 2012 17:13:50 +0400 Subject: [PATCH 049/172] breakpoints ui. master breakpoint chooser fixes --- .../ui/breakpoints/BreakpointChooser.java | 33 +++- .../BreakpointPropertiesPanel.java | 155 +++++++++++------- .../ui/breakpoints/JavaBreakpointItem.java | 30 ++-- .../intellij/ui/popup/util/DetailView.java | 6 + .../intellij/ui/popup/util/ItemWrapper.java | 28 +++- .../intellij/ui/popup/util/SplitterItem.java | 7 +- .../intellij/ide/bookmarks/BookmarkItem.java | 9 +- .../ui/popup/util/DetailViewImpl.java | 21 ++- .../breakpoints/ui/BreakpointItem.java | 15 +- .../impl/breakpoints/XBreakpointItem.java | 29 ++-- 10 files changed, 205 insertions(+), 128 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointChooser.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointChooser.java index 3eaf0476498e..cc94f6be4b59 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointChooser.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointChooser.java @@ -24,7 +24,9 @@ import com.intellij.openapi.ui.popup.JBPopup; import com.intellij.openapi.ui.popup.JBPopupListener; import com.intellij.openapi.ui.popup.LightweightWindowEvent; import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.UserDataHolderBase; import com.intellij.ui.popup.util.DetailView; +import com.intellij.ui.popup.util.ItemWrapper; import com.intellij.xdebugger.breakpoints.ui.BreakpointItem; import com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointMasterDetailPopupBuilder; import org.jetbrains.annotations.NotNull; @@ -62,8 +64,7 @@ public class BreakpointChooser { public void setSelectedBreakpoint(Object selectedBreakpoint) { mySelectedBreakpoint = selectedBreakpoint; myBreakpointItem = selectedBreakpoint != null ? new JavaBreakpointItem(null, (Breakpoint)selectedBreakpoint) : null; - updatePresentation(myComboBoxAction.getTemplatePresentation(), myBreakpointItem); - myActionToolbar.getComponent().repaint(); + updatePresentation(myComboBoxAction.getTemplatePresentation(), myBreakpointItem); } private void pop(DetailView.PreviewEditorState pushed) { @@ -80,7 +81,7 @@ public class BreakpointChooser { void breakpointChosen(Project project, BreakpointItem breakpointItem, JBPopup popup); } - public BreakpointChooser(Project project, Delegate delegate) { + public BreakpointChooser(Project project, Delegate delegate, Breakpoint baseBreakpoint) { myProject = project; myDelegate = delegate; @@ -146,7 +147,7 @@ public class BreakpointChooser { return null; } }; - + setSelectedBreakpoint(baseBreakpoint); myActionToolbar = ActionManager.getInstance().createActionToolbar("asdad", new DefaultActionGroup(myComboBoxAction), true); } @@ -156,7 +157,7 @@ public class BreakpointChooser { } private void updatePresentation(Presentation presentation, BreakpointItem breakpointItem) { - if (breakpointItem != null) { + if (breakpointItem != null && breakpointItem.getBreakpoint() != null) { presentation.setIcon(breakpointItem.getIcon()); presentation.setText(breakpointItem.getDisplayText()); } @@ -173,9 +174,11 @@ public class BreakpointChooser { private class MyDetailView implements DetailView { private final PreviewEditorState myPushed; + private ItemWrapper myCurrentItem; public MyDetailView(PreviewEditorState pushed) { myPushed = pushed; + putUserData(BreakpointItem.EDITOR_ONLY, Boolean.TRUE); } @Override @@ -210,14 +213,30 @@ public class BreakpointChooser { return myDetailView.getEditorState(); } + public void setCurrentItem(ItemWrapper currentItem) { + myCurrentItem = currentItem; + } + + @Override + public ItemWrapper getCurrentItem() { + return myCurrentItem; + } + + @Override + public boolean hasEditorOnly() { + return true; + } + + UserDataHolderBase myDataHolderBase = new UserDataHolderBase(); + @Override public T getUserData(@NotNull Key key) { - return myDetailView.getUserData(key); + return myDataHolderBase.getUserData(key); } @Override public void putUserData(@NotNull Key key, @Nullable T value) { - myDetailView.putUserData(key, value); + myDataHolderBase.putUserData(key, value); } } } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java index ce2bc0a5a938..c4dee4bc0638 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java @@ -20,6 +20,7 @@ */ package com.intellij.debugger.ui.breakpoints; +import com.intellij.debugger.DebuggerBundle; import com.intellij.debugger.DebuggerManagerEx; import com.intellij.debugger.InstanceFilter; import com.intellij.debugger.engine.evaluation.CodeFragmentKind; @@ -42,6 +43,7 @@ import com.intellij.psi.PsiClass; import com.intellij.psi.PsiElement; import com.intellij.ui.FieldPanel; import com.intellij.ui.MultiLineTooltipUI; +import com.intellij.ui.SimpleColoredComponent; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.popup.util.DetailView; import com.intellij.util.IJSwingUtilities; @@ -61,7 +63,7 @@ import java.util.List; public abstract class BreakpointPropertiesPanel { - private final BreakpointChooser myMasterBreakpointChooser; + private BreakpointChooser myMasterBreakpointChooser; public void setDetailView(DetailView detailView) { myDetailView = detailView; @@ -284,24 +286,6 @@ public abstract class BreakpointPropertiesPanel { myLogExpressionCombo = new DebuggerExpressionComboBox(project, "LineBreakpoint logMessage"); - myMasterBreakpointChooser = new BreakpointChooser(project, new BreakpointChooser.Delegate() { - @Override - public void breakpointChosen(Project project, BreakpointItem item, JBPopup popup) { - final boolean enabled = item != null && item.getBreakpoint() != null; - myLeaveEnabledRadioButton.setEnabled(enabled); - myDisableAgainRadio.setEnabled(enabled); - myEnableOrDisableLabel.setEnabled(enabled); - - if (item != null) { - - saveMasterBreakpoint(); - } - - updateMasterBreakpointPanel(findMasterBreakpointRule()); - - } - }); - myInstanceFiltersField = new FieldPanel(new MyTextField(), "", null, new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -357,8 +341,7 @@ public abstract class BreakpointPropertiesPanel { insert(myConditionComboPanel, conditionPanel); insert(myLogExpressionComboPanel, myLogExpressionCombo); - //insert(myDependentBreakpointComboPanel, baseBreakpointCombo); - insert(myDependentBreakpointComboPanel, myMasterBreakpointChooser.getComponent()); + insert(myInstanceFiltersFieldPanel, myInstanceFiltersField); insert(myClassFiltersFieldPanel, myClassFiltersField); @@ -390,6 +373,68 @@ public abstract class BreakpointPropertiesPanel { break; } } + items.add(new BreakpointItem() { + @Override + public Object getBreakpoint() { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public boolean isEnabled() { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public void setEnabled(boolean state) { + //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + protected void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView) { + renderer.clear(); + renderer.append(getDisplayText()); + } + + @Override + public Icon getIcon() { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public String getDisplayText() { + return DebuggerBundle.message("value.none"); + } + + @Override + public boolean navigate() { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public String speedSearchText() { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public String footerText() { + return ""; + } + + @Override + protected void doUpdateDetailView(DetailView panel, boolean editorOnly) { + //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public boolean allowedToRemove() { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public void removed(Project project) { + //To change body of implemented methods use File | Settings | File Templates. + } + }); return items; } @@ -414,9 +459,13 @@ public abstract class BreakpointPropertiesPanel { else { EnableBreakpointRule rule = findMasterBreakpointRule(); boolean selected = myLeaveEnabledRadioButton.isSelected(); - if (rule != null && (rule.getMasterBreakpoint() != masterBreakpoint || rule.isLeaveEnabled() != selected ) ) { - getBreakpointManager(myProject).removeBreakpointRule(rule); - + if (rule != null) { + if (rule.getMasterBreakpoint() != masterBreakpoint || rule.isLeaveEnabled() != selected) { + getBreakpointManager(myProject).removeBreakpointRule(rule); + } + else { + return; + } } getBreakpointManager(myProject).addBreakpointRule(new EnableBreakpointRule(getBreakpointManager(myProject), masterBreakpoint, @@ -569,14 +618,35 @@ public abstract class BreakpointPropertiesPanel { } private void initMasterBreakpointPanel() { - myMasterBreakpointChooser.setBreakpointItems(getBreakpointItemsExceptMy()); - final EnableBreakpointRule rule = findMasterBreakpointRule(); final Breakpoint baseBreakpoint = rule != null ? rule.getMasterBreakpoint() : null; updateMasterBreakpointPanel(rule); - myMasterBreakpointChooser.setSelectedBreakpoint(baseBreakpoint); + + myMasterBreakpointChooser = new BreakpointChooser(myProject, new BreakpointChooser.Delegate() { + @Override + public void breakpointChosen(Project project, BreakpointItem item, JBPopup popup) { + final boolean enabled = item != null && item.getBreakpoint() != null; + myLeaveEnabledRadioButton.setEnabled(enabled); + myDisableAgainRadio.setEnabled(enabled); + myEnableOrDisableLabel.setEnabled(enabled); + + if (item != null) { + + saveMasterBreakpoint(); + } + + updateMasterBreakpointPanel(findMasterBreakpointRule()); + + } + }, baseBreakpoint); + + insert(myDependentBreakpointComboPanel, myMasterBreakpointChooser.getComponent()); + + + myMasterBreakpointChooser.setBreakpointItems(getBreakpointItemsExceptMy()); + } private @Nullable EnableBreakpointRule findMasterBreakpointRule() { @@ -793,37 +863,6 @@ public abstract class BreakpointPropertiesPanel { return myPanel; } - private static class ComboboxItem { - private final Breakpoint breakpoint; - - public ComboboxItem() { - breakpoint = null; - } - - public ComboboxItem(@NotNull final Breakpoint breakpoint) { - this.breakpoint = breakpoint; - } - - public Breakpoint getBreakpoint() { - return breakpoint; - } - - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - final ComboboxItem comboboxItem = (ComboboxItem)o; - - if (breakpoint != null ? !breakpoint.equals(comboboxItem.breakpoint) : comboboxItem.breakpoint != null) return false; - - return true; - } - - public int hashCode() { - return breakpoint != null ? breakpoint.hashCode() : 0; - } - } - private BreakpointManager getBreakpointManager(Project project) { return DebuggerManagerEx.getInstanceEx(project).getBreakpointManager(); } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointItem.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointItem.java index 55b7821f7fc7..e46e7103fd45 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointItem.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointItem.java @@ -72,21 +72,23 @@ class JavaBreakpointItem extends BreakpointItem { } @Override - protected void doUpdateDetailView(DetailView panel) { - BreakpointPropertiesPanel breakpointPropertiesPanel = myBreakpointFactory != null ? myBreakpointFactory - .createBreakpointPropertiesPanel(myBreakpoint.getProject(), false) : null; - if (breakpointPropertiesPanel != null) { - breakpointPropertiesPanel.setSaveOnRemove(true); - breakpointPropertiesPanel.setDetailView(panel); - } + protected void doUpdateDetailView(DetailView panel, boolean editorOnly) { + if (!editorOnly) { + BreakpointPropertiesPanel breakpointPropertiesPanel = myBreakpointFactory != null ? myBreakpointFactory + .createBreakpointPropertiesPanel(myBreakpoint.getProject(), false) : null; - if (breakpointPropertiesPanel != null) { - breakpointPropertiesPanel.initFrom(myBreakpoint, true); - final JPanel mainPanel = breakpointPropertiesPanel.getPanel(); - panel.setDetailPanel(mainPanel); - } - else { - panel.setDetailPanel(null); + if (breakpointPropertiesPanel != null) { + breakpointPropertiesPanel.initFrom(myBreakpoint, true); + + breakpointPropertiesPanel.setSaveOnRemove(true); + breakpointPropertiesPanel.setDetailView(panel); + + final JPanel mainPanel = breakpointPropertiesPanel.getPanel(); + panel.setDetailPanel(mainPanel); + } + else { + panel.setDetailPanel(null); + } } if (myBreakpoint instanceof BreakpointWithHighlighter) { diff --git a/platform/lang-api/src/com/intellij/ui/popup/util/DetailView.java b/platform/lang-api/src/com/intellij/ui/popup/util/DetailView.java index c195f9789f62..8c174602d27d 100644 --- a/platform/lang-api/src/com/intellij/ui/popup/util/DetailView.java +++ b/platform/lang-api/src/com/intellij/ui/popup/util/DetailView.java @@ -45,6 +45,12 @@ public interface DetailView extends UserDataHolder { PreviewEditorState getEditorState(); + ItemWrapper getCurrentItem(); + + boolean hasEditorOnly(); + + void setCurrentItem(ItemWrapper item); + class PreviewEditorState { public static PreviewEditorState EMPTY = new PreviewEditorState(null, null, null); diff --git a/platform/lang-api/src/com/intellij/ui/popup/util/ItemWrapper.java b/platform/lang-api/src/com/intellij/ui/popup/util/ItemWrapper.java index c1c4d0bcc221..5852d175a7d8 100644 --- a/platform/lang-api/src/com/intellij/ui/popup/util/ItemWrapper.java +++ b/platform/lang-api/src/com/intellij/ui/popup/util/ItemWrapper.java @@ -22,21 +22,31 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; -public interface ItemWrapper { - void setupRenderer(ColoredListCellRenderer renderer, Project project, boolean selected); +public abstract class ItemWrapper { + public abstract void setupRenderer(ColoredListCellRenderer renderer, Project project, boolean selected); - void setupRenderer(ColoredTreeCellRenderer renderer); + public abstract void setupRenderer(ColoredTreeCellRenderer renderer); - void updateAccessoryView(JComponent label); + public abstract void updateAccessoryView(JComponent label); - String speedSearchText(); + public abstract String speedSearchText(); @Nullable - String footerText(); + public abstract String footerText(); - void updateDetailView(DetailView panel); + public void updateDetailView(DetailView panel) { + if (equals(panel.getCurrentItem())) { + return; + } - boolean allowedToRemove(); + doUpdateDetailView(panel, panel.hasEditorOnly()); - void removed(Project project); + panel.setCurrentItem(this); + } + + protected abstract void doUpdateDetailView(DetailView panel, boolean editorOnly); + + public abstract boolean allowedToRemove(); + + public abstract void removed(Project project); } diff --git a/platform/lang-api/src/com/intellij/ui/popup/util/SplitterItem.java b/platform/lang-api/src/com/intellij/ui/popup/util/SplitterItem.java index 1b3bf2bd64cc..79ebb95aca68 100644 --- a/platform/lang-api/src/com/intellij/ui/popup/util/SplitterItem.java +++ b/platform/lang-api/src/com/intellij/ui/popup/util/SplitterItem.java @@ -16,7 +16,6 @@ package com.intellij.ui.popup.util; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.popup.JBPopup; import com.intellij.ui.ColoredListCellRenderer; import com.intellij.ui.ColoredTreeCellRenderer; @@ -29,7 +28,7 @@ import javax.swing.*; * Time: 21:55 * To change this template use File | Settings | File Templates. */ -public class SplitterItem implements ItemWrapper { +public class SplitterItem extends ItemWrapper { private String myText; @@ -58,7 +57,7 @@ public class SplitterItem implements ItemWrapper { @Override public String speedSearchText() { - return ""; //To change body of implemented methods use File | Settings | File Templates. + return ""; } @Override @@ -67,7 +66,7 @@ public class SplitterItem implements ItemWrapper { } @Override - public void updateDetailView(DetailView panel) { + protected void doUpdateDetailView(DetailView panel, boolean editorOnly) { //To change body of implemented methods use File | Settings | File Templates. } diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarkItem.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarkItem.java index 75d3dd2da9fa..6415d3cf6baf 100644 --- a/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarkItem.java +++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarkItem.java @@ -42,7 +42,7 @@ import java.awt.*; * Time: 2:06 AM * To change this template use File | Settings | File Templates. */ -public class BookmarkItem implements ItemWrapper { +public class BookmarkItem extends ItemWrapper { private final Bookmark myBookmark; public BookmarkItem(Bookmark bookmark) { @@ -112,12 +112,7 @@ public class BookmarkItem implements ItemWrapper { return myBookmark.getFile().getPresentableUrl(); } - @Override - public void updateDetailView(final DetailView panel) { - doUpdateDetailView(panel); - } - - private void doUpdateDetailView(DetailView panel) { + protected void doUpdateDetailView(DetailView panel, boolean editorOnly) { panel.navigateInPreviewEditor(DetailView.PreviewEditorState.create(myBookmark.getFile(), myBookmark.getLine())); } diff --git a/platform/lang-impl/src/com/intellij/ui/popup/util/DetailViewImpl.java b/platform/lang-impl/src/com/intellij/ui/popup/util/DetailViewImpl.java index 494b1d649b3d..54213ac37c40 100644 --- a/platform/lang-impl/src/com/intellij/ui/popup/util/DetailViewImpl.java +++ b/platform/lang-impl/src/com/intellij/ui/popup/util/DetailViewImpl.java @@ -47,16 +47,17 @@ import java.awt.*; public class DetailViewImpl extends JPanel implements DetailView, UserDataHolder { private final Project myProject; private Editor myEditor; - private ItemWrapper myWrapper; - private JPanel myDetailPanel; + private ItemWrapper myWrapper; + + private JPanel myDetailPanel; private JBScrollPane myDetailScrollPanel; + private JPanel myDetailPanelWrapper; private JLabel myNothingToShow = new JLabel("Nothing to show"); private JLabel myNothingToShowInEditor = new JLabel("Nothing to show"); private RangeHighlighter myHighlighter; private PreviewEditorState myEditorState = PreviewEditorState.EMPTY; - public DetailViewImpl(Project project) { super(new BorderLayout()); myProject = project; @@ -78,11 +79,25 @@ public class DetailViewImpl extends JPanel implements DetailView, UserDataHolder } } + public void setCurrentItem(ItemWrapper wrapper) { + myWrapper = wrapper; + } + @Override public PreviewEditorState getEditorState() { return myEditorState; } + @Override + public ItemWrapper getCurrentItem() { + return myWrapper; + } + + @Override + public boolean hasEditorOnly() { + return false; + } + @Override public void removeNotify() { super.removeNotify(); diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/BreakpointItem.java b/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/BreakpointItem.java index 0d8a5d38e033..c9067e4425ef 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/BreakpointItem.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/BreakpointItem.java @@ -41,8 +41,9 @@ import javax.swing.*; * Time: 4:48 AM * To change this template use File | Settings | File Templates. */ -public abstract class BreakpointItem implements ItemWrapper { +public abstract class BreakpointItem extends ItemWrapper { protected static final Key BREAKPOINT_ITEM = Key.create("BreakpointItem"); + public static final Key EDITOR_ONLY = Key.create("EditorOnly"); public abstract Object getBreakpoint(); @@ -99,17 +100,6 @@ public abstract class BreakpointItem implements ItemWrapper { setupGenericRenderer(renderer, plainView); } - @Override - public void updateDetailView(DetailView panel) { - - if (panel.getUserData(BREAKPOINT_ITEM) == getBreakpoint()) { - return; - } - - doUpdateDetailView(panel); - - panel.putUserData(BREAKPOINT_ITEM, getBreakpoint()); - } protected abstract void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView); @@ -117,7 +107,6 @@ public abstract class BreakpointItem implements ItemWrapper { public abstract String getDisplayText(); - protected abstract void doUpdateDetailView(DetailView panel); @Override public boolean equals(Object o) { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointItem.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointItem.java index ed7d0ae1a818..8440fa919956 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointItem.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointItem.java @@ -32,12 +32,12 @@ import com.intellij.xdebugger.impl.breakpoints.ui.XLightBreakpointPropertiesPane import javax.swing.*; /** -* Created with IntelliJ IDEA. -* User: intendia -* Date: 10.05.12 -* Time: 1:14 -* To change this template use File | Settings | File Templates. -*/ + * Created with IntelliJ IDEA. + * User: intendia + * Date: 10.05.12 + * Time: 1:14 + * To change this template use File | Settings | File Templates. + */ class XBreakpointItem extends BreakpointItem { private final XBreakpoint myBreakpoint; @@ -82,7 +82,7 @@ class XBreakpointItem extends BreakpointItem { return ((XBreakpointBase)myBreakpoint).getType().getDisplayText(myBreakpoint); } - public void doUpdateDetailView(DetailView panel) { + public void doUpdateDetailView(DetailView panel, boolean editorOnly) { Project project = ((XBreakpointBase)myBreakpoint).getProject(); XSourcePosition sourcePosition = myBreakpoint.getSourcePosition(); @@ -90,14 +90,18 @@ class XBreakpointItem extends BreakpointItem { if (!showInEditor(panel, sourcePosition.getFile(), sourcePosition.getLine())) { return; } - } else { + } + else { panel.clearEditor(); } - XLightBreakpointPropertiesPanel> propertiesPanel = - new XLightBreakpointPropertiesPanel>(project, getManager(), myBreakpoint, true); - propertiesPanel.loadProperties(); - panel.setDetailPanel(propertiesPanel.getMainPanel()); + if (!editorOnly) { + + XLightBreakpointPropertiesPanel> propertiesPanel = + new XLightBreakpointPropertiesPanel>(project, getManager(), myBreakpoint, true); + propertiesPanel.loadProperties(); + panel.setDetailPanel(propertiesPanel.getMainPanel()); + } } @Override @@ -127,7 +131,6 @@ class XBreakpointItem extends BreakpointItem { breakpointManager.removeBreakpoint(myBreakpoint); } }.execute(); - } @Override From 40b72221771ff9ea408cae1e6b9ec964d29967f6 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Thu, 7 Jun 2012 20:13:12 +0400 Subject: [PATCH 050/172] improve android 'create resource from usage': show smart dialog --- .../messages/AndroidBundle.properties | 3 +- .../actions/CreateXmlResourceDialog.form | 35 +++-- .../actions/CreateXmlResourceDialog.java | 34 ++++- .../ResourceReferenceConverter.java | 70 ++++++++- .../AndroidAddStringResourceAction.java | 135 +----------------- .../android/util/AndroidResourceUtil.java | 126 ++++++++++++++++ .../layout/createResourceFromUsageCleanUp.xml | 9 ++ ...esourceFromUsageCleanUp_drawable_after.xml | 3 + ...createResourceFromUsage_drawable_after.xml | 2 +- .../createResourceFromUsage_after.xml | 2 +- .../android/dom/AndroidLayoutDomTest.java | 38 +++++ 11 files changed, 308 insertions(+), 149 deletions(-) create mode 100644 plugins/android/testData/dom/layout/createResourceFromUsageCleanUp.xml create mode 100644 plugins/android/testData/dom/layout/createResourceFromUsageCleanUp_drawable_after.xml diff --git a/plugins/android/resources/messages/AndroidBundle.properties b/plugins/android/resources/messages/AndroidBundle.properties index 7e87a93e68bd..796c174822aa 100644 --- a/plugins/android/resources/messages/AndroidBundle.properties +++ b/plugins/android/resources/messages/AndroidBundle.properties @@ -6,7 +6,8 @@ intention.family=Android package.not.found.error=Package is not specified in the manifest file cannot.resolve.flag.error=Cannot resolve flag cannot.resolve.format.error=Cannot resolve format -create.resource.quickfix.name=Create resource {0} in {1} +create.resource.quickfix.name=Create resource '{0}' in {1} +create.resource.intention.name=Create '{0}' resource {1} quick.fixes.family=Android Quick Fixes not.resource.file.error=File {0} is not resource file check.resource.dir.error=Cannot find resource directory for module {0} diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.form b/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.form index 2fc86f924add..30342474ccb2 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.form +++ b/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.form @@ -1,6 +1,6 @@
- + @@ -8,13 +8,13 @@ - + - + @@ -27,13 +27,13 @@ - + - + @@ -42,7 +42,7 @@ - + @@ -51,7 +51,7 @@ - + @@ -59,7 +59,7 @@ - + @@ -67,12 +67,29 @@ - + + + + + + + + + + + + + + + + + + diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java b/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java index 8c582e52eea5..3e91605653b8 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java +++ b/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java @@ -18,7 +18,6 @@ package org.jetbrains.android.actions; import com.android.resources.ResourceFolderType; import com.android.resources.ResourceType; import com.intellij.CommonBundle; -import com.intellij.ui.ListCellRendererWrapper; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.PlatformDataKeys; @@ -68,6 +67,9 @@ public class CreateXmlResourceDialog extends DialogWrapper { private JTextField myFileNameField; private JPanel myDirectoriesPanel; private JBLabel myDirectoriesLabel; + private JTextField myValueField; + private JBLabel myValueLabel; + private JBLabel myNameLabel; private final Module myModule; private final ResourceType myResourceType; @@ -78,11 +80,24 @@ public class CreateXmlResourceDialog extends DialogWrapper { private final CheckBoxList myDirectoriesList; private VirtualFile myResourceDir; - public CreateXmlResourceDialog(@NotNull Module module, @NotNull ResourceType resourceType) { + public CreateXmlResourceDialog(@NotNull Module module, + @NotNull ResourceType resourceType, + @Nullable String predefinedName, + @Nullable String predefinedValue) { super(module.getProject()); - myResourceType = resourceType; + if (predefinedName != null && predefinedName.length() > 0) { + myNameLabel.setVisible(false); + myNameField.setVisible(false); + myNameField.setText(predefinedName); + } + + if (predefinedValue != null && predefinedValue.length() > 0) { + myValueLabel.setVisible(false); + myValueField.setVisible(false); + myValueField.setText(predefinedValue); + } final Set modulesSet = new HashSet(); modulesSet.add(module); @@ -382,7 +397,7 @@ public class CreateXmlResourceDialog extends DialogWrapper { @Override public JComponent getPreferredFocusedComponent() { - return myNameField; + return myNameField.isVisible() ? myNameField : myValueField; } @Override @@ -409,6 +424,7 @@ public class CreateXmlResourceDialog extends DialogWrapper { } else { super.doOKAction(); + } } @@ -434,6 +450,16 @@ public class CreateXmlResourceDialog extends DialogWrapper { return myFileNameField.getText().trim(); } + @NotNull + public String getName() { + return myNameField.getText().trim(); + } + + @NotNull + public String getValue() { + return myValueField.getText().trim(); + } + @Nullable public Module getModule() { return myModule != null ? myModule : (Module)myModuleCombo.getSelectedItem(); diff --git a/plugins/android/src/org/jetbrains/android/dom/converters/ResourceReferenceConverter.java b/plugins/android/src/org/jetbrains/android/dom/converters/ResourceReferenceConverter.java index 30f6d2608222..6bf9f9b82614 100644 --- a/plugins/android/src/org/jetbrains/android/dom/converters/ResourceReferenceConverter.java +++ b/plugins/android/src/org/jetbrains/android/dom/converters/ResourceReferenceConverter.java @@ -15,23 +15,29 @@ */ package org.jetbrains.android.dom.converters; +import com.android.AndroidConstants; import com.android.resources.ResourceType; +import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInspection.LocalQuickFix; import com.intellij.codeInspection.ProblemDescriptor; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.undo.UndoUtil; import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.editor.Editor; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiReference; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlElement; import com.intellij.psi.xml.XmlTag; -import com.intellij.util.PsiNavigateUtil; +import com.intellij.util.IncorrectOperationException; import com.intellij.util.xml.*; +import org.jetbrains.android.actions.CreateXmlResourceDialog; import org.jetbrains.android.dom.AdditionalConverter; import org.jetbrains.android.dom.AndroidResourceType; import org.jetbrains.android.dom.resources.Item; @@ -336,7 +342,7 @@ public class ResourceReferenceConverter extends ResolvingConverter dirNames, - @NotNull String value) { - final Project project = module.getProject(); - final AndroidFacet facet = AndroidFacet.getInstance(module); - assert facet != null; - - try { - return addValueResource(facet, resourceName, resourceType, fileName, dirNames, value); - } - catch (Exception e) { - final String message = CreateElementActionBase.filterMessage(e.getMessage()); - - if (message == null || message.length() == 0) { - LOG.error(e); - } - else { - LOG.info(e); - reportError(project, message); - } - return false; - } - } - - private static boolean addValueResource(@NotNull AndroidFacet facet, - @NotNull String resourceName, - @NotNull ResourceType resourceType, - @NotNull String fileName, - @NotNull List dirNames, - @NotNull String value) throws Exception { - if (dirNames.size() == 0) { - return false; - } - final VirtualFile[] resFiles = new VirtualFile[dirNames.size()]; - - for (int i = 0, n = dirNames.size(); i < n; i++) { - final VirtualFile resFile = findOrCreateResourceFile(facet, fileName, dirNames.get(i)); - if (resFile == null) { - return false; - } - resFiles[i] = resFile; - } - - if (!ReadonlyStatusHandler.ensureFilesWritable(facet.getModule().getProject(), resFiles)) { - return false; - } - final Resources[] resourcesElements = new Resources[resFiles.length]; - - for (int i = 0; i < resFiles.length; i++) { - final Resources resources = AndroidUtils.loadDomElement(facet.getModule(), resFiles[i], Resources.class); - if (resources == null) { - reportError(facet.getModule().getProject(), AndroidBundle.message("not.resource.file.error", fileName)); - return false; - } - resourcesElements[i] = resources; - } - - for (Resources resources : resourcesElements) { - final ResourceElement element = AndroidResourceUtil.addValueResource(resourceType.getName(), resources); - element.getName().setValue(resourceName); - - if (value.length() > 0) { - element.setStringValue(value); - } - } - return true; - } - - @Nullable - private static VirtualFile findOrCreateResourceFile(@NotNull AndroidFacet facet, - @NotNull final String fileName, - @NotNull String dirName) throws Exception { - final Module module = facet.getModule(); - final Project project = module.getProject(); - final VirtualFile resDir = facet.getLocalResourceManager().getResourceDir(); - - if (resDir == null) { - reportError(project, AndroidBundle.message("check.resource.dir.error", module.getName())); - return null; - } - final VirtualFile dir = AndroidUtils.createChildDirectoryIfNotExist(project, resDir, dirName); - final String dirPath = FileUtil.toSystemDependentName(resDir.getPath() + '/' + dirName); - - if (dir == null) { - reportError(project, AndroidBundle.message("android.cannot.create.dir.error", dirPath)); - return null; - } - - final VirtualFile file = dir.findChild(fileName); - if (file != null) { - return file; - } - - AndroidFileTemplateProvider - .createFromTemplate(project, dir, AndroidFileTemplateProvider.VALUE_RESOURCE_FILE_TEMPLATE, fileName); - final VirtualFile result = dir.findChild(fileName); - if (result == null) { - reportError(project, AndroidBundle.message("android.cannot.create.file.error", dirPath + File.separatorChar + fileName)); - } - return result; - } - - private static void reportError(@NotNull Project project, @NotNull String message) { - if (ApplicationManager.getApplication().isUnitTestMode()) { - throw new IncorrectOperationException(message); - } - else { - Messages.showErrorDialog(project, message, CommonBundle.getErrorTitle()); - } - } - private static class MyVarOfTypeExpression extends VariableOfTypeMacro { private final String myDefaultValue; diff --git a/plugins/android/src/org/jetbrains/android/util/AndroidResourceUtil.java b/plugins/android/src/org/jetbrains/android/util/AndroidResourceUtil.java index 602bff3ea171..dcbdc39a17a1 100644 --- a/plugins/android/src/org/jetbrains/android/util/AndroidResourceUtil.java +++ b/plugins/android/src/org/jetbrains/android/util/AndroidResourceUtil.java @@ -19,22 +19,31 @@ package org.jetbrains.android.util; import com.android.resources.ResourceFolderType; import com.android.resources.ResourceType; import com.android.sdklib.SdkConstants; +import com.intellij.CommonBundle; +import com.intellij.ide.actions.CreateElementActionBase; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ModulePackageIndex; import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.ReadonlyStatusHandler; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlAttributeValue; import com.intellij.psi.xml.XmlTag; import com.intellij.util.ArrayUtil; +import com.intellij.util.IncorrectOperationException; import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashSet; +import org.jetbrains.android.AndroidFileTemplateProvider; import org.jetbrains.android.dom.manifest.Manifest; import org.jetbrains.android.dom.resources.Item; import org.jetbrains.android.dom.resources.ResourceElement; @@ -43,12 +52,15 @@ import org.jetbrains.android.facet.AndroidFacet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.File; import java.util.*; /** * @author Eugene.Kudelevsky */ public class AndroidResourceUtil { + private static final Logger LOG = Logger.getInstance("#org.jetbrains.android.util.AndroidResourceUtil"); + public static final String NEW_ID_PREFIX = "@+id/"; public static final Set VALUE_RESOURCE_TYPES = EnumSet.of(ResourceType.DRAWABLE, ResourceType.COLOR, ResourceType.DIMEN, @@ -565,4 +577,118 @@ public class AndroidResourceUtil { final List names = getNames(resourceTypes); return ArrayUtil.toStringArray(names); } + + public static boolean createValueResource(@NotNull Module module, + @NotNull String resourceName, + @NotNull ResourceType resourceType, + @NotNull String fileName, + @NotNull List dirNames, + @NotNull String value) { + final Project project = module.getProject(); + final AndroidFacet facet = AndroidFacet.getInstance(module); + assert facet != null; + + try { + return addValueResource(facet, resourceName, resourceType, fileName, dirNames, value); + } + catch (Exception e) { + final String message = CreateElementActionBase.filterMessage(e.getMessage()); + + if (message == null || message.length() == 0) { + LOG.error(e); + } + else { + LOG.info(e); + reportError(project, message); + } + return false; + } + } + + private static boolean addValueResource(@NotNull AndroidFacet facet, + @NotNull String resourceName, + @NotNull ResourceType resourceType, + @NotNull String fileName, + @NotNull List dirNames, + @NotNull String value) throws Exception { + if (dirNames.size() == 0) { + return false; + } + final VirtualFile[] resFiles = new VirtualFile[dirNames.size()]; + + for (int i = 0, n = dirNames.size(); i < n; i++) { + final VirtualFile resFile = findOrCreateResourceFile(facet, fileName, dirNames.get(i)); + if (resFile == null) { + return false; + } + resFiles[i] = resFile; + } + + if (!ReadonlyStatusHandler.ensureFilesWritable(facet.getModule().getProject(), resFiles)) { + return false; + } + final Resources[] resourcesElements = new Resources[resFiles.length]; + + for (int i = 0; i < resFiles.length; i++) { + final Resources resources = AndroidUtils.loadDomElement(facet.getModule(), resFiles[i], Resources.class); + if (resources == null) { + reportError(facet.getModule().getProject(), AndroidBundle.message("not.resource.file.error", fileName)); + return false; + } + resourcesElements[i] = resources; + } + + for (Resources resources : resourcesElements) { + final ResourceElement element = addValueResource(resourceType.getName(), resources); + element.getName().setValue(resourceName); + + if (value.length() > 0) { + element.setStringValue(value); + } + } + return true; + } + + @Nullable + private static VirtualFile findOrCreateResourceFile(@NotNull AndroidFacet facet, + @NotNull final String fileName, + @NotNull String dirName) throws Exception { + final Module module = facet.getModule(); + final Project project = module.getProject(); + final VirtualFile resDir = facet.getLocalResourceManager().getResourceDir(); + + if (resDir == null) { + reportError(project, AndroidBundle.message("check.resource.dir.error", module.getName())); + return null; + } + final VirtualFile dir = AndroidUtils.createChildDirectoryIfNotExist(project, resDir, dirName); + final String dirPath = FileUtil.toSystemDependentName(resDir.getPath() + '/' + dirName); + + if (dir == null) { + reportError(project, AndroidBundle.message("android.cannot.create.dir.error", dirPath)); + return null; + } + + final VirtualFile file = dir.findChild(fileName); + if (file != null) { + return file; + } + + AndroidFileTemplateProvider + .createFromTemplate(project, dir, AndroidFileTemplateProvider.VALUE_RESOURCE_FILE_TEMPLATE, fileName); + final VirtualFile result = dir.findChild(fileName); + if (result == null) { + reportError(project, AndroidBundle.message("android.cannot.create.file.error", dirPath + File.separatorChar + fileName)); + } + return result; + } + + private static void reportError(@NotNull Project project, @NotNull String message) { + if (ApplicationManager.getApplication().isUnitTestMode()) { + throw new IncorrectOperationException(message); + } + else { + Messages.showErrorDialog(project, message, CommonBundle.getErrorTitle()); + } + } } diff --git a/plugins/android/testData/dom/layout/createResourceFromUsageCleanUp.xml b/plugins/android/testData/dom/layout/createResourceFromUsageCleanUp.xml new file mode 100644 index 000000000000..1e0ef611712c --- /dev/null +++ b/plugins/android/testData/dom/layout/createResourceFromUsageCleanUp.xml @@ -0,0 +1,9 @@ + + + diff --git a/plugins/android/testData/dom/layout/createResourceFromUsageCleanUp_drawable_after.xml b/plugins/android/testData/dom/layout/createResourceFromUsageCleanUp_drawable_after.xml new file mode 100644 index 000000000000..3b9fffc53297 --- /dev/null +++ b/plugins/android/testData/dom/layout/createResourceFromUsageCleanUp_drawable_after.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/plugins/android/testData/dom/layout/createResourceFromUsage_drawable_after.xml b/plugins/android/testData/dom/layout/createResourceFromUsage_drawable_after.xml index 3b9fffc53297..bba8e55c5f40 100644 --- a/plugins/android/testData/dom/layout/createResourceFromUsage_drawable_after.xml +++ b/plugins/android/testData/dom/layout/createResourceFromUsage_drawable_after.xml @@ -1,3 +1,3 @@ - + a \ No newline at end of file diff --git a/plugins/android/testData/dom/resources/createResourceFromUsage_after.xml b/plugins/android/testData/dom/resources/createResourceFromUsage_after.xml index 957b0b8f0e1c..cdb63538ce0b 100644 --- a/plugins/android/testData/dom/resources/createResourceFromUsage_after.xml +++ b/plugins/android/testData/dom/resources/createResourceFromUsage_after.xml @@ -1,4 +1,4 @@ @drawable/dd2 - + a \ No newline at end of file diff --git a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java index 4d08447e2949..a2979b3405a0 100644 --- a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java +++ b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java @@ -4,6 +4,7 @@ import com.android.sdklib.SdkConstants; import com.intellij.codeInsight.TargetElementUtilBase; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.codeInspection.actions.CleanupInspectionIntention; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; @@ -364,6 +365,43 @@ public class AndroidLayoutDomTest extends AndroidDomTest { myFixture.checkResultByFile("res/values/drawables.xml", testFolder + '/' + getTestName(true) + "_drawable_after.xml", true); } + public void testCreateResourceFromUsageCleanUp() throws Throwable { + final VirtualFile virtualFile = copyFileToProject(getTestName(true) + ".xml"); + myFixture.configureFromExistingVirtualFile(virtualFile); + final List infos = myFixture.doHighlighting(); + + final List actions = new ArrayList(); + + for (HighlightInfo info : infos) { + final List> ranges = info.quickFixActionRanges; + + if (ranges != null) { + for (Pair pair : ranges) { + final HighlightInfo.IntentionActionDescriptor descriptor = pair.getFirst(); + final List options = descriptor.getOptions(myFixture.getFile(), myFixture.getEditor()); + + if (options != null) { + for (IntentionAction option : options) { + if (option instanceof CleanupInspectionIntention) { + actions.add(option); + } + } + } + } + } + } + + assertEquals(1, actions.size()); + + new WriteCommandAction.Simple(getProject()) { + @Override + protected void run() throws Throwable { + actions.get(0).invoke(getProject(), myFixture.getEditor(), myFixture.getFile()); + } + }.execute(); + myFixture.checkResultByFile("res/values/drawables.xml", testFolder + '/' + getTestName(true) + "_drawable_after.xml", true); + } + public void testXsdFile1() throws Throwable { final VirtualFile virtualFile = copyFileToProject("XsdFile.xsd", "res/raw/XsdFile.xsd"); myFixture.configureFromExistingVirtualFile(virtualFile); From c6ff7e0a62d1c919d83b418d64381e399e6a2752 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Fri, 8 Jun 2012 19:17:33 +0400 Subject: [PATCH 051/172] improve 'create from usages' quick fixes for android resources: smart creating of file resources --- .../messages/AndroidBundle.properties | 6 +- .../android/actions/CreateResourceDialog.form | 34 ++-- .../android/actions/CreateResourceDialog.java | 95 ++++++++++- .../actions/CreateResourceFileAction.java | 69 ++++++-- .../actions/CreateXmlResourceDialog.java | 11 +- .../ResourceReferenceConverter.java | 150 ++++++++++++------ .../LocalResourceManager.java | 13 +- .../uipreview/DeviceConfiguratorPanel.java | 6 +- .../util/ModuleListCellRendererWrapper.java | 22 +++ .../android/dom/AndroidLayoutDomTest.java | 20 ++- .../dom/AndroidValueResourcesTest.java | 7 +- 11 files changed, 322 insertions(+), 111 deletions(-) create mode 100644 plugins/android/src/org/jetbrains/android/util/ModuleListCellRendererWrapper.java diff --git a/plugins/android/resources/messages/AndroidBundle.properties b/plugins/android/resources/messages/AndroidBundle.properties index 796c174822aa..ebfbde4a815e 100644 --- a/plugins/android/resources/messages/AndroidBundle.properties +++ b/plugins/android/resources/messages/AndroidBundle.properties @@ -6,8 +6,10 @@ intention.family=Android package.not.found.error=Package is not specified in the manifest file cannot.resolve.flag.error=Cannot resolve flag cannot.resolve.format.error=Cannot resolve format -create.resource.quickfix.name=Create resource '{0}' in {1} -create.resource.intention.name=Create '{0}' resource {1} +create.value.resource.quickfix.name=Create value resource ''{0}'' in ''{1}'' +create.value.resource.intention.name=Create {0} value resource ''{1}'' +create.file.resource.quickfix.name=Create resource file ''{0}'' in {1} +create.file.resource.intention.name=Create {0} resource file ''{1}'' quick.fixes.family=Android Quick Fixes not.resource.file.error=File {0} is not resource file check.resource.dir.error=Cannot find resource directory for module {0} diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.form b/plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.form index 7707b5a275ac..2d3e556e7079 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.form +++ b/plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.form @@ -1,6 +1,6 @@
- + @@ -8,7 +8,7 @@ - + @@ -54,7 +54,7 @@ - + @@ -62,13 +62,13 @@ - + - + @@ -77,17 +77,18 @@ - + - + + - + @@ -95,12 +96,27 @@ - + + + + + + + + + + + + + + + + diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.java b/plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.java index f53dcb9cd0f8..13239b7c5a48 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.java +++ b/plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.java @@ -18,8 +18,10 @@ package org.jetbrains.android.actions; import com.android.ide.common.resources.configuration.FolderConfiguration; import com.android.resources.ResourceFolderType; +import com.android.resources.ResourceType; import com.intellij.CommonBundle; import com.intellij.ide.actions.TemplateKindCombo; +import com.intellij.openapi.module.Module; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.InputValidator; import com.intellij.openapi.ui.Messages; @@ -27,11 +29,15 @@ import com.intellij.ui.TextFieldWithAutoCompletion; import com.intellij.ui.components.JBLabel; import com.intellij.util.PlatformIcons; import com.intellij.util.containers.HashMap; +import com.intellij.util.containers.HashSet; import org.jetbrains.android.facet.AndroidFacet; import org.jetbrains.android.uipreview.DeviceConfiguratorPanel; import org.jetbrains.android.uipreview.InvalidOptionValueException; import org.jetbrains.android.util.AndroidBundle; +import org.jetbrains.android.util.AndroidUtils; +import org.jetbrains.android.util.ModuleListCellRendererWrapper; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; @@ -47,7 +53,7 @@ import java.util.List; * Time: 7:47:01 PM * To change this template use File | Settings | File Templates. */ -public abstract class CreateResourceDialog extends DialogWrapper { +public class CreateResourceDialog extends DialogWrapper { private JTextField myFileNameField; private TemplateKindCombo myResourceTypeCombo; private JPanel myPanel; @@ -58,6 +64,9 @@ public abstract class CreateResourceDialog extends DialogWrapper { private JTextField myDirectoryNameTextField; private JPanel myRootElementFieldWrapper; private JBLabel myRootElementLabel; + private JLabel myFileNameLabel; + private JComboBox myModuleCombo; + private JBLabel myModuleLabel; private TextFieldWithAutoCompletion myRootElementField; private InputValidator myValidator; @@ -65,7 +74,12 @@ public abstract class CreateResourceDialog extends DialogWrapper { private final DeviceConfiguratorPanel myDeviceConfiguratorPanel; private final AndroidFacet myFacet; - public CreateResourceDialog(@NotNull AndroidFacet facet, Collection actions) { + public CreateResourceDialog(@NotNull AndroidFacet facet, + Collection actions, + @Nullable ResourceType predefinedResourceType, + @Nullable String predefinedFileName, + @NotNull Module module, + boolean chooseModule) { super(facet.getModule().getProject()); myFacet = facet; myResTypeLabel.setLabelFor(myResourceTypeCombo); @@ -79,12 +93,17 @@ public abstract class CreateResourceDialog extends DialogWrapper { return a1.toString().compareTo(a2.toString()); } }); + String selectedTemplate = null; for (CreateTypedResourceFileAction action : actionArray) { String resType = action.getResourceType(); assert !myResType2ActionMap.containsKey(resType); myResType2ActionMap.put(resType, action); myResourceTypeCombo.addItem(action.toString(), null, resType); + + if (predefinedResourceType != null && predefinedResourceType.getName().equals(resType)) { + selectedTemplate = resType; + } } myDeviceConfiguratorPanel = new DeviceConfiguratorPanel(null) { @@ -122,6 +141,45 @@ public abstract class CreateResourceDialog extends DialogWrapper { } }); + if (predefinedResourceType != null && selectedTemplate != null) { + final boolean v = predefinedResourceType == ResourceType.LAYOUT; + myRootElementLabel.setVisible(v); + myRootElementFieldWrapper.setVisible(v); + + myResTypeLabel.setVisible(false); + myResourceTypeCombo.setVisible(false); + myUpDownHint.setVisible(false); + myResourceTypeCombo.setSelectedName(selectedTemplate); + } + + if (predefinedFileName != null) { + myFileNameField.setVisible(false); + myFileNameLabel.setVisible(false); + myFileNameField.setText(predefinedFileName); + } + + final Set modulesSet = new HashSet(); + modulesSet.add(module); + for (AndroidFacet depFacet : AndroidUtils.getAllAndroidDependencies(module, true)) { + modulesSet.add(depFacet.getModule()); + } + + final Module[] modules = modulesSet.toArray(new Module[modulesSet.size()]); + Arrays.sort(modules, new Comparator() { + @Override + public int compare(Module m1, Module m2) { + return m1.getName().compareTo(m2.getName()); + } + }); + myModuleCombo.setModel(new DefaultComboBoxModel(modules)); + + if (!chooseModule || modules.length == 1) { + myModuleLabel.setVisible(false); + myModuleCombo.setVisible(false); + } + myModuleCombo.setRenderer(new ModuleListCellRendererWrapper(myModuleCombo.getRenderer())); + myModuleCombo.setSelectedItem(module); + myDeviceConfiguratorPanel.updateAll(); myDeviceConfiguratorWrapper.add(myDeviceConfiguratorPanel, BorderLayout.CENTER); setOKActionEnabled(myDirectoryNameTextField.getText().length() > 0); @@ -152,7 +210,10 @@ public abstract class CreateResourceDialog extends DialogWrapper { return false; } - protected abstract InputValidator createValidator(@NotNull String subdirName); + @Nullable + protected InputValidator createValidator(@NotNull String subdirName) { + return null; + } @Override protected void doOKAction() { @@ -170,15 +231,24 @@ public abstract class CreateResourceDialog extends DialogWrapper { return; } - final String subdirName = myDirectoryNameTextField.getText(); - assert subdirName != null && subdirName.length() > 0; - + final String subdirName = getSubdirName(); + assert subdirName.length() > 0; myValidator = createValidator(subdirName); - if (myValidator.checkInput(fileName) && myValidator.canClose(fileName)) { + if (myValidator == null || myValidator.checkInput(fileName) && myValidator.canClose(fileName)) { super.doOKAction(); } } + @NotNull + public Module getSelectedModule() { + return (Module)myModuleCombo.getSelectedItem(); + } + + @NotNull + public String getSubdirName() { + return myDirectoryNameTextField.getText().trim(); + } + @NotNull protected String getRootElement() { final String item = myRootElementField.getText().trim(); @@ -196,7 +266,16 @@ public abstract class CreateResourceDialog extends DialogWrapper { @Override public JComponent getPreferredFocusedComponent() { - return myFileNameField; + if (myFileNameField.isVisible()) { + return myFileNameField; + } + else if (myResourceTypeCombo.isVisible()) { + return myResourceTypeCombo; + } + else if (myModuleCombo.isVisible()) { + return myModuleCombo; + } + return myDeviceConfiguratorPanel.getAvailableQualifiersList(); } public CreateTypedResourceFileAction getSelectedAction() { diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileAction.java b/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileAction.java index 137f48b5ce27..ce3d080544ff 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileAction.java +++ b/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileAction.java @@ -17,6 +17,7 @@ package org.jetbrains.android.actions; import com.android.AndroidConstants; +import com.android.resources.ResourceType; import com.intellij.CommonBundle; import com.intellij.ide.actions.CreateElementActionBase; import com.intellij.openapi.actionSystem.ActionManager; @@ -26,6 +27,7 @@ import com.intellij.openapi.actionSystem.DataKeys; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileTypes.StdFileTypes; +import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.InputValidator; import com.intellij.openapi.util.Computable; @@ -89,15 +91,35 @@ public class CreateResourceFileAction extends CreateElementActionBase { } // must be invoked in a write action - public static PsiElement[] createResourceFile(Project project, - @NotNull VirtualFile resDir, - @NotNull String resType, - @NotNull String resName) { - PsiDirectory psiResDir = PsiManager.getInstance(project).findDirectory(resDir); - if (psiResDir != null) { - CreateElementActionBase.MyInputValidator validator = getInstance().createValidator(project, psiResDir, resType); - if (validator.checkInput(resName) && validator.canClose(resName)) { - return validator.getCreatedElements(); + public static PsiElement[] createResourceFile(final Project project, + @NotNull AndroidFacet facet, + @NotNull final ResourceType resType, + @NotNull String resName, + boolean chooseDirectory) { + final CreateResourceFileAction action = getInstance(); + String subdirName = resType.getName(); + VirtualFile resourceDir = facet.getLocalResourceManager().getResourceDir(); + + if (chooseDirectory) { + final MyDialog dialog = new MyDialog(facet, action.mySubactions.values(), resType, resName, action, facet.getModule(), true); + dialog.setTitle(AndroidBundle.message("new.resource.dialog.title")); + dialog.show(); + if (!dialog.isOK()) { + return PsiElement.EMPTY_ARRAY; + } + subdirName = dialog.getSubdirName(); + final AndroidFacet selectedFacet = AndroidFacet.getInstance(dialog.getSelectedModule()); + LOG.assertTrue(selectedFacet != null); + resourceDir = selectedFacet.getLocalResourceManager().getResourceDir(); + } + + if (resourceDir != null) { + final PsiDirectory psiResDir = PsiManager.getInstance(project).findDirectory(resourceDir); + if (psiResDir != null) { + CreateElementActionBase.MyInputValidator validator = action.createValidator(project, psiResDir, subdirName); + if (validator.checkInput(resName) && validator.canClose(resName)) { + return validator.getCreatedElements(); + } } } return PsiElement.EMPTY_ARRAY; @@ -109,17 +131,11 @@ public class CreateResourceFileAction extends CreateElementActionBase { final AndroidFacet facet = AndroidFacet.getInstance(directory); LOG.assertTrue(facet != null); - CreateResourceDialog dialog = new CreateResourceDialog(facet, mySubactions.values()) { + MyDialog dialog = new MyDialog(facet, mySubactions.values(), null, null, CreateResourceFileAction.this, facet.getModule(), false) { @Override protected InputValidator createValidator(@NotNull String subdirName) { return CreateResourceFileAction.this.createValidator(project, directory, subdirName); } - - @Override - protected void doOKAction() { - myRootElement = getRootElement(); - super.doOKAction(); - } }; dialog.setTitle(AndroidBundle.message("new.resource.dialog.title")); dialog.show(); @@ -180,4 +196,25 @@ public class CreateResourceFileAction extends CreateElementActionBase { } return AndroidBundle.message("new.resource.action.name", directory.getName() + File.separator + newName); } + + private static class MyDialog extends CreateResourceDialog { + private final CreateResourceFileAction myAction; + + protected MyDialog(@NotNull AndroidFacet facet, + Collection actions, + @Nullable ResourceType predefinedResourceType, + @Nullable String predefinedFileName, + @NotNull CreateResourceFileAction action, + @NotNull Module module, + boolean chooseModule) { + super(facet, actions, predefinedResourceType, predefinedFileName, module, chooseModule); + myAction = action; + } + + @Override + protected void doOKAction() { + super.doOKAction(); + myAction.myRootElement = getRootElement(); + } + } } diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java b/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java index 3e91605653b8..ab2e43d7f575 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java +++ b/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java @@ -24,7 +24,6 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.fileChooser.actions.VirtualFileDeleteProvider; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; @@ -47,6 +46,7 @@ import org.jetbrains.android.facet.AndroidRootUtil; import org.jetbrains.android.util.AndroidBundle; import org.jetbrains.android.util.AndroidResourceUtil; import org.jetbrains.android.util.AndroidUtils; +import org.jetbrains.android.util.ModuleListCellRendererWrapper; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -125,14 +125,7 @@ public class CreateXmlResourceDialog extends DialogWrapper { myModuleCombo.setModel(new DefaultComboBoxModel(modules)); myModuleCombo.setSelectedItem(module); - - myModuleCombo.setRenderer(new ListCellRendererWrapper(myModuleCombo.getRenderer()) { - @Override - public void customize(JList list, Module module, int index, boolean selected, boolean hasFocus) { - setText(module.getName()); - setIcon(ModuleType.get(module).getNodeIcon(false)); - } - }); + myModuleCombo.setRenderer(new ModuleListCellRendererWrapper(myModuleCombo.getRenderer())); } final String defaultResFileName = AndroidResourceUtil.getDefaultResourceFileName(resourceType.getName()); diff --git a/plugins/android/src/org/jetbrains/android/dom/converters/ResourceReferenceConverter.java b/plugins/android/src/org/jetbrains/android/dom/converters/ResourceReferenceConverter.java index 6bf9f9b82614..2c97811d6614 100644 --- a/plugins/android/src/org/jetbrains/android/dom/converters/ResourceReferenceConverter.java +++ b/plugins/android/src/org/jetbrains/android/dom/converters/ResourceReferenceConverter.java @@ -121,7 +121,7 @@ public class ResourceReferenceConverter extends ResolvingConverter recommendedTypes = getResourceTypes(context); // hack to check if it is a real id attribute @@ -175,16 +175,16 @@ public class ResourceReferenceConverter extends ResolvingConverter getResourceTypesInCurrentModule(@NotNull AndroidFacet facet) { final Set result = new HashSet(); final LocalResourceManager manager = facet.getLocalResourceManager(); - + for (VirtualFile resSubdir : manager.getResourceSubdirs(null)) { final String resType = AndroidCommonUtils.getResourceTypeByDirName(resSubdir.getName()); - - if (resType != null && com.android.resources.ResourceType.getEnum(resType) != null) { + + if (resType != null && ResourceType.getEnum(resType) != null) { result.add(resType); } } @@ -245,7 +245,7 @@ public class ResourceReferenceConverter extends ResolvingConverter additionalConverter = getAdditionalConverter(context); - + if ((parsed == null || !parsed.isReference()) && additionalConverter != null) { String value = additionalConverter.fromString(s, context); if (value != null) { @@ -267,7 +267,7 @@ public class ResourceReferenceConverter extends ResolvingConverter fixes = new ArrayList(); + + if (AndroidResourceUtil.VALUE_RESOURCE_TYPES.contains(resType)) { + fixes.add(new MyCreateValueResourceQuickFix(facet, resType, resourceName, context.getFile())); } + if (XML_FILE_RESOURCE_TYPES.contains(resType)) { + fixes.add(new MyCreateFileResourceQuickFix(facet, resType, resourceName, context.getFile())); + } + return fixes.toArray(new LocalQuickFix[fixes.size()]); } } } @@ -335,20 +344,23 @@ public class ResourceReferenceConverter extends ResolvingConverter list = manager.findValueResources(myResourceType, myResourceName); - if (list.size() == 1) { - ResourceElement element = list.get(0); - XmlTag tag = element.getXmlTag(); - tag.getValue().setText(""); - } + String initialValue = !myResourceType.equals(ResourceType.ID) ? "value" : null; + ResourceElement resElement = manager.addValueResource(myResourceType.getName(), myResourceName, initialValue); + if (resElement != null) { + if (!(resElement instanceof Item)) { + // then it is ID + List list = manager.findValueResources(myResourceType.getName(), myResourceName); + if (list.size() == 1) { + ResourceElement element = list.get(0); + XmlTag tag = element.getXmlTag(); + tag.getValue().setText(""); } } } - else { - manager.addResourceFileAndNavigate(myResourceName, myResourceType); - } + UndoUtil.markPsiFileForUndo(myFile); + } + } + + public static class MyCreateFileResourceQuickFix implements LocalQuickFix, IntentionAction { + private final AndroidFacet myFacet; + private final ResourceType myResourceType; + private final String myResourceName; + private final PsiFile myFile; + + public MyCreateFileResourceQuickFix(@NotNull AndroidFacet facet, + @NotNull ResourceType resourceType, + @NotNull String resourceName, + @NotNull PsiFile file) { + myFacet = facet; + myResourceType = resourceType; + myResourceName = resourceName; + myFile = file; + } + + @NotNull + public String getName() { + return AndroidBundle.message("create.file.resource.quickfix.name", myResourceName, + '\'' + myResourceType.getName() + "' directory"); + } + + @NotNull + @Override + public String getText() { + return AndroidBundle.message("create.file.resource.intention.name", myResourceType, myResourceName + ".xml"); + } + + @NotNull + public String getFamilyName() { + return AndroidBundle.message("quick.fixes.family"); + } + + @Override + public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { + return true; + } + + @Override + public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + // simplified resource creating for batch mode + myFacet.getLocalResourceManager().addResourceFileAndNavigate(myResourceName, myResourceType, true); + UndoUtil.markPsiFileForUndo(myFile); + } + + @Override + public boolean startInWriteAction() { + return true; + } + + public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { + // simplified resource creating for batch mode + myFacet.getLocalResourceManager().addResourceFileAndNavigate(myResourceName, myResourceType, false); UndoUtil.markPsiFileForUndo(myFile); } } diff --git a/plugins/android/src/org/jetbrains/android/resourceManagers/LocalResourceManager.java b/plugins/android/src/org/jetbrains/android/resourceManagers/LocalResourceManager.java index 16cd938f0d43..f4067bb3593f 100644 --- a/plugins/android/src/org/jetbrains/android/resourceManagers/LocalResourceManager.java +++ b/plugins/android/src/org/jetbrains/android/resourceManagers/LocalResourceManager.java @@ -265,15 +265,12 @@ public class LocalResourceManager extends ResourceManager { // must be invoked in a write action @Nullable - public VirtualFile addResourceFileAndNavigate(@NotNull final String fileOrResourceName, @NotNull String resType) { - VirtualFile resDir = getResourceDir(); + public VirtualFile addResourceFileAndNavigate(@NotNull final String fileOrResourceName, + @NotNull ResourceType resType, + boolean chooseDirectory) { Project project = myModule.getProject(); - if (resDir == null) { - Messages - .showErrorDialog(project, AndroidBundle.message("check.resource.dir.error", myModule.getName()), CommonBundle.getErrorTitle()); - return null; - } - PsiElement[] createdElements = CreateResourceFileAction.createResourceFile(project, resDir, resType, fileOrResourceName); + PsiElement[] createdElements = + CreateResourceFileAction.createResourceFile(project, myFacet, resType, fileOrResourceName, chooseDirectory); if (createdElements.length == 0) return null; assert createdElements.length == 1; PsiElement element = createdElements[0]; diff --git a/plugins/android/src/org/jetbrains/android/uipreview/DeviceConfiguratorPanel.java b/plugins/android/src/org/jetbrains/android/uipreview/DeviceConfiguratorPanel.java index 3b09366207a2..13dfce4377ff 100644 --- a/plugins/android/src/org/jetbrains/android/uipreview/DeviceConfiguratorPanel.java +++ b/plugins/android/src/org/jetbrains/android/uipreview/DeviceConfiguratorPanel.java @@ -17,13 +17,13 @@ package org.jetbrains.android.uipreview; import com.android.ide.common.resources.configuration.*; import com.android.resources.*; -import com.intellij.ui.ListCellRendererWrapper; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.ui.VerticalFlowLayout; import com.intellij.openapi.util.Comparing; import com.intellij.ui.CollectionListModel; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.EnumComboBoxModel; +import com.intellij.ui.ListCellRendererWrapper; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBScrollPane; @@ -410,6 +410,10 @@ public abstract class DeviceConfiguratorPanel extends JPanel { add(myQualifierOptionsPanel, BorderLayout.EAST); } + public JBList getAvailableQualifiersList() { + return myAvailableQualifiersList; + } + private abstract static class MyQualifierEditor { abstract JComponent getComponent(); diff --git a/plugins/android/src/org/jetbrains/android/util/ModuleListCellRendererWrapper.java b/plugins/android/src/org/jetbrains/android/util/ModuleListCellRendererWrapper.java new file mode 100644 index 000000000000..5e965d880af9 --- /dev/null +++ b/plugins/android/src/org/jetbrains/android/util/ModuleListCellRendererWrapper.java @@ -0,0 +1,22 @@ +package org.jetbrains.android.util; + +import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleType; +import com.intellij.ui.ListCellRendererWrapper; + +import javax.swing.*; + +/** +* @author Eugene.Kudelevsky +*/ +public class ModuleListCellRendererWrapper extends ListCellRendererWrapper { + public ModuleListCellRendererWrapper(ListCellRenderer renderer) { + super(renderer); + } + + @Override + public void customize(JList list, Module module, int index, boolean selected, boolean hasFocus) { + setText(module.getName()); + setIcon(ModuleType.get(module).getNodeIcon(false)); + } +} diff --git a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java index a2979b3405a0..de12c53a9e0b 100644 --- a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java +++ b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java @@ -10,6 +10,7 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; +import org.jetbrains.android.dom.converters.ResourceReferenceConverter; import java.io.IOException; import java.util.ArrayList; @@ -349,11 +350,13 @@ public class AndroidLayoutDomTest extends AndroidDomTest { if (ranges != null) { for (Pair pair : ranges) { - actions.add(pair.getFirst().getAction()); + final IntentionAction action = pair.getFirst().getAction(); + if (action instanceof ResourceReferenceConverter.MyCreateValueResourceQuickFix) { + actions.add(action); + } } } } - assertEquals(1, actions.size()); new WriteCommandAction.Simple(getProject()) { @@ -378,19 +381,20 @@ public class AndroidLayoutDomTest extends AndroidDomTest { if (ranges != null) { for (Pair pair : ranges) { final HighlightInfo.IntentionActionDescriptor descriptor = pair.getFirst(); - final List options = descriptor.getOptions(myFixture.getFile(), myFixture.getEditor()); + if (descriptor.getAction() instanceof ResourceReferenceConverter.MyCreateValueResourceQuickFix) { + final List options = descriptor.getOptions(myFixture.getFile(), myFixture.getEditor()); - if (options != null) { - for (IntentionAction option : options) { - if (option instanceof CleanupInspectionIntention) { - actions.add(option); + if (options != null) { + for (IntentionAction option : options) { + if (option instanceof CleanupInspectionIntention) { + actions.add(option); + } } } } } } } - assertEquals(1, actions.size()); new WriteCommandAction.Simple(getProject()) { diff --git a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidValueResourcesTest.java b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidValueResourcesTest.java index add660f38b76..444486328e12 100644 --- a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidValueResourcesTest.java +++ b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidValueResourcesTest.java @@ -27,6 +27,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiReference; import com.intellij.psi.xml.XmlAttributeValue; +import org.jetbrains.android.dom.converters.ResourceReferenceConverter; import java.util.ArrayList; import java.util.List; @@ -197,11 +198,13 @@ public class AndroidValueResourcesTest extends AndroidDomTest { if (ranges != null) { for (Pair pair : ranges) { - actions.add(pair.getFirst().getAction()); + final IntentionAction action = pair.getFirst().getAction(); + if (action instanceof ResourceReferenceConverter.MyCreateValueResourceQuickFix) { + actions.add(action); + } } } } - assertEquals(1, actions.size()); new WriteCommandAction.Simple(getProject()) { From e5d1fec8f721ee28ff85b4f0e6c24dc77be22873 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Sat, 9 Jun 2012 18:38:54 +0400 Subject: [PATCH 052/172] refactoring, create android resources from java usages --- .../messages/AndroidBundle.properties | 3 +- plugins/android/src/META-INF/plugin.xml | 2 + .../AndroidGotoDeclarationHandler.java | 48 ++--- .../AndroidCreateLayoutFileAction.java | 5 +- .../android/actions/CreateResourceDialog.java | 39 +++- .../actions/CreateResourceFileAction.java | 76 ++++--- .../CreateResourceFileActionGroup.java | 15 +- .../CreateTypedResourceFileAction.java | 72 +++---- .../actions/CreateXmlResourceDialog.java | 11 +- .../ResourceReferenceConverter.java | 186 +----------------- .../inspections/AndroidQuickFixProvider.java | 74 +++++++ .../CreateFileResourceQuickFix.java | 117 +++++++++++ .../CreateValueResourceQuickFix.java | 126 ++++++++++++ .../AndroidAddStringResourceAction.java | 37 +--- .../newProject/AndroidModuleBuilder.java | 7 +- .../LocalResourceManager.java | 50 ----- .../android/util/AndroidResourceUtil.java | 130 +++++++++++- .../android/dom/AndroidLayoutDomTest.java | 43 +--- .../dom/AndroidValueResourcesTest.java | 4 +- 19 files changed, 601 insertions(+), 444 deletions(-) create mode 100644 plugins/android/src/org/jetbrains/android/inspections/AndroidQuickFixProvider.java create mode 100644 plugins/android/src/org/jetbrains/android/inspections/CreateFileResourceQuickFix.java create mode 100644 plugins/android/src/org/jetbrains/android/inspections/CreateValueResourceQuickFix.java diff --git a/plugins/android/resources/messages/AndroidBundle.properties b/plugins/android/resources/messages/AndroidBundle.properties index ebfbde4a815e..6fe79781fabd 100644 --- a/plugins/android/resources/messages/AndroidBundle.properties +++ b/plugins/android/resources/messages/AndroidBundle.properties @@ -412,4 +412,5 @@ deployment.target.settings.min.sdk.info.message=Only compatible AVDs are shown. android.compilation.warning.circular.app.dependency=Generated fields in {0}.R class in module ''{1}'' won''t be final, because of circular dependency on module ''{2}'' cannot.find.zip.align=The zipalign tool was not found in the SDK.\n\nPlease update to the latest SDK and re-export your application\nor run zipalign manually.\n\nAligning applications allows Android to use application resources\nmore efficiently. file.name.not.specified.error=File name is not specified -root.element.not.specified.error=Root element is not specified \ No newline at end of file +root.element.not.specified.error=Root element is not specified +directory.not.specified.error=Directory is not specified \ No newline at end of file diff --git a/plugins/android/src/META-INF/plugin.xml b/plugins/android/src/META-INF/plugin.xml index 3315888cb0df..4700bd2e5eec 100644 --- a/plugins/android/src/META-INF/plugin.xml +++ b/plugins/android/src/META-INF/plugin.xml @@ -219,6 +219,8 @@ + + diff --git a/plugins/android/src/org/jetbrains/android/AndroidGotoDeclarationHandler.java b/plugins/android/src/org/jetbrains/android/AndroidGotoDeclarationHandler.java index d73c45ffb5ab..9b23a4cc2c3a 100644 --- a/plugins/android/src/org/jetbrains/android/AndroidGotoDeclarationHandler.java +++ b/plugins/android/src/org/jetbrains/android/AndroidGotoDeclarationHandler.java @@ -19,7 +19,11 @@ import com.intellij.codeInsight.navigation.actions.GotoDeclarationHandler; import com.intellij.navigation.NavigationItem; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.editor.Editor; -import com.intellij.psi.*; +import com.intellij.openapi.util.Pair; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiIdentifier; +import com.intellij.psi.PsiReferenceExpression; import com.intellij.psi.meta.PsiMetaOwner; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.XmlAttributeValue; @@ -27,7 +31,6 @@ import org.jetbrains.android.dom.wrappers.FileResourceElementWrapper; import org.jetbrains.android.dom.wrappers.ValueResourceElementWrapper; import org.jetbrains.android.facet.AndroidFacet; import org.jetbrains.android.util.AndroidResourceUtil; -import org.jetbrains.android.util.AndroidUtils; import java.util.List; @@ -51,47 +54,22 @@ public class AndroidGotoDeclarationHandler implements GotoDeclarationHandler { return null; } - final String resFieldName = refExp.getReferenceName(); - if (resFieldName == null || resFieldName.length() == 0) { - return null; - } - - PsiExpression qExp = refExp.getQualifierExpression(); - if (!(qExp instanceof PsiReferenceExpression)) { - return null; - } - final PsiReferenceExpression resClassReference = (PsiReferenceExpression)qExp; - - final String resClassName = resClassReference.getReferenceName(); - if (resClassName == null || resClassName.length() == 0) { - return null; - } - - qExp = resClassReference.getQualifierExpression(); - if (!(qExp instanceof PsiReferenceExpression)) { - return null; - } - - final PsiElement resolvedElement = ((PsiReferenceExpression)qExp).resolve(); - if (!(resolvedElement instanceof PsiClass) || - !AndroidUtils.R_CLASS_NAME.equals(((PsiClass)resolvedElement).getName())) { - return null; - } - - final PsiFile containingFile = resolvedElement.getContainingFile(); - if (containingFile == null || !AndroidResourceUtil.isRJavaFile(facet, containingFile)) { + final Pair pair = AndroidResourceUtil.getReferredResourceField(facet, refExp); + if (pair == null) { return null; } + final String resClassName = pair.getFirst(); + final String resFieldName = pair.getSecond(); final List resourceList = facet.getLocalResourceManager().findResourcesByFieldName(resClassName, resFieldName); final PsiElement[] resources = resourceList.toArray(new PsiElement[resourceList.size()]); final PsiElement[] wrappedResources = new PsiElement[resources.length]; - + for (int i = 0; i < resources.length; i++) { final PsiElement resource = resources[i]; - - if (resource instanceof XmlAttributeValue && - resource instanceof PsiMetaOwner && + + if (resource instanceof XmlAttributeValue && + resource instanceof PsiMetaOwner && resource instanceof NavigationItem) { wrappedResources[i] = new ValueResourceElementWrapper((XmlAttributeValue)resource); } diff --git a/plugins/android/src/org/jetbrains/android/actions/AndroidCreateLayoutFileAction.java b/plugins/android/src/org/jetbrains/android/actions/AndroidCreateLayoutFileAction.java index 77de2e06e5b0..3e11642979a6 100644 --- a/plugins/android/src/org/jetbrains/android/actions/AndroidCreateLayoutFileAction.java +++ b/plugins/android/src/org/jetbrains/android/actions/AndroidCreateLayoutFileAction.java @@ -16,6 +16,7 @@ package org.jetbrains.android.actions; +import com.android.resources.ResourceFolderType; import com.android.resources.ResourceType; import com.intellij.CommonBundle; import com.intellij.facet.ProjectFacetManager; @@ -57,7 +58,7 @@ public class AndroidCreateLayoutFileAction extends CreateTypedResourceFileAction private String myLastRootComponentName; public AndroidCreateLayoutFileAction() { - super("Layout", "layout", "LinearLayout", false, false); + super("Layout", ResourceFolderType.LAYOUT, false, false); } @NotNull @@ -75,7 +76,7 @@ public class AndroidCreateLayoutFileAction extends CreateTypedResourceFileAction @Override protected PsiElement[] create(String newName, PsiDirectory directory) throws Exception { assert myLastRootComponentName != null; - return doCreate(newName, directory, myLastRootComponentName, false); + return doCreateAndNavigate(newName, directory, myLastRootComponentName, false); } @Override diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.java b/plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.java index 13239b7c5a48..68b7e5c6187a 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.java +++ b/plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.java @@ -73,15 +73,19 @@ public class CreateResourceDialog extends DialogWrapper { private final Map myResType2ActionMap = new HashMap(); private final DeviceConfiguratorPanel myDeviceConfiguratorPanel; private final AndroidFacet myFacet; + private final ResourceType myPredefinedResourceType; public CreateResourceDialog(@NotNull AndroidFacet facet, Collection actions, @Nullable ResourceType predefinedResourceType, @Nullable String predefinedFileName, + boolean chooseFileName, @NotNull Module module, boolean chooseModule) { super(facet.getModule().getProject()); myFacet = facet; + myPredefinedResourceType = predefinedResourceType; + myResTypeLabel.setLabelFor(myResourceTypeCombo); myResourceTypeCombo.registerUpDownHint(myFileNameField); myUpDownHint.setIcon(PlatformIcons.UP_DOWN_ARROWS); @@ -137,7 +141,7 @@ public class CreateResourceDialog extends DialogWrapper { @Override public void actionPerformed(ActionEvent e) { myDeviceConfiguratorPanel.applyEditors(); - updateRootElementCombo(); + updateRootElementTextField(); } }); @@ -153,8 +157,10 @@ public class CreateResourceDialog extends DialogWrapper { } if (predefinedFileName != null) { - myFileNameField.setVisible(false); - myFileNameLabel.setVisible(false); + if (!chooseFileName) { + myFileNameField.setVisible(false); + myFileNameLabel.setVisible(false); + } myFileNameField.setText(predefinedFileName); } @@ -183,11 +189,13 @@ public class CreateResourceDialog extends DialogWrapper { myDeviceConfiguratorPanel.updateAll(); myDeviceConfiguratorWrapper.add(myDeviceConfiguratorPanel, BorderLayout.CENTER); setOKActionEnabled(myDirectoryNameTextField.getText().length() > 0); - updateRootElementCombo(); + updateRootElementTextField(); init(); + + setTitle(AndroidBundle.message("new.resource.dialog.title")); } - private void updateRootElementCombo() { + private void updateRootElementTextField() { final CreateTypedResourceFileAction action = getSelectedAction(); if (action != null) { @@ -195,12 +203,19 @@ public class CreateResourceDialog extends DialogWrapper { myRootElementField = new TextFieldWithAutoCompletion( myFacet.getModule().getProject(), new TextFieldWithAutoCompletion.StringsCompletionProvider(allowedTagNames, null), true); myRootElementField.setEnabled(allowedTagNames.size() > 1); - myRootElementField.setText(!action.isChooseTagName() ? action.getDefaultRootTag() : ""); + myRootElementField.setText(!action.isChooseTagName() && myPredefinedResourceType != ResourceType.LAYOUT + ? action.getDefaultRootTag() + : ""); myRootElementFieldWrapper.removeAll(); myRootElementFieldWrapper.add(myRootElementField, BorderLayout.CENTER); } } + @NotNull + public String getFileName() { + return myFileNameField.getText().trim(); + } + private static boolean containsElement(@NotNull ListModel model, @NotNull Object objectToFind) { for (int i = 0, n = model.getSize(); i < n; i++) { if (objectToFind.equals(model.getElementAt(i))) { @@ -232,7 +247,10 @@ public class CreateResourceDialog extends DialogWrapper { } final String subdirName = getSubdirName(); - assert subdirName.length() > 0; + if (subdirName.length() == 0) { + Messages.showErrorDialog(myPanel, AndroidBundle.message("directory.not.specified.error"), CommonBundle.getErrorTitle()); + return; + } myValidator = createValidator(subdirName); if (myValidator == null || myValidator.checkInput(fileName) && myValidator.canClose(fileName)) { super.doOKAction(); @@ -266,7 +284,7 @@ public class CreateResourceDialog extends DialogWrapper { @Override public JComponent getPreferredFocusedComponent() { - if (myFileNameField.isVisible()) { + if (myFileNameField.getText().length() == 0) { return myFileNameField; } else if (myResourceTypeCombo.isVisible()) { @@ -275,7 +293,10 @@ public class CreateResourceDialog extends DialogWrapper { else if (myModuleCombo.isVisible()) { return myModuleCombo; } - return myDeviceConfiguratorPanel.getAvailableQualifiersList(); + else if (myRootElementFieldWrapper.isVisible()) { + return myRootElementField; + } + return myDirectoryNameTextField; } public CreateTypedResourceFileAction getSelectedAction() { diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileAction.java b/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileAction.java index ce3d080544ff..b8a3218f0e99 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileAction.java +++ b/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileAction.java @@ -30,6 +30,7 @@ import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.InputValidator; +import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -90,39 +91,48 @@ public class CreateResourceFileAction extends CreateElementActionBase { }); } - // must be invoked in a write action - public static PsiElement[] createResourceFile(final Project project, - @NotNull AndroidFacet facet, + @NotNull + public static PsiElement[] createFileResource(@NotNull AndroidFacet facet, @NotNull final ResourceType resType, @NotNull String resName, - boolean chooseDirectory) { + boolean chooseResName) { final CreateResourceFileAction action = getInstance(); - String subdirName = resType.getName(); - VirtualFile resourceDir = facet.getLocalResourceManager().getResourceDir(); - - if (chooseDirectory) { - final MyDialog dialog = new MyDialog(facet, action.mySubactions.values(), resType, resName, action, facet.getModule(), true); - dialog.setTitle(AndroidBundle.message("new.resource.dialog.title")); - dialog.show(); - if (!dialog.isOK()) { - return PsiElement.EMPTY_ARRAY; - } - subdirName = dialog.getSubdirName(); - final AndroidFacet selectedFacet = AndroidFacet.getInstance(dialog.getSelectedModule()); - LOG.assertTrue(selectedFacet != null); - resourceDir = selectedFacet.getLocalResourceManager().getResourceDir(); + final MyDialog dialog = + new MyDialog(facet, action.mySubactions.values(), resType, resName, chooseResName, action, facet.getModule(), true); + dialog.show(); + if (!dialog.isOK()) { + return PsiElement.EMPTY_ARRAY; } - if (resourceDir != null) { - final PsiDirectory psiResDir = PsiManager.getInstance(project).findDirectory(resourceDir); - if (psiResDir != null) { - CreateElementActionBase.MyInputValidator validator = action.createValidator(project, psiResDir, subdirName); - if (validator.checkInput(resName) && validator.canClose(resName)) { - return validator.getCreatedElements(); - } - } + if (chooseResName) { + resName = dialog.getFileName(); } - return PsiElement.EMPTY_ARRAY; + final String subdirName = dialog.getSubdirName(); + final AndroidFacet selectedFacet = AndroidFacet.getInstance(dialog.getSelectedModule()); + LOG.assertTrue(selectedFacet != null); + + final VirtualFile resourceDir = selectedFacet.getLocalResourceManager().getResourceDir(); + final Project project = facet.getModule().getProject(); + final PsiDirectory psiResDir = resourceDir != null ? PsiManager.getInstance(project).findDirectory(resourceDir) : null; + + if (psiResDir == null) { + Messages.showErrorDialog(project, "Cannot find resource directory for module " + selectedFacet.getModule().getName(), + CommonBundle.getErrorTitle()); + return PsiElement.EMPTY_ARRAY; + } + final String finalResName = resName; + + final PsiElement[] elements = ApplicationManager.getApplication().runWriteAction(new Computable() { + @Nullable + @Override + public PsiElement[] compute() { + MyInputValidator validator = action.createValidator(project, psiResDir, subdirName); + return validator.checkInput(finalResName) && validator.canClose(finalResName) + ? validator.getCreatedElements() + : null; + } + }); + return elements != null ? elements : PsiElement.EMPTY_ARRAY; } @NotNull @@ -131,13 +141,13 @@ public class CreateResourceFileAction extends CreateElementActionBase { final AndroidFacet facet = AndroidFacet.getInstance(directory); LOG.assertTrue(facet != null); - MyDialog dialog = new MyDialog(facet, mySubactions.values(), null, null, CreateResourceFileAction.this, facet.getModule(), false) { + final MyDialog dialog = + new MyDialog(facet, mySubactions.values(), null, null, true, CreateResourceFileAction.this, facet.getModule(), false) { @Override protected InputValidator createValidator(@NotNull String subdirName) { return CreateResourceFileAction.this.createValidator(project, directory, subdirName); } }; - dialog.setTitle(AndroidBundle.message("new.resource.dialog.title")); dialog.show(); return PsiElement.EMPTY_ARRAY; } @@ -159,8 +169,11 @@ public class CreateResourceFileAction extends CreateElementActionBase { @Override protected PsiElement[] create(String newName, PsiDirectory directory) throws Exception { CreateTypedResourceFileAction action = getActionByDir(directory); + if (action == null) { + throw new IllegalArgumentException("Incorrect directory"); + } if (myRootElement != null && myRootElement.length() > 0) { - return action.doCreate(newName, directory, myRootElement, false); + return action.doCreateAndNavigate(newName, directory, myRootElement, false); } return action.create(newName, directory); } @@ -204,10 +217,11 @@ public class CreateResourceFileAction extends CreateElementActionBase { Collection actions, @Nullable ResourceType predefinedResourceType, @Nullable String predefinedFileName, + boolean chooseFileName, @NotNull CreateResourceFileAction action, @NotNull Module module, boolean chooseModule) { - super(facet, actions, predefinedResourceType, predefinedFileName, module, chooseModule); + super(facet, actions, predefinedResourceType, predefinedFileName, chooseFileName, module, chooseModule); myAction = action; } diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileActionGroup.java b/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileActionGroup.java index 5024481ba13b..22c21899cf1a 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileActionGroup.java +++ b/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileActionGroup.java @@ -16,6 +16,7 @@ package org.jetbrains.android.actions; +import com.android.resources.ResourceFolderType; import com.intellij.openapi.actionSystem.DefaultActionGroup; import org.jetbrains.android.dom.animation.AndroidAnimationUtils; import org.jetbrains.android.dom.animator.AndroidAnimatorUtil; @@ -40,7 +41,7 @@ public class CreateResourceFileActionGroup extends DefaultActionGroup { CreateResourceFileAction a = new CreateResourceFileAction(); a.add(new AndroidCreateLayoutFileAction()); - a.add(new CreateTypedResourceFileAction("XML", "xml", "PreferenceScreen", false, true) { + a.add(new CreateTypedResourceFileAction("XML", ResourceFolderType.XML, false, true) { @NotNull @Override public List getAllowedTagNames(@NotNull AndroidFacet facet) { @@ -48,7 +49,7 @@ public class CreateResourceFileActionGroup extends DefaultActionGroup { } }); - a.add(new CreateTypedResourceFileAction("Drawable", "drawable", "selector", false, true) { + a.add(new CreateTypedResourceFileAction("Drawable", ResourceFolderType.DRAWABLE, false, true) { @NotNull @Override public List getAllowedTagNames(@NotNull AndroidFacet facet) { @@ -56,11 +57,11 @@ public class CreateResourceFileActionGroup extends DefaultActionGroup { } }); - a.add(new CreateTypedResourceFileAction("Color", "color", "selector", false, false)); - a.add(new CreateTypedResourceFileAction("Values", "values", "resources", true, false)); - a.add(new CreateTypedResourceFileAction("Menu", "menu", "menu", false, false)); + a.add(new CreateTypedResourceFileAction("Color", ResourceFolderType.COLOR, false, false)); + a.add(new CreateTypedResourceFileAction("Values", ResourceFolderType.VALUES, true, false)); + a.add(new CreateTypedResourceFileAction("Menu", ResourceFolderType.MENU, false, false)); - a.add(new CreateTypedResourceFileAction("Animation", "anim", "set", false, true) { + a.add(new CreateTypedResourceFileAction("Animation", ResourceFolderType.ANIM, false, true) { @NotNull @Override public List getAllowedTagNames(@NotNull AndroidFacet facet) { @@ -68,7 +69,7 @@ public class CreateResourceFileActionGroup extends DefaultActionGroup { } }); - a.add(new CreateTypedResourceFileAction("Animator", "animator", "set", false, true) { + a.add(new CreateTypedResourceFileAction("Animator", ResourceFolderType.ANIMATOR, false, true) { @NotNull @Override public List getAllowedTagNames(@NotNull AndroidFacet facet) { diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateTypedResourceFileAction.java b/plugins/android/src/org/jetbrains/android/actions/CreateTypedResourceFileAction.java index 5c32c6de9de6..f59644879537 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateTypedResourceFileAction.java +++ b/plugins/android/src/org/jetbrains/android/actions/CreateTypedResourceFileAction.java @@ -16,11 +16,9 @@ package org.jetbrains.android.actions; +import com.android.resources.ResourceFolderType; import com.intellij.CommonBundle; import com.intellij.ide.actions.CreateElementActionBase; -import com.intellij.ide.fileTemplates.FileTemplate; -import com.intellij.ide.fileTemplates.FileTemplateManager; -import com.intellij.ide.fileTemplates.FileTemplateUtil; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.LangDataKeys; import com.intellij.openapi.application.ApplicationManager; @@ -38,7 +36,6 @@ import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; import com.intellij.util.PsiNavigateUtil; import com.intellij.xml.refactoring.XmlTagInplaceRenamer; -import org.jetbrains.android.AndroidFileTemplateProvider; import org.jetbrains.android.facet.AndroidFacet; import org.jetbrains.android.util.AndroidBundle; import org.jetbrains.android.util.AndroidResourceUtil; @@ -48,36 +45,33 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Properties; /** * @author Eugene.Kudelevsky */ public class CreateTypedResourceFileAction extends CreateElementActionBase { - static final String ROOT_TAG_PROPERTY = "ROOT_TAG"; - private final String myResourceType; + private final ResourceFolderType myResourceType; private final String myResourcePresentableName; protected final String myDefaultRootTag; private final boolean myValuesResourceFile; private final boolean myChooseTagName; public CreateTypedResourceFileAction(@NotNull String resourcePresentableName, - @NotNull String resourceType, - @NotNull String defaultRootTag, + @NotNull ResourceFolderType resourceFolderType, boolean valuesResourceFile, boolean chooseTagName) { super(AndroidBundle.message("new.typed.resource.action.title", resourcePresentableName), AndroidBundle.message("new.typed.resource.action.description", resourcePresentableName), StdFileTypes.XML.getIcon()); - myResourceType = resourceType; + myResourceType = resourceFolderType; myResourcePresentableName = resourcePresentableName; - myDefaultRootTag = defaultRootTag; + myDefaultRootTag = getDefaultRootTabByResourceType(resourceFolderType); myValuesResourceFile = valuesResourceFile; myChooseTagName = chooseTagName; } public String getResourceType() { - return myResourceType; + return myResourceType.getName(); } @NotNull @@ -93,20 +87,12 @@ public class CreateTypedResourceFileAction extends CreateElementActionBase { @NotNull @Override protected PsiElement[] create(String newName, PsiDirectory directory) throws Exception { - return doCreate(newName, directory, myDefaultRootTag, myChooseTagName); + return doCreateAndNavigate(newName, directory, myDefaultRootTag, myChooseTagName); } - PsiElement[] doCreate(String newName, PsiDirectory directory, String rootTagName, boolean chooseTagName) throws Exception { - FileTemplateManager manager = FileTemplateManager.getInstance(); - String templateName = getTemplateName(); - FileTemplate template = manager.getJ2eeTemplate(templateName); - Properties properties = new Properties(); - if (!myValuesResourceFile) { - properties.setProperty(ROOT_TAG_PROPERTY, rootTagName); - } - PsiElement createdElement = FileTemplateUtil.createFromTemplate(template, newName, properties, directory); - assert createdElement instanceof XmlFile; - final XmlFile file = (XmlFile)createdElement; + PsiElement[] doCreateAndNavigate(String newName, PsiDirectory directory, String rootTagName, boolean chooseTagName) throws Exception { + final XmlFile file = AndroidResourceUtil + .createFileResource(newName, directory, rootTagName, myResourceType.getName(), myValuesResourceFile); doNavigate(file); if (chooseTagName) { @@ -124,26 +110,16 @@ public class CreateTypedResourceFileAction extends CreateElementActionBase { } } } - return new PsiElement[]{createdElement}; + return new PsiElement[]{file}; } protected void doNavigate(XmlFile file) { PsiNavigateUtil.navigate(file); } - private String getTemplateName() { - if (myValuesResourceFile) { - return AndroidFileTemplateProvider.VALUE_RESOURCE_FILE_TEMPLATE; - } - if ("layout".equals(myResourceType)) { - return AndroidFileTemplateProvider.LAYOUT_RESOURCE_FILE_TEMPLATE; - } - return AndroidFileTemplateProvider.RESOURCE_FILE_TEMPLATE; - } - @Override protected boolean isAvailable(DataContext context) { - return super.isAvailable(context) && doIsAvailable(context, myResourceType); + return super.isAvailable(context) && doIsAvailable(context, myResourceType.getName()); } public boolean isChooseTagName() { @@ -202,4 +178,28 @@ public class CreateTypedResourceFileAction extends CreateElementActionBase { public String toString() { return myResourcePresentableName; } + + @NotNull + public static String getDefaultRootTabByResourceType(@NotNull ResourceFolderType resourceType) { + switch (resourceType) { + case XML: + return "PreferenceScreen"; + case DRAWABLE: + return "selector"; + case COLOR: + return "selector"; + case VALUES: + return "resources"; + case MENU: + return "menu"; + case ANIM: + return "set"; + case ANIMATOR: + return "set"; + case LAYOUT: + return "LinearLayout"; + default: + } + throw new IllegalArgumentException("Incorrect resource folder type"); + } } diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java b/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java index ab2e43d7f575..227d9075738b 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java +++ b/plugins/android/src/org/jetbrains/android/actions/CreateXmlResourceDialog.java @@ -83,13 +83,16 @@ public class CreateXmlResourceDialog extends DialogWrapper { public CreateXmlResourceDialog(@NotNull Module module, @NotNull ResourceType resourceType, @Nullable String predefinedName, - @Nullable String predefinedValue) { + @Nullable String predefinedValue, + boolean chooseName) { super(module.getProject()); myResourceType = resourceType; if (predefinedName != null && predefinedName.length() > 0) { - myNameLabel.setVisible(false); - myNameField.setVisible(false); + if (!chooseName) { + myNameLabel.setVisible(false); + myNameField.setVisible(false); + } myNameField.setText(predefinedName); } @@ -390,7 +393,7 @@ public class CreateXmlResourceDialog extends DialogWrapper { @Override public JComponent getPreferredFocusedComponent() { - return myNameField.isVisible() ? myNameField : myValueField; + return myNameField.getText().length() == 0 ? myNameField : myValueField; } @Override diff --git a/plugins/android/src/org/jetbrains/android/dom/converters/ResourceReferenceConverter.java b/plugins/android/src/org/jetbrains/android/dom/converters/ResourceReferenceConverter.java index 2c97811d6614..af899538c7a6 100644 --- a/plugins/android/src/org/jetbrains/android/dom/converters/ResourceReferenceConverter.java +++ b/plugins/android/src/org/jetbrains/android/dom/converters/ResourceReferenceConverter.java @@ -15,38 +15,26 @@ */ package org.jetbrains.android.dom.converters; -import com.android.AndroidConstants; import com.android.resources.ResourceType; -import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInspection.LocalQuickFix; -import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.command.undo.UndoUtil; import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.editor.Editor; import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; import com.intellij.psi.PsiReference; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlElement; import com.intellij.psi.xml.XmlTag; -import com.intellij.util.IncorrectOperationException; import com.intellij.util.xml.*; -import org.jetbrains.android.actions.CreateXmlResourceDialog; import org.jetbrains.android.dom.AdditionalConverter; import org.jetbrains.android.dom.AndroidResourceType; -import org.jetbrains.android.dom.resources.Item; -import org.jetbrains.android.dom.resources.ResourceElement; import org.jetbrains.android.dom.resources.ResourceValue; import org.jetbrains.android.facet.AndroidFacet; +import org.jetbrains.android.inspections.CreateFileResourceQuickFix; +import org.jetbrains.android.inspections.CreateValueResourceQuickFix; import org.jetbrains.android.resourceManagers.LocalResourceManager; import org.jetbrains.android.resourceManagers.ResourceManager; -import org.jetbrains.android.util.AndroidBundle; import org.jetbrains.android.util.AndroidCommonUtils; import org.jetbrains.android.util.AndroidResourceUtil; import org.jetbrains.annotations.NonNls; @@ -61,11 +49,6 @@ import static org.jetbrains.android.util.AndroidUtils.SYSTEM_RESOURCE_PACKAGE; * @author yole */ public class ResourceReferenceConverter extends ResolvingConverter implements CustomReferenceConverter { - private static final Set XML_FILE_RESOURCE_TYPES = EnumSet.of(ResourceType.ANIM, ResourceType.ANIMATOR, - ResourceType.INTERPOLATOR, ResourceType.LAYOUT, - ResourceType.MENU, ResourceType.XML, ResourceType.COLOR, - ResourceType.DRAWABLE); - private final List myResourceTypes; private ResolvingConverter myAdditionalConverter; private boolean myAdditionalConverterSoft = false; @@ -313,10 +296,10 @@ public class ResourceReferenceConverter extends ResolvingConverter fixes = new ArrayList(); if (AndroidResourceUtil.VALUE_RESOURCE_TYPES.contains(resType)) { - fixes.add(new MyCreateValueResourceQuickFix(facet, resType, resourceName, context.getFile())); + fixes.add(new CreateValueResourceQuickFix(facet, resType, resourceName, context.getFile(), false)); } - if (XML_FILE_RESOURCE_TYPES.contains(resType)) { - fixes.add(new MyCreateFileResourceQuickFix(facet, resType, resourceName, context.getFile())); + if (AndroidResourceUtil.XML_FILE_RESOURCE_TYPES.contains(resType)) { + fixes.add(new CreateFileResourceQuickFix(facet, resType, resourceName, context.getFile(), false)); } return fixes.toArray(new LocalQuickFix[fixes.size()]); } @@ -350,163 +333,4 @@ public class ResourceReferenceConverter extends ResolvingConverter list = manager.findValueResources(myResourceType.getName(), myResourceName); - if (list.size() == 1) { - ResourceElement element = list.get(0); - XmlTag tag = element.getXmlTag(); - tag.getValue().setText(""); - } - } - } - UndoUtil.markPsiFileForUndo(myFile); - } - } - - public static class MyCreateFileResourceQuickFix implements LocalQuickFix, IntentionAction { - private final AndroidFacet myFacet; - private final ResourceType myResourceType; - private final String myResourceName; - private final PsiFile myFile; - - public MyCreateFileResourceQuickFix(@NotNull AndroidFacet facet, - @NotNull ResourceType resourceType, - @NotNull String resourceName, - @NotNull PsiFile file) { - myFacet = facet; - myResourceType = resourceType; - myResourceName = resourceName; - myFile = file; - } - - @NotNull - public String getName() { - return AndroidBundle.message("create.file.resource.quickfix.name", myResourceName, - '\'' + myResourceType.getName() + "' directory"); - } - - @NotNull - @Override - public String getText() { - return AndroidBundle.message("create.file.resource.intention.name", myResourceType, myResourceName + ".xml"); - } - - @NotNull - public String getFamilyName() { - return AndroidBundle.message("quick.fixes.family"); - } - - @Override - public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { - return true; - } - - @Override - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { - // simplified resource creating for batch mode - myFacet.getLocalResourceManager().addResourceFileAndNavigate(myResourceName, myResourceType, true); - UndoUtil.markPsiFileForUndo(myFile); - } - - @Override - public boolean startInWriteAction() { - return true; - } - - public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { - // simplified resource creating for batch mode - myFacet.getLocalResourceManager().addResourceFileAndNavigate(myResourceName, myResourceType, false); - UndoUtil.markPsiFileForUndo(myFile); - } - } } diff --git a/plugins/android/src/org/jetbrains/android/inspections/AndroidQuickFixProvider.java b/plugins/android/src/org/jetbrains/android/inspections/AndroidQuickFixProvider.java new file mode 100644 index 000000000000..39ec81858ca8 --- /dev/null +++ b/plugins/android/src/org/jetbrains/android/inspections/AndroidQuickFixProvider.java @@ -0,0 +1,74 @@ +package org.jetbrains.android.inspections; + +import com.android.resources.ResourceType; +import com.intellij.codeInsight.daemon.QuickFixActionRegistrar; +import com.intellij.codeInsight.quickfix.UnresolvedReferenceQuickFixProvider; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.util.Pair; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiReferenceExpression; +import org.jetbrains.android.dom.manifest.Manifest; +import org.jetbrains.android.facet.AndroidFacet; +import org.jetbrains.android.util.AndroidResourceUtil; +import org.jetbrains.annotations.NotNull; + +/** + * @author Eugene.Kudelevsky + */ +public class AndroidQuickFixProvider extends UnresolvedReferenceQuickFixProvider { + @Override + public void registerFixes(PsiReferenceExpression exp, QuickFixActionRegistrar registrar) { + final Module contextModule = ModuleUtil.findModuleForPsiElement(exp); + if (contextModule == null) { + return; + } + + final AndroidFacet facet = AndroidFacet.getInstance(contextModule); + if (facet == null) { + return; + } + + final Manifest manifest = facet.getManifest(); + if (manifest == null) { + return; + } + + final String aPackage = manifest.getPackage().getValue(); + if (aPackage == null) { + return; + } + + final PsiFile contextFile = exp.getContainingFile(); + if (contextFile == null) { + return; + } + + final Pair pair = AndroidResourceUtil.getReferredResourceField(facet, exp); + if (pair == null) { + return; + } + final String resClassName = pair.getFirst(); + final String resFieldName = pair.getSecond(); + + final ResourceType resourceType = ResourceType.getEnum(resClassName); + if (resourceType == ResourceType.STYLEABLE || resourceType == ResourceType.ATTR) { + // todo: support + return; + } + + if (AndroidResourceUtil.VALUE_RESOURCE_TYPES.contains(resourceType)) { + registrar + .register(new CreateValueResourceQuickFix(facet, resourceType, resFieldName, contextFile, true)); + } + if (AndroidResourceUtil.XML_FILE_RESOURCE_TYPES.contains(resourceType)) { + registrar.register(new CreateFileResourceQuickFix(facet, resourceType, resFieldName, contextFile, true)); + } + } + + @NotNull + @Override + public Class getReferenceClass() { + return PsiReferenceExpression.class; + } +} diff --git a/plugins/android/src/org/jetbrains/android/inspections/CreateFileResourceQuickFix.java b/plugins/android/src/org/jetbrains/android/inspections/CreateFileResourceQuickFix.java new file mode 100644 index 000000000000..03b559ddf87f --- /dev/null +++ b/plugins/android/src/org/jetbrains/android/inspections/CreateFileResourceQuickFix.java @@ -0,0 +1,117 @@ +package org.jetbrains.android.inspections; + +import com.android.resources.ResourceFolderType; +import com.android.resources.ResourceType; +import com.intellij.codeInsight.intention.HighPriorityAction; +import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.codeInspection.LocalQuickFix; +import com.intellij.codeInspection.ProblemDescriptor; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.command.undo.UndoUtil; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Computable; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiDirectory; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiManager; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.android.actions.CreateResourceFileAction; +import org.jetbrains.android.actions.CreateTypedResourceFileAction; +import org.jetbrains.android.facet.AndroidFacet; +import org.jetbrains.android.util.AndroidBundle; +import org.jetbrains.android.util.AndroidResourceUtil; +import org.jetbrains.annotations.NotNull; + +/** +* @author Eugene.Kudelevsky +*/ +public class CreateFileResourceQuickFix implements LocalQuickFix, IntentionAction, HighPriorityAction { + private static final Logger LOG = Logger.getInstance("#org.jetbrains.android.inspections.CreateFileResourceQuickFix"); + + private final AndroidFacet myFacet; + private final ResourceType myResourceType; + private final String myResourceName; + private final PsiFile myFile; + private final boolean myChooseResName; + + public CreateFileResourceQuickFix(@NotNull AndroidFacet facet, + @NotNull ResourceType resourceType, + @NotNull String resourceName, + @NotNull PsiFile file, + boolean chooseResName) { + myFacet = facet; + myResourceType = resourceType; + myResourceName = resourceName; + myFile = file; + myChooseResName = chooseResName; + } + + @NotNull + public String getName() { + return AndroidBundle.message("create.file.resource.quickfix.name", myResourceName, + '\'' + myResourceType.getName() + "' directory"); + } + + @NotNull + @Override + public String getText() { + return AndroidBundle.message("create.file.resource.intention.name", myResourceType, myResourceName + ".xml"); + } + + @NotNull + public String getFamilyName() { + return AndroidBundle.message("quick.fixes.family"); + } + + @Override + public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { + return true; + } + + @Override + public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + final PsiElement[] createdElements = + CreateResourceFileAction.createFileResource(myFacet, myResourceType, myResourceName + ".xml", myChooseResName); + if (createdElements.length > 0) { + UndoUtil.markPsiFileForUndo(myFile); + } + } + + @Override + public boolean startInWriteAction() { + return false; + } + + public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { + final VirtualFile resourceDir = myFacet.getLocalResourceManager().getResourceDir(); + if (resourceDir == null) { + return; + } + final PsiDirectory psiResDir = PsiManager.getInstance(project).findDirectory(resourceDir); + if (psiResDir == null) { + return; + } + final String resDirName = myResourceType.getName(); + PsiDirectory resSubdir = psiResDir.findSubdirectory(resDirName); + + if (resSubdir == null) { + resSubdir = ApplicationManager.getApplication().runWriteAction(new Computable() { + public PsiDirectory compute() { + return psiResDir.createSubdirectory(resDirName); + } + }); + } + + try { + AndroidResourceUtil.createFileResource(myResourceName, resSubdir, CreateTypedResourceFileAction.getDefaultRootTabByResourceType( + ResourceFolderType.getFolderType(resDirName)), resDirName, false); + UndoUtil.markPsiFileForUndo(myFile); + } + catch (Exception e) { + LOG.error(e); + } + } +} diff --git a/plugins/android/src/org/jetbrains/android/inspections/CreateValueResourceQuickFix.java b/plugins/android/src/org/jetbrains/android/inspections/CreateValueResourceQuickFix.java new file mode 100644 index 000000000000..2a4b02d71415 --- /dev/null +++ b/plugins/android/src/org/jetbrains/android/inspections/CreateValueResourceQuickFix.java @@ -0,0 +1,126 @@ +package org.jetbrains.android.inspections; + +import com.android.AndroidConstants; +import com.android.resources.ResourceType; +import com.intellij.codeInsight.intention.HighPriorityAction; +import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.codeInspection.LocalQuickFix; +import com.intellij.codeInspection.ProblemDescriptor; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.command.undo.UndoUtil; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.psi.PsiDocumentManager; +import com.intellij.psi.PsiFile; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.android.actions.CreateXmlResourceDialog; +import org.jetbrains.android.facet.AndroidFacet; +import org.jetbrains.android.util.AndroidBundle; +import org.jetbrains.android.util.AndroidResourceUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Collections; +import java.util.List; + +/** +* @author Eugene.Kudelevsky +*/ +public class CreateValueResourceQuickFix implements LocalQuickFix, IntentionAction, HighPriorityAction { + private final AndroidFacet myFacet; + private final ResourceType myResourceType; + private final String myResourceName; + private final PsiFile myFile; + private final boolean myChooseName; + + public CreateValueResourceQuickFix(@NotNull AndroidFacet facet, + @NotNull ResourceType resourceType, + @NotNull String resourceName, + @NotNull PsiFile file, + boolean chooseName) { + myFacet = facet; + myResourceType = resourceType; + myResourceName = resourceName; + myFile = file; + myChooseName = chooseName; + } + + @NotNull + public String getName() { + return AndroidBundle.message("create.value.resource.quickfix.name", myResourceName, + AndroidResourceUtil.getDefaultResourceFileName(myResourceType.getName())); + } + + @NotNull + @Override + public String getText() { + return AndroidBundle.message("create.value.resource.intention.name", myResourceType, myResourceName); + } + + @NotNull + public String getFamilyName() { + return AndroidBundle.message("quick.fixes.family"); + } + + @Override + public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { + return true; + } + + @Override + public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + doInvoke(); + } + + protected boolean doInvoke() { + if (ApplicationManager.getApplication().isUnitTestMode()) { + final String fileName = AndroidResourceUtil.getDefaultResourceFileName(myResourceType.getName()); + assert fileName != null; + + if (!AndroidResourceUtil.createValueResource(myFacet.getModule(), myResourceName, myResourceType, fileName, + Collections.singletonList(AndroidConstants.FD_RES_VALUES), "a")) { + return false; + } + } + else { + final CreateXmlResourceDialog dialog = new CreateXmlResourceDialog(myFacet.getModule(), myResourceType, myResourceName, null, + myChooseName); + dialog.setTitle("New " + StringUtil.capitalize(myResourceType.getDisplayName()) + " Value Resource"); + dialog.show(); + + if (!dialog.isOK()) { + return false; + } + + final Module moduleToPlaceResource = dialog.getModule(); + if (moduleToPlaceResource == null) { + return false; + } + final String fileName = dialog.getFileName(); + final List dirNames = dialog.getDirNames(); + final String resValue = dialog.getValue(); + final String resName = dialog.getResourceName(); + if (!AndroidResourceUtil.createValueResource(moduleToPlaceResource, resName, myResourceType, fileName, dirNames, resValue)) { + return false; + } + } + PsiDocumentManager.getInstance(myFile.getProject()).commitAllDocuments(); + UndoUtil.markPsiFileForUndo(myFile); + ApplicationManager.getApplication().invokeLater(new Runnable() { + public void run() { + ApplicationManager.getApplication().saveAll(); + } + }); + return true; + } + + @Override + public boolean startInWriteAction() { + return false; + } + + public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { + // todo: implement local fix + } +} diff --git a/plugins/android/src/org/jetbrains/android/intentions/AndroidAddStringResourceAction.java b/plugins/android/src/org/jetbrains/android/intentions/AndroidAddStringResourceAction.java index 007223e7ce29..bb62b105fa65 100644 --- a/plugins/android/src/org/jetbrains/android/intentions/AndroidAddStringResourceAction.java +++ b/plugins/android/src/org/jetbrains/android/intentions/AndroidAddStringResourceAction.java @@ -35,10 +35,8 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.TextRange; import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; -import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.psi.util.PsiUtil; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlAttributeValue; import com.intellij.psi.xml.XmlFile; @@ -180,7 +178,7 @@ public class AndroidAddStringResourceAction extends AbstractIntentionAction impl } if (resName == null) { - final CreateXmlResourceDialog dialog = new CreateXmlResourceDialog(facet.getModule(), ResourceType.STRING, null, value); + final CreateXmlResourceDialog dialog = new CreateXmlResourceDialog(facet.getModule(), ResourceType.STRING, null, value, false); dialog.setTitle("Extract String Resource"); dialog.show(); @@ -244,7 +242,7 @@ public class AndroidAddStringResourceAction extends AbstractIntentionAction impl ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { - createStubResourceField(module, aPackage, resType, rJavaFieldName); + AndroidResourceUtil.createStubResourceField(module, aPackage, resType, rJavaFieldName); } }); @@ -292,37 +290,6 @@ public class AndroidAddStringResourceAction extends AbstractIntentionAction impl }); } - private static void createStubResourceField(final Module module, - final String aPackage, - final String resType, - final String fieldName) { - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - final Project project = module.getProject(); - final PsiClass[] classes = - JavaPsiFacade.getInstance(project).findClasses(aPackage + ".R", GlobalSearchScope.moduleScope(module)); - if (classes.length == 1) { - final PsiClass aClass = classes[0]; - final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); - - PsiClass resTypeClass = aClass.findInnerClassByName(resType, false); - - if (resTypeClass == null) { - resTypeClass = (PsiClass)aClass.add(factory.createClass(resType)); - } - else if (resTypeClass.findFieldByName(fieldName, false) != null) { - return; - } - final PsiField psiField = (PsiField)resTypeClass.add(factory.createField(fieldName, PsiType.INT)); - PsiUtil.setModifierProperty(psiField, PsiModifier.PUBLIC, true); - PsiUtil.setModifierProperty(psiField, PsiModifier.STATIC, true); - PsiUtil.setModifierProperty(psiField, PsiModifier.FINAL, true); - } - } - }); - } - @Nullable private static String getPackage(@NotNull AndroidFacet facet) { Manifest manifest = facet.getManifest(); diff --git a/plugins/android/src/org/jetbrains/android/newProject/AndroidModuleBuilder.java b/plugins/android/src/org/jetbrains/android/newProject/AndroidModuleBuilder.java index 9be9195012cf..7f2cdc9a7183 100644 --- a/plugins/android/src/org/jetbrains/android/newProject/AndroidModuleBuilder.java +++ b/plugins/android/src/org/jetbrains/android/newProject/AndroidModuleBuilder.java @@ -17,6 +17,7 @@ package org.jetbrains.android.newProject; import com.android.AndroidConstants; +import com.android.resources.ResourceType; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.SdkConstants; import com.intellij.CommonBundle; @@ -78,6 +79,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Properties; @@ -425,7 +427,10 @@ public class AndroidModuleBuilder extends JavaModuleBuilder { final String normalizedAppName = AndroidResourceUtil.normalizeXmlResourceValue(myApplicationName.replace("\\", "\\\\")); if (appNameResElement == null) { - manager.addValueResource("string", appNameResource, normalizedAppName); + final String fileName = AndroidResourceUtil.getDefaultResourceFileName(ResourceType.STRING.getName()); + assert fileName != null; + AndroidResourceUtil.createValueResource(facet.getModule(), appNameResource, ResourceType.STRING, fileName, Collections + .singletonList(AndroidConstants.FD_RES_VALUES), normalizedAppName); } else { appNameResElement.setStringValue(normalizedAppName); diff --git a/plugins/android/src/org/jetbrains/android/resourceManagers/LocalResourceManager.java b/plugins/android/src/org/jetbrains/android/resourceManagers/LocalResourceManager.java index f4067bb3593f..28159de08edd 100644 --- a/plugins/android/src/org/jetbrains/android/resourceManagers/LocalResourceManager.java +++ b/plugins/android/src/org/jetbrains/android/resourceManagers/LocalResourceManager.java @@ -22,10 +22,8 @@ import com.intellij.CommonBundle; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Pair; -import com.intellij.openapi.vfs.ReadonlyStatusHandler; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; @@ -33,13 +31,11 @@ import com.intellij.psi.PsiField; import com.intellij.psi.PsiFile; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.xml.XmlFile; -import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.HashMap; import com.intellij.util.containers.HashSet; import com.intellij.util.indexing.FileBasedIndex; import org.jetbrains.android.AndroidFileTemplateProvider; import org.jetbrains.android.AndroidValueResourcesIndex; -import org.jetbrains.android.actions.CreateResourceFileAction; import org.jetbrains.android.dom.attrs.AttributeDefinitions; import org.jetbrains.android.dom.resources.Attr; import org.jetbrains.android.dom.resources.DeclareStyleable; @@ -57,8 +53,6 @@ import org.jetbrains.annotations.Nullable; import java.io.IOException; import java.util.*; -import static org.jetbrains.android.util.AndroidUtils.loadDomElement; - /** * @author Eugene.Kudelevsky */ @@ -263,50 +257,6 @@ public class LocalResourceManager extends ResourceManager { return result; } - // must be invoked in a write action - @Nullable - public VirtualFile addResourceFileAndNavigate(@NotNull final String fileOrResourceName, - @NotNull ResourceType resType, - boolean chooseDirectory) { - Project project = myModule.getProject(); - PsiElement[] createdElements = - CreateResourceFileAction.createResourceFile(project, myFacet, resType, fileOrResourceName, chooseDirectory); - if (createdElements.length == 0) return null; - assert createdElements.length == 1; - PsiElement element = createdElements[0]; - assert element instanceof PsiFile; - return ((PsiFile)element).getVirtualFile(); - } - - // must be invoked in a write action - @Nullable - public ResourceElement addValueResource(@NotNull final String type, @NotNull final String name, @Nullable final String value) { - String resourceFileName = AndroidResourceUtil.getDefaultResourceFileName(type); - if (resourceFileName == null) { - throw new IllegalArgumentException("Incorrect resource type"); - } - VirtualFile resFile = findOrCreateResourceFile(resourceFileName); - if (resFile == null || - !ReadonlyStatusHandler.ensureFilesWritable(myModule.getProject(), resFile)) { - return null; - } - final Resources resources = loadDomElement(myModule, resFile, Resources.class); - if (resources == null) { - if (ApplicationManager.getApplication().isUnitTestMode()) { - throw new IncorrectOperationException("invalid strings.xml"); - } - Messages.showErrorDialog(myModule.getProject(), AndroidBundle.message("not.resource.file.error", resourceFileName), - CommonBundle.getErrorTitle()); - return null; - } - ResourceElement element = AndroidResourceUtil.addValueResource(type, resources); - element.getName().setValue(name); - if (value != null) { - element.setStringValue(value); - } - return element; - } - @Nullable private VirtualFile findOrCreateChildDir(@NotNull final VirtualFile dir, @NotNull final String name) { try { diff --git a/plugins/android/src/org/jetbrains/android/util/AndroidResourceUtil.java b/plugins/android/src/org/jetbrains/android/util/AndroidResourceUtil.java index dcbdc39a17a1..0fdc4a277520 100644 --- a/plugins/android/src/org/jetbrains/android/util/AndroidResourceUtil.java +++ b/plugins/android/src/org/jetbrains/android/util/AndroidResourceUtil.java @@ -21,6 +21,9 @@ import com.android.resources.ResourceType; import com.android.sdklib.SdkConstants; import com.intellij.CommonBundle; import com.intellij.ide.actions.CreateElementActionBase; +import com.intellij.ide.fileTemplates.FileTemplate; +import com.intellij.ide.fileTemplates.FileTemplateManager; +import com.intellij.ide.fileTemplates.FileTemplateUtil; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; @@ -30,13 +33,17 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ModulePackageIndex; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.ReadonlyStatusHandler; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; +import com.intellij.psi.search.GlobalSearchScope; +import com.intellij.psi.util.PsiUtil; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlAttributeValue; +import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; import com.intellij.util.ArrayUtil; import com.intellij.util.IncorrectOperationException; @@ -68,6 +75,11 @@ public class AndroidResourceUtil { ResourceType.ID, ResourceType.BOOL, ResourceType.INTEGER); public static final Set REFERRABLE_RESOURCE_TYPES = EnumSet.noneOf(ResourceType.class); + public static final Set XML_FILE_RESOURCE_TYPES = EnumSet.of(ResourceType.ANIM, ResourceType.ANIMATOR, + ResourceType.INTERPOLATOR, ResourceType.LAYOUT, + ResourceType.MENU, ResourceType.XML, ResourceType.COLOR, + ResourceType.DRAWABLE); + static final String ROOT_TAG_PROPERTY = "ROOT_TAG"; private AndroidResourceUtil() { } @@ -606,11 +618,11 @@ public class AndroidResourceUtil { } private static boolean addValueResource(@NotNull AndroidFacet facet, - @NotNull String resourceName, - @NotNull ResourceType resourceType, + @NotNull final String resourceName, + @NotNull final ResourceType resourceType, @NotNull String fileName, @NotNull List dirNames, - @NotNull String value) throws Exception { + @NotNull final String value) throws Exception { if (dirNames.size() == 0) { return false; } @@ -638,14 +650,19 @@ public class AndroidResourceUtil { resourcesElements[i] = resources; } - for (Resources resources : resourcesElements) { - final ResourceElement element = addValueResource(resourceType.getName(), resources); - element.getName().setValue(resourceName); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override + public void run() { + for (Resources resources : resourcesElements) { + final ResourceElement element = addValueResource(resourceType.getName(), resources); + element.getName().setValue(resourceName); - if (value.length() > 0) { - element.setStringValue(value); + if (value.length() > 0) { + element.setStringValue(value); + } + } } - } + }); return true; } @@ -691,4 +708,99 @@ public class AndroidResourceUtil { Messages.showErrorDialog(project, message, CommonBundle.getErrorTitle()); } } + + @Nullable + public static Pair getReferredResourceField(@NotNull AndroidFacet facet, @NotNull PsiReferenceExpression exp) { + final String resFieldName = exp.getReferenceName(); + if (resFieldName == null || resFieldName.length() == 0) { + return null; + } + + PsiExpression qExp = exp.getQualifierExpression(); + if (!(qExp instanceof PsiReferenceExpression)) { + return null; + } + final PsiReferenceExpression resClassReference = (PsiReferenceExpression)qExp; + + final String resClassName = resClassReference.getReferenceName(); + if (resClassName == null || resClassName.length() == 0) { + return null; + } + + qExp = resClassReference.getQualifierExpression(); + if (!(qExp instanceof PsiReferenceExpression)) { + return null; + } + + final PsiElement resolvedElement = ((PsiReferenceExpression)qExp).resolve(); + if (!(resolvedElement instanceof PsiClass) || + !AndroidUtils.R_CLASS_NAME.equals(((PsiClass)resolvedElement).getName())) { + return null; + } + + final PsiFile containingFile = resolvedElement.getContainingFile(); + if (containingFile == null || !isRJavaFile(facet, containingFile)) { + return null; + } + return new Pair(resClassName, resFieldName); + } + + public static void createStubResourceField(@NotNull final Module module, + @NotNull final String aPackage, + @NotNull final String resClassName, + @NotNull final String resFieldName) { + ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override + public void run() { + final Project project = module.getProject(); + final PsiClass[] classes = + JavaPsiFacade.getInstance(project).findClasses(aPackage + ".R", GlobalSearchScope.moduleScope(module)); + if (classes.length == 1) { + final PsiClass aClass = classes[0]; + final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); + + PsiClass resTypeClass = aClass.findInnerClassByName(resClassName, false); + + if (resTypeClass == null) { + resTypeClass = (PsiClass)aClass.add(factory.createClass(resClassName)); + } + else if (resTypeClass.findFieldByName(resFieldName, false) != null) { + return; + } + final PsiField psiField = (PsiField)resTypeClass.add(factory.createField(resFieldName, PsiType.INT)); + PsiUtil.setModifierProperty(psiField, PsiModifier.PUBLIC, true); + PsiUtil.setModifierProperty(psiField, PsiModifier.STATIC, true); + PsiUtil.setModifierProperty(psiField, PsiModifier.FINAL, true); + } + } + }); + } + + @NotNull + public static XmlFile createFileResource(@NotNull String fileName, + @NotNull PsiDirectory resSubdir, + @NotNull String rootTagName, + @NotNull String resourceType, + boolean valuesResourceFile) throws Exception { + FileTemplateManager manager = FileTemplateManager.getInstance(); + String templateName = getTemplateName(resourceType, valuesResourceFile); + FileTemplate template = manager.getJ2eeTemplate(templateName); + Properties properties = new Properties(); + if (!valuesResourceFile) { + properties.setProperty(ROOT_TAG_PROPERTY, rootTagName); + } + PsiElement createdElement = FileTemplateUtil.createFromTemplate(template, fileName, properties, resSubdir); + assert createdElement instanceof XmlFile; + return (XmlFile)createdElement; + } + + private static String getTemplateName(String resourceType, boolean valuesResourceFile) { + if (valuesResourceFile) { + return AndroidFileTemplateProvider.VALUE_RESOURCE_FILE_TEMPLATE; + } + if ("layout".equals(resourceType)) { + return AndroidFileTemplateProvider.LAYOUT_RESOURCE_FILE_TEMPLATE; + } + return AndroidFileTemplateProvider.RESOURCE_FILE_TEMPLATE; + } } diff --git a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java index de12c53a9e0b..d859ac793252 100644 --- a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java +++ b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java @@ -4,13 +4,12 @@ import com.android.sdklib.SdkConstants; import com.intellij.codeInsight.TargetElementUtilBase; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.codeInspection.actions.CleanupInspectionIntention; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; -import org.jetbrains.android.dom.converters.ResourceReferenceConverter; +import org.jetbrains.android.inspections.CreateValueResourceQuickFix; import java.io.IOException; import java.util.ArrayList; @@ -351,7 +350,7 @@ public class AndroidLayoutDomTest extends AndroidDomTest { if (ranges != null) { for (Pair pair : ranges) { final IntentionAction action = pair.getFirst().getAction(); - if (action instanceof ResourceReferenceConverter.MyCreateValueResourceQuickFix) { + if (action instanceof CreateValueResourceQuickFix) { actions.add(action); } } @@ -368,44 +367,6 @@ public class AndroidLayoutDomTest extends AndroidDomTest { myFixture.checkResultByFile("res/values/drawables.xml", testFolder + '/' + getTestName(true) + "_drawable_after.xml", true); } - public void testCreateResourceFromUsageCleanUp() throws Throwable { - final VirtualFile virtualFile = copyFileToProject(getTestName(true) + ".xml"); - myFixture.configureFromExistingVirtualFile(virtualFile); - final List infos = myFixture.doHighlighting(); - - final List actions = new ArrayList(); - - for (HighlightInfo info : infos) { - final List> ranges = info.quickFixActionRanges; - - if (ranges != null) { - for (Pair pair : ranges) { - final HighlightInfo.IntentionActionDescriptor descriptor = pair.getFirst(); - if (descriptor.getAction() instanceof ResourceReferenceConverter.MyCreateValueResourceQuickFix) { - final List options = descriptor.getOptions(myFixture.getFile(), myFixture.getEditor()); - - if (options != null) { - for (IntentionAction option : options) { - if (option instanceof CleanupInspectionIntention) { - actions.add(option); - } - } - } - } - } - } - } - assertEquals(1, actions.size()); - - new WriteCommandAction.Simple(getProject()) { - @Override - protected void run() throws Throwable { - actions.get(0).invoke(getProject(), myFixture.getEditor(), myFixture.getFile()); - } - }.execute(); - myFixture.checkResultByFile("res/values/drawables.xml", testFolder + '/' + getTestName(true) + "_drawable_after.xml", true); - } - public void testXsdFile1() throws Throwable { final VirtualFile virtualFile = copyFileToProject("XsdFile.xsd", "res/raw/XsdFile.xsd"); myFixture.configureFromExistingVirtualFile(virtualFile); diff --git a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidValueResourcesTest.java b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidValueResourcesTest.java index 444486328e12..93c97fe11840 100644 --- a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidValueResourcesTest.java +++ b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidValueResourcesTest.java @@ -27,7 +27,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiReference; import com.intellij.psi.xml.XmlAttributeValue; -import org.jetbrains.android.dom.converters.ResourceReferenceConverter; +import org.jetbrains.android.inspections.CreateValueResourceQuickFix; import java.util.ArrayList; import java.util.List; @@ -199,7 +199,7 @@ public class AndroidValueResourcesTest extends AndroidDomTest { if (ranges != null) { for (Pair pair : ranges) { final IntentionAction action = pair.getFirst().getAction(); - if (action instanceof ResourceReferenceConverter.MyCreateValueResourceQuickFix) { + if (action instanceof CreateValueResourceQuickFix) { actions.add(action); } } From fab8a8f99885cb2aa20d90a65cc63008fb8be621 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Sat, 9 Jun 2012 19:06:05 +0400 Subject: [PATCH 053/172] rename --- .../actions/CreateResourceFileAction.java | 2 +- ...Dialog.form => CreateResourceFileDialog.form} | 2 +- ...Dialog.java => CreateResourceFileDialog.java} | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) rename plugins/android/src/org/jetbrains/android/actions/{CreateResourceDialog.form => CreateResourceFileDialog.form} (98%) rename plugins/android/src/org/jetbrains/android/actions/{CreateResourceDialog.java => CreateResourceFileDialog.java} (95%) diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileAction.java b/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileAction.java index b8a3218f0e99..ac5bbb1ffb88 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileAction.java +++ b/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileAction.java @@ -210,7 +210,7 @@ public class CreateResourceFileAction extends CreateElementActionBase { return AndroidBundle.message("new.resource.action.name", directory.getName() + File.separator + newName); } - private static class MyDialog extends CreateResourceDialog { + private static class MyDialog extends CreateResourceFileDialog { private final CreateResourceFileAction myAction; protected MyDialog(@NotNull AndroidFacet facet, diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.form b/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileDialog.form similarity index 98% rename from plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.form rename to plugins/android/src/org/jetbrains/android/actions/CreateResourceFileDialog.form index 2d3e556e7079..7169bfc92e4f 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.form +++ b/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileDialog.form @@ -1,5 +1,5 @@ -
+ diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.java b/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileDialog.java similarity index 95% rename from plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.java rename to plugins/android/src/org/jetbrains/android/actions/CreateResourceFileDialog.java index 68b7e5c6187a..8c5871a52969 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateResourceDialog.java +++ b/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileDialog.java @@ -53,7 +53,7 @@ import java.util.List; * Time: 7:47:01 PM * To change this template use File | Settings | File Templates. */ -public class CreateResourceDialog extends DialogWrapper { +public class CreateResourceFileDialog extends DialogWrapper { private JTextField myFileNameField; private TemplateKindCombo myResourceTypeCombo; private JPanel myPanel; @@ -75,13 +75,13 @@ public class CreateResourceDialog extends DialogWrapper { private final AndroidFacet myFacet; private final ResourceType myPredefinedResourceType; - public CreateResourceDialog(@NotNull AndroidFacet facet, - Collection actions, - @Nullable ResourceType predefinedResourceType, - @Nullable String predefinedFileName, - boolean chooseFileName, - @NotNull Module module, - boolean chooseModule) { + public CreateResourceFileDialog(@NotNull AndroidFacet facet, + Collection actions, + @Nullable ResourceType predefinedResourceType, + @Nullable String predefinedFileName, + boolean chooseFileName, + @NotNull Module module, + boolean chooseModule) { super(facet.getModule().getProject()); myFacet = facet; myPredefinedResourceType = predefinedResourceType; From 335692cd3724160fa45399bff2e01d2ef26e70ad Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Sat, 9 Jun 2012 19:16:28 +0400 Subject: [PATCH 054/172] IDEA-87227 fix mnemonics --- .../android/actions/CreateResourceFileDialog.java | 1 + .../android/uipreview/DeviceConfiguratorPanel.java | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileDialog.java b/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileDialog.java index 8c5871a52969..ecd4adbde004 100644 --- a/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileDialog.java +++ b/plugins/android/src/org/jetbrains/android/actions/CreateResourceFileDialog.java @@ -208,6 +208,7 @@ public class CreateResourceFileDialog extends DialogWrapper { : ""); myRootElementFieldWrapper.removeAll(); myRootElementFieldWrapper.add(myRootElementField, BorderLayout.CENTER); + myRootElementLabel.setLabelFor(myRootElementField); } } diff --git a/plugins/android/src/org/jetbrains/android/uipreview/DeviceConfiguratorPanel.java b/plugins/android/src/org/jetbrains/android/uipreview/DeviceConfiguratorPanel.java index 13dfce4377ff..edb4b219d40a 100644 --- a/plugins/android/src/org/jetbrains/android/uipreview/DeviceConfiguratorPanel.java +++ b/plugins/android/src/org/jetbrains/android/uipreview/DeviceConfiguratorPanel.java @@ -340,16 +340,18 @@ public abstract class DeviceConfiguratorPanel extends JPanel { final JPanel leftPanel = new JPanel(new BorderLayout(5, 5)); myAvailableQualifiersList = new JBList(); myAvailableQualifiersList.setMinimumSize(new Dimension(10, 10)); - leftPanel - .add(new JBLabel(AndroidBundle.message("android.layout.preview.edit.configuration.available.qualifiers.label")), BorderLayout.NORTH); + JBLabel label = new JBLabel(AndroidBundle.message("android.layout.preview.edit.configuration.available.qualifiers.label")); + label.setLabelFor(myAvailableQualifiersList); + leftPanel.add(label, BorderLayout.NORTH); leftPanel.add(new JBScrollPane(myAvailableQualifiersList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER); final JPanel rightPabel = new JPanel(new BorderLayout(5, 5)); myChosenQualifiersList = new JBList(); myChosenQualifiersList.setMinimumSize(new Dimension(10, 10)); - rightPabel - .add(new JBLabel(AndroidBundle.message("android.layout.preview.edit.configuration.choosen.qualifiers.label")), BorderLayout.NORTH); + label = new JBLabel(AndroidBundle.message("android.layout.preview.edit.configuration.choosen.qualifiers.label")); + label.setLabelFor(myChosenQualifiersList); + rightPabel.add(label, BorderLayout.NORTH); rightPabel.add(new JBScrollPane(myChosenQualifiersList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER); From cae534e044a2fac6656452d9cdb430d04fb9f318 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Sat, 9 Jun 2012 16:20:06 +0400 Subject: [PATCH 055/172] Cleanup --- bin/log.xml | 19 ++--- .../src/com/intellij/idea/LoggerFactory.java | 85 +++++-------------- 2 files changed, 26 insertions(+), 78 deletions(-) diff --git a/bin/log.xml b/bin/log.xml index a85a744b1c38..d8fca779f651 100644 --- a/bin/log.xml +++ b/bin/log.xml @@ -1,6 +1,6 @@ - + @@ -29,9 +29,9 @@ - - - + + + @@ -52,19 +52,10 @@ - - - + diff --git a/platform/platform-impl/src/com/intellij/idea/LoggerFactory.java b/platform/platform-impl/src/com/intellij/idea/LoggerFactory.java index 11d6a1843479..d7a8cc8ce70d 100644 --- a/platform/platform-impl/src/com/intellij/idea/LoggerFactory.java +++ b/platform/platform-impl/src/com/intellij/idea/LoggerFactory.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. @@ -25,53 +25,42 @@ import org.apache.log4j.xml.DOMConfigurator; import java.io.File; import java.io.StringReader; -@SuppressWarnings({"HardCodedStringLiteral"}) +@SuppressWarnings({"CallToPrintStackTrace", "UseOfSystemOutOrSystemErr"}) public class LoggerFactory implements Logger.Factory { private static final String SYSTEM_MACRO = "$SYSTEM_DIR$"; private static final String APPLICATION_MACRO = "$APPLICATION_DIR$"; - private static final String COMMENT_LINE_FOR_TEST_MODE_MACRO = "$COMMENT_LINE_FOR_TEST_MODE$"; - private static final String LOGDIR_MACRO = "$LOG_DIR$"; + private static final String LOG_DIR_MACRO = "$LOG_DIR$"; private boolean myInitialized = false; private static final LoggerFactory ourInstance = new LoggerFactory(); - public static final String LOG_DIR = "log"; public static LoggerFactory getInstance() { return ourInstance; } - private LoggerFactory() { - } + private LoggerFactory() { } - public Logger getLoggerInstance(String name) { - synchronized (this) { - try { - if (!isInitialized()) { - init(); - } + @Override + public synchronized Logger getLoggerInstance(String name) { + try { + if (!myInitialized) { + init(); } - catch (Exception e) { - e.printStackTrace(); - } - - return new IdeaLogger(org.apache.log4j.Logger.getLogger(name)); } + catch (Exception e) { + e.printStackTrace(); + } + + return new IdeaLogger(org.apache.log4j.Logger.getLogger(name)); } private void init() { try { - /* - //debug code. Don't delete. - ClassLoader classLoader = Logger.class.getClassLoader(); - if (!(classLoader.getClass().getName().startsWith("com.intellij"))) { - System.err.println("Logger shouldn't be used outside the PluginManager"); - Thread.dumpStack(); - } - */ - System.setProperty("log4j.defaultInitOverride", "true"); - File logXmlFile = FileUtil.findFirstThatExist(PathManager.getHomePath() + "/bin/log.xml", PathManager.getHomePath() + "/community/bin/log.xml"); + + File logXmlFile = FileUtil.findFirstThatExist(PathManager.getHomePath() + "/bin/log.xml", + PathManager.getHomePath() + "/community/bin/log.xml"); if (logXmlFile == null) { throw new RuntimeException("log.xml file does not exist! Path: [ $home/bin/log.xml]"); } @@ -79,14 +68,12 @@ public class LoggerFactory implements Logger.Factory { String text = FileUtil.loadFile(logXmlFile); text = StringUtil.replace(text, SYSTEM_MACRO, StringUtil.replace(PathManager.getSystemPath(), "\\", "\\\\")); text = StringUtil.replace(text, APPLICATION_MACRO, StringUtil.replace(PathManager.getHomePath(), "\\", "\\\\")); - text = StringUtil.replace(text, LOGDIR_MACRO, StringUtil.replace(PathManager.getLogPath(), "\\", "\\\\")); - - if ("true".equals(System.getProperty("idea.test.test_mode"))) { - text = commentTestModeLines(text); - } + text = StringUtil.replace(text, LOG_DIR_MACRO, StringUtil.replace(PathManager.getLogPath(), "\\", "\\\\")); File file = new File(PathManager.getLogPath()); - file.mkdirs(); + if (!file.mkdirs() && !file.exists()) { + System.err.println("Cannot create log directory: " + file); + } new DOMConfigurator().doConfigure(new StringReader(text), LogManager.getLoggerRepository()); @@ -96,34 +83,4 @@ public class LoggerFactory implements Logger.Factory { e.printStackTrace(); } } - - private boolean isInitialized() { - return myInitialized; - } - - private static String commentTestModeLines(String text) { - String result = text; - int index = text.indexOf(COMMENT_LINE_FOR_TEST_MODE_MACRO); - if (index != -1) { - String str1 = result.substring(0, index); - String str2 = result.substring(index); - int firstLineChar = Math.max(str1.lastIndexOf('\n'), str1.lastIndexOf('\r')); - int lastLineChar = str2.indexOf('\n'); - int lastLineChar2 = str2.indexOf('\r'); - if (lastLineChar == -1) { - lastLineChar = lastLineChar2; - } - else if (lastLineChar2 != -1) { - lastLineChar = Math.min(lastLineChar, lastLineChar2); - } - if (firstLineChar != -1) { - str1 = str1.substring(0, firstLineChar); - } - if (lastLineChar != -1) { - str2 = str2.substring(lastLineChar); - } - result = commentTestModeLines(str1) + commentTestModeLines(str2); - } - return result; - } } From c96d667848ac9cb1230412f9dcef25c0c57b3293 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Sat, 9 Jun 2012 18:33:35 +0400 Subject: [PATCH 056/172] Separate log4j config for tests --- lib/log4j.dtd | 227 ++++++++++++++++++ .../intellij/testFramework/TestLogger.java | 8 +- .../testFramework/TestLoggerFactory.java | 15 +- test-log.xml | 34 +++ 4 files changed, 275 insertions(+), 9 deletions(-) create mode 100644 lib/log4j.dtd create mode 100644 test-log.xml diff --git a/lib/log4j.dtd b/lib/log4j.dtd new file mode 100644 index 000000000000..1aabd96c3beb --- /dev/null +++ b/lib/log4j.dtd @@ -0,0 +1,227 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/testFramework/src/com/intellij/testFramework/TestLogger.java b/platform/testFramework/src/com/intellij/testFramework/TestLogger.java index 4c6685ff5d21..9469811ef904 100644 --- a/platform/testFramework/src/com/intellij/testFramework/TestLogger.java +++ b/platform/testFramework/src/com/intellij/testFramework/TestLogger.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. @@ -29,7 +29,7 @@ public class TestLogger extends com.intellij.openapi.diagnostic.Logger { @Override public boolean isDebugEnabled() { - return false; + return myLogger.isDebugEnabled(); } @Override @@ -67,6 +67,10 @@ public class TestLogger extends com.intellij.openapi.diagnostic.Logger { myLogger.warn(message, t); } + public Level getLevel() { + return myLogger.getLevel(); + } + @Override public void setLevel(Level level) { myLogger.setLevel(level); diff --git a/platform/testFramework/src/com/intellij/testFramework/TestLoggerFactory.java b/platform/testFramework/src/com/intellij/testFramework/TestLoggerFactory.java index 7ad886df983a..971d52ca8039 100644 --- a/platform/testFramework/src/com/intellij/testFramework/TestLoggerFactory.java +++ b/platform/testFramework/src/com/intellij/testFramework/TestLoggerFactory.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. @@ -54,7 +54,10 @@ public class TestLoggerFactory implements Logger.Factory { private void init() { try { - final File logXmlFile = new File(PathManager.getBinPath() + File.separator + "log.xml"); + File logXmlFile = new File(PathManager.getHomePath(), "test-log.xml"); + if (!logXmlFile.exists()) { + logXmlFile = new File(PathManager.getBinPath(), "log.xml"); + } if (!logXmlFile.exists()) { return; } @@ -65,11 +68,9 @@ public class TestLoggerFactory implements Logger.Factory { text = StringUtil.replace(text, APPLICATION_MACRO, StringUtil.replace(PathManager.getHomePath(), "\\", "\\\\")); text = StringUtil.replace(text, LOG_DIR_MACRO, StringUtil.replace(logDir, "\\", "\\\\")); - final File logDirFile = new File(PathManager.getSystemPath() + File.separator + LOG_DIR); - if (!logDirFile.mkdirs()) { - if (!logDirFile.exists()) { - throw new IOException("Unable to create log dir: " + logDirFile); - } + final File logDirFile = new File(logDir); + if (!logDirFile.mkdirs() && !logDirFile.exists()) { + throw new IOException("Unable to create log dir: " + logDirFile); } System.setProperty("log4j.defaultInitOverride", "true"); diff --git a/test-log.xml b/test-log.xml new file mode 100644 index 000000000000..d01850b67dc8 --- /dev/null +++ b/test-log.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a0362a410cf7d7c6e70503821b29c99368bf544c Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Sat, 9 Jun 2012 19:36:21 +0400 Subject: [PATCH 057/172] Trace FileWatcher tests execution --- .../openapi/vfs/impl/local/FileWatcher.java | 15 +++++++++++---- .../openapi/vfs/local/FileWatcherTest.java | 11 +++++++++++ test-log.xml | 7 ++++++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java index 5b9eda3ce0bf..139541d85171 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java @@ -57,6 +57,9 @@ public class FileWatcher { @NonNls private static final String EXIT_COMMAND = "EXIT"; @NonNls private static final String MESSAGE_COMMAND = "MESSAGE"; + private static final int MAX_PROCESS_LAUNCH_ATTEMPT_COUNT = 10; + private static final int MAGIC_PROCESS_LAUNCH_ATTEMPT_COUNT = 88 * MAX_PROCESS_LAUNCH_ATTEMPT_COUNT; + private final Object LOCK = new Object(); private List myDirtyPaths = new ArrayList(); @@ -78,7 +81,6 @@ public class FileWatcher { private volatile BufferedWriter notifierWriter; private boolean myFailureShownToTheUser = false; private int attemptCount = 0; - private static final int MAX_PROCESS_LAUNCH_ATTEMPT_COUNT = 10; private boolean isShuttingDown = false; private final ManagingFS myManagingFS; @@ -323,7 +325,7 @@ public class FileWatcher { myFailureShownToTheUser = true; attemptCount = 0; startupProcess(false); - attemptCount = 2 * MAX_PROCESS_LAUNCH_ATTEMPT_COUNT; + attemptCount = MAGIC_PROCESS_LAUNCH_ATTEMPT_COUNT; if (notifierProcess != null) { new WatchForChangesThread().start(); } @@ -368,6 +370,11 @@ public class FileWatcher { final String command = readLine(); if (command == null) { + if (attemptCount == MAGIC_PROCESS_LAUNCH_ATTEMPT_COUNT) { + LOG.debug("Leaving watcher thread"); + return; + } + // Unexpected process exit, relaunch attempt startupProcess(true); continue; @@ -466,7 +473,7 @@ public class FileWatcher { private void writeLine(String line) throws IOException { if (LOG.isDebugEnabled()) { - LOG.debug("to fsnotifier: " + line); + LOG.debug("<< " + line); } final Process process = notifierProcess; @@ -502,7 +509,7 @@ public class FileWatcher { final String line = reader.readLine(); if (LOG.isDebugEnabled()) { - LOG.debug("fsnotifier says: " + line); + LOG.debug(">> " + line); } return line; } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java index b0aed3874df4..91f46cc63d01 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java @@ -18,6 +18,7 @@ package com.intellij.openapi.vfs.local; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; @@ -43,6 +44,8 @@ import java.util.*; public class FileWatcherTest extends PlatformLangTestCase { private static final int NATIVE_PROCESS_DELAY = 750; // time to event to be caught by native watcher and passed to watcher thread + private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vfs.impl.local.FileWatcher"); + private FileWatcher myWatcher; private LocalFileSystem myFileSystem; private MessageBusConnection myConnection; @@ -68,6 +71,8 @@ public class FileWatcherTest extends PlatformLangTestCase { @Override protected void setUp() throws Exception { + LOG.debug("================== setting up " + getName() + " =================="); + super.setUp(); Disposer.register(getProject(), myAlarm); @@ -92,10 +97,14 @@ public class FileWatcherTest extends PlatformLangTestCase { myEvents.addAll(events); } }); + + LOG.debug("================== setting up " + getName() + " =================="); } @Override protected void tearDown() throws Exception { + LOG.debug("================== tearing down " + getName() + " =================="); + try { myConnection.disconnect(); myWatcher.shutdown(); @@ -105,6 +114,8 @@ public class FileWatcherTest extends PlatformLangTestCase { myWatcher = null; super.tearDown(); } + + LOG.debug("================== tearing down " + getName() + " =================="); } diff --git a/test-log.xml b/test-log.xml index d01850b67dc8..3028abeab261 100644 --- a/test-log.xml +++ b/test-log.xml @@ -14,7 +14,7 @@ - + @@ -26,6 +26,11 @@ + + + + + From e2937d0f0a62ca2ca4a24f826539c8ae8598f26a Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Sat, 9 Jun 2012 20:43:45 +0400 Subject: [PATCH 058/172] IDEA-78338 pass cannonical adb path --- .../src/org/jetbrains/android/sdk/AndroidSdkData.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/android/src/org/jetbrains/android/sdk/AndroidSdkData.java b/plugins/android/src/org/jetbrains/android/sdk/AndroidSdkData.java index b864f7198332..91b53de228de 100644 --- a/plugins/android/src/org/jetbrains/android/sdk/AndroidSdkData.java +++ b/plugins/android/src/org/jetbrains/android/sdk/AndroidSdkData.java @@ -41,6 +41,7 @@ import org.jetbrains.annotations.Nullable; import java.awt.*; import java.io.File; +import java.io.IOException; import java.util.Map; /** @@ -316,9 +317,15 @@ public class AndroidSdkData { private String getAdbPath() { String path = getLocation() + File.separator + SdkConstants.OS_SDK_PLATFORM_TOOLS_FOLDER + SdkConstants.FN_ADB; if (!new File(path).exists()) { - return getLocation() + File.separator + AndroidCommonUtils.toolPath(SdkConstants.FN_ADB); + path = getLocation() + File.separator + AndroidCommonUtils.toolPath(SdkConstants.FN_ADB); + } + try { + return new File(path).getCanonicalPath(); + } + catch (IOException e) { + LOG.info(e); + return path; } - return path; } public static void terminateDdmlib() { From 979640775b3425bb5e7c3320b0312b0655ebf92d Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Sat, 9 Jun 2012 20:57:28 +0400 Subject: [PATCH 059/172] Highlight type parameters by default --- platform/platform-resources/src/DefaultColorSchemesManager.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-resources/src/DefaultColorSchemesManager.xml b/platform/platform-resources/src/DefaultColorSchemesManager.xml index a5c720af6b5a..c8ac1d74af1e 100644 --- a/platform/platform-resources/src/DefaultColorSchemesManager.xml +++ b/platform/platform-resources/src/DefaultColorSchemesManager.xml @@ -435,7 +435,7 @@ - + diff --git a/platform/lang-impl/src/com/intellij/ui/popup/util/DetailViewImpl.java b/platform/lang-impl/src/com/intellij/ui/popup/util/DetailViewImpl.java index 54213ac37c40..6b0f0fbc6c40 100644 --- a/platform/lang-impl/src/com/intellij/ui/popup/util/DetailViewImpl.java +++ b/platform/lang-impl/src/com/intellij/ui/popup/util/DetailViewImpl.java @@ -30,6 +30,8 @@ import com.intellij.openapi.util.Key; import com.intellij.openapi.util.UserDataHolder; import com.intellij.openapi.util.UserDataHolderBase; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.SideBorder; import com.intellij.ui.components.JBScrollPane; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -148,6 +150,8 @@ public class DetailViewImpl extends JPanel implements DetailView, UserDataHolder validate(); getEditor().getScrollingModel().scrollToCaret(ScrollType.CENTER); + getEditor().setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); + clearHightlighting(); if (lineAttributes != null) { myHighlighter = getEditor().getMarkupModel().addLineHighlighter(positionToNavigate.line, HighlighterLayer.SELECTION - 1, diff --git a/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java b/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java index b338b3162e57..b8de9a93159f 100644 --- a/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java +++ b/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java @@ -22,9 +22,7 @@ import com.intellij.openapi.ui.popup.JBPopupListener; import com.intellij.openapi.ui.popup.LightweightWindowEvent; import com.intellij.openapi.ui.popup.PopupChooserBuilder; import com.intellij.openapi.wm.IdeFocusManager; -import com.intellij.ui.ColoredListCellRenderer; -import com.intellij.ui.Gray; -import com.intellij.ui.TitledSeparator; +import com.intellij.ui.*; import com.intellij.ui.components.JBList; import com.intellij.ui.speedSearch.FilteringListModel; import com.intellij.util.Alarm; @@ -59,6 +57,7 @@ public class MasterDetailPopupBuilder { private JComponent myChooserComponent; private ActionToolbar myActionToolbar; private boolean myAddDetailViewToEast = true; + private Dimension myMinSize; public MasterDetailPopupBuilder setDetailView(DetailView detailView) { @@ -194,14 +193,18 @@ public class MasterDetailPopupBuilder { setItemChoosenCallback(runnable). setCloseOnEnter(myCloseOnEnter). setMayBeParent(true). - setMinSize(new Dimension(-1, 700)). setFilteringEnabled(new Function() { public String fun(Object o) { return ((ItemWrapper)o).speedSearchText(); } }); + if (myMinSize != null) { + builder.setMinSize(myMinSize); + } + myPopup = builder.createPopup(); + builder.getScrollPane().setBorder(IdeBorderFactory.createBorder(SideBorder.RIGHT)); myPopup.addListener(new JBPopupListener() { @Override public void beforeShown(LightweightWindowEvent event) { @@ -263,6 +266,11 @@ public class MasterDetailPopupBuilder { myAddDetailViewToEast = addDetailViewToEast; } + public MasterDetailPopupBuilder setMinSize(Dimension minSize) { + myMinSize = minSize; + return this; + } + public static boolean allowedToRemoveItems(Object[] values) { for (Object value : values) { ItemWrapper item = (ItemWrapper)value; diff --git a/platform/platform-api/src/com/intellij/openapi/ui/popup/PopupChooserBuilder.java b/platform/platform-api/src/com/intellij/openapi/ui/popup/PopupChooserBuilder.java index 1d7ddf517976..6c1aea206ed0 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/popup/PopupChooserBuilder.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/popup/PopupChooserBuilder.java @@ -83,6 +83,12 @@ public class PopupChooserBuilder { private boolean myModalContext; private boolean myCloseOnEnter = true; + public JScrollPane getScrollPane() { + return myScrollPane; + } + + private JScrollPane myScrollPane; + public PopupChooserBuilder(@NotNull JList list) { myChooserComponent = list; } @@ -232,29 +238,28 @@ public class PopupChooserBuilder { registerClosePopupKeyboardAction(keystroke, true); } - final JScrollPane scrollPane; if (myChooserComponent instanceof ListWithFilter) { - scrollPane = ((ListWithFilter)myChooserComponent).getScrollPane(); + myScrollPane = ((ListWithFilter)myChooserComponent).getScrollPane(); } else if (myChooserComponent instanceof JTable) { - scrollPane = createScrollPane((JTable)myChooserComponent); + myScrollPane = createScrollPane((JTable)myChooserComponent); } else if (myChooserComponent instanceof JTree) { - scrollPane = createScrollPane((JTree)myChooserComponent); + myScrollPane = createScrollPane((JTree)myChooserComponent); } else { throw new IllegalStateException("PopupChooserBuilder is intended to be constructed with one of JTable, JTree, JList components"); } - scrollPane.getViewport().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + myScrollPane.getViewport().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); Insets viewportPadding = UIUtil.getListViewportPadding(); - ((JComponent)scrollPane.getViewport().getView()).setBorder(BorderFactory.createEmptyBorder(viewportPadding.top, viewportPadding.left, viewportPadding.bottom, viewportPadding.right)); + ((JComponent)myScrollPane.getViewport().getView()).setBorder(BorderFactory.createEmptyBorder(viewportPadding.top, viewportPadding.left, viewportPadding.bottom, viewportPadding.right)); if (myChooserComponent instanceof ListWithFilter) { contentPane.add(myChooserComponent, BorderLayout.CENTER); } else { - contentPane.add(scrollPane, BorderLayout.CENTER); + contentPane.add(myScrollPane, BorderLayout.CENTER); } if (mySouthComponent != null) { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java index cae1c77a2a75..857340f25839 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java @@ -26,7 +26,6 @@ import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.JBPopupListener; import com.intellij.openapi.ui.popup.LightweightWindowEvent; import com.intellij.openapi.util.SystemInfo; -import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.popup.util.DetailView; import com.intellij.ui.popup.util.ItemWrapper; import com.intellij.ui.popup.util.MasterDetailPopupBuilder; @@ -193,18 +192,23 @@ public class BreakpointMasterDetailPopupBuilder { } }; - final JBPopup popup = myPopupBuilder. - setActionsGroup(actions). - setTree(tree). - setDelegate(delegate). - setCloseOnEnter(false).createMasterDetailPopup(); + myPopupBuilder. + setActionsGroup(actions). + setTree(tree). + setDelegate(delegate); - tree.setBorder(IdeBorderFactory.createBorder()); + if (!myIsViewer) { + myPopupBuilder.setMinSize(new Dimension(-1, 700)); + } + + final JBPopup popup = myPopupBuilder.setCloseOnEnter(false).createMasterDetailPopup(); myTreeController.setDelegate(new BreakpointItemsTreeController.BreakpointItemsTreeDelegate() { @Override public void execute(BreakpointItem item) { - myCallback.breakpointChosen(myProject, item, popup); + if (myCallback != null) { + myCallback.breakpointChosen(myProject, item, popup); + } } }); diff --git a/resources-en/src/messages/DebuggerBundle.properties b/resources-en/src/messages/DebuggerBundle.properties index 37b2fbe141bc..6704cc25f199 100644 --- a/resources-en/src/messages/DebuggerBundle.properties +++ b/resources-en/src/messages/DebuggerBundle.properties @@ -418,7 +418,7 @@ error.cannot.create.expression.from.code.fragment=Cannot create expression from error.invalid.local.variable.name=Invalid local variable name ''{0}'' error.inconsistent.debug.info=Inconsistent debug information error.invalid.stackframe=Internal exception - invalid stackframe -label.breakpoint.properties.panel.group.conditions=Conditions +label.breakpoint.properties.panel.group.conditions=Filters label.breakpoint.properties.panel.group.actions=Actions label.breakpoint.properties.panel.group.suspend.policy=Suspend policy active.tooltip.title=Evaluation of {0} From dbd8286da086ecf652705660f9ae734c2da412b4 Mon Sep 17 00:00:00 2001 From: Dmitry Boulytchev Date: Sat, 9 Jun 2012 23:09:44 +0400 Subject: [PATCH 066/172] Fixed stupid NPE in a stupid way (classToSubClasses) (compile-server) --- .../src/org/jetbrains/ether/dependencyView/Mappings.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java b/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java index cecac9e10441..825d66cd93d9 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java @@ -2002,9 +2002,10 @@ public class Mappings { if (!compiledClasses.contains(a)) { final TIntHashSet old = myClassToSubclasses.get(a); - old.removeAll(b.toArray()); - - myClassToSubclasses.replace(a, old); + if (old != null) { + old.removeAll(b.toArray()); + myClassToSubclasses.replace(a, old); + } } return true; From b7374155b7588a0253c16a453ee3b7dce7315016 Mon Sep 17 00:00:00 2001 From: Danila Ponomarenko Date: Fri, 8 Jun 2012 21:15:24 +0400 Subject: [PATCH 067/172] IDEA-87162 Internationalization refactoring problem with escapes fixed --- .../codeInspection/i18n/I18nizeAction.java | 3 +- .../properties/editor/ResourceBundleUtil.java | 48 +++++-------------- 2 files changed, 15 insertions(+), 36 deletions(-) diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nizeAction.java b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nizeAction.java index 9a4b445fe271..a48642d9f200 100644 --- a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nizeAction.java +++ b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nizeAction.java @@ -25,6 +25,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiLiteralExpression; @@ -122,7 +123,7 @@ public class I18nizeAction extends AnAction { CommandProcessor.getInstance().executeCommand(project, new Runnable(){ public void run() { try { - handler.performI18nization(psiFile, editor, dialog.getLiteralExpression(), propertiesFiles, dialog.getKey(), dialog.getValue(), + handler.performI18nization(psiFile, editor, dialog.getLiteralExpression(), propertiesFiles, dialog.getKey(), StringUtil.unescapeStringCharacters(dialog.getValue()), dialog.getI18nizedText(), dialog.getParameters(), dialog.getPropertyCreationHandler()); } diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleUtil.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleUtil.java index 235f50d6d62e..7b7a511c23e3 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleUtil.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleUtil.java @@ -15,6 +15,7 @@ */ package com.intellij.lang.properties.editor; +import com.intellij.openapi.util.text.StringUtil; import gnu.trove.TIntHashSet; import org.jetbrains.annotations.NotNull; @@ -27,9 +28,8 @@ import java.util.Properties; */ public class ResourceBundleUtil { - private static final TIntHashSet SYMBOLS_TO_ESCAPE = new TIntHashSet(new int[]{'#', '!', '=', ':'}); - private static final char ESCAPE_SYMBOL = '\\'; - + private static final String ADDITIONAL_ESCAPE_SYMBOLS = "#!=:"; + private ResourceBundleUtil() { } @@ -37,47 +37,25 @@ public class ResourceBundleUtil { * Allows to map given 'raw' property value text to the 'user-friendly' text to show at the resource bundle editor. *

* Note: please refer to {@link Properties#store(Writer, String)} contract for the property value escape rules. - * - * @param text 'raw' property value text - * @return 'user-friendly' text to show at the resource bundle editor + * + * @param text 'raw' property value text + * @return 'user-friendly' text to show at the resource bundle editor */ @NotNull public static String fromPropertyValueToValueEditor(@NotNull String text) { - StringBuilder buffer = new StringBuilder(); - boolean escaped = false; - for (int i = 0; i < text.length(); i++) { - char c = text.charAt(i); - if (c == ESCAPE_SYMBOL && !escaped) { - escaped = true; - continue; - } - buffer.append(c); - escaped = false; - } - return buffer.toString(); + return StringUtil.unescapeStringCharacters(text); } /** - * Perform reverse operation to {@link #fromPropertyValueToValueEditor(String)}. - * - * @param text 'user-friendly' text shown to the user at the resource bundle editor - * @return 'raw' value to store at the *.properties file + * Performs reverse operation to {@link #fromPropertyValueToValueEditor(String)}. + * + * @param text 'user-friendly' text shown to the user at the resource bundle editor + * @return 'raw' value to store at the *.properties file */ @NotNull public static String fromValueEditorToPropertyValue(@NotNull String text) { - StringBuilder buffer = new StringBuilder(); - for (int i = 0; i < text.length(); i++) { - char c = text.charAt(i); - - if ((i == 0 && (c == ' ' || c == '\t')) // Leading white space - || c == '\n' // Multi-line value - || c == ESCAPE_SYMBOL // Escaped 'escape' symbol - || SYMBOLS_TO_ESCAPE.contains(c)) // Special symbol - { - buffer.append(ESCAPE_SYMBOL); - } - buffer.append(c); - } + final StringBuilder buffer = new StringBuilder(); + StringUtil.escapeStringCharacters(text.length(), text, ADDITIONAL_ESCAPE_SYMBOLS, true, buffer); return buffer.toString(); } } From c63295cda95b251d04a50fb05fe195e8556af6ec Mon Sep 17 00:00:00 2001 From: Danila Ponomarenko Date: Fri, 8 Jun 2012 21:49:54 +0400 Subject: [PATCH 068/172] understood and reverted --- .../properties/editor/ResourceBundleUtil.java | 48 ++++++++++++++----- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleUtil.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleUtil.java index 7b7a511c23e3..235f50d6d62e 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleUtil.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleUtil.java @@ -15,7 +15,6 @@ */ package com.intellij.lang.properties.editor; -import com.intellij.openapi.util.text.StringUtil; import gnu.trove.TIntHashSet; import org.jetbrains.annotations.NotNull; @@ -28,8 +27,9 @@ import java.util.Properties; */ public class ResourceBundleUtil { - private static final String ADDITIONAL_ESCAPE_SYMBOLS = "#!=:"; - + private static final TIntHashSet SYMBOLS_TO_ESCAPE = new TIntHashSet(new int[]{'#', '!', '=', ':'}); + private static final char ESCAPE_SYMBOL = '\\'; + private ResourceBundleUtil() { } @@ -37,25 +37,47 @@ public class ResourceBundleUtil { * Allows to map given 'raw' property value text to the 'user-friendly' text to show at the resource bundle editor. *

* Note: please refer to {@link Properties#store(Writer, String)} contract for the property value escape rules. - * - * @param text 'raw' property value text - * @return 'user-friendly' text to show at the resource bundle editor + * + * @param text 'raw' property value text + * @return 'user-friendly' text to show at the resource bundle editor */ @NotNull public static String fromPropertyValueToValueEditor(@NotNull String text) { - return StringUtil.unescapeStringCharacters(text); + StringBuilder buffer = new StringBuilder(); + boolean escaped = false; + for (int i = 0; i < text.length(); i++) { + char c = text.charAt(i); + if (c == ESCAPE_SYMBOL && !escaped) { + escaped = true; + continue; + } + buffer.append(c); + escaped = false; + } + return buffer.toString(); } /** - * Performs reverse operation to {@link #fromPropertyValueToValueEditor(String)}. - * - * @param text 'user-friendly' text shown to the user at the resource bundle editor - * @return 'raw' value to store at the *.properties file + * Perform reverse operation to {@link #fromPropertyValueToValueEditor(String)}. + * + * @param text 'user-friendly' text shown to the user at the resource bundle editor + * @return 'raw' value to store at the *.properties file */ @NotNull public static String fromValueEditorToPropertyValue(@NotNull String text) { - final StringBuilder buffer = new StringBuilder(); - StringUtil.escapeStringCharacters(text.length(), text, ADDITIONAL_ESCAPE_SYMBOLS, true, buffer); + StringBuilder buffer = new StringBuilder(); + for (int i = 0; i < text.length(); i++) { + char c = text.charAt(i); + + if ((i == 0 && (c == ' ' || c == '\t')) // Leading white space + || c == '\n' // Multi-line value + || c == ESCAPE_SYMBOL // Escaped 'escape' symbol + || SYMBOLS_TO_ESCAPE.contains(c)) // Special symbol + { + buffer.append(ESCAPE_SYMBOL); + } + buffer.append(c); + } return buffer.toString(); } } From 5da7997a503c9d4a954ec367e61b5954bf0b384f Mon Sep 17 00:00:00 2001 From: Danila Ponomarenko Date: Sun, 10 Jun 2012 15:55:31 +0400 Subject: [PATCH 069/172] IDEA-87233 Intentions: convert "then" statement to block and similar fixed --- .../siyeh/ipp/braces/AddBracesIntention.java | 115 ++++++++++++++---- .../siyeh/ipp/braces/AddBracesPredicate.java | 48 -------- 2 files changed, 92 insertions(+), 71 deletions(-) delete mode 100644 plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/AddBracesPredicate.java diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/AddBracesIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/AddBracesIntention.java index d21d823feb93..4a7d2c4a6c99 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/AddBracesIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/AddBracesIntention.java @@ -15,49 +15,118 @@ */ package com.siyeh.ipp.braces; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiIfStatement; -import com.intellij.psi.PsiKeyword; -import com.intellij.psi.PsiStatement; +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.*; +import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.IncorrectOperationException; import com.siyeh.IntentionPowerPackBundle; import com.siyeh.ipp.base.MutablyNamedIntention; import com.siyeh.ipp.base.PsiElementPredicate; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class AddBracesIntention extends MutablyNamedIntention { @NotNull protected PsiElementPredicate getElementPredicate() { - return new AddBracesPredicate(); + return new PsiElementPredicate() { + @Override + public boolean satisfiedBy(PsiElement element) { + final PsiStatement statement = getBody(element); + return statement != null && !(statement instanceof PsiBlockStatement); + } + }; } protected String getTextForElement(PsiElement element) { - final PsiElement parent = element.getParent(); - @NonNls final String keyword; + final PsiElement body = getBody(element); + if (body == null) { + return null; + } + + return IntentionPowerPackBundle.message("add.braces.intention.name", getKeyword(body.getParent(), body)); + } + + @NotNull + private static String getKeyword(@NotNull PsiElement parent, @NotNull PsiElement element) { if (parent instanceof PsiIfStatement) { final PsiIfStatement ifStatement = (PsiIfStatement)parent; final PsiStatement elseBranch = ifStatement.getElseBranch(); - if (element.equals(elseBranch)) { - keyword = PsiKeyword.ELSE; - } - else { - keyword = PsiKeyword.IF; - } + return element.equals(elseBranch) ? PsiKeyword.ELSE : PsiKeyword.IF; } - else { - final PsiElement firstChild = parent.getFirstChild(); - assert firstChild != null; - keyword = firstChild.getText(); - } - return IntentionPowerPackBundle.message("add.braces.intention.name", keyword); + final PsiElement firstChild = parent.getFirstChild(); + assert firstChild != null; + return firstChild.getText(); } - protected void processIntention(@NotNull PsiElement element) - throws IncorrectOperationException { - final PsiStatement statement = (PsiStatement)element; - final String newStatement = "{\n" + element.getText() + "\n}"; + protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException { + final PsiStatement statement = getBody(element); + if (statement == null) { + return; + } + final String newStatement = "{\n" + statement.getText() + "\n}"; replaceStatement(newStatement, statement); } + + @Nullable + private static PsiStatement getBody(@NotNull PsiElement element) { + final PsiElement parent = element.getParent(); + if (parent instanceof PsiIfStatement) { + final PsiIfStatement ifStatement = (PsiIfStatement)parent; + if (isBetweenThen(ifStatement, element)) { + return ifStatement.getThenBranch(); + } + + if (isBetweenElse(ifStatement, element)) { + return ifStatement.getElseBranch(); + } + } + if (parent instanceof PsiWhileStatement) { + return ((PsiWhileStatement)parent).getBody(); + } + if (parent instanceof PsiDoWhileStatement) { + return ((PsiDoWhileStatement)parent).getBody(); + } + if (parent instanceof PsiForStatement) { + return ((PsiForStatement)parent).getBody(); + } + if (parent instanceof PsiForeachStatement) { + return ((PsiForeachStatement)parent).getBody(); + } + return null; + } + + private static boolean isBetweenThen(@NotNull PsiIfStatement ifStatement, @NotNull PsiElement element) { + final PsiElement rParenth = ifStatement.getRParenth(); + final PsiElement elseElement = ifStatement.getElseElement(); + + if (rParenth == null) { + return false; + } + + if (elseElement == null) { + return true; + } + + final TextRange rParenthTextRangeTextRange = rParenth.getTextRange(); + final TextRange elseElementTextRange = elseElement.getTextRange(); + final TextRange elementTextRange = element.getTextRange(); + + return new TextRange(rParenthTextRangeTextRange.getEndOffset(), elseElementTextRange.getStartOffset()).contains(elementTextRange); + } + + private static boolean isBetweenElse(@NotNull PsiIfStatement ifStatement, @NotNull PsiElement element) { + final PsiElement elseElement = ifStatement.getElseElement(); + + if (elseElement == null) { + return false; + } + + final TextRange ifStatementTextRange = ifStatement.getTextRange(); + final TextRange elseElementTextRange = elseElement.getTextRange(); + final TextRange elementTextRange = element.getTextRange(); + + return new TextRange(elseElementTextRange.getStartOffset(), ifStatementTextRange.getEndOffset()).contains(elementTextRange); + } } \ No newline at end of file diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/AddBracesPredicate.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/AddBracesPredicate.java deleted file mode 100644 index 0bce137d2517..000000000000 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/AddBracesPredicate.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2003-2005 Dave Griffith - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.siyeh.ipp.braces; - -import com.intellij.psi.*; -import com.siyeh.ipp.base.PsiElementPredicate; -import org.jetbrains.annotations.NotNull; - -class AddBracesPredicate implements PsiElementPredicate { - public boolean satisfiedBy(@NotNull PsiElement element) { - if (!(element instanceof PsiStatement)) { - return false; - } - if (element instanceof PsiBlockStatement) { - return false; - } - final PsiElement parent = element.getParent(); - if (parent instanceof PsiIfStatement) { - final PsiIfStatement ifStatement = (PsiIfStatement)parent; - final PsiStatement elseBranch = ifStatement.getElseBranch(); - return !(element.equals(elseBranch) && element instanceof PsiIfStatement); - } - if (parent instanceof PsiWhileStatement) { - return true; - } - if (parent instanceof PsiDoWhileStatement) { - return true; - } - if (parent instanceof PsiForStatement) { - final PsiForStatement forStatement = (PsiForStatement)parent; - return element.equals(forStatement); - } - return parent instanceof PsiForeachStatement; - } -} \ No newline at end of file From 7c0fc9ce1321e180a216f3566ecde0a384c79125 Mon Sep 17 00:00:00 2001 From: Danila Ponomarenko Date: Sun, 10 Jun 2012 17:02:42 +0400 Subject: [PATCH 070/172] IDEA-87233 Intentions: convert "then" statement to block and similar additionally fixed --- .../IntentionPowerPak/src/META-INF/plugin.xml | 11 +- .../siyeh/ipp/braces/AddBracesIntention.java | 94 +------------- .../siyeh/ipp/braces/BaseBracesIntention.java | 115 ++++++++++++++++++ .../ipp/braces/RemoveBracesIntention.java | 68 ++++++----- .../ipp/braces/RemoveBracesPredicate.java | 47 ------- 5 files changed, 161 insertions(+), 174 deletions(-) create mode 100644 plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/BaseBracesIntention.java delete mode 100644 plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/RemoveBracesPredicate.java diff --git a/plugins/IntentionPowerPak/src/META-INF/plugin.xml b/plugins/IntentionPowerPak/src/META-INF/plugin.xml index d52b3c759254..b022104c9475 100644 --- a/plugins/IntentionPowerPak/src/META-INF/plugin.xml +++ b/plugins/IntentionPowerPak/src/META-INF/plugin.xml @@ -301,17 +301,14 @@ com.siyeh.ipp.braces.AddBracesIntention intention.category.control.flow - - com.siyeh.ipp.forloop.ReverseForLoopDirectionIntention - intention.category.control.flow - - - + + com.siyeh.ipp.forloop.ReverseForLoopDirectionIntention + intention.category.control.flow + diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/AddBracesIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/AddBracesIntention.java index 4a7d2c4a6c99..ac643a754ba0 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/AddBracesIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/AddBracesIntention.java @@ -15,118 +15,36 @@ */ package com.siyeh.ipp.braces; -import com.intellij.openapi.util.TextRange; import com.intellij.psi.*; -import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.IncorrectOperationException; -import com.siyeh.IntentionPowerPackBundle; -import com.siyeh.ipp.base.MutablyNamedIntention; import com.siyeh.ipp.base.PsiElementPredicate; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -public class AddBracesIntention extends MutablyNamedIntention { +public class AddBracesIntention extends BaseBracesIntention { @NotNull protected PsiElementPredicate getElementPredicate() { return new PsiElementPredicate() { @Override public boolean satisfiedBy(PsiElement element) { - final PsiStatement statement = getBody(element); + final PsiStatement statement = getSurroundingStatement(element); return statement != null && !(statement instanceof PsiBlockStatement); } }; } - protected String getTextForElement(PsiElement element) { - final PsiElement body = getBody(element); - if (body == null) { - return null; - } - - return IntentionPowerPackBundle.message("add.braces.intention.name", getKeyword(body.getParent(), body)); - } - @NotNull - private static String getKeyword(@NotNull PsiElement parent, @NotNull PsiElement element) { - if (parent instanceof PsiIfStatement) { - final PsiIfStatement ifStatement = (PsiIfStatement)parent; - final PsiStatement elseBranch = ifStatement.getElseBranch(); - return element.equals(elseBranch) ? PsiKeyword.ELSE : PsiKeyword.IF; - } - final PsiElement firstChild = parent.getFirstChild(); - assert firstChild != null; - return firstChild.getText(); + @Override + protected String getMessageKey() { + return "add.braces.intention.name"; } protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException { - final PsiStatement statement = getBody(element); + final PsiStatement statement = getSurroundingStatement(element); if (statement == null) { return; } final String newStatement = "{\n" + statement.getText() + "\n}"; replaceStatement(newStatement, statement); } - - @Nullable - private static PsiStatement getBody(@NotNull PsiElement element) { - final PsiElement parent = element.getParent(); - if (parent instanceof PsiIfStatement) { - final PsiIfStatement ifStatement = (PsiIfStatement)parent; - if (isBetweenThen(ifStatement, element)) { - return ifStatement.getThenBranch(); - } - - if (isBetweenElse(ifStatement, element)) { - return ifStatement.getElseBranch(); - } - } - if (parent instanceof PsiWhileStatement) { - return ((PsiWhileStatement)parent).getBody(); - } - if (parent instanceof PsiDoWhileStatement) { - return ((PsiDoWhileStatement)parent).getBody(); - } - if (parent instanceof PsiForStatement) { - return ((PsiForStatement)parent).getBody(); - } - if (parent instanceof PsiForeachStatement) { - return ((PsiForeachStatement)parent).getBody(); - } - return null; - } - - private static boolean isBetweenThen(@NotNull PsiIfStatement ifStatement, @NotNull PsiElement element) { - final PsiElement rParenth = ifStatement.getRParenth(); - final PsiElement elseElement = ifStatement.getElseElement(); - - if (rParenth == null) { - return false; - } - - if (elseElement == null) { - return true; - } - - final TextRange rParenthTextRangeTextRange = rParenth.getTextRange(); - final TextRange elseElementTextRange = elseElement.getTextRange(); - final TextRange elementTextRange = element.getTextRange(); - - return new TextRange(rParenthTextRangeTextRange.getEndOffset(), elseElementTextRange.getStartOffset()).contains(elementTextRange); - } - - private static boolean isBetweenElse(@NotNull PsiIfStatement ifStatement, @NotNull PsiElement element) { - final PsiElement elseElement = ifStatement.getElseElement(); - - if (elseElement == null) { - return false; - } - - final TextRange ifStatementTextRange = ifStatement.getTextRange(); - final TextRange elseElementTextRange = elseElement.getTextRange(); - final TextRange elementTextRange = element.getTextRange(); - - return new TextRange(elseElementTextRange.getStartOffset(), ifStatementTextRange.getEndOffset()).contains(elementTextRange); - } } \ No newline at end of file diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/BaseBracesIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/BaseBracesIntention.java new file mode 100644 index 000000000000..9b1e57afe720 --- /dev/null +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/BaseBracesIntention.java @@ -0,0 +1,115 @@ +/* + * 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.siyeh.ipp.braces; + +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.*; +import com.siyeh.IntentionPowerPackBundle; +import com.siyeh.ipp.base.MutablyNamedIntention; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Danila Ponomarenko + */ +public abstract class BaseBracesIntention extends MutablyNamedIntention { + + protected final String getTextForElement(PsiElement element) { + final PsiElement body = getSurroundingStatement(element); + if (body == null) { + return null; + } + + return IntentionPowerPackBundle.message(getMessageKey(), getKeyword(body.getParent(), body)); + } + + @NotNull + protected abstract String getMessageKey(); + + @NotNull + private static String getKeyword(@NotNull PsiElement parent, @NotNull PsiElement element) { + if (parent instanceof PsiIfStatement) { + final PsiIfStatement ifStatement = (PsiIfStatement)parent; + final PsiStatement elseBranch = ifStatement.getElseBranch(); + return element.equals(elseBranch) ? PsiKeyword.ELSE : PsiKeyword.IF; + } + final PsiElement firstChild = parent.getFirstChild(); + assert firstChild != null; + return firstChild.getText(); + } + + + @Nullable + protected static PsiStatement getSurroundingStatement(@NotNull PsiElement element) { + final PsiElement parent = element.getParent(); + if (parent instanceof PsiIfStatement) { + final PsiIfStatement ifStatement = (PsiIfStatement)parent; + if (isBetweenThen(ifStatement, element)) { + return ifStatement.getThenBranch(); + } + + if (isBetweenElse(ifStatement, element)) { + return ifStatement.getElseBranch(); + } + } + if (parent instanceof PsiWhileStatement) { + return ((PsiWhileStatement)parent).getBody(); + } + if (parent instanceof PsiDoWhileStatement) { + return ((PsiDoWhileStatement)parent).getBody(); + } + if (parent instanceof PsiForStatement) { + return ((PsiForStatement)parent).getBody(); + } + if (parent instanceof PsiForeachStatement) { + return ((PsiForeachStatement)parent).getBody(); + } + return null; + } + + private static boolean isBetweenThen(@NotNull PsiIfStatement ifStatement, @NotNull PsiElement element) { + final PsiElement rParenth = ifStatement.getRParenth(); + final PsiElement elseElement = ifStatement.getElseElement(); + + if (rParenth == null) { + return false; + } + + if (elseElement == null) { + return true; + } + + final TextRange rParenthTextRangeTextRange = rParenth.getTextRange(); + final TextRange elseElementTextRange = elseElement.getTextRange(); + final TextRange elementTextRange = element.getTextRange(); + + return new TextRange(rParenthTextRangeTextRange.getEndOffset(), elseElementTextRange.getStartOffset()).contains(elementTextRange); + } + + private static boolean isBetweenElse(@NotNull PsiIfStatement ifStatement, @NotNull PsiElement element) { + final PsiElement elseElement = ifStatement.getElseElement(); + + if (elseElement == null) { + return false; + } + + final TextRange ifStatementTextRange = ifStatement.getTextRange(); + final TextRange elseElementTextRange = elseElement.getTextRange(); + final TextRange elementTextRange = element.getTextRange(); + + return new TextRange(elseElementTextRange.getStartOffset(), ifStatementTextRange.getEndOffset()).contains(elementTextRange); + } +} diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/RemoveBracesIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/RemoveBracesIntention.java index 6998e6f516e4..658665d46555 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/RemoveBracesIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/RemoveBracesIntention.java @@ -15,52 +15,59 @@ */ package com.siyeh.ipp.braces; +import com.intellij.openapi.vfs.newvfs.impl.StubVirtualFile; import com.intellij.psi.*; import com.intellij.util.IncorrectOperationException; -import com.siyeh.IntentionPowerPackBundle; -import com.siyeh.ipp.base.MutablyNamedIntention; import com.siyeh.ipp.base.PsiElementPredicate; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -public class RemoveBracesIntention extends MutablyNamedIntention { +public class RemoveBracesIntention extends BaseBracesIntention { @NotNull protected PsiElementPredicate getElementPredicate() { - return new RemoveBracesPredicate(); + return new PsiElementPredicate() { + @Override + public boolean satisfiedBy(PsiElement element) { + final PsiStatement statement = getSurroundingStatement(element); + if (statement == null || !(statement instanceof PsiBlockStatement)) { + return false; + } + + final PsiStatement[] statements = ((PsiBlockStatement)statement).getCodeBlock().getStatements(); + if (statements.length != 1 || statements[0] instanceof PsiDeclarationStatement) { + return false; + } + final PsiFile file = statement.getContainingFile(); + //this intention doesn't work in JSP files, as it can't tell about tags + // inside the braces + return !JspPsiUtil.isInJspFile(file); + } + }; } - protected String getTextForElement(PsiElement element) { - final PsiElement parent = element.getParent(); - assert parent != null; - @NonNls final String keyword; - if (parent instanceof PsiIfStatement) { - final PsiIfStatement ifStatement = (PsiIfStatement)parent; - final PsiStatement elseBranch = ifStatement.getElseBranch(); - if (element.equals(elseBranch)) { - keyword = PsiKeyword.ELSE; - } - else { - keyword = PsiKeyword.IF; - } - } - else { - final PsiElement firstChild = parent.getFirstChild(); - assert firstChild != null; - keyword = firstChild.getText(); - } - return IntentionPowerPackBundle.message("remove.braces.intention.name", - keyword); + @NotNull + @Override + protected String getMessageKey() { + return "remove.braces.intention.name"; } protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException { - final PsiBlockStatement blockStatement = (PsiBlockStatement)element; + final PsiStatement body = getSurroundingStatement(element); + if (body == null || !(body instanceof PsiBlockStatement)) return; + final PsiBlockStatement blockStatement = (PsiBlockStatement)body; + final PsiCodeBlock codeBlock = blockStatement.getCodeBlock(); final PsiStatement[] statements = codeBlock.getStatements(); final PsiStatement statement = statements[0]; - // handle comments + handleComments(blockStatement, codeBlock); + + final String text = statement.getText(); + replaceStatement(text, blockStatement); + } + + private static void handleComments(PsiBlockStatement blockStatement, PsiCodeBlock codeBlock) { final PsiElement parent = blockStatement.getParent(); assert parent != null; final PsiElement grandParent = parent.getParent(); @@ -68,7 +75,7 @@ public class RemoveBracesIntention extends MutablyNamedIntention { PsiElement sibling = codeBlock.getFirstChild(); assert sibling != null; sibling = sibling.getNextSibling(); - while (sibling != null && !sibling.equals(statement)) { + while (sibling != null) { if (sibling instanceof PsiComment) { grandParent.addBefore(sibling, parent); } @@ -79,8 +86,5 @@ public class RemoveBracesIntention extends MutablyNamedIntention { final PsiElement nextSibling = parent.getNextSibling(); grandParent.addAfter(lastChild, nextSibling); } - - final String text = statement.getText(); - replaceStatement(text, blockStatement); } } \ No newline at end of file diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/RemoveBracesPredicate.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/RemoveBracesPredicate.java deleted file mode 100644 index a31d87e3490c..000000000000 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/braces/RemoveBracesPredicate.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2003-2006 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.siyeh.ipp.braces; - -import com.intellij.psi.*; -import com.siyeh.ipp.base.PsiElementPredicate; -import org.jetbrains.annotations.NotNull; - -class RemoveBracesPredicate implements PsiElementPredicate { - public boolean satisfiedBy(@NotNull PsiElement element) { - if (!(element instanceof PsiBlockStatement)) { - return false; - } - final PsiBlockStatement blockStatement = (PsiBlockStatement)element; - final PsiElement parent = blockStatement.getParent(); - if (!(parent instanceof PsiIfStatement || - parent instanceof PsiWhileStatement || - parent instanceof PsiDoWhileStatement || - parent instanceof PsiForStatement || - parent instanceof PsiForeachStatement)) { - return false; - } - final PsiCodeBlock codeBlock = blockStatement.getCodeBlock(); - final PsiStatement[] statements = codeBlock.getStatements(); - if (statements.length != 1 || - statements[0] instanceof PsiDeclarationStatement) { - return false; - } - final PsiFile file = element.getContainingFile(); - //this intention doesn't work in JSP files, as it can't tell about tags - // inside the braces - return !JspPsiUtil.isInJspFile(file); - } -} \ No newline at end of file From af1f165c9dea76c23caee7605082d6fe59365625 Mon Sep 17 00:00:00 2001 From: Danila Ponomarenko Date: Sun, 10 Jun 2012 18:56:01 +0400 Subject: [PATCH 071/172] IDEA-86117 boolean expressions: intentions and Unwrap/Remove unwrap implemented --- .../unwrap/JavaBinaryExpressionUnwrapper.java | 62 +++++++++++++++++++ .../unwrap/JavaMethodParameterUnwrapper.java | 2 +- .../unwrap/JavaUnwrapDescriptor.java | 3 +- .../src/messages/CodeInsightBundle.properties | 2 +- .../GroovyMethodParameterUnwrapper.java | 2 +- 5 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 java/java-impl/src/com/intellij/codeInsight/unwrap/JavaBinaryExpressionUnwrapper.java diff --git a/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaBinaryExpressionUnwrapper.java b/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaBinaryExpressionUnwrapper.java new file mode 100644 index 000000000000..3d1438e42071 --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaBinaryExpressionUnwrapper.java @@ -0,0 +1,62 @@ +/* + * 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.codeInsight.unwrap; + +import com.intellij.codeInsight.CodeInsightBundle; +import com.intellij.openapi.util.Comparing; +import com.intellij.psi.PsiBinaryExpression; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiExpression; +import com.intellij.util.IncorrectOperationException; + +/** + * @author Danila Ponomarenko + */ +public class JavaBinaryExpressionUnwrapper extends JavaUnwrapper { + public JavaBinaryExpressionUnwrapper() { + super(""); + } + + @Override + public String getDescription(PsiElement e) { + return CodeInsightBundle.message("unwrap.with.placeholder", e.getText()); + } + + @Override + public boolean isApplicableTo(PsiElement e) { + return e.getParent() instanceof PsiBinaryExpression; + } + + @Override + protected void doUnwrap(PsiElement element, Context context) throws IncorrectOperationException { + final PsiBinaryExpression parent = (PsiBinaryExpression)element.getParent(); + + final PsiExpression lOperand = parent.getLOperand(); + final PsiExpression rOperand = parent.getROperand(); + + if (rOperand == null) { + return; + } + + if (Comparing.equal(lOperand, element)) { + context.extractElement(rOperand, parent); + } + else { + context.extractElement(lOperand, parent); + } + context.delete(parent); + } +} diff --git a/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaMethodParameterUnwrapper.java b/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaMethodParameterUnwrapper.java index 42704f238231..c0b79edc33cb 100644 --- a/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaMethodParameterUnwrapper.java +++ b/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaMethodParameterUnwrapper.java @@ -32,7 +32,7 @@ public class JavaMethodParameterUnwrapper extends JavaUnwrapper { public String getDescription(PsiElement e) { String text = e.getText(); if (text.length() > 20) text = text.substring(0, 17) + "..."; - return CodeInsightBundle.message("unwrap.method.parameter", text); + return CodeInsightBundle.message("unwrap.with.placeholder", text); } public boolean isApplicableTo(PsiElement e) { diff --git a/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaUnwrapDescriptor.java b/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaUnwrapDescriptor.java index 7a5a48883908..f3dc91b8cdb6 100644 --- a/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaUnwrapDescriptor.java +++ b/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaUnwrapDescriptor.java @@ -32,7 +32,8 @@ public class JavaUnwrapDescriptor extends UnwrapDescriptorBase { new JavaCatchRemover(), new JavaSynchronizedUnwrapper(), new JavaAnonymousUnwrapper(), - new JavaConditionalUnwrapper() + new JavaConditionalUnwrapper(), + new JavaBinaryExpressionUnwrapper() }; } } diff --git a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties index 17413a924376..629ad188ee85 100644 --- a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties +++ b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties @@ -87,7 +87,7 @@ unwrap.try=Unwrap 'try...' unwrap.conditional=Unwrap 'f ? a : b' remove.catch=Remove 'catch...' unwrap.synchronized=Unwrap 'synchronized...' -unwrap.method.parameter=Unwrap ''{0}'' +unwrap.with.placeholder=Unwrap ''{0}'' unwrap.anonymous=Unwrap 'anonymous...' generate.equals.hashcode.wizard.title=Generate equals() and hashCode() generate.equals.hashcode.equals.fields.chooser.title=Choose &fields to be included in equals() diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/unwrap/GroovyMethodParameterUnwrapper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/unwrap/GroovyMethodParameterUnwrapper.java index 754ca20cd877..547de92f533f 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/unwrap/GroovyMethodParameterUnwrapper.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/unwrap/GroovyMethodParameterUnwrapper.java @@ -32,7 +32,7 @@ public class GroovyMethodParameterUnwrapper extends GroovyUnwrapper { public String getDescription(PsiElement e) { String text = e.getText(); if (text.length() > 20) text = text.substring(0, 17) + "..."; - return CodeInsightBundle.message("unwrap.method.parameter", text); + return CodeInsightBundle.message("unwrap.with.placeholder", text); } public boolean isApplicableTo(PsiElement e) { From 36980e0d415211a4d5b4d998859a0f2dafbfa577 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 11 Jun 2012 09:19:29 +0200 Subject: [PATCH 072/172] delete old-style resolve of exported names and some other code which isn't used any more --- platform/platform-resources-en/src/misc/registry.properties | 2 -- 1 file changed, 2 deletions(-) diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index c3adfb7970d6..51db7ac1bef9 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -225,8 +225,6 @@ vcs.remote.management.ready=false type.ahead.logging.enabled=false fast.tree.expand.in.structure.view=false -python.exported.names.local.cache=false - ide.use.nautilus3=true ide.use.nautilus3.description=Use Nautilus if available From 4a54b1e713fcb84723aa32cc21739c68803a4e15 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Fri, 8 Jun 2012 17:15:06 +0200 Subject: [PATCH 073/172] AppCode: duplication removed --- .../openapi/projectRoots/impl/SdkConfigurationUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/SdkConfigurationUtil.java b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/SdkConfigurationUtil.java index 3cc157a9291d..91bca1ccdaa4 100644 --- a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/SdkConfigurationUtil.java +++ b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/SdkConfigurationUtil.java @@ -168,7 +168,7 @@ public class SdkConfigurationUtil { return sdk; } - public static void setDirectoryProjectSdk(@NotNull final Project project, final Sdk sdk) { + public static void setDirectoryProjectSdk(@NotNull final Project project, @Nullable final Sdk sdk) { ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { ProjectRootManager.getInstance(project).setProjectSdk(sdk); From 134fb9190172498aa0be189624db1a3003a0b5e8 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 11 Jun 2012 11:36:25 +0200 Subject: [PATCH 074/172] don't try to highlight name identifier ranges which are empty or invalid (EA-33987 - assert: ProperTextRange.) --- .../codeInsight/highlighting/HighlightUsagesHandler.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightUsagesHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightUsagesHandler.java index e68bcb345be5..f91feb6c5613 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightUsagesHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightUsagesHandler.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. @@ -268,6 +268,9 @@ public class HighlightUsagesHandler extends HighlightHandlerBase { final PsiDeclaredTarget declaredTarget = (PsiDeclaredTarget)target; final TextRange range = declaredTarget.getNameIdentifierRange(); if (range != null) { + if (range.getStartOffset() < 0 || range.getLength() <= 0) { + return null; + } final PsiElement navElement = declaredTarget.getNavigationElement(); if (PsiUtilBase.isUnderPsiRoot(file, navElement)) { return injectedManager.injectedToHost(navElement, range.shiftRight(navElement.getTextRange().getStartOffset())); From 75adf14cdb78dba184d2cd75f11b9b8b9dbf9cb0 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 11 Jun 2012 11:43:43 +0200 Subject: [PATCH 075/172] fix exception under JDK 7 (EA-28757 - ISE: TabLabel.paintOffscreen, IDEA-79916) --- .../platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java index 0c512c632510..ac455afd4848 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java @@ -139,7 +139,9 @@ public class TabLabel extends JPanel { } public void paintOffscreen(Graphics g) { - validateTree(); + synchronized(getTreeLock()) { + validateTree(); + } doPaint(g); } From a183d29f7ed67fc7399fe6b9b266bfbf814981d9 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 11 Jun 2012 11:47:08 +0200 Subject: [PATCH 076/172] defensive copy to prevent CME (EA-36064 - CME: JBTabsImpl.updateContainer) --- .../platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java index f0623fa5895c..20c3a1753343 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java @@ -2443,7 +2443,7 @@ public class JBTabsImpl extends JComponent } private void updateContainer(boolean forced, final boolean layoutNow) { - for (TabInfo each : myVisibleInfos) { + for (TabInfo each : new ArrayList(myVisibleInfos)) { final JComponent eachComponent = each.getComponent(); if (getSelectedInfo() == each && getSelectedInfo() != null) { unqueueFromRemove(eachComponent); From f0bf4306b6b5b87b07f678046318772fc5fd8231 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 11 Jun 2012 13:59:28 +0200 Subject: [PATCH 077/172] EA-36371 - SIOOBE: ChooseByNamePopup.getPathToAnonymous --- .../com/intellij/ide/util/gotoByName/ChooseByNamePopup.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java index e938b1786640..bce981756da1 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.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. @@ -343,7 +343,7 @@ public class ChooseByNamePopup extends ChooseByNameBase implements ChooseByNameP String path = matcher.group(2); if (path != null) { path = path.trim(); - if (path.endsWith("$")) { + if (path.endsWith("$") && path.length() >= 2) { path = path.substring(0, path.length() - 2); } if (!path.isEmpty()) return path; From 844f2641b1f03f728f63e92b57ac9f54b1225918 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 11 Jun 2012 14:06:56 +0200 Subject: [PATCH 078/172] EA-36449 - NPE: IntentionSettingsConfigurable.isModified --- .../intention/impl/config/IntentionSettingsConfigurable.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsConfigurable.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsConfigurable.java index cf2ebaea9d26..775756da4373 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsConfigurable.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsConfigurable.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. @@ -65,7 +65,7 @@ public class IntentionSettingsConfigurable extends BaseConfigurable implements S } public boolean isModified() { - return myPanel.isModified(); + return myPanel != null && myPanel.isModified(); } public String getDisplayName() { From d444c027f44ea469e81dfb3eaf3188c95d96ce4c Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 11 Jun 2012 14:39:44 +0200 Subject: [PATCH 079/172] EA-36079 - NPE: PsiViewerDialog$EditorListener.selectionChanged --- .../src/com/intellij/internal/psiView/PsiViewerDialog.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java b/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java index cfb74dc28a0a..2d2e929b8967 100644 --- a/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java +++ b/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java @@ -1247,9 +1247,9 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider, Disp ViewerTreeStructure treeStructure = (ViewerTreeStructure)myPsiTreeBuilder.getTreeStructure(); if (treeStructure == null) return; final PsiElement rootElement = treeStructure.getRootPsiElement(); + if (rootElement == null) return; final SelectionModel selection = myEditor.getSelectionModel(); - PsiElement rootPsiElement = treeStructure.getRootPsiElement(); - final TextRange textRange = rootPsiElement.getTextRange(); + final TextRange textRange = rootElement.getTextRange(); int baseOffset = textRange != null ? textRange.getStartOffset() : 0; final int start = selection.getSelectionStart()+baseOffset; final int end = selection.getSelectionEnd()+baseOffset - 1; From a1038d6bdbebfcd4c147d4ba71f3a6d8da0b0b32 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 11 Jun 2012 14:59:10 +0200 Subject: [PATCH 080/172] Undo: undo is now available in the current file, even if it is not affected by the document change (OC-3902, IDEA-55193) --- .../openapi/command/impl/UndoManagerImpl.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoManagerImpl.java index 3339ea90dadd..82741248cd9a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoManagerImpl.java @@ -252,12 +252,42 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap if (myCommandLevel == 0) return; // possible if command listener was added within command myCommandLevel--; if (myCommandLevel > 0) return; + + if (myProject != null && myCurrentMerger.hasActions() && !myCurrentMerger.isGlobal()) { + addFocusedDocumentAsAffected(); + } + myCurrentMerger.setAfterState(getCurrentState()); myMerger.commandFinished(commandName, groupId, myCurrentMerger); disposeCurrentMerger(); } + private void addFocusedDocumentAsAffected() { + VirtualFile[] selected = FileEditorManager.getInstance(myProject).getSelectedFiles(); + if (selected.length == 0) return; + + final DocumentReference[] refs = new DocumentReference[selected.length]; + for (int i = 0; i < refs.length; i++) { + refs[i] = DocumentReferenceManager.getInstance().create(selected[i]); + } + + myCurrentMerger.addAction(new BasicUndoableAction() { + @Override + public void undo() throws UnexpectedUndoException { + } + + @Override + public void redo() throws UnexpectedUndoException { + } + + @Override + public DocumentReference[] getAffectedDocuments() { + return refs; + } + }); + } + private EditorAndState getCurrentState() { FileEditor editor = myEditorProvider.getCurrentEditor(); if (editor == null) { @@ -598,7 +628,8 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap @TestOnly private void flushMergers() { // Run dummy command in order to flush all mergers... - CommandProcessor.getInstance().executeCommand(myProject, EmptyRunnable.getInstance(), CommonBundle.message("drop.undo.history.command.name"), null); + CommandProcessor.getInstance() + .executeCommand(myProject, EmptyRunnable.getInstance(), CommonBundle.message("drop.undo.history.command.name"), null); } @TestOnly From d772e3bdd151c65d00033426fb41e5d0fd6abc69 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 11 Jun 2012 15:22:33 +0200 Subject: [PATCH 081/172] IDE-specific default masks for searching in files (PY-6718) --- .../intellij/find/impl/FindSettingsImpl.java | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindSettingsImpl.java b/platform/lang-impl/src/com/intellij/find/impl/FindSettingsImpl.java index e09e8f129f45..3a0e76644bd4 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindSettingsImpl.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindSettingsImpl.java @@ -29,6 +29,7 @@ import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMExternalizableStringList; import com.intellij.openapi.util.WriteExternalException; import com.intellij.util.ArrayUtil; +import com.intellij.util.PlatformUtils; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -55,6 +56,26 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom private static final int MAX_RECENT_SIZE = 30; + public FindSettingsImpl() { + RECENT_FILE_MASKS.add("*.properties"); + RECENT_FILE_MASKS.add("*.html"); + RECENT_FILE_MASKS.add("*.jsp"); + RECENT_FILE_MASKS.add("*.xml"); + RECENT_FILE_MASKS.add("*.java"); + RECENT_FILE_MASKS.add("*.js"); + RECENT_FILE_MASKS.add("*.as"); + RECENT_FILE_MASKS.add("*.css"); + RECENT_FILE_MASKS.add("*.mxml"); + if (PlatformUtils.isPyCharm()) { + RECENT_FILE_MASKS.add("*.py"); + } + else if (PlatformUtils.isRubyMine()) { + RECENT_FILE_MASKS.add("*.rb"); + } + else if (PlatformUtils.isPhpStorm()) { + RECENT_FILE_MASKS.add("*.php"); + } + } @Override public boolean isSearchOverloadedMethods() { @@ -103,20 +124,6 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom catch (InvalidDataException e) { LOG.info(e); } - if (RECENT_FILE_MASKS.isEmpty()) { - RECENT_FILE_MASKS.add("*.properties"); - RECENT_FILE_MASKS.add("*.html"); - RECENT_FILE_MASKS.add("*.jsp"); - RECENT_FILE_MASKS.add("*.xml"); - RECENT_FILE_MASKS.add("*.java"); - RECENT_FILE_MASKS.add("*.php"); - RECENT_FILE_MASKS.add("*.js"); - RECENT_FILE_MASKS.add("*.as"); - RECENT_FILE_MASKS.add("*.css"); - RECENT_FILE_MASKS.add("*.mxml"); - RECENT_FILE_MASKS.add("*.py"); - RECENT_FILE_MASKS.add("*.rb"); - } } @Override From 2986a63e1a9c2530edc3693fa09a377af4bfd5e5 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 11 Jun 2012 16:47:18 +0200 Subject: [PATCH 082/172] less brain-dead way of calculating array size when reallocating (IDEA-73303) --- .../openapi/editor/ex/util/SegmentArray.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/platform/core-impl/src/com/intellij/openapi/editor/ex/util/SegmentArray.java b/platform/core-impl/src/com/intellij/openapi/editor/ex/util/SegmentArray.java index 5d27e366e4f6..1a254ff25812 100644 --- a/platform/core-impl/src/com/intellij/openapi/editor/ex/util/SegmentArray.java +++ b/platform/core-impl/src/com/intellij/openapi/editor/ex/util/SegmentArray.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. @@ -72,8 +72,11 @@ public class SegmentArray { if (newArraySize == 0) { newArraySize = 16; } - while (newArraySize <= index) { - newArraySize = newArraySize * 120 / 100; + else { + newArraySize = newArraySize * 12 / 10; + } + if (index >= newArraySize) { + newArraySize = index * 12 / 10; } int[] newArray = new int[newArraySize]; System.arraycopy(array, 0, newArray, 0, array.length); @@ -89,8 +92,11 @@ public class SegmentArray { if (newArraySize == 0) { newArraySize = 16; } - while (newArraySize <= index) { - newArraySize = newArraySize * 120 / 100; + else { + newArraySize = newArraySize * 12 / 10; + } + if (index >= newArraySize) { + newArraySize = index * 12 / 10; } T[] newArray = (T[])Array.newInstance(array.getClass().getComponentType(), newArraySize); @@ -107,9 +113,12 @@ public class SegmentArray { if (newArraySize == 0) { newArraySize = 16; } - while (newArraySize <= index) { + else { newArraySize = newArraySize * 12 / 10; } + if (index >= newArraySize) { + newArraySize = index * 12 / 10; + } short[] newArray = new short[newArraySize]; System.arraycopy(array, 0, newArray, 0, array.length); return newArray; From e9228017d1f7b514231d0103370ac99d4c492b05 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Tue, 12 Jun 2012 11:07:50 +0200 Subject: [PATCH 083/172] AppCode:Execution: stop running session is now a project-wide setting (OC-4013) --- .../RunConfigurationsSettings.java | 27 ++++++++++ .../execution/impl/RunConfigurable.java | 54 ++++++++++++++++--- .../src/META-INF/LangExtensionPoints.xml | 3 ++ 3 files changed, 77 insertions(+), 7 deletions(-) create mode 100644 platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationsSettings.java diff --git a/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationsSettings.java b/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationsSettings.java new file mode 100644 index 000000000000..732976cf73a7 --- /dev/null +++ b/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationsSettings.java @@ -0,0 +1,27 @@ +/* + * 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.execution.configurations; + +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.options.UnnamedConfigurable; +import org.jetbrains.annotations.NotNull; + +public interface RunConfigurationsSettings { + ExtensionPointName EXTENSION_POINT = ExtensionPointName.create("com.intellij.runConfigurationsSettings"); + + @NotNull + UnnamedConfigurable createConfigurable(); +} \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.java b/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.java index b132670a75e3..40ae8e7048f4 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.java @@ -22,6 +22,7 @@ import com.intellij.execution.configurations.*; import com.intellij.icons.AllIcons; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.options.*; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; @@ -32,6 +33,7 @@ import com.intellij.openapi.ui.popup.ListPopupStep; import com.intellij.openapi.ui.popup.PopupStep; import com.intellij.openapi.ui.popup.util.BaseListPopupStep; import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.*; import com.intellij.ui.components.JBScrollPane; @@ -43,10 +45,10 @@ import com.intellij.util.config.StorageAccessors; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.Convertor; import com.intellij.util.containers.HashMap; +import com.intellij.util.ui.GridBag; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.tree.TreeUtil; import gnu.trove.THashSet; -import net.miginfocom.swing.MigLayout; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -65,6 +67,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; class RunConfigurable extends BaseConfigurable { + private static final Icon ADD_ICON = IconUtil.getAddIcon(); private static final Icon REMOVE_ICON = IconUtil.getRemoveIcon(); @NonNls private static final String DIVIDER_PROPORTION = "dividerProportion"; @@ -84,6 +87,7 @@ class RunConfigurable extends BaseConfigurable { private static final Logger LOG = Logger.getInstance("#com.intellij.execution.impl.RunConfigurable"); private final JTextField myRecentsLimit = new JTextField("5", 2); private final JCheckBox myConfirmation = new JCheckBox(ExecutionBundle.message("rerun.confirmation.checkbox"), true); + private final List> myAdditionalSettings = new ArrayList>(); private Map myStoredComponents = new HashMap(); public RunConfigurable(final Project project) { @@ -392,7 +396,19 @@ class RunConfigurable extends BaseConfigurable { myRightPanel.removeAll(); myRightPanel.add(scrollPane, BorderLayout.CENTER); if (configurationType == null) { - myRightPanel.add(createRecentLimitPanel(), BorderLayout.SOUTH); + JPanel settingsPanel = new JPanel(new GridBagLayout()); + GridBag grid = new GridBag().setDefaultAnchor(GridBagConstraints.NORTHWEST); + + for (Pair each : myAdditionalSettings) { + settingsPanel.add(each.second, grid.nextLine().next()); + } + settingsPanel.add(createSettingsPanel(), grid.nextLine().next()); + + JPanel wrapper = new JPanel(new BorderLayout()); + wrapper.add(settingsPanel, BorderLayout.WEST); + wrapper.add(Box.createGlue(), BorderLayout.CENTER); + + myRightPanel.add(wrapper, BorderLayout.SOUTH); } myRightPanel.revalidate(); myRightPanel.repaint(); @@ -412,12 +428,14 @@ class RunConfigurable extends BaseConfigurable { return leftPanel; } - private JPanel createRecentLimitPanel() { - final JPanel bottomPanel = new JPanel(new MigLayout("ins 5, gap 5")); + private JPanel createSettingsPanel() { + JPanel bottomPanel = new JPanel(new GridBagLayout()); + GridBag g = new GridBag(); + + bottomPanel.add(myConfirmation, g.nextLine().coverLine()); + bottomPanel.add(new JLabel("Temporary configurations limit:"), g.nextLine().next()); + bottomPanel.add(myRecentsLimit, g.next().anchor(GridBagConstraints.WEST)); - bottomPanel.add(new JLabel("Temporary configurations limit:")); - bottomPanel.add(myRecentsLimit, "wrap, h pref!, w pref!"); - bottomPanel.add(myConfirmation, "spanx 2"); myRecentsLimit.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { @@ -475,6 +493,11 @@ class RunConfigurable extends BaseConfigurable { } public JComponent createComponent() { + for (RunConfigurationsSettings each : Extensions.getExtensions(RunConfigurationsSettings.EXTENSION_POINT)) { + UnnamedConfigurable configurable = each.createConfigurable(); + myAdditionalSettings.add(Pair.create(configurable, configurable.createComponent())); + } + myWholePanel = new JPanel(new BorderLayout()); mySplitter.setFirstComponent(createLeftPanel()); mySplitter.setSecondComponent(myRightPanel); @@ -497,6 +520,11 @@ class RunConfigurable extends BaseConfigurable { final RunManagerConfig config = manager.getConfig(); myRecentsLimit.setText(Integer.toString(config.getRecentsLimit())); myConfirmation.setSelected(config.isRestartRequiresConfirmation()); + + for (Pair each : myAdditionalSettings) { + each.first.reset(); + } + setModified(false); } @@ -545,6 +573,10 @@ class RunConfigurable extends BaseConfigurable { } } + for (Pair each : myAdditionalSettings) { + each.first.apply(); + } + manager.saveOrder(); setModified(false); } @@ -683,6 +715,10 @@ class RunConfigurable extends BaseConfigurable { if (configurable.isModified()) return true; } + for (Pair each : myAdditionalSettings) { + if (each.first.isModified()) return true; + } + return false; } @@ -693,6 +729,10 @@ class RunConfigurable extends BaseConfigurable { } myStoredComponents.clear(); + for (Pair each : myAdditionalSettings) { + each.first.disposeUIResources(); + } + TreeUtil.traverseDepth(myRoot, new TreeUtil.Traverse() { public boolean accept(Object node) { if (node instanceof DefaultMutableTreeNode) { diff --git a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml index 8fd73d58f75d..30b87276a330 100644 --- a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml @@ -267,6 +267,9 @@ + + From 70a83dc3c3086c2f49edb87479c5301b9618fda8 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 12 Jun 2012 13:14:16 +0200 Subject: [PATCH 084/172] @Nullable --- .../src/com/intellij/lang/LanguagePerFileMappings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/lang/LanguagePerFileMappings.java b/platform/lang-impl/src/com/intellij/lang/LanguagePerFileMappings.java index d0062512e0e3..d5a4fa9703f8 100644 --- a/platform/lang-impl/src/com/intellij/lang/LanguagePerFileMappings.java +++ b/platform/lang-impl/src/com/intellij/lang/LanguagePerFileMappings.java @@ -137,7 +137,7 @@ public abstract class LanguagePerFileMappings implements PersistentStateCompo handleMappingChange(mappings.keySet(), oldFiles, !getProject().isDefault()); } - public void setMapping(final VirtualFile file, T dialect) { + public void setMapping(@Nullable final VirtualFile file, @Nullable T dialect) { synchronized (myMappings) { if (dialect == null) { myMappings.remove(file); From ad2c94d35b11484faeaa47af387272c176cfbf08 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Tue, 12 Jun 2012 14:42:19 +0200 Subject: [PATCH 085/172] AppCode:Debugger: debugger driver is now application-wide choice (Settings->Debugger) --- ...gurationAction.java => RunConfigurationsComboBoxAction.java} | 2 +- platform/platform-resources/src/idea/LangActions.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename platform/lang-impl/src/com/intellij/execution/actions/{RunConfigurationAction.java => RunConfigurationsComboBoxAction.java} (99%) diff --git a/platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationAction.java b/platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationsComboBoxAction.java similarity index 99% rename from platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationAction.java rename to platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationsComboBoxAction.java index 44a934ee0e2a..8b8535f85fe5 100644 --- a/platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationAction.java +++ b/platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationsComboBoxAction.java @@ -41,7 +41,7 @@ import javax.swing.*; import java.awt.*; import java.util.ArrayList; -public class RunConfigurationAction extends ComboBoxAction implements DumbAware { +public class RunConfigurationsComboBoxAction extends ComboBoxAction implements DumbAware { private static final Logger LOG = Logger.getInstance("#com.intellij.execution.actions.RunConfigurationAction"); private static final Key BUTTON_KEY = Key.create("COMBOBOX_BUTTON"); diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml index 900de7e35567..7422ec6184f8 100644 --- a/platform/platform-resources/src/idea/LangActions.xml +++ b/platform/platform-resources/src/idea/LangActions.xml @@ -7,7 +7,7 @@ - + From 58cdac880c822a643aacde81e6a557ca400853d6 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 12 Jun 2012 17:06:47 +0400 Subject: [PATCH 086/172] IDEA-87332 When autoscroll to source is on, clicking a jar file pops up Project Structure --- .../com/intellij/ide/projectView/impl/nodes/PsiFileNode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiFileNode.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiFileNode.java index f2661471450f..b53889ffb4d1 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiFileNode.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiFileNode.java @@ -103,7 +103,7 @@ public class PsiFileNode extends BasePsiNode implements NavigatableWith public void navigate(boolean requestFocus) { VirtualFile jarRoot = getJarRoot(); final Project project = getProject(); - if (jarRoot != null && ProjectRootsUtil.isLibraryRoot(jarRoot, project)) { + if (requestFocus && jarRoot != null && ProjectRootsUtil.isLibraryRoot(jarRoot, project)) { final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(jarRoot, project); if (orderEntry != null) { ProjectSettingsService.getInstance(project).openLibraryOrSdkSettings(orderEntry); From 2526988d9c0552c2a7d7f2db7f695048990807fa Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Tue, 12 Jun 2012 15:40:32 +0200 Subject: [PATCH 087/172] IDEA-87299 (quickfix: replace 'StringBuilder' with 'String' is incorrect) --- ...ngBufferReplaceableByStringInspection.java | 19 ++++++++++++------- .../replace_with_string/NonString1.after.java | 8 ++++++++ .../style/replace_with_string/NonString1.java | 8 ++++++++ .../replace_with_string/NonString2.after.java | 8 ++++++++ .../style/replace_with_string/NonString2.java | 8 ++++++++ ...ingBufferReplaceableWithStringFixTest.java | 17 ++--------------- 6 files changed, 46 insertions(+), 22 deletions(-) create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString1.after.java create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString1.java create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString2.after.java create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString2.java diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java index d642e1831b8b..7b12147c0e9f 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java @@ -86,7 +86,6 @@ public class StringBufferReplaceableByStringInspection extends BaseInspection { if (stringExpression != null && stringBuilderExpression != null) { replaceExpression(stringBuilderExpression, stringExpression.toString()); } - return; } return; } @@ -111,9 +110,9 @@ public class StringBufferReplaceableByStringInspection extends BaseInspection { } @Nullable - private static StringBuilder buildStringExpression(PsiExpression initializer, StringBuilder result) { - if (initializer instanceof PsiNewExpression) { - final PsiNewExpression newExpression = (PsiNewExpression)initializer; + private static StringBuilder buildStringExpression(PsiExpression expression, StringBuilder result) { + if (expression instanceof PsiNewExpression) { + final PsiNewExpression newExpression = (PsiNewExpression)expression; final PsiExpressionList argumentList = newExpression.getArgumentList(); if (argumentList == null) { return null; @@ -124,16 +123,19 @@ public class StringBufferReplaceableByStringInspection extends BaseInspection { final PsiType type = argument.getType(); if (!PsiType.INT.equals(type)) { result.append(argument.getText()); + if (type != null && type.equalsToText("java.lang.CharSequence")) { + result.append(".toString()"); + } } } - final PsiElement parent = initializer.getParent(); + final PsiElement parent = expression.getParent(); if (result.length() == 0 && parent instanceof PsiVariable) { result.append("\"\""); } return result; } - else if (initializer instanceof PsiMethodCallExpression) { - final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)initializer; + else if (expression instanceof PsiMethodCallExpression) { + final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)expression; final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression(); final PsiExpression qualifier = methodExpression.getQualifierExpression(); result = buildStringExpression(qualifier, result); @@ -173,6 +175,9 @@ public class StringBufferReplaceableByStringInspection extends BaseInspection { } else { result.append(argument.getText()); + if (type != null && !type.equalsToText(CommonClassNames.JAVA_LANG_STRING)) { + result.append(".toString()"); + } } } } diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString1.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString1.after.java new file mode 100644 index 000000000000..b1d2560216d3 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString1.after.java @@ -0,0 +1,8 @@ +package com.siyeh.igfixes.style.replace_with_string; + +class NonString1 { + + String foo(CharSequence text) { + return text.toString(); + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString1.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString1.java new file mode 100644 index 000000000000..373df173bf70 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString1.java @@ -0,0 +1,8 @@ +package com.siyeh.igfixes.style.replace_with_string; + +class NonString1 { + + String foo(CharSequence text) { + return new StringBuilder(text).toString(); + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString2.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString2.after.java new file mode 100644 index 000000000000..bf867ce0efdd --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString2.after.java @@ -0,0 +1,8 @@ +package com.siyeh.igfixes.style.replace_with_string; + +class NonString2 { + + String foo(Object o) { + return o.toString(); + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString2.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString2.java new file mode 100644 index 000000000000..8005bbcbf376 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString2.java @@ -0,0 +1,8 @@ +package com.siyeh.igfixes.style.replace_with_string; + +class NonString2 { + + String foo(Object o) { + return new StringBuilder().append(o).toString(); + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/style/StringBufferReplaceableWithStringFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/style/StringBufferReplaceableWithStringFixTest.java index bbcd239687cc..0fbcea0f3655 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/style/StringBufferReplaceableWithStringFixTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/style/StringBufferReplaceableWithStringFixTest.java @@ -1,18 +1,3 @@ -/* - * Copyright 2012 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.siyeh.ig.fixes.style; import com.siyeh.InspectionGadgetsBundle; @@ -37,4 +22,6 @@ public class StringBufferReplaceableWithStringFixTest extends IGQuickFixesTestCa public void testPrecedence() { doTest("Precedence", InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); } public void testPrecedence2() { doTest("Precedence2", InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); } public void testPrecedence3() { doTest("Precedence3", InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); } + public void testNonString1() { doTest("Precedence3", InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); } + public void testNonString2() { doTest("Precedence3", InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); } } From f69b4012af66238e00131f5ac47b3dcd8df1036e Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Tue, 12 Jun 2012 16:01:05 +0200 Subject: [PATCH 088/172] IDEA-87080 (False positives from inspection "Serializable class without 'serialVersionUID'") --- ...bleHasSerialVersionUIDFieldInspection.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableHasSerialVersionUIDFieldInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableHasSerialVersionUIDFieldInspection.java index 804498f194f4..49edb30014e0 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableHasSerialVersionUIDFieldInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableHasSerialVersionUIDFieldInspection.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. @@ -25,8 +25,7 @@ import com.siyeh.ig.psiutils.SerializationUtils; import org.intellij.lang.annotations.Pattern; import org.jetbrains.annotations.NotNull; -public class SerializableHasSerialVersionUIDFieldInspection - extends SerializableInspection { +public class SerializableHasSerialVersionUIDFieldInspection extends SerializableInspection { @Pattern("[a-zA-Z_0-9.-]+") @Override @@ -59,32 +58,32 @@ public class SerializableHasSerialVersionUIDFieldInspection return new SerializableHasSerialVersionUIDFieldVisitor(); } - private class SerializableHasSerialVersionUIDFieldVisitor - extends BaseInspectionVisitor { + private class SerializableHasSerialVersionUIDFieldVisitor extends BaseInspectionVisitor { @Override public void visitClass(@NotNull PsiClass aClass) { - // no call to super, so it doesn't drill down - if (aClass.isInterface() || aClass.isAnnotationType() || - aClass.isEnum()) { + if (aClass.isInterface() || aClass.isAnnotationType() || aClass.isEnum()) { return; } - if (aClass instanceof PsiTypeParameter || - aClass instanceof PsiEnumConstantInitializer) { + if (aClass instanceof PsiTypeParameter || aClass instanceof PsiEnumConstantInitializer) { return; } - if (ignoreAnonymousInnerClasses && - aClass instanceof PsiAnonymousClass) { + if (ignoreAnonymousInnerClasses && aClass instanceof PsiAnonymousClass) { return; } - final PsiField serialVersionUIDField = aClass.findFieldByName( - HardcodedMethodConstants.SERIAL_VERSION_UID, false); + final PsiField serialVersionUIDField = aClass.findFieldByName(HardcodedMethodConstants.SERIAL_VERSION_UID, false); if (serialVersionUIDField != null) { return; } if (!SerializationUtils.isSerializable(aClass)) { return; } + final PsiMethod[] methods = aClass.findMethodsByName("writeReplace", true); + for (PsiMethod method : methods) { + if (SerializationUtils.isWriteReplace(method)) { + return; + } + } if (isIgnoredSubclass(aClass)) { return; } From 61b7d0c997c99e9bcfb439ee7a7e3190cf209d6a Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 12 Jun 2012 18:43:09 +0400 Subject: [PATCH 089/172] IDEA-60295 Modules UML diagram: allow to rename module and library --- .../openapi/actionSystem/LangDataKeys.java | 4 + .../projectView/impl/RenameModuleHandler.java | 2 +- .../impl/libraries/RenameLibraryHandler.java | 129 ++++++++++++++++++ .../src/messages/IdeBundle.properties | 2 + resources/src/idea/RichPlatformPlugin.xml | 1 + 5 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/RenameLibraryHandler.java diff --git a/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java b/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java index df9badfb808e..0150e9b5ba69 100644 --- a/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java +++ b/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java @@ -21,6 +21,7 @@ import com.intellij.ide.IdeView; import com.intellij.lang.Language; import com.intellij.openapi.module.ModifiableModuleModel; import com.intellij.openapi.module.Module; +import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.ui.popup.JBPopup; import com.intellij.openapi.util.Condition; import com.intellij.psi.PsiElement; @@ -58,4 +59,7 @@ public class LangDataKeys extends PlatformDataKeys { public static final DataKey POSITION_ADJUSTER_POPUP = DataKey.create("chooseByNameDropDown"); public static final DataKey PARENT_POPUP = DataKey.create("chooseByNamePopup"); + + + public static final DataKey LIBRARY = DataKey.create("project.model.library"); } diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/RenameModuleHandler.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/RenameModuleHandler.java index 2ec203bf6131..f38dedb29047 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/RenameModuleHandler.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/RenameModuleHandler.java @@ -46,6 +46,7 @@ import org.jetbrains.annotations.Nullable; /** * @author dsl */ + public class RenameModuleHandler implements RenameHandler, TitledHandler { private static final Logger LOG = Logger.getInstance("#com.intellij.ide.projectView.actions.RenameModuleHandler"); @@ -80,7 +81,6 @@ public class RenameModuleHandler implements RenameHandler, TitledHandler { private static class MyInputValidator implements InputValidator { private final Project myProject; private final Module myModule; - public MyInputValidator(Project project, Module module) { myProject = project; myModule = module; diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/RenameLibraryHandler.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/RenameLibraryHandler.java new file mode 100644 index 000000000000..501201fffeb1 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/RenameLibraryHandler.java @@ -0,0 +1,129 @@ +/* + * 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.roots.impl.libraries; + +import com.intellij.ide.IdeBundle; +import com.intellij.ide.TitledHandler; +import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.actionSystem.LangDataKeys; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.command.CommandProcessor; +import com.intellij.openapi.command.undo.BasicUndoableAction; +import com.intellij.openapi.command.undo.UndoManager; +import com.intellij.openapi.command.undo.UndoableAction; +import com.intellij.openapi.command.undo.UnexpectedUndoException; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.libraries.Library; +import com.intellij.openapi.ui.InputValidator; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.util.Ref; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.refactoring.rename.RenameHandler; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Konstantin Bulenkov + */ +public class RenameLibraryHandler implements RenameHandler, TitledHandler { + private static final Logger LOG = Logger.getInstance("#com.intellij.ide.projectView.actions.RenameModuleHandler"); + + public boolean isAvailableOnDataContext(DataContext dataContext) { + Library library = LangDataKeys.LIBRARY.getData(dataContext); + return library != null; + } + + public boolean isRenaming(DataContext dataContext) { + return isAvailableOnDataContext(dataContext); + } + + public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) { + LOG.assertTrue(false); + } + + public void invoke(@NotNull final Project project, @NotNull PsiElement[] elements, @NotNull DataContext dataContext) { + final Library library = LangDataKeys.LIBRARY.getData(dataContext); + LOG.assertTrue(library != null); + Messages.showInputDialog(project, + IdeBundle.message("prompt.enter.new.library.name"), + IdeBundle.message("title.rename.library"), + Messages.getQuestionIcon(), + library.getName(), + new MyInputValidator(project, library)); + } + + public String getActionTitle() { + return IdeBundle.message("title.rename.library"); + } + + private static class MyInputValidator implements InputValidator { + private final Project myProject; + private final Library myLibrary; + public MyInputValidator(Project project, Library library) { + myProject = project; + myLibrary = library; + } + + public boolean checkInput(String inputString) { + return inputString != null && inputString.length() > 0 && myLibrary.getTable().getLibraryByName(inputString) == null; + } + + public boolean canClose(final String inputString) { + final String oldName = myLibrary.getName(); + final Library.ModifiableModel modifiableModel = renameLibrary(inputString); + if (modifiableModel == null) return false; + final Ref success = Ref.create(Boolean.TRUE); + CommandProcessor.getInstance().executeCommand(myProject, new Runnable() { + public void run() { + UndoableAction action = new BasicUndoableAction() { + public void undo() throws UnexpectedUndoException { + final Library.ModifiableModel modifiableModel = renameLibrary(oldName); + if (modifiableModel != null) { + modifiableModel.commit(); + } + } + + @Override + public void redo() throws UnexpectedUndoException { + final Library.ModifiableModel modifiableModel = renameLibrary(inputString); + if (modifiableModel != null) { + modifiableModel.commit(); + } + } + }; + UndoManager.getInstance(myProject).undoableActionPerformed(action); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + modifiableModel.commit(); + } + }); + } + }, IdeBundle.message("command.renaming.module", oldName), null); + return success.get().booleanValue(); + } + + @Nullable + private Library.ModifiableModel renameLibrary(String inputString) { + final Library.ModifiableModel modifiableModel = myLibrary.getModifiableModel(); + modifiableModel.setName(inputString); + return modifiableModel; + } + } + +} diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index f021f1c46b61..da9e2fbd340a 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -547,8 +547,10 @@ title.popup.views=Views title.project=Project error.module.already.exists=Module named ''{0}'' already exists title.rename.module=Rename Module +title.rename.library=Rename Library command.renaming.module=Renaming module {0} prompt.enter.new.module.name=Enter new module name +prompt.enter.new.library.name=Enter new library name tooltip.ui.designer.form=UI Designer Form node.projectview.libraries=Libraries node.projectview.external.libraries=External Libraries diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml index 621a2c0d8808..d77865b1981c 100644 --- a/resources/src/idea/RichPlatformPlugin.xml +++ b/resources/src/idea/RichPlatformPlugin.xml @@ -105,6 +105,7 @@ + From 1e90838abac3c4d3365f61baa5e6245d7b7015d9 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 12 Jun 2012 14:42:01 +0200 Subject: [PATCH 090/172] no closure folding for synchronized methods (IDEA-87268) --- .../folding/impl/JavaFoldingBuilder.java | 11 ++++++++--- .../codeInsight/folding/JavaFoldingTest.groovy | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/folding/impl/JavaFoldingBuilder.java b/java/java-impl/src/com/intellij/codeInsight/folding/impl/JavaFoldingBuilder.java index 7a74b3b31fef..9ec174fdf21c 100644 --- a/java/java-impl/src/com/intellij/codeInsight/folding/impl/JavaFoldingBuilder.java +++ b/java/java-impl/src/com/intellij/codeInsight/folding/impl/JavaFoldingBuilder.java @@ -569,7 +569,7 @@ public class JavaFoldingBuilder extends CustomFoldingBuilder implements DumbAwar } } - private static boolean hasOnlyOneMethod(@NotNull PsiAnonymousClass anonymousClass, boolean checkResolve) { + private static boolean hasOnlyOneLambdaMethod(@NotNull PsiAnonymousClass anonymousClass, boolean checkResolve) { PsiField[] fields = anonymousClass.getFields(); if (fields.length != 0) { if (fields.length == 1 && HighlightUtil.SERIAL_VERSION_UID_FIELD_NAME.equals(fields[0].getName()) && @@ -590,8 +590,13 @@ public class JavaFoldingBuilder extends CustomFoldingBuilder implements DumbAwar return false; } + PsiMethod method = anonymousClass.getMethods()[0]; + if (method.hasModifierProperty(PsiModifier.SYNCHRONIZED)) { + return false; + } + if (checkResolve) { - PsiReferenceList throwsList = anonymousClass.getMethods()[0].getThrowsList(); + PsiReferenceList throwsList = method.getThrowsList(); for (PsiClassType type : throwsList.getReferencedTypes()) { if (type.resolve() == null) { return false; @@ -617,7 +622,7 @@ public class JavaFoldingBuilder extends CustomFoldingBuilder implements DumbAwar final PsiExpressionList argumentList = expression.getArgumentList(); if (argumentList != null && argumentList.getExpressions().length == 0) { final PsiMethod[] methods = anonymousClass.getMethods(); - if (hasOnlyOneMethod(anonymousClass, !quick) && (quick || seemsLikeLambda(anonymousClass.getBaseClassType().resolve()))) { + if (hasOnlyOneLambdaMethod(anonymousClass, !quick) && (quick || seemsLikeLambda(anonymousClass.getBaseClassType().resolve()))) { final PsiMethod method = methods[0]; final PsiCodeBlock body = method.getBody(); if (body != null) { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy index a362c06bff2f..178087bf8e8d 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy @@ -283,6 +283,22 @@ class Test { assert !foldingModel.getCollapsedRegionAtOffset(text.indexOf("Runnable")) } + public void "test no closure folding for synchronized methods"() { + def text = """\ +class Test { + void test() { new Runnable() { + public synchronized void run() { + System.out.println(); + } + }; + } +} +""" + configure text + def foldingModel = myFixture.editor.foldingModel as FoldingModelImpl + assert !foldingModel.getCollapsedRegionAtOffset(text.indexOf("Runnable")) + } + public void testFindInFolding() { def text = """\ class Test { From 1d40c9037ff6ae741a76e4907a19ea08019d1e52 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 12 Jun 2012 19:02:42 +0200 Subject: [PATCH 091/172] middle matching variants should be after start matching ones --- .../completion/PrefixMatchingWeigher.java | 45 ++++++++++++++++--- .../impl/CompletionServiceImpl.java | 23 ++++------ 2 files changed, 46 insertions(+), 22 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/PrefixMatchingWeigher.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/PrefixMatchingWeigher.java index 2df59cd5fa37..f298603491f0 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/PrefixMatchingWeigher.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/PrefixMatchingWeigher.java @@ -18,10 +18,14 @@ package com.intellij.codeInsight.completion; import com.intellij.codeInsight.CodeInsightSettings; import com.intellij.codeInsight.completion.impl.CamelHumpMatcher; import com.intellij.codeInsight.lookup.LookupElement; +import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.codeStyle.MinusculeMatcher; import com.intellij.psi.codeStyle.NameUtil; import org.jetbrains.annotations.NotNull; +import java.util.Iterator; + /** * @author peter */ @@ -33,13 +37,7 @@ public class PrefixMatchingWeigher extends CompletionWeigher { } public static int getPrefixMatchingDegree(LookupElement item, CompletionLocation location) { - final String prefix = location.getCompletionParameters().getLookup().itemPattern(item); - - final int setting = CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE; - final NameUtil.MatchingCaseSensitivity sensitivity = - setting == CodeInsightSettings.NONE ? NameUtil.MatchingCaseSensitivity.NONE : - setting == CodeInsightSettings.FIRST_LETTER ? NameUtil.MatchingCaseSensitivity.FIRST_LETTER : NameUtil.MatchingCaseSensitivity.ALL; - final MinusculeMatcher matcher = new MinusculeMatcher(CamelHumpMatcher.applyMiddleMatching(prefix), sensitivity); + final MinusculeMatcher matcher = getMinusculeMatcher(location.getCompletionParameters().getLookup().itemPattern(item)); int max = Integer.MIN_VALUE; for (String lookupString : item.getAllLookupStrings()) { @@ -47,4 +45,37 @@ public class PrefixMatchingWeigher extends CompletionWeigher { } return max; } + + private static MinusculeMatcher getMinusculeMatcher(String prefix) { + final int setting = CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE; + final NameUtil.MatchingCaseSensitivity sensitivity = + setting == CodeInsightSettings.NONE ? NameUtil.MatchingCaseSensitivity.NONE : + setting == CodeInsightSettings.FIRST_LETTER ? NameUtil.MatchingCaseSensitivity.FIRST_LETTER : NameUtil.MatchingCaseSensitivity.ALL; + return new MinusculeMatcher(CamelHumpMatcher.applyMiddleMatching(prefix), sensitivity); + } + + public static StartMatchingDegree getStartMatchingDegree(LookupElement element, CompletionLocation location) { + StartMatchingDegree result = StartMatchingDegree.middleMatch; + String prefix = location.getCompletionParameters().getLookup().itemPattern(element); + if (StringUtil.isNotEmpty(prefix)) { + MinusculeMatcher matcher = getMinusculeMatcher(prefix); + for (String ls : element.getAllLookupStrings()) { + Iterable fragments = matcher.matchingFragments(ls); + if (fragments != null) { + Iterator iterator = fragments.iterator(); + if (!ls.isEmpty() && prefix.charAt(0) == ls.charAt(0)) { + return StartMatchingDegree.startMatchSameCase; + } + if (iterator.hasNext() && iterator.next().contains(0)) { + result = StartMatchingDegree.startMatchDifferentCase; + } + } + } + } + return result; + } + + public enum StartMatchingDegree { + startMatchSameCase, startMatchDifferentCase, middleMatch + } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CompletionServiceImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CompletionServiceImpl.java index 4854888bfc60..2a1b20d70737 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CompletionServiceImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CompletionServiceImpl.java @@ -25,7 +25,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.project.ProjectManagerAdapter; import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.patterns.ElementPattern; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; @@ -238,24 +237,18 @@ public class CompletionServiceImpl extends CompletionService{ final CompletionLocation location = new CompletionLocation(parameters); CompletionSorterImpl sorter = emptySorter(); - final String prefix = matcher.getPrefix(); - if (!prefix.isEmpty()) { - final String prefixHumps = StringUtil.capitalsOnly(prefix); - if (prefixHumps.length() > 0) { - sorter = sorter.weigh(new LookupElementWeigher("prefixHumps") { + sorter = sorter.withClassifier(new ClassifierFactory("prefixHumps") { + @Override + public Classifier createClassifier(Classifier next) { + return new ComparingClassifier(next, "prefixHumps") { @NotNull @Override - public Comparable weigh(@NotNull LookupElement element) { - for (String itemString : element.getAllLookupStrings()) { - if (StringUtil.capitalsOnly(itemString).startsWith(prefixHumps) && StringUtil.isCapitalized(itemString)) { - return false; - } - } - return true; + public Comparable getWeight(LookupElement element) { + return PrefixMatchingWeigher.getStartMatchingDegree(element, location); } - }); + }; } - } + }); for (final Weigher weigher : WeighingService.getWeighers(CompletionService.RELEVANCE_KEY)) { final String id = weigher.toString(); From 20b661dd77b1b5d97c66744bb160c5beed507eaf Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 12 Jun 2012 19:25:20 +0200 Subject: [PATCH 092/172] single-pass VirtualFile.getPath --- .../newvfs/impl/VirtualFileSystemEntry.java | 70 ++++++++----------- 1 file changed, 31 insertions(+), 39 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java index 1e6483398117..e08ab5b4892c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java @@ -218,41 +218,37 @@ public abstract class VirtualFileSystemEntry extends NewVirtualFile { } } - protected int getPathLength() { - Object o = rawName(); - int length = o instanceof String ? ((String)o).length() : ((byte[]) o).length; - length += getEncodedSuffix().length(); - return myParent == null ? length : myParent.getPathLength() + length + 1; - } + protected char[] appendPathOnFileSystem(int pathLength, int[] position) { + final Object o = rawName(); + final String suffix = getEncodedSuffix(); + final int nameLength = (o instanceof String ? ((String)o).length() : ((byte[]) o).length) + suffix.length(); - protected int appendPathOnFileSystem(@NotNull char[] chars, int pos) { + final char[] chars; if (myParent != null) { - pos = myParent.appendPathOnFileSystem(chars, pos); - } - - Object o = rawName(); - String suffix = getEncodedSuffix(); - //noinspection StringEquality - if (o == EMPTY && suffix == EMPTY) { - return pos; - } - - if (pos > 0 && chars[pos - 1] != '/') { - chars[pos++] = '/'; + chars = myParent.appendPathOnFileSystem(pathLength + 1 + nameLength, position); + if (position[0] > 0 && chars[position[0] - 1] != '/') { + chars[position[0]++] = '/'; + } + } else { + chars = new char[pathLength + nameLength]; } if (o instanceof String) { - pos = copyString(chars, pos, (String)o); - return copyString(chars, pos, suffix); + position[0] = copyString(chars, position[0], (String)o); + } else { + byte[] bytes = (byte[]) o; + int pos = position[0]; + //noinspection ForLoopReplaceableByForEach + for (int i = 0, len = bytes.length; i < len; i++) { + chars[pos++] = (char)bytes[i]; + } + position[0] = pos; } - byte[] bytes = (byte[]) o; - //noinspection ForLoopReplaceableByForEach - for (int i = 0, len = bytes.length; i < len; i++) { - chars[pos++] = (char)bytes[i]; - } - return copyString(chars, pos, suffix); + position[0] = copyString(chars, position[0], suffix); + return chars; } + private static int copyString(@NotNull char[] chars, int pos, @NotNull String s) { int length = s.length(); s.getChars(0, length, chars, pos); @@ -263,23 +259,19 @@ public abstract class VirtualFileSystemEntry extends NewVirtualFile { @NotNull public String getUrl() { String protocol = getFileSystem().getProtocol(); - char[] chars = new char[getPathLength() + protocol.length() + "://".length()]; - int pos = copyString(chars, 0, protocol); - pos = copyString(chars, pos, "://"); - - return getPathImpl(chars, pos); + int prefixLen = protocol.length() + "://".length(); + int[] pos = {prefixLen}; + char[] chars = appendPathOnFileSystem(prefixLen, pos); + copyString(chars, copyString(chars, 0, protocol), "://"); + return new String(chars, 0, pos[0]); } @Override @NotNull public String getPath() { - char[] chars = new char[getPathLength()]; - return getPathImpl(chars, 0); - } - - private String getPathImpl(@NotNull char[] chars, int pos) { - int count = appendPathOnFileSystem(chars, pos); - return new String(chars, 0, count); + int[] pos = {0}; + char[] chars = appendPathOnFileSystem(0, pos); + return new String(chars, 0, pos[0]); } @Override From e945668dbe249167f5920b5140586ca654db650b Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Wed, 13 Jun 2012 00:13:05 +0400 Subject: [PATCH 093/172] increment modification counter on libraries change --- .../intellij/openapi/roots/impl/ProjectRootManagerImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerImpl.java index ff66095a2661..7bcb2d0f215e 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerImpl.java @@ -495,6 +495,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj } public void afterLibraryAdded(final Library newLibrary) { + myModificationCount++; mergeRootsChangesDuring(new Runnable() { public void run() { for (LibraryTable.Listener listener : myListeners) { @@ -505,6 +506,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj } public void afterLibraryRenamed(final Library library) { + myModificationCount++; mergeRootsChangesDuring(new Runnable() { public void run() { for (LibraryTable.Listener listener : myListeners) { @@ -515,6 +517,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj } public void beforeLibraryRemoved(final Library library) { + myModificationCount++; mergeRootsChangesDuring(new Runnable() { public void run() { for (LibraryTable.Listener listener : myListeners) { @@ -525,6 +528,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj } public void afterLibraryRemoved(final Library library) { + myModificationCount++; mergeRootsChangesDuring(new Runnable() { public void run() { for (LibraryTable.Listener listener : myListeners) { From 7d414e981745315d5996da5f9fb3fb0a4aafd366 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 13 Jun 2012 11:40:34 +0400 Subject: [PATCH 094/172] convert anonymous to inner: collapse diamonds (IDEA-87265) --- .../AnonymousToInnerHandler.java | 9 +++++++-- .../anonymousToInner/canBeStatic_after.java | 2 +- .../anonymousToInner/collapseDiamonds.java | 14 ++++++++++++++ .../anonymousToInner/collapseDiamonds_after.java | 16 ++++++++++++++++ .../genericTypeParameters_after.java | 2 +- .../refactoring/AnonymousToInnerTest.java | 4 ++++ 6 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 java/java-tests/testData/refactoring/anonymousToInner/collapseDiamonds.java create mode 100644 java/java-tests/testData/refactoring/anonymousToInner/collapseDiamonds_after.java diff --git a/java/java-impl/src/com/intellij/refactoring/anonymousToInner/AnonymousToInnerHandler.java b/java/java-impl/src/com/intellij/refactoring/anonymousToInner/AnonymousToInnerHandler.java index dd808a94a12d..5ae7c8613e07 100644 --- a/java/java-impl/src/com/intellij/refactoring/anonymousToInner/AnonymousToInnerHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/anonymousToInner/AnonymousToInnerHandler.java @@ -26,6 +26,7 @@ import com.intellij.openapi.editor.ScrollType; import com.intellij.openapi.project.Project; import com.intellij.psi.*; import com.intellij.psi.codeStyle.CodeStyleManager; +import com.intellij.psi.impl.PsiDiamondTypeUtil; import com.intellij.psi.search.LocalSearchScope; import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.psi.util.PsiTreeUtil; @@ -184,8 +185,12 @@ public class AnonymousToInnerHandler implements RefactoringActionHandler { } } buf.append(")"); - PsiExpression newClassExpression = JavaPsiFacade.getInstance(myManager.getProject()).getElementFactory().createExpressionFromText(buf.toString(), null); - newExpr.replace(newClassExpression); + PsiNewExpression newClassExpression = + (PsiNewExpression)JavaPsiFacade.getInstance(myManager.getProject()).getElementFactory().createExpressionFromText(buf.toString(), null); + newClassExpression = (PsiNewExpression)newExpr.replace(newClassExpression); + if (PsiDiamondTypeUtil.canCollapseToDiamond(newClassExpression, newClassExpression, newClassExpression.getType())) { + PsiDiamondTypeUtil.replaceExplicitWithDiamond(newClassExpression.getClassOrAnonymousClassReference().getParameterList()); + } } @Nullable diff --git a/java/java-tests/testData/refactoring/anonymousToInner/canBeStatic_after.java b/java/java-tests/testData/refactoring/anonymousToInner/canBeStatic_after.java index f56eeb0391ed..4bcfab1cb5bd 100644 --- a/java/java-tests/testData/refactoring/anonymousToInner/canBeStatic_after.java +++ b/java/java-tests/testData/refactoring/anonymousToInner/canBeStatic_after.java @@ -1,6 +1,6 @@ public class Foo { public void foo() { - Predicate predicate = new MyPredicate(); + Predicate predicate = new MyPredicate<>(); } private interface Predicate { diff --git a/java/java-tests/testData/refactoring/anonymousToInner/collapseDiamonds.java b/java/java-tests/testData/refactoring/anonymousToInner/collapseDiamonds.java new file mode 100644 index 000000000000..dd7ca4915b75 --- /dev/null +++ b/java/java-tests/testData/refactoring/anonymousToInner/collapseDiamonds.java @@ -0,0 +1,14 @@ +public class Foo { + public void foo() { + Predicate predicate = new Predicate() { + @Override + public boolean test(T t) { + return false; + } + }; + } + + private interface Predicate { + boolean test(K t); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/anonymousToInner/collapseDiamonds_after.java b/java/java-tests/testData/refactoring/anonymousToInner/collapseDiamonds_after.java new file mode 100644 index 000000000000..4bcfab1cb5bd --- /dev/null +++ b/java/java-tests/testData/refactoring/anonymousToInner/collapseDiamonds_after.java @@ -0,0 +1,16 @@ +public class Foo { + public void foo() { + Predicate predicate = new MyPredicate<>(); + } + + private interface Predicate { + boolean test(K t); + } + + private static class MyPredicate implements Predicate { + @Override + public boolean test(T t) { + return false; + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/anonymousToInner/genericTypeParameters_after.java b/java/java-tests/testData/refactoring/anonymousToInner/genericTypeParameters_after.java index aa7fe1d30f5d..9ee35687cb2a 100644 --- a/java/java-tests/testData/refactoring/anonymousToInner/genericTypeParameters_after.java +++ b/java/java-tests/testData/refactoring/anonymousToInner/genericTypeParameters_after.java @@ -2,7 +2,7 @@ import java.util.*; class A { public Iterator> iterator(long revision) { - return new MyIterator(); + return new MyIterator<>(); } private static class MyIterator implements Iterator> { diff --git a/java/java-tests/testSrc/com/intellij/refactoring/AnonymousToInnerTest.java b/java/java-tests/testSrc/com/intellij/refactoring/AnonymousToInnerTest.java index 1dcfc7ab39e5..71fa16179846 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/AnonymousToInnerTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/AnonymousToInnerTest.java @@ -38,6 +38,10 @@ public class AnonymousToInnerTest extends LightCodeInsightTestCase { doTest("MyRunnable", true); } + public void testCollapseDiamonds() throws Exception { // IDEADEV-29446 + doTest("MyPredicate", true); + } + public void testCanBeStatic() throws Exception { configureByFile(TEST_ROOT + getTestName(true) + ".java"); AnonymousToInnerHandler handler = new AnonymousToInnerHandler(){ From 21540098fceca8af76a468831778456e97f41e18 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Tue, 5 Jun 2012 15:06:59 +0400 Subject: [PATCH 095/172] cleanup --- .../plugins/groovy/lang/GppFunctionalTest.groovy | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GppFunctionalTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GppFunctionalTest.groovy index 9cf1e0015c84..dc92c267363d 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GppFunctionalTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GppFunctionalTest.groovy @@ -10,6 +10,7 @@ import com.intellij.openapi.roots.ModifiableRootModel import com.intellij.openapi.roots.OrderRootType import com.intellij.openapi.roots.libraries.Library import com.intellij.openapi.vfs.JarFileSystem +import com.intellij.psi.search.GlobalSearchScope import com.intellij.testFramework.LightProjectDescriptor import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase @@ -314,13 +315,14 @@ class Bar implements Intf { class BarImpl extends Bar {} """ def facade = JavaPsiFacade.getInstance(getProject()) - assertOneElement(OverrideImplementUtil.getMethodsToOverrideImplement(facade.findClass("Foo"), true)) + def allScope = GlobalSearchScope.allScope(project) + assertOneElement(OverrideImplementUtil.getMethodsToOverrideImplement(facade.findClass("Foo", allScope), true)) - GrTypeDefinition barClass = facade.findClass("Bar") + GrTypeDefinition barClass = facade.findClass("Bar", allScope) as GrTypeDefinition assertEmpty(OverrideImplementUtil.getMethodsToOverrideImplement(barClass, true)) assertTrue "bar" in OverrideImplementUtil.getMethodsToOverrideImplement(barClass, false).collect { ((PsiMethod) it.element).name } - assertEmpty(OverrideImplementUtil.getMethodsToOverrideImplement(facade.findClass("BarImpl"), true)) + assertEmpty(OverrideImplementUtil.getMethodsToOverrideImplement(facade.findClass("BarImpl", allScope), true)) def implementations = new GotoImplementationHandler().getSourceAndTargetElements(myFixture.editor, myFixture.file).targets assertEquals Arrays.toString(implementations), 3, implementations.size() @@ -332,7 +334,7 @@ class BarImpl extends Bar {} l.each { it.substring(1) } } """ - PsiMethod method = resolveReference().navigationElement + PsiMethod method = resolveReference().navigationElement as PsiMethod assertEquals "each", method.name assertEquals "groovypp.util.Iterations", method.containingClass.qualifiedName } @@ -342,7 +344,7 @@ class BarImpl extends Bar {} Integer[] a = [] a.foldLeft(2, { a, b -> a+b }) """ - PsiMethod method = resolveReference().navigationElement + PsiMethod method = resolveReference().navigationElement as PsiMethod assertEquals "foldLeft", method.name assertEquals "groovypp.util.Iterations", method.containingClass.qualifiedName } From b90c6335629418ea5842936b39083ee851f127ae Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Tue, 5 Jun 2012 15:25:29 +0400 Subject: [PATCH 096/172] 'Unassigned variable access' should highlight as unassigned only first reference --- .../UnassignedVariableAccessInspection.java | 11 +++-- .../controlFlow/ControlFlowBuilderUtil.java | 45 ++++++++++++------- .../controlFlow/impl/ControlFlowBuilder.java | 4 +- .../groovy/lang/GroovyHighlightingTest.groovy | 1 + .../testdata/highlighting/Unassigned4.groovy | 6 +++ 5 files changed, 42 insertions(+), 25 deletions(-) create mode 100644 plugins/groovy/testdata/highlighting/Unassigned4.groovy diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unassignedVariable/UnassignedVariableAccessInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unassignedVariable/UnassignedVariableAccessInspection.java index b7da3dcfc12b..c2a40380b4ec 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unassignedVariable/UnassignedVariableAccessInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unassignedVariable/UnassignedVariableAccessInspection.java @@ -16,21 +16,20 @@ package org.jetbrains.plugins.groovy.codeInspection.unassignedVariable; import com.intellij.codeInspection.ProblemsHolder; -import com.intellij.codeInspection.ProblemHighlightType; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiParameter; import com.intellij.psi.PsiField; +import com.intellij.psi.PsiParameter; import com.intellij.psi.util.PsiTreeUtil; import org.jetbrains.annotations.Nls; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.groovy.codeInspection.GroovyInspectionBundle; import org.jetbrains.plugins.groovy.codeInspection.GroovyLocalInspectionBase; import org.jetbrains.plugins.groovy.gpp.GppTypeConverter; import org.jetbrains.plugins.groovy.lang.psi.GrControlFlowOwner; import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement; -import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction; import org.jetbrains.plugins.groovy.lang.psi.controlFlow.ControlFlowBuilderUtil; +import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction; import org.jetbrains.plugins.groovy.lang.psi.controlFlow.ReadWriteVariableInstruction; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; @@ -62,7 +61,7 @@ public class UnassignedVariableAccessInspection extends GroovyLocalInspectionBas protected void check(GrControlFlowOwner owner, ProblemsHolder problemsHolder) { Instruction[] flow = owner.getControlFlow(); - ReadWriteVariableInstruction[] reads = ControlFlowBuilderUtil.getReadsWithoutPriorWrites(flow); + ReadWriteVariableInstruction[] reads = ControlFlowBuilderUtil.getReadsWithoutPriorWrites(flow, true); for (ReadWriteVariableInstruction read : reads) { PsiElement element = read.getElement(); if (element instanceof GroovyPsiElement) { @@ -70,7 +69,7 @@ public class UnassignedVariableAccessInspection extends GroovyLocalInspectionBas GroovyPsiElement property = ResolveUtil.resolveProperty((GroovyPsiElement) element, name); if (property != null && !(property instanceof PsiParameter) && !(property instanceof PsiField) && PsiTreeUtil.isAncestor(owner, property, false) && !GppTypeConverter.hasTypedContext(element)) { - problemsHolder.registerProblem(element, GroovyInspectionBundle.message("unassigned.access.tooltip", name, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); + problemsHolder.registerProblem(element, GroovyInspectionBundle.message("unassigned.access.tooltip", name)); } } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/ControlFlowBuilderUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/ControlFlowBuilderUtil.java index c5c80a0471d3..5231c2b40439 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/ControlFlowBuilderUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/ControlFlowBuilderUtil.java @@ -16,6 +16,7 @@ package org.jetbrains.plugins.groovy.lang.psi.controlFlow; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.util.ArrayUtil; import gnu.trove.TIntHashSet; import gnu.trove.TObjectIntHashMap; @@ -56,7 +57,7 @@ public class ControlFlowBuilderUtil { return currN; } - public static ReadWriteVariableInstruction[] getReadsWithoutPriorWrites(Instruction[] flow) { + public static ReadWriteVariableInstruction[] getReadsWithoutPriorWrites(Instruction[] flow, boolean onlyFirstRead) { List result = new ArrayList(); TObjectIntHashMap namesIndex = buildNamesIndex(flow); @@ -65,7 +66,7 @@ public class ControlFlowBuilderUtil { int[] postorder = postorder(flow); int[] invpostorder = invPostorder(postorder); - findReadsBeforeWrites(flow, definitelyAssigned, result, namesIndex, postorder, invpostorder); + findReadsBeforeWrites(flow, definitelyAssigned, result, namesIndex, postorder, invpostorder, onlyFirstRead); if (result.size() == 0) return ReadWriteVariableInstruction.EMPTY_ARRAY; return result.toArray(new ReadWriteVariableInstruction[result.size()]); } @@ -97,28 +98,36 @@ public class ControlFlowBuilderUtil { List result, TObjectIntHashMap namesIndex, int[] postorder, - int[] invpostorder) { + int[] invpostorder, + boolean onlyFirstRead) { //skip instructions that are not reachable from the start - int start = 0; - while (invpostorder[start] != 0) start++; + int start = ArrayUtil.find(invpostorder, 0); for (int i = start; i < flow.length; i++) { int j = invpostorder[i]; Instruction curr = flow[j]; if (curr instanceof ReadWriteVariableInstruction) { - ReadWriteVariableInstruction readWriteInsn = (ReadWriteVariableInstruction) curr; - int idx = namesIndex.get(readWriteInsn.getVariableName()); + ReadWriteVariableInstruction rw = (ReadWriteVariableInstruction) curr; + int name = namesIndex.get(rw.getVariableName()); TIntHashSet vars = definitelyAssigned[j]; - if (!readWriteInsn.isWrite()) { - if (vars == null || !vars.contains(idx)) { - result.add(readWriteInsn); - } - } else { + if (rw.isWrite()) { if (vars == null) { vars = new TIntHashSet(); definitelyAssigned[j] = vars; } - vars.add(idx); + vars.add(name); + } + else { + if (vars == null || !vars.contains(name)) { + result.add(rw); + if (onlyFirstRead) { + if (vars == null) { + vars = new TIntHashSet(); + definitelyAssigned[j] = vars; + } + vars.add(name); + } + } } } @@ -132,20 +141,22 @@ public class ControlFlowBuilderUtil { succDefinitelyAssigned = new TIntHashSet(); succDefinitelyAssigned.addAll(currArray); definitelyAssigned[succ.num()] = succDefinitelyAssigned; - } else { + } + else { succDefinitelyAssigned.retainAll(currArray); } - } else { + } + else { if (succDefinitelyAssigned != null) { succDefinitelyAssigned.clear(); - } else { + } + else { succDefinitelyAssigned = new TIntHashSet(); definitelyAssigned[succ.num()] = succDefinitelyAssigned; } } } } - } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java index 65818f5b0f27..f80888d338f9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java @@ -247,7 +247,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { Set names = new HashSet(); - ReadWriteVariableInstruction[] reads = ControlFlowBuilderUtil.getReadsWithoutPriorWrites(closure.getControlFlow()); + ReadWriteVariableInstruction[] reads = ControlFlowBuilderUtil.getReadsWithoutPriorWrites(closure.getControlFlow(), false); for (ReadWriteVariableInstruction read : reads) { names.add(read.getVariableName()); } @@ -1019,7 +1019,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { final Set vars = new HashSet(); typeDefinition.acceptChildren(new GroovyRecursiveElementVisitor() { private void collectVars(Instruction[] flow) { - ReadWriteVariableInstruction[] reads = ControlFlowBuilderUtil.getReadsWithoutPriorWrites(flow); + ReadWriteVariableInstruction[] reads = ControlFlowBuilderUtil.getReadsWithoutPriorWrites(flow, false); for (ReadWriteVariableInstruction instruction : reads) { vars.add(instruction.getVariableName()); } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy index 9022f9362348..e612fc2c2050 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy @@ -185,6 +185,7 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase { public void testUnassigned1() throws Exception { doTest(new UnassignedVariableAccessInspection()); } public void testUnassigned2() throws Exception { doTest(new UnassignedVariableAccessInspection()); } public void testUnassigned3() throws Exception { doTest(new UnassignedVariableAccessInspection()); } + public void testUnassigned4() throws Exception { doTest(new UnassignedVariableAccessInspection()); } public void testUnassignedTryFinally() throws Exception { doTest(new UnassignedVariableAccessInspection()); } public void testUnusedVariable() throws Exception { doTest(new UnusedDefInspection(), new GrUnusedIncDecInspection()); } diff --git a/plugins/groovy/testdata/highlighting/Unassigned4.groovy b/plugins/groovy/testdata/highlighting/Unassigned4.groovy new file mode 100644 index 000000000000..bd85f6ab0fe3 --- /dev/null +++ b/plugins/groovy/testdata/highlighting/Unassigned4.groovy @@ -0,0 +1,6 @@ +def r +if (fff) { + r = 9 +} +print r +print r From 34df8d34a597159da2e54d05b2bd0ed2b4e34b75 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Tue, 5 Jun 2012 17:17:42 +0400 Subject: [PATCH 097/172] don't complete same-name-qualifier variables twice --- .../lang/completion/GroovyCompletionContributor.java | 11 ++++++++++- .../groovy/lang/completion/GroovyCompletionUtil.java | 2 ++ .../expressions/CompleteReferenceExpression.java | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java index 2b4ce4c98938..1b29f8287edd 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java @@ -431,8 +431,10 @@ public class GroovyCompletionContributor extends CompletionContributor { final PsiType qualifierType = qualifier instanceof GrExpression ? ((GrExpression)qualifier).getType() : null; LinkedHashSet result = new LinkedHashSet(); + final Set unresolvedProps; if (reference instanceof GrReferenceExpression && (qualifier instanceof GrExpression || qualifier == null)) { - for (String string : CompleteReferenceExpression.getVariantsWithSameQualifier(matcher, (GrExpression)qualifier, (GrReferenceExpression)reference)) { + unresolvedProps = CompleteReferenceExpression.getVariantsWithSameQualifier(matcher, (GrExpression)qualifier, (GrReferenceExpression)reference); + for (String string : unresolvedProps) { result.add(GroovyCompletionUtil.getLookupElement(string)); } if (parameters.getInvocationCount() < 2 && qualifier != null && qualifierType == null && @@ -443,6 +445,9 @@ public class GroovyCompletionContributor extends CompletionContributor { return result; } } + else { + unresolvedProps = Collections.emptySet(); + } final ElementFilter classFilter = getClassFilter(position); @@ -468,6 +473,10 @@ public class GroovyCompletionContributor extends CompletionContributor { object = ((GroovyResolveResult)object).getElement(); } + if (object instanceof GrReferenceExpression && unresolvedProps.contains(((GrReferenceExpression)object).getName())) { + return; + } + if (object instanceof PsiMember && JavaCompletionUtil.isInExcludedPackage((PsiMember)object, true)) { return; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java index bcb9f460a4e2..288f33e0077f 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java @@ -29,6 +29,7 @@ import com.intellij.openapi.editor.RangeMarker; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.highlighter.HighlighterIterator; import com.intellij.openapi.fileEditor.FileDocumentManager; +import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.util.Iconable; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; @@ -216,6 +217,7 @@ public class GroovyCompletionUtil { List result = CollectionFactory.arrayList(); for (GroovyResolveResult candidate : candidates) { result.add(createCompletionVariant(candidate)); + ProgressManager.checkCanceled(); } return result; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java index c124cb1c0496..052d3c261548 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java @@ -369,6 +369,7 @@ public class CompleteReferenceExpression { private final boolean myFieldPointerOperator; private final boolean myMethodPointerOperator; private final boolean myIsMap; + private Set myNonDeclaredVars = new com.intellij.util.containers.HashSet(); protected CompleteReferenceProcessor(GrReferenceExpression place, Consumer consumer, @NotNull PrefixMatcher matcher, CompletionParameters parameters) { super(null, EnumSet.allOf(ResolveKind.class), place, PsiType.EMPTY_ARRAY); @@ -428,6 +429,10 @@ public class CompleteReferenceExpression { if (element instanceof PsiVariable && !myMatcher.prefixMatches(((PsiVariable)element).getName())) { return; } + if (element instanceof GrReferenceExpression) { + String name = ((GrReferenceExpression)element).getName(); + if (!myNonDeclaredVars.add(name)) return; + } if (element instanceof GrReflectedMethod) { element = ((GrReflectedMethod)element).getBaseMethod(); From 1b1ad422dc62783f94d6b4a52478768687fdbec8 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Wed, 13 Jun 2012 11:41:52 +0400 Subject: [PATCH 098/172] instruction numbers are set inside addNode() --- .../psi/controlFlow/AfterCallInstruction.java | 4 +- .../lang/psi/controlFlow/CallInstruction.java | 4 +- .../lang/psi/controlFlow/GotoInstruction.java | 4 +- .../controlFlow/InstanceOfInstruction.java | 4 +- .../controlFlow/NegatingGotoInstruction.java | 4 +- .../controlFlow/PositiveGotoInstruction.java | 4 +- .../ReadWriteVariableInstruction.java | 4 +- .../psi/controlFlow/ReturnInstruction.java | 4 +- .../controlFlow/impl/ArgumentInstruction.java | 4 +- .../impl/ConditionInstruction.java | 4 +- .../controlFlow/impl/ControlFlowBuilder.java | 78 +++++++++---------- .../psi/controlFlow/impl/FakeInstruction.java | 2 +- .../controlFlow/impl/IfEndInstruction.java | 4 +- .../psi/controlFlow/impl/InstructionImpl.java | 11 ++- .../impl/MaybeReturnInstruction.java | 4 +- .../controlFlow/impl/ThrowingInstruction.java | 4 +- 16 files changed, 72 insertions(+), 71 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/AfterCallInstruction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/AfterCallInstruction.java index 5b77d64b8253..e1693c46a420 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/AfterCallInstruction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/AfterCallInstruction.java @@ -26,8 +26,8 @@ public class AfterCallInstruction extends InstructionImpl { public final CallInstruction myCall; private ReturnInstruction myReturnInstruction; - public AfterCallInstruction(int num, CallInstruction call) { - super(null, num); + public AfterCallInstruction(CallInstruction call) { + super(null); this.myCall = call; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/CallInstruction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/CallInstruction.java index 30e824f7c071..7d70b6ee4306 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/CallInstruction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/CallInstruction.java @@ -25,8 +25,8 @@ import java.util.Collections; public class CallInstruction extends InstructionImpl { private final InstructionImpl myCallee; - public CallInstruction(int num, InstructionImpl callee) { - super(null, num); + public CallInstruction(InstructionImpl callee) { + super(null); myCallee = callee; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/GotoInstruction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/GotoInstruction.java index 7a566976feee..014e7b7735d7 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/GotoInstruction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/GotoInstruction.java @@ -27,8 +27,8 @@ import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.InstructionImpl; public abstract class GotoInstruction extends InstructionImpl { @NotNull private final ConditionInstruction myCondition; - public GotoInstruction(@Nullable PsiElement element, int num, @NotNull ConditionInstruction condition) { - super(element, num); + public GotoInstruction(@Nullable PsiElement element, @NotNull ConditionInstruction condition) { + super(element); myCondition = condition; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/InstanceOfInstruction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/InstanceOfInstruction.java index a8e3951c8fef..9df3f097ff52 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/InstanceOfInstruction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/InstanceOfInstruction.java @@ -32,8 +32,8 @@ import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.InstructionImpl; public class InstanceOfInstruction extends InstructionImpl implements MixinTypeInstruction { private final ConditionInstruction myCondition; - public InstanceOfInstruction(int num, GrExpression assertion, ConditionInstruction cond) { - super(assertion, num); + public InstanceOfInstruction(GrExpression assertion, ConditionInstruction cond) { + super(assertion); myCondition = cond; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/NegatingGotoInstruction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/NegatingGotoInstruction.java index de949ae5e294..99d7e018d1c9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/NegatingGotoInstruction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/NegatingGotoInstruction.java @@ -24,8 +24,8 @@ import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.ConditionInstructi * @author Max Medvedev */ public class NegatingGotoInstruction extends GotoInstruction { - public NegatingGotoInstruction(@Nullable PsiElement element, int num, @NotNull ConditionInstruction condition) { - super(element, num, condition); + public NegatingGotoInstruction(@Nullable PsiElement element, @NotNull ConditionInstruction condition) { + super(element, condition); } @Override diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/PositiveGotoInstruction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/PositiveGotoInstruction.java index d0d0c8140980..165dec4e6f49 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/PositiveGotoInstruction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/PositiveGotoInstruction.java @@ -24,7 +24,7 @@ import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.ConditionInstructi * @author Max Medvedev */ public class PositiveGotoInstruction extends GotoInstruction { - public PositiveGotoInstruction(@Nullable PsiElement element, int num, @NotNull ConditionInstruction condition) { - super(element, num, condition); + public PositiveGotoInstruction(@Nullable PsiElement element, @NotNull ConditionInstruction condition) { + super(element, condition); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/ReadWriteVariableInstruction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/ReadWriteVariableInstruction.java index 37cb2f018c6f..419ee1b9ed6d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/ReadWriteVariableInstruction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/ReadWriteVariableInstruction.java @@ -31,8 +31,8 @@ public class ReadWriteVariableInstruction extends InstructionImpl { private final boolean myIsWrite; private final String myName; - public ReadWriteVariableInstruction(@NotNull String varName, PsiElement element, int num, int accessType) { - super(element, num); + public ReadWriteVariableInstruction(@NotNull String varName, PsiElement element, int accessType) { + super(element); myName = varName; myIsWrite = accessType == WRITE; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/ReturnInstruction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/ReturnInstruction.java index e9e431892031..244182a47c57 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/ReturnInstruction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/ReturnInstruction.java @@ -26,8 +26,8 @@ import java.util.Deque; * @author peter */ public class ReturnInstruction extends InstructionImpl { - public ReturnInstruction(GrFinallyClause finallyClause, int num) { - super(finallyClause, num); + public ReturnInstruction(GrFinallyClause finallyClause) { + super(finallyClause); } public String toString() { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ArgumentInstruction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ArgumentInstruction.java index 44551b5cef4c..27017bd04095 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ArgumentInstruction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ArgumentInstruction.java @@ -41,8 +41,8 @@ import static org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSig public class ArgumentInstruction extends InstructionImpl implements MixinTypeInstruction { private static final Logger LOG = Logger.getInstance(ArgumentInstruction.class); - public ArgumentInstruction(@Nullable GrReferenceExpression ref, int num) { - super(ref, num); + public ArgumentInstruction(@Nullable GrReferenceExpression ref) { + super(ref); } @Nullable diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ConditionInstruction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ConditionInstruction.java index 4dfdf506d20a..c0b9c89ec657 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ConditionInstruction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ConditionInstruction.java @@ -28,8 +28,8 @@ import java.util.Set; public class ConditionInstruction extends InstructionImpl implements Instruction { private final Set myDependent = new HashSet(); - public ConditionInstruction(@NotNull PsiElement element, int num) { - super(element, num); + public ConditionInstruction(@NotNull PsiElement element) { + super(element); myDependent.add(this); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java index f80888d338f9..5b0fd7ea2d09 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java @@ -115,7 +115,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { final PsiElement lbrace = block.getLBrace(); if (lbrace != null && parent instanceof GrMethod) { for (GrParameter parameter : ((GrMethod)parent).getParameters()) { - addNode(new ReadWriteVariableInstruction(parameter.getName(), parameter, myInstructionNumber++, WRITE)); + addNode(new ReadWriteVariableInstruction(parameter.getName(), parameter, WRITE)); } } super.visitOpenBlock(block); @@ -143,9 +143,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { if (finallyClause != null) return; if (last instanceof GrExpression && PsiTreeUtil.isAncestor(myLastInScope, last, false)) { - final MaybeReturnInstruction instruction = new MaybeReturnInstruction((GrExpression)last, myInstructionNumber++); - checkPending(instruction); - addNode(instruction); + addNodeAndCheckPending(new MaybeReturnInstruction((GrExpression)last)); } } @@ -195,10 +193,10 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { private void buildFlowForClosure(final GrClosableBlock closure) { for (GrParameter parameter : closure.getAllParameters()) { - addNode(new ReadWriteVariableInstruction(parameter.getName(), parameter, myInstructionNumber++, WRITE)); + addNode(new ReadWriteVariableInstruction(parameter.getName(), parameter, WRITE)); } - addNode(new ReadWriteVariableInstruction("owner", closure.getLBrace(), myInstructionNumber++, WRITE)); + addNode(new ReadWriteVariableInstruction("owner", closure.getLBrace(), WRITE)); PsiElement child = closure.getFirstChild(); while (child != null) { @@ -215,6 +213,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { } private T addNode(T instruction) { + instruction.setNumber(myInstructionNumber++); myInstructions.add(instruction); if (myHead != null) { addEdge(myHead, instruction); @@ -253,10 +252,10 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { } for (String name : names) { - addNodeAndCheckPending(new ReadWriteVariableInstruction(name, closure, myInstructionNumber++, READ)); + addNodeAndCheckPending(new ReadWriteVariableInstruction(name, closure, READ)); } - addNodeAndCheckPending(new InstructionImpl(closure, myInstructionNumber++)); + addNodeAndCheckPending(new InstructionImpl(closure)); } public void visitBreakStatement(GrBreakStatement breakStatement) { @@ -300,7 +299,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { public void visitAssertStatement(GrAssertStatement assertStatement) { final GrExpression assertion = assertStatement.getAssertion(); if (assertion != null) { - myConditions.push(addNodeAndCheckPending(new ConditionInstruction(assertion, myInstructionNumber++))); + myConditions.push(addNodeAndCheckPending(new ConditionInstruction(assertion))); assertion.accept(this); final InstructionImpl assertInstruction = startNode(assertStatement); GrExpression errorMessage = assertStatement.getErrorMessage(); @@ -324,7 +323,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { if (exception == null) return; exception.accept(this); - final InstructionImpl throwInstruction = new ThrowingInstruction(throwStatement, myInstructionNumber++); + final InstructionImpl throwInstruction = new ThrowingInstruction(throwStatement); addNodeAndCheckPending(throwInstruction); interruptFlow(); @@ -374,7 +373,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { if (lValue instanceof GrReferenceExpression) { String referenceName = ((GrReferenceExpression)lValue).getReferenceName(); if (referenceName != null) { - addNodeAndCheckPending(new ReadWriteVariableInstruction(referenceName, lValue, myInstructionNumber++, READ)); + addNodeAndCheckPending(new ReadWriteVariableInstruction(referenceName, lValue, READ)); } } } @@ -403,7 +402,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { return; } - ConditionInstruction cond = new ConditionInstruction(expression, myInstructionNumber++); + ConditionInstruction cond = new ConditionInstruction(expression); addNodeAndCheckPending(cond); registerCondition(cond); @@ -414,7 +413,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { List negations = collectAndRemoveAllPendingNegations(expression); - addPendingEdge(expression, addNodeAndCheckPending(new PositiveGotoInstruction(expression, myInstructionNumber++, cond))); + addPendingEdge(expression, addNodeAndCheckPending(new PositiveGotoInstruction(expression, cond))); myHead = reduceAllNegationsIntoInstruction(expression, negations); } @@ -422,7 +421,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { @Nullable private InstructionImpl reduceAllNegationsIntoInstruction(GroovyPsiElement currentScope, List negations) { if (negations.size() > 1) { - InstructionImpl instruction = addNode(new InstructionImpl(currentScope, myInstructionNumber++)); + InstructionImpl instruction = addNode(new InstructionImpl(currentScope)); for (GotoInstruction negation : negations) { addEdge(negation, instruction); } @@ -453,17 +452,17 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { public void visitInstanceofExpression(GrInstanceOfExpression expression) { expression.getOperand().accept(this); - ConditionInstruction cond = new ConditionInstruction(expression, myInstructionNumber++); + ConditionInstruction cond = new ConditionInstruction(expression); addNodeAndCheckPending(cond); registerCondition(cond); - addNode(new InstanceOfInstruction(myInstructionNumber++, expression, cond)); - NegatingGotoInstruction negation = new NegatingGotoInstruction(expression, myInstructionNumber++, cond); + addNode(new InstanceOfInstruction(expression, cond)); + NegatingGotoInstruction negation = new NegatingGotoInstruction(expression, cond); addNode(negation); addPendingEdge(expression, negation); myHead = cond; - InstanceOfInstruction instruction = addNode(new InstanceOfInstruction(myInstructionNumber++, expression, cond)); + addNode(new InstanceOfInstruction(expression, cond)); myConditions.removeFirstOccurrence(cond); } @@ -474,15 +473,15 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { if (name == null) return; if (ControlFlowUtils.isIncOrDecOperand(refExpr)) { - final InstructionImpl i = new ReadWriteVariableInstruction(name, refExpr, myInstructionNumber++, READ); + final InstructionImpl i = new ReadWriteVariableInstruction(name, refExpr, READ); addNodeAndCheckPending(i); - addNode(new ReadWriteVariableInstruction(name, refExpr, myInstructionNumber++, WRITE)); + addNode(new ReadWriteVariableInstruction(name, refExpr, WRITE)); } else { final int type = PsiUtil.isLValue(refExpr) ? WRITE : READ; - addNodeAndCheckPending(new ReadWriteVariableInstruction(name, refExpr, myInstructionNumber++, type)); + addNodeAndCheckPending(new ReadWriteVariableInstruction(name, refExpr, type)); if (refExpr.getParent() instanceof GrArgumentList && refExpr.getParent().getParent() instanceof GrCall) { - addNodeAndCheckPending(new ArgumentInstruction(refExpr, myInstructionNumber++)); + addNodeAndCheckPending(new ArgumentInstruction(refExpr)); } } } @@ -530,7 +529,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { return; } - ConditionInstruction condition = new ConditionInstruction(expression, myInstructionNumber++); + ConditionInstruction condition = new ConditionInstruction(expression); addNodeAndCheckPending(condition); registerCondition(condition); @@ -548,13 +547,13 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { } if (negations.isEmpty()) { InstructionImpl head = myHead; - NegatingGotoInstruction negation = addNode(new NegatingGotoInstruction(expression, myInstructionNumber++, condition)); + NegatingGotoInstruction negation = addNode(new NegatingGotoInstruction(expression, condition)); addPendingEdge(expression, negation); myHead = head; } } else /*if (opType == mLOR)*/ { - addNodeAndCheckPending(new InstructionImpl(expression, myInstructionNumber++)); //collect all pending edges from left argument + addNodeAndCheckPending(new InstructionImpl(expression)); //collect all pending edges from left argument addPendingEdge(expression, myHead); myHead = reduceAllNegationsIntoInstruction(expression, negations); @@ -574,7 +573,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { if (myCaughtExceptionInfos.size() <= 0 && myFinallyCount <= 0) { return; } - final InstructionImpl instruction = new ThrowingInstruction(call, myInstructionNumber++); + final InstructionImpl instruction = new ThrowingInstruction(call); addNodeAndCheckPending(instruction); for (ExceptionInfo info : myCaughtExceptionInfos) { @@ -623,7 +622,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { } if (thenBranch != null || elseBranch != null) { - final InstructionImpl end = new IfEndInstruction(ifStatement, myInstructionNumber++); + final InstructionImpl end = new IfEndInstruction(ifStatement); addNode(end); if (thenEnd != null) addEdge(thenEnd, end); if (elseEnd != null) { @@ -659,10 +658,8 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { } GrVariable variable = clause.getDeclaredVariable(); if (variable != null) { - ReadWriteVariableInstruction writeInst = - new ReadWriteVariableInstruction(variable.getName(), variable, myInstructionNumber++, WRITE); - checkPending(writeInst); - addNode(writeInst); + ReadWriteVariableInstruction writeInst = new ReadWriteVariableInstruction(variable.getName(), variable, WRITE); + addNodeAndCheckPending(writeInst); } } @@ -907,7 +904,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { final GrParameter parameter = catchClauses[i].getParameter(); if (parameter != null) { - addNode(new ReadWriteVariableInstruction(parameter.getName(), parameter, myInstructionNumber++, WRITE)); + addNode(new ReadWriteVariableInstruction(parameter.getName(), parameter, WRITE)); } catchClauses[i].accept(this); catches[i] = myHead; @@ -945,7 +942,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { myHead = finallyInstruction; finallyClause.accept(this); - final ReturnInstruction returnInstruction = new ReturnInstruction(finallyClause, myInstructionNumber++); + final ReturnInstruction returnInstruction = new ReturnInstruction(finallyClause); for (AfterCallInstruction postCall : postCalls) { postCall.setReturnInstruction(returnInstruction); addEdge(returnInstruction, postCall); @@ -970,11 +967,11 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { private AfterCallInstruction addCallNode(InstructionImpl finallyInstruction, GroovyPsiElement scopeWhenAdded, InstructionImpl src) { interruptFlow(); - final CallInstruction call = new CallInstruction(myInstructionNumber++, finallyInstruction); + final CallInstruction call = new CallInstruction(finallyInstruction); addNode(call); addEdge(src, call); addEdge(call, finallyInstruction); - AfterCallInstruction afterCall = new AfterCallInstruction(myInstructionNumber++, call); + AfterCallInstruction afterCall = new AfterCallInstruction(call); addNode(afterCall); addPendingEdge(scopeWhenAdded, afterCall); return afterCall; @@ -985,7 +982,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { } private InstructionImpl startNode(GroovyPsiElement element, boolean checkPending) { - final InstructionImpl instruction = new InstructionImpl(element, myInstructionNumber++); + final InstructionImpl instruction = new InstructionImpl(element); addNode(instruction); if (checkPending) checkPending(instruction); myProcessingStack.push(instruction); @@ -1060,18 +1057,17 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { } for (String var : vars) { - addNodeAndCheckPending(new ReadWriteVariableInstruction(var, typeDefinition, myInstructionNumber++, READ)); + addNodeAndCheckPending(new ReadWriteVariableInstruction(var, typeDefinition, READ)); } - addNodeAndCheckPending(new InstructionImpl(typeDefinition, myInstructionNumber++)); + addNodeAndCheckPending(new InstructionImpl(typeDefinition)); } public void visitVariable(GrVariable variable) { super.visitVariable(variable); if (variable.getInitializerGroovy() != null || variable.getParent() instanceof GrTupleDeclaration && ((GrTupleDeclaration)variable.getParent()).getInitializerGroovy() != null) { - ReadWriteVariableInstruction writeInst = new ReadWriteVariableInstruction(variable.getName(), variable, myInstructionNumber++, WRITE); - checkPending(writeInst); - addNode(writeInst); + ReadWriteVariableInstruction writeInst = new ReadWriteVariableInstruction(variable.getName(), variable, WRITE); + addNodeAndCheckPending(writeInst); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/FakeInstruction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/FakeInstruction.java index 94b0c6885594..e48d32ab2bbd 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/FakeInstruction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/FakeInstruction.java @@ -22,6 +22,6 @@ import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction; */ public class FakeInstruction extends InstructionImpl implements Instruction { public FakeInstruction(int num) { - super(null, num); + super(null); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/IfEndInstruction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/IfEndInstruction.java index 6894127c05e0..1458e2fb2384 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/IfEndInstruction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/IfEndInstruction.java @@ -21,8 +21,8 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrIfStatement; * @author Maxim.Medvedev */ public class IfEndInstruction extends InstructionImpl{ - public IfEndInstruction(GrIfStatement ifStatement, int num) { - super(ifStatement, num); + public IfEndInstruction(GrIfStatement ifStatement) { + super(ifStatement); } @Override diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/InstructionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/InstructionImpl.java index 57334ee8d734..20492c9d24fb 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/InstructionImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/InstructionImpl.java @@ -35,16 +35,15 @@ public class InstructionImpl implements Instruction { private final LinkedHashSet myNegations = new LinkedHashSet(); PsiElement myPsiElement; - private final int myNumber; + private int myNumber = -1; @Nullable public PsiElement getElement() { return myPsiElement; } - public InstructionImpl(@Nullable PsiElement element, int num) { + public InstructionImpl(@Nullable PsiElement element) { myPsiElement = element; - myNumber = num; } public Iterable successors(CallEnvironment environment) { @@ -91,6 +90,7 @@ public class InstructionImpl implements Instruction { } public int num() { + assert myNumber != -1; return myNumber; } @@ -116,4 +116,9 @@ public class InstructionImpl implements Instruction { myNegations.add((NegatingGotoInstruction)instruction); } } + + final void setNumber(int num) { + assert myNumber == -1; + myNumber = num; + } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/MaybeReturnInstruction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/MaybeReturnInstruction.java index 74bdb78d4c57..7720041c4486 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/MaybeReturnInstruction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/MaybeReturnInstruction.java @@ -23,8 +23,8 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpres * @author peter */ public class MaybeReturnInstruction extends InstructionImpl { - MaybeReturnInstruction(GrExpression element, int num) { - super(element, num); + MaybeReturnInstruction(GrExpression element) { + super(element); } public String toString() { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ThrowingInstruction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ThrowingInstruction.java index ba256f569a0f..e2f312eed69c 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ThrowingInstruction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ThrowingInstruction.java @@ -23,8 +23,8 @@ import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction; * @author Max Medvedev */ public class ThrowingInstruction extends InstructionImpl { - public ThrowingInstruction(@Nullable PsiElement element, int num) { - super(element, num); + public ThrowingInstruction(@Nullable PsiElement element) { + super(element); } @Override From 9e984ab7329e3304aeb21cf3b7a2020861720603 Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Wed, 13 Jun 2012 12:03:04 +0400 Subject: [PATCH 099/172] don't require test name to be non-empty --- .../sm/runner/OutputToGeneralTestEventsConverter.java | 4 ++-- .../testframework/sm/runner/events/TreeNodeEvent.java | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/OutputToGeneralTestEventsConverter.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/OutputToGeneralTestEventsConverter.java index 9554844e1455..13f28ad5b9da 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/OutputToGeneralTestEventsConverter.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/OutputToGeneralTestEventsConverter.java @@ -247,11 +247,11 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer } } - private void fireOnSuiteFinished(@NotNull TestSuiteFinishedEvent nodeFinishedEvent) { + private void fireOnSuiteFinished(@NotNull TestSuiteFinishedEvent suiteFinishedEvent) { // local variable is used to prevent concurrent modification final GeneralTestEventsProcessor processor = myProcessor; if (processor != null) { - processor.onSuiteFinished(nodeFinishedEvent); + processor.onSuiteFinished(suiteFinishedEvent); } } diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/events/TreeNodeEvent.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/events/TreeNodeEvent.java index 2758e5536bb1..8858fc71ca64 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/events/TreeNodeEvent.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/events/TreeNodeEvent.java @@ -15,7 +15,7 @@ */ package com.intellij.execution.testframework.sm.runner.events; -import jetbrains.buildServer.messages.serviceMessages.MessageWithAttributes; +import jetbrains.buildServer.messages.serviceMessages.ServiceMessage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -37,9 +37,6 @@ public abstract class TreeNodeEvent { if (myId < -1) { fail("id should be greater than -2"); } - if (myName != null && myName.isEmpty()) { - fail("Tree node name is empty"); - } } protected void fail(@NotNull String message) { @@ -86,11 +83,11 @@ public abstract class TreeNodeEvent { } } - public static int getNodeId(@NotNull MessageWithAttributes message) { + public static int getNodeId(@NotNull ServiceMessage message) { return getIntAttribute(message, "nodeId"); } - public static int getIntAttribute(@NotNull MessageWithAttributes message, @NotNull String key) { + public static int getIntAttribute(@NotNull ServiceMessage message, @NotNull String key) { String value = message.getAttributes().get(key); if (value == null) { return -1; From cab2ad0f10ba9ddaab633b90fc5e78d7fd81ae48 Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Wed, 13 Jun 2012 13:21:25 +0400 Subject: [PATCH 100/172] EA-36478 --- .../designSurface/InplaceEditingLayer.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/InplaceEditingLayer.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/InplaceEditingLayer.java index a0a8cbfe7b86..e47fe94ee638 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/InplaceEditingLayer.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/InplaceEditingLayer.java @@ -173,19 +173,27 @@ public class InplaceEditingLayer extends JComponent { myInplaceComponent.setBounds(bounds.x, bounds.y, myPreferredWidth, size.height); add(myInplaceComponent); + myDesigner.getSurfaceArea().addSelectionListener(mySelectionListener); + if (componentToFocus == null) { componentToFocus = IdeFocusTraversalPolicy.getPreferredFocusedComponent(myInplaceComponent); } - if (componentToFocus != null) { - componentToFocus.requestFocusInWindow(); + if (componentToFocus == null) { + componentToFocus = myInplaceComponent; + } + if (componentToFocus.requestFocusInWindow()) { + myFocusWatcher.install(myInplaceComponent); } else { - myInplaceComponent.requestFocusInWindow(); + grabFocus(); + componentToFocus.requestFocusInWindow(); + ApplicationManager.getApplication().invokeLater(new Runnable() { + public void run() { + myFocusWatcher.install(myInplaceComponent); + } + }); } - myDesigner.getSurfaceArea().addSelectionListener(mySelectionListener); - myFocusWatcher.install(myInplaceComponent); - enableEvents(AWTEvent.MOUSE_EVENT_MASK); repaint(); } From 997d0da928b1bc51cf2ccdf5cd26b924cd153bd1 Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Wed, 13 Jun 2012 13:43:48 +0400 Subject: [PATCH 101/172] Hide column header --- .../com/intellij/designer/propertyTable/PropertyTable.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/PropertyTable.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/PropertyTable.java index 3fe2aab4930a..bcc840cd979e 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/PropertyTable.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/PropertyTable.java @@ -45,6 +45,7 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.plaf.TableUI; import javax.swing.table.AbstractTableModel; +import javax.swing.table.JTableHeader; import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; import java.awt.*; @@ -85,6 +86,10 @@ public final class PropertyTable extends JBTable implements ComponentSelectionLi setModel(myModel); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + JTableHeader tableHeader = getTableHeader(); + tableHeader.setVisible(false); + tableHeader.setPreferredSize(new Dimension()); + addMouseListener(new MouseTableListener()); getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override From 23debfbdf16ac372ee33fa78cfd3e9a5280f8ec1 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Wed, 13 Jun 2012 13:43:20 +0400 Subject: [PATCH 102/172] cleanup --- .../resolve/ast/DelegatedMethodsContributor.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ast/DelegatedMethodsContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ast/DelegatedMethodsContributor.java index cb4a439041e2..cdaaec262769 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ast/DelegatedMethodsContributor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ast/DelegatedMethodsContributor.java @@ -15,12 +15,14 @@ */ package org.jetbrains.plugins.groovy.lang.resolve.ast; -import com.intellij.openapi.util.Key; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.impl.light.LightMethodBuilder; import com.intellij.psi.impl.light.LightMirrorMethod; -import com.intellij.psi.util.*; +import com.intellij.psi.util.MethodSignature; +import com.intellij.psi.util.MethodSignatureUtil; +import com.intellij.psi.util.PsiUtil; +import com.intellij.psi.util.TypeConversionUtil; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.hash.HashSet; import gnu.trove.THashMap; @@ -44,9 +46,6 @@ import java.util.*; * @author Max Medvedev */ public class DelegatedMethodsContributor extends AstTransformContributor { - - private static Key> CACHED_DELEGATED_METHODS = Key.create("cached delegated methods"); - @Override public void collectMethods(@NotNull final GrTypeDefinition clazz, Collection collector) { Set processed = new HashSet(); @@ -160,7 +159,7 @@ public class DelegatedMethodsContributor extends AstTransformContributor { * @param collector result collection */ private static void process(PsiClass clazz, - PsiSubstitutor superClassSubsitutor, + PsiSubstitutor superClassSubstitutor, Set processed, List collector, GrTypeDefinition classToDelegateTo) { @@ -168,7 +167,7 @@ public class DelegatedMethodsContributor extends AstTransformContributor { //process super methods before delegated methods for (PsiClassType superType : clazz.getSuperTypes()) { - processClassInner(superType, superClassSubsitutor, true, result, classToDelegateTo, processed); + processClassInner(superType, superClassSubstitutor, true, result, classToDelegateTo, processed); } if (clazz instanceof GrTypeDefinition) { @@ -180,7 +179,7 @@ public class DelegatedMethodsContributor extends AstTransformContributor { final PsiType type = field.getDeclaredType(); if (!(type instanceof PsiClassType)) continue; - processClassInner((PsiClassType)type, superClassSubsitutor, shouldDelegateDeprecated(delegate), result, classToDelegateTo, processed); + processClassInner((PsiClassType)type, superClassSubstitutor, shouldDelegateDeprecated(delegate), result, classToDelegateTo, processed); } } From 7409d481cf6cc3bc28dccba185a96e462f5089fe Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Wed, 13 Jun 2012 13:52:31 +0400 Subject: [PATCH 103/172] IDEA-87255 Invalid groovy stub generation with @Delegate and final methods in superclass --- .../convertToJava/StubGenerator.java | 13 +++- .../groovy/compiler/GeneratorTest.java | 4 ++ .../groovy/stubGenerator/finalMethods.test | 67 +++++++++++++++++++ 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 plugins/groovy/testdata/groovy/stubGenerator/finalMethods.test diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/StubGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/StubGenerator.java index 8bb3a4e6d155..09aab643117f 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/StubGenerator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/StubGenerator.java @@ -20,13 +20,13 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.impl.light.LightMethodBuilder; +import com.intellij.psi.impl.light.LightMirrorMethod; import com.intellij.psi.util.MethodSignature; import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; import com.intellij.psi.util.PsiUtil; import com.intellij.psi.util.TypeConversionUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.containers.CollectionFactory; -import com.intellij.util.containers.ContainerUtil; import gnu.trove.THashSet; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; @@ -278,7 +278,16 @@ public class StubGenerator implements ClassItemGenerator { @Override public Collection collectMethods(PsiClass typeDefinition, boolean classDef) { List methods = new ArrayList(); - ContainerUtil.addAll(methods, typeDefinition.getMethods()); + for (PsiMethod method : typeDefinition.getMethods()) { + if (method instanceof LightMirrorMethod) { + PsiMethod prototype = ((LightMirrorMethod)method).getPrototype(); + PsiClass aClass = prototype.getContainingClass(); + if (prototype.hasModifierProperty(PsiModifier.FINAL) && aClass != null && typeDefinition.isInheritor(aClass, true)) { + continue; //skip final super methods + } + } + methods.add(method); + } if (classDef) { final Collection toOverride = OverrideImplementUtil.getMethodSignaturesToOverride(typeDefinition); for (MethodSignature signature : toOverride) { diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GeneratorTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GeneratorTest.java index 42ca5ab50003..1041a9cb6e88 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GeneratorTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GeneratorTest.java @@ -122,6 +122,10 @@ public class GeneratorTest extends LightGroovyTestCase { doTest(); } + public void testFinalMethods() { + doTest(); + } + public void doTest() { final String relTestPath = getTestName(true) + ".test"; final List data = TestUtils.readInput(getTestDataPath() + "/" + relTestPath); diff --git a/plugins/groovy/testdata/groovy/stubGenerator/finalMethods.test b/plugins/groovy/testdata/groovy/stubGenerator/finalMethods.test new file mode 100644 index 000000000000..e8678dfee028 --- /dev/null +++ b/plugins/groovy/testdata/groovy/stubGenerator/finalMethods.test @@ -0,0 +1,67 @@ +class B { + final void foo(){} +} + +class C extends B { + @Delegate Object o +} +----- +public class B extends groovy.lang.GroovyObjectSupport implements groovy.lang.GroovyObject { +public final void foo() { +return ; +} + +public java.lang.Object getProperty(java.lang.String property) { +return null; +} + +public void setProperty(java.lang.String property, java.lang.Object newValue) { +return ; +} + +public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) { +return null; +} + +public groovy.lang.MetaClass getMetaClass() { +return null; +} + +public void setMetaClass(groovy.lang.MetaClass metaClass) { +return ; +} + +} +--- +public class C extends B implements groovy.lang.GroovyObject { +public java.lang.Object getO() { +return null; +} + +public void setO(java.lang.Object o) { +return ; +} + +public java.lang.Object getProperty(java.lang.String property) { +return null; +} + +public void setProperty(java.lang.String property, java.lang.Object newValue) { +return ; +} + +public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) { +return null; +} + +public groovy.lang.MetaClass getMetaClass() { +return null; +} + +public void setMetaClass(groovy.lang.MetaClass metaClass) { +return ; +} + +private java.lang.Object o = null; +} +--- From e81e3a60da966bca54afdc12dc688b8d5122c0fc Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Wed, 13 Jun 2012 15:20:31 +0400 Subject: [PATCH 104/172] EA-36478 --- .../uiDesigner/designSurface/GuiEditor.java | 2 +- .../designSurface/InplaceEditingLayer.java | 22 +++++++++++++------ .../designSurface/InplaceEditingLayer.java | 3 ++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java index d5e8dbbc09db..19784cd03e1a 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java @@ -249,7 +249,7 @@ public final class GuiEditor extends JPanel implements DataProvider, ModuleProvi myGlassLayer.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { myDecorationLayer.repaint(); - fireSelectedComponentChanged(); + //fireSelectedComponentChanged(); // EA-36478 } public void focusLost(FocusEvent e) { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/InplaceEditingLayer.java b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/InplaceEditingLayer.java index ec3e5a1135d9..766916515186 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/InplaceEditingLayer.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/InplaceEditingLayer.java @@ -198,20 +198,28 @@ public final class InplaceEditingLayer extends JComponent{ // 3. Add it into layer add(myInplaceEditorComponent); myInplaceEditorComponent.revalidate(); - myInplaceEditorComponent.requestFocusInWindow(); // 4. Request focus into proper component JComponent componentToFocus = myInplaceEditor.getPreferredFocusedComponent(myInplaceEditorComponent); - if(componentToFocus == null){ + if (componentToFocus == null) { componentToFocus = IdeFocusTraversalPolicy.getPreferredFocusedComponent(myInplaceEditorComponent); } - if(componentToFocus != null){ - componentToFocus.requestFocusInWindow(); + if (componentToFocus == null) { + componentToFocus = myInplaceEditorComponent; } - else{ - myInplaceEditorComponent.requestFocusInWindow(); + if (componentToFocus.requestFocusInWindow()) { + myFocusWatcher.install(myInplaceEditorComponent); + } + else { + grabFocus(); + final JComponent finalComponentToFocus = componentToFocus; + ApplicationManager.getApplication().invokeLater(new Runnable() { + public void run() { + finalComponentToFocus.requestFocusInWindow(); + myFocusWatcher.install(myInplaceEditorComponent); + } + }); } - myFocusWatcher.install(myInplaceEditorComponent); // 5. Block any mouse event to finish editing by any of them enableEvents(MouseEvent.MOUSE_EVENT_MASK); diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/InplaceEditingLayer.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/InplaceEditingLayer.java index e47fe94ee638..a593f3908721 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/InplaceEditingLayer.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/InplaceEditingLayer.java @@ -186,9 +186,10 @@ public class InplaceEditingLayer extends JComponent { } else { grabFocus(); - componentToFocus.requestFocusInWindow(); + final JComponent finalComponentToFocus = componentToFocus; ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { + finalComponentToFocus.requestFocusInWindow(); myFocusWatcher.install(myInplaceComponent); } }); From 948358983371f2b4f416eda644b1f13e0ee3b186 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 13 Jun 2012 15:21:10 +0400 Subject: [PATCH 105/172] FileWatcherTest stability fix --- .../openapi/vfs/local/FileWatcherTest.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java index 91f46cc63d01..9835414cd750 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java @@ -42,17 +42,19 @@ import java.io.IOException; import java.util.*; public class FileWatcherTest extends PlatformLangTestCase { - private static final int NATIVE_PROCESS_DELAY = 750; // time to event to be caught by native watcher and passed to watcher thread + private static final int NATIVE_PROCESS_DELAY = 750; // time for events to be caught by native watcher and passed to watcher thread private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vfs.impl.local.FileWatcher"); private FileWatcher myWatcher; private LocalFileSystem myFileSystem; private MessageBusConnection myConnection; + private volatile boolean myAccept = false; private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD); private final Runnable myNotifier = new Runnable() { @Override public void run() { + if (!myAccept) return; synchronized (myAlarm) { myAlarm.cancelAllRequests(); myAlarm.addRequest(new Runnable() { @@ -429,11 +431,17 @@ public class FileWatcherTest extends PlatformLangTestCase { private List getEvents() throws InterruptedException { - waitForResponse(); - myFileSystem.refresh(false); - final ArrayList result = new ArrayList(myEvents); - myEvents.clear(); - return result; + myAccept = true; + try { + waitForResponse(); + myFileSystem.refresh(false); + final ArrayList result = new ArrayList(myEvents); + myEvents.clear(); + return result; + } + finally { + myAccept = false; + } } private void waitForResponse() throws InterruptedException { @@ -445,9 +453,7 @@ public class FileWatcherTest extends PlatformLangTestCase { private void clearEvents() { myFileSystem.refresh(false); - synchronized (myEvents) { - myEvents.clear(); - } + myEvents.clear(); } @NotNull From f0ecf877ba374c894286c21a7433ae900c5f26b6 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 13 Jun 2012 15:35:56 +0400 Subject: [PATCH 106/172] test fixed --- .../maven/dom/MavenDependencyCompletionAndResolutionTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java index 91a59d600a73..34a218318537 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java @@ -636,7 +636,7 @@ public class MavenDependencyCompletionAndResolutionTest extends MavenDomWithIndi " " + ""); - assertCompletionVariants(myProjectPom, "jar", "test-jar", "pom", "ear", "ejb", "ejb-client", "war", "bundle"); + assertCompletionVariants(myProjectPom, "jar", "test-jar", "pom", "ear", "ejb", "ejb-client", "war", "bundle", "jboss-har"); } public void testDoNotHighlightUnknownType() throws Throwable { From 653dd2720e7c2f4e7cdd7d9828ae212b49c13ec8 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Wed, 13 Jun 2012 16:10:00 +0400 Subject: [PATCH 107/172] avoid project leak --- .../android/logcat/AndroidLogcatToolWindowFactory.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/android/src/org/jetbrains/android/logcat/AndroidLogcatToolWindowFactory.java b/plugins/android/src/org/jetbrains/android/logcat/AndroidLogcatToolWindowFactory.java index 49926ecd6171..e6a826f06825 100644 --- a/plugins/android/src/org/jetbrains/android/logcat/AndroidLogcatToolWindowFactory.java +++ b/plugins/android/src/org/jetbrains/android/logcat/AndroidLogcatToolWindowFactory.java @@ -65,16 +65,16 @@ public class AndroidLogcatToolWindowFactory implements ToolWindowFactory { final AndroidLogcatToolWindowView view = new AndroidLogcatToolWindowView(project) { @Override protected boolean isActive() { - return toolWindow.isVisible(); + ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID); + return window.isVisible(); } }; - final ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(project); - toolWindowManager.addToolWindowManagerListener(new ToolWindowManagerAdapter() { + ToolWindowManagerEx.getInstanceEx(project).addToolWindowManagerListener(new ToolWindowManagerAdapter() { boolean myToolWindowVisible; @Override public void stateChanged() { - ToolWindow window = toolWindowManager.getToolWindow(TOOL_WINDOW_ID); + ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID); if (window != null) { boolean visible = window.isVisible(); if (visible != myToolWindowVisible) { @@ -125,7 +125,7 @@ public class AndroidLogcatToolWindowFactory implements ToolWindowFactory { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { view.activate(); - final ToolWindow window = toolWindowManager.getToolWindow(TOOL_WINDOW_ID); + final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID); if (window != null && window.isVisible()) { checkFacetAndSdk(project, view); } From 549fb156c696fc99b6abc42be11af11224015904 Mon Sep 17 00:00:00 2001 From: Danila Ponomarenko Date: Wed, 13 Jun 2012 17:16:59 +0400 Subject: [PATCH 108/172] BinaryUnwrapper to PolyadicUnwrapper --- ...a => JavaPolyadicExpressionUnwrapper.java} | 47 +++++++++++++------ .../unwrap/JavaUnwrapDescriptor.java | 2 +- 2 files changed, 33 insertions(+), 16 deletions(-) rename java/java-impl/src/com/intellij/codeInsight/unwrap/{JavaBinaryExpressionUnwrapper.java => JavaPolyadicExpressionUnwrapper.java} (51%) diff --git a/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaBinaryExpressionUnwrapper.java b/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaPolyadicExpressionUnwrapper.java similarity index 51% rename from java/java-impl/src/com/intellij/codeInsight/unwrap/JavaBinaryExpressionUnwrapper.java rename to java/java-impl/src/com/intellij/codeInsight/unwrap/JavaPolyadicExpressionUnwrapper.java index 3d1438e42071..1fa629365025 100644 --- a/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaBinaryExpressionUnwrapper.java +++ b/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaPolyadicExpressionUnwrapper.java @@ -16,17 +16,19 @@ package com.intellij.codeInsight.unwrap; import com.intellij.codeInsight.CodeInsightBundle; -import com.intellij.openapi.util.Comparing; -import com.intellij.psi.PsiBinaryExpression; +import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiExpression; +import com.intellij.psi.PsiPolyadicExpression; import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author Danila Ponomarenko */ -public class JavaBinaryExpressionUnwrapper extends JavaUnwrapper { - public JavaBinaryExpressionUnwrapper() { +public class JavaPolyadicExpressionUnwrapper extends JavaUnwrapper { + public JavaPolyadicExpressionUnwrapper() { super(""); } @@ -37,26 +39,41 @@ public class JavaBinaryExpressionUnwrapper extends JavaUnwrapper { @Override public boolean isApplicableTo(PsiElement e) { - return e.getParent() instanceof PsiBinaryExpression; + if (!(e.getParent() instanceof PsiPolyadicExpression)) { + return false; + } + + final PsiPolyadicExpression expression = (PsiPolyadicExpression)e.getParent(); + + final PsiExpression operand = findOperand(e, expression); + + return operand != null; } @Override protected void doUnwrap(PsiElement element, Context context) throws IncorrectOperationException { - final PsiBinaryExpression parent = (PsiBinaryExpression)element.getParent(); + final PsiPolyadicExpression parent = (PsiPolyadicExpression)element.getParent(); - final PsiExpression lOperand = parent.getLOperand(); - final PsiExpression rOperand = parent.getROperand(); + final PsiExpression operand = findOperand(element, parent); - if (rOperand == null) { + if (operand == null) { return; } - if (Comparing.equal(lOperand, element)) { - context.extractElement(rOperand, parent); - } - else { - context.extractElement(lOperand, parent); - } + context.extractElement(operand, parent); context.delete(parent); } + + @Nullable + private static PsiExpression findOperand(@NotNull PsiElement e, @NotNull PsiPolyadicExpression expression) { + final TextRange elementTextRange = e.getTextRange(); + + for (PsiExpression operand : expression.getOperands()) { + final TextRange operandTextRange = operand.getTextRange(); + if (operandTextRange != null && operandTextRange.contains(elementTextRange)) { + return operand; + } + } + return null; + } } diff --git a/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaUnwrapDescriptor.java b/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaUnwrapDescriptor.java index f3dc91b8cdb6..ead2eff79ade 100644 --- a/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaUnwrapDescriptor.java +++ b/java/java-impl/src/com/intellij/codeInsight/unwrap/JavaUnwrapDescriptor.java @@ -33,7 +33,7 @@ public class JavaUnwrapDescriptor extends UnwrapDescriptorBase { new JavaSynchronizedUnwrapper(), new JavaAnonymousUnwrapper(), new JavaConditionalUnwrapper(), - new JavaBinaryExpressionUnwrapper() + new JavaPolyadicExpressionUnwrapper() }; } } From aae0aa0639ceaf0930aaa4d7a1215f9bd883f01a Mon Sep 17 00:00:00 2001 From: Danila Ponomarenko Date: Wed, 13 Jun 2012 17:17:22 +0400 Subject: [PATCH 109/172] IDEA-86117 boolean expressions: intentions and Unwrap/Remove partial impl --- .../impl/ExtractIfConditionAction.java | 267 ++++++++++++++++++ .../src/messages/CodeInsightBundle.properties | 3 + resources/src/META-INF/IdeaPlugin.xml | 4 + 3 files changed, 274 insertions(+) create mode 100644 java/java-impl/src/com/intellij/codeInsight/intention/impl/ExtractIfConditionAction.java diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ExtractIfConditionAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ExtractIfConditionAction.java new file mode 100644 index 000000000000..ee186c3710e0 --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ExtractIfConditionAction.java @@ -0,0 +1,267 @@ +/* + * 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.codeInsight.intention.impl; + +import com.intellij.codeInsight.CodeInsightBundle; +import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.*; +import com.intellij.psi.codeStyle.CodeStyleManager; +import com.intellij.psi.impl.JavaFactoryProvider; +import com.intellij.psi.tree.IElementType; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.util.IncorrectOperationException; +import com.intellij.util.ObjectUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Danila Ponomarenko + */ +public class ExtractIfConditionAction extends PsiElementBaseIntentionAction { + @Override + public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) { + final PsiIfStatement ifStatement = PsiTreeUtil.getParentOfType(element, PsiIfStatement.class); + if (ifStatement == null || ifStatement.getCondition() == null || !(ifStatement.getCondition() instanceof PsiBinaryExpression)) { + return false; + } + + final PsiExpression condition = ifStatement.getCondition(); + + if (condition == null || !(condition instanceof PsiBinaryExpression)) { + return false; + } + + final PsiBinaryExpression binaryCondition = (PsiBinaryExpression)condition; + final PsiType expressionType = binaryCondition.getType(); + if (expressionType == null || !PsiType.BOOLEAN.isAssignableFrom(expressionType)) { + return false; + } + + final IElementType operation = binaryCondition.getOperationTokenType(); + + if (operation != JavaTokenType.OROR && operation != JavaTokenType.ANDAND) { + return false; + } + + final PsiExpression lOperand = binaryCondition.getLOperand(); + final PsiExpression rOperand = binaryCondition.getROperand(); + + if (rOperand == null) { + return false; + } + + final TextRange lOperandTextRange = lOperand.getTextRange(); + final TextRange rOperandTextRange = rOperand.getTextRange(); + final TextRange elementTextRange = element.getTextRange(); + + if (lOperandTextRange == null || rOperandTextRange == null || elementTextRange == null) { + return false; + } + + if (lOperandTextRange.contains(elementTextRange)) { + setText(CodeInsightBundle.message("intention.extract.if.condition.text", lOperand.getText())); + return true; + } + + if (rOperandTextRange.contains(elementTextRange)) { + setText(CodeInsightBundle.message("intention.extract.if.condition.text", rOperand.getText())); + return true; + } + + return false; + } + + @Override + public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { + final PsiIfStatement ifStatement = PsiTreeUtil.getParentOfType(element, PsiIfStatement.class); + if (ifStatement == null || ifStatement.getCondition() == null || !(ifStatement.getCondition() instanceof PsiBinaryExpression)) { + return; + } + + final PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory(); + final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project); + + final PsiStatement newIfStatement = create(factory, ifStatement, element); + if (newIfStatement == null) { + return; + } + + ifStatement.replace(codeStyleManager.reformat(newIfStatement)); + } + + @Nullable + private static PsiStatement create(@NotNull PsiElementFactory factory, + @NotNull PsiIfStatement ifStatement, + @NotNull PsiElement element) { + + final PsiExpression condition = ifStatement.getCondition(); + + if (condition == null || !(condition instanceof PsiBinaryExpression)) { + return null; + } + + final PsiBinaryExpression binaryCondition = (PsiBinaryExpression)condition; + + final PsiExpression lOperand = binaryCondition.getLOperand(); + final PsiExpression rOperand = binaryCondition.getROperand(); + + if (rOperand == null) { + return null; + } + + final TextRange lOperandTextRange = lOperand.getTextRange(); + final TextRange rOperandTextRange = rOperand.getTextRange(); + final TextRange elementTextRange = element.getTextRange(); + + if (lOperandTextRange == null || rOperandTextRange == null) { + return null; + } + + if (lOperandTextRange.contains(elementTextRange)) { + return create(factory, ifStatement.getThenBranch(), ifStatement.getElseBranch(), lOperand, rOperand, binaryCondition.getOperationTokenType()); + } + else if (rOperandTextRange.contains(elementTextRange)) { + return create(factory, ifStatement.getThenBranch(), ifStatement.getElseBranch(), rOperand, lOperand, binaryCondition.getOperationTokenType()); + } + + return null; + } + + @Nullable + private static PsiStatement create(@NotNull PsiElementFactory factory, + @Nullable PsiStatement thenBranch, + @Nullable PsiStatement elseBranch, + @NotNull PsiExpression extract, + @NotNull PsiExpression leave, + @NotNull IElementType operation) { + if (thenBranch == null) { + return null; + } + + if (operation == JavaTokenType.OROR) { + return createOrOr(factory, thenBranch, elseBranch, extract, leave); + } + if (operation == JavaTokenType.ANDAND) { + return createAndAnd(factory, thenBranch, elseBranch, extract, leave); + } + + return null; + } + + @NotNull + private static PsiStatement createAndAnd(@NotNull PsiElementFactory factory, + @NotNull PsiStatement thenBranch, + @Nullable PsiStatement elseBranch, + @NotNull PsiExpression extract, + @NotNull PsiExpression leave) { + + return factory.createStatementFromText( + createIfString(extract, + createIfString(leave, thenBranch, elseBranch), + elseBranch + ), + thenBranch + ); + } + + @NotNull + private static PsiStatement createOrOr(@NotNull PsiElementFactory factory, + @NotNull PsiStatement thenBranch, + @Nullable PsiStatement elseBranch, + @NotNull PsiExpression extract, + @NotNull PsiExpression leave) { + + return factory.createStatementFromText( + createIfString(extract, thenBranch, + createIfString(leave, thenBranch, elseBranch) + ), + thenBranch + ); + } + + @NotNull + private static String createIfString(@NotNull PsiExpression condition, + @NotNull PsiStatement thenBranch, + @Nullable PsiStatement elseBranch) { + return createIfString(condition.getText(), toThenBranchString(thenBranch), toElseBranchString(elseBranch)); + } + + @NotNull + private static String createIfString(@NotNull PsiExpression condition, + @NotNull PsiStatement thenBranch, + @Nullable String elseBranch) { + return createIfString(condition.getText(), toThenBranchString(thenBranch), elseBranch); + } + + @NotNull + private static String createIfString(@NotNull PsiExpression condition, + @NotNull String thenBranch, + @Nullable PsiStatement elseBranch) { + return createIfString(condition.getText(), thenBranch, toElseBranchString(elseBranch)); + } + + @NotNull + private static String createIfString(@NotNull String condition, + @NotNull String thenBranch, + @Nullable String elseBranch) { + final String elsePart = elseBranch != null ? " else " + elseBranch : ""; + return "if (" + condition + ")\n" + thenBranch + elsePart; + } + + @NotNull + private static String toThenBranchString(@NotNull PsiStatement statement) { + if (!(statement instanceof PsiBlockStatement)) { + return "{ " + statement.getText() + " }"; + } + + return statement.getText(); + } + + @Nullable + private static String toElseBranchString(@Nullable PsiStatement statement) { + if (statement == null) { + return null; + } + + if (statement instanceof PsiBlockStatement || statement instanceof PsiIfStatement) { + return statement.getText(); + } + + return "{ " + statement.getText() + " }"; + } + + @Nullable + private static PsiExpression findOperand(@NotNull PsiElement e, @NotNull PsiPolyadicExpression expression) { + final TextRange elementTextRange = e.getTextRange(); + + for (PsiExpression operand : expression.getOperands()) { + final TextRange operandTextRange = operand.getTextRange(); + if (operandTextRange != null && operandTextRange.contains(elementTextRange)) { + return operand; + } + } + return null; + } + + @NotNull + @Override + public String getFamilyName() { + return CodeInsightBundle.message("intention.extract.if.condition.family"); + } +} diff --git a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties index 629ad188ee85..773e1c1cd3cf 100644 --- a/platform/platform-resources-en/src/messages/CodeInsightBundle.properties +++ b/platform/platform-resources-en/src/messages/CodeInsightBundle.properties @@ -200,10 +200,13 @@ intention.implement.abstract.method.error.no.classes.title=No Classes Found intention.implement.abstract.method.class.chooser.title=Choose Implementing Class intention.implement.abstract.method.command.name=Implement method intention.invert.if.condition=Invert If Condition +intention.extract.if.condition.text=Extract if ({0}) +intention.extract.if.condition.family=Extract If Condition intention.underscores.in.literals.family=Underscores in numeric literals intention.remove.literal.underscores=Remove underscores from literal intention.insert.literal.underscores=Insert underscores into literal + intention.create.test=Create Test intention.create.test.dialog.testing.library=Testing library: intention.create.test.dialog.language=Language: diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 605a9c3edae4..b5e6933e783d 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -547,6 +547,10 @@ com.intellij.codeInsight.intention.impl.InvertIfConditionAction Control Flow + + com.intellij.codeInsight.intention.impl.ExtractIfConditionAction + Control Flow + com.intellij.codeInsight.daemon.impl.quickfix.RemoveRedundantElseAction Control Flow From 520d5b8da2b0d5d9b83ec988023ff5307860799b Mon Sep 17 00:00:00 2001 From: Danila Ponomarenko Date: Wed, 13 Jun 2012 17:38:32 +0400 Subject: [PATCH 110/172] IDEA-86117 boolean expressions: intentions and Unwrap/Remove implemented --- .../impl/ExtractIfConditionAction.java | 83 ++++++++----------- 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ExtractIfConditionAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ExtractIfConditionAction.java index ee186c3710e0..fe01746dcfc5 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ExtractIfConditionAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ExtractIfConditionAction.java @@ -19,6 +19,7 @@ import com.intellij.codeInsight.CodeInsightBundle; import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.TextRange; import com.intellij.psi.*; import com.intellij.psi.codeStyle.CodeStyleManager; @@ -37,60 +38,41 @@ public class ExtractIfConditionAction extends PsiElementBaseIntentionAction { @Override public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) { final PsiIfStatement ifStatement = PsiTreeUtil.getParentOfType(element, PsiIfStatement.class); - if (ifStatement == null || ifStatement.getCondition() == null || !(ifStatement.getCondition() instanceof PsiBinaryExpression)) { + if (ifStatement == null || ifStatement.getCondition() == null) { return false; } final PsiExpression condition = ifStatement.getCondition(); - if (condition == null || !(condition instanceof PsiBinaryExpression)) { + if (condition == null || !(condition instanceof PsiPolyadicExpression)) { return false; } - final PsiBinaryExpression binaryCondition = (PsiBinaryExpression)condition; - final PsiType expressionType = binaryCondition.getType(); + final PsiPolyadicExpression polyadicExpression = (PsiPolyadicExpression)condition; + final PsiType expressionType = polyadicExpression.getType(); if (expressionType == null || !PsiType.BOOLEAN.isAssignableFrom(expressionType)) { return false; } - final IElementType operation = binaryCondition.getOperationTokenType(); + final IElementType operation = polyadicExpression.getOperationTokenType(); if (operation != JavaTokenType.OROR && operation != JavaTokenType.ANDAND) { return false; } - final PsiExpression lOperand = binaryCondition.getLOperand(); - final PsiExpression rOperand = binaryCondition.getROperand(); + final PsiExpression operand = findOperand(element, polyadicExpression); - if (rOperand == null) { + if (operand == null) { return false; } - - final TextRange lOperandTextRange = lOperand.getTextRange(); - final TextRange rOperandTextRange = rOperand.getTextRange(); - final TextRange elementTextRange = element.getTextRange(); - - if (lOperandTextRange == null || rOperandTextRange == null || elementTextRange == null) { - return false; - } - - if (lOperandTextRange.contains(elementTextRange)) { - setText(CodeInsightBundle.message("intention.extract.if.condition.text", lOperand.getText())); - return true; - } - - if (rOperandTextRange.contains(elementTextRange)) { - setText(CodeInsightBundle.message("intention.extract.if.condition.text", rOperand.getText())); - return true; - } - - return false; + setText(CodeInsightBundle.message("intention.extract.if.condition.text", operand.getText())); + return true; } @Override public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { final PsiIfStatement ifStatement = PsiTreeUtil.getParentOfType(element, PsiIfStatement.class); - if (ifStatement == null || ifStatement.getCondition() == null || !(ifStatement.getCondition() instanceof PsiBinaryExpression)) { + if (ifStatement == null) { return; } @@ -112,35 +94,42 @@ public class ExtractIfConditionAction extends PsiElementBaseIntentionAction { final PsiExpression condition = ifStatement.getCondition(); - if (condition == null || !(condition instanceof PsiBinaryExpression)) { + if (condition == null || !(condition instanceof PsiPolyadicExpression)) { return null; } - final PsiBinaryExpression binaryCondition = (PsiBinaryExpression)condition; + final PsiPolyadicExpression polyadicExpression = (PsiPolyadicExpression)condition; - final PsiExpression lOperand = binaryCondition.getLOperand(); - final PsiExpression rOperand = binaryCondition.getROperand(); + final PsiExpression operand = findOperand(element, polyadicExpression); - if (rOperand == null) { + if (operand == null) { return null; } - final TextRange lOperandTextRange = lOperand.getTextRange(); - final TextRange rOperandTextRange = rOperand.getTextRange(); - final TextRange elementTextRange = element.getTextRange(); - if (lOperandTextRange == null || rOperandTextRange == null) { - return null; - } + return create( + factory, + ifStatement.getThenBranch(), ifStatement.getElseBranch(), + operand, + removeOperand(factory, polyadicExpression, operand), + polyadicExpression.getOperationTokenType() + ); + } - if (lOperandTextRange.contains(elementTextRange)) { - return create(factory, ifStatement.getThenBranch(), ifStatement.getElseBranch(), lOperand, rOperand, binaryCondition.getOperationTokenType()); + @NotNull + private static PsiExpression removeOperand(@NotNull PsiElementFactory factory, + @NotNull PsiPolyadicExpression expression, + @NotNull PsiExpression operand) { + final StringBuilder sb = new StringBuilder(); + for (PsiExpression e : expression.getOperands()) { + if (e == operand) continue; + final PsiJavaToken token = expression.getTokenBeforeOperand(e); + if (token != null && sb.length() != 0) { + sb.append(token.getText()).append(" "); + } + sb.append(e.getText()); } - else if (rOperandTextRange.contains(elementTextRange)) { - return create(factory, ifStatement.getThenBranch(), ifStatement.getElseBranch(), rOperand, lOperand, binaryCondition.getOperationTokenType()); - } - - return null; + return factory.createExpressionFromText(sb.toString(), expression); } @Nullable From aab6d25d2da07d93b8d1436156a4f95c9581cd7b Mon Sep 17 00:00:00 2001 From: Danila Ponomarenko Date: Wed, 13 Jun 2012 17:56:10 +0400 Subject: [PATCH 111/172] IDEA-86117 boolean expressions: intentions and Unwrap/Remove description added --- .../intention/impl/ExtractIfConditionAction.java | 3 --- .../ExtractIfConditionAction/after.java.template | 7 +++++++ .../ExtractIfConditionAction/before.java.template | 5 +++++ .../ExtractIfConditionAction/description.html | 5 +++++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 resources-en/src/intentionDescriptions/ExtractIfConditionAction/after.java.template create mode 100644 resources-en/src/intentionDescriptions/ExtractIfConditionAction/before.java.template create mode 100644 resources-en/src/intentionDescriptions/ExtractIfConditionAction/description.html diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ExtractIfConditionAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ExtractIfConditionAction.java index fe01746dcfc5..4328e37054fb 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ExtractIfConditionAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ExtractIfConditionAction.java @@ -19,15 +19,12 @@ import com.intellij.codeInsight.CodeInsightBundle; import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.TextRange; import com.intellij.psi.*; import com.intellij.psi.codeStyle.CodeStyleManager; -import com.intellij.psi.impl.JavaFactoryProvider; import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.IncorrectOperationException; -import com.intellij.util.ObjectUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/resources-en/src/intentionDescriptions/ExtractIfConditionAction/after.java.template b/resources-en/src/intentionDescriptions/ExtractIfConditionAction/after.java.template new file mode 100644 index 000000000000..2b67c557f958 --- /dev/null +++ b/resources-en/src/intentionDescriptions/ExtractIfConditionAction/after.java.template @@ -0,0 +1,7 @@ +if (b && c) { + x = 1; +} else if (a) { + x = 1; +} else { + x = 2; +} \ No newline at end of file diff --git a/resources-en/src/intentionDescriptions/ExtractIfConditionAction/before.java.template b/resources-en/src/intentionDescriptions/ExtractIfConditionAction/before.java.template new file mode 100644 index 000000000000..e4884f4d6f77 --- /dev/null +++ b/resources-en/src/intentionDescriptions/ExtractIfConditionAction/before.java.template @@ -0,0 +1,5 @@ +if (a || b && c) { + x = 1; +} else { + x = 2; +} diff --git a/resources-en/src/intentionDescriptions/ExtractIfConditionAction/description.html b/resources-en/src/intentionDescriptions/ExtractIfConditionAction/description.html new file mode 100644 index 000000000000..405094f1b01d --- /dev/null +++ b/resources-en/src/intentionDescriptions/ExtractIfConditionAction/description.html @@ -0,0 +1,5 @@ + + +This intention extracts operand expression from If condition and creates new If statement with this expression as a condition, keeping the original control flow. + + \ No newline at end of file From 369e37a1a15608c3a65535c3d8e109ff3b09974b Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Wed, 13 Jun 2012 17:59:07 +0400 Subject: [PATCH 112/172] reverted ref counting storage changes to 963e35d87061c03b67705bf5aeb826092e6aa30c to avoid EOF exception of unresolved reason --- .../util/io/storage/RefCountingStorage.java | 181 +++++------------- 1 file changed, 43 insertions(+), 138 deletions(-) diff --git a/platform/util/src/com/intellij/util/io/storage/RefCountingStorage.java b/platform/util/src/com/intellij/util/io/storage/RefCountingStorage.java index b8704c5d2432..39afca729925 100644 --- a/platform/util/src/com/intellij/util/io/storage/RefCountingStorage.java +++ b/platform/util/src/com/intellij/util/io/storage/RefCountingStorage.java @@ -19,7 +19,6 @@ */ package com.intellij.util.io.storage; -import com.intellij.openapi.util.LowMemoryWatcher; import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream; import com.intellij.openapi.util.io.ByteSequence; import com.intellij.openapi.util.io.StreamUtil; @@ -39,42 +38,17 @@ import java.util.zip.Inflater; import java.util.zip.InflaterInputStream; public class RefCountingStorage extends AbstractStorage { - private final Map> myPendingZipRequests = new ConcurrentHashMap>(); - private volatile int myPendingZipRequestsSize; - private final ThreadPoolExecutor myPendingZipRequestsExecutor = new ThreadPoolExecutor(1, 1, Long.MAX_VALUE, TimeUnit.DAYS, new LinkedBlockingQueue(), new ThreadFactory() { + private final Map> myPendingWriteRequests = new ConcurrentHashMap>(); + private int myPendingWriteRequestsSize; + private final ThreadPoolExecutor myPendingWriteRequestsExecutor = new ThreadPoolExecutor(1, 1, Long.MAX_VALUE, TimeUnit.DAYS, new LinkedBlockingQueue(), new ThreadFactory() { @Override public Thread newThread(Runnable runnable) { - return new Thread(runnable, "Ref Counter Storage Zipper"); + return new Thread(runnable, "RefCountingStorage write content helper"); } }); private final boolean myDoNotZipCaches = Boolean.valueOf(System.getProperty("idea.doNotZipCaches")).booleanValue(); - private static final int MAX_PENDING_ZIP_SIZE = 20 * 1024 * 1024; - - private final Map myPendingWriteRequests = new ConcurrentHashMap(); - private volatile int myPendingWriteRequestsSize; - private final LowMemoryWatcher myPendingWritesFlusher = LowMemoryWatcher.register(new Runnable() { - @Override - public void run() { - flushPendingWrites(); // only pending writes - } - }); - - private static class WriteRequest { - final byte[] content; - final int length; - final int recordId; - final boolean fixedSize; - - WriteRequest(byte[] _content, int _length, int _recordId, boolean _fixedSize) { - content = _content; - length = _length; - recordId = _recordId; - fixedSize = _fixedSize; - } - } - - private static final int MAX_PENDING_WRITE_SIZE = 2 * 1024 * 1024; + private static final int MAX_PENDING_WRITE_SIZE = 20 * 1024 * 1024; public RefCountingStorage(String path) throws IOException { super(path); @@ -93,48 +67,35 @@ public class RefCountingStorage extends AbstractStorage { } private BufferExposingByteArrayOutputStream internalReadStream(int record) throws IOException { - waitForZipToFinish(record); - WriteRequest request; + waitForPendingWriteForRecord(record); + synchronized (myLock) { - request = myPendingWriteRequests.get(record); - } - byte[] bytes; - int length; - if (request != null) { - bytes = request.content; - length = request.length; - } else { - bytes = super.readBytes(record); - length = bytes.length; - } - - InflaterInputStream in = new CustomInflaterInputStream(bytes, length); - try { - final BufferExposingByteArrayOutputStream outputStream = new BufferExposingByteArrayOutputStream(); - StreamUtil.copyStreamContent(in, outputStream); - return outputStream; - } - finally { - in.close(); + byte[] result = super.readBytes(record); + InflaterInputStream in = new CustomInflaterInputStream(result); + try { + final BufferExposingByteArrayOutputStream outputStream = new BufferExposingByteArrayOutputStream(); + StreamUtil.copyStreamContent(in, outputStream); + return outputStream; + } + finally { + in.close(); + } } } private static class CustomInflaterInputStream extends InflaterInputStream { - private int usedBufferLength; - - public CustomInflaterInputStream(byte[] compressedData, int _length) { - super(new UnsyncByteArrayInputStream(compressedData, 0, _length), new Inflater(), 1); + public CustomInflaterInputStream(byte[] compressedData) { + super(new UnsyncByteArrayInputStream(compressedData), new Inflater(), 1); // force to directly use compressed data, this ensures less round trips with native extraction code and copy streams this.buf = compressedData; - this.len = -1; // ensure one time fill - usedBufferLength = _length; + this.len = -1; } @Override protected void fill() throws IOException { if (len >= 0) throw new EOFException(); - len = usedBufferLength; + len = buf.length; inf.setInput(buf, 0, len); } @@ -146,29 +107,7 @@ public class RefCountingStorage extends AbstractStorage { } private void waitForPendingWriteForRecord(int record) { - waitForZipToFinish(record); - - WriteRequest request; - synchronized (myLock) { - request = myPendingWriteRequests.get(record); - } - if (request != null) { - try { - write(request); - } - catch (Exception e) { - throw new RuntimeException(e); - } - } - } - - private void waitForZipToFinish(int record) { - Future future; - - synchronized (myLock) { - future = myPendingZipRequests.get(record); - } - + Future future = myPendingWriteRequests.get(record); if (future != null) { try { future.get(); @@ -192,51 +131,25 @@ public class RefCountingStorage extends AbstractStorage { return; } - waitForPendingWriteForRecord(record); // ensure previous write was completed + waitForPendingWriteForRecord(record); synchronized (myLock) { - myPendingZipRequestsSize += bytes.getLength(); - - if (myPendingZipRequestsSize > MAX_PENDING_ZIP_SIZE) { // help async thread - scheduleZippedContentToWrite(zip(bytes, record), record, fixedSize); + myPendingWriteRequestsSize += bytes.getLength(); + if (myPendingWriteRequestsSize > MAX_PENDING_WRITE_SIZE) { + zipAndWrite(bytes, record, fixedSize); } else { - myPendingZipRequests.put(record, myPendingZipRequestsExecutor.submit(new Callable() { + myPendingWriteRequests.put(record, myPendingWriteRequestsExecutor.submit(new Callable() { @Override public Object call() throws IOException { - scheduleZippedContentToWrite(zip(bytes, record), record, fixedSize); + zipAndWrite(bytes, record, fixedSize); return null; } })); } - - if (myPendingWriteRequestsSize > MAX_PENDING_WRITE_SIZE) { - flushPendingWrites(); // we do it under lock to ensure normally only one thread will bulky flush stuff - } } } - private void scheduleZippedContentToWrite(final BufferExposingByteArrayOutputStream outputStream, final int record, final boolean fixedSize) { - synchronized (myLock) { - myPendingWriteRequestsSize += outputStream.size(); - myPendingWriteRequests.put(record, new WriteRequest(outputStream.getInternalBuffer(), outputStream.size(), record, fixedSize)); - - if (myPendingWriteRequestsSize > MAX_PENDING_WRITE_SIZE) { // we do it under lock to ensure normally only one thread will bulky flush stuff - flushPendingWrites(); - } - } - } - - - private void write(WriteRequest writeRequest) throws IOException { - synchronized (myLock) { - if (!myPendingWriteRequests.containsKey(writeRequest.recordId)) return; // some thread helped us - super.writeBytes(writeRequest.recordId, new ByteSequence(writeRequest.content, 0, writeRequest.length), writeRequest.fixedSize); - myPendingWriteRequests.remove(writeRequest.recordId); - myPendingWriteRequestsSize -= writeRequest.length; - } - } - - private BufferExposingByteArrayOutputStream zip(ByteSequence bytes, int record) throws IOException { + private void zipAndWrite(ByteSequence bytes, int record, boolean fixedSize) throws IOException { BufferExposingByteArrayOutputStream s = new BufferExposingByteArrayOutputStream(); DeflaterOutputStream out = new DeflaterOutputStream(s); try { @@ -245,11 +158,16 @@ public class RefCountingStorage extends AbstractStorage { finally { out.close(); } + synchronized (myLock) { - myPendingZipRequests.remove(record); - myPendingZipRequestsSize -= bytes.getLength(); + doWrite(record, fixedSize, s); + myPendingWriteRequestsSize -= bytes.getLength(); + myPendingWriteRequests.remove(record); } - return s; + } + + private void doWrite(int record, boolean fixedSize, BufferExposingByteArrayOutputStream s) throws IOException { + super.writeBytes(record, new ByteSequence(s.getInternalBuffer(), 0, s.size()), fixedSize); } @Override @@ -290,53 +208,40 @@ public class RefCountingStorage extends AbstractStorage { @Override public void force() { - flushAllPendingWrites(); + flushPendingWrites(); super.force(); } @Override public boolean isDirty() { - return myPendingZipRequestsSize > 0 || myPendingWriteRequestsSize > 0 || super.isDirty(); + return myPendingWriteRequests.size() > 0 || super.isDirty(); } @Override public boolean flushSome() { - flushAllPendingWrites(); + flushPendingWrites(); return super.flushSome(); } @Override public void dispose() { - flushAllPendingWrites(); + flushPendingWrites(); super.dispose(); } @Override public void checkSanity(int record) { - flushAllPendingWrites(); + flushPendingWrites(); super.checkSanity(record); } private void flushPendingWrites() { - for(Map.Entry entry: myPendingWriteRequests.entrySet()) { - try { - WriteRequest value = entry.getValue(); - if (value != null) write(value); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - - private void flushAllPendingWrites() { - for(Map.Entry> entry: myPendingZipRequests.entrySet()) { + for(Map.Entry> entry:myPendingWriteRequests.entrySet()) { try { entry.getValue().get(); } catch (Exception e) { throw new RuntimeException(e); } } - - flushPendingWrites(); } } From 760742aef70452295eee1d4b36fc88a50a7782fb Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 13 Jun 2012 16:56:27 +0400 Subject: [PATCH 113/172] byte code viewer: dispose corrected; register exception reporter --- .../documentation/DockablePopupManager.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DockablePopupManager.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DockablePopupManager.java index 27c439543dee..fbe3f1ab5c55 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DockablePopupManager.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DockablePopupManager.java @@ -100,14 +100,7 @@ public abstract class DockablePopupManager { contentManager.addContentManagerListener(new ContentManagerAdapter() { @Override public void contentRemoved(ContentManagerEvent event) { - if (contentManager.getContentCount() == 0) { - final JComponent c = event.getContent().getComponent(); - if (c instanceof Disposable) { - Disposer.dispose((Disposable)c); - } - - restorePopupBehavior(); - } + restorePopupBehavior(); } }); @@ -214,10 +207,7 @@ public abstract class DockablePopupManager { final Content[] contents = myToolWindow.getContentManager().getContents(); for (final Content content : contents) { - final JComponent c = content.getComponent(); - if (c instanceof Disposable) { - Disposer.dispose((Disposable)c); - } + myToolWindow.getContentManager().removeContent(content, true); } ToolWindowManagerEx.getInstanceEx(myProject).unregisterToolWindow(getToolwindowId()); From 7e41e9c7add52b61aa0728769fdc4c916c7f0983 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 13 Jun 2012 18:33:07 +0400 Subject: [PATCH 114/172] EA-36474 - assert: TypeConversionUtil.getSuperClassSubstitutor --- .../InlineSuperClassRefactoringProcessor.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/inlineSuperClass/InlineSuperClassRefactoringProcessor.java b/java/java-impl/src/com/intellij/refactoring/inlineSuperClass/InlineSuperClassRefactoringProcessor.java index c98e6b8da9d4..453dc14687dd 100644 --- a/java/java-impl/src/com/intellij/refactoring/inlineSuperClass/InlineSuperClassRefactoringProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/inlineSuperClass/InlineSuperClassRefactoringProcessor.java @@ -221,7 +221,7 @@ public class InlineSuperClassRefactoringProcessor extends FixableUsagesRefactori super.performRefactoring(pushDownUsages); RefactoringUtil.sortDepthFirstRightLeftOrder(usages); for (UsageInfo usageInfo : usages) { - if (!(usageInfo instanceof ReplaceExtendsListUsageInfo)) { + if (!(usageInfo instanceof ReplaceExtendsListUsageInfo || usageInfo instanceof RemoveImportUsageInfo)) { try { ((FixableUsageInfo)usageInfo).fixUsage(); } @@ -234,8 +234,8 @@ public class InlineSuperClassRefactoringProcessor extends FixableUsagesRefactori //postpone broken hierarchy for (UsageInfo usage : usages) { - if (usage instanceof ReplaceExtendsListUsageInfo) { - ((ReplaceExtendsListUsageInfo)usage).fixUsage(); + if (usage instanceof ReplaceExtendsListUsageInfo || usage instanceof RemoveImportUsageInfo) { + ((FixableUsageInfo)usage).fixUsage(); } } try { From 9adb8d1cdd1dc6207bc2caac1a66a62b02a5093e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Wed, 13 Jun 2012 16:45:57 +0200 Subject: [PATCH 115/172] simplify PsiJavaParserFacadeImpl.createDummyJavaFile() --- .../com/intellij/psi/impl/PsiJavaParserFacadeImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiJavaParserFacadeImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiJavaParserFacadeImpl.java index 99107f54c2cd..e510a8dfeecc 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiJavaParserFacadeImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiJavaParserFacadeImpl.java @@ -17,7 +17,10 @@ package com.intellij.psi.impl; import com.intellij.ide.highlighter.JavaFileType; import com.intellij.lang.PsiBuilder; -import com.intellij.lang.java.parser.*; +import com.intellij.lang.java.parser.DeclarationParser; +import com.intellij.lang.java.parser.JavaParser; +import com.intellij.lang.java.parser.JavaParserUtil; +import com.intellij.lang.java.parser.ReferenceParser; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.openapi.util.text.StringUtil; @@ -46,6 +49,8 @@ public class PsiJavaParserFacadeImpl implements PsiJavaParserFacade { protected final PsiManager myManager; private PsiJavaFile myDummyJavaFile; + private static final String DUMMY_FILE_NAME = "_Dummy_." + JavaFileType.INSTANCE.getDefaultExtension(); + public PsiJavaParserFacadeImpl(PsiManager manager) { myManager = manager; } @@ -323,9 +328,8 @@ public class PsiJavaParserFacadeImpl implements PsiJavaParserFacade { } protected PsiJavaFile createDummyJavaFile(final String text) { - final String fileName = "_Dummy_." + JavaFileType.INSTANCE.getDefaultExtension(); final FileType type = JavaFileType.INSTANCE; - return (PsiJavaFile)PsiFileFactory.getInstance(myManager.getProject()).createFileFromText(type, fileName, text, 0, text.length()); + return (PsiJavaFile)PsiFileFactory.getInstance(myManager.getProject()).createFileFromText(DUMMY_FILE_NAME, type, text); } @NotNull From 4220ba26d2db4a4c2746a337bcc7c2bf4fbac713 Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Wed, 13 Jun 2012 19:17:36 +0400 Subject: [PATCH 116/172] don't iterate over all TestLocationProvider if custom provider can't find location --- .../sm/CompositeTestLocationProvider.java | 61 +++++++++++++++++++ .../sm/SMTestRunnerConnectionUtil.java | 20 +++--- .../testframework/sm/runner/SMTestProxy.java | 27 ++------ 3 files changed, 79 insertions(+), 29 deletions(-) create mode 100644 platform/smRunner/src/com/intellij/execution/testframework/sm/CompositeTestLocationProvider.java diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/CompositeTestLocationProvider.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/CompositeTestLocationProvider.java new file mode 100644 index 000000000000..0f1018f72a83 --- /dev/null +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/CompositeTestLocationProvider.java @@ -0,0 +1,61 @@ +/* + * 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.execution.testframework.sm; + +import com.intellij.execution.Location; +import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.project.DumbService; +import com.intellij.openapi.project.Project; +import com.intellij.testIntegration.TestLocationProvider; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collections; +import java.util.List; + +/** + * @author Sergey Simonchik + */ +public class CompositeTestLocationProvider implements TestLocationProvider { + + private final TestLocationProvider myPrimaryLocator; + + public CompositeTestLocationProvider(@Nullable TestLocationProvider primaryLocator) { + myPrimaryLocator = primaryLocator; + } + + @NotNull + @Override + public List getLocation(@NotNull String protocolId, @NotNull String locationData, Project project) { + if (myPrimaryLocator != null) { + List locations = myPrimaryLocator.getLocation(protocolId, locationData, project); + if (!locations.isEmpty()) { + return locations; + } + } + final boolean isDumbMode = DumbService.isDumb(project); + for (TestLocationProvider provider : Extensions.getExtensions(TestLocationProvider.EP_NAME)) { + if (isDumbMode && !DumbService.isDumbAware(provider)) { + continue; + } + final List locations = provider.getLocation(protocolId, locationData, project); + if (!locations.isEmpty()) { + return locations; + } + } + return Collections.emptyList(); + } +} diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java index 99221666a0b4..7c1567c9c435 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java @@ -85,16 +85,20 @@ public class SMTestRunnerConnectionUtil { final RunnerSettings runnerSettings, final ConfigurationPerRunnerSettings configurationSettings, @Nullable final TestLocationProvider locator) { - return createConsoleWithCustomLocator(testFrameworkName, consoleProperties, runnerSettings, - configurationSettings, locator, false); + return createConsoleWithCustomLocator(testFrameworkName, + consoleProperties, + runnerSettings, + configurationSettings, + new CompositeTestLocationProvider(locator), + false); } - public static BaseTestsOutputConsoleView createConsoleWithCustomLocator(@NotNull final String testFrameworkName, - @NotNull final TestConsoleProperties consoleProperties, - final RunnerSettings runnerSettings, - final ConfigurationPerRunnerSettings configurationSettings, - @Nullable final TestLocationProvider locator, - final boolean idBasedTreeConstruction) { + public static SMTRunnerConsoleView createConsoleWithCustomLocator(@NotNull final String testFrameworkName, + @NotNull final TestConsoleProperties consoleProperties, + final RunnerSettings runnerSettings, + final ConfigurationPerRunnerSettings configurationSettings, + @Nullable final TestLocationProvider locator, + final boolean idBasedTreeConstruction) { // Console final String splitterPropertyName = testFrameworkName + ".Splitter.Proportion"; final SMTRunnerConsoleView console = diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java index 68464529f969..edc1b91d5391 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java @@ -25,8 +25,6 @@ import com.intellij.execution.testframework.sm.runner.ui.TestsPresentationUtil; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.ide.util.EditSourceUtil; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.pom.Navigatable; @@ -60,7 +58,7 @@ public class SMTestProxy extends AbstractTestProxy { private final boolean myIsSuite; private boolean myIsEmptyIsCached = false; // is used for separating unknown and unset values private boolean myIsEmpty = true; - TestLocationProvider myCustomLocator = null; + TestLocationProvider myLocator = null; private final boolean myPreservePresentableName; public SMTestProxy(final String testName, final boolean isSuite, @@ -78,7 +76,7 @@ public class SMTestProxy extends AbstractTestProxy { } public void setLocator(@NotNull TestLocationProvider locator) { - myCustomLocator = locator; + myLocator = locator; } public boolean isInProgress() { @@ -186,30 +184,17 @@ public class SMTestProxy extends AbstractTestProxy { //TODO multiresolve support - if (myLocationUrl == null) { + if (myLocationUrl == null || myLocator == null) { return null; } final String protocolId = TestsLocationProviderUtil.extractProtocol(myLocationUrl); final String path = TestsLocationProviderUtil.extractPath(myLocationUrl); - final boolean isDumbMode = DumbService.isDumb(project); - if (protocolId != null && path != null) { - if (myCustomLocator != null) { - List locations = myCustomLocator.getLocation(protocolId, path, project); - if (!locations.isEmpty()) { - return locations.iterator().next(); - } - } - for (TestLocationProvider provider : Extensions.getExtensions(TestLocationProvider.EP_NAME)) { - if (isDumbMode && !DumbService.isDumbAware(provider)) { - continue; - } - final List locations = provider.getLocation(protocolId, path, project); - if (!locations.isEmpty()) { - return locations.iterator().next(); - } + List locations = myLocator.getLocation(protocolId, path, project); + if (!locations.isEmpty()) { + return locations.iterator().next(); } } From e141f833928e7996903fb0fe69633d82ca8019e5 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 13 Jun 2012 19:07:03 +0400 Subject: [PATCH 117/172] EA-36406 - assert: TypeEvaluator.evaluateType --- .../com/intellij/refactoring/typeMigration/TypeEvaluator.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeEvaluator.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeEvaluator.java index 7b12bc349967..67e643841567 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeEvaluator.java +++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeEvaluator.java @@ -200,8 +200,7 @@ public class TypeEvaluator { return elseType; case 3: - LOG.error("Condition type conflict."); - return null; + return expr.getType(); default: LOG.error("Must not happen."); From 87ef1bbd6dc6d283a99a78e5d16eb38b378725a8 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Wed, 13 Jun 2012 17:18:15 +0200 Subject: [PATCH 118/172] AppCode:Device: lib rebuild with 10.6 as a base sdk, + project cleanup --- .../com/intellij/psi/PsiModificationTrackerTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java b/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java index 0dc335947726..4d4649626603 100644 --- a/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java @@ -5,6 +5,7 @@ import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.editor.SelectionModel; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.util.PsiModificationTracker; +import com.intellij.testFramework.IdeaTestCase; import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import com.intellij.util.Processor; import org.jetbrains.annotations.NonNls; @@ -15,6 +16,12 @@ import java.io.IOException; * @author Dmitry Avdeev */ public class PsiModificationTrackerTest extends LightPlatformCodeInsightFixtureTestCase { + @Override + public void setUp() throws Exception { + IdeaTestCase.initPlatformPrefix(); + super.setUp(); + } + public void testAnnotationNotChanged() throws Exception { doReplaceTest("@SuppressWarnings(\"zz\")\n" + "public class Foo { }", From 23b738a8a92fdb4cb2cf0f3a336f1aaaa9947124 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Wed, 13 Jun 2012 17:18:54 +0200 Subject: [PATCH 119/172] wrong change reverted --- .../com/intellij/psi/PsiModificationTrackerTest.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java b/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java index 4d4649626603..0dc335947726 100644 --- a/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java @@ -5,7 +5,6 @@ import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.editor.SelectionModel; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.util.PsiModificationTracker; -import com.intellij.testFramework.IdeaTestCase; import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import com.intellij.util.Processor; import org.jetbrains.annotations.NonNls; @@ -16,12 +15,6 @@ import java.io.IOException; * @author Dmitry Avdeev */ public class PsiModificationTrackerTest extends LightPlatformCodeInsightFixtureTestCase { - @Override - public void setUp() throws Exception { - IdeaTestCase.initPlatformPrefix(); - super.setUp(); - } - public void testAnnotationNotChanged() throws Exception { doReplaceTest("@SuppressWarnings(\"zz\")\n" + "public class Foo { }", From 99c6f41a8e4a0f1e4eaecfe52af77081179ea2e5 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Wed, 13 Jun 2012 17:37:10 +0200 Subject: [PATCH 120/172] PsiModificationTrackerTest test fixed --- .../com/intellij/psi/PsiModificationTrackerTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java b/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java index 0dc335947726..7cba4a83f4a3 100644 --- a/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java @@ -3,8 +3,10 @@ package com.intellij.psi; import com.intellij.ide.highlighter.JavaFileType; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.editor.SelectionModel; +import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.util.PsiModificationTracker; +import com.intellij.testFramework.IdeaTestCase; import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import com.intellij.util.Processor; import org.jetbrains.annotations.NonNls; @@ -15,6 +17,12 @@ import java.io.IOException; * @author Dmitry Avdeev */ public class PsiModificationTrackerTest extends LightPlatformCodeInsightFixtureTestCase { + @Override + public void setUp() throws Exception { + IdeaTestCase.initPlatformPrefix(); + super.setUp(); + } + public void testAnnotationNotChanged() throws Exception { doReplaceTest("@SuppressWarnings(\"zz\")\n" + "public class Foo { }", @@ -86,6 +94,7 @@ public class PsiModificationTrackerTest extends LightPlatformCodeInsightFixtureT try { final VirtualFile vFile = psiFile.getVirtualFile(); assert vFile != null : psiFile; + FileEditorManager.getInstance(getProject()).closeFile(vFile); vFile.delete(this); } catch (IOException e) { From 6e2ad78e82fa1fb62f89f2e1f4068dc5efd6e550 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Wed, 13 Jun 2012 15:46:24 +0400 Subject: [PATCH 121/172] EA-35347 fix already disposed --- plugins/git4idea/src/git4idea/roots/GitRootProblemNotifier.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/git4idea/src/git4idea/roots/GitRootProblemNotifier.java b/plugins/git4idea/src/git4idea/roots/GitRootProblemNotifier.java index d50416e64f31..00381d6ecf14 100644 --- a/plugins/git4idea/src/git4idea/roots/GitRootProblemNotifier.java +++ b/plugins/git4idea/src/git4idea/roots/GitRootProblemNotifier.java @@ -210,7 +210,7 @@ public class GitRootProblemNotifier { @Override public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - if (event.getDescription().equals("configure")) { + if (event.getDescription().equals("configure") && !myProject.isDisposed()) { ShowSettingsUtil.getInstance().showSettingsDialog(myProject, ActionsBundle.message("group.VcsGroup.text")); Collection errorsAfterPossibleFix = GitRootProblemNotifier.getInstance(myProject).scan(); if (errorsAfterPossibleFix.isEmpty() && !notification.isExpired()) { From 255403db1e6590879ae10ec26c711c79832c12e1 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Wed, 13 Jun 2012 16:20:04 +0400 Subject: [PATCH 122/172] IDEA-87375 Git cherry-pick: commit with the correct message. 1. In the CherryPickCommitSession commit with the correct message. 2. The correct message should also be shown in notifications. For this use GitCommitWrapper with a mutable subject of commit message, and update it with the actual commit message got from the CommitExecutor. --- .../history/browser/GitCherryPicker.java | 114 +++++++++++++----- 1 file changed, 84 insertions(+), 30 deletions(-) diff --git a/plugins/git4idea/src/git4idea/history/browser/GitCherryPicker.java b/plugins/git4idea/src/git4idea/history/browser/GitCherryPicker.java index 1ea1dff3f174..d71aa1d10d12 100644 --- a/plugins/git4idea/src/git4idea/history/browser/GitCherryPicker.java +++ b/plugins/git4idea/src/git4idea/history/browser/GitCherryPicker.java @@ -84,7 +84,7 @@ public class GitCherryPicker { } public void cherryPick(@NotNull Map> commitsInRoots) { - List successfulCommits = new ArrayList(); + List successfulCommits = new ArrayList(); for (Map.Entry> entry : commitsInRoots.entrySet()) { if (!cherryPick(entry.getKey(), entry.getValue(), successfulCommits)) { return; @@ -95,7 +95,7 @@ public class GitCherryPicker { // return true to continue with other roots, false to break execution private boolean cherryPick(@NotNull GitRepository repository, @NotNull List commits, - @NotNull List successfulCommits) { + @NotNull List successfulCommits) { for (GitCommit commit : commits) { GitSimpleEventDetector conflictDetector = new GitSimpleEventDetector(CHERRY_PICK_CONFLICT); GitSimpleEventDetector localChangesOverwrittenDetector = new GitSimpleEventDetector(LOCAL_CHANGES_OVERWRITTEN_BY_CHERRY_PICK); @@ -103,14 +103,16 @@ public class GitCherryPicker { repository.getRoot()); GitCommandResult result = myGit.cherryPick(repository, commit.getHash().getValue(), myAutoCommit, conflictDetector, localChangesOverwrittenDetector, untrackedFilesDetector); + GitCommitWrapper commitWrapper = new GitCommitWrapper(commit); if (result.success()) { if (myAutoCommit) { - successfulCommits.add(commit); + successfulCommits.add(commitWrapper); } else { - boolean committed = updateChangeListManagerShowCommitDialogAndRemoveChangeListOnSuccess(repository, commit, successfulCommits); + boolean committed = updateChangeListManagerShowCommitDialogAndRemoveChangeListOnSuccess(repository, commitWrapper, + successfulCommits); if (!committed) { - notifyCommitCancelled(commit, successfulCommits); + notifyCommitCancelled(commitWrapper, successfulCommits); return false; } } @@ -121,20 +123,21 @@ public class GitCherryPicker { commit.getSubject()).merge(); if (mergeCompleted) { - boolean committed = updateChangeListManagerShowCommitDialogAndRemoveChangeListOnSuccess(repository, commit, successfulCommits); + boolean committed = updateChangeListManagerShowCommitDialogAndRemoveChangeListOnSuccess(repository, commitWrapper, + successfulCommits); if (!committed) { - notifyCommitCancelled(commit, successfulCommits); + notifyCommitCancelled(commitWrapper, successfulCommits); return false; } } else { updateChangeListManager(commit); - notifyConflictWarning(repository, commit, successfulCommits); + notifyConflictWarning(repository, commitWrapper, successfulCommits); return false; } } else if (untrackedFilesDetector.wasMessageDetected()) { - String description = commitDetails(commit) + String description = commitDetails(commitWrapper) + "
Some untracked working tree files would be overwritten by cherry-pick.
" + "Please move, remove or add them before you can cherry-pick. View them"; description += getSuccessfulCommitDetailsIfAny(successfulCommits); @@ -145,11 +148,11 @@ public class GitCherryPicker { } else if (localChangesOverwrittenDetector.hasHappened()) { notifyError("Your local changes would be overwritten by cherry-pick.
Commit your changes or stash them to proceed.", - commit, successfulCommits); + commitWrapper, successfulCommits); return false; } else { - notifyError(result.getErrorOutputAsHtmlString(), commit, successfulCommits); + notifyError(result.getErrorOutputAsHtmlString(), commitWrapper, successfulCommits); return false; } } @@ -157,9 +160,9 @@ public class GitCherryPicker { } private boolean updateChangeListManagerShowCommitDialogAndRemoveChangeListOnSuccess(@NotNull GitRepository repository, - @NotNull GitCommit commit, - @NotNull List successfulCommits) { - CherryPickData data = updateChangeListManager(commit); + @NotNull GitCommitWrapper commit, + @NotNull List successfulCommits) { + CherryPickData data = updateChangeListManager(commit.getCommit()); boolean committed = showCommitDialog(repository, commit, data.myChangeList, data.myCommitMessage); if (committed) { removeChangeList(data); @@ -176,10 +179,11 @@ public class GitCherryPicker { } } - private void notifyConflictWarning(@NotNull GitRepository repository, @NotNull GitCommit commit, - @NotNull List successfulCommits) { + private void notifyConflictWarning(@NotNull GitRepository repository, @NotNull GitCommitWrapper commit, + @NotNull List successfulCommits) { NotificationListener resolveLinkListener = new ResolveLinkListener(myProject, myGit, myPlatformFacade, repository.getRoot(), - commit.getShortHash().getString(), commit.getAuthor(), + commit.getCommit().getShortHash().getString(), + commit.getCommit().getAuthor(), commit.getSubject()); String description = commitDetails(commit) + "
Unresolved conflicts remain in the working tree. Resolve them."; @@ -187,7 +191,7 @@ public class GitCherryPicker { myPlatformFacade.getNotificator(myProject).notifyStrongWarning("Cherry-picked with conflicts", description, resolveLinkListener); } - private void notifyCommitCancelled(@NotNull GitCommit commit, @NotNull List successfulCommits) { + private void notifyCommitCancelled(@NotNull GitCommitWrapper commit, @NotNull List successfulCommits) { if (successfulCommits.isEmpty()) { // don't notify about cancelled commit. Notify just in the case when there were already successful commits in the queue. return; @@ -239,22 +243,30 @@ public class GitCherryPicker { return message; } - private boolean showCommitDialog(@NotNull final GitRepository repository, @NotNull final GitCommit commit, + private boolean showCommitDialog(@NotNull final GitRepository repository, @NotNull final GitCommitWrapper commit, @NotNull final LocalChangeList changeList, @NotNull final String commitMessage) { final AtomicBoolean commitSucceeded = new AtomicBoolean(); myPlatformFacade.invokeAndWait(new Runnable() { @Override public void run() { cancelCherryPick(repository); - List changes = commit.getChanges(); + List changes = commit.getCommit().getChanges(); CherryPickCommitExecutor executor = new CherryPickCommitExecutor(myProject, myPlatformFacade, changes, commitMessage); boolean commitNotCancelled = myPlatformFacade.getVcsHelper(myProject).commitChanges(changes, changeList, commitMessage, executor); - commitSucceeded.set(commitNotCancelled && !executor.hasCommitFailed()); + boolean success = commitNotCancelled && !executor.hasCommitFailed(); + if (success) { + commit.setActualSubject(getSubjectFromCommitMessage(executor.getActualCommitMessage())); + } + commitSucceeded.set(success); } }, ModalityState.NON_MODAL); return commitSucceeded.get(); } + private static String getSubjectFromCommitMessage(String commitMessage) { + return commitMessage.substring(0, commitMessage.indexOf("\n")); + } + /** * We control the cherry-pick workflow ourselves + we want to use partial commits ('git commit --only'), which is prohibited during * cherry-pick, i.e. until the CHERRY_PICK_HEAD exists. @@ -289,14 +301,14 @@ public class GitCherryPicker { } } - private void notifyError(@NotNull String content, @NotNull GitCommit failedCommit, @NotNull List successfulCommits) { + private void notifyError(@NotNull String content, @NotNull GitCommitWrapper failedCommit, @NotNull List successfulCommits) { String description = commitDetails(failedCommit) + "
" + content; description += getSuccessfulCommitDetailsIfAny(successfulCommits); myPlatformFacade.getNotificator(myProject).notifyError("Cherry-pick failed", description); } @NotNull - private static String getSuccessfulCommitDetailsIfAny(@NotNull List successfulCommits) { + private static String getSuccessfulCommitDetailsIfAny(@NotNull List successfulCommits) { String description = ""; if (!successfulCommits.isEmpty()) { description += "
However cherry-pick succeeded for the following " + pluralize("commit", successfulCommits.size()) + ":
"; @@ -305,23 +317,23 @@ public class GitCherryPicker { return description; } - private void notifySuccess(@NotNull List successfulCommits) { + private void notifySuccess(@NotNull List successfulCommits) { String description = getCommitsDetails(successfulCommits); myPlatformFacade.getNotificator(myProject).notifySuccess("Cherry-pick successful", description); } @NotNull - private static String getCommitsDetails(@NotNull List successfulCommits) { + private static String getCommitsDetails(@NotNull List successfulCommits) { String description = ""; - for (GitCommit commit : successfulCommits) { + for (GitCommitWrapper commit : successfulCommits) { description += commitDetails(commit) + "
"; } return description.substring(0, description.length() - "
".length()); } @NotNull - private static String commitDetails(@NotNull GitCommit commit) { - return commit.getShortHash().toString() + " \"" + commit.getSubject() + "\""; + private static String commitDetails(@NotNull GitCommitWrapper commit) { + return commit.getCommit().getShortHash().toString() + " \"" + commit.getSubject() + "\""; } private void refreshChangedFiles(@NotNull Collection filePaths) { @@ -453,6 +465,8 @@ public class GitCherryPicker { @NotNull private final String myCommitMessage; private boolean myCommitFailed; + private CherryPickCommitExecutor.CherryPickCommitSession myCommitSession; + CherryPickCommitExecutor(@NotNull Project project, @NotNull PlatformFacade platformFacade, @NotNull List changes, @NotNull String commitMessage) { myProject = project; @@ -470,14 +484,22 @@ public class GitCherryPicker { @NotNull @Override public CommitSession createCommitSession() { - return new CherryPickCommitSession(); + myCommitSession = new CherryPickCommitSession(); + return myCommitSession; } public boolean hasCommitFailed() { return myCommitFailed; } + @NotNull + public String getActualCommitMessage() { + return myCommitSession.getActualCommitMessage(); + } + private class CherryPickCommitSession implements CommitSession { + private String myActualCommitMessage; + @Override public JComponent getAdditionalConfigurationUI() { return null; @@ -500,12 +522,13 @@ public class GitCherryPicker { GitCheckinEnvironment ce = ServiceManager.getService(myProject, GitCheckinEnvironment.class); try { ce.reset(); - List exceptions = ce.commit(myChanges, myCommitMessage); + List exceptions = ce.commit(myChanges, commitMessage); VcsDirtyScopeManager.getInstance(myProject).filePathsDirty(ChangesUtil.getPaths(myChanges), null); if (exceptions != null && !exceptions.isEmpty()) { VcsException exception = exceptions.get(0); handleError(exception); } + myActualCommitMessage = commitMessage; } catch (Throwable e) { LOG.error(e); @@ -557,6 +580,37 @@ public class GitCherryPicker { return committingDocs; } + public String getActualCommitMessage() { + return myActualCommitMessage; + } + } + } + + /** + * This class is needed to hold both the original GitCommit, and the commit message which could be changed by the user. + * Only the subject of the commit message is needed. + */ + private static class GitCommitWrapper { + @NotNull private final GitCommit myOriginalCommit; + @NotNull private String myActualSubject; + + private GitCommitWrapper(@NotNull GitCommit commit) { + myOriginalCommit = commit; + myActualSubject = commit.getSubject(); + } + + @NotNull + public String getSubject() { + return myActualSubject; + } + + public void setActualSubject(@NotNull String actualSubject) { + myActualSubject = actualSubject; + } + + @NotNull + public GitCommit getCommit() { + return myOriginalCommit; } } From f647813dfa63ea32aefe20244a5107fae534d8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Wed, 13 Jun 2012 18:04:04 +0200 Subject: [PATCH 123/172] BeanProperty: add note about BeanPropertyRenameHandler --- .../com/intellij/psi/impl/beanProperties/BeanProperty.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/psi/impl/beanProperties/BeanProperty.java b/java/java-impl/src/com/intellij/psi/impl/beanProperties/BeanProperty.java index 1fd0d8e03a8d..3c5fd4d6e88e 100644 --- a/java/java-impl/src/com/intellij/psi/impl/beanProperties/BeanProperty.java +++ b/java/java-impl/src/com/intellij/psi/impl/beanProperties/BeanProperty.java @@ -28,6 +28,9 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; +/** + * Provide {@link com.intellij.refactoring.rename.BeanPropertyRenameHandler} if necessary. + */ @Presentation(icon = "AllIcons.Nodes.Property") public class BeanProperty { @@ -104,5 +107,4 @@ public class BeanProperty { public static BeanProperty createBeanProperty(@NotNull PsiMethod method) { return PropertyUtil.isSimplePropertyAccessor(method) ? new BeanProperty(method) : null; } - } From 69b90836d8101bafe45b9264a979eac4ac69bd23 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 13 Jun 2012 18:48:37 +0400 Subject: [PATCH 124/172] Typo; cleanup --- .../openapi/module/impl/ModuleTypeManagerImpl.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleTypeManagerImpl.java b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleTypeManagerImpl.java index cbaba3885c3d..dad03d612c46 100644 --- a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleTypeManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleTypeManagerImpl.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. @@ -28,7 +28,6 @@ public class ModuleTypeManagerImpl extends ModuleTypeManager { private final LinkedHashMap myModuleTypes = new LinkedHashMap(); - public ModuleTypeManagerImpl() { registerModuleType(getDefaultModuleType(), true); } @@ -40,17 +39,18 @@ public class ModuleTypeManagerImpl extends ModuleTypeManager { public void registerModuleType(ModuleType type, boolean classpathProvider) { for (ModuleType oldType : myModuleTypes.keySet()) { if (oldType.getId().equals(type.getId())) { - LOG.error("Trying to register a module type that claunches with existing one. Old=" + oldType + ", new = " + type); + LOG.error("Trying to register a module type that clashes with existing one. Old=" + oldType + ", new = " + type); return; } } + myModuleTypes.put(type, classpathProvider); } public ModuleType[] getRegisteredTypes() { List result = new ArrayList(); result.addAll(myModuleTypes.keySet()); - for(ModuleTypeEP moduleTypeEP: Extensions.getExtensions(ModuleTypeEP.EP_NAME)) { + for (ModuleTypeEP moduleTypeEP : Extensions.getExtensions(ModuleTypeEP.EP_NAME)) { result.add(moduleTypeEP.getModuleType()); } @@ -64,18 +64,17 @@ public class ModuleTypeManagerImpl extends ModuleTypeManager { return type; } } - for(ModuleTypeEP ep: Extensions.getExtensions(ModuleTypeEP.EP_NAME)) { + for (ModuleTypeEP ep : Extensions.getExtensions(ModuleTypeEP.EP_NAME)) { if (ep.id.equals(moduleTypeID)) { return ep.getModuleType(); } } - return new UnknownModuleType(moduleTypeID, getDefaultModuleType()); } public boolean isClasspathProvider(final ModuleType moduleType) { - for(ModuleTypeEP ep: Extensions.getExtensions(ModuleTypeEP.EP_NAME)) { + for (ModuleTypeEP ep : Extensions.getExtensions(ModuleTypeEP.EP_NAME)) { if (ep.id.equals(moduleType.getId())) { return ep.classpathProvider; } From 8cb73d2871fcd4602898d4ee64b30f20e00b4657 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 13 Jun 2012 19:55:51 +0400 Subject: [PATCH 125/172] EA-35407 - assert: MoveFilesOrDirectoriesHandler.doMove --- .../moveFilesOrDirectories/MoveFilesOrDirectoriesHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesHandler.java b/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesHandler.java index 7c74b3522101..18649c075b23 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesHandler.java +++ b/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesHandler.java @@ -27,6 +27,7 @@ import com.intellij.refactoring.move.MoveCallback; import com.intellij.refactoring.move.MoveHandlerDelegate; import org.jetbrains.annotations.Nullable; +import java.util.Arrays; import java.util.HashSet; public class MoveFilesOrDirectoriesHandler extends MoveHandlerDelegate { @@ -70,7 +71,8 @@ public class MoveFilesOrDirectoriesHandler extends MoveHandlerDelegate { } public void doMove(final Project project, final PsiElement[] elements, final PsiElement targetContainer, @Nullable final MoveCallback callback) { - if (!LOG.assertTrue(targetContainer == null || targetContainer instanceof PsiDirectory || targetContainer instanceof PsiDirectoryContainer, targetContainer)) { + if (!LOG.assertTrue(targetContainer == null || targetContainer instanceof PsiDirectory || targetContainer instanceof PsiDirectoryContainer, + "container: " + targetContainer + "; elements: " + Arrays.toString(elements))) { return; } MoveFilesOrDirectoriesUtil.doMove(project, adjustForMove(project, elements, targetContainer), new PsiElement[] {targetContainer}, callback); From ec9cec6e6bd45a921c3f1b438e61811f5b771371 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 13 Jun 2012 21:12:39 +0400 Subject: [PATCH 126/172] scopes: provide multiline editor for pattern field --- .../ide/util/scopeChooser/ScopeEditorForm.form | 15 ++++++--------- .../ide/util/scopeChooser/ScopeEditorPanel.java | 9 +++++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorForm.form b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorForm.form index 1b5332962a23..f93b6d7c9553 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorForm.form +++ b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorForm.form @@ -77,18 +77,9 @@ - - - - - - - - - @@ -110,6 +101,12 @@ + + + + + + diff --git a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorPanel.java b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorPanel.java index b17e874c866b..e99b4fc3da27 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorPanel.java @@ -60,7 +60,7 @@ import java.util.ArrayList; public class ScopeEditorPanel { private JPanel myButtonsPanel; - private JTextField myPatternField; + private RawCommandLineEditor myPatternField; private JPanel myTreeToolbar; private final Tree myPackageTree; private JPanel myPanel; @@ -107,20 +107,21 @@ public class ScopeEditorPanel { } }; + myPatternField.setDialogCaption("Pattern"); myPatternField.getDocument().addDocumentListener(new DocumentAdapter() { public void textChanged(DocumentEvent event) { onTextChange(); } }); - myPatternField.addCaretListener(new CaretListener() { + myPatternField.getTextField().addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent e) { myCaretPosition = e.getDot(); updateCaretPositionText(); } }); - myPatternField.addFocusListener(new FocusListener() { + myPatternField.getTextField().addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { if (myErrorMessage != null) { myPositionPanel.setVisible(true); @@ -615,7 +616,7 @@ public class ScopeEditorPanel { if (requestFocus) { SwingUtilities.invokeLater(new Runnable() { public void run() { - myPatternField.requestFocusInWindow(); + myPatternField.getTextField().requestFocusInWindow(); } }); } From e0abfd79a1628f65fc66bad1b434fd38c6276a7b Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 13 Jun 2012 21:14:05 +0400 Subject: [PATCH 127/172] copyright: make enabled on multi module selection (IDEA-87258) --- .../maddyhome/idea/copyright/actions/AbstractFileProcessor.java | 2 +- .../maddyhome/idea/copyright/actions/UpdateCopyrightAction.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/actions/AbstractFileProcessor.java b/plugins/copyright/src/com/maddyhome/idea/copyright/actions/AbstractFileProcessor.java index 9432ce2f3a0f..33583874e831 100644 --- a/plugins/copyright/src/com/maddyhome/idea/copyright/actions/AbstractFileProcessor.java +++ b/plugins/copyright/src/com/maddyhome/idea/copyright/actions/AbstractFileProcessor.java @@ -339,7 +339,7 @@ public abstract class AbstractFileProcessor { readAction.run(); } }, title, true, myProject); - new WriteCommandAction(myProject, title, null) { + new WriteCommandAction(myProject, title) { protected void run(Result result) throws Throwable { writeAction.run(); } diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/actions/UpdateCopyrightAction.java b/plugins/copyright/src/com/maddyhome/idea/copyright/actions/UpdateCopyrightAction.java index 2d1008ea00e6..2d51d43c22c3 100644 --- a/plugins/copyright/src/com/maddyhome/idea/copyright/actions/UpdateCopyrightAction.java +++ b/plugins/copyright/src/com/maddyhome/idea/copyright/actions/UpdateCopyrightAction.java @@ -72,6 +72,7 @@ public class UpdateCopyrightAction extends AnAction { } else if ((files == null || files.length != 1) && LangDataKeys.MODULE_CONTEXT.getData(context) == null && + LangDataKeys.MODULE_CONTEXT_ARRAY.getData(context) == null && PlatformDataKeys.PROJECT_CONTEXT.getData(context) == null) { final PsiElement[] elems = LangDataKeys.PSI_ELEMENT_ARRAY.getData(context); if (elems != null) { From 2c677d8791f4a7e63574b740f000422afc086d59 Mon Sep 17 00:00:00 2001 From: Vassiliy Kudryashov Date: Wed, 13 Jun 2012 17:40:02 +0400 Subject: [PATCH 128/172] IDEA-82509 Allow configuring run configurations as singletons --- .../intellij/execution/ExecutionManager.java | 5 + .../RunnerAndConfigurationSettings.java | 4 + .../configurations/ConfigurationFactory.java | 4 + .../UnknownConfigurationType.java | 5 + .../runners/ExecutionEnvironment.java | 23 +++- .../execution/ExecutorRegistryImpl.java | 10 +- .../execution/actions/CreateAction.java | 4 +- .../execution/impl/BeforeRunStepsPanel.java | 27 +++- .../ConfigurationSettingsEditorWrapper.java | 2 + .../execution/impl/ExecutionManagerImpl.java | 121 ++++++++++++++++++ .../RunnerAndConfigurationSettingsImpl.java | 15 +++ .../execution/runners/RestartAction.java | 67 +--------- .../src/messages/ExecutionBundle.properties | 1 + 13 files changed, 215 insertions(+), 73 deletions(-) diff --git a/platform/lang-api/src/com/intellij/execution/ExecutionManager.java b/platform/lang-api/src/com/intellij/execution/ExecutionManager.java index abb7212d2e2b..22a8bcd4beb5 100644 --- a/platform/lang-api/src/com/intellij/execution/ExecutionManager.java +++ b/platform/lang-api/src/com/intellij/execution/ExecutionManager.java @@ -40,4 +40,9 @@ public abstract class ExecutionManager { public abstract void startRunProfile(@NotNull RunProfileStarter starter, @NotNull RunProfileState state, @NotNull Project project, @NotNull Executor executor, @NotNull ExecutionEnvironment env); + + public abstract void restartRunProfile(@NotNull Project project, + @NotNull Executor executor, + @NotNull RunnerAndConfigurationSettings configuration); + } diff --git a/platform/lang-api/src/com/intellij/execution/RunnerAndConfigurationSettings.java b/platform/lang-api/src/com/intellij/execution/RunnerAndConfigurationSettings.java index 26a0944f9267..b483163243e7 100644 --- a/platform/lang-api/src/com/intellij/execution/RunnerAndConfigurationSettings.java +++ b/platform/lang-api/src/com/intellij/execution/RunnerAndConfigurationSettings.java @@ -56,4 +56,8 @@ public interface RunnerAndConfigurationSettings { void setEditBeforeRun(boolean b); boolean isEditBeforeRun(); + + void setSingleton(boolean singleton); + + boolean isSingleton(); } diff --git a/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationFactory.java b/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationFactory.java index bb97b8f80efc..47b7e35715d5 100644 --- a/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationFactory.java +++ b/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationFactory.java @@ -76,4 +76,8 @@ public abstract class ConfigurationFactory { */ public void configureBeforeRunTaskDefaults(Key providerID, BeforeRunTask task) { } + + public boolean canConfigurationBeSingleton() { + return true; // Configuration may be marked as singleton by default + } } diff --git a/platform/lang-api/src/com/intellij/execution/configurations/UnknownConfigurationType.java b/platform/lang-api/src/com/intellij/execution/configurations/UnknownConfigurationType.java index 9a86b783e389..ba5b0511dc9c 100644 --- a/platform/lang-api/src/com/intellij/execution/configurations/UnknownConfigurationType.java +++ b/platform/lang-api/src/com/intellij/execution/configurations/UnknownConfigurationType.java @@ -55,6 +55,11 @@ public class UnknownConfigurationType implements ConfigurationType { public RunConfiguration createTemplateConfiguration(final Project project) { return new UnknownRunConfiguration(this, project); } + + @Override + public boolean canConfigurationBeSingleton() { + return false; + } }}; } } diff --git a/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java b/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java index 4fc694ee0295..9ffd921a8ed9 100644 --- a/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java +++ b/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java @@ -41,6 +41,7 @@ public class ExecutionEnvironment { private RunProfile myRunProfile; private RunnerSettings myRunnerSettings; private ConfigurationPerRunnerSettings myConfigurationSettings; + @Nullable private RunnerAndConfigurationSettings myRunnerAndConfigurationSettings; @TestOnly public ExecutionEnvironment() { @@ -52,18 +53,29 @@ public class ExecutionEnvironment { @NotNull final RunnerAndConfigurationSettings configuration, Project project) { this(configuration.getConfiguration(), project, configuration.getRunnerSettings(runner), configuration.getConfigurationSettings(runner), - null); + null, configuration); } public ExecutionEnvironment(@NotNull RunProfile runProfile, Project project, RunnerSettings runnerSettings, - ConfigurationPerRunnerSettings configurationSettings, @Nullable RunContentDescriptor contentToReuse) { + ConfigurationPerRunnerSettings configurationSettings, + @Nullable RunContentDescriptor contentToReuse) { + this(runProfile, project, runnerSettings, configurationSettings, contentToReuse, null); + } + + public ExecutionEnvironment(@NotNull RunProfile runProfile, + Project project, + RunnerSettings runnerSettings, + ConfigurationPerRunnerSettings configurationSettings, + @Nullable RunContentDescriptor contentToReuse, + @Nullable RunnerAndConfigurationSettings settings) { myRunProfile = runProfile; myRunnerSettings = runnerSettings; myConfigurationSettings = configurationSettings; myProject = project; myContentToReuse = contentToReuse; + myRunnerAndConfigurationSettings = settings; } /** @@ -71,7 +83,7 @@ public class ExecutionEnvironment { */ @Deprecated public ExecutionEnvironment(@NotNull final ProgramRunner runner, @NotNull final RunnerAndConfigurationSettings configuration, final DataContext context) { - this(configuration.getConfiguration(), PlatformDataKeys.PROJECT.getData(context), configuration.getRunnerSettings(runner), configuration.getConfigurationSettings(runner), null); + this(configuration.getConfiguration(), PlatformDataKeys.PROJECT.getData(context), configuration.getRunnerSettings(runner), configuration.getConfigurationSettings(runner), null, configuration); } /** @@ -93,6 +105,11 @@ public class ExecutionEnvironment { this(runProfile, PlatformDataKeys.PROJECT.getData(dataContext), runnerSettings, configurationSettings, null); } + @Nullable + public RunnerAndConfigurationSettings getRunnerAndConfigurationSettings() { + return myRunnerAndConfigurationSettings; + } + @NotNull public RunProfile getRunProfile() { return myRunProfile; diff --git a/platform/lang-impl/src/com/intellij/execution/ExecutorRegistryImpl.java b/platform/lang-impl/src/com/intellij/execution/ExecutorRegistryImpl.java index 04471074818d..4360edec45a0 100644 --- a/platform/lang-impl/src/com/intellij/execution/ExecutorRegistryImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/ExecutorRegistryImpl.java @@ -25,6 +25,7 @@ import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.*; +import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.Trinity; import com.intellij.util.containers.HashMap; import com.intellij.util.containers.HashSet; @@ -33,6 +34,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import java.util.*; /** @@ -40,6 +42,8 @@ import java.util.*; */ public class ExecutorRegistryImpl extends ExecutorRegistry { private static final Logger LOG = Logger.getInstance("#com.intellij.execution.ExecutorRegistryImpl"); + private static final Icon STOP_AND_START_ICON = IconLoader.getIcon("/actions/restart.png"); + @NonNls public static final String RUNNERS_GROUP = "RunnerActions"; @NonNls public static final String RUN_CONTEXT_GROUP = "RunContextGroup"; @@ -240,7 +244,11 @@ public class ExecutorRegistryImpl extends ExecutorRegistry { if (configuration == null) { return; } - ProgramRunnerUtil.executeConfiguration(project, configuration, myExecutor); + if (configuration.isSingleton()) { + ExecutionManager.getInstance(project).restartRunProfile(project, myExecutor, configuration); + } else { + ProgramRunnerUtil.executeConfiguration(project, configuration, myExecutor); + } } } } diff --git a/platform/lang-impl/src/com/intellij/execution/actions/CreateAction.java b/platform/lang-impl/src/com/intellij/execution/actions/CreateAction.java index d7fd9e783393..b4b2c9e07286 100644 --- a/platform/lang-impl/src/com/intellij/execution/actions/CreateAction.java +++ b/platform/lang-impl/src/com/intellij/execution/actions/CreateAction.java @@ -122,7 +122,9 @@ public class CreateAction extends BaseRunConfigurationAction { final RunnerAndConfigurationSettings configuration = context.getConfiguration(); final RunnerAndConfigurationSettings template = runManager.getConfigurationTemplate(configuration.getFactory()); final RunConfiguration templateConfiguration = template.getConfiguration(); - runManager.addConfiguration(configuration, runManager.isConfigurationShared(template), runManager.getBeforeRunTasks( templateConfiguration), + runManager.addConfiguration(configuration, + runManager.isConfigurationShared(template), + runManager.getBeforeRunTasks(templateConfiguration), false); runManager.setActiveConfiguration(configuration); } diff --git a/platform/lang-impl/src/com/intellij/execution/impl/BeforeRunStepsPanel.java b/platform/lang-impl/src/com/intellij/execution/impl/BeforeRunStepsPanel.java index 0d1e0a76b703..3c75b8d42253 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/BeforeRunStepsPanel.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/BeforeRunStepsPanel.java @@ -52,6 +52,7 @@ import java.util.Set; */ class BeforeRunStepsPanel extends JPanel { private JCheckBox myShowSettingsBeforeRunCheckBox; + private JCheckBox mySingletonCheckBox; private JBList myList; private final CollectionListModel myModel; private RunConfiguration myRunConfiguration; @@ -129,11 +130,14 @@ class BeforeRunStepsPanel extends JPanel { }); myShowSettingsBeforeRunCheckBox = new JCheckBox(ExecutionBundle.message("configuration.edit.before.run")); + mySingletonCheckBox = new JCheckBox(ExecutionBundle.message("configuration.singleton")); + myPanel = myDecorator.createPanel(); setLayout(new MigLayout("fill, ins 0, gap 10, hidemode 3")); - add(myShowSettingsBeforeRunCheckBox, "shrinky, ay bottom, wrap"); - myPanel = myDecorator.createPanel(); - add(myPanel, "grow, push"); + add(myShowSettingsBeforeRunCheckBox, "shrink, split 2"); + add(mySingletonCheckBox, "shrink"); + add(Box.createHorizontalGlue(), "push, grow, wrap"); + add(myPanel, "grow, push, spanx 2"); } @Nullable @@ -154,7 +158,10 @@ class BeforeRunStepsPanel extends JPanel { originalTasks.addAll(RunManagerImpl.getInstanceImpl(myRunConfiguration.getProject()).getBeforeRunTasks(myRunConfiguration)); myModel.replaceAll(originalTasks); myShowSettingsBeforeRunCheckBox.setSelected(settings.isEditBeforeRun()); - myShowSettingsBeforeRunCheckBox.setEnabled(!(myRunConfiguration instanceof UnknownRunConfiguration)); + myShowSettingsBeforeRunCheckBox.setEnabled(!(isUnknown())); + mySingletonCheckBox.setSelected(settings.isSingleton()); + mySingletonCheckBox.setEnabled(!(isUnknown())); + mySingletonCheckBox.setVisible(myRunConfiguration.getFactory().canConfigurationBeSingleton()); myPanel.setVisible(checkBeforeRunTasksAbility(false)); } @@ -171,8 +178,12 @@ class BeforeRunStepsPanel extends JPanel { return myShowSettingsBeforeRunCheckBox.isSelected(); } + public boolean isSingleton() { + return myRunConfiguration.getFactory().canConfigurationBeSingleton() && mySingletonCheckBox.isSelected(); + } + private boolean checkBeforeRunTasksAbility(boolean checkOnlyAddAction) { - if (myRunConfiguration instanceof UnknownRunConfiguration) { + if (isUnknown()) { return false; } Set activeProviderKeys = getActiveProviderKeys(); @@ -191,8 +202,12 @@ class BeforeRunStepsPanel extends JPanel { return false; } + private boolean isUnknown() { + return myRunConfiguration instanceof UnknownRunConfiguration; + } + void doAddAction(AnActionButton button) { - if (myRunConfiguration instanceof UnknownRunConfiguration) { + if (isUnknown()) { return; } diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java b/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java index 61602caf11fc..71aadd855153 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java @@ -117,8 +117,10 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor> myRunningConfigurations = + new ArrayList>(); /** * reflection @@ -157,6 +167,7 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom final RunContentDescriptor descriptor = starter.execute(project, executor, state, reuseContent, env); if (descriptor != null) { + myRunningConfigurations.add(Trinity.create(descriptor, env.getRunnerAndConfigurationSettings(), executor)); ExecutionManager.getInstance(project).getContentManager().showRunContent(executor, descriptor, reuseContent); final ProcessHandler processHandler = descriptor.getProcessHandler(); if (processHandler != null) { @@ -194,6 +205,116 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom } } + @Override + public void restartRunProfile(@NotNull final Project project, + @NotNull final Executor executor, + @NotNull final RunnerAndConfigurationSettings configuration) { + RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project); + final RunManagerConfig config = runManager.getConfig(); + final List> pairs = getRunningDescriptors(configuration); + + for (Pair pair : pairs) { + ProcessHandler processHandler = pair.getFirst().getProcessHandler(); + if (processHandler == null) + continue; + if (!processHandler.isProcessTerminated()) { + if (config.isRestartRequiresConfirmation()) { + DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() { + @Override + public boolean isToBeShown() { + return config.isRestartRequiresConfirmation(); + } + + @Override + public void setToBeShown(boolean value, int exitCode) { + config.setRestartRequiresConfirmation(value); + } /**/ + + @Override + public boolean canBeHidden() { + return true; + } + + @Override + public boolean shouldSaveOptionsOnCancel() { + return false; + } + + @Override + public String getDoNotShowMessage() { + return CommonBundle.message("dialog.options.do.not.show"); + } + }; + if (Messages.OK != Messages.showOkCancelDialog(ExecutionBundle.message("rerun.confirmation.message", configuration.getName()), + ExecutionBundle.message("rerun.confirmation.title") + " ("+pair.getSecond().getId()+")", + CommonBundle.message("button.ok"), + CommonBundle.message("button.cancel"), + Messages.getQuestionIcon(), option)) { + return; + } + } + stop(processHandler); + for ( + Iterator> iterator = myRunningConfigurations.iterator(); + iterator.hasNext(); ) { + Trinity trinity = iterator.next(); + if (trinity.getFirst() == pair.getFirst()) { + iterator.remove(); + break; + } + } + } + } + + if (pairs.isEmpty()) { + ProgramRunnerUtil.executeConfiguration(project, configuration, executor); + return; + } + + Runnable runnable = new Runnable() { + @Override + public void run() { + for (Pair pair : pairs) { + ProcessHandler processHandler = pair.getFirst().getProcessHandler(); + if (processHandler == null) + continue; + if (!processHandler.isProcessTerminated()) { + awaitingTerminationAlarm.addRequest(this, 100); + return; + } + } + ProgramRunnerUtil.executeConfiguration(project, configuration, executor); + } + }; + awaitingTerminationAlarm.addRequest(runnable, 100); + } + + private List> getRunningDescriptors(RunnerAndConfigurationSettings configuration) { + List> result = new ArrayList>(); + for (Trinity trinity : myRunningConfigurations) { + if (trinity.getSecond() == configuration) { + result.add(Pair.create(trinity.getFirst(), trinity.getThird())); + } + } + return result; + } + + + + private static void stop(ProcessHandler processHandler) { + if (processHandler instanceof KillableProcess && processHandler.isProcessTerminating()) { + ((KillableProcess)processHandler).killProcess(); + return; + } + + if (processHandler.detachIsDefault()) { + processHandler.detachProcess(); + } + else { + processHandler.destroyProcess(); + } + } + @NotNull public String getComponentName() { return "ExecutionManager"; diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.java index 5f3116c907f2..9dfe97b09c78 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.java @@ -59,6 +59,8 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C private static final String TEMPORARY_ATTRIBUTE = "temporary"; @NonNls private static final String EDIT_BEFORE_RUN = "editBeforeRun"; + @NonNls + private static final String SINGLETON = "singleton"; /** for compatibility */ @@ -77,6 +79,7 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C private boolean myTemporary; private boolean myEditBeforeRun; + private boolean mySingleton; public RunnerAndConfigurationSettingsImpl(RunManagerImpl manager) { myManager = manager; @@ -136,6 +139,16 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C return myEditBeforeRun; } + @Override + public void setSingleton(boolean singleton) { + mySingleton = singleton; + } + + @Override + public boolean isSingleton() { + return mySingleton; + } + @Nullable private ConfigurationFactory getFactory(final Element element) { final String typeName = element.getAttributeValue(CONFIGURATION_TYPE_ATTRIBUTE); @@ -147,6 +160,7 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C myIsTemplate = Boolean.valueOf(element.getAttributeValue(TEMPLATE_FLAG_ATTRIBUTE)).booleanValue(); myTemporary = Boolean.valueOf(element.getAttributeValue(TEMPORARY_ATTRIBUTE)).booleanValue() || TEMP_CONFIGURATION.equals(element.getName()); myEditBeforeRun = Boolean.valueOf(element.getAttributeValue(EDIT_BEFORE_RUN)).booleanValue(); + mySingleton = Boolean.valueOf(element.getAttributeValue(SINGLETON)).booleanValue(); final ConfigurationFactory factory = getFactory(element); if (factory == null) return; @@ -208,6 +222,7 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C element.setAttribute(FACTORY_NAME_ATTRIBUTE, factory.getName()); if (isEditBeforeRun()) element.setAttribute(EDIT_BEFORE_RUN, String.valueOf(true)); + if (isSingleton()) element.setAttribute(SINGLETON, String.valueOf(true)); if (myTemporary) { element.setAttribute(TEMPORARY_ATTRIBUTE, Boolean.toString(myTemporary)); } diff --git a/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java b/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java index ebceccc36430..04b8f125deda 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java @@ -15,9 +15,7 @@ */ package com.intellij.execution.runners; -import com.intellij.CommonBundle; import com.intellij.execution.*; -import com.intellij.execution.impl.RunManagerImpl; import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.ui.RunContentDescriptor; import com.intellij.icons.AllIcons; @@ -26,9 +24,9 @@ import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.keymap.KeymapManager; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; -import com.intellij.util.Alarm; +import com.intellij.openapi.util.IconLoader; +import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -44,14 +42,13 @@ public class RestartAction extends AnAction implements DumbAware { private final Executor myExecutor; private final Icon myIcon; private final ExecutionEnvironment myEnvironment; - private final Alarm awaitingTerminationAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD); public RestartAction(final Executor executor, final ProgramRunner runner, final ProcessHandler processHandler, final Icon icon, final RunContentDescriptor descritor, - final ExecutionEnvironment env) { + @NotNull final ExecutionEnvironment env) { super(null, null, icon); myIcon = icon; myEnvironment = env; @@ -64,61 +61,7 @@ public class RestartAction extends AnAction implements DumbAware { } public void actionPerformed(final AnActionEvent e) { - final DataContext dataContext = e.getDataContext(); - final RunManagerConfig config = RunManagerImpl.getInstanceImpl(myEnvironment.getProject()).getConfig(); - if (myProcessHandler != null && !myProcessHandler.isProcessTerminated() && config.isRestartRequiresConfirmation()) { - DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() { - @Override - public boolean isToBeShown() { - return config.isRestartRequiresConfirmation(); - } - - @Override - public void setToBeShown(boolean value, int exitCode) { - config.setRestartRequiresConfirmation(value); - } - - @Override - public boolean canBeHidden() { - return true; - } - - @Override - public boolean shouldSaveOptionsOnCancel() { - return false; - } - - @Override - public String getDoNotShowMessage() { - return CommonBundle.message("dialog.options.do.not.show"); - } - }; - if (Messages.OK != Messages.showOkCancelDialog(ExecutionBundle.message("rerun.confirmation.message", myEnvironment.getRunProfile().getName()), - ExecutionBundle.message("rerun.confirmation.title"), CommonBundle.message("button.ok"), - CommonBundle.message("button.cancel"), - Messages.getQuestionIcon(), option)) { - return; - } - } - ActionManager.getInstance().getAction(IdeActions.ACTION_STOP_PROGRAM).actionPerformed(e); - update(e); - if (myProcessHandler != null) { - Runnable runnable = new Runnable() { - @Override - public void run() { - if (myProcessHandler == null || myProcessHandler.isProcessTerminated()) { - doRestart(dataContext); - } - else { - awaitingTerminationAlarm.addRequest(this, 100); - } - } - }; - awaitingTerminationAlarm.addRequest(runnable, 100); - } - else { - doRestart(dataContext); - } + ExecutionManager.getInstance(myEnvironment.getProject()).restartRunProfile(myEnvironment.getProject(), myExecutor, myEnvironment.getRunnerAndConfigurationSettings()); } public void restart() { @@ -133,7 +76,7 @@ public class RestartAction extends AnAction implements DumbAware { try { final ExecutionEnvironment old = myEnvironment; myRunner.execute(myExecutor, new ExecutionEnvironment(old.getRunProfile(), project, old.getRunnerSettings(), - old.getConfigurationSettings(), myDescriptor)); + old.getConfigurationSettings(), myDescriptor, old.getRunnerAndConfigurationSettings())); } catch (RunCanceledByUserException ignore) { } diff --git a/platform/platform-resources-en/src/messages/ExecutionBundle.properties b/platform/platform-resources-en/src/messages/ExecutionBundle.properties index c0c60bb80bb0..884c7b2c4c74 100644 --- a/platform/platform-resources-en/src/messages/ExecutionBundle.properties +++ b/platform/platform-resources-en/src/messages/ExecutionBundle.properties @@ -318,6 +318,7 @@ export.test.results.output.path.empty=Output path is empty export.test.results.output.filename.empty=Output file name is empty export.test.results.footer=Generated by {0} on {1} configuration.edit.before.run=Show settings +configuration.singleton=Allow only one instance failed.to.create.output.file=Failed to create output file ''{0}'' script.execution.timeout=Script execution took more than {0} seconds. From eb0917ff9416d8fb48e5f6aeee9e2bf91876f52b Mon Sep 17 00:00:00 2001 From: Vassiliy Kudryashov Date: Wed, 13 Jun 2012 18:05:52 +0400 Subject: [PATCH 129/172] IDEA-82509 Allow configuring run configurations as singletons --- .../src/com/intellij/execution/runners/RestartAction.java | 1 - 1 file changed, 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java b/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java index 04b8f125deda..3d6a332f8fcd 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java @@ -25,7 +25,6 @@ import com.intellij.openapi.keymap.KeymapManager; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.util.IconLoader; import org.jetbrains.annotations.NotNull; import javax.swing.*; From b364bf9b32bac1be9dbb4ae064be8dc47e3301e8 Mon Sep 17 00:00:00 2001 From: Vassiliy Kudryashov Date: Wed, 13 Jun 2012 21:58:42 +0400 Subject: [PATCH 130/172] IDEA-82509 Allow configuring run configurations as singletons --- .../com/intellij/execution/impl/BeforeRunStepsPanel.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/impl/BeforeRunStepsPanel.java b/platform/lang-impl/src/com/intellij/execution/impl/BeforeRunStepsPanel.java index 3c75b8d42253..d3d392761031 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/BeforeRunStepsPanel.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/BeforeRunStepsPanel.java @@ -51,9 +51,9 @@ import java.util.Set; * @author Vassiliy Kudryashov */ class BeforeRunStepsPanel extends JPanel { - private JCheckBox myShowSettingsBeforeRunCheckBox; - private JCheckBox mySingletonCheckBox; - private JBList myList; + private final JCheckBox myShowSettingsBeforeRunCheckBox; + private final JCheckBox mySingletonCheckBox; + private final JBList myList; private final CollectionListModel myModel; private RunConfiguration myRunConfiguration; From 14b8e71d2efd373465ae48e35d637a1dbb707d09 Mon Sep 17 00:00:00 2001 From: "andrey.zaytsev" Date: Wed, 13 Jun 2012 23:57:54 +0400 Subject: [PATCH 131/172] IDEA-87369 Right-click on a breakpoint: "edit" action is disabled if the cursor is not on the corresponding line --- .../BreakpointWithHighlighter.java | 121 +++++++++--------- .../xdebugger/impl/DebuggerSupport.java | 11 ++ .../impl/actions/EditBreakpointAction.java | 31 ++++- .../actions/EditBreakpointActionHandler.java | 4 + .../impl/breakpoints/XBreakpointBase.java | 5 +- 5 files changed, 108 insertions(+), 64 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java index 7ef5417ca915..a285463aeea4 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java @@ -25,6 +25,7 @@ import com.intellij.debugger.engine.events.DebuggerCommandImpl; import com.intellij.debugger.engine.requests.RequestManagerImpl; import com.intellij.debugger.impl.DebuggerContextImpl; import com.intellij.debugger.settings.DebuggerSettings; +import com.intellij.debugger.ui.JavaDebuggerSupport; import com.intellij.idea.ActionsBundle; import com.intellij.openapi.actionSystem.ActionGroup; import com.intellij.openapi.actionSystem.AnAction; @@ -49,6 +50,7 @@ import com.intellij.psi.PsiManager; import com.intellij.psi.jsp.JspFile; import com.intellij.ui.classFilter.ClassFilter; import com.intellij.util.StringBuilderSpinAllocator; +import com.intellij.xdebugger.impl.DebuggerSupport; import com.intellij.xdebugger.impl.actions.EditBreakpointAction; import com.intellij.xdebugger.impl.actions.ViewBreakpointsAction; import com.intellij.xdebugger.impl.actions.XDebuggerActions; @@ -594,67 +596,6 @@ public abstract class BreakpointWithHighlighter extends Breakpoint { } } - @NotNull - private ActionGroup createMenuActions() { - final BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager(); - /** - * Used from Popup Menu - */ - class RemoveAction extends AnAction { - @Nullable private Breakpoint myBreakpoint; - - public RemoveAction(Breakpoint breakpoint) { - super(DebuggerBundle.message("action.remove.text")); - myBreakpoint = breakpoint; - } - - @Override - public void actionPerformed(AnActionEvent e) { - if (myBreakpoint != null) { - breakpointManager.removeBreakpoint(myBreakpoint); - myBreakpoint = null; - } - } - } - - /** - * Used from Popup Menu - */ - class SetEnabledAction extends AnAction { - private final boolean myNewValue; - private final Breakpoint myBreakpoint; - - public SetEnabledAction(Breakpoint breakpoint, boolean newValue) { - super(newValue ? DebuggerBundle.message("action.enable.text") : DebuggerBundle.message("action.disable.text")); - myBreakpoint = breakpoint; - myNewValue = newValue; - } - - @Override - public void actionPerformed(AnActionEvent e) { - myBreakpoint.ENABLED = myNewValue; - breakpointManager.fireBreakpointChanged(myBreakpoint); - myBreakpoint.updateUI(); - } - } - - - AnAction viewBreakpointsAction = - new ViewBreakpointsAction(ActionsBundle.actionText(XDebuggerActions.VIEW_BREAKPOINTS), this); - - DefaultActionGroup group = new DefaultActionGroup(); - RangeHighlighter highlighter = getHighlighter(); - if (highlighter != null) { - group.add(new EditBreakpointAction()); - group.addSeparator(); - } - group.add(new SetEnabledAction(this, !ENABLED)); - group.add(new RemoveAction(this)); - group.addSeparator(); - group.add(viewBreakpointsAction); - return group; - } - private class MyGutterIconRenderer extends GutterIconRenderer { private final Icon myIcon; private final String myDescription; @@ -699,7 +640,63 @@ public abstract class BreakpointWithHighlighter extends Breakpoint { @Override public ActionGroup getPopupMenuActions() { - return createMenuActions(); + final BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager(); + /** + * Used from Popup Menu + */ + class RemoveAction extends AnAction { + @Nullable private Breakpoint myBreakpoint; + + public RemoveAction(Breakpoint breakpoint) { + super(DebuggerBundle.message("action.remove.text")); + myBreakpoint = breakpoint; + } + + @Override + public void actionPerformed(AnActionEvent e) { + if (myBreakpoint != null) { + breakpointManager.removeBreakpoint(myBreakpoint); + myBreakpoint = null; + } + } + } + + /** + * Used from Popup Menu + */ + class SetEnabledAction extends AnAction { + private final boolean myNewValue; + private final Breakpoint myBreakpoint; + + public SetEnabledAction(Breakpoint breakpoint, boolean newValue) { + super(newValue ? DebuggerBundle.message("action.enable.text") : DebuggerBundle.message("action.disable.text")); + myBreakpoint = breakpoint; + myNewValue = newValue; + } + + @Override + public void actionPerformed(AnActionEvent e) { + myBreakpoint.ENABLED = myNewValue; + breakpointManager.fireBreakpointChanged(myBreakpoint); + myBreakpoint.updateUI(); + } + } + + + AnAction viewBreakpointsAction = + new ViewBreakpointsAction(ActionsBundle.actionText(XDebuggerActions.VIEW_BREAKPOINTS), BreakpointWithHighlighter.this); + + DefaultActionGroup group = new DefaultActionGroup(); + RangeHighlighter highlighter = getHighlighter(); + if (highlighter != null) { + group.add(new EditBreakpointAction.ContextAction(this, BreakpointWithHighlighter.this, DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class))); + group.addSeparator(); + } + group.add(new SetEnabledAction(BreakpointWithHighlighter.this, !ENABLED)); + group.add(new RemoveAction(BreakpointWithHighlighter.this)); + group.addSeparator(); + group.add(viewBreakpointsAction); + return group; } @Override diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/DebuggerSupport.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/DebuggerSupport.java index fec2522df253..1b173c310f9e 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/DebuggerSupport.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/DebuggerSupport.java @@ -104,4 +104,15 @@ public abstract class DebuggerSupport { @NotNull public abstract EditBreakpointActionHandler getEditBreakpointAction(); + + + @Nullable + public static DebuggerSupport getDebuggerSupport(Class aClass) { + for (DebuggerSupport support : getDebuggerSupports()) { + if (support.getClass() == aClass) { + return support; + } + } + return null; + } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointAction.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointAction.java index 9ffd9eea4abb..a59824d37b00 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointAction.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointAction.java @@ -16,13 +16,42 @@ package com.intellij.xdebugger.impl.actions; import com.intellij.idea.ActionsBundle; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.markup.GutterIconRenderer; import com.intellij.xdebugger.impl.DebuggerSupport; import org.jetbrains.annotations.NotNull; public class EditBreakpointAction extends XDebuggerActionBase { + public static class ContextAction extends AnAction { + private final GutterIconRenderer myRenderer; + private final Object myBreakpoint; + private DebuggerSupport myDebuggerSupport; + + public ContextAction(GutterIconRenderer breakpointRenderer, Object breakpoint, DebuggerSupport debuggerSupport) { + myRenderer = breakpointRenderer; + myBreakpoint = breakpoint; + myDebuggerSupport = debuggerSupport; + initPresentation(this); + } + + @Override + public void actionPerformed(AnActionEvent e) { + final Editor editor = PlatformDataKeys.EDITOR.getData(e.getDataContext()); + if (editor == null) return; + myDebuggerSupport.getEditBreakpointAction().editBreakpoint(getEventProject(e), editor, myBreakpoint, myRenderer); + } + } + public EditBreakpointAction() { - getTemplatePresentation().setText(ActionsBundle.actionText("EditBreakpoint")); + initPresentation(this); + } + + private static void initPresentation(AnAction action) { + action.getTemplatePresentation().setText(ActionsBundle.actionText("EditBreakpoint")); } @NotNull diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointActionHandler.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointActionHandler.java index 0e7e9f5d8fc6..dced3beba523 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointActionHandler.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointActionHandler.java @@ -53,6 +53,10 @@ public abstract class EditBreakpointActionHandler extends DebuggerActionHandler GutterIconRenderer breakpointGutterRenderer = pair.first; if (breakpointGutterRenderer == null) return; + editBreakpoint(project, editor, breakpoint, breakpointGutterRenderer); + } + + public void editBreakpoint(@NotNull Project project, @NotNull Editor editor, @NotNull Object breakpoint, @NotNull GutterIconRenderer breakpointGutterRenderer) { EditorGutterComponentEx gutterComponent = ((EditorEx)editor).getGutterComponentEx(); Point point = gutterComponent.getPoint(breakpointGutterRenderer); if (point == null) return; diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java index ee402cd19137..aa77773d5e53 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java @@ -37,7 +37,9 @@ import com.intellij.xdebugger.breakpoints.SuspendPolicy; import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.breakpoints.XBreakpointProperties; import com.intellij.xdebugger.breakpoints.XBreakpointType; +import com.intellij.xdebugger.impl.DebuggerSupport; import com.intellij.xdebugger.impl.XDebugSessionImpl; +import com.intellij.xdebugger.impl.XDebuggerSupport; import com.intellij.xdebugger.impl.XDebuggerUtilImpl; import com.intellij.xdebugger.impl.actions.EditBreakpointAction; import com.intellij.xdebugger.impl.actions.ViewBreakpointsAction; @@ -366,7 +368,8 @@ public class XBreakpointBase, P extends XBreakpointP DefaultActionGroup group = new DefaultActionGroup(); final XDebuggerManager debuggerManager = XDebuggerManager.getInstance(getProject()); - group.add(new EditBreakpointAction()); + + group.add(new EditBreakpointAction.ContextAction(this, XBreakpointBase.this, DebuggerSupport.getDebuggerSupport(XDebuggerSupport.class))); group.add(new Separator()); From fa20240ba8eefe810409b3e998608c0608550ae9 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Wed, 13 Jun 2012 15:28:01 +0400 Subject: [PATCH 132/172] IDEA-87221 Invalid 'assignment is not used' --- .../controlFlow/impl/ControlFlowBuilder.java | 20 +++++++--- .../groovy/lang/GroovyHighlightingTest.groovy | 38 +++++++++++++++++-- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java index 5b0fd7ea2d09..03f57fee1467 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java @@ -413,9 +413,15 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { List negations = collectAndRemoveAllPendingNegations(expression); + InstructionImpl head = myHead; addPendingEdge(expression, addNodeAndCheckPending(new PositiveGotoInstruction(expression, cond))); - myHead = reduceAllNegationsIntoInstruction(expression, negations); + if (negations.isEmpty()) { + myHead = head; + } + else { + myHead = reduceAllNegationsIntoInstruction(expression, negations); + } } @Nullable @@ -556,7 +562,8 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { addNodeAndCheckPending(new InstructionImpl(expression)); //collect all pending edges from left argument addPendingEdge(expression, myHead); - myHead = reduceAllNegationsIntoInstruction(expression, negations); + InstructionImpl head = reduceAllNegationsIntoInstruction(expression, negations); + if (head != null) myHead = head; //addNode(new NegatingGotoInstruction(expression, myInstructionNumber++, condition)); } myConditions.removeFirstOccurrence(condition); @@ -611,7 +618,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { } myHead = reduceAllNegationsIntoInstruction(ifStatement, negations); - if (negations.isEmpty() && conditionEnd != null) { + if (myHead == null && conditionEnd != null) { myHead = conditionEnd; } if (elseBranch != null) { @@ -785,6 +792,7 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { GrExpression elseBranch = expression.getElseBranch(); condition.accept(this); + InstructionImpl conditionEnd = myHead; List negations = collectAndRemoveAllPendingNegations(expression); if (thenBranch != null) { @@ -794,7 +802,8 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { } if (elseBranch != null) { - myHead = reduceAllNegationsIntoInstruction(expression, negations); + InstructionImpl head = reduceAllNegationsIntoInstruction(expression, negations); + myHead = head != null ? head : conditionEnd; elseBranch.accept(this); handlePossibleReturn(elseBranch); } @@ -810,7 +819,8 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { addPendingEdge(expression, myHead); if (elseBranch != null) { - myHead = reduceAllNegationsIntoInstruction(expression, negations); + InstructionImpl head = reduceAllNegationsIntoInstruction(expression, negations); + if (head != null) myHead = head; elseBranch.accept(this); handlePossibleReturn(elseBranch); } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy index e612fc2c2050..fa1c8d9966e2 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy @@ -49,6 +49,8 @@ import org.jetbrains.plugins.groovy.util.TestUtils import org.jetbrains.plugins.groovy.codeInspection.bugs.* import org.jetbrains.plugins.groovy.codeInspection.confusing.* +import static org.jetbrains.plugins.groovy.util.TestUtils.getMockGroovy1_8LibraryName + /** * @author peter */ @@ -56,8 +58,8 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase { public static final DefaultLightProjectDescriptor GROOVY_18_PROJECT_DESCRIPTOR = new DefaultLightProjectDescriptor() { @Override public void configureModule(Module module, ModifiableRootModel model, ContentEntry contentEntry) { - final Library.ModifiableModel modifiableModel = model.getModuleLibraryTable().createLibrary("GROOVY").getModifiableModel(); - final VirtualFile groovyJar = JarFileSystem.getInstance().refreshAndFindFileByPath(TestUtils.getMockGroovy1_8LibraryName()+"!/"); + final Library.ModifiableModel modifiableModel = model.moduleLibraryTable.createLibrary("GROOVY").modifiableModel; + final VirtualFile groovyJar = JarFileSystem.instance.refreshAndFindFileByPath(mockGroovy1_8LibraryName + '!/'); assertTrue(groovyJar != null); modifiableModel.addRoot(groovyJar, OrderRootType.CLASSES); modifiableModel.commit(); @@ -66,7 +68,7 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase { @Override protected String getBasePath() { - return TestUtils.getTestDataPath() + "highlighting/"; + return TestUtils.testDataPath + 'highlighting/'; } @NotNull @@ -1059,4 +1061,34 @@ class A { myFixture.enableInspections(GroovyAssignabilityCheckInspection) myFixture.checkHighlighting(true, false, true) } + + void testUsedVar() { + testHighlighting('''\ +def foo(xxx) { + if ((xxx = 5) || xxx) { + xxx=4 + } +} + +def foxo(doo) { + def xxx = 'asdf' + if (!doo) { + println xxx + xxx=5 + } +} + +def bar(xxx) { + print ((xxx=5)?:xxx) +} + +def a(xxx) { + if (2 && (xxx=5)) { + xxx + } + else { + } +} +''', UnusedDefInspection) + } } \ No newline at end of file From dda51dddeb442f0eea9ca12976f93d3004b278f5 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Wed, 13 Jun 2012 15:38:02 +0400 Subject: [PATCH 133/172] 'convert to GString' should not be applicable to gstring --- .../ConvertConcatenationToGstringIntention.java | 7 ++++++- .../statements/expressions/literals/GrLiteralImpl.java | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertConcatenationToGstringIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertConcatenationToGstringIntention.java index 8e51b604fe8b..b1356e55193a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertConcatenationToGstringIntention.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertConcatenationToGstringIntention.java @@ -39,6 +39,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrString; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; +import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrLiteralImpl; import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil; import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames; @@ -175,7 +176,11 @@ public class ConvertConcatenationToGstringIntention extends Intention { } public static boolean satisfiedBy(PsiElement element, boolean checkForParent) { - if (element instanceof GrString || element instanceof GrLiteral && ((GrLiteral)element).getValue() instanceof String) return true; + if (element instanceof GrLiteral && + ((GrLiteral)element).getValue() instanceof String && + GrLiteralImpl.getLiteralType((GrLiteral)element) != GroovyTokenTypes.mGSTRING_LITERAL) { + return true; + } if (!(element instanceof GrBinaryExpression)) return false; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralImpl.java index d2428e868418..720bda68a0ac 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralImpl.java @@ -149,7 +149,7 @@ public class GrLiteralImpl extends GrAbstractLiteral implements GrLiteral, PsiLa return null; } - private static IElementType getLiteralType(GrLiteral literal) { + public static IElementType getLiteralType(GrLiteral literal) { PsiElement firstChild = literal.getFirstChild(); assert firstChild != null; return firstChild.getNode().getElementType(); From c681fd0b16204a78e94e39a887e44cf615892ac6 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Thu, 14 Jun 2012 10:12:24 +0400 Subject: [PATCH 134/172] IDEA-87197 Support @TypeChecked(SKIP) --- .../lang/psi/impl/GroovyPsiManager.java | 33 ++++++++++++------- .../lang/psi/util/GroovyCommonClassNames.java | 1 + .../groovy/lang/resolve/ResolveUtil.java | 10 ++++++ 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiManager.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiManager.java index a7339849bec0..e02b05fc7a65 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiManager.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiManager.java @@ -40,25 +40,29 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement; import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; -import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames; +import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentMap; +import static com.intellij.psi.CommonClassNames.*; +import static org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames.*; + /** * @author ven */ public class GroovyPsiManager { private static final Logger LOG = Logger.getInstance("org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager"); - private static final Set ourPopularClasses = Sets.newHashSet(GroovyCommonClassNames.GROOVY_LANG_CLOSURE, - GroovyCommonClassNames.DEFAULT_BASE_CLASS_NAME, - GroovyCommonClassNames.GROOVY_OBJECT_SUPPORT, - CommonClassNames.JAVA_UTIL_LIST, - CommonClassNames.JAVA_UTIL_COLLECTION, - CommonClassNames.JAVA_LANG_STRING); + private static final Set ourPopularClasses = Sets.newHashSet(GROOVY_LANG_CLOSURE, + DEFAULT_BASE_CLASS_NAME, + GROOVY_OBJECT_SUPPORT, + JAVA_UTIL_LIST, + JAVA_UTIL_COLLECTION, + JAVA_LANG_STRING); private final Project myProject; private volatile GrTypeDefinition myArrayClass; @@ -135,16 +139,23 @@ public class GroovyPsiManager { private boolean isCompileStaticInner(PsiMember member) { PsiModifierList list = member.getModifierList(); if (list != null) { - PsiAnnotation annotation = list.findAnnotation(GroovyCommonClassNames.GROOVY_TRANSFORM_COMPILE_STATIC); - if (annotation != null) return true; - PsiAnnotation typeChecked = list.findAnnotation(GroovyCommonClassNames.GROOVY_TRANSFORM_TYPE_CHECKED); - if (typeChecked != null) return true; + PsiAnnotation compileStatic = list.findAnnotation(GROOVY_TRANSFORM_COMPILE_STATIC); + if (compileStatic != null) return checkForPass(compileStatic); + PsiAnnotation typeChecked = list.findAnnotation(GROOVY_TRANSFORM_TYPE_CHECKED); + if (typeChecked != null) return checkForPass(typeChecked); } PsiClass aClass = member.getContainingClass(); if (aClass != null) return isCompileStatic(aClass); return false; } + private static boolean checkForPass(PsiAnnotation annotation) { + PsiAnnotationMemberValue value = annotation.findAttributeValue("value"); + return value == null || + value instanceof GrReferenceExpression && + ResolveUtil.isEnumConstant((GrReferenceExpression)value, "PASS", GROOVY_TRANSFORM_TYPE_CHECKING_MODE); + } + @Nullable public PsiClass findClassWithCache(String fqName, GlobalSearchScope resolveScope) { SoftReference> reference = myClassCache.get(fqName); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyCommonClassNames.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyCommonClassNames.java index 851927168bdb..d939e0f36379 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyCommonClassNames.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyCommonClassNames.java @@ -53,6 +53,7 @@ public final class GroovyCommonClassNames { @NonNls public static final String GROOVY_LANG_SINGLETON = "groovy.lang.Singleton"; @NonNls public static final String GROOVY_TRANSFORM_COMPILE_STATIC = "groovy.transform.CompileStatic"; @NonNls public static final String GROOVY_TRANSFORM_TYPE_CHECKED = "groovy.transform.TypeChecked"; + @NonNls public static final String GROOVY_TRANSFORM_TYPE_CHECKING_MODE = "groovy.transform.TypeCheckingMode"; private GroovyCommonClassNames() { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java index bdfc6115f5de..97df07eb5752 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java @@ -687,4 +687,14 @@ public class ResolveUtil { } return null; } + + public static boolean isEnumConstant(GrReferenceExpression ref, String name, String qName) { + PsiElement resolved = ref.resolve(); + if (!(resolved instanceof PsiEnumConstant)) return false; + if (!name.equals(((PsiEnumConstant)resolved).getName())) return false; + + PsiClass aClass = ((PsiEnumConstant)resolved).getContainingClass(); + if (aClass == null) return false; + return qName.equals(aClass.getQualifiedName()); + } } From fe9e7232eab0643f8f0c2510da7de4ed66c8cd7e Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Thu, 14 Jun 2012 11:35:51 +0400 Subject: [PATCH 135/172] fix tests --- .../intellij/execution/testframework/sm/FileUrlLocationTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/FileUrlLocationTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/FileUrlLocationTest.java index 58a0170ccdec..4ae30313b971 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/FileUrlLocationTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/FileUrlLocationTest.java @@ -45,6 +45,7 @@ public class FileUrlLocationTest extends SMLightFixtureTestCase { final String filePath, final int lineNum) { final SMTestProxy testProxy = new SMTestProxy("myTest", false, "file://" + filePath + ":" + lineNum); + testProxy.setLocator(new CompositeTestLocationProvider(null)); final Location location = testProxy.getLocation(getProject()); assertNotNull(location); From a65fe552028380105a82b8007317be3cb61eae50 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Thu, 14 Jun 2012 09:54:40 +0200 Subject: [PATCH 136/172] improve whitespace handling of "Replace with 'try' with resources" quickfix --- ...inallyCanBeTryWithResourcesInspection.java | 51 ++++++++----------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/migration/TryFinallyCanBeTryWithResourcesInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/migration/TryFinallyCanBeTryWithResourcesInspection.java index 68cca910f8b4..5154916f3f18 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/migration/TryFinallyCanBeTryWithResourcesInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/migration/TryFinallyCanBeTryWithResourcesInspection.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. @@ -31,6 +31,7 @@ import com.siyeh.ig.InspectionGadgetsFix; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.*; @@ -74,8 +75,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection { } @Override - protected void doFix(Project project, ProblemDescriptor descriptor) - throws IncorrectOperationException { + protected void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException { final PsiElement element = descriptor.getPsiElement(); final PsiElement parent = element.getParent(); if (!(parent instanceof PsiTryStatement)) { @@ -93,10 +93,8 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection { variables.add(variable); } } - final PsiElementFactory factory = - JavaPsiFacade.getElementFactory(project); - @NonNls final StringBuilder newTryStatementText = - new StringBuilder("try ("); + final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); + @NonNls final StringBuilder newTryStatementText = new StringBuilder("try ("); final Set unwantedChildren = new HashSet(2); boolean separator = false; for (PsiLocalVariable variable : variables) { @@ -120,19 +118,17 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection { newTryStatementText.append(initializer.getText()); } else { - final int index = findInitialization(tryBlockChildren, - variable, hasInitializer); + final int index = findInitialization(tryBlockChildren, variable, hasInitializer); if (index < 0) { return; } unwantedChildren.add(Integer.valueOf(index)); - final PsiExpressionStatement expressionStatement = - (PsiExpressionStatement)tryBlockChildren[index]; - final PsiAssignmentExpression assignmentExpression = - (PsiAssignmentExpression) - expressionStatement.getExpression(); - final PsiExpression rhs = - assignmentExpression.getRExpression(); + final PsiExpressionStatement expressionStatement = (PsiExpressionStatement)tryBlockChildren[index]; + if (expressionStatement.getNextSibling() instanceof PsiWhiteSpace) { + unwantedChildren.add(Integer.valueOf(index + 1)); + } + final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression)expressionStatement.getExpression(); + final PsiExpression rhs = assignmentExpression.getRExpression(); if (rhs == null) { return; } @@ -145,16 +141,12 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection { for (int i = 1; i < tryBlockStatementsLength; i++) { final PsiElement child = tryBlockChildren[i]; if (unwantedChildren.contains(Integer.valueOf(i))) { - if (child.getNextSibling() instanceof PsiWhiteSpace) { - i++; - } continue; } newTryStatementText.append(child.getText()); } newTryStatementText.append('}'); - final PsiCatchSection[] catchSections = - tryStatement.getCatchSections(); + final PsiCatchSection[] catchSections = tryStatement.getCatchSections(); for (PsiCatchSection catchSection : catchSections) { newTryStatementText.append(catchSection.getText()); } @@ -167,17 +159,17 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection { for (int i = 1; i < finallyChildrenLength; i++) { final PsiElement child = finallyChildren[i]; if (isCloseStatement(child, variables)) { - if (child.getNextSibling() instanceof PsiWhiteSpace) { - i++; - } continue; } if (!appended) { - if (child instanceof PsiWhiteSpace || - child instanceof PsiComment) { + if (child instanceof PsiComment) { + final PsiElement prevSibling = child.getPrevSibling(); + if (prevSibling instanceof PsiWhiteSpace) { + savedComments.add(prevSibling); + } savedComments.add(child); } - else { + else if (!(child instanceof PsiWhiteSpace)) { newTryStatementText.append(" finally {"); for (PsiElement savedComment : savedComments) { newTryStatementText.append(savedComment.getText()); @@ -204,9 +196,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection { parent1.addAfter(savedComment, tryStatement); } } - final PsiStatement newTryStatement = - factory.createStatementFromText( - newTryStatementText.toString(), element); + final PsiStatement newTryStatement = factory.createStatementFromText(newTryStatementText.toString(), element); tryStatement.replace(newTryStatement); } @@ -404,6 +394,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection { return variables; } + @Nullable static PsiLocalVariable findAutoCloseableVariable( PsiStatement statement) { if (statement instanceof PsiIfStatement) { From 2c544d3fee4f5ba98a12eaabc440c4240be163da Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 14 Jun 2012 11:54:37 +0400 Subject: [PATCH 137/172] Fix GitCherryPickTest: commit session is null in tests => return the original commit message --- .../src/git4idea/history/browser/GitCherryPicker.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/git4idea/src/git4idea/history/browser/GitCherryPicker.java b/plugins/git4idea/src/git4idea/history/browser/GitCherryPicker.java index d71aa1d10d12..031809e42429 100644 --- a/plugins/git4idea/src/git4idea/history/browser/GitCherryPicker.java +++ b/plugins/git4idea/src/git4idea/history/browser/GitCherryPicker.java @@ -45,6 +45,7 @@ import git4idea.repo.GitRepository; import git4idea.util.UntrackedFilesNotifier; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.event.HyperlinkEvent; @@ -462,17 +463,17 @@ public class GitCherryPicker { @NotNull private final Project myProject; @NotNull private final PlatformFacade myPlatformFacade; @NotNull private final List myChanges; - @NotNull private final String myCommitMessage; + @NotNull private final String myOriginalCommitMessage; private boolean myCommitFailed; - private CherryPickCommitExecutor.CherryPickCommitSession myCommitSession; + @Nullable private CherryPickCommitExecutor.CherryPickCommitSession myCommitSession; CherryPickCommitExecutor(@NotNull Project project, @NotNull PlatformFacade platformFacade, - @NotNull List changes, @NotNull String commitMessage) { + @NotNull List changes, @NotNull String originalCommitMessage) { myProject = project; myPlatformFacade = platformFacade; myChanges = changes; - myCommitMessage = commitMessage; + myOriginalCommitMessage = originalCommitMessage; } @Nls @@ -494,7 +495,7 @@ public class GitCherryPicker { @NotNull public String getActualCommitMessage() { - return myCommitSession.getActualCommitMessage(); + return myCommitSession == null ? myOriginalCommitMessage : myCommitSession.getActualCommitMessage(); } private class CherryPickCommitSession implements CommitSession { From d978a1b19d32c0f49c105b6e4e9d5ae43baad738 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 14 Jun 2012 11:11:16 +0400 Subject: [PATCH 138/172] create test: remember once chosen super class --- .../createTest/CreateTestDialog.java | 9 ++++++--- .../ui/ReferenceEditorComboWithBrowseButton.java | 7 ++++++- .../src/com/intellij/ui/EditorComboBox.java | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/java/java-impl/src/com/intellij/testIntegration/createTest/CreateTestDialog.java b/java/java-impl/src/com/intellij/testIntegration/createTest/CreateTestDialog.java index 3b38008516db..573a8c7dba60 100644 --- a/java/java-impl/src/com/intellij/testIntegration/createTest/CreateTestDialog.java +++ b/java/java-impl/src/com/intellij/testIntegration/createTest/CreateTestDialog.java @@ -69,6 +69,7 @@ import java.util.List; public class CreateTestDialog extends DialogWrapper { private static final String RECENTS_KEY = "CreateTestDialog.RecentsKey"; + private static final String RECENT_SUPERS_KEY = "CreateTestDialog.Recents.Supers"; private static final String DEFAULT_LIBRARY_NAME_PROPERTY = CreateTestDialog.class.getName() + ".defaultLibrary"; private static final String SHOW_INHERITED_MEMBERS_PROPERTY = CreateTestDialog.class.getName() + ".includeInheritedMembers"; @@ -81,7 +82,7 @@ public class CreateTestDialog extends DialogWrapper { private final List myLibraryButtons = new ArrayList(); private EditorTextField myTargetClassNameField; - private ReferenceEditorWithBrowseButton mySuperClassField; + private ReferenceEditorComboWithBrowseButton mySuperClassField; private ReferenceEditorComboWithBrowseButton myTargetPackageField; private JCheckBox myGenerateBeforeBox; private JCheckBox myGenerateAfterBox; @@ -176,7 +177,8 @@ public class CreateTestDialog extends DialogWrapper { } }); - mySuperClassField = JavaReferenceEditorUtil.createReferenceEditorWithBrowseButton(new MyChooseSuperClassAction(), "", myProject, true); + mySuperClassField = new ReferenceEditorComboWithBrowseButton(new MyChooseSuperClassAction(), null, myProject, true, + JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE, RECENT_SUPERS_KEY); mySuperClassField.setMinimumSize(mySuperClassField.getPreferredSize()); String targetPackageName = targetPackage != null ? targetPackage.getQualifiedName() : ""; @@ -209,7 +211,7 @@ public class CreateTestDialog extends DialogWrapper { myFixLibraryPanel.setVisible(!descriptor.isLibraryAttached(myTargetModule)); String superClass = descriptor.getDefaultSuperClass(); - mySuperClassField.setText(superClass == null ? "" : superClass); + mySuperClassField.appendItem(superClass == null ? "" : superClass); mySelectedFramework = descriptor; } @@ -416,6 +418,7 @@ public class CreateTestDialog extends DialogWrapper { protected void doOKAction() { RecentsManager.getInstance(myProject).registerRecentEntry(RECENTS_KEY, myTargetPackageField.getText()); + RecentsManager.getInstance(myProject).registerRecentEntry(RECENT_SUPERS_KEY, mySuperClassField.getText()); String errorMessage; try { diff --git a/java/java-impl/src/com/intellij/ui/ReferenceEditorComboWithBrowseButton.java b/java/java-impl/src/com/intellij/ui/ReferenceEditorComboWithBrowseButton.java index 286e897e82ec..718a8c2fcdc7 100644 --- a/java/java-impl/src/com/intellij/ui/ReferenceEditorComboWithBrowseButton.java +++ b/java/java-impl/src/com/intellij/ui/ReferenceEditorComboWithBrowseButton.java @@ -19,6 +19,7 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.ComponentWithBrowseButton; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; @@ -42,7 +43,7 @@ public class ReferenceEditorComboWithBrowseButton extends ComponentWithBrowseBut @NotNull final Project project, boolean toAcceptClasses, final JavaCodeFragment.VisibilityChecker visibilityChecker, final String recentsKey) { - super(new EditorComboBox(createDocument(text, project, toAcceptClasses, visibilityChecker), project, StdFileTypes.JAVA), + super(new EditorComboBox(createDocument(StringUtil.isEmpty(text) ? "" : text, project, toAcceptClasses, visibilityChecker), project, StdFileTypes.JAVA), browseActionListener); final List recentEntries = RecentsManager.getInstance(project).getRecentEntries(recentsKey); if (recentEntries != null) { @@ -82,4 +83,8 @@ public class ReferenceEditorComboWithBrowseButton extends ComponentWithBrowseBut public void prependItem(String item) { getChildComponent().prependItem(item); } + + public void appendItem(String item) { + getChildComponent().appendItem(item); + } } diff --git a/platform/platform-impl/src/com/intellij/ui/EditorComboBox.java b/platform/platform-impl/src/com/intellij/ui/EditorComboBox.java index e20f02484fb0..af01dd3dce83 100644 --- a/platform/platform-impl/src/com/intellij/ui/EditorComboBox.java +++ b/platform/platform-impl/src/com/intellij/ui/EditorComboBox.java @@ -215,6 +215,20 @@ public class EditorComboBox extends JComboBox implements DocumentListener { setModel(new DefaultComboBoxModel(ArrayUtil.toObjectArray(objects))); } + public void appendItem(String item) { + ArrayList objects = new ArrayList(); + + int count = getItemCount(); + for (int i = 0; i < count; i++) { + objects.add(getItemAt(i)); + } + + if (!objects.contains(item)) { + objects.add(item); + } + setModel(new DefaultComboBoxModel(ArrayUtil.toObjectArray(objects))); + } + private class MyEditor implements ComboBoxEditor { public void addActionListener(ActionListener l) { } From 9711e33baee4d11fa4cb573f588680c1a6cf4be6 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 14 Jun 2012 12:02:20 +0400 Subject: [PATCH 139/172] include file templates in searchable options (IDEA-87213) --- .../ide/ui/search/TraverseUIStarter.java | 58 ++++++++++++++----- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/ui/search/TraverseUIStarter.java b/platform/lang-impl/src/com/intellij/ide/ui/search/TraverseUIStarter.java index 04dde9854cda..05dd4c188f5b 100644 --- a/platform/lang-impl/src/com/intellij/ide/ui/search/TraverseUIStarter.java +++ b/platform/lang-impl/src/com/intellij/ide/ui/search/TraverseUIStarter.java @@ -17,8 +17,12 @@ package com.intellij.ide.ui.search; import com.intellij.application.options.OptionsContainingConfigurable; +import com.intellij.ide.fileTemplates.FileTemplate; +import com.intellij.ide.fileTemplates.FileTemplateManager; +import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable; import com.intellij.ide.plugins.AvailablePluginsManagerMain; import com.intellij.ide.plugins.PluginManagerConfigurable; +import com.intellij.internal.ImageDuplicateResultsDialog; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.impl.ActionManagerImpl; @@ -90,9 +94,7 @@ public class TraverseUIStarter implements ApplicationStarter { configurableElement.setAttribute(ID, id); configurableElement.setAttribute(CONFIGURABLE_NAME, configurable.getDisplayName()); final TreeSet sortedOptions = options.get(configurable); - for (OptionDescription option : sortedOptions) { - append(option.getPath(), option.getHit(), option.getOption(), configurableElement); - } + writeOptions(configurableElement, sortedOptions); if (configurable instanceof KeymapPanel){ processKeymap(configurableElement); } else if (configurable instanceof OptionsContainingConfigurable){ @@ -102,6 +104,8 @@ public class TraverseUIStarter implements ApplicationStarter { for (OptionDescription description : descriptions) { append(null, AvailablePluginsManagerMain.MANAGE_REPOSITORIES, description.getOption(), configurableElement); } + } else if (configurable instanceof AllFileTemplatesConfigurable) { + processFileTemplates(configurableElement); } root.addContent(configurableElement); configurable.disposeUIResources(); @@ -118,13 +122,39 @@ public class TraverseUIStarter implements ApplicationStarter { ((ApplicationEx)ApplicationManager.getApplication()).exit(true); } + private static void processFileTemplates(Element configurableElement) { + final SearchableOptionsRegistrar optionsRegistrar = SearchableOptionsRegistrar.getInstance(); + TreeSet options = new TreeSet(); + + processTemplates(optionsRegistrar, options, FileTemplateManager.getInstance().getAllTemplates()); + processTemplates(optionsRegistrar, options, FileTemplateManager.getInstance().getAllPatterns()); + processTemplates(optionsRegistrar, options, FileTemplateManager.getInstance().getAllCodeTemplates()); + processTemplates(optionsRegistrar, options, FileTemplateManager.getInstance().getAllJ2eeTemplates()); + + writeOptions(configurableElement, options); + } + + private static void processTemplates(SearchableOptionsRegistrar optionsRegistrar, + TreeSet options, + FileTemplate[] templates) { + for (FileTemplate template : templates) { + collectOptions(optionsRegistrar, options, template.getName()); + //collectOptions(optionsRegistrar, options, template.getDescription()); + } + } + + private static void collectOptions(SearchableOptionsRegistrar optionsRegistrar, TreeSet options, String text) { + final Set strings = optionsRegistrar.getProcessedWordsWithoutStemming(text); + for (String word : strings) { + options.add(new OptionDescription(word, text, null)); + } + } + private static void processOptionsContainingConfigurable(final OptionsContainingConfigurable configurable, final Element configurableElement) { final Set optionsPath = configurable.processListOptions(); final TreeSet result = wordsToOptionDescriptors(optionsPath); - for (OptionDescription option : result) { - append(option.getPath(), option.getHit(), option.getOption(), configurableElement); - } + writeOptions(configurableElement, result); } private static TreeSet wordsToOptionDescriptors(Set optionsPath) { @@ -150,24 +180,22 @@ public class TraverseUIStarter implements ApplicationStarter { final AnAction anAction = actionManager.getAction(id); final String text = anAction.getTemplatePresentation().getText(); if (text != null) { - final Set strings = searchableOptionsRegistrar.getProcessedWordsWithoutStemming(text); - for (String word : strings) { - options.add(new OptionDescription(word, text, null)); - } + collectOptions(searchableOptionsRegistrar, options, text); } final String description = anAction.getTemplatePresentation().getDescription(); if (description != null) { - final Set strings = searchableOptionsRegistrar.getProcessedWordsWithoutStemming(description); - for (String word : strings) { - options.add(new OptionDescription(word, description, null)); - } + collectOptions(searchableOptionsRegistrar, options, description); } } + writeOptions(configurableElement, options); + } + + private static void writeOptions(Element configurableElement, TreeSet options) { for (OptionDescription opt : options) { append(opt.getPath(), opt.getHit(), opt.getOption(), configurableElement); } } - + private static void append(String path, String hit, final String word, final Element configurableElement) { Element optionElement = new Element(OPTION); optionElement.setAttribute(NAME, word); From 369771bc855b94cbbf16427bb49fc56ddb005a31 Mon Sep 17 00:00:00 2001 From: Oleg Sukhodolsky Date: Thu, 14 Jun 2012 12:12:54 +0400 Subject: [PATCH 140/172] RUBY-11320: ERB_RAW_EXPRESSION_START can also start ruby expression so we must filter out errors if next element is ERB_RAW_EXPRESSION_START #RUBY-11320 fixed --- .../highlighting/TemplateLanguageErrorFilter.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/TemplateLanguageErrorFilter.java b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/TemplateLanguageErrorFilter.java index c70ffd4f3576..3b58b7602ea1 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/TemplateLanguageErrorFilter.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/TemplateLanguageErrorFilter.java @@ -19,18 +19,23 @@ import com.intellij.lang.Language; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiErrorElement; -import com.intellij.psi.tree.IElementType; +import com.intellij.psi.tree.TokenSet; import org.jetbrains.annotations.NotNull; /** * @author Dennis.Ushakov */ public abstract class TemplateLanguageErrorFilter extends HighlightErrorFilter { - private final IElementType myTemplateExpressionStart; + @NotNull + private final TokenSet myTemplateExpressionStartTokens; + @NotNull private final Class myTemplateFileViewProviderClass; - protected TemplateLanguageErrorFilter(IElementType templateExpressionStart, Class templateFileViewProviderClass) { - myTemplateExpressionStart = templateExpressionStart; + protected TemplateLanguageErrorFilter( + final @NotNull TokenSet templateExpressionStartTokens, + final @NotNull Class templateFileViewProviderClass) + { + myTemplateExpressionStartTokens = TokenSet.create(templateExpressionStartTokens.getTypes()); myTemplateFileViewProviderClass = templateFileViewProviderClass; } @@ -45,7 +50,7 @@ public abstract class TemplateLanguageErrorFilter extends HighlightErrorFilter { final Language css = Language.findLanguageByID("CSS"); if (javaScript != null && parentLanguage.is(javaScript) || css != null && parentLanguage.is(css)) { final PsiElement next = viewProvider.findElementAt(element.getTextOffset() + 1, viewProvider.getBaseLanguage()); - if (next != null && next.getNode().getElementType() == myTemplateExpressionStart) { + if (next != null && myTemplateExpressionStartTokens.contains(next.getNode().getElementType())) { return false; } } From be37189c4604523a9c7e7e0ad147f58be36a0e9a Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Thu, 14 Jun 2012 13:27:21 +0400 Subject: [PATCH 141/172] IDEA-80408 android-dex: optimize option --- .../compiler/tools/AndroidDxRunner.java | 36 +++++++++++++++++-- .../AndroidDexCompilerConfiguration.java | 1 + ...ndroidDexCompilerSettingsConfigurable.form | 12 +++++-- .../AndroidDexCompilerSettingsFactory.java | 11 +++--- .../compiler/tools/AndroidDxWrapper.java | 10 +++--- 5 files changed, 58 insertions(+), 12 deletions(-) diff --git a/plugins/android/rt/src/org/jetbrains/android/compiler/tools/AndroidDxRunner.java b/plugins/android/rt/src/org/jetbrains/android/compiler/tools/AndroidDxRunner.java index 017d393d6aab..035643b98267 100644 --- a/plugins/android/rt/src/org/jetbrains/android/compiler/tools/AndroidDxRunner.java +++ b/plugins/android/rt/src/org/jetbrains/android/compiler/tools/AndroidDxRunner.java @@ -52,6 +52,7 @@ public class AndroidDxRunner { private static Field myJarOutputField; private static Field myFileNamesField; private static Field myStrictNameCheckField; + private static Field myOptimizeField; private static Field myConsoleOut; private static Field myConsoleErr; @@ -82,6 +83,8 @@ public class AndroidDxRunner { myVerboseField = argClass.getField("verbose"); myStrictNameCheckField = argClass.getField("strictNameCheck"); + myOptimizeField = getFieldIfPossible(argClass); + myConsoleOut = consoleClass.getField("out"); myConsoleErr = consoleClass.getField("err"); } @@ -102,7 +105,17 @@ public class AndroidDxRunner { } } - private static int runDex(String dxPath, String outFilePath, String[] fileNames) { + @Nullable + private static Field getFieldIfPossible(Class argClass) { + try { + return argClass.getField("optimize"); + } + catch (NoSuchFieldException e) { + return null; + } + } + + private static int runDex(String dxPath, String outFilePath, String[] fileNames, boolean optimize) { loadDex(dxPath); try { @@ -116,6 +129,13 @@ public class AndroidDxRunner { myVerboseField.set(args, false); myStrictNameCheckField.set(args, false); + if (myOptimizeField != null) { + myOptimizeField.set(args, optimize); + } + else { + reportWarning("Cannot find 'optimize' field. The option won't be passed to DEX"); + } + Object res = myMethod.invoke(null, args); if (res instanceof Integer) { @@ -203,8 +223,20 @@ public class AndroidDxRunner { Set files = new HashSet(); HashSet visited = new HashSet(); HashSet qNames = new HashSet(); + boolean optimize = true; int i = 2; + + while (i < args.length && args[i].startsWith("--")) { + if ("--optimize".equals(args[i])) { + i++; + if (i < args.length) { + optimize = Boolean.parseBoolean(args[i]); + } + } + i++; + } + while (i < args.length) { String arg = args[i]; if ("--exclude".equals(arg)) { @@ -226,7 +258,7 @@ public class AndroidDxRunner { files.removeAll(Arrays.asList(excludedFiles)); String[] filesArray = files.toArray(new String[files.size()]); //System.out.println("file names: " + concat(filesArray)); - runDex(dxPath, outFilePath, filesArray); + runDex(dxPath, outFilePath, filesArray, optimize); } private static String concat(String[] ar) { diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompilerConfiguration.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompilerConfiguration.java index 73af4e6d2b82..419e22f4d001 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompilerConfiguration.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompilerConfiguration.java @@ -32,6 +32,7 @@ import com.intellij.util.xmlb.XmlSerializerUtil; public class AndroidDexCompilerConfiguration implements PersistentStateComponent { public String VM_OPTIONS = ""; public int MAX_HEAP_SIZE = 1024; + public boolean OPTIMIZE = true; @Override public AndroidDexCompilerConfiguration getState() { diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompilerSettingsConfigurable.form b/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompilerSettingsConfigurable.form index 6e6e87d078fe..53097ee7e989 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompilerSettingsConfigurable.form +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompilerSettingsConfigurable.form @@ -1,6 +1,6 @@ - + @@ -24,7 +24,7 @@ - + @@ -49,6 +49,14 @@ + + + + + + + + diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompilerSettingsFactory.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompilerSettingsFactory.java index eb5c8c31b120..6502c7e87046 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompilerSettingsFactory.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompilerSettingsFactory.java @@ -21,6 +21,7 @@ import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.project.Project; import com.intellij.ui.RawCommandLineEditor; +import com.intellij.ui.components.JBCheckBox; import org.jetbrains.android.util.AndroidBundle; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; @@ -42,6 +43,7 @@ public class AndroidDexCompilerSettingsFactory implements CompilerSettingsFactor private JSpinner myHeapSizeSpinner; private JLabel myVmOptionsLabel; private RawCommandLineEditor myVmOptionsEditor; + private JBCheckBox myOptimizeCheckBox; public AndroidDexCompilerSettingsConfigurable(Project project) { myConfig = AndroidDexCompilerConfiguration.getInstance(project); @@ -68,22 +70,23 @@ public class AndroidDexCompilerSettingsFactory implements CompilerSettingsFactor @Override public boolean isModified() { int maxHeapSize = ((Integer)myHeapSizeSpinner.getValue()).intValue(); - if (maxHeapSize != myConfig.MAX_HEAP_SIZE) { - return true; - } - return !myVmOptionsEditor.getText().equals(myConfig.VM_OPTIONS); + return maxHeapSize != myConfig.MAX_HEAP_SIZE || + !myVmOptionsEditor.getText().equals(myConfig.VM_OPTIONS) || + myOptimizeCheckBox.isSelected() != myConfig.OPTIMIZE; } @Override public void apply() throws ConfigurationException { myConfig.MAX_HEAP_SIZE = ((Integer)myHeapSizeSpinner.getValue()).intValue(); myConfig.VM_OPTIONS = myVmOptionsEditor.getText(); + myConfig.OPTIMIZE = myOptimizeCheckBox.isSelected(); } @Override public void reset() { myHeapSizeSpinner.setModel(new SpinnerNumberModel(myConfig.MAX_HEAP_SIZE, 1, 10000000, 1)); myVmOptionsEditor.setText(myConfig.VM_OPTIONS); + myOptimizeCheckBox.setSelected(myConfig.OPTIMIZE); } @Override diff --git a/plugins/android/src/org/jetbrains/android/compiler/tools/AndroidDxWrapper.java b/plugins/android/src/org/jetbrains/android/compiler/tools/AndroidDxWrapper.java index 892ff18591ea..7267ac0f54bd 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/tools/AndroidDxWrapper.java +++ b/plugins/android/src/org/jetbrains/android/compiler/tools/AndroidDxWrapper.java @@ -51,9 +51,9 @@ public class AndroidDxWrapper { @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"}) public static Map> execute(@NotNull Module module, - @NotNull IAndroidTarget target, - @NotNull String outputDir, - @NotNull String[] compileTargets) { + @NotNull IAndroidTarget target, + @NotNull String outputDir, + @NotNull String[] compileTargets) { String outFile = outputDir + File.separatorChar + AndroidCommonUtils.CLASSES_FILE_NAME; final Map> messages = new HashMap>(2); @@ -79,15 +79,17 @@ public class AndroidDxWrapper { parameters.setJdk(sdk); parameters.setMainClass(AndroidDxRunner.class.getName()); + final AndroidDexCompilerConfiguration configuration = AndroidDexCompilerConfiguration.getInstance(module.getProject()); + ParametersList programParamList = parameters.getProgramParametersList(); programParamList.add(dxJarPath); programParamList.add(outFile); + programParamList.add("--optimize", Boolean.toString(configuration.OPTIMIZE)); programParamList.addAll(compileTargets); programParamList.add("--exclude"); ParametersList vmParamList = parameters.getVMParametersList(); - AndroidDexCompilerConfiguration configuration = AndroidDexCompilerConfiguration.getInstance(module.getProject()); String additionalVmParams = configuration.VM_OPTIONS; if (additionalVmParams.length() > 0) { vmParamList.addParametersString(additionalVmParams); From 112157af1dada4b4e5e874d4f8bff82fb5222138 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Thu, 14 Jun 2012 13:47:26 +0400 Subject: [PATCH 142/172] annotations in stacktraces --- .../execution/impl/ConsoleViewImpl.java | 6 +- .../unscramble/AnalyzeStacktraceUtil.java | 10 +- .../unscramble/AnnotateStackTraceAction.java | 232 ++++++++++++++++++ 3 files changed, 241 insertions(+), 7 deletions(-) create mode 100644 platform/lang-impl/src/com/intellij/unscramble/AnnotateStackTraceAction.java diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java index e87a6cf4d699..c61e184c4209 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java @@ -79,7 +79,6 @@ import gnu.trove.TIntObjectHashMap; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.TestOnly; import javax.swing.*; import java.awt.*; @@ -130,11 +129,14 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo private final Runnable myFinishProgress; private boolean myAllowHeavyFilters = false; - @TestOnly public Editor getEditor() { return myEditor; } + public EditorHyperlinkSupport getHyperlinks() { + return myHyperlinks; + } + public void scrollToEnd() { if (myEditor == null) return; myEditor.getCaretModel().moveToOffset(myEditor.getDocument().getTextLength()); diff --git a/platform/lang-impl/src/com/intellij/unscramble/AnalyzeStacktraceUtil.java b/platform/lang-impl/src/com/intellij/unscramble/AnalyzeStacktraceUtil.java index a094599f2c14..44648abcc385 100644 --- a/platform/lang-impl/src/com/intellij/unscramble/AnalyzeStacktraceUtil.java +++ b/platform/lang-impl/src/com/intellij/unscramble/AnalyzeStacktraceUtil.java @@ -19,9 +19,8 @@ package com.intellij.unscramble; import com.intellij.execution.ExecutionManager; import com.intellij.execution.Executor; import com.intellij.execution.executors.DefaultRunExecutor; -import com.intellij.execution.filters.Filter; -import com.intellij.execution.filters.TextConsoleBuilder; -import com.intellij.execution.filters.TextConsoleBuilderFactory; +import com.intellij.execution.filters.*; +import com.intellij.execution.impl.ConsoleViewImpl; import com.intellij.execution.ui.ConsoleView; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.execution.ui.ExecutionConsole; @@ -95,8 +94,8 @@ public class AnalyzeStacktraceUtil { for(Filter filter: Extensions.getExtensions(EP_NAME, project)) { builder.addFilter(filter); } - final ConsoleView consoleView = builder.getConsole(); + final DefaultActionGroup toolbarActions = new DefaultActionGroup(); JComponent consoleComponent = consoleFactory != null ? consoleFactory.createConsoleComponent(consoleView, toolbarActions) @@ -109,10 +108,11 @@ public class AnalyzeStacktraceUtil { }; final Executor executor = DefaultRunExecutor.getRunExecutorInstance(); - toolbarActions.add(new CloseAction(executor, descriptor, project)); for (AnAction action: consoleView.createConsoleActions()) { toolbarActions.add(action); } + toolbarActions.add(new AnnotateStackTraceAction((ConsoleViewImpl)consoleView)); + toolbarActions.add(new CloseAction(executor, descriptor, project)); ExecutionManager.getInstance(project).getContentManager().showRunContent(executor, descriptor); consoleView.allowHeavyFilters(); printStacktrace(consoleView, text); diff --git a/platform/lang-impl/src/com/intellij/unscramble/AnnotateStackTraceAction.java b/platform/lang-impl/src/com/intellij/unscramble/AnnotateStackTraceAction.java new file mode 100644 index 000000000000..00a18b3e0479 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/unscramble/AnnotateStackTraceAction.java @@ -0,0 +1,232 @@ +/* + * 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.unscramble; + +import com.intellij.execution.filters.FileHyperlinkInfo; +import com.intellij.execution.filters.HyperlinkInfo; +import com.intellij.execution.impl.ConsoleViewImpl; +import com.intellij.execution.impl.EditorHyperlinkSupport; +import com.intellij.icons.AllIcons; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.colors.ColorKey; +import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.colors.EditorFontType; +import com.intellij.openapi.editor.ex.EditorGutterComponentEx; +import com.intellij.openapi.editor.markup.RangeHighlighter; +import com.intellij.openapi.fileEditor.OpenFileDescriptor; +import com.intellij.openapi.progress.PerformInBackgroundOption; +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.progress.Task; +import com.intellij.openapi.vcs.AbstractVcs; +import com.intellij.openapi.vcs.FilePath; +import com.intellij.openapi.vcs.VcsException; +import com.intellij.openapi.vcs.actions.ActiveAnnotationGutter; +import com.intellij.openapi.vcs.actions.VcsContextFactory; +import com.intellij.openapi.vcs.annotate.AnnotationSource; +import com.intellij.openapi.vcs.history.VcsFileRevision; +import com.intellij.openapi.vcs.history.VcsHistoryProvider; +import com.intellij.openapi.vcs.history.VcsHistorySession; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.text.DateFormatUtil; +import com.intellij.vcsUtil.VcsUtil; +import org.jetbrains.annotations.NotNull; + +import java.awt.*; +import java.util.*; +import java.util.List; + +/** +* @author Konstantin Bulenkov +*/ +class AnnotateStackTraceAction extends AnAction { + private final EditorHyperlinkSupport myHyperlinks; + private Map cache; + private int newestLine = -1; + private int maxDateLength = 0; + private final Editor myEditor; + + AnnotateStackTraceAction(ConsoleViewImpl consoleView) { + super("Annotate", null, AllIcons.Actions.Annotate); + myHyperlinks = consoleView.getHyperlinks(); + myEditor = consoleView.getEditor(); + myEditor.getColorsScheme().setColor( + EditorColors.CARET_ROW_COLOR, EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.CARET_ROW_COLOR)); + } + + @Override + public void actionPerformed(AnActionEvent e) { + cache = new HashMap(); + + ProgressManager.getInstance().run( + new Task.Backgroundable(myEditor.getProject(), "Getting file history", true, PerformInBackgroundOption.ALWAYS_BACKGROUND) { + @Override + public boolean shouldStartInBackground() { + return true; + } + + @Override + public void onSuccess() { + } + + private void showGutter() { + myEditor.getGutter().registerTextAnnotation(new ActiveAnnotationGutter() { + @Override + public void doAction(int lineNum) { + } + + @Override + public Cursor getCursor(int lineNum) { + return Cursor.getDefaultCursor(); + } + + @Override + public String getLineText(int line, Editor editor) { + final VcsFileRevision revision = cache.get(line); + if (revision != null) { + return String.format("%"+maxDateLength+"s", DateFormatUtil.formatPrettyDate(revision.getRevisionDate())) + " " + revision.getAuthor(); + } + return ""; + } + + @Override + public String getToolTip(int line, Editor editor) { + final VcsFileRevision revision = cache.get(line); + if (revision != null) { + return "" + + revision.getAuthor() + + " " + + DateFormatUtil.formatDateTime(revision.getRevisionDate()) + + "
" + + revision.getCommitMessage() + + ""; + } + return null; + } + + @Override + public EditorFontType getStyle(int line, Editor editor) { + return line == newestLine ? EditorFontType.BOLD : EditorFontType.PLAIN; + } + + @Override + public ColorKey getColor(int line, Editor editor) { + return AnnotationSource.LOCAL.getColor(); + } + + @Override + public Color getBgColor(int line, Editor editor) { + return null; + } + + @Override + public List getPopupActions(int line, Editor editor) { + return Collections.emptyList(); + } + + @Override + public void gutterClosed() { + } + }); + } + + @Override + public void run(@NotNull ProgressIndicator indicator) { + Date newestDate = null; + HashMap> files2lines = new HashMap>(); + List files = new ArrayList(); + for (int line = 0; line < myEditor.getDocument().getLineCount(); line++) { + indicator.checkCanceled(); + final List links = myHyperlinks.findAllHyperlinksOnLine(line); + if (links.size() > 0) { + final HyperlinkInfo info = myHyperlinks.getHyperlinks().get(links.get(links.size() - 1)); + if (info instanceof FileHyperlinkInfo) { + final OpenFileDescriptor fileDescriptor = ((FileHyperlinkInfo)info).getDescriptor(); + if (fileDescriptor != null) { + final VirtualFile file = fileDescriptor.getFile(); + if (files2lines.containsKey(file)) { + files2lines.get(file).add(line); + } else { + final ArrayList lines = new ArrayList(); + lines.add(line); + files2lines.put(file, lines); + files.add(file); + } + } + } + } + } + + + for (VirtualFile file : files) { + indicator.checkCanceled(); + final AbstractVcs vcs = VcsUtil.getVcsFor(myEditor.getProject(), file); + FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(file); + if (vcs != null) { + try { + final VcsHistoryProvider provider = vcs.getVcsHistoryProvider(); + final VcsHistorySession session; + if (provider != null) { + session = provider.createSessionFor(filePath); + final List list; + if (session != null) { + list = session.getRevisionList(); + final List lines = files2lines.get(file); + if (list != null && !list.isEmpty()) { + final VcsFileRevision revision = list.get(0); + final Date date = revision.getRevisionDate(); + if (newestDate == null || date.after(newestDate)) { + newestDate = date; + newestLine = lines.get(0); + } + final int length = DateFormatUtil.formatPrettyDate(date).length(); + if (length > maxDateLength) { + maxDateLength = length; + } + for (Integer line : lines) { + cache.put(line, revision); + } + ApplicationManager.getApplication().invokeLater(new Runnable() { + public void run() { + if (cache.keySet().size() == 1) { + showGutter(); + } else { + ((EditorGutterComponentEx)myEditor.getGutter()).revalidateMarkup(); + } + } + }); + } + } + } + } + catch (VcsException ignored) { + } + } + + } + } + }); + } + + @Override + public void update(AnActionEvent e) { + e.getPresentation().setEnabled(cache == null); + } +} From 97ed06614a67e6c70e8fa41d79f604bb6a63c42e Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Thu, 14 Jun 2012 13:54:36 +0400 Subject: [PATCH 143/172] relaunch dex on make if its configuration is changed --- .../android/compiler/AndroidDexCompiler.java | 69 +++++++++++++++++-- .../compiler/tools/AndroidDxWrapper.java | 13 ++-- 2 files changed, 69 insertions(+), 13 deletions(-) diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompiler.java index a1b6abf4ab76..d4fcde7f0261 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidDexCompiler.java @@ -41,6 +41,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.DataInput; +import java.io.DataOutput; import java.io.IOException; import java.util.*; @@ -78,7 +79,7 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler { } public ValidityState createValidityState(DataInput in) throws IOException { - return new ClassesAndJarsValidityState(in); + return new MyValidityState(in); } public static VirtualFile getOutputDirectoryForDex(@NotNull Module module) { @@ -114,6 +115,9 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler { } public ProcessingItem[] compute() { + final AndroidDexCompilerConfiguration dexConfig = + AndroidDexCompilerConfiguration.getInstance(myContext.getProject()); + Module[] modules = ModuleManager.getInstance(myContext.getProject()).getModules(); List items = new ArrayList(); for (Module module : modules) { @@ -181,7 +185,8 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler { continue; } - items.add(new DexItem(module, dexOutputDir, platform.getTarget(), files)); + items.add(new DexItem(module, dexOutputDir, platform.getTarget(), files, dexConfig.VM_OPTIONS, dexConfig.MAX_HEAP_SIZE, + dexConfig.OPTIMIZE)); } } return items.toArray(new ProcessingItem[items.size()]); @@ -214,8 +219,9 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler { files[i++] = FileUtil.toSystemDependentName(file.getPath()); } - Map> messages = AndroidCompileUtil.toCompilerMessageCategoryKeys( - AndroidDxWrapper.execute(dexItem.myModule, dexItem.myAndroidTarget, outputDirPath, files)); + Map> messages = AndroidCompileUtil.toCompilerMessageCategoryKeys(AndroidDxWrapper.execute( + dexItem.myModule, dexItem.myAndroidTarget, outputDirPath, files, dexItem.myAdditionalVmParams, dexItem.myMaxHeapSize, + dexItem.myOptimize)); addMessages(messages, dexItem.myModule); if (messages.get(CompilerMessageCategory.ERROR).isEmpty()) { @@ -241,15 +247,24 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler { final VirtualFile myClassDir; final IAndroidTarget myAndroidTarget; final Collection myFiles; + final String myAdditionalVmParams; + final int myMaxHeapSize; + final boolean myOptimize; public DexItem(@NotNull Module module, @NotNull VirtualFile classDir, @NotNull IAndroidTarget target, - Collection files) { + Collection files, + @NotNull String additionalVmParams, + int maxHeapSize, + boolean optimize) { myModule = module; myClassDir = classDir; myAndroidTarget = target; myFiles = files; + myAdditionalVmParams = additionalVmParams; + myMaxHeapSize = maxHeapSize; + myOptimize = optimize; } @NotNull @@ -259,7 +274,49 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler { @Nullable public ValidityState getValidityState() { - return new ClassesAndJarsValidityState(myFiles); + return new MyValidityState(myFiles, myAdditionalVmParams, myMaxHeapSize, myOptimize); + } + } + + private static class MyValidityState extends ClassesAndJarsValidityState { + private final String myAdditionalVmParams; + private final int myMaxHeapSize; + private final boolean myOptimize; + + public MyValidityState(@NotNull Collection files, @NotNull String additionalVmParams, int maxHeapSize, boolean optimize) { + super(files); + myAdditionalVmParams = additionalVmParams; + myMaxHeapSize = maxHeapSize; + myOptimize = optimize; + } + + public MyValidityState(@NotNull DataInput in) throws IOException { + super(in); + myAdditionalVmParams = in.readUTF(); + myMaxHeapSize = in.readInt(); + myOptimize = in.readBoolean(); + } + + @Override + public void save(DataOutput out) throws IOException { + super.save(out); + out.writeUTF(myAdditionalVmParams); + out.writeInt(myMaxHeapSize); + out.writeBoolean(myOptimize); + } + + @Override + public boolean equalsTo(ValidityState otherState) { + if (!super.equalsTo(otherState)) { + return false; + } + if (!(otherState instanceof MyValidityState)) { + return false; + } + final MyValidityState state = (MyValidityState)otherState; + return state.myAdditionalVmParams.equals(myAdditionalVmParams) && + state.myMaxHeapSize == myMaxHeapSize && + state.myOptimize == myOptimize; } } } diff --git a/plugins/android/src/org/jetbrains/android/compiler/tools/AndroidDxWrapper.java b/plugins/android/src/org/jetbrains/android/compiler/tools/AndroidDxWrapper.java index 7267ac0f54bd..3456dac64a94 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/tools/AndroidDxWrapper.java +++ b/plugins/android/src/org/jetbrains/android/compiler/tools/AndroidDxWrapper.java @@ -29,7 +29,6 @@ import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.util.PathUtil; import com.intellij.util.PathsList; import com.intellij.util.containers.HashMap; -import org.jetbrains.android.compiler.AndroidDexCompilerConfiguration; import org.jetbrains.android.util.AndroidBundle; import org.jetbrains.android.util.AndroidCommonUtils; import org.jetbrains.android.util.AndroidCompilerMessageKind; @@ -53,7 +52,10 @@ public class AndroidDxWrapper { public static Map> execute(@NotNull Module module, @NotNull IAndroidTarget target, @NotNull String outputDir, - @NotNull String[] compileTargets) { + @NotNull String[] compileTargets, + @NotNull String additionalVmParams, + int maxHeapSize, + boolean optimize) { String outFile = outputDir + File.separatorChar + AndroidCommonUtils.CLASSES_FILE_NAME; final Map> messages = new HashMap>(2); @@ -79,23 +81,20 @@ public class AndroidDxWrapper { parameters.setJdk(sdk); parameters.setMainClass(AndroidDxRunner.class.getName()); - final AndroidDexCompilerConfiguration configuration = AndroidDexCompilerConfiguration.getInstance(module.getProject()); - ParametersList programParamList = parameters.getProgramParametersList(); programParamList.add(dxJarPath); programParamList.add(outFile); - programParamList.add("--optimize", Boolean.toString(configuration.OPTIMIZE)); + programParamList.add("--optimize", Boolean.toString(optimize)); programParamList.addAll(compileTargets); programParamList.add("--exclude"); ParametersList vmParamList = parameters.getVMParametersList(); - String additionalVmParams = configuration.VM_OPTIONS; if (additionalVmParams.length() > 0) { vmParamList.addParametersString(additionalVmParams); } if (!hasXmxParam(vmParamList)) { - vmParamList.add("-Xmx" + configuration.MAX_HEAP_SIZE + "M"); + vmParamList.add("-Xmx" + maxHeapSize + "M"); } final PathsList classPath = parameters.getClassPath(); classPath.add(PathUtil.getJarPathForClass(AndroidDxRunner.class)); From 9e78298af87b3fe1a4cb32bc541cf8f6f5419fb0 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 14 Jun 2012 13:38:35 +0400 Subject: [PATCH 144/172] support loaded local profiles with the same name as existing shared (IDEA-84956) --- .../ui/InspectionToolsConfigurable.java | 46 +++++++++++++------ 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionToolsConfigurable.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionToolsConfigurable.java index 5067129f78fb..fe306e537246 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionToolsConfigurable.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionToolsConfigurable.java @@ -27,7 +27,6 @@ import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; import com.intellij.codeInspection.ModifiableModel; import com.intellij.codeInspection.ex.InspectionProfileImpl; import com.intellij.codeInspection.ex.InspectionToolRegistrar; -import com.intellij.icons.AllIcons; import com.intellij.ui.ListCellRendererWrapper; import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.diagnostic.Logger; @@ -173,7 +172,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple profile.setLocal(true); profile.initInspectionTools(null); profile.setModified(true); - if (myPanels.get(profile.getName()) != null) { + if (getProfilePanel(profile) != null) { if (Messages.showOkCancelDialog(myWholePanel, "Profile with name \'" + profile.getName() + "\' already exists. Do you want to overwrite it?", "Warning", Messages.getInformationIcon()) != DialogWrapper.OK_EXIT_CODE) return; } addProfile((InspectionProfileImpl)profile.getModifiableModel()); @@ -247,7 +246,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple if (!myPanels.containsKey(modelName)) { ((DefaultComboBoxModel)myProfiles.getModel()).addElement(model); } - myPanels.put(modelName, panel); + putProfile(model, panel); myProfiles.setSelectedItem(model); } @@ -281,7 +280,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple public void customize(final JList list, final Profile value, final int index, final boolean selected, final boolean hasFocus) { final String profileName = value.getName(); setText(profileName); - final SingleInspectionProfilePanel panel = myPanels.get(profileName); + final SingleInspectionProfilePanel panel = getProfilePanel(value); setIcon(panel != null && panel.isProfileShared() ? Profile.PROJECT_PROFILE : Profile.LOCAL_PROFILE); } }); @@ -320,15 +319,36 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple } public void apply() throws ConfigurationException { - for (final Iterator it = myPanels.keySet().iterator(); it.hasNext();) { - final String name = it.next(); + final Map panels = new LinkedHashMap(); + for (final String name : myPanels.keySet()) { if (myDeletedProfiles.remove(name)) { deleteProfile(name); - it.remove(); - } else { - myPanels.get(name).apply(); + } + else { + final SingleInspectionProfilePanel panel = getProfilePanel(name); + panel.apply(); + final ModifiableModel profile = panel.getSelectedProfile(); + panels.put(getProfilePrefix(profile) + profile.getName(), panel); } } + myPanels.clear(); + myPanels.putAll(panels); + } + + private SingleInspectionProfilePanel getProfilePanel(String name) { + return myPanels.get(name); + } + + private SingleInspectionProfilePanel getProfilePanel(Profile inspectionProfile) { + return getProfilePanel(getProfilePrefix(inspectionProfile) + inspectionProfile.getName()); + } + + private void putProfile(Profile profile, SingleInspectionProfilePanel panel) { + myPanels.put(getProfilePrefix(profile) + profile.getName(), panel); + } + + private static String getProfilePrefix(Profile profile) { + return (profile.isLocal() ? "L" : "S"); } protected void deleteProfile(String name) { @@ -349,7 +369,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple model.addElement(profile); final String profileName = profile.getName(); final SingleInspectionProfilePanel panel = new SingleInspectionProfilePanel(myProjectProfileManager, profileName, ((InspectionProfileImpl)profile).getModifiableModel()); - myPanels.put(profileName, panel); + putProfile(profile, panel); myPanel.add(profileName, panel); } final InspectionProfileImpl inspectionProfile = getCurrentProfile(); @@ -426,7 +446,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple public void selectInspectionTool(String selectedToolShortName) { final InspectionProfileImpl inspectionProfile = getSelectedObject(); assert inspectionProfile != null : configuredProfiles(); - final SingleInspectionProfilePanel panel = myPanels.get(inspectionProfile.getName()); + final SingleInspectionProfilePanel panel = getProfilePanel(inspectionProfile); LOG.assertTrue(panel != null, "No settings panel for: " + inspectionProfile.getName() + "; " + configuredProfiles()); panel.selectInspectionTool(selectedToolShortName); } @@ -434,7 +454,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple protected SingleInspectionProfilePanel getSelectedPanel() { final InspectionProfileImpl inspectionProfile = getSelectedObject(); assert inspectionProfile != null : configuredProfiles(); - return myPanels.get(inspectionProfile.getName()); + return getProfilePanel(inspectionProfile); } private String configuredProfiles() { @@ -453,6 +473,6 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple public JComponent getPreferredFocusedComponent() { final InspectionProfileImpl inspectionProfile = getSelectedObject(); assert inspectionProfile != null : configuredProfiles(); - return myPanels.get(inspectionProfile.getName()).getTree(); + return getProfilePanel(inspectionProfile).getTree(); } } From e98378e08a6abd0f62e8cbf1f8ea162e8b5a3c63 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 14 Jun 2012 14:16:15 +0400 Subject: [PATCH 145/172] add hint to run tests from go-to-test popup (IDEA-84931) --- .../navigation/GotoTargetHandler.java | 5 +++++ .../GotoTestOrCodeHandler.java | 20 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/GotoTargetHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/GotoTargetHandler.java index 68f42ce81276..76e1d92784fe 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/GotoTargetHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/GotoTargetHandler.java @@ -176,6 +176,7 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler { return true; } }). + setAdText(getAdText(gotoData.source, targets.length)). createPopup(); if (gotoData.listUpdaterTask != null) { gotoData.listUpdaterTask.init((AbstractPopup)popup, list); @@ -237,6 +238,10 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler { protected abstract String getChooserTitle(PsiElement sourceElement, String name, int length); protected abstract String getNotFoundMessage(Project project, Editor editor, PsiFile file); + @Nullable + protected String getAdText(PsiElement source, int length) { + return null; + } public interface AdditionalAction { String getText(); diff --git a/platform/lang-impl/src/com/intellij/testIntegration/GotoTestOrCodeHandler.java b/platform/lang-impl/src/com/intellij/testIntegration/GotoTestOrCodeHandler.java index cdd9ec709d36..41ec65b1ce54 100644 --- a/platform/lang-impl/src/com/intellij/testIntegration/GotoTestOrCodeHandler.java +++ b/platform/lang-impl/src/com/intellij/testIntegration/GotoTestOrCodeHandler.java @@ -20,7 +20,12 @@ import com.intellij.codeInsight.CodeInsightBundle; import com.intellij.codeInsight.navigation.GotoTargetHandler; import com.intellij.codeInsight.navigation.NavigationUtil; import com.intellij.icons.AllIcons; +import com.intellij.openapi.actionSystem.IdeActions; +import com.intellij.openapi.actionSystem.Shortcut; import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.keymap.Keymap; +import com.intellij.openapi.keymap.KeymapManager; +import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.project.Project; import com.intellij.pom.Navigatable; import com.intellij.psi.PsiElement; @@ -75,7 +80,7 @@ public class GotoTestOrCodeHandler extends GotoTargetHandler { } } - return new GotoData(sourceElement, PsiUtilBase.toPsiElementArray(candidates), actions); + return new GotoData(sourceElement, PsiUtilCore.toPsiElementArray(candidates), actions); } @NotNull @@ -102,6 +107,19 @@ public class GotoTestOrCodeHandler extends GotoTargetHandler { return CodeInsightBundle.message("goto.test.notFound"); } + @Nullable + @Override + protected String getAdText(PsiElement source, int length) { + if (length > 0 && !TestFinderHelper.isTest(source)) { + final Keymap keymap = KeymapManager.getInstance().getActiveKeymap(); + final Shortcut[] shortcuts = keymap.getShortcuts(IdeActions.ACTION_DEFAULT_RUNNER); + if (shortcuts.length > 0) { + return ("Press " + KeymapUtil.getShortcutText(shortcuts[0]) + " to run selected tests"); + } + } + return null; + } + @Override protected void navigateToElement(Navigatable element) { if (element instanceof PsiElement) { From 312d4892c0392b38b665a29947b31a235391e075 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Thu, 14 Jun 2012 14:41:29 +0400 Subject: [PATCH 146/172] IDEA-87114 renaming @TupleConstructor class --- .../rename/RenameJavaClassProcessor.java | 6 ++++-- .../refactoring/rename/RenameTest.groovy | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaClassProcessor.java b/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaClassProcessor.java index 9069c92bf963..d98870a493f6 100644 --- a/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaClassProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaClassProcessor.java @@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Pair; import com.intellij.psi.*; +import com.intellij.psi.impl.light.LightElement; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.LocalSearchScope; import com.intellij.psi.search.SearchScope; @@ -134,10 +135,11 @@ public class RenameJavaClassProcessor extends RenamePsiElementProcessor { final PsiElement prototype = ((PsiMirrorElement)constructor).getPrototype(); if (prototype instanceof PsiNamedElement) { allRenames.put(prototype, newName); - continue; } } - allRenames.put(constructor, newName); + else if (!(constructor instanceof LightElement)) { + allRenames.put(constructor, newName); + } } } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/rename/RenameTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/rename/RenameTest.groovy index 7fc6d22388a5..c4e6352a9a4c 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/rename/RenameTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/rename/RenameTest.groovy @@ -573,4 +573,23 @@ class Java { } } + + void testTupleConstructor() { + myFixture.with { + configureByText('a.groovy', '''\ +import groovy.transform.TupleConstructor + +@TupleConstructor +class Xx {} +''') + + renameElementAtCaret('Yy') + checkResult("""\ +import groovy.transform.TupleConstructor + +@TupleConstructor +class Yy {} +""") + } + } } From 64ecf416c4cde8f4ba661141520b27064167d920 Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Thu, 14 Jun 2012 14:55:01 +0400 Subject: [PATCH 147/172] Palette --- .../AndroidDesignerEditorPanel.java | 27 ++- .../ui-designer-new/src/META-INF/plugin.xml | 3 + .../designer/AbstractToolWindowManager.java | 134 +++++++++++++ .../designer/DesignerToolWindowManager.java | 135 +++---------- .../designSurface/DesignerEditorPanel.java | 11 ++ .../com/intellij/designer/palette/Group.java | 1 - .../com/intellij/designer/palette/Item.java | 7 +- .../designer/palette2/PaletteContainer.java | 119 ++++++++++++ .../designer/palette2/PaletteGroup.java | 43 +++++ .../palette2/PaletteGroupComponent.java | 148 +++++++++++++++ .../designer/palette2/PaletteItem.java | 29 +++ .../palette2/PaletteItemsComponent.java | 177 ++++++++++++++++++ .../designer/palette2/PalettePanel.java | 69 +++++++ .../palette2/PaletteToolWindowManager.java | 84 +++++++++ 14 files changed, 870 insertions(+), 117 deletions(-) create mode 100644 plugins/ui-designer/ui-designer-new/src/com/intellij/designer/AbstractToolWindowManager.java create mode 100644 plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteContainer.java create mode 100644 plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteGroup.java create mode 100644 plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteGroupComponent.java create mode 100644 plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteItem.java create mode 100644 plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteItemsComponent.java create mode 100644 plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PalettePanel.java create mode 100644 plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteToolWindowManager.java diff --git a/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java b/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java index dd22f60250d4..6acfa7bb3cde 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java +++ b/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java @@ -21,10 +21,7 @@ import com.android.sdklib.IAndroidTarget; import com.intellij.android.designer.actions.ProfileAction; import com.intellij.android.designer.componentTree.AndroidTreeDecorator; import com.intellij.android.designer.inspection.ErrorAnalyzer; -import com.intellij.android.designer.model.IConfigurableComponent; -import com.intellij.android.designer.model.ModelParser; -import com.intellij.android.designer.model.PropertyParser; -import com.intellij.android.designer.model.RadViewComponent; +import com.intellij.android.designer.model.*; import com.intellij.android.designer.profile.ProfileManager; import com.intellij.designer.DesignerToolWindowManager; import com.intellij.designer.componentTree.TreeComponentDecorator; @@ -35,8 +32,11 @@ import com.intellij.designer.designSurface.OperationContext; import com.intellij.designer.designSurface.selection.NonResizeSelectionDecorator; import com.intellij.designer.designSurface.tools.ComponentCreationFactory; import com.intellij.designer.designSurface.tools.ComponentPasteFactory; +import com.intellij.designer.model.MetaManager; import com.intellij.designer.model.RadComponent; import com.intellij.designer.palette.Item; +import com.intellij.designer.palette2.PaletteGroup; +import com.intellij.ide.palette.PaletteItem; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ex.ApplicationManagerEx; import com.intellij.openapi.module.Module; @@ -62,6 +62,7 @@ import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.*; +import java.util.ArrayList; import java.util.List; /** @@ -445,6 +446,24 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel { return null; } + private List myPaletteGroups; + + @Override + public List getPaletteGroups() { + if (myPaletteGroups == null) { + myPaletteGroups = new ArrayList(); + MetaManager metaManager = ViewsMetaManager.getInstance(getProject()); + for (com.intellij.ide.palette.PaletteGroup group : metaManager.getPaletteGroups()) { + PaletteGroup newGroup = new PaletteGroup(group.getName()); + for (PaletteItem item : group.getItems()) { + newGroup.addItem((com.intellij.designer.palette2.PaletteItem)item); + } + myPaletteGroups.add(newGroup); + } + } + return myPaletteGroups; + } + @Override @NotNull protected ComponentCreationFactory createCreationFactory(final Item paletteItem) { diff --git a/plugins/ui-designer/ui-designer-new/src/META-INF/plugin.xml b/plugins/ui-designer/ui-designer-new/src/META-INF/plugin.xml index d73517d191ee..95581745aef9 100644 --- a/plugins/ui-designer/ui-designer-new/src/META-INF/plugin.xml +++ b/plugins/ui-designer/ui-designer-new/src/META-INF/plugin.xml @@ -12,6 +12,9 @@ com.intellij.designer.DesignerToolWindowManager + diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/AbstractToolWindowManager.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/AbstractToolWindowManager.java new file mode 100644 index 000000000000..a19b516689eb --- /dev/null +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/AbstractToolWindowManager.java @@ -0,0 +1,134 @@ +/* + * 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.designer; + +import com.intellij.designer.designSurface.DesignerEditorPanel; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.components.ProjectComponent; +import com.intellij.openapi.fileEditor.FileEditor; +import com.intellij.openapi.fileEditor.FileEditorManager; +import com.intellij.openapi.fileEditor.FileEditorManagerEvent; +import com.intellij.openapi.fileEditor.FileEditorManagerListener; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.startup.StartupManager; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.wm.ToolWindow; +import com.intellij.util.ui.update.MergingUpdateQueue; +import com.intellij.util.ui.update.Update; +import org.jetbrains.annotations.Nullable; + +/** + * @author Alexander Lobas + */ +public abstract class AbstractToolWindowManager implements ProjectComponent { + private final MergingUpdateQueue myWindowQueue = new MergingUpdateQueue(getComponentName(), 200, true, null); + protected final Project myProject; + protected final FileEditorManager myFileEditorManager; + protected ToolWindow myToolWindow; + private boolean myToolWindowReady; + private boolean myToolWindowDisposed; + + public AbstractToolWindowManager(Project project, FileEditorManager fileEditorManager) { + myProject = project; + myFileEditorManager = fileEditorManager; + project.getMessageBus().connect(project).subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() { + @Override + public void fileOpened(FileEditorManager source, VirtualFile file) { + bindToDesigner(getActiveDesigner()); + } + + @Override + public void fileClosed(FileEditorManager source, VirtualFile file) { + ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override + public void run() { + bindToDesigner(getActiveDesigner()); + } + }); + } + + @Override + public void selectionChanged(FileEditorManagerEvent event) { + bindToDesigner(getDesigner(event.getNewEditor())); + } + }); + } + + @Override + public void projectOpened() { + StartupManager.getInstance(myProject).registerPostStartupActivity(new Runnable() { + public void run() { + myToolWindowReady = true; + } + }); + } + + @Override + public void projectClosed() { + if (!myToolWindowDisposed) { + disposeComponent(); + myToolWindowDisposed = true; + myToolWindow = null; + } + } + + @Nullable + private static DesignerEditorPanel getDesigner(FileEditor editor) { + if (editor instanceof DesignerEditor) { + DesignerEditor designerEditor = (DesignerEditor)editor; + return designerEditor.getDesignerPanel(); + } + return null; + } + + @Nullable + public DesignerEditorPanel getActiveDesigner() { + FileEditor[] editors = myFileEditorManager.getSelectedEditors(); + // TODO: check all editors instead first + return editors.length > 0 ? getDesigner(editors[0]) : null; + } + + private void bindToDesigner(final DesignerEditorPanel designer) { + myWindowQueue.cancelAllUpdates(); + myWindowQueue.queue(new Update("update") { + @Override + public void run() { + if (!myToolWindowReady || myToolWindowDisposed) { + return; + } + if (myToolWindow == null) { + if (designer == null) { + return; + } + initToolWindow(); + } + updateToolWindow(designer); + } + }); + } + + protected abstract void initToolWindow(); + + protected abstract void updateToolWindow(@Nullable DesignerEditorPanel designer); + + @Override + public void initComponent() { + } + + @Override + public void disposeComponent() { + } +} \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/DesignerToolWindowManager.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/DesignerToolWindowManager.java index ac15746f593f..623e3b8a84be 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/DesignerToolWindowManager.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/DesignerToolWindowManager.java @@ -22,19 +22,11 @@ import com.intellij.designer.propertyTable.PropertyTablePanel; import com.intellij.icons.AllIcons; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.components.ProjectComponent; -import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.fileEditor.FileEditorManager; -import com.intellij.openapi.fileEditor.FileEditorManagerEvent; -import com.intellij.openapi.fileEditor.FileEditorManagerListener; import com.intellij.openapi.project.Project; -import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.IconLoader; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowAnchor; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.openapi.wm.ex.ToolWindowEx; @@ -44,8 +36,6 @@ import com.intellij.ui.SideBorder; import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentManager; import com.intellij.util.ui.tree.TreeUtil; -import com.intellij.util.ui.update.MergingUpdateQueue; -import com.intellij.util.ui.update.Update; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -58,62 +48,22 @@ import java.awt.event.ComponentEvent; /** * @author Alexander Lobas */ -public final class DesignerToolWindowManager implements ProjectComponent { - private final MergingUpdateQueue myWindowQueue = new MergingUpdateQueue("designer.components.properties", 200, true, null); - private final Project myProject; - private final FileEditorManager myFileEditorManager; - private ToolWindow myToolWindow; +public final class DesignerToolWindowManager extends AbstractToolWindowManager { private Splitter myToolWindowPanel; private ComponentTree myComponentTree; private ComponentTreeBuilder myTreeBuilder; private PropertyTablePanel myPropertyTablePanel; - private boolean myToolWindowReady; - private boolean myToolWindowDisposed; public DesignerToolWindowManager(Project project, FileEditorManager fileEditorManager) { - myProject = project; - myFileEditorManager = fileEditorManager; - project.getMessageBus().connect(project).subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() { - @Override - public void fileOpened(FileEditorManager source, VirtualFile file) { - bindToDesigner(getActiveDesigner()); - } - - @Override - public void fileClosed(FileEditorManager source, VirtualFile file) { - ApplicationManager.getApplication().invokeLater(new Runnable() { - @Override - public void run() { - bindToDesigner(getActiveDesigner()); - } - }); - } - - @Override - public void selectionChanged(FileEditorManagerEvent event) { - bindToDesigner(getDesigner(event.getNewEditor())); - } - }); + super(project, fileEditorManager); } - @Override - public void projectOpened() { - StartupManager.getInstance(myProject).registerPostStartupActivity(new Runnable() { - public void run() { - myToolWindowReady = true; - } - }); - } @Override - public void projectClosed() { - if (!myToolWindowDisposed) { - myToolWindowDisposed = true; - clearTreeBuilder(); - myComponentTree = null; - myPropertyTablePanel = null; - myToolWindow = null; - } + public void disposeComponent() { + clearTreeBuilder(); + myComponentTree = null; + myPropertyTablePanel = null; } private void clearTreeBuilder() { @@ -153,55 +103,26 @@ public final class DesignerToolWindowManager implements ProjectComponent { } } - @Nullable - private static DesignerEditorPanel getDesigner(FileEditor editor) { - if (editor instanceof DesignerEditor) { - DesignerEditor designerEditor = (DesignerEditor)editor; - return designerEditor.getDesignerPanel(); + @Override + protected void updateToolWindow(@Nullable DesignerEditorPanel designer) { + clearTreeBuilder(); + myComponentTree.newModel(); + if (designer == null) { + myComponentTree.setDesignerPanel(null); + myPropertyTablePanel.getPropertyTable().setArea(null, null); + myToolWindow.setAvailable(false, null); + } + else { + myComponentTree.setDesignerPanel(designer); + myTreeBuilder = new ComponentTreeBuilder(myComponentTree, designer); + myPropertyTablePanel.getPropertyTable().setArea(designer, myTreeBuilder.getTreeArea()); + myToolWindow.setAvailable(true, null); + myToolWindow.show(null); } - return null; } - @Nullable - public DesignerEditorPanel getActiveDesigner() { - FileEditor[] editors = myFileEditorManager.getSelectedEditors(); - // TODO: check all editors instead first - return editors.length > 0 ? getDesigner(editors[0]) : null; - } - - private void bindToDesigner(final DesignerEditorPanel designer) { - myWindowQueue.cancelAllUpdates(); - myWindowQueue.queue(new Update("update") { - @Override - public void run() { - if (!myToolWindowReady || myToolWindowDisposed) { - return; - } - if (myToolWindow == null) { - if (designer == null) { - return; - } - initToolWindow(); - } - clearTreeBuilder(); - myComponentTree.newModel(); - if (designer == null) { - myComponentTree.setDesignerPanel(null); - myPropertyTablePanel.getPropertyTable().setArea(null, null); - myToolWindow.setAvailable(false, null); - } - else { - myComponentTree.setDesignerPanel(designer); - myTreeBuilder = new ComponentTreeBuilder(myComponentTree, designer); - myPropertyTablePanel.getPropertyTable().setArea(designer, myTreeBuilder.getTreeArea()); - myToolWindow.setAvailable(true, null); - myToolWindow.show(null); - } - } - }); - } - - private void initToolWindow() { + @Override + protected void initToolWindow() { myComponentTree = new ComponentTree(); JScrollPane treeScrollPane = ScrollPaneFactory.createScrollPane(myComponentTree); treeScrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); @@ -263,18 +184,10 @@ public final class DesignerToolWindowManager implements ProjectComponent { return new AnAction[]{expandAll, collapseAll}; } - @Override - public void initComponent() { - } - - @Override - public void disposeComponent() { - } - @NotNull @NonNls @Override public String getComponentName() { return "UIDesignerToolWindowManager2"; } -} +} \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java index 8921c51e02ec..963c35edd47d 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java @@ -24,6 +24,8 @@ import com.intellij.designer.designSurface.tools.*; import com.intellij.designer.model.FindComponentVisitor; import com.intellij.designer.model.RadComponent; import com.intellij.designer.palette.Item; +import com.intellij.designer.palette2.PaletteGroup; +import com.intellij.designer.palette2.PaletteItem; import com.intellij.designer.propertyTable.InplaceContext; import com.intellij.designer.propertyTable.Property; import com.intellij.diagnostic.LogMessageEx; @@ -336,6 +338,10 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider mySurfaceArea.addSelectionListener(mySourceSelectionListener); } + public void activatePaletteItem(@Nullable PaletteItem item) { + // XXX + } + protected final void showDesignerCard() { myErrorMessages.removeAll(); myErrorStack.setText(null); @@ -691,6 +697,11 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider protected abstract void execute(List operations); + public List getPaletteGroups() { + // XXX + return null; + } + @NotNull protected abstract ComponentCreationFactory createCreationFactory(Item paletteItem); diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette/Group.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette/Group.java index 23905efe5ad2..d3b2f46332fa 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette/Group.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette/Group.java @@ -18,7 +18,6 @@ package com.intellij.designer.palette; import com.intellij.ide.palette.PaletteGroup; import com.intellij.ide.palette.PaletteItem; import com.intellij.openapi.actionSystem.ActionGroup; -import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette/Item.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette/Item.java index 3794bb28fb49..f2e65797b783 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette/Item.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette/Item.java @@ -29,7 +29,7 @@ import javax.swing.*; /** * @author Alexander Lobas */ -public final class Item implements PaletteItem { +public final class Item implements PaletteItem, com.intellij.designer.palette2.PaletteItem { private String myTitle; private String myIconPath; private Icon myIcon; @@ -54,6 +54,11 @@ public final class Item implements PaletteItem { return myIcon; } + @Override + public String getTooltip() { + return myTooltip; + } + @Override public void customizeCellRenderer(ColoredListCellRenderer cellRenderer, boolean selected, boolean hasFocus) { cellRenderer.setIcon(getIcon()); diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteContainer.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteContainer.java new file mode 100644 index 000000000000..27c19709ed79 --- /dev/null +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteContainer.java @@ -0,0 +1,119 @@ +/* + * 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.designer.palette2; + +import javax.swing.*; +import java.awt.*; + +/** + * @author Alexander Lobas + */ +public class PaletteContainer extends JPanel implements Scrollable { + public PaletteContainer() { + super(new PaletteContainerLayout()); + } + + @Override + public Dimension getPreferredScrollableViewportSize() { + return getPreferredSize(); + } + + @Override + public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { + return 20; + } + + @Override + public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { + return 100; + } + + @Override + public boolean getScrollableTracksViewportWidth() { + return true; + } + + @Override + public boolean getScrollableTracksViewportHeight() { + return false; + } + + ////////////////////////////////////////////////////////////////////////////////////////// + // + // + // + ////////////////////////////////////////////////////////////////////////////////////////// + + private static class PaletteContainerLayout implements LayoutManager { + @Override + public void layoutContainer(Container parent) { + int width = parent.getWidth(); + int height = 0; + + for (Component component : parent.getComponents()) { + if (component instanceof PaletteGroupComponent) { + PaletteGroupComponent groupComponent = (PaletteGroupComponent)component; + groupComponent.setLocation(0, height); + if (groupComponent.isVisible()) { + int groupHeight = groupComponent.getPreferredSize().height; + groupComponent.setSize(width, groupHeight); + height += groupHeight; + } + else { + groupComponent.setSize(0, 0); + } + if (groupComponent.isSelected() || !groupComponent.isVisible()) { + PaletteItemsComponent itemsComponent = groupComponent.getItemsComponent(); + int itemsHeight = itemsComponent.getPreferredSize().height; + itemsComponent.setBounds(0, height, width, itemsHeight); + height += itemsHeight; + } + } + } + } + + @Override + public Dimension preferredLayoutSize(Container parent) { + int width = parent.getWidth(); + int height = 0; + + for (Component component : parent.getComponents()) { + if (component instanceof PaletteGroupComponent) { + PaletteGroupComponent groupComponent = (PaletteGroupComponent)component; + height += groupComponent.getHeight(); + if (groupComponent.isSelected()) { + height += groupComponent.getItemsComponent().getPreferredHeight(width); + } + } + } + + return new Dimension(10, height); + } + + @Override + public Dimension minimumLayoutSize(Container parent) { + return new Dimension(); + } + + @Override + public void addLayoutComponent(String name, Component comp) { + } + + @Override + public void removeLayoutComponent(Component comp) { + } + } +} \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteGroup.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteGroup.java new file mode 100644 index 000000000000..544e841edd6b --- /dev/null +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteGroup.java @@ -0,0 +1,43 @@ +/* + * 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.designer.palette2; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Alexander Lobas + */ +public class PaletteGroup { + private final String myName; + protected final List myItems = new ArrayList(); + + public PaletteGroup(String name) { + myName = name; + } + + public void addItem(PaletteItem item) { + myItems.add(item); + } + + public List getItems() { + return myItems; + } + + public String getName() { + return myName; + } +} \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteGroupComponent.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteGroupComponent.java new file mode 100644 index 000000000000..277b982d37d0 --- /dev/null +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteGroupComponent.java @@ -0,0 +1,148 @@ +/* + * 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.designer.palette2; + +import com.intellij.icons.AllIcons; +import com.intellij.util.ui.UIUtil; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; + +/** + * @author Alexander Lobas + */ +public class PaletteGroupComponent extends JCheckBox { + private final PaletteGroup myGroup; + private PaletteItemsComponent myItemsComponent; + + public PaletteGroupComponent(PaletteGroup group) { + myGroup = group; + + setText(group.getName()); + setSelected(true); + setIcon(AllIcons.Nodes.TreeClosed); + setSelectedIcon(AllIcons.Nodes.TreeOpen); + setFont(getFont().deriveFont(Font.BOLD)); + setFocusPainted(false); + setMargin(new Insets(0, 3, 0, 3)); + + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + myItemsComponent.setVisible(isSelected()); + } + }); + + initActions(); + } + + @Override + public Color getBackground() { + if (isFocusOwner()) { + return UIUtil.getListSelectionBackground(); + } + return super.getBackground(); + } + + @Override + public Color getForeground() { + if (isFocusOwner()) { + return UIUtil.getListSelectionForeground(); + } + return super.getForeground(); + } + + public PaletteItemsComponent getItemsComponent() { + return myItemsComponent; + } + + public void setItemsComponent(PaletteItemsComponent itemsComponent) { + myItemsComponent = itemsComponent; + } + + ////////////////////////////////////////////////////////////////////////////////////////// + // + // + // + ////////////////////////////////////////////////////////////////////////////////////////// + + private void initActions() { + InputMap inputMap = getInputMap(WHEN_FOCUSED); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0, false), "moveFocusDown"); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0, false), "moveFocusUp"); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0, false), "collapse"); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0, false), "expand"); + + ActionMap actionMap = getActionMap(); + actionMap.put("moveFocusDown", new MoveFocusAction(true)); + actionMap.put("moveFocusUp", new MoveFocusAction(false)); + actionMap.put("collapse", new ExpandAction(false)); + actionMap.put("expand", new ExpandAction(true)); + } + + private class MoveFocusAction extends AbstractAction { + private final boolean myMoveDown; + + public MoveFocusAction(boolean moveDown) { + myMoveDown = moveDown; + } + + public void actionPerformed(ActionEvent e) { + KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); + Container container = kfm.getCurrentFocusCycleRoot(); + FocusTraversalPolicy policy = container.getFocusTraversalPolicy(); + if (policy == null) { + policy = kfm.getDefaultFocusTraversalPolicy(); + } + + Component next = myMoveDown + ? policy.getComponentAfter(container, PaletteGroupComponent.this) + : policy.getComponentBefore(container, PaletteGroupComponent.this); + if (next instanceof PaletteItemsComponent) { + PaletteItemsComponent list = (PaletteItemsComponent)next; + if (list.getModel().getSize() != 0) { + list.takeFocusFrom(list == myItemsComponent ? 0 : -1); + return; + } + else { + next = myMoveDown ? policy.getComponentAfter(container, next) : policy.getComponentBefore(container, next); + } + } + if (next instanceof PaletteGroupComponent) { + next.requestFocus(); + } + } + } + + private class ExpandAction extends AbstractAction { + private final boolean myExpand; + + public ExpandAction(boolean expand) { + myExpand = expand; + } + + public void actionPerformed(ActionEvent e) { + if (myExpand != isSelected()) { + setSelected(myExpand); + if (myItemsComponent != null) { + myItemsComponent.setVisible(isSelected()); + } + } + } + } +} \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteItem.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteItem.java new file mode 100644 index 000000000000..08c38da4aa81 --- /dev/null +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteItem.java @@ -0,0 +1,29 @@ +/* + * 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.designer.palette2; + +import javax.swing.*; + +/** + * @author Alexander Lobas + */ +public interface PaletteItem { + String getTitle(); + + Icon getIcon(); + + String getTooltip(); +} \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteItemsComponent.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteItemsComponent.java new file mode 100644 index 000000000000..1c290a2ff5bf --- /dev/null +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteItemsComponent.java @@ -0,0 +1,177 @@ +/* + * 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.designer.palette2; + +import com.intellij.ui.ColoredListCellRenderer; +import com.intellij.ui.SimpleTextAttributes; +import com.intellij.ui.components.JBList; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; + +/** + * @author Alexander Lobas + */ +public class PaletteItemsComponent extends JBList { + private final PaletteGroup myGroup; + + public PaletteItemsComponent(PaletteGroup group) { + myGroup = group; + + setModel(new AbstractListModel() { + @Override + public int getSize() { + return myGroup.getItems().size(); + } + + @Override + public Object getElementAt(int index) { + return myGroup.getItems().get(index); + } + }); + setCellRenderer(new ColoredListCellRenderer() { + @Override + protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { + clear(); + PaletteItem item = (PaletteItem)value; + setIcon(item.getIcon()); + append(item.getTitle(), SimpleTextAttributes.REGULAR_ATTRIBUTES); + setToolTipText(item.getTooltip()); + } + }); + + setVisibleRowCount(0); + setLayoutOrientation(HORIZONTAL_WRAP); + setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + initActions(); + } + + Integer myTempWidth; + + public int getWidth() { + return (myTempWidth == null) ? super.getWidth() : myTempWidth.intValue(); + } + + public int getPreferredHeight(int width) { + myTempWidth = width; + try { + return getUI().getPreferredSize(this).height; + } + finally { + myTempWidth = null; + } + } + + public void takeFocusFrom(int indexToSelect) { + if (indexToSelect == -1) { + indexToSelect = getModel().getSize() - 1; + } + else if (getModel().getSize() == 0) { + indexToSelect = -1; + } + requestFocus(); + setSelectedIndex(indexToSelect); + if (indexToSelect >= 0) { + ensureIndexIsVisible(indexToSelect); + } + } + + ////////////////////////////////////////////////////////////////////////////////////////// + // + // + // + ////////////////////////////////////////////////////////////////////////////////////////// + + private void initActions() { + ActionMap map = getActionMap(); + map.put("selectPreviousRow", new MoveFocusAction(map.get("selectPreviousRow"), false)); + map.put("selectNextRow", new MoveFocusAction(map.get("selectNextRow"), true)); + map.put("selectPreviousColumn", new MoveFocusAction(new ChangeColumnAction(map.get("selectPreviousColumn"), false), false)); + map.put("selectNextColumn", new MoveFocusAction(new ChangeColumnAction(map.get("selectNextColumn"), true), true)); + } + + private class MoveFocusAction extends AbstractAction { + private final Action myDefaultAction; + private final boolean myFocusNext; + + public MoveFocusAction(Action defaultAction, boolean focusNext) { + myDefaultAction = defaultAction; + myFocusNext = focusNext; + } + + public void actionPerformed(ActionEvent e) { + int selIndexBefore = getSelectedIndex(); + myDefaultAction.actionPerformed(e); + int selIndexCurrent = getSelectedIndex(); + if (selIndexBefore != selIndexCurrent) { + return; + } + if (myFocusNext && selIndexCurrent == 0) { + return; + } + + KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); + Container container = kfm.getCurrentFocusCycleRoot(); + FocusTraversalPolicy policy = container.getFocusTraversalPolicy(); + if (policy == null) { + policy = kfm.getDefaultFocusTraversalPolicy(); + } + Component next = myFocusNext + ? policy.getComponentAfter(container, PaletteItemsComponent.this) + : policy.getComponentBefore(container, PaletteItemsComponent.this); + if (next instanceof PaletteGroupComponent) { + clearSelection(); + next.requestFocus(); + ((PaletteGroupComponent)next).scrollRectToVisible(next.getBounds()); + } + } + } + + private class ChangeColumnAction extends AbstractAction { + private final Action myDefaultAction; + private final boolean mySelectNext; + + public ChangeColumnAction(Action defaultAction, boolean selectNext) { + myDefaultAction = defaultAction; + mySelectNext = selectNext; + } + + public void actionPerformed(ActionEvent e) { + int selIndexBefore = getSelectedIndex(); + myDefaultAction.actionPerformed(e); + int selIndexCurrent = getSelectedIndex(); + if (mySelectNext && selIndexBefore < selIndexCurrent || !mySelectNext && selIndexBefore > selIndexCurrent) { + return; + } + + if (mySelectNext) { + if (selIndexCurrent == selIndexBefore + 1) { + selIndexCurrent++; + } + if (selIndexCurrent < getModel().getSize() - 1) { + setSelectedIndex(selIndexCurrent + 1); + scrollRectToVisible(getCellBounds(selIndexCurrent + 1, selIndexCurrent + 1)); + } + } + else if (selIndexCurrent > 0) { + setSelectedIndex(selIndexCurrent - 1); + scrollRectToVisible(getCellBounds(selIndexCurrent - 1, selIndexCurrent - 1)); + } + } + } +} \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PalettePanel.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PalettePanel.java new file mode 100644 index 000000000000..9b6e12c64436 --- /dev/null +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PalettePanel.java @@ -0,0 +1,69 @@ +/* + * 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.designer.palette2; + +import com.intellij.designer.designSurface.DesignerEditorPanel; +import com.intellij.ui.ScrollPaneFactory; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; +import java.awt.*; +import java.util.Collections; +import java.util.List; + +/** + * @author Alexander Lobas + */ +public class PalettePanel extends JPanel { + private final JPanel myPaletteContainer = new PaletteContainer(); + private List myGroups = Collections.emptyList(); + + public PalettePanel() { + super(new GridLayout(1, 1)); + JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myPaletteContainer); + scrollPane.setBorder(null); + add(scrollPane); + } + + public PaletteItem getActiveItem() { + // XXX + return null; + } + + public void clearActiveItem() { + // XXX + } + + public boolean isEmpty() { + return myGroups.isEmpty(); + } + + public void loadPalette(@Nullable DesignerEditorPanel designer) { + myGroups = designer.getPaletteGroups(); + myPaletteContainer.removeAll(); + + for (PaletteGroup group : myGroups) { + PaletteGroupComponent groupComponent = new PaletteGroupComponent(group); + PaletteItemsComponent itemsComponent = new PaletteItemsComponent(group); + + groupComponent.setItemsComponent(itemsComponent); + myPaletteContainer.add(groupComponent); + myPaletteContainer.add(itemsComponent); + } + + myPaletteContainer.revalidate(); + } +} \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteToolWindowManager.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteToolWindowManager.java new file mode 100644 index 000000000000..9cbf68e810cc --- /dev/null +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/palette2/PaletteToolWindowManager.java @@ -0,0 +1,84 @@ +/* + * 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.designer.palette2; + +import com.intellij.designer.AbstractToolWindowManager; +import com.intellij.designer.designSurface.DesignerEditorPanel; +import com.intellij.icons.AllIcons; +import com.intellij.openapi.fileEditor.FileEditorManager; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.wm.ToolWindowAnchor; +import com.intellij.openapi.wm.ToolWindowManager; +import com.intellij.ui.content.Content; +import com.intellij.ui.content.ContentManager; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Alexander Lobas + */ +public class PaletteToolWindowManager extends AbstractToolWindowManager { + private final PalettePanel myToolWindowPanel = new PalettePanel(); + + public PaletteToolWindowManager(Project project, FileEditorManager fileEditorManager) { + super(project, fileEditorManager); + } + + public static PaletteToolWindowManager getInstance(Project project) { + return project.getComponent(PaletteToolWindowManager.class); + } + + public PaletteItem getActiveItem() { + return myToolWindowPanel.getActiveItem(); + } + + public void clearActiveItem() { + myToolWindowPanel.clearActiveItem(); + } + + @Override + protected void initToolWindow() { + myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow("Palette2", false, ToolWindowAnchor.RIGHT, myProject, true); + myToolWindow.setIcon(AllIcons.Toolwindows.ToolWindowPalette); + + ContentManager contentManager = myToolWindow.getContentManager(); + Content content = contentManager.getFactory().createContent(myToolWindowPanel, null, false); + content.setCloseable(false); + content.setPreferredFocusableComponent(myToolWindowPanel); + contentManager.addContent(content); + contentManager.setSelectedContent(content, true); + myToolWindow.setAvailable(false, null); + } + + @Override + protected void updateToolWindow(@Nullable DesignerEditorPanel designer) { + myToolWindowPanel.loadPalette(designer); + + if (myToolWindowPanel.isEmpty()) { + myToolWindow.setAvailable(false, null); + } + else { + myToolWindow.setAvailable(true, null); + myToolWindow.show(null); + } + } + + @NotNull + @Override + public String getComponentName() { + return "PaletteToolWindowManager"; + } +} \ No newline at end of file From dc60fefd9d530254867a1809fefd272d8bf6c488 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Thu, 14 Jun 2012 14:56:17 +0400 Subject: [PATCH 148/172] OC-4023: Enter on placeholder invokes smart completion. --- .../codeInsight/completion/NextPrevParameterAction.java | 2 +- .../codeInsight/completion/CodeCompletionHandlerBase.java | 2 +- .../codeInsight/completion/CompletionProgressIndicator.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/lang-api/src/com/intellij/codeInsight/completion/NextPrevParameterAction.java b/platform/lang-api/src/com/intellij/codeInsight/completion/NextPrevParameterAction.java index 859da99d24af..87248caa69e6 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/completion/NextPrevParameterAction.java +++ b/platform/lang-api/src/com/intellij/codeInsight/completion/NextPrevParameterAction.java @@ -38,7 +38,7 @@ public abstract class NextPrevParameterAction extends CodeInsightAction { } @Override - protected CodeInsightActionHandler getHandler() { + public CodeInsightActionHandler getHandler() { return new Handler(); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java index 4715b4e5d53f..e24f399eedaa 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java @@ -623,7 +623,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { return invokedExplicitly && CodeInsightSettings.getInstance().AUTOCOMPLETE_COMMON_PREFIX; } - protected static void lookupItemSelected(final CompletionProgressIndicator indicator, @NotNull final LookupElement item, final char completionChar, + protected void lookupItemSelected(final CompletionProgressIndicator indicator, @NotNull final LookupElement item, final char completionChar, final List items) { if (indicator.isAutopopupCompletion()) { FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_BASIC); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java index 2868f0ca6123..b0f57ae05d52 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java @@ -108,7 +108,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement setMergeCommand(); - CodeCompletionHandlerBase.lookupItemSelected(CompletionProgressIndicator.this, item, event.getCompletionChar(), myLookup.getItems()); + myHandler.lookupItemSelected(CompletionProgressIndicator.this, item, event.getCompletionChar(), myLookup.getItems()); } From 1edfa0c9a806068b708b4f324867817f2c17ad3d Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Tue, 5 Jun 2012 13:16:29 +0400 Subject: [PATCH 149/172] Recognize command line like "grails run-app" in Grails Run Configuration (automatically remove "grails" word) --- .../org/jetbrains/plugins/groovy/mvc/MvcRunConfiguration.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfiguration.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfiguration.java index 3d55c4161749..5d762b15fba8 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfiguration.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfiguration.java @@ -226,7 +226,7 @@ public abstract class MvcRunConfiguration extends ModuleBasedConfiguration getConfigurationEditor() { @@ -240,7 +240,7 @@ public abstract class MvcRunConfiguration extends ModuleBasedConfiguration Date: Thu, 14 Jun 2012 15:09:45 +0400 Subject: [PATCH 150/172] IDEA-65935 (Groovy + Maven + GMaven: Provide Groovy language support in Maven POMs) --- .../plugins/groovy/MavenGroovyInjector.java | 4 +- ...enPluginConfigurationLanguageInjector.java | 16 ++++++-- .../groovy/MavenGroovyInjectionTest.groovy | 39 +++++++++++++++++++ 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyInjector.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyInjector.java index 7c529bfd21f4..30648f82c6bf 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyInjector.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyInjector.java @@ -18,12 +18,14 @@ package org.jetbrains.idea.maven.plugins.groovy; import org.jetbrains.idea.maven.utils.MavenPluginConfigurationLanguageInjector; import org.jetbrains.plugins.groovy.GroovyFileType; +import java.util.Arrays; + /** * @author Sergey Evdokimov */ public class MavenGroovyInjector extends MavenPluginConfigurationLanguageInjector { public MavenGroovyInjector() { - super("source", "org.codehaus.groovy.maven", "gmaven-plugin", GroovyFileType.GROOVY_LANGUAGE); + super("source", Arrays.asList("org.codehaus.groovy.maven", "org.codehaus.gmaven"), "gmaven-plugin", GroovyFileType.GROOVY_LANGUAGE); } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenPluginConfigurationLanguageInjector.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenPluginConfigurationLanguageInjector.java index 29981e608193..d1fddf9efa1b 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenPluginConfigurationLanguageInjector.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenPluginConfigurationLanguageInjector.java @@ -26,13 +26,16 @@ import com.intellij.psi.xml.XmlText; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Collection; +import java.util.Collections; + /** * @author Sergey Evdokimov */ public class MavenPluginConfigurationLanguageInjector implements LanguageInjector { private final String myParameterName; - private final String myPluginGroupId; + private final Collection myPluginGroupIds; private final String myPluginArtifactId; private final Language myLanguage; @@ -40,8 +43,15 @@ public class MavenPluginConfigurationLanguageInjector implements LanguageInjecto @NotNull String pluginGroupId, @NotNull String pluginArtifactId, @Nullable Language language) { + this(parameterName, Collections.singleton(pluginGroupId), pluginArtifactId, language); + } + + protected MavenPluginConfigurationLanguageInjector(@NotNull String parameterName, + @NotNull Collection pluginGroupIds, + @NotNull String pluginArtifactId, + @Nullable Language language) { myParameterName = parameterName; - myPluginGroupId = pluginGroupId; + myPluginGroupIds = pluginGroupIds; myPluginArtifactId = pluginArtifactId; myLanguage = language; } @@ -68,7 +78,7 @@ public class MavenPluginConfigurationLanguageInjector implements LanguageInjecto XmlTag plugin = (XmlTag)pluginTag; XmlTag groupId = plugin.findFirstSubTag("groupId"); - if (groupId == null || !groupId.getValue().getText().trim().equals(myPluginGroupId)) return; + if (groupId == null || !myPluginGroupIds.contains(groupId.getValue().getText().trim())) return; XmlTag artifactId = plugin.findFirstSubTag("artifactId"); if (artifactId == null || !artifactId.getValue().getText().trim().equals(myPluginArtifactId)) return; diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyInjectionTest.groovy b/plugins/maven/src/test/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyInjectionTest.groovy index 13b5a2d37a34..acc7e4b4eeef 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyInjectionTest.groovy +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyInjectionTest.groovy @@ -67,6 +67,45 @@ class MavenGroovyInjectionTest extends LightCodeInsightFixtureTestCase { + +""") + + myFixture.completeBasic() + + def lookups = myFixture.lookupElementStrings + assert lookups.containsAll(["String", "StringBuffer", "StringBuilder"]) + } + + public void testCompletion2() { + myFixture.configureByText("pom.xml", """ + + + 4.0.0 + + simpleMaven + simpleMaven + 1.0 + + jar + + + + + org.codehaus.gmaven + gmaven-plugin + 1.3 + + + + String + + + + + + """) From 6fac34993e27e9a7c871f1d30772839ba5ed9591 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 8 Jun 2012 14:21:24 +0400 Subject: [PATCH 151/172] reverted --- .../InnerClassesShadowing.java | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InnerClassesShadowing.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InnerClassesShadowing.java index e7a5e3d51d99..e87c5db28998 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InnerClassesShadowing.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InnerClassesShadowing.java @@ -1,16 +1,98 @@ +import java.io.*; + +public class Main { + static interface A + { + interface B { } + } + + static class D implements A + { + private interface B { } + } + + + static class C extends D implements A + { + interface E extends B { } + interface E1 extends D.B { } + interface E2 extends A.B { } + } + +} + + + +class Main1 { + static interface A + { + interface B { } + } + + static class D implements A + { + interface B { } + } + + + static class C extends D implements A + { + interface E extends B { } + interface E1 extends D.B { + } + interface E2 extends A.B { } + } + +} + + interface A { + interface B { } interface B1 { } } class D implements A { + private interface B { } interface B1 { } } class C extends D implements A { + interface E extends B { } + interface E1 extends D.B { } + interface E2 extends A.B { } + interface F extends B1 { } + interface F1 extends D.B1 { } + interface F2 extends A.B1 { } + } + +class AO {} +class BAO { + AO bar = new AO(); + { + bar.foo(); + } + private class AO { + void foo(){} + } + +} + +class WithFileInputStream { + private static final Runnable runn = new Runnable() { + public void run() { + new FileInputStream("path"); + } + }; + + private static class FileInputStream { + private FileInputStream(String str) { + } + } +} \ No newline at end of file From dab0a315e18defa6ffe64d6606f5176daa4c0513 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 8 Jun 2012 17:35:49 +0400 Subject: [PATCH 152/172] less output --- .../test/java/org/jetbrains/idea/maven/MavenTestCase.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java index fccf7936e9a9..576fea06d84e 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java @@ -144,9 +144,9 @@ public abstract class MavenTestCase extends UsefulTestCase { } } }); - if (!FileUtil.delete(myDir)) { - System.out.println("Cannot delete " + myDir); - printDirectoryContent(myDir); + if (!FileUtil.delete(myDir) && myDir.exists()) { + System.err.println("Cannot delete " + myDir); + //printDirectoryContent(myDir); myDir.deleteOnExit(); } From b56c1eb339133f262e8d6165979af2002ed468f1 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Sat, 9 Jun 2012 17:40:32 +0400 Subject: [PATCH 153/172] performance: do not compute method.getText() --- .../daemon/impl/JavaLineMarkerProvider.java | 40 +++++++++++-------- .../codeInsight/GroovyLineMarkerProvider.java | 23 +++++++---- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java index bf7305100d6f..4ab59906589d 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java @@ -22,6 +22,7 @@ import com.intellij.codeInsight.daemon.LineMarkerProvider; import com.intellij.codeInsight.daemon.MergeableLineMarkerInfo; import com.intellij.icons.AllIcons; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.colors.CodeInsightColors; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; @@ -32,6 +33,8 @@ import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.search.searches.AllOverridingMethodsSearch; import com.intellij.psi.search.searches.ClassInheritorsSearch; @@ -71,8 +74,9 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware { @Override @Nullable public LineMarkerInfo getLineMarkerInfo(@NotNull final PsiElement element) { - if (element instanceof PsiIdentifier && element.getParent() instanceof PsiMethod) { - PsiMethod method = (PsiMethod)element.getParent(); + PsiElement parent; + if (element instanceof PsiIdentifier && (parent = element.getParent()) instanceof PsiMethod) { + PsiMethod method = (PsiMethod)parent; MethodSignatureBackedByPsiMethod superSignature = null; try { superSignature = SuperMethodsSearch.search(method, null, true, false).findFirst(); @@ -101,13 +105,19 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware { } } if (isMember && !(element1 instanceof PsiAnonymousClass || element1.getParent() instanceof PsiAnonymousClass)) { + PsiFile file = element1.getContainingFile(); + Document document = file == null ? null : PsiDocumentManager.getInstance(file.getProject()).getDocument(file); boolean drawSeparator = false; - int category = getCategory(element1); - for (PsiElement child = element1.getPrevSibling(); child != null; child = child.getPrevSibling()) { - int category1 = getCategory(child); - if (category1 == 0) continue; - drawSeparator = category != 1 || category1 != 1; - break; + + if (document != null) { + CharSequence documentChars = document.getCharsSequence(); + int category = getCategory(element1, documentChars); + for (PsiElement child = element1.getPrevSibling(); child != null; child = child.getPrevSibling()) { + int category1 = getCategory(child, documentChars); + if (category1 == 0) continue; + drawSeparator = category != 1 || category1 != 1; + break; + } } if (drawSeparator) { @@ -125,20 +135,18 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware { return null; } - protected static int getCategory(PsiElement element) { + protected static int getCategory(@NotNull PsiElement element, @NotNull CharSequence documentChars) { if (element instanceof PsiField || element instanceof PsiTypeParameter) return 1; if (element instanceof PsiClass || element instanceof PsiClassInitializer) return 2; if (element instanceof PsiMethod) { if (((PsiMethod)element).hasModifierProperty(PsiModifier.ABSTRACT)) { return 1; } - String text = element.getText(); - if (text.indexOf('\n') < 0 && text.indexOf('\r') < 0) { - return 1; - } - else { - return 2; - } + TextRange textRange = element.getTextRange(); + int start = textRange.getStartOffset(); + int end = Math.min(documentChars.length(), textRange.getEndOffset()); + int crlf = StringUtil.getLineBreakCount(documentChars.subSequence(start, end)); + return crlf == 0 ? 1 : 2; } return 0; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/GroovyLineMarkerProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/GroovyLineMarkerProvider.java index ab026026a37f..6b91cbdf7f2d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/GroovyLineMarkerProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/GroovyLineMarkerProvider.java @@ -21,6 +21,7 @@ import com.intellij.codeInsight.daemon.LineMarkerInfo; import com.intellij.codeInsight.daemon.impl.JavaLineMarkerProvider; import com.intellij.codeInsight.daemon.impl.MarkerType; import com.intellij.lang.ASTNode; +import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.colors.CodeInsightColors; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; @@ -117,13 +118,19 @@ public class GroovyLineMarkerProvider extends JavaLineMarkerProvider { } } if (isMember && !(element1 instanceof PsiAnonymousClass || element1.getParent() instanceof PsiAnonymousClass)) { + PsiFile file = element1.getContainingFile(); + Document document = file == null ? null : PsiDocumentManager.getInstance(file.getProject()).getDocument(file); boolean drawSeparator = false; - int category = getGroovyCategory(element1); - for (PsiElement child = element1.getPrevSibling(); child != null; child = child.getPrevSibling()) { - int category1 = getGroovyCategory(child); - if (category1 == 0) continue; - drawSeparator = category != 1 || category1 != 1; - break; + if (document != null) { + CharSequence documentChars = document.getCharsSequence(); + + int category = getGroovyCategory(element1, documentChars); + for (PsiElement child = element1.getPrevSibling(); child != null; child = child.getPrevSibling()) { + int category1 = getGroovyCategory(child, documentChars); + if (category1 == 0) continue; + drawSeparator = category != 1 || category1 != 1; + break; + } } if (drawSeparator) { @@ -155,7 +162,7 @@ public class GroovyLineMarkerProvider extends JavaLineMarkerProvider { return false; } - private static int getGroovyCategory(PsiElement element) { + private static int getGroovyCategory(PsiElement element, CharSequence documentChars) { if (element instanceof GrVariableDeclarationBase) { GrVariable[] variables = ((GrVariableDeclarationBase)element).getVariables(); if (variables.length == 1 && variables[0] instanceof GrField && variables[0].getInitializerGroovy() instanceof GrClosableBlock) { @@ -163,7 +170,7 @@ public class GroovyLineMarkerProvider extends JavaLineMarkerProvider { } } - return JavaLineMarkerProvider.getCategory(element); + return JavaLineMarkerProvider.getCategory(element, documentChars); } @Override From 3193e823ae23e060f6c9ac95dcd123ee0ff96c26 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 14 Jun 2012 14:30:56 +0400 Subject: [PATCH 154/172] do not instantiate PSI for the alien project --- .../intellij/codeInsight/daemon/impl/DaemonListeners.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java index 8bfaabded0ea..78d294258eb6 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java @@ -67,6 +67,7 @@ import com.intellij.profile.codeInspection.InspectionProfileManager; import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.psi.*; import com.intellij.psi.impl.PsiDocumentManagerImpl; +import com.intellij.psi.impl.PsiManagerEx; import com.intellij.psi.search.scope.packageSet.NamedScopesHolder; import com.intellij.util.messages.MessageBus; import com.intellij.util.messages.MessageBusConnection; @@ -246,9 +247,10 @@ class DaemonListeners implements Disposable { String propertyName = event.getPropertyName(); if (VirtualFile.PROP_NAME.equals(propertyName)) { stopDaemonAndRestartAllFiles(); - PsiFile psiFile = PsiManager.getInstance(myProject).findFile(event.getFile()); + VirtualFile virtualFile = event.getFile(); + PsiFile psiFile = ((PsiManagerEx)PsiManager.getInstance(myProject)).getFileManager().getCachedPsiFile(virtualFile); if (psiFile != null && !myDaemonCodeAnalyzer.isHighlightingAvailable(psiFile)) { - Document document = FileDocumentManager.getInstance().getCachedDocument(event.getFile()); + Document document = FileDocumentManager.getInstance().getCachedDocument(virtualFile); if (document != null) { // highlight markers no more //todo clear all highlights regardless the pass id @@ -303,6 +305,7 @@ class DaemonListeners implements Disposable { for (FileEditor fe : editors) { if (!(fe instanceof TextEditor)) continue; Editor editor = ((TextEditor)fe).getEditor(); + if (editor.getProject() != myProject) continue; final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument()); if (psiFile == null) continue; // optimization: do expensive classloading outside readaction From e7b03ba5a4f2d5f0f59deb06ba9f76fc871968fa Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 14 Jun 2012 15:36:35 +0400 Subject: [PATCH 155/172] notnull 2 --- .../search/scope/packageSet/PatternPackageSet.java | 2 ++ .../intellij/profile/ApplicationProfileManager.java | 1 - .../profile/DefaultProjectProfileManager.java | 3 +++ .../src/com/intellij/profile/ProfileManager.java | 4 ++-- .../search/scope/packageSet/AbstractPackageSet.java | 2 ++ .../search/scope/packageSet/ComplementPackageSet.java | 3 +++ .../scope/packageSet/FilePatternPackageSet.java | 11 +++++++++-- .../scope/packageSet/IntersectionPackageSet.java | 3 +++ .../scope/packageSet/NamedPackageSetReference.java | 3 +++ .../psi/search/scope/packageSet/PackageSet.java | 5 ++++- .../psi/search/scope/packageSet/UnionPackageSet.java | 2 ++ .../ChangeListsScopesProvider.java | 2 ++ .../codeInspection/InspectionProfileManager.java | 2 ++ 13 files changed, 37 insertions(+), 6 deletions(-) diff --git a/java/openapi/src/com/intellij/psi/search/scope/packageSet/PatternPackageSet.java b/java/openapi/src/com/intellij/psi/search/scope/packageSet/PatternPackageSet.java index ac7e6d84061b..fa8b3faf6e67 100644 --- a/java/openapi/src/com/intellij/psi/search/scope/packageSet/PatternPackageSet.java +++ b/java/openapi/src/com/intellij/psi/search/scope/packageSet/PatternPackageSet.java @@ -106,6 +106,7 @@ public class PatternPackageSet extends PatternBasedPackageSet { return StringUtil.getQualifiedName(fileIndex.getPackageNameByDirectory(file.isDirectory() ? file : file.getParent()), file.getNameWithoutExtension()); } + @NotNull @Override public PackageSet createCopy() { return new PatternPackageSet(myAspectJSyntaxPattern, myScope, myModulePatternText); @@ -116,6 +117,7 @@ public class PatternPackageSet extends PatternBasedPackageSet { return 0; } + @NotNull @Override public String getText() { StringBuilder buf = new StringBuilder(); diff --git a/platform/lang-api/src/com/intellij/profile/ApplicationProfileManager.java b/platform/lang-api/src/com/intellij/profile/ApplicationProfileManager.java index 13e33d5a7bb7..9fdf3eca2232 100644 --- a/platform/lang-api/src/com/intellij/profile/ApplicationProfileManager.java +++ b/platform/lang-api/src/com/intellij/profile/ApplicationProfileManager.java @@ -43,7 +43,6 @@ public abstract class ApplicationProfileManager implements ProfileManager{ public abstract void addProfile(Profile profile); - @Nullable public NamedScopesHolder getScopesManager() { return null; } diff --git a/platform/lang-api/src/com/intellij/profile/DefaultProjectProfileManager.java b/platform/lang-api/src/com/intellij/profile/DefaultProjectProfileManager.java index babb9f1077ac..02f8b8973ad3 100644 --- a/platform/lang-api/src/com/intellij/profile/DefaultProjectProfileManager.java +++ b/platform/lang-api/src/com/intellij/profile/DefaultProjectProfileManager.java @@ -160,17 +160,20 @@ public abstract class DefaultProjectProfileManager extends ProjectProfileManager } } + @NotNull @Override public NamedScopesHolder getScopesManager() { return myHolder; } + @NotNull @Override public synchronized Collection getProfiles() { getProjectProfileImpl(); return myProfiles.values(); } + @NotNull @Override public synchronized String[] getAvailableProfileNames() { return ArrayUtil.toStringArray(myProfiles.keySet()); diff --git a/platform/lang-api/src/com/intellij/profile/ProfileManager.java b/platform/lang-api/src/com/intellij/profile/ProfileManager.java index 3d89f01aa885..d10d6ccb21d7 100644 --- a/platform/lang-api/src/com/intellij/profile/ProfileManager.java +++ b/platform/lang-api/src/com/intellij/profile/ProfileManager.java @@ -17,7 +17,6 @@ package com.intellij.profile; import com.intellij.psi.search.scope.packageSet.NamedScopesHolder; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.Collection; @@ -26,9 +25,9 @@ import java.util.Collection; * Date: 09-Dec-2005 */ public interface ProfileManager { - @Nullable NamedScopesHolder getScopesManager(); + @NotNull Collection getProfiles(); Profile getProfile(@NotNull String name, boolean returnRootProfileIfNamedIsAbsent); @@ -37,6 +36,7 @@ public interface ProfileManager { void updateProfile(Profile profile); + @NotNull String[] getAvailableProfileNames(); void deleteProfile(String name); diff --git a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/AbstractPackageSet.java b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/AbstractPackageSet.java index 0bf2ca76b74b..2f00759cbc4f 100644 --- a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/AbstractPackageSet.java +++ b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/AbstractPackageSet.java @@ -33,6 +33,7 @@ public abstract class AbstractPackageSet extends PackageSetBase { myPriority = priority; } + @NotNull public AbstractPackageSet createCopy() { return this; } @@ -41,6 +42,7 @@ public abstract class AbstractPackageSet extends PackageSetBase { return myPriority; } + @NotNull @Override public String getText() { return myText; diff --git a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/ComplementPackageSet.java b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/ComplementPackageSet.java index 5294ce11dd3b..7c1f22da9881 100644 --- a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/ComplementPackageSet.java +++ b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/ComplementPackageSet.java @@ -16,6 +16,7 @@ package com.intellij.psi.search.scope.packageSet; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; public class ComplementPackageSet extends PackageSetBase { private final PackageSet myComplementarySet; @@ -29,10 +30,12 @@ public class ComplementPackageSet extends PackageSetBase { : myComplementarySet.contains(getPsiFile(file, holder), holder); } + @NotNull public PackageSet createCopy() { return new ComplementPackageSet(myComplementarySet.createCopy()); } + @NotNull public String getText() { StringBuffer buf = new StringBuffer(); boolean needParen = myComplementarySet.getNodePriority() > getNodePriority(); diff --git a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/FilePatternPackageSet.java b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/FilePatternPackageSet.java index 7218322e2fd1..2d76d7a22bfe 100644 --- a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/FilePatternPackageSet.java +++ b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/FilePatternPackageSet.java @@ -31,12 +31,13 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.regex.Pattern; public class FilePatternPackageSet extends PatternBasedPackageSet { - public static final @NonNls String SCOPE_FILE = "file"; + @NonNls public static final String SCOPE_FILE = "file"; private Pattern myModulePattern; private Pattern myModuleGroupPattern; private final String myPathPattern; @@ -48,7 +49,7 @@ public class FilePatternPackageSet extends PatternBasedPackageSet { @NonNls String filePattern) { myPathPattern = filePattern; myModulePatternText = modulePattern; - if (modulePattern == null || modulePattern.length() == 0) { + if (modulePattern == null || modulePattern.isEmpty()) { myModulePattern = null; } else { @@ -66,6 +67,7 @@ public class FilePatternPackageSet extends PatternBasedPackageSet { myFilePattern = filePattern != null ? Pattern.compile(convertToRegexp(filePattern, '/')) : null; } + @Override public boolean contains(VirtualFile file, NamedScopesHolder holder) { Project project = holder.getProject(); ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); @@ -147,14 +149,19 @@ public class FilePatternPackageSet extends PatternBasedPackageSet { return buf.toString(); } + @Override + @NotNull public PackageSet createCopy() { return new FilePatternPackageSet(myModulePatternText, myPathPattern); } + @Override public int getNodePriority() { return 0; } + @Override + @NotNull public String getText() { @NonNls StringBuffer buf = new StringBuffer("file"); diff --git a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/IntersectionPackageSet.java b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/IntersectionPackageSet.java index 49478442199a..7d47f9e5e52c 100644 --- a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/IntersectionPackageSet.java +++ b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/IntersectionPackageSet.java @@ -16,6 +16,7 @@ package com.intellij.psi.search.scope.packageSet; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; public class IntersectionPackageSet extends PackageSetBase { private final PackageSet myFirstSet; @@ -35,6 +36,7 @@ public class IntersectionPackageSet extends PackageSetBase { return false; } + @NotNull public PackageSet createCopy() { return new IntersectionPackageSet(myFirstSet.createCopy(), mySecondSet.createCopy()); } @@ -43,6 +45,7 @@ public class IntersectionPackageSet extends PackageSetBase { return 2; } + @NotNull public String getText() { StringBuffer buf = new StringBuffer(); boolean needParen = myFirstSet.getNodePriority() > getNodePriority(); diff --git a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/NamedPackageSetReference.java b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/NamedPackageSetReference.java index c344bfbebbff..bd22fb7ce479 100644 --- a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/NamedPackageSetReference.java +++ b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/NamedPackageSetReference.java @@ -16,6 +16,7 @@ package com.intellij.psi.search.scope.packageSet; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; public class NamedPackageSetReference extends PackageSetBase { private final String myName; @@ -35,10 +36,12 @@ public class NamedPackageSetReference extends PackageSetBase { return false; } + @NotNull public PackageSet createCopy() { return new NamedPackageSetReference(myName); } + @NotNull public String getText() { return "$" + myName; } diff --git a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/PackageSet.java b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/PackageSet.java index 59f8c8f16fdb..5e59d8c7bbf4 100644 --- a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/PackageSet.java +++ b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/PackageSet.java @@ -17,10 +17,13 @@ package com.intellij.psi.search.scope.packageSet; import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; public interface PackageSet { boolean contains(PsiFile file, NamedScopesHolder holder); + @NotNull PackageSet createCopy(); - @NonNls String getText(); + @NonNls @NotNull + String getText(); int getNodePriority(); } \ No newline at end of file diff --git a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/UnionPackageSet.java b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/UnionPackageSet.java index 52fedd70caab..896431e432a6 100644 --- a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/UnionPackageSet.java +++ b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/UnionPackageSet.java @@ -33,6 +33,7 @@ public class UnionPackageSet extends PackageSetBase { (mySecondSet instanceof PackageSetBase ? ((PackageSetBase)mySecondSet).contains(file, holder) : mySecondSet.contains(getPsiFile(file, holder), holder)); } + @NotNull public PackageSet createCopy() { return new UnionPackageSet(myFirstSet.createCopy(), mySecondSet.createCopy()); } @@ -41,6 +42,7 @@ public class UnionPackageSet extends PackageSetBase { return 3; } + @NotNull public String getText() { return myFirstSet.getText() + "||" + mySecondSet.getText(); } diff --git a/platform/lang-impl/src/com/intellij/packageDependencies/ChangeListsScopesProvider.java b/platform/lang-impl/src/com/intellij/packageDependencies/ChangeListsScopesProvider.java index 64f8867eeae8..8fa3c197ba45 100644 --- a/platform/lang-impl/src/com/intellij/packageDependencies/ChangeListsScopesProvider.java +++ b/platform/lang-impl/src/com/intellij/packageDependencies/ChangeListsScopesProvider.java @@ -103,11 +103,13 @@ public class ChangeListsScopesProvider extends CustomScopesProviderEx { return files.contains(file); } + @NotNull @Override public PackageSet createCopy() { return this; } + @NotNull @Override public String getText() { return "file:*//*"; diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java index c29801d58402..91daed97ef45 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java @@ -134,6 +134,7 @@ public class InspectionProfileManager extends ApplicationProfileManager implemen return InspectionsBundle.message("inspection.profiles.presentable.name"); } + @NotNull public Collection getProfiles() { initProfiles(); return mySchemesManager.getAllSchemes(); @@ -343,6 +344,7 @@ public class InspectionProfileManager extends ApplicationProfileManager implemen return directory; } + @NotNull public String[] getAvailableProfileNames() { final Collection names = mySchemesManager.getAllSchemeNames(); return ArrayUtil.toStringArray(names); From 2ed30c9cf89bbe4c6ef1bb0c66cf6efe90858aae Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 14 Jun 2012 15:37:04 +0400 Subject: [PATCH 156/172] memory --- .../psi/impl/PropertiesFileImpl.java | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/plugins/properties/src/com/intellij/lang/properties/psi/impl/PropertiesFileImpl.java b/plugins/properties/src/com/intellij/lang/properties/psi/impl/PropertiesFileImpl.java index b4763dff8dc1..4dbd4a509510 100644 --- a/plugins/properties/src/com/intellij/lang/properties/psi/impl/PropertiesFileImpl.java +++ b/plugins/properties/src/com/intellij/lang/properties/psi/impl/PropertiesFileImpl.java @@ -18,7 +18,9 @@ package com.intellij.lang.properties.psi.impl; import com.intellij.extapi.psi.PsiFileBase; import com.intellij.lang.ASTFactory; import com.intellij.lang.ASTNode; -import com.intellij.lang.properties.*; +import com.intellij.lang.properties.IProperty; +import com.intellij.lang.properties.PropertiesLanguage; +import com.intellij.lang.properties.PropertiesUtil; import com.intellij.lang.properties.ResourceBundle; import com.intellij.lang.properties.parsing.PropertiesElementTypes; import com.intellij.lang.properties.psi.PropertiesElementFactory; @@ -26,13 +28,16 @@ import com.intellij.lang.properties.psi.PropertiesFile; import com.intellij.lang.properties.psi.Property; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.StdFileTypes; -import com.intellij.psi.*; +import com.intellij.psi.FileViewProvider; +import com.intellij.psi.PsiElement; +import com.intellij.psi.TokenType; import com.intellij.psi.impl.source.tree.ChangeUtil; import com.intellij.psi.impl.source.tree.TreeElement; import com.intellij.psi.tree.TokenSet; import com.intellij.util.ArrayUtil; import com.intellij.util.IncorrectOperationException; -import com.intellij.util.containers.MultiMap; +import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.MostlySingularMultiMap; import gnu.trove.THashMap; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -42,7 +47,7 @@ import java.util.*; public class PropertiesFileImpl extends PsiFileBase implements PropertiesFile { private static final TokenSet PROPERTIES_LIST_SET = TokenSet.create(PropertiesElementTypes.PROPERTIES_LIST); - private volatile MultiMap myPropertiesMap; //guarded by lock + private volatile MostlySingularMultiMap myPropertiesMap; //guarded by lock private volatile List myProperties; //guarded by lock private final Object lock = new Object(); @@ -50,6 +55,7 @@ public class PropertiesFileImpl extends PsiFileBase implements PropertiesFile { super(viewProvider, PropertiesLanguage.INSTANCE); } + @Override @NotNull public FileType getFileType() { return StdFileTypes.PROPERTIES; @@ -60,6 +66,7 @@ public class PropertiesFileImpl extends PsiFileBase implements PropertiesFile { return "Properties file:" + getName(); } + @Override @NotNull public List getProperties() { ensurePropertiesLoaded(); @@ -74,12 +81,12 @@ public class PropertiesFileImpl extends PsiFileBase implements PropertiesFile { if (myPropertiesMap != null) return; final ASTNode[] props = getPropertiesList().getChildren(PropertiesElementTypes.PROPERTIES); - MultiMap propertiesMap = new MultiMap(); + MostlySingularMultiMap propertiesMap = new MostlySingularMultiMap(); List properties = new ArrayList(props.length); for (final ASTNode prop : props) { final Property property = (Property)prop.getPsi(); String key = property.getUnescapedKey(); - propertiesMap.putValue(key, property); + propertiesMap.add(key, property); properties.add(property); } synchronized (lock) { @@ -89,32 +96,37 @@ public class PropertiesFileImpl extends PsiFileBase implements PropertiesFile { } } + @Override public IProperty findPropertyByKey(@NotNull String key) { ensurePropertiesLoaded(); synchronized (lock) { - Collection list = myPropertiesMap.get(key); - return list.isEmpty() ? null : list.iterator().next(); + Iterator iterator = myPropertiesMap.get(key).iterator(); + return iterator.hasNext() ? iterator.next() : null; } } + @Override @NotNull public List findPropertiesByKey(@NotNull String key) { ensurePropertiesLoaded(); synchronized (lock) { - return (List)myPropertiesMap.get(key); + return ContainerUtil.collect(myPropertiesMap.get(key).iterator()); } } + @Override @NotNull public ResourceBundle getResourceBundle() { return PropertiesUtil.getResourceBundle(getContainingFile()); } + @Override @NotNull public Locale getLocale() { return PropertiesUtil.getLocale(getVirtualFile()); } + @Override public PsiElement add(@NotNull PsiElement element) throws IncorrectOperationException { if (element instanceof Property) { throw new IncorrectOperationException("Use addProperty() instead"); @@ -122,6 +134,7 @@ public class PropertiesFileImpl extends PsiFileBase implements PropertiesFile { return super.add(element); } + @Override @NotNull public PsiElement addProperty(@NotNull IProperty property) throws IncorrectOperationException { if (haveToAddNewLine()) { @@ -132,6 +145,7 @@ public class PropertiesFileImpl extends PsiFileBase implements PropertiesFile { return copy.getPsi(); } + @Override @NotNull public PsiElement addPropertyAfter(@NotNull final Property property, @Nullable final Property anchor) throws IncorrectOperationException { final TreeElement copy = ChangeUtil.copyToElement(property); @@ -167,6 +181,7 @@ public class PropertiesFileImpl extends PsiFileBase implements PropertiesFile { return lastChild != null && !lastChild.getText().endsWith("\n"); } + @Override @NotNull public Map getNamesMap() { Map result = new THashMap(); From c35bed85449ad51a865c4c87d8834439a3eb68c6 Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Thu, 14 Jun 2012 15:39:51 +0400 Subject: [PATCH 157/172] IDEA-86814 Maven 3 do not support '-cpu / -npu' options Fix after review --- .../idea/maven/project/MavenGeneralConfigurable.form | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralConfigurable.form b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralConfigurable.form index f2eff28c8b7e..7bc25cb9ae5f 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralConfigurable.form +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralConfigurable.form @@ -90,7 +90,9 @@ - + + + @@ -137,13 +139,12 @@ - + - - + From f0254ecd0dc782b787624e5b88c07bc3348e0765 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Thu, 14 Jun 2012 15:19:43 +0400 Subject: [PATCH 158/172] IDEA-87378 I can't choose whether to rename Groovy property or Groovy method --- .../groovy/lang/psi/util/GroovyPropertyUtils.java | 2 +- .../refactoring/GroovyRefactoringBundle.properties | 2 +- .../groovy/refactoring/rename/GrMethodRenameHandler.java | 5 +++-- .../groovy/refactoring/rename/RenamePropertyUtil.java | 9 +++------ 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyPropertyUtils.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyPropertyUtils.java index f8faaefb3e2e..5a1b66d97225 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyPropertyUtils.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyPropertyUtils.java @@ -128,7 +128,7 @@ public class GroovyPropertyUtils { } @NotNull - public static PsiMethod[] getAllGetters(PsiClass aClass, String propertyName, boolean isStatic, boolean checkSuperClasses) { + public static PsiMethod[] getAllGetters(PsiClass aClass, @NotNull String propertyName, boolean isStatic, boolean checkSuperClasses) { if (aClass == null) return PsiMethod.EMPTY_ARRAY; PsiMethod[] methods; if (checkSuperClasses) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringBundle.properties index 4640da8ee706..9f2aac09e770 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringBundle.properties +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringBundle.properties @@ -169,4 +169,4 @@ rename.implicit.closure.parameter.to=Rename implicit closure parameter to\: implicit.closure.parameter=Implicit closure parameter selected.expression.should.not.be.lvalue=Selected expression should not be left hand side of assignment column.name.use.any.var=Use any var -rename.groovy.method=Rename groovy method +rename.groovy.method=Rename Groovy method diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/GrMethodRenameHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/GrMethodRenameHandler.java index eac040ad8b36..ec03a388cc0d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/GrMethodRenameHandler.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/GrMethodRenameHandler.java @@ -24,11 +24,13 @@ import com.intellij.openapi.editor.ScrollType; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiMethod; import com.intellij.refactoring.rename.RenameDialog; import com.intellij.refactoring.rename.RenameHandler; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod; +import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils; import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle; /** @@ -37,8 +39,7 @@ import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle; public class GrMethodRenameHandler implements RenameHandler, TitledHandler { public boolean isAvailableOnDataContext(DataContext dataContext) { final PsiElement element = getElement(dataContext); - if (element instanceof GrMethod) return true; - return false; + return element instanceof GrMethod && !GroovyPropertyUtils.isSimplePropertyAccessor((PsiMethod)element); } @Nullable diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenamePropertyUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenamePropertyUtil.java index 408d0628bebb..c7ce7bf30881 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenamePropertyUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenamePropertyUtil.java @@ -18,16 +18,12 @@ package org.jetbrains.plugins.groovy.refactoring.rename; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.Pair; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiField; -import com.intellij.psi.PsiMember; +import com.intellij.psi.*; import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.util.RadioUpDownListener; import com.intellij.usageView.UsageViewUtil; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.Nullable; -import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod; @@ -76,9 +72,10 @@ public class RenamePropertyUtil { final PsiClass containingClass = m.getContainingClass(); if (containingClass == null) return member(m); - final boolean isStatic = m.hasModifierProperty(GrModifier.STATIC); + final boolean isStatic = m.hasModifierProperty(PsiModifier.STATIC); List property = new ArrayList(); + assert name != null; ContainerUtil.addAll(property, GroovyPropertyUtils.getAllGetters(containingClass, name, isStatic, false)); ContainerUtil.addAll(property, GroovyPropertyUtils.getAllSetters(containingClass, name, isStatic, false)); From 28a442bfd5b808b49337ebe5b69ae37ece44bf72 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Thu, 14 Jun 2012 15:40:16 +0400 Subject: [PATCH 159/172] IDEA-87425 New category classes in Groovy 2.0 --- plugins/groovy/resources/standardDsls/extensions.gdsl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/groovy/resources/standardDsls/extensions.gdsl b/plugins/groovy/resources/standardDsls/extensions.gdsl index 10e8edee3f5e..17a71ec16568 100644 --- a/plugins/groovy/resources/standardDsls/extensions.gdsl +++ b/plugins/groovy/resources/standardDsls/extensions.gdsl @@ -22,11 +22,17 @@ package standardDsls */ contributor([:]) { + category "org.codehaus.groovy.runtime.DateGroovyMethods" category "org.codehaus.groovy.runtime.DefaultGroovyMethods" category "org.codehaus.groovy.runtime.DefaultGroovyStaticMethods", true - category "org.codehaus.groovy.runtime.DateGroovyMethods" category "org.codehaus.groovy.runtime.EncodingGroovyMethods" + category "org.codehaus.groovy.runtime.IOGroovyMethods" + category "org.codehaus.groovy.runtime.ProcessGroovyMethods" + category "org.codehaus.groovy.runtime.ResourceGroovyMethods" + category "org.codehaus.groovy.runtime.SocketGroovyMethods" category "org.codehaus.groovy.runtime.SqlGroovyMethods" + category "org.codehaus.groovy.runtime.StringGroovyMethods" category "org.codehaus.groovy.runtime.SwingGroovyMethods" category "org.codehaus.groovy.runtime.XmlGroovyMethods" + } From d99d5a99766ea22c9096e70c7fbdca107d332c49 Mon Sep 17 00:00:00 2001 From: irengrig Date: Tue, 5 Jun 2012 14:05:44 +0400 Subject: [PATCH 160/172] IDEA-86863 Subversion: "file is changed on server" marker is shown for all locally changed files in 1.6 working copy --- .../src/org/jetbrains/idea/svn/SvnDiffProvider.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnDiffProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnDiffProvider.java index 661a0a647234..7398b38e7da4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnDiffProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnDiffProvider.java @@ -162,7 +162,7 @@ public class SvnDiffProvider implements DiffProvider, DiffMixin { final SVNStatusClient client = myVcs.createStatusClient(); try { final SVNStatus svnStatus = client.doStatus(file, true); - if (svnStatus == null) { + if (svnStatus == null || itemExists(svnStatus) && SVNRevision.UNDEFINED.equals(svnStatus.getRemoteRevision())) { // IDEADEV-21785 (no idea why this can happen) final SVNInfo info = myVcs.createWCClient().doInfo(file, SVNRevision.HEAD); if (info == null || info.getURL() == null) { @@ -171,8 +171,7 @@ public class SvnDiffProvider implements DiffProvider, DiffMixin { } return createResult(info.getCommittedRevision(), true, false); } - final boolean exists = ! SVNStatusType.STATUS_DELETED.equals(svnStatus.getRemoteContentsStatus()) && - ! SVNStatusType.STATUS_DELETED.equals(svnStatus.getRemoteNodeStatus()); + final boolean exists = itemExists(svnStatus); if (! exists) { // get really latest revision final LatestExistentSearcher searcher = new LatestExistentSearcher(myVcs, svnStatus.getURL()); @@ -191,4 +190,9 @@ public class SvnDiffProvider implements DiffProvider, DiffMixin { return defaultResult(); } } + + private boolean itemExists(SVNStatus svnStatus) { + return ! SVNStatusType.STATUS_DELETED.equals(svnStatus.getRemoteContentsStatus()) && + ! SVNStatusType.STATUS_DELETED.equals(svnStatus.getRemoteNodeStatus()); + } } From 7b6307a7041daafac404a02354dc9b33b22fd7ff Mon Sep 17 00:00:00 2001 From: irengrig Date: Wed, 6 Jun 2012 18:08:50 +0400 Subject: [PATCH 161/172] correct comparison --- .../idea/svn/commandLine/SvnInfoStructure.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnInfoStructure.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnInfoStructure.java index 7916f326ec9c..015788b635eb 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnInfoStructure.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnInfoStructure.java @@ -84,17 +84,17 @@ public class SvnInfoStructure { } private SVNConflictReason parseConflictReason(String reason) throws SAXException { - if (ConflictDescriptor.Reason.edited.equals(reason)) { + if (ConflictDescriptor.Reason.edited.name().equals(reason)) { return SVNConflictReason.EDITED; - } else if (ConflictDescriptor.Reason.obstructed.equals(reason)) { + } else if (ConflictDescriptor.Reason.obstructed.name().equals(reason)) { return SVNConflictReason.OBSTRUCTED; - } else if (ConflictDescriptor.Reason.deleted.equals(reason)) { + } else if (ConflictDescriptor.Reason.deleted.name().equals(reason)) { return SVNConflictReason.DELETED; - } else if (ConflictDescriptor.Reason.missing.equals(reason)) { + } else if (ConflictDescriptor.Reason.missing.name().equals(reason)) { return SVNConflictReason.MISSING; - } else if (ConflictDescriptor.Reason.unversioned.equals(reason)) { + } else if (ConflictDescriptor.Reason.unversioned.name().equals(reason)) { return SVNConflictReason.UNVERSIONED; - } else if (ConflictDescriptor.Reason.added.equals(reason)) { + } else if (ConflictDescriptor.Reason.added.name().equals(reason)) { return SVNConflictReason.ADDED; } if ("edit".equals(reason)) { From 403da2e3211cef211cf278abfe565c8d4b6ba5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Thu, 14 Jun 2012 14:14:01 +0200 Subject: [PATCH 162/172] IDEA-87235 Spring webflow: binder@binding@property rename is incorrect when performed from Structure view --- .../refactoring/rename/BeanPropertyRenameHandler.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/rename/BeanPropertyRenameHandler.java b/java/java-impl/src/com/intellij/refactoring/rename/BeanPropertyRenameHandler.java index 0b6366742815..4c41a438cffc 100644 --- a/java/java-impl/src/com/intellij/refactoring/rename/BeanPropertyRenameHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/rename/BeanPropertyRenameHandler.java @@ -44,12 +44,16 @@ public abstract class BeanPropertyRenameHandler implements RenameHandler { } public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) { - final BeanProperty property = getProperty(dataContext); - new PropertyRenameDialog(property, editor).show(); + performInvoke(editor, dataContext); } public void invoke(@NotNull Project project, @NotNull PsiElement[] elements, DataContext dataContext) { + performInvoke(null, dataContext); + } + private void performInvoke(@Nullable Editor editor, DataContext dataContext) { + final BeanProperty property = getProperty(dataContext); + new PropertyRenameDialog(property, editor).show(); } public static void doRename(@NotNull final BeanProperty property, final String newName, final boolean searchInComments) { @@ -89,6 +93,5 @@ public abstract class BeanPropertyRenameHandler implements RenameHandler { doRename(myProperty, newName, searchInComments); close(DialogWrapper.OK_EXIT_CODE); } - } } From 7b846d20c88d0a2228ca74be7485f6fe0616dd8f Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Thu, 14 Jun 2012 16:35:04 +0400 Subject: [PATCH 163/172] IDEA-87280 ('Create new maven module' does not create standard maven /resources folder) --- .../jetbrains/idea/maven/wizards/MavenModuleBuilderHelper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenModuleBuilderHelper.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenModuleBuilderHelper.java index 3e40d8780479..b705bd671c73 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenModuleBuilderHelper.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenModuleBuilderHelper.java @@ -123,6 +123,7 @@ public class MavenModuleBuilderHelper { if (myArchetype == null) { try { VfsUtil.createDirectories(root.getPath() + "/src/main/java"); + VfsUtil.createDirectories(root.getPath() + "/src/main/resources"); VfsUtil.createDirectories(root.getPath() + "/src/test/java"); } catch (IOException e) { From d4dad4ad8285bf5142f6f996cfe97ee0f8ccff87 Mon Sep 17 00:00:00 2001 From: irengrig Date: Thu, 14 Jun 2012 16:49:05 +0400 Subject: [PATCH 164/172] special Favorites node - current task - to be further used in connection with Tasks; ability to import references from Find Usages there; ability to add notes there ("working set") --- .../openapi/actionSystem/LangDataKeys.java | 1 + .../src/com/intellij/usageView/UsageInfo.java | 25 ++ .../ide/actions/NewElementAction.java | 4 + .../ide/favoritesTreeView/Concept.java | 27 ++ .../favoritesTreeView/FavoritesListNode.java | 54 ++- .../FavoritesListProvider.java | 51 +++ .../favoritesTreeView/FavoritesManager.java | 386 ++++++++++++++---- .../ide/favoritesTreeView/FavoritesPanel.java | 11 +- .../FavoritesProjectViewPane.java | 4 +- .../favoritesTreeView/FavoritesRootNode.java | 5 +- .../FavoritesTreeStructure.java | 10 +- .../favoritesTreeView/FavoritesTreeUtil.java | 120 ++++++ .../FavoritesTreeViewPanel.java | 202 ++++++--- .../FavoritesViewSelectInTarget.java | 2 +- .../FileGroupingProjectNode.java | 87 ++++ .../favoritesTreeView/FileSerializable.java | 54 +++ .../intellij/ide/favoritesTreeView/Flag.java | 46 +++ .../favoritesTreeView/ImportUsagesAction.java | 69 ++++ .../InvalidUsageNoteNode.java | 55 +++ .../InvalidUsageNoteProjectNode.java | 50 +++ .../ide/favoritesTreeView/NoteNode.java | 74 ++++ .../favoritesTreeView/NoteProjectNode.java | 52 +++ .../favoritesTreeView/NoteSerializable.java | 63 +++ .../ide/favoritesTreeView/PercentDone.java | 36 ++ .../ProjectDefaultFavoriteListProvider.java | 69 ++++ .../ProjectViewNodeWithChildrenList.java | 69 ++++ .../TaskDefaultFavoriteListProvider.java | 283 +++++++++++++ .../UsageFavoriteNodeProvider.java | 313 ++++++++++++++ .../ide/favoritesTreeView/UsageNode.java | 61 +++ .../UsageProjectTreeNode.java | 91 +++++ .../favoritesTreeView/UsageSerializable.java | 165 ++++++++ .../WorkingSetSerializable.java | 34 ++ .../WorkingSetUsageActionProvider.java | 45 ++ .../actions/AddAllToFavoritesActionGroup.java | 2 +- .../actions/AddNewFavoritesListAction.java | 6 +- .../actions/AddToFavoritesAction.java | 1 + .../actions/AddToFavoritesActionGroup.java | 2 +- .../actions/AddToFavoritesPopupAction.java | 2 +- .../DeleteAllFavoritesListsButThisAction.java | 4 +- .../actions/DeleteFromFavoritesAction.java | 26 +- .../actions/RenameFavoritesListAction.java | 2 +- .../actions/SendToFavoritesAction.java | 2 +- .../actions/SendToFavoritesGroup.java | 2 +- .../util/scopeChooser/ScopeChooserCombo.java | 5 +- .../treeView/AbstractTreeStructureBase.java | 2 +- .../com/intellij/ui/PrepareTreeRenderer.java | 79 ++++ .../src/META-INF/LangExtensionPoints.xml | 3 + .../src/META-INF/LangExtensions.xml | 1 + .../intellij/usages/impl/UsageViewImpl.java | 19 +- .../com/intellij/util/ProxyComparator.java | 39 ++ .../util/src/com/intellij/util/TreeItem.java | 23 +- resources/src/META-INF/IdeaPlugin.xml | 3 + 52 files changed, 2669 insertions(+), 172 deletions(-) create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/Concept.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesListProvider.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeUtil.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FileGroupingProjectNode.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FileSerializable.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/Flag.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/ImportUsagesAction.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/InvalidUsageNoteNode.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/InvalidUsageNoteProjectNode.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/NoteNode.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/NoteProjectNode.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/NoteSerializable.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/PercentDone.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/ProjectDefaultFavoriteListProvider.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/ProjectViewNodeWithChildrenList.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/TaskDefaultFavoriteListProvider.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageFavoriteNodeProvider.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageNode.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageProjectTreeNode.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageSerializable.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/WorkingSetSerializable.java create mode 100644 platform/lang-impl/src/com/intellij/ide/favoritesTreeView/WorkingSetUsageActionProvider.java create mode 100644 platform/platform-api/src/com/intellij/ui/PrepareTreeRenderer.java create mode 100644 platform/util/src/com/intellij/util/ProxyComparator.java diff --git a/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java b/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java index 0150e9b5ba69..a7235246ee96 100644 --- a/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java +++ b/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java @@ -49,6 +49,7 @@ public class LangDataKeys extends PlatformDataKeys { * Returns {@link com.intellij.ide.IdeView} (one of project, packages, commander or favorites view). */ public static final DataKey IDE_VIEW = DataKey.create("IDEView"); + public static final DataKey NO_NEW_ACTION = DataKey.create("IDEview.no.create.element.action"); public static final DataKey> PRESELECT_NEW_ACTION_CONDITION = DataKey.create("newElementAction.preselect.id"); public static final DataKey TARGET_PSI_ELEMENT = DataKey.create("psi.TargetElement"); diff --git a/platform/lang-api/src/com/intellij/usageView/UsageInfo.java b/platform/lang-api/src/com/intellij/usageView/UsageInfo.java index 37aacd8539e5..719c0fe54db2 100644 --- a/platform/lang-api/src/com/intellij/usageView/UsageInfo.java +++ b/platform/lang-api/src/com/intellij/usageView/UsageInfo.java @@ -69,6 +69,31 @@ public class UsageInfo { this.isNonCodeUsage = isNonCodeUsage; } + public UsageInfo(@NotNull SmartPsiElementPointer smartPointer, + SmartPsiFileRange psiFileRange, boolean dynamicUsage, + boolean nonCodeUsage) { + myDynamicUsage = dynamicUsage; + isNonCodeUsage = nonCodeUsage; + myPsiFileRange = psiFileRange; + mySmartPointer = smartPointer; + } + + public SmartPsiElementPointer getSmartPointer() { + return mySmartPointer; + } + + public SmartPsiFileRange getPsiFileRange() { + return myPsiFileRange; + } + + public boolean isNonCodeUsage() { + return isNonCodeUsage; + } + + public void setDynamicUsage(boolean dynamicUsage) { + myDynamicUsage = dynamicUsage; + } + public UsageInfo(@NotNull PsiElement element, boolean isNonCodeUsage) { this(element, -1, -1, isNonCodeUsage); } diff --git a/platform/lang-impl/src/com/intellij/ide/actions/NewElementAction.java b/platform/lang-impl/src/com/intellij/ide/actions/NewElementAction.java index b5b2d40817db..31d879ea72e1 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/NewElementAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/NewElementAction.java @@ -90,6 +90,10 @@ public class NewElementAction extends AnAction implements DumbAware, PopupActio presentation.setEnabled(false); return; } + if (Boolean.TRUE.equals(LangDataKeys.NO_NEW_ACTION.getData(context))) { + presentation.setEnabled(false); + return; + } final IdeView ideView = LangDataKeys.IDE_VIEW.getData(context); if (ideView == null) { presentation.setEnabled(false); diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/Concept.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/Concept.java new file mode 100644 index 000000000000..e4a2d3c57b1f --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/Concept.java @@ -0,0 +1,27 @@ +/* + * 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.ide.favoritesTreeView; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/1/12 + * Time: 2:14 PM + */ +public class Concept { + private String myTagName; + private String myDescription; +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesListNode.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesListNode.java index a667fcc1a413..2415484f26ce 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesListNode.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesListNode.java @@ -22,6 +22,7 @@ import com.intellij.ide.projectView.impl.AbstractUrl; import com.intellij.ide.util.treeView.AbstractTreeNode; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; +import com.intellij.util.TreeItem; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -35,17 +36,23 @@ import java.util.List; public class FavoritesListNode extends AbstractTreeNode { private final Project myProject; private final String myListName; + private final boolean myAllowsTree; - protected FavoritesListNode(Project project, String listName) { + protected FavoritesListNode(Project project, String listName, boolean tree) { super(project, listName); myProject = project; myListName = listName; + myAllowsTree = tree; + } + + public boolean isAllowsTree() { + return myAllowsTree; } @NotNull @Override public Collection getChildren() { - return getFavoritesRoots(myProject, myListName); + return getFavoritesRoots(myProject, myListName, this); } @Override @@ -54,32 +61,53 @@ public class FavoritesListNode extends AbstractTreeNode { presentation.setPresentableText(myListName); } - @NotNull public static Collection getFavoritesRoots(Project project, String listName) { - final Collection> pairs = FavoritesManager.getInstance(project).getFavoritesListRootUrls(listName); + @NotNull public static Collection getFavoritesRoots(Project project, String listName, final FavoritesListNode listNode) { + final Collection>> pairs = FavoritesManager.getInstance(project).getFavoritesListRootUrls(listName); if (pairs == null) return Collections.emptyList(); - return createFavoriteRoots(project, pairs); + return createFavoriteRoots(project, pairs, listNode); } @NotNull - private static Collection createFavoriteRoots(Project project, @NotNull Collection> urls) { - List result = new ArrayList(); - for (Pair pair : urls) { - AbstractUrl abstractUrl = pair.getFirst(); + private static Collection createFavoriteRoots(Project project, @NotNull Collection>> urls, + final AbstractTreeNode me) { + Collection result = new ArrayList(); + processUrls(project, urls, result, me); + return result; + } + + private static void processUrls(Project project, + Collection>> urls, + Collection result, final AbstractTreeNode me) { + for (TreeItem> pair : urls) { + AbstractUrl abstractUrl = pair.getData().getFirst(); final Object[] path = abstractUrl.createPath(project); if (path == null || path.length < 1 || path[0] == null) { continue; } try { - final String className = pair.getSecond(); + final String className = pair.getData().getSecond(); @SuppressWarnings("unchecked") final Class nodeClass = (Class)Class.forName(className); - final AbstractTreeNode node = ProjectViewNode.createTreeNode(nodeClass, project, path[path.length - 1], FavoritesManager.getInstance(project).getViewSettings()); + final AbstractTreeNode node = ProjectViewNode + .createTreeNode(nodeClass, project, path[path.length - 1], FavoritesManager.getInstance(project).getViewSettings()); + node.setParent(me); + node.setIndex(result.size()); result.add(node); + + if (node instanceof ProjectViewNodeWithChildrenList) { + final List>> children = pair.getChildren(); + if (children != null && ! children.isEmpty()) { + Collection childList = new ArrayList(); + processUrls(project, children, childList, node); + for (AbstractTreeNode treeNode : childList) { + ((ProjectViewNodeWithChildrenList)node).addChild(treeNode); + } + } + } } catch (Exception ignored) { } } - return result; - } + } } diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesListProvider.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesListProvider.java new file mode 100644 index 000000000000..a80ab7f13fa9 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesListProvider.java @@ -0,0 +1,51 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.ide.dnd.aware.DnDAwareTree; +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.project.Project; + +import javax.swing.tree.TreeCellRenderer; +import java.util.Comparator; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/7/12 + * Time: 4:17 PM + */ +public interface FavoritesListProvider { + ExtensionPointName EP_NAME = new ExtensionPointName("com.intellij.favoritesListProvider"); + + String getListName(final Project project); + boolean canBeRemoved(); + boolean isTreeLike(); + + Comparator getNodeDescriptorComparator(); + + Operation getCustomDeleteOperation(); + Operation getCustomAddOperation(); + Operation getCustomEditOperation(); + + TreeCellRenderer getTreeCellRenderer(); + + interface Operation { + boolean willHandle(final DnDAwareTree tree); + String getCustomName(); + void handle(Project project, final DnDAwareTree tree); + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesManager.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesManager.java index 44744c76c999..80d1f6a7118e 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesManager.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesManager.java @@ -34,21 +34,31 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.util.PsiUtilBase; import com.intellij.util.ArrayUtil; +import com.intellij.util.Consumer; +import com.intellij.util.TreeItem; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.tree.TreeCellRenderer; import java.util.*; public class FavoritesManager implements ProjectComponent, JDOMExternalizable { // fav list name -> list of (root: root url, root class) - private final Map>> myName2FavoritesRoots = - new LinkedHashMap>>(); + private final Map>>> myName2FavoritesRoots = + new LinkedHashMap>>>(); + private final Set myReadOnlyLists = new HashSet(); + private final Set myAllowsTreeLists = new HashSet(); private final Project myProject; private final List myListeners = new ArrayList(); private final FavoritesViewSettings myViewSettings = new FavoritesViewSettings(); - + private final Map myEditHandlers = new HashMap(); + private final Map myAddHandlers = new HashMap(); + private final Map myDeleteHandlers = new HashMap(); + private final Map myCustomRenderers = new HashMap(); + private final Map> myComparators = new HashMap>(); + private final FavoritesListener fireListeners = new FavoritesListener() { public void rootsChanged(String listName) { FavoritesListener[] listeners = myListeners.toArray(new FavoritesListener[myListeners.size()]); @@ -79,6 +89,31 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable { myListeners.remove(listener); } + public synchronized FavoritesListProvider.Operation getCustomAdd(final String name) { + return myAddHandlers.get(name); + } + + public synchronized FavoritesListProvider.Operation getCustomEdit(final String name) { + return myEditHandlers.get(name); + } + + public synchronized FavoritesListProvider.Operation getCustomDelete(final String name) { + return myDeleteHandlers.get(name); + } + + public void removeRootByIndexes(String name, List elementsIndexes) { + List>> list = getFavoritesListRootUrls(name); + assert list != null; + for (Integer index : elementsIndexes.subList(0, elementsIndexes.size() - 1)) { + assert index >= 0 && index < list.size(); + final TreeItem> item = list.get(index); + list = item.getChildren(); + } + assert list != null && ! list.isEmpty(); + list.remove(elementsIndexes.get(elementsIndexes.size() - 1).intValue()); + fireListeners.rootsChanged(name); + } + public static FavoritesManager getInstance(Project project) { return project.getComponent(FavoritesManager.class); } @@ -87,31 +122,45 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable { myProject = project; } - @NotNull public String[] getAvailableFavoritesLists(){ + @NotNull public String[] getAvailableFavoritesListNames(){ final Set keys = myName2FavoritesRoots.keySet(); return ArrayUtil.toStringArray(keys); } - public synchronized void createNewList(@NotNull String name){ - myName2FavoritesRoots.put(name, new LinkedHashSet>()); + public synchronized boolean allowsTree(@NotNull final String name) { + return myAllowsTreeLists.contains(name); + } + + public synchronized void createNewList(@NotNull String name, boolean readOnly, boolean allowsTree){ + myName2FavoritesRoots.put(name, new ArrayList>>()); + if (readOnly) { + myReadOnlyLists.add(name); + } + if (allowsTree) { + myAllowsTreeLists.add(name); + } fireListeners.listAdded(name); } + public synchronized void fireListeners(@NotNull final String listName) { + fireListeners.rootsChanged(listName); + } + public FavoritesViewSettings getViewSettings() { return myViewSettings; } public synchronized boolean removeFavoritesList(@NotNull String name){ - if (name.equals(myProject.getName())) return false; + if (myReadOnlyLists.contains(name)) return false; boolean result = myName2FavoritesRoots.remove(name) != null; fireListeners.listRemoved(name); return result; } @NotNull - public Collection> getFavoritesListRootUrls(@NotNull String name) { - final LinkedHashSet> pairs = myName2FavoritesRoots.get(name); - return pairs == null ? Collections.>emptyList() : pairs; + public List>> getFavoritesListRootUrls(@NotNull String name) { + final List>> pairs = myName2FavoritesRoots.get(name); + return pairs == null ? Collections.>>emptyList() : pairs; } public synchronized boolean addRoots(@NotNull String name, Module moduleContext, @NotNull Object elements) { @@ -119,27 +168,139 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable { return !nodes.isEmpty() && addRoots(name, nodes); } + public synchronized Comparator getCustomComparator(@NotNull final String name) { + return myComparators.get(name); + } + + private Pair createPairForNode(AbstractTreeNode node) { + final String className = node.getClass().getName(); + final Object value = node.getValue(); + final AbstractUrl url = createUrlByElement(value, myProject); + if (url == null) return null; + return Pair.create(url, className); + } + public boolean addRoots(final String name, final Collection nodes) { - final Collection> list = getFavoritesListRootUrls(name); + final Collection>> list = getFavoritesListRootUrls(name); for (AbstractTreeNode node : nodes) { - final String className = node.getClass().getName(); - final Object value = node.getValue(); - final AbstractUrl url = createUrlByElement(value, myProject); - if (url != null) { - list.add(Pair.create(url, className)); + final Pair pair = createPairForNode(node); + if (pair != null) { + final TreeItem> treeItem = new TreeItem>(pair); + list.add(treeItem); + appendChildNodes(node, treeItem); } } fireListeners.rootsChanged(name); return true; } - public synchronized boolean removeRoot(@NotNull String name, @NotNull Object element) { - AbstractUrl url = createUrlByElement(element, myProject); + private void appendChildNodes(AbstractTreeNode node, TreeItem> treeItem) { + final Collection children = node.getChildren(); + for (AbstractTreeNode child : children) { + final TreeItem> childTreeItem = new TreeItem>(createPairForNode(child)); + treeItem.addChild(childTreeItem); + appendChildNodes(child, childTreeItem); + } + } + + public synchronized boolean addRoot(@NotNull String name, + @NotNull List parentElements, + final AbstractTreeNode newElement, + @Nullable AbstractTreeNode sibling) { + final List>> items = myName2FavoritesRoots.get(name); + if (items == null) return false; + AbstractUrl url = createUrlByElement(newElement.getValue(), myProject); if (url == null) return false; - Collection> list = getFavoritesListRootUrls(name); - Pair found = null; - for (Pair pair : list) { - if (url.equals(pair.getFirst())) { + final TreeItem> newItem = + new TreeItem>(Pair.create(url, newElement.getClass().getName())); + + if (parentElements.isEmpty()) { + // directly to list + if (sibling != null) { + TreeItem> after = null; + AbstractUrl siblingUrl = createUrlByElement(sibling.getValue(), myProject); + int idx = -1; + for (int i = 0; i < items.size(); i++) { + TreeItem> item = items.get(i); + if (item.getData().getFirst().equals(siblingUrl)) { + idx = i; + break; + } + } + if (idx != -1) { + items.add(idx, newItem); + } else { + items.add(newItem); + } + } else { + items.add(newItem); + } + + fireListeners.rootsChanged(name); + return true; + } + + Collection>> list = items; + TreeItem> item = null; + for (AbstractTreeNode obj : parentElements) { + item = findNextItem(obj, list); + if (item == null) return false; + list = item.getChildren(); + } + + if (sibling != null) { + TreeItem> after = null; + AbstractUrl siblingUrl = createUrlByElement(sibling.getValue(), myProject); + for (TreeItem> treeItem : list) { + if (treeItem.getData().getFirst().equals(siblingUrl)) { + after = treeItem; + break; + } + } + if (after == null) { + item.addChild(newItem); + } else { + item.addChildAfter(newItem, after); + } + } else { + item.addChild(newItem); + } + fireListeners.rootsChanged(name); + return true; + } + + public synchronized boolean editRoot(@NotNull String name, @NotNull List elementsIndexes, final AbstractTreeNode newElement) { + List>> list = getFavoritesListRootUrls(name); + assert list != null; + for (Integer index : elementsIndexes.subList(0, elementsIndexes.size() - 1)) { + assert index >= 0 && index < list.size(); + final TreeItem> item = list.get(index); + list = item.getChildren(); + } + assert list != null && ! list.isEmpty(); + final Object value = newElement.getValue(); + final AbstractUrl urlByElement = createUrlByElement(value, myProject); + if (urlByElement == null) return false; + list.set(elementsIndexes.get(elementsIndexes.size() - 1).intValue(), new TreeItem>(Pair.create(urlByElement, newElement.getClass().getName()))); + return true; + } + + public synchronized boolean removeRoot(@NotNull String name, @NotNull List elements) { + Collection>> list = getFavoritesListRootUrls(name); + if (elements.size() > 1) { + final List sublist = elements.subList(0, elements.size() - 1); + for (AbstractTreeNode obj : sublist) { + final TreeItem> item = findNextItem(obj, list); + if (item == null || item.getChildren() == null) return false; + list = item.getChildren(); + } + } + + TreeItem> found = null; + AbstractUrl url = createUrlByElement(elements.get(elements.size() - 1).getValue(), myProject); + if (url == null) return false; + for (TreeItem> pair : list) { + if (url.equals(pair.getData().getFirst())) { found = pair; break; } @@ -149,11 +310,23 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable { fireListeners.rootsChanged(name); return true; } + return false; } + private TreeItem> findNextItem(AbstractTreeNode obj, Collection>> list) { + AbstractUrl url = createUrlByElement(obj.getValue(), myProject); + for (TreeItem> pair : list) { + if (url.equals(pair.getData().getFirst())) { + return pair; + } + } + return null; + } + public synchronized boolean renameFavoritesList(@NotNull String oldName, @NotNull String newName) { - LinkedHashSet> list = myName2FavoritesRoots.remove(oldName); + if (myReadOnlyLists.contains(oldName)) return false; + List>> list = myName2FavoritesRoots.remove(oldName); if (list != null && newName.length() > 0) { myName2FavoritesRoots.put(newName, list); fireListeners.listRemoved(oldName); @@ -163,6 +336,10 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable { return false; } + public synchronized boolean isReadOnly(@NotNull final String listName) { + return myReadOnlyLists.contains(listName); + } + public void initComponent() { } @@ -171,9 +348,34 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable { public void projectOpened() { StartupManager.getInstance(myProject).registerPostStartupActivity(new DumbAwareRunnable() { public void run() { - if (myName2FavoritesRoots.isEmpty()) { - final String name = myProject.getName(); - createNewList(name); + final FavoritesListProvider[] extensions = Extensions.getExtensions(FavoritesListProvider.EP_NAME, myProject); + for (FavoritesListProvider extension : extensions) { + final String name = extension.getListName(myProject); + if (! myName2FavoritesRoots.containsKey(name)) { + createNewList(name, extension.canBeRemoved(), extension.isTreeLike()); + } else if (! myReadOnlyLists.contains(name) && ! extension.canBeRemoved()) { + myReadOnlyLists.add(name); + } + final FavoritesListProvider.Operation addOperation = extension.getCustomAddOperation(); + if (! myAddHandlers.containsKey(name)) { + myAddHandlers.put(name, addOperation); + } + final FavoritesListProvider.Operation editOperation = extension.getCustomEditOperation(); + if (! myEditHandlers.containsKey(name)) { + myEditHandlers.put(name, editOperation); + } + final FavoritesListProvider.Operation deleteOperation = extension.getCustomDeleteOperation(); + if (! myDeleteHandlers.containsKey(name)) { + myDeleteHandlers.put(name, deleteOperation); + } + final TreeCellRenderer treeCellRenderer = extension.getTreeCellRenderer(); + if (treeCellRenderer != null && ! myCustomRenderers.containsKey(name)) { + myCustomRenderers.put(name, treeCellRenderer); + } + final Comparator comparator = extension.getNodeDescriptorComparator(); + if (comparator != null && ! myComparators.containsKey(name)) { + myComparators.put(name, comparator); + } } final MyRootsChangeAdapter myPsiTreeChangeAdapter = new MyRootsChangeAdapter(); @@ -190,11 +392,15 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable { return "FavoritesManager"; } + public synchronized TreeCellRenderer getCustomRenderer(@NotNull final String name) { + return myCustomRenderers.get(name); + } + public void readExternal(Element element) throws InvalidDataException { myName2FavoritesRoots.clear(); for (Object list : element.getChildren(ELEMENT_FAVORITES_LIST)) { final String name = ((Element)list).getAttributeValue(ATTRIBUTE_NAME); - LinkedHashSet> roots = readRoots((Element)list, myProject); + List>> roots = readRoots((Element)list, myProject); myName2FavoritesRoots.put(name, roots); } DefaultJDOMExternalizer.readExternal(this, element); @@ -204,16 +410,26 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable { @NonNls private static final String FAVORITES_ROOT = "favorite_root"; @NonNls private static final String ELEMENT_FAVORITES_LIST = "favorites_list"; @NonNls private static final String ATTRIBUTE_NAME = "name"; - private static LinkedHashSet> readRoots(final Element list, Project project) { - LinkedHashSet> result = new LinkedHashSet>(); - for (Object favorite : list.getChildren(FAVORITES_ROOT)) { - final String className = ((Element)favorite).getAttributeValue(CLASS_NAME); - final AbstractUrl abstractUrl = readUrlFromElement((Element)favorite, project); + private static List>> readRoots(final Element list, Project project) { + List>> result = new ArrayList>>(); + readFavoritesOneLevel(list, project, result); + return result; + } + + private static void readFavoritesOneLevel(Element list, Project project, Collection>> result) { + final List listChildren = list.getChildren(FAVORITES_ROOT); + if (listChildren == null || listChildren.isEmpty()) return; + + for (Object favorite : listChildren) { + final Element favoriteElement = (Element)favorite; + final String className = favoriteElement.getAttributeValue(CLASS_NAME); + final AbstractUrl abstractUrl = readUrlFromElement(favoriteElement, project); if (abstractUrl != null) { - result.add(Pair.create(abstractUrl, className)); + final TreeItem> treeItem = new TreeItem>(Pair.create(abstractUrl, className)); + result.add(treeItem); + readFavoritesOneLevel(favoriteElement, project, treeItem.getChildren()); } } - return result; } private static final ArrayList ourAbstractUrlProviders = new ArrayList(); @@ -279,18 +495,22 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable { return null; } - private static void writeRoots(Element element, LinkedHashSet> roots) { - for (Pair root : roots) { - final AbstractUrl url = root.getFirst(); + private static void writeRoots(Element element, Collection>> roots) { + for (TreeItem> root : roots) { + final AbstractUrl url = root.getData().getFirst(); if (url == null) continue; final Element list = new Element(FAVORITES_ROOT); url.write(list); - list.setAttribute(CLASS_NAME, root.getSecond()); + list.setAttribute(CLASS_NAME, root.getData().getSecond()); element.addContent(list); + final List>> children = root.getChildren(); + if (children != null && ! children.isEmpty()) { + writeRoots(list, children); + } } } - + // currently only one level here.. public boolean contains(@NotNull String name, @NotNull final VirtualFile vFile){ final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); final Set find = new HashSet(); @@ -303,9 +523,9 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable { } }; - Collection> urls = getFavoritesListRootUrls(name); - for (Pair pair : urls) { - AbstractUrl abstractUrl = pair.getFirst(); + Collection>> urls = getFavoritesListRootUrls(name); + for (TreeItem> pair : urls) { + AbstractUrl abstractUrl = pair.getData().getFirst(); if (abstractUrl == null) { continue; } @@ -377,6 +597,19 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable { return false; } + private void iterateTreeItems(final Collection>> coll, Consumer>> consumer) { + final ArrayDeque>> queue = new ArrayDeque>>(); + queue.addAll(coll); + while (! queue.isEmpty()) { + final TreeItem> item = queue.removeFirst(); + consumer.consume(item); + final List>> children = item.getChildren(); + if (children != null && ! children.isEmpty()) { + queue.addAll(children); + } + } + } + private class MyRootsChangeAdapter extends PsiTreeChangeAdapter { public void beforeChildMovement(@NotNull final PsiTreeChangeEvent event) { final PsiElement oldParent = event.getOldParent(); @@ -393,26 +626,29 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable { childUrl = new DirectoryUrl(((PsiDirectory)newParent).getVirtualFile().getUrl() + "/" + ((PsiDirectory)child).getName(), module.getName()); } + for (String listName : myName2FavoritesRoots.keySet()) { - final LinkedHashSet> roots = myName2FavoritesRoots.get(listName); - final LinkedHashSet> newRoots = new LinkedHashSet>(); - for (Pair root : roots) { - final Object[] path = root.first.createPath(myProject); - if (path == null || path.length < 1 || path[0] == null) { - continue; - } - final Object element = path[path.length - 1]; - if (element == child && childUrl != null) { - newRoots.add(Pair.create(childUrl, root.second)); - } - else { - if (element == oldParent) { - newRoots.add(Pair.create(root.first.createUrlByElement(newParent), root.second)); + final List>> roots = myName2FavoritesRoots.get(listName); + final AbstractUrl finalChildUrl = childUrl; + iterateTreeItems(roots, new Consumer>>() { + @Override + public void consume(TreeItem> item) { + final Pair root = item.getData(); + final Object[] path = root.first.createPath(myProject); + if (path == null || path.length < 1 || path[0] == null) { + return; + } + final Object element = path[path.length - 1]; + if (element == child && finalChildUrl != null) { + item.setData(Pair.create(finalChildUrl, root.second)); + } + else { + if (element == oldParent) { + item.setData(Pair.create(root.first.createUrlByElement(newParent), root.second)); + } } - newRoots.add(root); } - } - myName2FavoritesRoots.put(listName, newRoots); + }); } } } @@ -425,22 +661,26 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable { if (module == null) return; final String url = ((PsiDirectory)psiElement.getParent()).getVirtualFile().getUrl() + "/" + event.getNewValue(); final AbstractUrl childUrl = psiElement instanceof PsiFile ? new PsiFileUrl(url) : new DirectoryUrl(url, module.getName()); + for (String listName : myName2FavoritesRoots.keySet()) { - final LinkedHashSet> roots = myName2FavoritesRoots.get(listName); - final LinkedHashSet> newRoots = new LinkedHashSet>(); - for (Pair root : roots) { - final Object[] path = root.first.createPath(myProject); - if (path == null || path.length < 1 || path[0] == null) { - continue; + final List>> roots = myName2FavoritesRoots.get(listName); + iterateTreeItems(roots, new Consumer>>() { + @Override + public void consume(TreeItem> item) { + final Pair root = item.getData(); + final Object[] path = root.first.createPath(myProject); + if (path == null || path.length < 1 || path[0] == null) { + return; + } + final Object element = path[path.length - 1]; + if (element == psiElement && psiElement instanceof PsiFile) { + item.setData(Pair.create(childUrl, root.second)); + } + else { + item.setData(root); + } } - final Object element = path[path.length - 1]; - if (element == psiElement && psiElement instanceof PsiFile) { - newRoots.add(Pair.create(childUrl, root.second)); - } else { - newRoots.add(root); - } - } - myName2FavoritesRoots.put(listName, newRoots); + }); } } } diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesPanel.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesPanel.java index d2e0864f3941..a2066fbed8fe 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesPanel.java @@ -34,6 +34,7 @@ import javax.swing.tree.TreePath; import java.awt.*; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; /** * @author Konstantin Bulenkov @@ -73,6 +74,7 @@ public class FavoritesPanel { return new DnDDragStartBean(""); } }) + // todo process drag-and-drop here for tasks .setTargetChecker(new DnDTargetChecker() { @Override public boolean update(DnDEvent event) { @@ -132,9 +134,9 @@ public class FavoritesPanel { final String listFrom = getListNodeFromPath(path).getValue(); if (listTo.equals(listFrom)) return; if (path.getPathCount() == 3) { - final Object element = ((FavoritesTreeNodeDescriptor)((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject()) + final AbstractTreeNode element = (AbstractTreeNode)((FavoritesTreeNodeDescriptor)((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject()) .getElement().getValue(); - mgr.removeRoot(listFrom, element); + mgr.removeRoot(listFrom, Collections.singletonList(element)); mgr.addRoots(listTo, null, element); } } @@ -143,7 +145,8 @@ public class FavoritesPanel { if (elements != null && elements.length > 0) { ArrayList nodes = new ArrayList(); for (PsiElement element : elements) { - final Collection tmp = AddToFavoritesAction.createNodes(myProject, null, element, true, FavoritesManager.getInstance(myProject).getViewSettings()); + final Collection tmp = AddToFavoritesAction + .createNodes(myProject, null, element, true, FavoritesManager.getInstance(myProject).getViewSettings()); nodes.addAll(tmp); mgr.addRoots(listTo, nodes); } @@ -171,7 +174,7 @@ public class FavoritesPanel { } return null; } - + @Nullable private FavoritesListNode findFavoritesListNode(Point point) { diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesProjectViewPane.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesProjectViewPane.java index 3965f1a6cc87..b0c9b0a69c28 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesProjectViewPane.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesProjectViewPane.java @@ -69,7 +69,7 @@ public class FavoritesProjectViewPane extends AbstractProjectViewPane { myProjectView.addProjectPane(FavoritesProjectViewPane.this); myFavoritesManager.addFavoritesListener(myFavoritesListener); - if (ArrayUtil.find(myFavoritesManager.getAvailableFavoritesLists(), listName) == -1) { + if (ArrayUtil.find(myFavoritesManager.getAvailableFavoritesListNames(), listName) == -1) { listName = null; } myProjectView.changeView(ID, listName); @@ -113,7 +113,7 @@ public class FavoritesProjectViewPane extends AbstractProjectViewPane { @NotNull public String[] getSubIds() { - return myFavoritesManager.getAvailableFavoritesLists(); + return myFavoritesManager.getAvailableFavoritesListNames(); } @NotNull diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesRootNode.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesRootNode.java index 03b690e33698..cdbf688563de 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesRootNode.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesRootNode.java @@ -39,8 +39,9 @@ public class FavoritesRootNode extends AbstractTreeNode { public Collection getChildren() { if (myFavoritesRoots == null) { myFavoritesRoots = new ArrayList(); - for (String list : FavoritesManager.getInstance(myProject).getAvailableFavoritesLists()) { - myFavoritesRoots.add(new FavoritesListNode(myProject, list)); + final FavoritesManager favoritesManager = FavoritesManager.getInstance(myProject); + for (String list : favoritesManager.getAvailableFavoritesListNames()) { + myFavoritesRoots.add(new FavoritesListNode(myProject, list, favoritesManager.allowsTree(list))); } } return myFavoritesRoots; diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeStructure.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeStructure.java index 442685b29c7f..ba38609b0adc 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeStructure.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeStructure.java @@ -29,10 +29,10 @@ import com.intellij.psi.SmartPsiElementPointer; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; -import java.util.Set; +import java.util.List; /** * @author Konstantin Bulenkov @@ -62,8 +62,10 @@ public class FavoritesTreeStructure extends ProjectTreeStructure { return super.getChildElements(favTreeElement); } - final Set result = new HashSet(); - for (AbstractTreeNode abstractTreeNode : FavoritesListNode.getFavoritesRoots(myProject, ((FavoritesListNode)element).getName())) { + final List result = new ArrayList(); + final FavoritesListNode listNode = (FavoritesListNode)element; + final Collection roots = FavoritesListNode.getFavoritesRoots(myProject, listNode.getName(), listNode); + for (AbstractTreeNode abstractTreeNode : roots) { final Object value = abstractTreeNode.getValue(); if (value == null) continue; diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeUtil.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeUtil.java new file mode 100644 index 000000000000..3abb8d3a08d1 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeUtil.java @@ -0,0 +1,120 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.ide.dnd.aware.DnDAwareTree; +import com.intellij.ide.util.treeView.AbstractTreeNode; +import org.jetbrains.annotations.NotNull; + +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreePath; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/9/12 + * Time: 5:33 PM + */ +public class FavoritesTreeUtil { + @NotNull + public static FavoritesTreeNodeDescriptor[] getSelectedNodeDescriptors(final DnDAwareTree tree) { + TreePath[] path = tree.getSelectionPaths(); + if (path == null) { + return FavoritesTreeNodeDescriptor.EMPTY_ARRAY; + } + ArrayList result = new ArrayList(); + for (TreePath treePath : path) { + DefaultMutableTreeNode lastPathNode = (DefaultMutableTreeNode)treePath.getLastPathComponent(); + Object userObject = lastPathNode.getUserObject(); + if (!(userObject instanceof FavoritesTreeNodeDescriptor)) { + continue; + } + FavoritesTreeNodeDescriptor treeNodeDescriptor = (FavoritesTreeNodeDescriptor)userObject; + result.add(treeNodeDescriptor); + } + return result.toArray(new FavoritesTreeNodeDescriptor[result.size()]); + } + + public static List getLogicalPathToSelected(final DnDAwareTree tree) { + final List result = new ArrayList(); + final TreePath selectionPath = tree.getSelectionPath(); + return getLogicalPathTo(result, selectionPath); + } + + public static List getLogicalIndexPathTo(TreePath selectionPath) { + final List result = new ArrayList(); + final Object component = selectionPath.getLastPathComponent(); + if (component instanceof DefaultMutableTreeNode) { + final Object uo = ((DefaultMutableTreeNode)component).getUserObject(); + if (uo instanceof FavoritesTreeNodeDescriptor) { + AbstractTreeNode treeNode = ((FavoritesTreeNodeDescriptor)uo).getElement(); + while ((! (treeNode instanceof FavoritesListNode)) && treeNode != null) { +// final int idx = getIndex(treeNode.getParent().getChildren(), treeNode); +// if (idx == -1) return null; + result.add(treeNode.getIndex()); + treeNode = treeNode.getParent(); + } + Collections.reverse(result); + return result; + } + } + return Collections.emptyList(); + } + + /*private static int getIndex(Collection children, AbstractTreeNode node) { + int idx = 0; + for (AbstractTreeNode child : children) { + if (child == node) { + return idx; + } + ++ idx; + } + assert false; + return -1; + }*/ + + public static List getLogicalPathTo(List result, TreePath selectionPath) { + final Object component = selectionPath.getLastPathComponent(); + if (component instanceof DefaultMutableTreeNode) { + final Object uo = ((DefaultMutableTreeNode)component).getUserObject(); + if (uo instanceof FavoritesTreeNodeDescriptor) { + AbstractTreeNode treeNode = ((FavoritesTreeNodeDescriptor)uo).getElement(); + while ((! (treeNode instanceof FavoritesListNode)) && treeNode != null) { + result.add(treeNode); + treeNode = treeNode.getParent(); + } + Collections.reverse(result); + return result; + } + } + return Collections.emptyList(); + } + + public static FavoritesListNode extractParentList(FavoritesTreeNodeDescriptor descriptor) { + final AbstractTreeNode node = descriptor.getElement(); + AbstractTreeNode current = node; + while (current != null) { + if (current instanceof FavoritesListNode) { + return (FavoritesListNode) current; + } + current = current.getParent(); + } + return null; + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java index 510ce562be71..93cdcfe78a18 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java @@ -34,6 +34,7 @@ import com.intellij.ide.util.DeleteHandler; import com.intellij.ide.util.DirectoryChooserUtil; import com.intellij.ide.util.EditorHelper; import com.intellij.ide.util.treeView.AbstractTreeNode; +import com.intellij.ide.util.treeView.NodeDescriptor; import com.intellij.ide.util.treeView.NodeRenderer; import com.intellij.navigation.ItemPresentation; import com.intellij.openapi.actionSystem.*; @@ -64,11 +65,12 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreePath; +import javax.swing.tree.TreeCellRenderer; import java.awt.*; import java.awt.event.MouseListener; import java.util.ArrayList; import java.util.Arrays; +import java.util.Comparator; import java.util.List; /** @@ -76,12 +78,14 @@ import java.util.List; * @author Konstantin Bulenkov */ public class FavoritesTreeViewPanel extends JPanel implements DataProvider { + public static final String NEW_FAVORITES_LIST = "New Favorites List..."; private final FavoritesTreeStructure myFavoritesTreeStructure; private FavoritesViewTreeBuilder myBuilder; private final CopyPasteDelegator myCopyPasteDelegator; private final MouseListener myTreePopupHandler; public static final DataKey CONTEXT_FAVORITES_ROOTS_DATA_KEY = DataKey.create("FavoritesRoot"); + public static final DataKey FAVORITES_TREE_KEY = DataKey.create("Favorites.Tree"); public static final DataKey FAVORITES_LIST_NAME_DATA_KEY = DataKey.create("FavoritesListName"); protected Project myProject; @@ -89,25 +93,16 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider { private final MyDeletePSIElementProvider myDeletePSIElementProvider = new MyDeletePSIElementProvider(); private final ModuleDeleteProvider myDeleteModuleProvider = new ModuleDeleteProvider(); - private final AutoScrollToSourceHandler myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { - @Override - protected boolean isAutoScrollMode() { - return FavoritesManager.getInstance(myProject).getViewSettings().isAutoScrollToSource(); - } - - @Override - protected void setAutoScrollMode(boolean state) { - FavoritesManager.getInstance(myProject).getViewSettings().setAutoScrollToSource(state); - } - }; - - + private final AutoScrollToSourceHandler myAutoScrollToSourceHandler; private final IdeView myIdeView = new MyIdeView(); + private final FavoritesManager myFavoritesManager; + private final NodeRenderer myNodeRenderer; public FavoritesTreeViewPanel(Project project) { super(new BorderLayout()); myProject = project; + myFavoritesManager = FavoritesManager.getInstance(myProject); myFavoritesTreeStructure = new FavoritesTreeStructure(project); DefaultMutableTreeNode root = new DefaultMutableTreeNode(); @@ -121,9 +116,26 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider { myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.setLargeModel(true); + myTree.setRowHeight(0); new TreeSpeedSearch(myTree); ToolTipManager.sharedInstance().registerComponent(myTree); - myTree.setCellRenderer(new NodeRenderer() { + myBuilder.setNodeDescriptorComparator(new Comparator() { + @Override + public int compare(NodeDescriptor o1, NodeDescriptor o2) { + if (o1 instanceof FavoritesTreeNodeDescriptor && o2 instanceof FavoritesTreeNodeDescriptor) { + final FavoritesListNode listNode1 = FavoritesTreeUtil.extractParentList((FavoritesTreeNodeDescriptor)o1); + final FavoritesListNode listNode2 = FavoritesTreeUtil.extractParentList((FavoritesTreeNodeDescriptor)o2); + if (listNode1.equals(listNode2)) { + final Comparator comparator = myFavoritesManager.getCustomComparator(listNode1.getName()); + if (comparator != null) { + return comparator.compare((FavoritesTreeNodeDescriptor) o1, (FavoritesTreeNodeDescriptor) o2); + } + } + } + return o1.getIndex() - o2.getIndex(); + } + }); + myNodeRenderer = new NodeRenderer() { public void customizeCellRenderer(JTree tree, Object value, boolean selected, @@ -153,6 +165,41 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider { } } } + }; + myTree.setCellRenderer(new TreeCellRenderer() { + @Override + public Component getTreeCellRendererComponent(JTree tree, + Object value, + boolean selected, + boolean expanded, + boolean leaf, + int row, + boolean hasFocus) { + if (value instanceof DefaultMutableTreeNode) { + final DefaultMutableTreeNode node = (DefaultMutableTreeNode)value; + //only favorites roots to explain + final Object userObject = node.getUserObject(); + if (userObject instanceof FavoritesTreeNodeDescriptor) { + final FavoritesTreeNodeDescriptor favoritesTreeNodeDescriptor = (FavoritesTreeNodeDescriptor)userObject; + AbstractTreeNode treeNode = favoritesTreeNodeDescriptor.getElement(); + while (treeNode != null && (!(treeNode instanceof FavoritesListNode))) { + treeNode = treeNode.getParent(); + } + if (treeNode != null) { + final String name = ((FavoritesListNode)treeNode).getValue(); + final TreeCellRenderer customRenderer = myFavoritesManager.getCustomRenderer(name); + if (customRenderer != null) { + final Component component = + customRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); + if (component != null) { + return component; + } + } + } + } + } + return myNodeRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); + } }); myTreePopupHandler = CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_FAVORITES_VIEW_POPUP, ActionPlaces.FAVORITES_VIEW_POPUP); @@ -167,18 +214,41 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider { } }; - ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTree) - .setAddAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - AddNewFavoritesListAction.doAddNewFavoritesList(myProject); + final AnActionButtonRunnable addListOrNoteAction = new AnActionButtonRunnable() { + @Override + public void run(AnActionButton button) { + final List nodes = getSelectedListsNodes(); + if (nodes.size() == 1) { + final FavoritesListProvider.Operation customAdd = myFavoritesManager.getCustomAdd(nodes.get(0).getName()); + if (customAdd != null && customAdd.willHandle(myTree)) { + customAdd.handle(myProject, myTree); + return; + } } - }) + AddNewFavoritesListAction.doAddNewFavoritesList(myProject); + } + }; + final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTree) + .setAddAction(addListOrNoteAction) .setLineBorder(0, 0, 1, 0) - .setAddActionName("New Favorites List") + .setAddActionName(NEW_FAVORITES_LIST) .disableRemoveAction() .disableDownAction() .disableUpAction() + .setAddActionUpdater(new AnActionButtonUpdater() { + @Override + public boolean isEnabled(AnActionEvent e) { + e.getPresentation().setText(NEW_FAVORITES_LIST); + final List nodes = getSelectedListsNodes(); + if (nodes.size() == 1) { + final FavoritesListProvider.Operation customAdd = myFavoritesManager.getCustomAdd(nodes.get(0).getName()); + if (customAdd != null && customAdd.willHandle(myTree)) { + e.getPresentation().setText(customAdd.getCustomName()); + } + } + return true; + } + }) .addExtraAction(new DeleteFromFavoritesAction() { { getTemplatePresentation().setIcon(IconUtil.getRemoveIcon()); @@ -188,15 +258,54 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider { public ShortcutSet getShortcut() { return CustomShortcutSet.fromString("DELETE"); } + }).addExtraAction(new AnActionButton("Edit", AllIcons.Actions.Edit) { + @Override + public ShortcutSet getShortcut() { + return CommonShortcuts.getRename(); + } + + @Override + public void actionPerformed(AnActionEvent e) { + final List nodes = getSelectedListsNodes(); + if (nodes.size() == 1) { + final FavoritesListProvider.Operation customEdit = myFavoritesManager.getCustomEdit(nodes.get(0).getName()); + if (customEdit != null && customEdit.willHandle(myTree)) { + customEdit.handle(myProject, myTree); + } + } + } + + @Override + public boolean isEnabled() { + final List nodes = getSelectedListsNodes(); + if (nodes.size() == 1) { + final FavoritesListProvider.Operation customEdit = myFavoritesManager.getCustomEdit(nodes.get(0).getName()); + if (customEdit != null && customEdit.willHandle(myTree)) { + return true; + } + } + return false; + } }); - AnAction action = ActionManager.getInstance().getAction(IdeActions.ACTION_NEW_ELEMENT); + final AnAction action = ActionManager.getInstance().getAction(IdeActions.ACTION_NEW_ELEMENT); action.registerCustomShortcutSet(action.getShortcutSet(), myTree); final JPanel panel = decorator.createPanel(); panel.setBorder(IdeBorderFactory.createEmptyBorder(0)); add(panel, BorderLayout.CENTER); setBorder(IdeBorderFactory.createEmptyBorder(0)); + myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { + @Override + protected boolean isAutoScrollMode() { + return myFavoritesManager.getViewSettings().isAutoScrollToSource(); + } + + @Override + protected void setAutoScrollMode(boolean state) { + myFavoritesManager.getViewSettings().setAutoScrollToSource(state); + } + }; myAutoScrollToSourceHandler.install(myTree); } @@ -251,7 +360,7 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider { return myProject; } if (PlatformDataKeys.NAVIGATABLE.is(dataId)) { - final FavoritesTreeNodeDescriptor[] selectedNodeDescriptors = getSelectedNodeDescriptors(); + final FavoritesTreeNodeDescriptor[] selectedNodeDescriptors = FavoritesTreeUtil.getSelectedNodeDescriptors(myTree); return selectedNodeDescriptors.length == 1 ? selectedNodeDescriptors[0].getElement() : null; } if (PlatformDataKeys.NAVIGATABLE_ARRAY.is(dataId)) { @@ -271,6 +380,9 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider { if (PlatformDataKeys.HELP_ID.is(dataId)) { return "reference.toolWindows.favorites"; } + if (LangDataKeys.NO_NEW_ACTION.is(dataId)) { + return Boolean.TRUE; + } if (LangDataKeys.PSI_ELEMENT.is(dataId)) { PsiElement[] elements = getSelectedPsiElements(); if (elements.length != 1) { @@ -326,7 +438,7 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider { } if (CONTEXT_FAVORITES_ROOTS_DATA_KEY.is(dataId)) { List result = new ArrayList(); - FavoritesTreeNodeDescriptor[] selectedNodeDescriptors = getSelectedNodeDescriptors(); + FavoritesTreeNodeDescriptor[] selectedNodeDescriptors = FavoritesTreeUtil.getSelectedNodeDescriptors(myTree); for (FavoritesTreeNodeDescriptor selectedNodeDescriptor : selectedNodeDescriptors) { FavoritesTreeNodeDescriptor root = selectedNodeDescriptor.getFavoritesRoot(); if (root != null && root.getElement() instanceof FavoritesListNode) { @@ -335,8 +447,11 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider { } return result.toArray(new FavoritesTreeNodeDescriptor[result.size()]); } + if (FAVORITES_TREE_KEY.is(dataId)) { + return myTree; + } if (FAVORITES_LIST_NAME_DATA_KEY.is(dataId)) { - final FavoritesTreeNodeDescriptor[] descriptors = getSelectedNodeDescriptors(); + final FavoritesTreeNodeDescriptor[] descriptors = FavoritesTreeUtil.getSelectedNodeDescriptors(myTree); if (descriptors.length == 1) { final AbstractTreeNode node = descriptors[0].getElement(); if (node instanceof FavoritesListNode) { @@ -345,7 +460,7 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider { } return null; } - FavoritesTreeNodeDescriptor[] descriptors = getSelectedNodeDescriptors(); + FavoritesTreeNodeDescriptor[] descriptors = FavoritesTreeUtil.getSelectedNodeDescriptors(myTree); if (descriptors.length > 0) { List nodes = new ArrayList(); for (FavoritesTreeNodeDescriptor descriptor : descriptors) { @@ -356,6 +471,18 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider { return null; } + private List getSelectedListsNodes() { + final List result = new SmartList(); + final FavoritesTreeNodeDescriptor[] descriptors = FavoritesTreeUtil.getSelectedNodeDescriptors(myTree); + for (FavoritesTreeNodeDescriptor descriptor : descriptors) { + final FavoritesListNode listNode = FavoritesTreeUtil.extractParentList(descriptor); + if (listNode != null) { + result.add(listNode); + } + } + return result; + } + private List getSelectedElements(Class klass) { final Object[] elements = getSelectedNodeElements(); ArrayList result = new ArrayList(); @@ -390,7 +517,7 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider { } private Object[] getSelectedNodeElements() { - final FavoritesTreeNodeDescriptor[] selectedNodeDescriptors = getSelectedNodeDescriptors(); + final FavoritesTreeNodeDescriptor[] selectedNodeDescriptors = FavoritesTreeUtil.getSelectedNodeDescriptors(myTree); ArrayList result = new ArrayList(); for (FavoritesTreeNodeDescriptor selectedNodeDescriptor : selectedNodeDescriptors) { if (selectedNodeDescriptor != null) { @@ -404,25 +531,6 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider { return ArrayUtil.toObjectArray(result); } - @NotNull - public FavoritesTreeNodeDescriptor[] getSelectedNodeDescriptors() { - TreePath[] path = myTree.getSelectionPaths(); - if (path == null) { - return FavoritesTreeNodeDescriptor.EMPTY_ARRAY; - } - ArrayList result = new ArrayList(); - for (TreePath treePath : path) { - DefaultMutableTreeNode lastPathNode = (DefaultMutableTreeNode)treePath.getLastPathComponent(); - Object userObject = lastPathNode.getUserObject(); - if (!(userObject instanceof FavoritesTreeNodeDescriptor)) { - continue; - } - FavoritesTreeNodeDescriptor treeNodeDescriptor = (FavoritesTreeNodeDescriptor)userObject; - result.add(treeNodeDescriptor); - } - return result.toArray(new FavoritesTreeNodeDescriptor[result.size()]); - } - public void setupToolWindow(ToolWindowEx window) { final CollapseAllAction collapseAction = new CollapseAllAction(myTree); collapseAction.getTemplatePresentation().setIcon(AllIcons.General.CollapseAll); diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesViewSelectInTarget.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesViewSelectInTarget.java index ed52ffd3afee..254f0d0ce22c 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesViewSelectInTarget.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesViewSelectInTarget.java @@ -112,7 +112,7 @@ public class FavoritesViewSelectInTarget extends SelectInTargetPsiWrapper { public static String findSuitableFavoritesList(VirtualFile file, Project project, final String currentSubId) { final FavoritesManager favoritesManager = FavoritesManager.getInstance(project); if (currentSubId != null && favoritesManager.contains(currentSubId, file)) return currentSubId; - final String[] lists = favoritesManager.getAvailableFavoritesLists(); + final String[] lists = favoritesManager.getAvailableFavoritesListNames(); for (String name : lists) { if (favoritesManager.contains(name, file)) return name; } diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FileGroupingProjectNode.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FileGroupingProjectNode.java new file mode 100644 index 000000000000..4f7704a0e40d --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FileGroupingProjectNode.java @@ -0,0 +1,87 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.icons.AllIcons; +import com.intellij.ide.projectView.PresentationData; +import com.intellij.ide.projectView.ViewSettings; +import com.intellij.openapi.fileEditor.OpenFileDescriptor; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; + +import java.io.File; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/8/12 + * Time: 12:23 PM + */ +public class FileGroupingProjectNode extends ProjectViewNodeWithChildrenList { + private VirtualFile myVirtualFile; + + public FileGroupingProjectNode(Project project, File file, ViewSettings viewSettings) { + super(project, file, viewSettings); + final LocalFileSystem lfs = LocalFileSystem.getInstance(); + myVirtualFile = lfs.findFileByIoFile(file); + if (myVirtualFile == null) { + myVirtualFile = lfs.refreshAndFindFileByIoFile(file); + } + } + + @Override + public boolean contains(@NotNull VirtualFile file) { + return file.equals(myVirtualFile); + } + + @Override + protected void update(PresentationData presentation) { + if (myVirtualFile != null && myVirtualFile.isDirectory()) { + presentation.setOpenIcon(AllIcons.Nodes.TreeOpen); + presentation.setClosedIcon(AllIcons.Nodes.TreeClosed); + } else if (myVirtualFile != null) { + presentation.setIcons(myVirtualFile.getFileType().getIcon()); + } else { + presentation.setIcons(AllIcons.FileTypes.Unknown); + } + presentation.setPresentableText(getValue().getName()); + } + + @Override + public VirtualFile getVirtualFile() { + return myVirtualFile; + } + + @Override + public void navigate(boolean requestFocus) { + if (myVirtualFile != null) { + new OpenFileDescriptor(myProject, myVirtualFile).navigate(requestFocus); + } + } + + // todo possibly we need file + @Override + public boolean canNavigate() { + return myVirtualFile != null && myVirtualFile.isValid(); + } + + @Override + public boolean canNavigateToSource() { + return myVirtualFile != null && myVirtualFile.isValid(); + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FileSerializable.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FileSerializable.java new file mode 100644 index 000000000000..b409b84e3851 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FileSerializable.java @@ -0,0 +1,54 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.openapi.project.Project; + +import java.io.File; +import java.io.IOException; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/8/12 + * Time: 12:43 PM + */ +public class FileSerializable implements WorkingSetSerializable { + @Override + public String getId() { + return File.class.getName(); + } + + @Override + public int getVersion() { + return 0; + } + + @Override + public void serializeMe(File t, StringBuilder oos) throws IOException { + oos.append(t.getPath()); + } + + @Override + public File deserializeMe(Project project, String ois) throws IOException { + return new File(ois); + } + + @Override + public File deserializeMeInvalid(Project project, String ois) throws IOException { + return new File(ois); + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/Flag.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/Flag.java new file mode 100644 index 000000000000..5d2a7805c69e --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/Flag.java @@ -0,0 +1,46 @@ +/* + * 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.ide.favoritesTreeView; + +import java.awt.*; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/1/12 + * Time: 2:03 PM + */ +public enum Flag { + orange(new Color(255,128,0)), + blue(new Color(0,102,204)), + green(new Color(0, 130,130)), + red(new Color(255,45,45)), + brown(new Color(128,64,0)), + magenta(new Color(255,0,255)), + violet(new Color(128,0,255)), + yellow(new Color(255,255,0)), + grey(new Color(140,140,140)); + + private final Color myColor; + + private Flag(Color color) { + myColor = color; + } + + public Color getColor() { + return myColor; + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/ImportUsagesAction.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/ImportUsagesAction.java new file mode 100644 index 000000000000..bd837f38862c --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/ImportUsagesAction.java @@ -0,0 +1,69 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.icons.AllIcons; +import com.intellij.ide.projectView.ViewSettings; +import com.intellij.ide.util.treeView.AbstractTreeNode; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.project.Project; +import com.intellij.usages.Usage; +import com.intellij.usages.UsageView; + +import java.util.Collection; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/1/12 + * Time: 11:22 PM + */ +public class ImportUsagesAction extends AnAction { + public ImportUsagesAction() { + super("To Favorites", "To Favorites", AllIcons.Toolwindows.ToolWindowFavorites); + } + + @Override + public void update(AnActionEvent e) { + final DataContext dc = e.getDataContext(); + final boolean enabled = isEnabled(dc); + e.getPresentation().setEnabled(enabled); + } + + private boolean isEnabled(DataContext dc) { + final Project project = PlatformDataKeys.PROJECT.getData(dc); + final Usage[] usages = UsageView.USAGES_KEY.getData(dc); + return project != null && usages != null && usages.length > 0; + } + + @Override + public void actionPerformed(AnActionEvent e) { + final DataContext dc = e.getDataContext(); + final boolean enabled = isEnabled(dc); + if (! enabled) return; + + final Project project = PlatformDataKeys.PROJECT.getData(dc); + + final Collection nodes = new UsageFavoriteNodeProvider().getFavoriteNodes(dc, ViewSettings.DEFAULT); + final FavoritesManager favoritesManager = FavoritesManager.getInstance(project); + if (nodes != null && ! nodes.isEmpty()) { + favoritesManager.addRoots(TaskDefaultFavoriteListProvider.CURRENT_TASK, nodes); + } + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/InvalidUsageNoteNode.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/InvalidUsageNoteNode.java new file mode 100644 index 000000000000..366eba3f1fec --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/InvalidUsageNoteNode.java @@ -0,0 +1,55 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.usages.TextChunk; + +import java.util.List; +import java.util.Set; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/7/12 + * Time: 1:26 PM + */ +public class InvalidUsageNoteNode { + private PercentDone myPercentDone = PercentDone._0; + private Set myFlags; + private Set myConcepts; + + final List myText; + + public InvalidUsageNoteNode(List text) { + myText = text; + } + + public PercentDone getPercentDone() { + return myPercentDone; + } + + public Set getFlags() { + return myFlags; + } + + public Set getConcepts() { + return myConcepts; + } + + public List getText() { + return myText; + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/InvalidUsageNoteProjectNode.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/InvalidUsageNoteProjectNode.java new file mode 100644 index 000000000000..f1f4cd09e0c4 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/InvalidUsageNoteProjectNode.java @@ -0,0 +1,50 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.ide.projectView.PresentationData; +import com.intellij.ide.projectView.ViewSettings; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.usages.TextChunk; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/7/12 + * Time: 1:28 PM + */ +public class InvalidUsageNoteProjectNode extends ProjectViewNodeWithChildrenList { + public InvalidUsageNoteProjectNode(Project project, InvalidUsageNoteNode node, ViewSettings viewSettings) { + super(project, node, viewSettings); + } + + @Override + public boolean contains(@NotNull VirtualFile file) { + return false; + } + + @Override + protected void update(PresentationData presentation) { + final List text = getValue().getText(); + if (! text.isEmpty()) { + UsageProjectTreeNode.updatePresentationWithTextChunks(presentation, text.toArray(new TextChunk[text.size()])); + } + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/NoteNode.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/NoteNode.java new file mode 100644 index 000000000000..f99fd0ffa436 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/NoteNode.java @@ -0,0 +1,74 @@ +/* + * 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.ide.favoritesTreeView; + +import java.util.Set; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 5/31/12 + * Time: 8:47 PM + */ +public class NoteNode { + private PercentDone myPercentDone = PercentDone._0; + private Set myFlags; + private Set myConcepts; + + private String myText; + private boolean myReadonly; + + public NoteNode(String text, boolean readonly) { + myText = text; + myReadonly = readonly; + } + + public PercentDone getPercentDone() { + return myPercentDone; + } + + public void setPercentDone(PercentDone percentDone) { + myPercentDone = percentDone; + } + + public Set getFlags() { + return myFlags; + } + + public void setFlags(Set flags) { + myFlags = flags; + } + + public Set getConcepts() { + return myConcepts; + } + + public void setConcepts(Set concepts) { + myConcepts = concepts; + } + + public String getText() { + return myText; + } + + public void setText(String text) { + myText = text; + } + + public boolean isReadonly() { + return myReadonly; + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/NoteProjectNode.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/NoteProjectNode.java new file mode 100644 index 000000000000..1ea507dcfe46 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/NoteProjectNode.java @@ -0,0 +1,52 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.ide.projectView.PresentationData; +import com.intellij.ide.projectView.ViewSettings; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vcs.FileStatus; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/7/12 + * Time: 12:15 PM + */ +public class NoteProjectNode extends ProjectViewNodeWithChildrenList { + public NoteProjectNode(Project project, NoteNode node, ViewSettings viewSettings) { + super(project, node, viewSettings); + } + + @Override + public boolean contains(@NotNull VirtualFile file) { + return false; + } + + @Override + public String toString() { + return getValue().getText(); + } + + @Override + protected void update(PresentationData presentation) { + presentation.setPresentableText(getValue().getText()); + // todo define own color + presentation.setForcedTextForeground(FileStatus.COLOR_SWITCHED); + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/NoteSerializable.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/NoteSerializable.java new file mode 100644 index 000000000000..86d8847fed49 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/NoteSerializable.java @@ -0,0 +1,63 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; + +import java.io.IOException; +import java.util.List; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/9/12 + * Time: 4:11 PM + */ +public class NoteSerializable implements WorkingSetSerializable { + + @Override + public String getId() { + return NoteNode.class.getName(); + } + + @Override + public int getVersion() { + return 0; + } + + @Override + public void serializeMe(NoteNode t, StringBuilder oos) throws IOException { + oos.append(StringUtil.escapeXml(t.getText())); + oos.append("<>"); + oos.append(String.valueOf(t.isReadonly())); + oos.append("<>"); + } + + @Override + public NoteNode deserializeMe(Project project, String ois) throws IOException { + final List strings = StringUtil.split(ois, "<>", true); + if (strings.size() == 2) { + return new NoteNode(StringUtil.unescapeXml(strings.get(0)), Boolean.parseBoolean(strings.get(1))); + } + return null; + } + + @Override + public NoteNode deserializeMeInvalid(Project project, String ois) throws IOException { + return null; + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/PercentDone.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/PercentDone.java new file mode 100644 index 000000000000..0dfaa4115169 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/PercentDone.java @@ -0,0 +1,36 @@ +/* + * 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.ide.favoritesTreeView; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/1/12 + * Time: 1:53 PM + */ +public enum PercentDone { + _0(0),_05(5),_20(20),_50(50),_70(70),_100(100); + + private final int myPercent; + + private PercentDone(int percent) { + myPercent = percent; + } + + public int getPercent() { + return myPercent; + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/ProjectDefaultFavoriteListProvider.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/ProjectDefaultFavoriteListProvider.java new file mode 100644 index 000000000000..2b763a180133 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/ProjectDefaultFavoriteListProvider.java @@ -0,0 +1,69 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.openapi.project.Project; + +import javax.swing.tree.TreeCellRenderer; +import java.util.Comparator; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/7/12 + * Time: 4:30 PM + */ +public class ProjectDefaultFavoriteListProvider implements FavoritesListProvider { + @Override + public String getListName(Project project) { + return project.getName(); + } + + @Override + public boolean canBeRemoved() { + return false; + } + + @Override + public boolean isTreeLike() { + return false; + } + + @Override + public Comparator getNodeDescriptorComparator() { + return null; + } + + @Override + public Operation getCustomDeleteOperation() { + return null; + } + + @Override + public Operation getCustomAddOperation() { + return null; + } + + @Override + public Operation getCustomEditOperation() { + return null; + } + + @Override + public TreeCellRenderer getTreeCellRenderer() { + return null; + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/ProjectViewNodeWithChildrenList.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/ProjectViewNodeWithChildrenList.java new file mode 100644 index 000000000000..08cee563a32d --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/ProjectViewNodeWithChildrenList.java @@ -0,0 +1,69 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.ide.projectView.ProjectViewNode; +import com.intellij.ide.projectView.ViewSettings; +import com.intellij.ide.util.treeView.AbstractTreeNode; +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/7/12 + * Time: 12:41 PM + */ +public abstract class ProjectViewNodeWithChildrenList extends ProjectViewNode { + protected final List myChildren; + + protected ProjectViewNodeWithChildrenList(Project project, T t, ViewSettings viewSettings) { + super(project, t, viewSettings); + myChildren = new ArrayList(); + } + + @NotNull + @Override + public Collection getChildren() { + return myChildren; + } + + public void addChild(final AbstractTreeNode node) { + myChildren.add(node); + node.setParent(this); + } + + public void addChildBefore(final AbstractTreeNode newNode, final AbstractTreeNode existingNode) { + int idx = -1; + for (int i = 0; i < myChildren.size(); i++) { + AbstractTreeNode node = myChildren.get(i); + // exactly the same node! + if (node == existingNode) { + idx = i; + break; + } + } + if (idx == -1) { + addChild(newNode); + } else { + myChildren.add(idx, newNode); + } + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/TaskDefaultFavoriteListProvider.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/TaskDefaultFavoriteListProvider.java new file mode 100644 index 000000000000..760c10b4168e --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/TaskDefaultFavoriteListProvider.java @@ -0,0 +1,283 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.ide.dnd.aware.DnDAwareTree; +import com.intellij.ide.util.treeView.AbstractTreeNode; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonShortcuts; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; +import com.intellij.openapi.keymap.KeymapUtil; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.ex.MultiLineLabel; +import com.intellij.openapi.ui.popup.ComponentPopupBuilder; +import com.intellij.openapi.ui.popup.JBPopup; +import com.intellij.openapi.ui.popup.JBPopupFactory; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.ui.MultilineTreeCellRenderer; +import com.intellij.ui.components.JBScrollPane; +import com.intellij.util.Consumer; +import com.intellij.util.ui.UIUtil; + +import javax.swing.*; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreeCellRenderer; +import javax.swing.tree.TreePath; +import java.awt.*; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/7/12 + * Time: 4:33 PM + */ +public class TaskDefaultFavoriteListProvider implements FavoritesListProvider { + public static final String CURRENT_TASK = "Current task"; + + @Override + public String getListName(Project project) { + return CURRENT_TASK; + } + + @Override + public boolean canBeRemoved() { + return false; + } + + @Override + public boolean isTreeLike() { + return false; + } + + @Override + public Comparator getNodeDescriptorComparator() { + return new Comparator() { + @Override + public int compare(FavoritesTreeNodeDescriptor o1, FavoritesTreeNodeDescriptor o2) { + return o1.getIndex() - o2.getIndex(); + } + }; + } + + @Override + public Operation getCustomDeleteOperation() { + return null; + } + + @Override + public Operation getCustomAddOperation() { + return new Operation() { + @Override + public boolean willHandle(DnDAwareTree tree) { + final int count = tree.getSelectionCount(); + if (count != 1) { + return false; + } + final TreePath path = tree.getSelectionPath(); + if (path.getPathCount() > 2) return true; + return false; + } + + @Override + public String getCustomName() { + return "New Note"; + } + + @Override + public void handle(final Project project, final DnDAwareTree tree) { + final Object component = tree.getSelectionPath().getLastPathComponent(); + if (component instanceof DefaultMutableTreeNode) { + final Object uo = ((DefaultMutableTreeNode)component).getUserObject(); + if (uo instanceof FavoritesTreeNodeDescriptor) { + final FavoritesManager favoritesManager = FavoritesManager.getInstance(project); + + final AbstractTreeNode treeNode = ((FavoritesTreeNodeDescriptor)uo).getElement(); + final NoteNode node = new NoteNode("Test text", false); + final NoteProjectNode noteNode = new NoteProjectNode(project, node, favoritesManager.getViewSettings()); + final Consumer after = new Consumer() { + @Override + public void consume(String text) { + node.setText(text); + // above it + final AbstractTreeNode parent = treeNode.getParent(); + noteNode.setParent(parent); + if (parent instanceof ProjectViewNodeWithChildrenList) { + // add through manager + //((ProjectViewNodeWithChildrenList)parent).addChildBefore(noteNode, treeNode); + final List pathToSelected = FavoritesTreeUtil.getLogicalPathToSelected(tree); + final List elements; + AbstractTreeNode sibling; + if (pathToSelected.isEmpty()) { + elements = pathToSelected; + sibling = null; + } + else { + elements = pathToSelected.subList(0, pathToSelected.size() - 1); + sibling = pathToSelected.get(pathToSelected.size() - 1); + } + favoritesManager.addRoot(CURRENT_TASK, elements, noteNode, sibling); + } else if (parent instanceof FavoritesListNode) { + favoritesManager.addRoot(CURRENT_TASK, Collections.emptyList(), noteNode, treeNode); + } + } + }; + showNotePopup(project, tree, after, ""); + } + } + } + }; + } + + private void showNotePopup(Project project, + final DnDAwareTree tree, + final Consumer after, final String initText) { + final JTextArea textArea = new JTextArea(3, 50); + textArea.setFont(UIUtil.getTreeFont()); + textArea.setText(initText); + final JBScrollPane pane = new JBScrollPane(textArea); + final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(pane, textArea) + .setCancelOnClickOutside(true) + .setAdText(KeymapUtil.getShortcutsText(CommonShortcuts.CTRL_ENTER.getShortcuts()) + " to finish") + .setTitle("Comment") + .setMovable(true) + .setRequestFocus(true).setResizable(true).setMayBeParent(true); + final JBPopup popup = builder.createPopup(); + final JComponent content = popup.getContent(); + final AnAction action = new AnAction() { + @Override + public void actionPerformed(AnActionEvent e) { + popup.closeOk(e.getInputEvent()); + unregisterCustomShortcutSet(content); + after.consume(textArea.getText()); + } + }; + action.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, content); + ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override + public void run() { + popup.showInCenterOf(tree); + } + }, ModalityState.NON_MODAL, project.getDisposed()); + } + + @Override + public Operation getCustomEditOperation() { + return new Operation() { + @Override + public boolean willHandle(DnDAwareTree tree) { + final int count = tree.getSelectionCount(); + if (count != 1) { + return false; + } + final TreePath path = tree.getSelectionPath(); + if (path.getPathCount() < 2) return false; + // todo temporarily + if (path.getLastPathComponent() instanceof DefaultMutableTreeNode) { + final Object uo = ((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject(); + if (uo instanceof FavoritesTreeNodeDescriptor) { + return ((FavoritesTreeNodeDescriptor)uo).getElement() instanceof NoteProjectNode; + } + } + return false; + } + + @Override + public String getCustomName() { + return null; + } + + @Override + public void handle(Project project, final DnDAwareTree tree) { + final Object component = tree.getSelectionPath().getLastPathComponent(); + if (component instanceof DefaultMutableTreeNode) { + final Object uo = ((DefaultMutableTreeNode)component).getUserObject(); + if (uo instanceof FavoritesTreeNodeDescriptor) { + final FavoritesManager favoritesManager = FavoritesManager.getInstance(project); + + final AbstractTreeNode treeNode = ((FavoritesTreeNodeDescriptor)uo).getElement(); + + if (treeNode instanceof NoteProjectNode) { + showNotePopup(project, tree, new Consumer() { + @Override + public void consume(String s) { + ((NoteProjectNode)treeNode).getValue().setText(s); + favoritesManager.editRoot(CURRENT_TASK, FavoritesTreeUtil.getLogicalIndexPathTo(tree.getSelectionPath()), treeNode); + favoritesManager.fireListeners(CURRENT_TASK); + } + }, ((NoteProjectNode)treeNode).getValue().getText()); + } + } + } + } + }; + } + + @Override + public TreeCellRenderer getTreeCellRenderer() { + return new MyRenderer(); + } + + private static class MyRenderer implements TreeCellRenderer { + private AbstractTreeNode myNode; + + private final MultilineTreeCellRenderer myMultilineTreeCellRenderer = new MultilineTreeCellRenderer() { + @Override + protected void initComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { + if (myNode instanceof NoteProjectNode) { + setForeground(UIUtil.getListSelectionBackground()); + final NoteNode note = ((NoteProjectNode)myNode).getValue(); + final String[] lines = StringUtil.splitByLines(note.getText()); + setText(lines, null); + } + } + }; + + private final MultiLineLabel myLabel = new MultiLineLabel(); + + @Override + public Component getTreeCellRendererComponent(JTree tree, + Object value, + boolean selected, + boolean expanded, + boolean leaf, + int row, + boolean hasFocus) { + if (value instanceof DefaultMutableTreeNode) { + final DefaultMutableTreeNode node = (DefaultMutableTreeNode)value; + //only favorites roots to explain + final Object userObject = node.getUserObject(); + if (userObject instanceof FavoritesTreeNodeDescriptor) { + final FavoritesTreeNodeDescriptor favoritesTreeNodeDescriptor = (FavoritesTreeNodeDescriptor)userObject; + AbstractTreeNode treeNode = favoritesTreeNodeDescriptor.getElement(); + if (treeNode instanceof NoteProjectNode) { + myNode = treeNode; + myLabel.setText(((NoteProjectNode)myNode).getValue().getText()); + //myLabel.setBackground(selected ? ); + myMultilineTreeCellRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); + return myMultilineTreeCellRenderer; + //return myLabel; + } + } + } + return null; + } + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageFavoriteNodeProvider.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageFavoriteNodeProvider.java new file mode 100644 index 000000000000..ac9f38092b89 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageFavoriteNodeProvider.java @@ -0,0 +1,313 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.ide.projectView.ViewSettings; +import com.intellij.ide.util.treeView.AbstractTreeNode; +import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.usageView.UsageInfo; +import com.intellij.usages.Usage; +import com.intellij.usages.UsageInfo2UsageAdapter; +import com.intellij.usages.UsageView; +import com.intellij.usages.impl.NullUsage; +import com.intellij.usages.rules.UsageInFile; +import com.intellij.usages.rules.UsageInFiles; +import com.intellij.util.ProxyComparator; +import com.intellij.util.SmartList; +import com.intellij.util.containers.Convertor; +import com.intellij.util.containers.MultiMap; +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.io.IOException; +import java.util.*; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/6/12 + * Time: 6:51 PM + */ +public class UsageFavoriteNodeProvider extends FavoriteNodeProvider { + private final static Map> ourSerializables = new HashMap>(); + private final static Comparator VIRTUAL_FILE_COMPARATOR = + new ProxyComparator(new Convertor() { + @Override + public String convert(VirtualFile o) { + return o.getPath(); + } + }); + private static final Logger LOG = Logger.getInstance("#com.intellij.ide.favoritesTreeView.UsageFavoriteNodeProvider"); + + static { + final TreeSet usageSet = createSet(); + final UsageSerializable serializable = new UsageSerializable(); + ourSerializables.put(serializable.getId(), usageSet); + usageSet.add(serializable); + + final TreeSet fileSet = createSet(); + final FileSerializable fileSerializable = new FileSerializable(); + ourSerializables.put(fileSerializable.getId(), fileSet); + fileSet.add(fileSerializable); + + final TreeSet noteSet = createSet(); + final NoteSerializable noteSerializable = new NoteSerializable(); + ourSerializables.put(noteSerializable.getId(), noteSet); + noteSet.add(noteSerializable); + } + + private static TreeSet createSet() { + return new TreeSet(new Comparator() { + @Override + public int compare(WorkingSetSerializable o1, WorkingSetSerializable o2) { + assert o1.getId().equals(o1.getId()); + return Comparing.compare(o1.getVersion(), o2.getVersion()); + } + }); + } + + @Override + public Collection getFavoriteNodes(DataContext context, ViewSettings viewSettings) { + final Project project = PlatformDataKeys.PROJECT.getData(context); + if (project == null) { + return null; + } + final Usage[] usages = UsageView.USAGES_KEY.getData(context); + if (usages != null) { + + final List result = new SmartList(); + final MultiMap map = new MultiMap(); + final List nonMapped = new ArrayList(); + for (Usage usage : usages) { + if (usage instanceof UsageInFile) { + map.putValue(((UsageInFile)usage).getFile(), usage); + } else if (usage instanceof UsageInFiles) { + final VirtualFile[] files = ((UsageInFiles)usage).getFiles(); + for (VirtualFile file : files) { + map.putValue(file, usage); + } + } else { + nonMapped.add(usage); + } + } + + final TreeSet keys = new TreeSet(VIRTUAL_FILE_COMPARATOR); + keys.addAll(map.keySet()); + for (VirtualFile key : keys) { + final FileGroupingProjectNode grouping = new FileGroupingProjectNode(project, new File(key.getPath()), viewSettings); + result.add(grouping); + final Collection subUsages = map.get(key); + for (Usage usage : subUsages) { + if (usage instanceof UsageInfo2UsageAdapter) { + final UsageProjectTreeNode node = + new UsageProjectTreeNode(project, ((UsageInfo2UsageAdapter)usage).getUsageInfo(), viewSettings); + grouping.addChild(node); + } else if (NullUsage.INSTANCE.equals(usage)) { + continue; + } else { + grouping.addChild(new NoteProjectNode(project, new NoteNode(usage.getPresentation().getPlainText(), true), viewSettings)); + } + } + } + for (Usage usage : nonMapped) { + if (usage instanceof UsageInfo2UsageAdapter) { + final UsageProjectTreeNode node = + new UsageProjectTreeNode(project, ((UsageInfo2UsageAdapter)usage).getUsageInfo(), viewSettings); + result.add(node); + } else if (NullUsage.INSTANCE.equals(usage)) { + continue; + } else { + result.add(new NoteProjectNode(project, new NoteNode(usage.getPresentation().getPlainText(), true), viewSettings)); + } + } + + return result; + } + return null; + } + + @Override + public AbstractTreeNode createNode(Project project, Object element, ViewSettings viewSettings) { + if (element instanceof UsageInfo) { + return new UsageProjectTreeNode(project, (UsageInfo)element, viewSettings); + } else if (element instanceof InvalidUsageNoteNode) { + return new InvalidUsageNoteProjectNode(project, (InvalidUsageNoteNode)element, viewSettings); + } else if (element instanceof NoteNode) { + return new NoteProjectNode(project, (NoteNode)element, viewSettings); + } else if (element instanceof File) { + return new FileGroupingProjectNode(project, (File)element, viewSettings); + } + return super.createNode(project, element, viewSettings); + } + + @Override + public PsiElement getPsiElement(Object element) { + if (element instanceof UsageInfo) { + return ((UsageInfo)element).getElement(); + } + return super.getPsiElement(element); + } + + @Override + public boolean elementContainsFile(Object element, VirtualFile vFile) { + return false; + } + + @Override + public int getElementWeight(Object element, boolean isSortByType) { + return 0; + } + + @Override + public String getElementLocation(Object element) { + if (element instanceof UsageInfo) { + final PsiElement psiElement = ((UsageInfo)element).getElement(); + final PsiFile file = psiElement.getContainingFile(); + /*if (parent != null) { + return ClassPresentationUtil.getNameForClass(parent, true); + }*/ + return file.getPresentation().getPresentableText();//+- // todo do smthg for invalid usage + } else if (element instanceof File) { + return ((File)element).getParent(); + } + return null; + } + + @Override + public boolean isInvalidElement(Object element) { + /*if (element instanceof UsageInfo) { + return ((UsageInfo)element).getElement().isValid(); + } else if (element instanceof InvalidUsageNoteNode) { + return true; + } */ + return false; + } + + @NotNull + @Override + public String getFavoriteTypeId() { + return "usage"; + } + + @Override + public String getElementUrl(Object element) { + //if (element instanceof UsageInfo) { + final TreeSet serializables = ourSerializables.get(element.getClass().getName()); + if (serializables != null && ! serializables.isEmpty()) { + final WorkingSetSerializable last = serializables.last(); + //final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + //final ObjectOutputStream os = new ObjectOutputStream(baos); + final StringBuilder sb = new StringBuilder(); + sb.append(last.getId()); + sb.append(' '); + sb.append("" + last.getVersion()); + sb.append(' '); + + //os.writeUTF(last.getId()); + //os.writeInt(last.getVersion()); + last.serializeMe(element, sb); + //os.close(); + //final byte[] bytes = baos.toByteArray(); + return sb.toString(); + //return new String(bytes, 4, bytes.length - 4); + } + catch (IOException e) { + LOG.info(e); + return null; + } + } + //} + return null; + } + + @Override + public String getElementModuleName(Object element) { + if (element instanceof UsageInfo) { + Module module = ModuleUtil.findModuleForPsiElement(((UsageInfo)element).getElement()); + return module != null ? module.getName() : null; + } + return null; + } + + @Override + public Object[] createPathFromUrl(Project project, String url, String moduleName) { + try { + //final byte[] bytes = url.getBytes(CharsetToolkit.UTF8_CHARSET); + /*final byte[] wrapped = new byte[bytes.length + 4]; + final ByteArrayOutputStream bas = new ByteArrayOutputStream(); + final ObjectOutputStream oos = new ObjectOutputStream(bas); + oos.close(); + final byte[] header = bas.toByteArray(); + System.arraycopy(header, 0, wrapped, 0, 4); + System.arraycopy(bytes, 0, wrapped, 0, bytes.length);*/ + + //ObjectInputStream is = new ObjectInputStream(new ByteArrayInputStream(bytes)); + final List parts = StringUtil.split(url, " ", true); + if (parts.size() < 3) return null; + + final String id = parts.get(0); + final TreeSet set = ourSerializables.get(id); + if (set != null && ! set.isEmpty()) { + final int version = Integer.parseInt(parts.get(1)); + final String cut = StringUtil.join(parts.subList(2, parts.size()), " "); + for (java.util.Iterator iterator = set.descendingIterator(); iterator.hasNext(); ) { + WorkingSetSerializable serializable = iterator.next(); + if (serializable.getVersion() == version) { + return readWithSerializable(project, url, cut, serializable); + } + } + readWithSerializable(project, url, cut, set.last()); + } + } + catch (IOException e) { + LOG.info(e); + } + return null; + } + + private Object[] readWithSerializable(Project project, String url, String is, WorkingSetSerializable serializable) + throws IOException { + Object obj = serializable.deserializeMe(project, is); + if (obj == null) { + obj = serializable.deserializeMeInvalid(project, is); + } + return obj == null ? null : new Object[] {obj}; + /*Object obj = serializable.deserializeMe(project, is); + if (obj == null) { + is.close(); + is = new ObjectInputStream(new ByteArrayInputStream(url.getBytes(CharsetToolkit.UTF8_CHARSET))); + is.readUTF(); + is.readInt(); + obj = serializable.deserializeMeInvalid(project, is); + } + if (obj != null) { + return new Object[]{obj}; + } else { + return null; + }*/ + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageNode.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageNode.java new file mode 100644 index 000000000000..e9be02390e3d --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageNode.java @@ -0,0 +1,61 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.pom.Navigatable; +import com.intellij.usages.Usage; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/1/12 + * Time: 1:51 PM + */ +public class UsageNode implements Navigatable { + private Usage myUsage; + private NoteNode myComment; + + public Usage getUsage() { + return myUsage; + } + + public void setUsage(Usage usage) { + myUsage = usage; + } + + public NoteNode getComment() { + return myComment; + } + + public void setComment(NoteNode comment) { + myComment = comment; + } + + @Override + public void navigate(boolean requestFocus) { + myUsage.navigate(requestFocus); + } + + @Override + public boolean canNavigate() { + return myUsage.isValid() && myUsage.canNavigate(); + } + + @Override + public boolean canNavigateToSource() { + return myUsage.isValid() && myUsage.canNavigate(); + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageProjectTreeNode.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageProjectTreeNode.java new file mode 100644 index 000000000000..5e95607ef707 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageProjectTreeNode.java @@ -0,0 +1,91 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.ide.projectView.PresentationData; +import com.intellij.ide.projectView.ViewSettings; +import com.intellij.openapi.editor.markup.TextAttributes; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiElement; +import com.intellij.ui.SimpleTextAttributes; +import com.intellij.usageView.UsageInfo; +import com.intellij.usages.TextChunk; +import com.intellij.usages.UsageInfo2UsageAdapter; +import com.intellij.usages.UsagePresentation; +import org.jetbrains.annotations.NotNull; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/6/12 + * Time: 7:24 PM + * + */ +public class UsageProjectTreeNode extends ProjectViewNodeWithChildrenList { + private final UsagePresentation myUsagePresentation; + + public UsageProjectTreeNode(Project project, UsageInfo usage, ViewSettings viewSettings) { + super(project, usage, viewSettings); + final UsageInfo2UsageAdapter adapter = new UsageInfo2UsageAdapter(usage); + myUsagePresentation = adapter.getPresentation(); + } + + @Override + public boolean contains(@NotNull VirtualFile file) { + final UsageInfo info = getValue(); + if (info == null) return false; + final PsiElement element = info.getElement(); + return element != null && file.equals(element.getContainingFile().getVirtualFile()); + } + + @Override + public String toString() { + return myUsagePresentation.getPlainText(); + } + + @Override + protected void update(PresentationData presentation) { + presentation.setOpenIcon(myUsagePresentation.getIcon()); + presentation.setClosedIcon(myUsagePresentation.getIcon()); + presentation.setTooltip(myUsagePresentation.getTooltipText()); + final TextChunk[] text = myUsagePresentation.getText(); + updatePresentationWithTextChunks(presentation, text); + } + + public static void updatePresentationWithTextChunks(PresentationData presentation, TextChunk[] text) { + for (TextChunk chunk : text) { + final TextAttributes attributes = chunk.getAttributes(); + presentation.addText(chunk.getText(), new SimpleTextAttributes(attributes.getBackgroundColor(), attributes.getForegroundColor(), + attributes.getEffectColor(), attributes.getFontType())); + } + } + + @Override + public void navigate(boolean requestFocus) { + getValue().navigateTo(requestFocus); + } + + @Override + public boolean canNavigate() { + return getValue().getElement().isValid(); + } + + @Override + public boolean canNavigateToSource() { + return getValue().getElement().isValid(); + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageSerializable.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageSerializable.java new file mode 100644 index 000000000000..0e8edac12fed --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageSerializable.java @@ -0,0 +1,165 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.codeInsight.folding.impl.GenericElementSignatureProvider; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.ProperTextRange; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiManager; +import com.intellij.usageView.UsageInfo; +import com.intellij.usages.UsageInfo2UsageAdapter; + +import java.io.File; +import java.io.IOException; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/7/12 + * Time: 1:58 PM + */ +public class UsageSerializable implements WorkingSetSerializable { + private static final Logger LOG = Logger.getInstance("#com.intellij.ide.favoritesTreeView.UsageSerializable"); + private final static String separator = "<>"; + + @Override + public String getId() { + return UsageInfo.class.getName(); + } + + @Override + public int getVersion() { + return 0; + } + + @Override + public void serializeMe(UsageInfo info, StringBuilder os) throws IOException { + //final SmartPsiElementPointer pointer = info.getSmartPointer(); + final GenericElementSignatureProvider provider = new GenericElementSignatureProvider(); + final String signature = provider.getSignature(info.getElement()); + append(os, info.getElement().getContainingFile().getVirtualFile().getPath()); + os.append(separator); + append(os, signature); + os.append(separator); + final ProperTextRange rangeInElement = info.getRangeInElement(); + if (rangeInElement == null) { + append(os, "-1"); + os.append(separator); + append(os, "-1"); + os.append(separator); + } else { + append(os, String.valueOf(rangeInElement.getStartOffset())); + os.append(separator); + append(os, String.valueOf(rangeInElement.getEndOffset())); + os.append(separator); + } + append(os, String.valueOf(info.isNonCodeUsage())); + os.append(separator); + append(os, String.valueOf(info.isDynamicUsage())); + os.append(separator); + final String text = new UsageInfo2UsageAdapter(info).getPlainText(); + append(os, text); + os.append(separator); + } + + private void append(final StringBuilder sb, final String s) { + sb.append(StringUtil.escapeXml(s)); + } + + @Override + public UsageInfo deserializeMe(Project project, String is) throws IOException { + return new Reader(is).execute(project); + } + + private static class Reader { + private int idx; + private String is; + + private Reader(String is) { + this.idx = 0; + this.is = is; + } + + private String readNext(final boolean allowEnd) { + int idxNext = is.indexOf(separator, idx); + if (idxNext == -1) { + if (allowEnd) { + return StringUtil.unescapeXml(new String(is.substring(idx))); + } + } + final String s = new String(is.substring(idx, idxNext)); + idx = idxNext + separator.length(); + return s; + } + + public UsageInfo execute(final Project project) { + final GenericElementSignatureProvider provider = new GenericElementSignatureProvider(); + + final String path = readNext(false); + if (path == null) return null; + final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(path)); + if (file == null) return null; + PsiFile psiFile = PsiManager.getInstance(project).findFile(file); + if (psiFile == null) return null; + final String signature = readNext(false); + final PsiElement element = provider.restoreBySignature(psiFile, signature, new StringBuilder()); + if (element == null) return null; + final String startStr = readNext(false); + if (startStr == null) return null; + final int start = Integer.parseInt(startStr); + final String endStr = readNext(false); + if (endStr == null) return null; + final int end = Integer.parseInt(endStr); + final String nonCodeUsageStr = readNext(false); + if (nonCodeUsageStr == null) return null; + final boolean nonCodeUsage = Boolean.parseBoolean(nonCodeUsageStr); + final String dynamicUsageStr = readNext(false); + if (dynamicUsageStr == null) return null; + final boolean dynamicUsage = Boolean.parseBoolean(dynamicUsageStr); + + final String text = readNext(true); + if (text == null) return null; + + final UsageInfo info = new UsageInfo(element, start, end, nonCodeUsage); + info.setDynamicUsage(dynamicUsage); + + return info; + /*final String newText = new UsageInfo2UsageAdapter(info).getPlainText(); + if (! Comparing.equal(newText, text)) { + LOG.info("Usage not restored, oldText:\n'" + text + "'\nnew text: '\n" + newText + "'"); + return null; + }*/ + } + } + + @Override + public InvalidUsageNoteNode deserializeMeInvalid(Project project, String is) throws IOException { + /*is.readUTF(); //file + is.readUTF(); + is.readInt(); + is.readInt(); + is.readBoolean(); + is.readBoolean(); + return new InvalidUsageNoteNode(Collections.singletonList(new TextChunk(new TextAttributes(), is.readUTF())));*/ + return null; + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/WorkingSetSerializable.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/WorkingSetSerializable.java new file mode 100644 index 000000000000..c8eae474e69d --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/WorkingSetSerializable.java @@ -0,0 +1,34 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.openapi.project.Project; + +import java.io.IOException; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/7/12 + * Time: 1:55 PM + */ +public interface WorkingSetSerializable { + String getId(); + int getVersion(); + void serializeMe(final Valid t, final StringBuilder oos) throws IOException; + Valid deserializeMe(Project project, final String ois) throws IOException; + Invalid deserializeMeInvalid(Project project, final String ois) throws IOException; +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/WorkingSetUsageActionProvider.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/WorkingSetUsageActionProvider.java new file mode 100644 index 000000000000..5b2f82393e46 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/WorkingSetUsageActionProvider.java @@ -0,0 +1,45 @@ +/* + * 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.ide.favoritesTreeView; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.project.Project; +import com.intellij.usages.UsageView; +import com.intellij.usages.rules.UsageGroupingRule; +import com.intellij.usages.rules.UsageGroupingRuleProvider; +import org.jetbrains.annotations.NotNull; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/2/12 + * Time: 5:01 PM + */ +public class WorkingSetUsageActionProvider implements UsageGroupingRuleProvider { + private UsageGroupingRule[] myRules = new UsageGroupingRule[0]; + + @NotNull + @Override + public UsageGroupingRule[] getActiveRules(Project project) { + return myRules; + } + + @NotNull + @Override + public AnAction[] createGroupingActions(UsageView view) { + return new AnAction[]{new ImportUsagesAction()}; + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddAllToFavoritesActionGroup.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddAllToFavoritesActionGroup.java index e733b277bdfd..ef95d71717e3 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddAllToFavoritesActionGroup.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddAllToFavoritesActionGroup.java @@ -32,7 +32,7 @@ public class AddAllToFavoritesActionGroup extends ActionGroup { if (project == null){ return AnAction.EMPTY_ARRAY; } - final String[] availableFavoritesLists = FavoritesManager.getInstance(project).getAvailableFavoritesLists(); + final String[] availableFavoritesLists = FavoritesManager.getInstance(project).getAvailableFavoritesListNames(); if (availableFavoritesLists == null) return AnAction.EMPTY_ARRAY; AnAction[] actions = new AnAction[availableFavoritesLists.length + 2]; int idx = 0; diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddNewFavoritesListAction.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddNewFavoritesListAction.java index 3ddd4a917a01..a3b6d2f988ab 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddNewFavoritesListAction.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddNewFavoritesListAction.java @@ -50,7 +50,7 @@ public class AddNewFavoritesListAction extends AnAction { } public boolean canClose(String inputString) { - final boolean isNew = ArrayUtil.find(favoritesManager.getAvailableFavoritesLists(), inputString.trim()) == -1; + final boolean isNew = ArrayUtil.find(favoritesManager.getAvailableFavoritesListNames(), inputString.trim()) == -1; if (!isNew) { Messages.showErrorDialog(project, IdeBundle.message("error.favorites.list.already.exists", inputString.trim()), @@ -61,12 +61,12 @@ public class AddNewFavoritesListAction extends AnAction { } }); if (name == null || name.length() == 0) return null; - favoritesManager.createNewList(name); + favoritesManager.createNewList(name, false, false); return name; } private static String getUniqueName(Project project) { - String[] names = FavoritesManager.getInstance(project).getAvailableFavoritesLists(); + String[] names = FavoritesManager.getInstance(project).getAvailableFavoritesListNames(); for (int i = 0; ; i++) { String newName = IdeBundle.message("favorites.list.unnamed", i > 0 ? i : ""); if (ArrayUtil.find(names, newName) > -1) continue; diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddToFavoritesAction.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddToFavoritesAction.java index bc0a655b3a75..994b10f06c9d 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddToFavoritesAction.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddToFavoritesAction.java @@ -106,6 +106,7 @@ public class AddToFavoritesAction extends AnAction { final boolean inProjectView = e.getPlace().equals(ActionPlaces.J2EE_VIEW_POPUP) || e.getPlace().equals(ActionPlaces.STRUCTURE_VIEW_POPUP) || e.getPlace().equals(ActionPlaces.PROJECT_VIEW_POPUP); + //com.intellij.openapi.actionSystem.ActionPlaces.USAGE_VIEW_TOOLBAR return getNodesToAdd(dataContext, inProjectView) != null; } diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddToFavoritesActionGroup.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddToFavoritesActionGroup.java index c10a4d5ec25e..49f0b8ed7d1c 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddToFavoritesActionGroup.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddToFavoritesActionGroup.java @@ -35,7 +35,7 @@ public class AddToFavoritesActionGroup extends ActionGroup { if (project == null){ return AnAction.EMPTY_ARRAY; } - final String[] availableFavoritesLists = FavoritesManager.getInstance(project).getAvailableFavoritesLists(); + final String[] availableFavoritesLists = FavoritesManager.getInstance(project).getAvailableFavoritesListNames(); AnAction[] actions = new AnAction[availableFavoritesLists.length + 2]; int idx = 0; for (String favoritesList : availableFavoritesLists) { diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddToFavoritesPopupAction.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddToFavoritesPopupAction.java index 76339f366b7c..385ea6e1fc55 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddToFavoritesPopupAction.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/AddToFavoritesPopupAction.java @@ -29,7 +29,7 @@ import com.intellij.openapi.project.Project; public class AddToFavoritesPopupAction extends QuickSwitchSchemeAction { protected void fillActions(Project project, DefaultActionGroup group, DataContext dataContext) { group.removeAll(); - final String[] availableFavoritesLists = FavoritesManager.getInstance(project).getAvailableFavoritesLists(); + final String[] availableFavoritesLists = FavoritesManager.getInstance(project).getAvailableFavoritesListNames(); for (String favoritesList : availableFavoritesLists) { group.add(new AddToFavoritesAction(favoritesList)); } diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/DeleteAllFavoritesListsButThisAction.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/DeleteAllFavoritesListsButThisAction.java index bbcd092946ff..e18682915c65 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/DeleteAllFavoritesListsButThisAction.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/DeleteAllFavoritesListsButThisAction.java @@ -40,7 +40,7 @@ public class DeleteAllFavoritesListsButThisAction extends AnAction implements Du } FavoritesManager favoritesManager = FavoritesManager.getInstance(project); String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext); - String[] lists = favoritesManager.getAvailableFavoritesLists(); + String[] lists = favoritesManager.getAvailableFavoritesListNames(); for (String list : lists) { if (!list.equals(listName)) { favoritesManager.removeFavoritesList(list); @@ -59,7 +59,7 @@ public class DeleteAllFavoritesListsButThisAction extends AnAction implements Du final String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext); presentation.setEnabled(false); if (listName != null) { - final String[] favoritesLists = FavoritesManager.getInstance(project).getAvailableFavoritesLists(); + final String[] favoritesLists = FavoritesManager.getInstance(project).getAvailableFavoritesListNames(); if (listName.equals(project.getName())) { presentation.setEnabled(favoritesLists.length > 1); } else { diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/DeleteFromFavoritesAction.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/DeleteFromFavoritesAction.java index c16ba8013970..e3ee3763db5a 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/DeleteFromFavoritesAction.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/DeleteFromFavoritesAction.java @@ -17,12 +17,9 @@ package com.intellij.ide.favoritesTreeView.actions; import com.intellij.ide.IdeBundle; -import com.intellij.ide.favoritesTreeView.FavoritesListNode; -import com.intellij.ide.favoritesTreeView.FavoritesManager; -import com.intellij.ide.favoritesTreeView.FavoritesTreeNodeDescriptor; -import com.intellij.ide.favoritesTreeView.FavoritesTreeViewPanel; +import com.intellij.ide.dnd.aware.DnDAwareTree; +import com.intellij.ide.favoritesTreeView.*; import com.intellij.ide.util.treeView.AbstractTreeNode; -import com.intellij.ide.util.treeView.NodeDescriptor; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.PlatformDataKeys; @@ -31,6 +28,8 @@ import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.ui.AnActionButton; +import java.util.List; + /** * @author anna * @author Konstantin Bulenkov @@ -50,6 +49,8 @@ public class DeleteFromFavoritesAction extends AnActionButton implements DumbAwa } FavoritesManager favoritesManager = FavoritesManager.getInstance(project); FavoritesTreeNodeDescriptor[] roots = FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS_DATA_KEY.getData(dataContext); + final DnDAwareTree tree = FavoritesTreeViewPanel.FAVORITES_TREE_KEY.getData(dataContext); + assert roots != null; for (FavoritesTreeNodeDescriptor root : roots) { final AbstractTreeNode node = root.getElement(); @@ -59,10 +60,14 @@ public class DeleteFromFavoritesAction extends AnActionButton implements DumbAwa else { final Object value = node.getValue(); LOG.assertTrue(value != null, node); - final NodeDescriptor parent = root.getParentDescriptor(); - if (parent instanceof FavoritesTreeNodeDescriptor) { - final String name = ((FavoritesTreeNodeDescriptor)parent).getName(); - favoritesManager.removeRoot(name, value); + final FavoritesListNode listNode = FavoritesTreeUtil.extractParentList(root); + LOG.assertTrue(listNode != null); + + //final List pathToSelected = FavoritesTreeUtil.getLogicalPathToSelected(tree); + //favoritesManager.removeRoot(listNode.getName(), pathToSelected); + final List pathTo = FavoritesTreeUtil.getLogicalIndexPathTo(tree.getSelectionPath()); + if (pathTo != null) { + favoritesManager.removeRootByIndexes(listNode.getName(), pathTo); } } } @@ -81,9 +86,10 @@ public class DeleteFromFavoritesAction extends AnActionButton implements DumbAwa return; } + final FavoritesManager fm = FavoritesManager.getInstance(project); if (roots.length == 1 && roots[0].getElement() instanceof FavoritesListNode - && project.getName().equals(roots[0].getElement().getValue())) { + && fm.isReadOnly(((FavoritesListNode) roots[0].getElement()).getName())) { e.getPresentation().setEnabled(false); return; } diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/RenameFavoritesListAction.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/RenameFavoritesListAction.java index 6fdf7b9c400f..00a60a0ea410 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/RenameFavoritesListAction.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/RenameFavoritesListAction.java @@ -56,7 +56,7 @@ public class RenameFavoritesListAction extends AnAction implements DumbAware { } public boolean canClose(String inputString) { - String[] lists = favoritesManager.getAvailableFavoritesLists(); + String[] lists = favoritesManager.getAvailableFavoritesListNames(); final boolean isNew = ArrayUtil.find(lists, inputString.trim()) == -1; if (!isNew) { Messages.showErrorDialog(project, IdeBundle.message("error.favorites.list.already.exists", inputString.trim()), diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/SendToFavoritesAction.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/SendToFavoritesAction.java index 5f9c1834e59a..55fd06221e70 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/SendToFavoritesAction.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/SendToFavoritesAction.java @@ -79,7 +79,7 @@ public class SendToFavoritesAction extends AnAction{ if (name == null) { name = root.getFavoritesRoot().getName(); } - favoritesManager.removeRoot(name, rootElement.getValue()); + favoritesManager.removeRoot(name, Collections.singletonList(rootElement)); favoritesManager.addRoots(toName, Collections.singletonList(rootElement)); } } diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/SendToFavoritesGroup.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/SendToFavoritesGroup.java index 61c0f90d2c85..d06afdbb4e49 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/SendToFavoritesGroup.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/actions/SendToFavoritesGroup.java @@ -76,7 +76,7 @@ public class SendToFavoritesGroup extends ActionGroup{ } - final String[] allLists = favoritesManager.getAvailableFavoritesLists(); + final String[] allLists = favoritesManager.getAvailableFavoritesListNames(); List actions = new ArrayList(); for (String list : allLists) { diff --git a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java index dea601d8705f..78dc71be077a 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java +++ b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java @@ -50,6 +50,7 @@ import com.intellij.usages.UsageView; import com.intellij.usages.UsageViewManager; import com.intellij.usages.rules.PsiElementUsage; import com.intellij.util.PlatformUtils; +import com.intellij.util.TreeItem; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -353,8 +354,8 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo final FavoritesManager favoritesManager = FavoritesManager.getInstance(project); if (favoritesManager != null) { - for (final String favorite : favoritesManager.getAvailableFavoritesLists()) { - final Collection> rootUrls = favoritesManager.getFavoritesListRootUrls(favorite); + for (final String favorite : favoritesManager.getAvailableFavoritesListNames()) { + final Collection>> rootUrls = favoritesManager.getFavoritesListRootUrls(favorite); if (rootUrls.isEmpty()) continue; // ignore unused root result.add(new GlobalSearchScope(project) { @Override diff --git a/platform/lang-impl/src/com/intellij/ide/util/treeView/AbstractTreeStructureBase.java b/platform/lang-impl/src/com/intellij/ide/util/treeView/AbstractTreeStructureBase.java index bc47efcd5f5f..c1bef72d1519 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/treeView/AbstractTreeStructureBase.java +++ b/platform/lang-impl/src/com/intellij/ide/util/treeView/AbstractTreeStructureBase.java @@ -45,7 +45,7 @@ public abstract class AbstractTreeStructureBase extends AbstractTreeStructure { LOG.assertTrue(element instanceof AbstractTreeNode, element != null ? element.getClass().getName() : null); AbstractTreeNode treeNode = (AbstractTreeNode)element; Collection elements = treeNode.getChildren(); - List providers = getProvidersDumbAware(); + List providers = getProvidersDumbAware(); if (providers != null && !providers.isEmpty()) { ViewSettings settings = treeNode instanceof ProjectViewNode ? ((ProjectViewNode) treeNode).getSettings() : ViewSettings.DEFAULT; for (TreeStructureProvider provider : providers) { diff --git a/platform/platform-api/src/com/intellij/ui/PrepareTreeRenderer.java b/platform/platform-api/src/com/intellij/ui/PrepareTreeRenderer.java new file mode 100644 index 000000000000..ad4c0da76105 --- /dev/null +++ b/platform/platform-api/src/com/intellij/ui/PrepareTreeRenderer.java @@ -0,0 +1,79 @@ +/* + * 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.ui; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/12/12 + * Time: 4:40 PM + */ +public class PrepareTreeRenderer { +/* public static void prepare(final JTree tree, final JComponent component, final boolean selected, final boolean hasFocus) { + final boolean treeFocused = tree.hasFocus(); + // We paint background if and only if tree path is selected and tree has focus. + // If path is selected and tree is not focused then we just paint focused border. + if (UIUtil.isFullRowSelectionLAF()) { + component.setBackground(selected ? UIUtil.getTreeSelectionBackground() : null); + } + else if (UIUtil.isUnderAquaLookAndFeel() && tree.getUI() instanceof MacTreeUI && ((MacTreeUI)tree.getUI()).isWideSelection()) { + component.setPaintFocusBorder(false); + //setBackground(selected ? UIUtil.getTreeSelectionBackground() : null); + } + else { + if (selected) { + component.setPaintFocusBorder(true); + if (treeFocused) { + component.setBackground(UIUtil.getTreeSelectionBackground()); + } + else { + component.setBackground(null); + } + } + else { + component.setBackground(null); + } + } + + component.setForeground(tree.getForeground()); + component.setIcon(null); + + if (UIUtil.isUnderGTKLookAndFeel()){ + component.setOpaque(false); // avoid nasty background + component.setIconOpaque(false); + } + else if (UIUtil.isUnderNimbusLookAndFeel() && selected && hasFocus) { + component.setOpaque(false); // avoid erasing Nimbus focus frame + component.setIconOpaque(false); + } + else if (UIUtil.isUnderAquaLookAndFeel() && tree.getUI() instanceof MacTreeUI && ((MacTreeUI)tree.getUI()).isWideSelection()) { + component.setOpaque(false); // avoid erasing Nimbus focus frame + component.setIconOpaque(false); + } + else { + component.setOpaque(myOpaque || selected && hasFocus || selected && treeFocused); // draw selection background even for non-opaque tree + } + + if (tree.getUI() instanceof MacTreeUI) { + component.setMyBorder(null); + component.setIpad(new Insets(0, 2, 0, 2)); + } + + if (component.getFont() == null) { + component.setFont(tree.getFont()); + } + } */ +} diff --git a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml index 30b87276a330..2ccff061d3d1 100644 --- a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml @@ -230,6 +230,9 @@ + diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index 0061d237eaf9..37b415652433 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -505,6 +505,7 @@ + diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java index 08b1ff32d64a..fbc86eb37456 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java @@ -24,7 +24,6 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.ide.CopyPasteManager; -import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; @@ -1046,6 +1045,24 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra return usages; } + /*public MultiMap getUsagesGroupedByFile() { + final MultiMap result = new MultiMap(); + final ArrayDeque> queue = new ArrayDeque>(); + final Node[] nodes = getSelectedNodes(); + for (Node node : nodes) { + if (node instanceof UsageNode) { + final VirtualFile vf = fileForUsage((UsageNode) node); + if (vf != null) { + result.putValue(vf, ((UsageNode)node).getUsage()); + } + } else if (node instanceof GroupNode) { + if (node instanceof TypeSafeDataProvider) { + ((TypeSafeDataProvider)node).calcData(); + } + } + } + }*/ + @Override @NotNull public Set getUsages() { diff --git a/platform/util/src/com/intellij/util/ProxyComparator.java b/platform/util/src/com/intellij/util/ProxyComparator.java new file mode 100644 index 000000000000..db73ab730248 --- /dev/null +++ b/platform/util/src/com/intellij/util/ProxyComparator.java @@ -0,0 +1,39 @@ +/* + * 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.util; + +import com.intellij.util.containers.Convertor; + +import java.util.Comparator; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/3/12 + * Time: 2:07 AM + */ +public class ProxyComparator,T> implements Comparator { + private final Convertor myConvertor; + + public ProxyComparator(Convertor convertor) { + myConvertor = convertor; + } + + @Override + public int compare(T o1, T o2) { + return myConvertor.convert(o1).compareTo(myConvertor.convert(o2)); + } +} diff --git a/platform/util/src/com/intellij/util/TreeItem.java b/platform/util/src/com/intellij/util/TreeItem.java index d3a8dbf3fdbf..8aa1e339ba7a 100644 --- a/platform/util/src/com/intellij/util/TreeItem.java +++ b/platform/util/src/com/intellij/util/TreeItem.java @@ -19,7 +19,7 @@ import java.util.ArrayList; import java.util.List; public class TreeItem { - private final Data myData; + private Data myData; private TreeItem myParent; private final List> myChildren = new ArrayList>(); @@ -31,6 +31,10 @@ public class TreeItem { return myData; } + public void setData(Data data) { + myData = data; + } + public TreeItem getParent() { return myParent; } @@ -47,4 +51,21 @@ public class TreeItem { child.setParent(this); myChildren.add(child); } + + public void addChildAfter(TreeItem child, TreeItem after) { + child.setParent(this); + int idx = -1; + for (int i = 0; i < myChildren.size(); i++) { + TreeItem item = myChildren.get(i); + if (item.equals(after)) { + idx = i; + break; + } + } + if (idx == -1) { + myChildren.add(child); + } else { + myChildren.add(idx, child); + } + } } diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index b5e6933e783d..777b53bc910c 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -1003,6 +1003,9 @@ + + + From e253d6a0dc44dfd8cea8853fbd6c2bb6de9c0038 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 14 Jun 2012 17:12:35 +0400 Subject: [PATCH 165/172] new project model: more java-specific properties added to the model --- .../jps/model/JpsElementFactory.java | 13 ++ .../org/jetbrains/jps/model/JpsProject.java | 4 + .../ExplodedDirectoryModuleExtension.java | 18 +++ .../jps/model/java/JpsAnnotationRootType.java | 10 ++ .../model/java/JpsJavaExtensionService.java | 31 +++++ ...nsion.java => JpsJavaModuleExtension.java} | 14 +- .../jps/model/library/JpsLibraryRootType.java | 14 +- .../jetbrains/jps/model/module/JpsModule.java | 3 + .../jps/service/JpsServiceManager.java | 3 + ...ins.jps.model.java.JpsJavaExtensionService | 1 + .../jps/model/impl/JpsElementFactoryImpl.java | 29 +++++ .../jps/model/impl/JpsGlobalImpl.java | 2 +- .../jps/model/impl/JpsProjectImpl.java | 17 ++- .../jps/model/impl/JpsUrlListKind.java | 20 +++ .../ExplodedDirectoryModuleExtensionImpl.java | 65 ++++++++++ .../java/impl/JavaModuleExtensionImpl.java | 76 ----------- .../java/impl/JavaModuleExtensionKind.java | 24 +--- .../impl/JpsJavaDependencyExtensionKind.java | 17 +-- .../impl/JpsJavaExtensionServiceImpl.java | 57 +++++++++ .../java/impl/JpsJavaModuleExtensionImpl.java | 121 ++++++++++++++++++ .../model/library/impl/JpsLibraryImpl.java | 10 +- .../model/library/impl/JpsLibraryKind.java | 11 +- .../jps/model/module/impl/JpsModuleImpl.java | 20 ++- .../jps/model/module/impl/JpsModuleKind.java | 13 +- .../service/impl/JpsServiceManagerImpl.java | 10 +- .../jps/model/JpsJavaExtensionTest.java | 23 ++-- 26 files changed, 476 insertions(+), 150 deletions(-) create mode 100644 jps/model-api/src/org/jetbrains/jps/model/java/ExplodedDirectoryModuleExtension.java create mode 100644 jps/model-api/src/org/jetbrains/jps/model/java/JpsAnnotationRootType.java create mode 100644 jps/model-api/src/org/jetbrains/jps/model/java/JpsJavaExtensionService.java rename jps/model-api/src/org/jetbrains/jps/model/java/{JavaModuleExtension.java => JpsJavaModuleExtension.java} (51%) create mode 100644 jps/model-impl/src/META-INF/services/org.jetbrains.jps.model.java.JpsJavaExtensionService create mode 100644 jps/model-impl/src/org/jetbrains/jps/model/impl/JpsUrlListKind.java create mode 100644 jps/model-impl/src/org/jetbrains/jps/model/java/impl/ExplodedDirectoryModuleExtensionImpl.java delete mode 100644 jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaModuleExtensionImpl.java create mode 100644 jps/model-impl/src/org/jetbrains/jps/model/java/impl/JpsJavaExtensionServiceImpl.java create mode 100644 jps/model-impl/src/org/jetbrains/jps/model/java/impl/JpsJavaModuleExtensionImpl.java diff --git a/jps/model-api/src/org/jetbrains/jps/model/JpsElementFactory.java b/jps/model-api/src/org/jetbrains/jps/model/JpsElementFactory.java index 1e25c2197573..d94c2711bf68 100644 --- a/jps/model-api/src/org/jetbrains/jps/model/JpsElementFactory.java +++ b/jps/model-api/src/org/jetbrains/jps/model/JpsElementFactory.java @@ -1,8 +1,12 @@ package org.jetbrains.jps.model; import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.model.library.JpsLibrary; import org.jetbrains.jps.model.library.JpsLibraryReference; +import org.jetbrains.jps.model.library.JpsLibraryType; +import org.jetbrains.jps.model.module.JpsModule; import org.jetbrains.jps.model.module.JpsModuleReference; +import org.jetbrains.jps.model.module.JpsModuleType; import org.jetbrains.jps.service.JpsServiceManager; /** @@ -13,6 +17,10 @@ public abstract class JpsElementFactory { return JpsServiceManager.getInstance().getService(JpsElementFactory.class); } + public abstract JpsModule createModule(String name, JpsModuleType type); + + public abstract JpsLibrary createLibrary(@NotNull String name, @NotNull JpsLibraryType type); + @NotNull public abstract JpsModuleReference createModuleReference(@NotNull String moduleName); @@ -20,4 +28,9 @@ public abstract class JpsElementFactory { public abstract JpsLibraryReference createLibraryReference(@NotNull String libraryName, @NotNull JpsElementReference parentReference); + @NotNull + public abstract JpsElementReference createProjectReference(); + + @NotNull + public abstract JpsElementReference createGlobalReference(); } diff --git a/jps/model-api/src/org/jetbrains/jps/model/JpsProject.java b/jps/model-api/src/org/jetbrains/jps/model/JpsProject.java index 0beb26b8a514..9855a4b3d5d8 100644 --- a/jps/model-api/src/org/jetbrains/jps/model/JpsProject.java +++ b/jps/model-api/src/org/jetbrains/jps/model/JpsProject.java @@ -24,4 +24,8 @@ public interface JpsProject extends JpsCompositeElement, JpsReferenceableElement @NotNull List getModules(); + + void addModule(JpsModule module); + + void addLibrary(JpsLibrary library); } diff --git a/jps/model-api/src/org/jetbrains/jps/model/java/ExplodedDirectoryModuleExtension.java b/jps/model-api/src/org/jetbrains/jps/model/java/ExplodedDirectoryModuleExtension.java new file mode 100644 index 000000000000..a1fcdb97e3e8 --- /dev/null +++ b/jps/model-api/src/org/jetbrains/jps/model/java/ExplodedDirectoryModuleExtension.java @@ -0,0 +1,18 @@ +package org.jetbrains.jps.model.java; + +import org.jetbrains.jps.model.JpsElement; + +/** + * @author nik + */ +//todo[nik] move to j2me plugin +public interface ExplodedDirectoryModuleExtension extends JpsElement { + + String getExplodedUrl(); + + void setExplodedUrl(String explodedUrl); + + boolean isExcludeExploded(); + + void setExcludeExploded(boolean excludeExploded); +} diff --git a/jps/model-api/src/org/jetbrains/jps/model/java/JpsAnnotationRootType.java b/jps/model-api/src/org/jetbrains/jps/model/java/JpsAnnotationRootType.java new file mode 100644 index 000000000000..51669166ac94 --- /dev/null +++ b/jps/model-api/src/org/jetbrains/jps/model/java/JpsAnnotationRootType.java @@ -0,0 +1,10 @@ +package org.jetbrains.jps.model.java; + +import org.jetbrains.jps.model.library.JpsOrderRootType; + +/** + * @author nik + */ +public class JpsAnnotationRootType extends JpsOrderRootType { + public static final JpsAnnotationRootType INSTANCE = new JpsAnnotationRootType(); +} diff --git a/jps/model-api/src/org/jetbrains/jps/model/java/JpsJavaExtensionService.java b/jps/model-api/src/org/jetbrains/jps/model/java/JpsJavaExtensionService.java new file mode 100644 index 000000000000..a7334ea52c87 --- /dev/null +++ b/jps/model-api/src/org/jetbrains/jps/model/java/JpsJavaExtensionService.java @@ -0,0 +1,31 @@ +package org.jetbrains.jps.model.java; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.model.JpsElementKind; +import org.jetbrains.jps.model.module.JpsDependencyElement; +import org.jetbrains.jps.model.module.JpsModule; +import org.jetbrains.jps.service.JpsServiceManager; + +/** + * @author nik + */ +public abstract class JpsJavaExtensionService { + public static JpsJavaExtensionService getInstance() { + return JpsServiceManager.getInstance().getService(JpsJavaExtensionService.class); + } + + @NotNull + public abstract JpsJavaModuleExtension getOrCreateModuleExtension(@NotNull JpsModule module); + + @NotNull + public abstract JpsJavaDependencyExtension getOrCreateDependencyExtension(@NotNull JpsDependencyElement dependency); + + @NotNull + public abstract JpsElementKind getModuleExtensionKind(); + + @NotNull + public abstract JpsElementKind getDependencyExtensionKind(); + + @NotNull + public abstract ExplodedDirectoryModuleExtension getOrCreateExplodedDirectoryExtension(@NotNull JpsModule module); +} diff --git a/jps/model-api/src/org/jetbrains/jps/model/java/JavaModuleExtension.java b/jps/model-api/src/org/jetbrains/jps/model/java/JpsJavaModuleExtension.java similarity index 51% rename from jps/model-api/src/org/jetbrains/jps/model/java/JavaModuleExtension.java rename to jps/model-api/src/org/jetbrains/jps/model/java/JpsJavaModuleExtension.java index 1ac6c18b42a4..f2c7bdcc2986 100644 --- a/jps/model-api/src/org/jetbrains/jps/model/java/JavaModuleExtension.java +++ b/jps/model-api/src/org/jetbrains/jps/model/java/JpsJavaModuleExtension.java @@ -1,11 +1,15 @@ package org.jetbrains.jps.model.java; import org.jetbrains.jps.model.JpsElement; +import org.jetbrains.jps.model.JpsUrlList; /** * @author nik */ -public interface JavaModuleExtension extends JpsElement { +public interface JpsJavaModuleExtension extends JpsElement { + JpsUrlList getJavadocRoots(); + + JpsUrlList getAnnotationRoots(); String getOutputUrl(); @@ -18,4 +22,12 @@ public interface JavaModuleExtension extends JpsElement { LanguageLevel getLanguageLevel(); void setLanguageLevel(LanguageLevel languageLevel); + + boolean isInheritOutput(); + + void setInheritOutput(boolean inheritOutput); + + boolean isExcludeOutput(); + + void setExcludeOutput(boolean excludeOutput); } diff --git a/jps/model-api/src/org/jetbrains/jps/model/library/JpsLibraryRootType.java b/jps/model-api/src/org/jetbrains/jps/model/library/JpsLibraryRootType.java index 70afc3f5e8ee..707344331440 100644 --- a/jps/model-api/src/org/jetbrains/jps/model/library/JpsLibraryRootType.java +++ b/jps/model-api/src/org/jetbrains/jps/model/library/JpsLibraryRootType.java @@ -4,14 +4,16 @@ package org.jetbrains.jps.model.library; * @author nik */ public class JpsLibraryRootType { - public static final JpsLibraryRootType COMPILED = new JpsLibraryRootType(JpsOrderRootType.COMPILED, false); - public static final JpsLibraryRootType SOURCES = new JpsLibraryRootType(JpsOrderRootType.SOURCES, false); + public static final JpsLibraryRootType COMPILED = new JpsLibraryRootType(JpsOrderRootType.COMPILED, false, false); + public static final JpsLibraryRootType SOURCES = new JpsLibraryRootType(JpsOrderRootType.SOURCES, false, false); private final boolean myJarDirectory; + private final boolean myRecursive; private final JpsOrderRootType myType; - public JpsLibraryRootType(JpsOrderRootType type, boolean jarDirectory) { - myType = type; + public JpsLibraryRootType(JpsOrderRootType type, boolean jarDirectory, boolean recursive) { myJarDirectory = jarDirectory; + myRecursive = recursive; + myType = type; } public boolean isJarDirectory() { @@ -21,4 +23,8 @@ public class JpsLibraryRootType { public JpsOrderRootType getType() { return myType; } + + public boolean isRecursive() { + return myRecursive; + } } diff --git a/jps/model-api/src/org/jetbrains/jps/model/module/JpsModule.java b/jps/model-api/src/org/jetbrains/jps/model/module/JpsModule.java index fdc54705c502..88aa5b375f8e 100644 --- a/jps/model-api/src/org/jetbrains/jps/model/module/JpsModule.java +++ b/jps/model-api/src/org/jetbrains/jps/model/module/JpsModule.java @@ -42,6 +42,9 @@ public interface JpsModule extends JpsNamedElement, JpsReferenceableElement type, @NotNull String name); + @NotNull + JpsLibrary addModuleLibrary(@NotNull JpsLibrary library); + void delete(); @NotNull diff --git a/jps/model-api/src/org/jetbrains/jps/service/JpsServiceManager.java b/jps/model-api/src/org/jetbrains/jps/service/JpsServiceManager.java index d24524ca3664..2f86a7898341 100644 --- a/jps/model-api/src/org/jetbrains/jps/service/JpsServiceManager.java +++ b/jps/model-api/src/org/jetbrains/jps/service/JpsServiceManager.java @@ -12,8 +12,11 @@ public abstract class JpsServiceManager { public abstract T getService(Class serviceClass); + public abstract Iterable getExtensions(Class extensionClass); + private static class InstanceHolder { private static final JpsServiceManager INSTANCE; + static { INSTANCE = ServiceLoader.load(JpsServiceManager.class).iterator().next(); } diff --git a/jps/model-impl/src/META-INF/services/org.jetbrains.jps.model.java.JpsJavaExtensionService b/jps/model-impl/src/META-INF/services/org.jetbrains.jps.model.java.JpsJavaExtensionService new file mode 100644 index 000000000000..3d58916622f6 --- /dev/null +++ b/jps/model-impl/src/META-INF/services/org.jetbrains.jps.model.java.JpsJavaExtensionService @@ -0,0 +1 @@ +org.jetbrains.jps.model.java.impl.JpsJavaExtensionServiceImpl \ No newline at end of file diff --git a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsElementFactoryImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsElementFactoryImpl.java index 70492b460fe7..21902607503a 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsElementFactoryImpl.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsElementFactoryImpl.java @@ -2,15 +2,32 @@ package org.jetbrains.jps.model.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.model.*; +import org.jetbrains.jps.model.library.JpsLibrary; import org.jetbrains.jps.model.library.JpsLibraryReference; +import org.jetbrains.jps.model.library.JpsLibraryType; +import org.jetbrains.jps.model.library.impl.JpsLibraryImpl; import org.jetbrains.jps.model.library.impl.JpsLibraryReferenceImpl; +import org.jetbrains.jps.model.module.JpsModule; import org.jetbrains.jps.model.module.JpsModuleReference; +import org.jetbrains.jps.model.module.JpsModuleType; +import org.jetbrains.jps.model.module.impl.JpsModuleImpl; import org.jetbrains.jps.model.module.impl.JpsModuleReferenceImpl; /** * @author nik */ public class JpsElementFactoryImpl extends JpsElementFactory { + + @Override + public JpsModule createModule(String name, JpsModuleType type) { + return new JpsModuleImpl(type, name); + } + + @Override + public JpsLibrary createLibrary(@NotNull String name, @NotNull JpsLibraryType type) { + return new JpsLibraryImpl(name, type); + } + @NotNull @Override public JpsModuleReference createModuleReference(@NotNull String moduleName) { @@ -23,4 +40,16 @@ public class JpsElementFactoryImpl extends JpsElementFactory { @NotNull JpsElementReference parentReference) { return new JpsLibraryReferenceImpl(libraryName, parentReference); } + + @NotNull + @Override + public JpsElementReference createProjectReference() { + return new JpsProjectElementReference(); + } + + @NotNull + @Override + public JpsElementReference createGlobalReference() { + return new JpsGlobalElementReference(); + } } diff --git a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsGlobalImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsGlobalImpl.java index c5bb2c500b64..f48ad0d0f365 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsGlobalImpl.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsGlobalImpl.java @@ -23,7 +23,7 @@ public class JpsGlobalImpl extends JpsRootElementBase implements @NotNull @Override public JpsLibrary addLibrary(@NotNull JpsLibraryType libraryType, @NotNull final String name) { - final JpsElementCollectionImpl collection = myContainer.getChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND); + final JpsElementCollectionImpl collection = myContainer.getChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND); return collection.addChild(new JpsLibraryImpl(name, libraryType)); } diff --git a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsProjectImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsProjectImpl.java index ff8d13885d40..e70099f276da 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsProjectImpl.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsProjectImpl.java @@ -17,7 +17,8 @@ import java.util.List; * @author nik */ public class JpsProjectImpl extends JpsRootElementBase implements JpsProject { - private static final JpsElementCollectionKind> EXTERNAL_REFERENCES_COLLECTION_KIND = new JpsElementCollectionKind>(new JpsElementKindBase>("external reference")); + private static final JpsElementCollectionKind> EXTERNAL_REFERENCES_COLLECTION_KIND = + new JpsElementCollectionKind>(new JpsElementKindBase>("external reference")); public JpsProjectImpl(JpsModel model, JpsEventDispatcher eventDispatcher) { super(model, eventDispatcher); @@ -37,14 +38,14 @@ public class JpsProjectImpl extends JpsRootElementBase implement @NotNull @Override public JpsModule addModule(@NotNull JpsModuleType moduleType, @NotNull final String name) { - final JpsElementCollectionImpl collection = myContainer.getChild(JpsModuleKind.MODULE_COLLECTION_KIND); + final JpsElementCollectionImpl collection = myContainer.getChild(JpsModuleKind.MODULE_COLLECTION_KIND); return collection.addChild(new JpsModuleImpl(moduleType, name)); } @NotNull @Override public JpsLibrary addLibrary(@NotNull JpsLibraryType libraryType, @NotNull final String name) { - final JpsElementCollectionImpl collection = myContainer.getChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND); + final JpsElementCollectionImpl collection = myContainer.getChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND); return collection.addChild(new JpsLibraryImpl(name, libraryType)); } @@ -60,6 +61,16 @@ public class JpsProjectImpl extends JpsRootElementBase implement return myContainer.getChild(JpsModuleKind.MODULE_COLLECTION_KIND).getElements(); } + @Override + public void addModule(JpsModule module) { + myContainer.getChild(JpsModuleKind.MODULE_COLLECTION_KIND).addChild(module); + } + + @Override + public void addLibrary(JpsLibrary library) { + myContainer.getChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND).addChild(library); + } + @NotNull @Override public JpsElementReference createReference() { diff --git a/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsUrlListKind.java b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsUrlListKind.java new file mode 100644 index 000000000000..95c6f2e1ac0f --- /dev/null +++ b/jps/model-impl/src/org/jetbrains/jps/model/impl/JpsUrlListKind.java @@ -0,0 +1,20 @@ +package org.jetbrains.jps.model.impl; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.model.JpsElementCreator; +import org.jetbrains.jps.model.JpsUrlList; + +/** + * @author nik + */ +public class JpsUrlListKind extends JpsElementKindBase implements JpsElementCreator { + public JpsUrlListKind(String debugName) { + super(debugName); + } + + @NotNull + @Override + public JpsUrlList create() { + return new JpsUrlListImpl(); + } +} diff --git a/jps/model-impl/src/org/jetbrains/jps/model/java/impl/ExplodedDirectoryModuleExtensionImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/java/impl/ExplodedDirectoryModuleExtensionImpl.java new file mode 100644 index 000000000000..e8a03bf27cb2 --- /dev/null +++ b/jps/model-impl/src/org/jetbrains/jps/model/java/impl/ExplodedDirectoryModuleExtensionImpl.java @@ -0,0 +1,65 @@ +package org.jetbrains.jps.model.java.impl; + +import com.intellij.openapi.util.Comparing; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.model.impl.JpsElementBase; +import org.jetbrains.jps.model.impl.JpsElementKindBase; +import org.jetbrains.jps.model.java.ExplodedDirectoryModuleExtension; + +/** + * @author nik + */ +public class ExplodedDirectoryModuleExtensionImpl extends JpsElementBase implements + ExplodedDirectoryModuleExtension { + public static final JpsElementKindBase KIND = + new JpsElementKindBase("exploded directory"); + + private String myExplodedUrl; + private boolean myExcludeExploded; + + public ExplodedDirectoryModuleExtensionImpl() { + } + + public ExplodedDirectoryModuleExtensionImpl(ExplodedDirectoryModuleExtensionImpl original) { + myExcludeExploded = original.myExcludeExploded; + myExplodedUrl = original.myExplodedUrl; + } + + @Override + public String getExplodedUrl() { + return myExplodedUrl; + } + + @Override + public void setExplodedUrl(String explodedUrl) { + if (!Comparing.equal(myExplodedUrl, explodedUrl)) { + myExplodedUrl = explodedUrl; + fireElementChanged(); + } + } + + @Override + public boolean isExcludeExploded() { + return myExcludeExploded; + } + + @Override + public void setExcludeExploded(boolean excludeExploded) { + if (myExcludeExploded != excludeExploded) { + myExcludeExploded = excludeExploded; + fireElementChanged(); + } + } + + @NotNull + @Override + public ExplodedDirectoryModuleExtensionImpl createCopy() { + return new ExplodedDirectoryModuleExtensionImpl(this); + } + + @Override + public void applyChanges(@NotNull ExplodedDirectoryModuleExtensionImpl modified) { + setExcludeExploded(modified.myExcludeExploded); + setExplodedUrl(modified.myExplodedUrl); + } +} diff --git a/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaModuleExtensionImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaModuleExtensionImpl.java deleted file mode 100644 index 4bf2a2b70bc5..000000000000 --- a/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaModuleExtensionImpl.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.jetbrains.jps.model.java.impl; - -import com.intellij.openapi.util.Comparing; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jps.model.impl.JpsElementBase; -import org.jetbrains.jps.model.java.JavaModuleExtension; -import org.jetbrains.jps.model.java.LanguageLevel; - -/** - * @author nik - */ -public class JavaModuleExtensionImpl extends JpsElementBase implements JavaModuleExtension { - private String myOutputUrl; - private String myTestOutputUrl; - private LanguageLevel myLanguageLevel; - - public JavaModuleExtensionImpl() { - } - - public JavaModuleExtensionImpl(JavaModuleExtensionImpl original) { - myOutputUrl = original.myOutputUrl; - myTestOutputUrl = original.myTestOutputUrl; - myLanguageLevel = original.myLanguageLevel; - } - - @NotNull - @Override - public JavaModuleExtensionImpl createCopy() { - return new JavaModuleExtensionImpl(this); - } - - @Override - public String getOutputUrl() { - return myOutputUrl; - } - - @Override - public void setOutputUrl(String outputUrl) { - if (!Comparing.equal(myOutputUrl, outputUrl)) { - myOutputUrl = outputUrl; - fireElementChanged(); - } - } - - @Override - public String getTestOutputUrl() { - return myTestOutputUrl; - } - - @Override - public void setTestOutputUrl(String testOutputUrl) { - if (!Comparing.equal(myTestOutputUrl, testOutputUrl)) { - myTestOutputUrl = testOutputUrl; - fireElementChanged(); - } - } - - @Override - public LanguageLevel getLanguageLevel() { - return myLanguageLevel; - } - - @Override - public void setLanguageLevel(LanguageLevel languageLevel) { - if (!Comparing.equal(myLanguageLevel, languageLevel)) { - myLanguageLevel = languageLevel; - fireElementChanged(); - } - } - - public void applyChanges(@NotNull JavaModuleExtensionImpl modified) { - setLanguageLevel(modified.myLanguageLevel); - setOutputUrl(modified.myOutputUrl); - setTestOutputUrl(modified.myTestOutputUrl); - } -} diff --git a/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaModuleExtensionKind.java b/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaModuleExtensionKind.java index 5425a5521da4..d46529ff5010 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaModuleExtensionKind.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JavaModuleExtensionKind.java @@ -1,33 +1,23 @@ package org.jetbrains.jps.model.java.impl; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jps.model.*; +import org.jetbrains.jps.model.JpsElementCreator; import org.jetbrains.jps.model.impl.JpsElementKindBase; -import org.jetbrains.jps.model.java.JavaModuleExtension; -import org.jetbrains.jps.model.module.JpsModule; /** * @author nik */ -public class JavaModuleExtensionKind extends JpsElementKindBase implements JpsElementCreator { - private static final JavaModuleExtensionKind INSTANCE = new JavaModuleExtensionKind(); +public class JavaModuleExtensionKind extends JpsElementKindBase + implements JpsElementCreator { + public static final JavaModuleExtensionKind INSTANCE = new JavaModuleExtensionKind(); - public JavaModuleExtensionKind() { + private JavaModuleExtensionKind() { super("java module extension"); } @NotNull @Override - public JavaModuleExtensionImpl create() { - return new JavaModuleExtensionImpl(); - } - - @NotNull - public static JavaModuleExtension getExtension(@NotNull JpsModule module) { - JavaModuleExtension child = module.getContainer().getChild(INSTANCE); - if (child == null) { - child = module.getContainer().setChild(INSTANCE); - } - return child; + public JpsJavaModuleExtensionImpl create() { + return new JpsJavaModuleExtensionImpl(); } } diff --git a/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JpsJavaDependencyExtensionKind.java b/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JpsJavaDependencyExtensionKind.java index 0319b55211ca..48555c5b7de7 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JpsJavaDependencyExtensionKind.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JpsJavaDependencyExtensionKind.java @@ -1,19 +1,18 @@ package org.jetbrains.jps.model.java.impl; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jps.model.*; +import org.jetbrains.jps.model.JpsElementCreator; import org.jetbrains.jps.model.impl.JpsElementKindBase; -import org.jetbrains.jps.model.java.JpsJavaDependencyExtension; import org.jetbrains.jps.model.java.JpsJavaDependencyScope; -import org.jetbrains.jps.model.module.JpsDependencyElement; /** * @author nik */ -public class JpsJavaDependencyExtensionKind extends JpsElementKindBase implements JpsElementCreator { +public class JpsJavaDependencyExtensionKind extends JpsElementKindBase + implements JpsElementCreator { public static final JpsJavaDependencyExtensionKind INSTANCE = new JpsJavaDependencyExtensionKind(); - public JpsJavaDependencyExtensionKind() { + private JpsJavaDependencyExtensionKind() { super("java dependency extension"); } @@ -22,12 +21,4 @@ public class JpsJavaDependencyExtensionKind extends JpsElementKindBase getModuleExtensionKind() { + return JavaModuleExtensionKind.INSTANCE; + } + + @NotNull + @Override + public JpsElementKind getDependencyExtensionKind() { + return JpsJavaDependencyExtensionKind.INSTANCE; + } + + @Override + @NotNull + public ExplodedDirectoryModuleExtension getOrCreateExplodedDirectoryExtension(@NotNull JpsModule module) { + ExplodedDirectoryModuleExtension extension = module.getContainer().getChild(ExplodedDirectoryModuleExtensionImpl.KIND); + if (extension == null) { + extension = module.getContainer().setChild(ExplodedDirectoryModuleExtensionImpl.KIND, new ExplodedDirectoryModuleExtensionImpl()); + } + return extension; + } +} diff --git a/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JpsJavaModuleExtensionImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JpsJavaModuleExtensionImpl.java new file mode 100644 index 000000000000..0dba7526275a --- /dev/null +++ b/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JpsJavaModuleExtensionImpl.java @@ -0,0 +1,121 @@ +package org.jetbrains.jps.model.java.impl; + +import com.intellij.openapi.util.Comparing; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.model.JpsUrlList; +import org.jetbrains.jps.model.impl.JpsCompositeElementBase; +import org.jetbrains.jps.model.impl.JpsUrlListKind; +import org.jetbrains.jps.model.java.JpsJavaModuleExtension; +import org.jetbrains.jps.model.java.LanguageLevel; + +/** + * @author nik + */ +public class JpsJavaModuleExtensionImpl extends JpsCompositeElementBase implements JpsJavaModuleExtension { + private static final JpsUrlListKind JAVADOC_ROOTS_KIND = new JpsUrlListKind("javadoc roots"); + private static final JpsUrlListKind ANNOTATIONS_ROOTS_KIND = new JpsUrlListKind("annotation roots"); + private String myOutputUrl; + private String myTestOutputUrl; + private boolean myInheritOutput; + private boolean myExcludeOutput; + private LanguageLevel myLanguageLevel; + + public JpsJavaModuleExtensionImpl() { + myContainer.setChild(JAVADOC_ROOTS_KIND); + myContainer.setChild(ANNOTATIONS_ROOTS_KIND); + } + + public JpsJavaModuleExtensionImpl(JpsJavaModuleExtensionImpl original) { + super(original); + myOutputUrl = original.myOutputUrl; + myTestOutputUrl = original.myTestOutputUrl; + myLanguageLevel = original.myLanguageLevel; + } + + @NotNull + @Override + public JpsJavaModuleExtensionImpl createCopy() { + return new JpsJavaModuleExtensionImpl(this); + } + + @Override + public JpsUrlList getAnnotationRoots() { + return myContainer.getChild(ANNOTATIONS_ROOTS_KIND); + } + + @Override + public JpsUrlList getJavadocRoots() { + return myContainer.getChild(JAVADOC_ROOTS_KIND); + } + + @Override + public String getOutputUrl() { + return myOutputUrl; + } + + @Override + public void setOutputUrl(String outputUrl) { + if (!Comparing.equal(myOutputUrl, outputUrl)) { + myOutputUrl = outputUrl; + fireElementChanged(); + } + } + + @Override + public String getTestOutputUrl() { + return myTestOutputUrl; + } + + @Override + public void setTestOutputUrl(String testOutputUrl) { + if (!Comparing.equal(myTestOutputUrl, testOutputUrl)) { + myTestOutputUrl = testOutputUrl; + fireElementChanged(); + } + } + + @Override + public LanguageLevel getLanguageLevel() { + return myLanguageLevel; + } + + @Override + public void setLanguageLevel(LanguageLevel languageLevel) { + if (!Comparing.equal(myLanguageLevel, languageLevel)) { + myLanguageLevel = languageLevel; + fireElementChanged(); + } + } + + public void applyChanges(@NotNull JpsJavaModuleExtensionImpl modified) { + setLanguageLevel(modified.myLanguageLevel); + setOutputUrl(modified.myOutputUrl); + setTestOutputUrl(modified.myTestOutputUrl); + } + + @Override + public boolean isInheritOutput() { + return myInheritOutput; + } + + @Override + public void setInheritOutput(boolean inheritOutput) { + if (myInheritOutput != inheritOutput) { + myInheritOutput = inheritOutput; + fireElementChanged(); + } + } + + @Override + public boolean isExcludeOutput() { + return myExcludeOutput; + } + + @Override + public void setExcludeOutput(boolean excludeOutput) { + if (myExcludeOutput != excludeOutput) { + myExcludeOutput = excludeOutput; + fireElementChanged(); + } + } +} diff --git a/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryImpl.java index 45728e409a93..beb49333b109 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryImpl.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryImpl.java @@ -15,7 +15,8 @@ import java.util.List; * @author nik */ public class JpsLibraryImpl extends JpsNamedCompositeElementBase implements JpsLibrary { - private static final JpsElementCollectionKind LIBRARY_ROOTS_COLLECTION = new JpsElementCollectionKind(JpsLibraryRootKind.INSTANCE); + private static final JpsElementCollectionKind LIBRARY_ROOTS_COLLECTION = + new JpsElementCollectionKind(JpsLibraryRootKind.INSTANCE); private static final JpsTypedDataKind> TYPED_DATA_KIND = new JpsTypedDataKind>(); public JpsLibraryImpl(@NotNull String name, @NotNull JpsLibraryType type) { @@ -65,9 +66,9 @@ public class JpsLibraryImpl extends JpsNamedCompositeElementBase getParent() { + public JpsElementCollectionImpl getParent() { //noinspection unchecked - return (JpsElementCollectionImpl)myParent; + return (JpsElementCollectionImpl)myParent; } @NotNull @@ -80,7 +81,8 @@ public class JpsLibraryImpl extends JpsNamedCompositeElementBase parentReference = ((JpsReferenceableElement)getParent().getParent()).createReference(); + final JpsElementReference parentReference = + ((JpsReferenceableElement)getParent().getParent()).createReference(); return new JpsLibraryReferenceImpl(getName(), parentReference); } } diff --git a/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryKind.java b/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryKind.java index 9e09aa2d9ec1..c6da7110d833 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryKind.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/library/impl/JpsLibraryKind.java @@ -1,29 +1,30 @@ package org.jetbrains.jps.model.library.impl; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jps.model.impl.JpsElementKindBase; import org.jetbrains.jps.model.JpsEventDispatcher; import org.jetbrains.jps.model.impl.JpsElementCollectionKind; +import org.jetbrains.jps.model.impl.JpsElementKindBase; +import org.jetbrains.jps.model.library.JpsLibrary; import org.jetbrains.jps.model.library.JpsLibraryListener; /** * @author nik */ -public class JpsLibraryKind extends JpsElementKindBase { +public class JpsLibraryKind extends JpsElementKindBase { public static final JpsLibraryKind INSTANCE = new JpsLibraryKind(); - public static final JpsElementCollectionKind LIBRARIES_COLLECTION_KIND = new JpsElementCollectionKind(INSTANCE); + public static final JpsElementCollectionKind LIBRARIES_COLLECTION_KIND = new JpsElementCollectionKind(INSTANCE); private JpsLibraryKind() { super("library"); } @Override - public void fireElementAdded(@NotNull JpsEventDispatcher dispatcher, @NotNull JpsLibraryImpl element) { + public void fireElementAdded(@NotNull JpsEventDispatcher dispatcher, @NotNull JpsLibrary element) { dispatcher.getPublisher(JpsLibraryListener.class).libraryAdded(element); } @Override - public void fireElementRemoved(@NotNull JpsEventDispatcher dispatcher, @NotNull JpsLibraryImpl element) { + public void fireElementRemoved(@NotNull JpsEventDispatcher dispatcher, @NotNull JpsLibrary element) { dispatcher.getPublisher(JpsLibraryListener.class).libraryRemoved(element); } } diff --git a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleImpl.java index 49fc525c5ee0..adb148b5da3d 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleImpl.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleImpl.java @@ -16,16 +16,17 @@ import java.util.List; */ public class JpsModuleImpl extends JpsNamedCompositeElementBase implements JpsModule { private static final JpsTypedDataKind> TYPED_DATA_KIND = new JpsTypedDataKind>(); - private static final JpsElementKind CONTENT_ROOTS_KIND = new JpsElementKindBase("content roots"); - private static final JpsElementKind EXCLUDED_ROOTS_KIND = new JpsElementKindBase("excluded roots"); - public static final JpsElementKind DEPENDENCIES_LIST_KIND = new JpsElementKindBase("dependencies"); + private static final JpsUrlListKind CONTENT_ROOTS_KIND = new JpsUrlListKind("content roots"); + private static final JpsUrlListKind EXCLUDED_ROOTS_KIND = new JpsUrlListKind("excluded roots"); + public static final JpsElementKind DEPENDENCIES_LIST_KIND = + new JpsElementKindBase("dependencies"); public JpsModuleImpl(JpsModuleType type, @NotNull String name) { super(name); myContainer.setChild(TYPED_DATA_KIND, new JpsTypedDataImpl>(type)); - myContainer.setChild(CONTENT_ROOTS_KIND, new JpsUrlListImpl()); - myContainer.setChild(EXCLUDED_ROOTS_KIND, new JpsUrlListImpl()); + myContainer.setChild(CONTENT_ROOTS_KIND); + myContainer.setChild(EXCLUDED_ROOTS_KIND); myContainer.setChild(DEPENDENCIES_LIST_KIND, new JpsDependenciesListImpl()); myContainer.setChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND); myContainer.setChild(JpsModuleSourceRootKind.ROOT_COLLECTION_KIND); @@ -115,7 +116,12 @@ public class JpsModuleImpl extends JpsNamedCompositeElementBase type, @NotNull String name) { - final JpsElementCollectionImpl collection = myContainer.getChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND); - return collection.addChild(new JpsLibraryImpl(name, type)); + return addModuleLibrary(new JpsLibraryImpl(name, type)); + } + + @NotNull + @Override + public JpsLibrary addModuleLibrary(final @NotNull JpsLibrary library) { + return myContainer.getChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND).addChild(library); } } diff --git a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleKind.java b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleKind.java index 9fe135efa227..affce588f0b5 100644 --- a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleKind.java +++ b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleKind.java @@ -2,29 +2,30 @@ package org.jetbrains.jps.model.module.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.model.JpsElementKind; -import org.jetbrains.jps.model.impl.JpsElementKindBase; import org.jetbrains.jps.model.JpsEventDispatcher; import org.jetbrains.jps.model.impl.JpsElementCollectionKind; +import org.jetbrains.jps.model.impl.JpsElementKindBase; +import org.jetbrains.jps.model.module.JpsModule; import org.jetbrains.jps.model.module.JpsModuleListener; /** * @author nik */ -public class JpsModuleKind extends JpsElementKindBase { - public static final JpsElementKind INSTANCE = new JpsModuleKind(); - public static final JpsElementCollectionKind MODULE_COLLECTION_KIND = new JpsElementCollectionKind(INSTANCE); +public class JpsModuleKind extends JpsElementKindBase { + public static final JpsElementKind INSTANCE = new JpsModuleKind(); + public static final JpsElementCollectionKind MODULE_COLLECTION_KIND = new JpsElementCollectionKind(INSTANCE); public JpsModuleKind() { super("module"); } @Override - public void fireElementAdded(@NotNull JpsEventDispatcher dispatcher, @NotNull JpsModuleImpl element) { + public void fireElementAdded(@NotNull JpsEventDispatcher dispatcher, @NotNull JpsModule element) { dispatcher.getPublisher(JpsModuleListener.class).moduleAdded(element); } @Override - public void fireElementRemoved(@NotNull JpsEventDispatcher dispatcher, @NotNull JpsModuleImpl element) { + public void fireElementRemoved(@NotNull JpsEventDispatcher dispatcher, @NotNull JpsModule element) { dispatcher.getPublisher(JpsModuleListener.class).moduleRemoved(element); } } diff --git a/jps/model-impl/src/org/jetbrains/jps/service/impl/JpsServiceManagerImpl.java b/jps/model-impl/src/org/jetbrains/jps/service/impl/JpsServiceManagerImpl.java index 4f9c546a4cef..960bcff17879 100644 --- a/jps/model-impl/src/org/jetbrains/jps/service/impl/JpsServiceManagerImpl.java +++ b/jps/model-impl/src/org/jetbrains/jps/service/impl/JpsServiceManagerImpl.java @@ -3,6 +3,7 @@ package org.jetbrains.jps.service.impl; import org.jetbrains.jps.service.JpsServiceManager; import java.util.Iterator; +import java.util.List; import java.util.ServiceConfigurationError; import java.util.ServiceLoader; import java.util.concurrent.ConcurrentHashMap; @@ -12,6 +13,7 @@ import java.util.concurrent.ConcurrentHashMap; */ public class JpsServiceManagerImpl extends JpsServiceManager { private final ConcurrentHashMap myServices = new ConcurrentHashMap(); + private final ConcurrentHashMap> myExtensions = new ConcurrentHashMap>(); @Override public T getService(Class serviceClass) { @@ -24,10 +26,16 @@ public class JpsServiceManagerImpl extends JpsServiceManager { } service = iterator.next(); if (iterator.hasNext()) { - throw new ServiceConfigurationError("More than one implementation for " + serviceClass + " found: " + service.getClass() + " and " + iterator.next().getClass()); + throw new ServiceConfigurationError( + "More than one implementation for " + serviceClass + " found: " + service.getClass() + " and " + iterator.next().getClass()); } myServices.putIfAbsent(serviceClass, service); } return service; } + + @Override + public Iterable getExtensions(Class extensionClass) { + return ServiceLoader.load(extensionClass); + } } diff --git a/jps/model-impl/testSrc/org/jetbrains/jps/model/JpsJavaExtensionTest.java b/jps/model-impl/testSrc/org/jetbrains/jps/model/JpsJavaExtensionTest.java index 0b5609390503..3e66b86643d5 100644 --- a/jps/model-impl/testSrc/org/jetbrains/jps/model/JpsJavaExtensionTest.java +++ b/jps/model-impl/testSrc/org/jetbrains/jps/model/JpsJavaExtensionTest.java @@ -1,11 +1,6 @@ package org.jetbrains.jps.model; -import org.jetbrains.jps.model.java.JpsJavaDependencyExtension; -import org.jetbrains.jps.model.java.JpsJavaDependencyScope; -import org.jetbrains.jps.model.java.JpsJavaLibraryType; -import org.jetbrains.jps.model.java.JpsJavaModuleType; -import org.jetbrains.jps.model.java.impl.JavaModuleExtensionKind; -import org.jetbrains.jps.model.java.impl.JpsJavaDependencyExtensionKind; +import org.jetbrains.jps.model.java.*; import org.jetbrains.jps.model.library.JpsLibrary; import org.jetbrains.jps.model.module.JpsDependencyElement; import org.jetbrains.jps.model.module.JpsLibraryDependency; @@ -17,8 +12,10 @@ import org.jetbrains.jps.model.module.JpsModule; public class JpsJavaExtensionTest extends JpsModelTestCase { public void testModule() { final JpsModule module = myModel.getProject().addModule(JpsJavaModuleType.INSTANCE, "m"); - JavaModuleExtensionKind.getExtension(module).setOutputUrl("file://path"); - assertEquals("file://path", JavaModuleExtensionKind.getExtension(module).getOutputUrl()); + final JpsJavaModuleExtension extension = JpsJavaExtensionService.getInstance().getOrCreateModuleExtension(module); + extension.setOutputUrl("file://path"); + assertEquals("file://path", + module.getContainer().getChild(JpsJavaExtensionService.getInstance().getModuleExtensionKind()).getOutputUrl()); } public void testDependency() { @@ -26,12 +23,14 @@ public class JpsJavaExtensionTest extends JpsModelTestCase { final JpsModule module = model.getProject().addModule(JpsJavaModuleType.INSTANCE, "m"); final JpsLibrary library = model.getProject().addLibrary(JpsJavaLibraryType.INSTANCE, "l"); final JpsLibraryDependency dependency = module.getDependenciesList().addLibraryDependency(library); - JpsJavaDependencyExtensionKind.getExtension(dependency).setScope(JpsJavaDependencyScope.TEST); - JpsJavaDependencyExtensionKind.getExtension(dependency).setExported(true); + JpsJavaExtensionService.getInstance().getOrCreateDependencyExtension(dependency).setScope(JpsJavaDependencyScope.TEST); + JpsJavaExtensionService.getInstance().getOrCreateDependencyExtension(dependency).setExported(true); model.commit(); - final JpsDependencyElement dep = assertOneElement(assertOneElement(myModel.getProject().getModules()).getDependenciesList().getDependencies()); - final JpsJavaDependencyExtension extension = dep.getContainer().getChild(JpsJavaDependencyExtensionKind.INSTANCE); + final JpsDependencyElement dep = + assertOneElement(assertOneElement(myModel.getProject().getModules()).getDependenciesList().getDependencies()); + final JpsJavaDependencyExtension extension = + dep.getContainer().getChild(JpsJavaExtensionService.getInstance().getDependencyExtensionKind()); assertTrue(extension.isExported()); assertSame(JpsJavaDependencyScope.TEST, extension.getScope()); } From be058e0961a53d6b95501a893d2685bda3eec9d3 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 14 Jun 2012 17:14:57 +0400 Subject: [PATCH 166/172] new project model: loading project from disk --- .idea/modules.xml | 362 +++++++++++------- .../jps-model-serialization.iml | 19 + ...odel.serialization.JpsModelLoaderExtension | 1 + .../serialization/JpsLibraryTableLoader.java | 84 ++++ .../JpsModelLoaderExtension.java | 38 ++ .../JpsModuleComponentSerializer.java | 15 + .../model/serialization/JpsModuleLoader.java | 120 ++++++ .../model/serialization/JpsProjectLoader.java | 144 +++++++ .../java/JpsJavaModelLoaderExtension.java | 83 ++++ .../testData/iprProject/iprProject.iml | 27 ++ .../testData/iprProject/iprProject.ipr | 59 +++ .../JpsModuleSerializationTest.java | 31 ++ 12 files changed, 853 insertions(+), 130 deletions(-) create mode 100644 jps/model-serialization/jps-model-serialization.iml create mode 100644 jps/model-serialization/src/META-INF/services/org.jetbrains.jps.model.serialization.JpsModelLoaderExtension create mode 100644 jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsLibraryTableLoader.java create mode 100644 jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsModelLoaderExtension.java create mode 100644 jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsModuleComponentSerializer.java create mode 100644 jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsModuleLoader.java create mode 100644 jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsProjectLoader.java create mode 100644 jps/model-serialization/src/org/jetbrains/jps/model/serialization/java/JpsJavaModelLoaderExtension.java create mode 100644 jps/model-serialization/testData/iprProject/iprProject.iml create mode 100644 jps/model-serialization/testData/iprProject/iprProject.ipr create mode 100644 jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsModuleSerializationTest.java diff --git a/.idea/modules.xml b/.idea/modules.xml index 7dd2c78681b2..90f05a8508f1 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,136 +2,238 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/model-serialization/jps-model-serialization.iml b/jps/model-serialization/jps-model-serialization.iml new file mode 100644 index 000000000000..2ed39f108303 --- /dev/null +++ b/jps/model-serialization/jps-model-serialization.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/jps/model-serialization/src/META-INF/services/org.jetbrains.jps.model.serialization.JpsModelLoaderExtension b/jps/model-serialization/src/META-INF/services/org.jetbrains.jps.model.serialization.JpsModelLoaderExtension new file mode 100644 index 000000000000..4a1c8009b1c3 --- /dev/null +++ b/jps/model-serialization/src/META-INF/services/org.jetbrains.jps.model.serialization.JpsModelLoaderExtension @@ -0,0 +1 @@ +org.jetbrains.jps.model.serialization.java.JpsJavaModelLoaderExtension \ No newline at end of file diff --git a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsLibraryTableLoader.java b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsLibraryTableLoader.java new file mode 100644 index 000000000000..ee53d55a93a9 --- /dev/null +++ b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsLibraryTableLoader.java @@ -0,0 +1,84 @@ +package org.jetbrains.jps.model.serialization; + +import com.intellij.openapi.util.JDOMUtil; +import com.intellij.util.containers.MultiMap; +import org.jdom.Element; +import org.jetbrains.jps.model.JpsElementFactory; +import org.jetbrains.jps.model.java.JpsJavaLibraryType; +import org.jetbrains.jps.model.library.JpsLibrary; +import org.jetbrains.jps.model.library.JpsLibraryRootType; +import org.jetbrains.jps.model.library.JpsLibraryType; +import org.jetbrains.jps.model.library.JpsOrderRootType; +import org.jetbrains.jps.service.JpsServiceManager; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author nik + */ +public class JpsLibraryTableLoader { + private static final Map PREDEFINED_ROOT_TYPES = new HashMap(); + + static { + PREDEFINED_ROOT_TYPES.put("CLASSES", JpsOrderRootType.COMPILED); + PREDEFINED_ROOT_TYPES.put("SOURCES", JpsOrderRootType.SOURCES); + } + + public static void loadLibraries(Element libraryTableElement, List result) { + for (Element libraryElement : JDOMUtil.getChildren(libraryTableElement, "library")) { + JpsLibrary library = loadLibrary(libraryElement); + result.add(library); + } + } + + public static JpsLibrary loadLibrary(Element libraryElement) { + String name = libraryElement.getAttributeValue("name"); + String typeId = libraryElement.getAttributeValue("type"); + JpsLibrary library = JpsElementFactory.getInstance().createLibrary(name, getLibraryType(typeId)); + + MultiMap jarDirectories = new MultiMap(); + MultiMap recursiveJarDirectories = new MultiMap(); + for (Element jarDirectory : JDOMUtil.getChildren(libraryElement, "jarDirectory")) { + String url = jarDirectory.getAttributeValue("url"); + String rootType = jarDirectory.getAttributeValue("type"); + boolean recursive = Boolean.parseBoolean(jarDirectory.getAttributeValue("recursive")); + jarDirectories.putValue(getRootType(rootType), url); + if (recursive) { + recursiveJarDirectories.putValue(getRootType(rootType), url); + } + } + for (Element rootsElement : JDOMUtil.getChildren(libraryElement)) { + final String rootTypeId = rootsElement.getName(); + if (!rootTypeId.equals("jarDirectory")) { + final JpsOrderRootType rootType = getRootType(rootTypeId); + for (Element rootElement : JDOMUtil.getChildren(rootsElement, "root")) { + String url = rootElement.getAttributeValue("url"); + final boolean jarDirectory = jarDirectories.get(rootType).contains(url); + final boolean recursive = recursiveJarDirectories.get(rootType).contains(url); + library.addUrl(url, new JpsLibraryRootType(rootType, jarDirectory, recursive)); + } + } + } + return library; + } + + private static JpsOrderRootType getRootType(String rootTypeId) { + final JpsOrderRootType type = PREDEFINED_ROOT_TYPES.get(rootTypeId); + if (type != null) { + return type; + } + for (JpsModelLoaderExtension extension : JpsServiceManager.getInstance().getExtensions(JpsModelLoaderExtension.class)) { + final JpsOrderRootType rootType = extension.getRootType(rootTypeId); + if (rootType != null) { + return rootType; + } + } + return JpsOrderRootType.COMPILED; + } + + private static JpsLibraryType getLibraryType(String typeId) { + return JpsJavaLibraryType.INSTANCE; + } +} diff --git a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsModelLoaderExtension.java b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsModelLoaderExtension.java new file mode 100644 index 000000000000..6a889b3b7f65 --- /dev/null +++ b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsModelLoaderExtension.java @@ -0,0 +1,38 @@ +package org.jetbrains.jps.model.serialization; + +import org.jdom.Element; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jps.model.JpsCompositeElement; +import org.jetbrains.jps.model.JpsElementReference; +import org.jetbrains.jps.model.library.JpsOrderRootType; +import org.jetbrains.jps.model.library.JpsSdkType; +import org.jetbrains.jps.model.module.JpsDependencyElement; +import org.jetbrains.jps.model.module.JpsModule; + +/** + * @author nik + */ +public abstract class JpsModelLoaderExtension { + + public void loadRootModel(@NotNull JpsModule module, @NotNull Element rootModel) { + } + + @Nullable + public JpsOrderRootType getRootType(@NotNull String typeId) { + return null; + } + + @Nullable + public JpsSdkType getSdkType(@NotNull String typeId) { + return null; + } + + public void loadModuleDependencyProperties(JpsDependencyElement dependency, Element orderEntry) { + } + + @Nullable + public JpsElementReference createLibraryTableReference(String tableLevel) { + return null; + } +} diff --git a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsModuleComponentSerializer.java b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsModuleComponentSerializer.java new file mode 100644 index 000000000000..08befb67ee9b --- /dev/null +++ b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsModuleComponentSerializer.java @@ -0,0 +1,15 @@ +package org.jetbrains.jps.model.serialization; + +import org.jdom.Element; +import org.jetbrains.annotations.NotNull; + +/** + * @author nik + */ +public abstract class JpsModuleComponentSerializer { + + @NotNull + public abstract String getComponentName(); + + public abstract void loadComponent(@NotNull Element component); +} diff --git a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsModuleLoader.java b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsModuleLoader.java new file mode 100644 index 000000000000..17b560a893be --- /dev/null +++ b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsModuleLoader.java @@ -0,0 +1,120 @@ +package org.jetbrains.jps.model.serialization; + +import org.jdom.Element; +import org.jetbrains.jps.model.JpsCompositeElement; +import org.jetbrains.jps.model.JpsElementFactory; +import org.jetbrains.jps.model.JpsElementReference; +import org.jetbrains.jps.model.java.*; +import org.jetbrains.jps.model.library.JpsLibrary; +import org.jetbrains.jps.model.library.JpsSdkType; +import org.jetbrains.jps.model.module.*; +import org.jetbrains.jps.service.JpsServiceManager; + +import static com.intellij.openapi.util.JDOMUtil.getChildren; + +/** + * @author nik + */ +public class JpsModuleLoader { + private static final String URL_ATTRIBUTE = "url"; + + public static void loadRootModel(JpsModule module, Element rootModelComponent) { + for (Element contentElement : getChildren(rootModelComponent, "content")) { + final String url = contentElement.getAttributeValue(URL_ATTRIBUTE); + module.getContentRootsList().addUrl(url); + for (Element sourceElement : getChildren(contentElement, "sourceFolder")) { + final String sourceUrl = sourceElement.getAttributeValue(URL_ATTRIBUTE); + final String packagePrefix = sourceElement.getAttributeValue("packagePrefix"); + final boolean testSource = Boolean.parseBoolean(sourceElement.getAttributeValue("isTestSource")); + final JavaSourceRootType rootType = testSource ? JavaSourceRootType.SOURCE : JavaSourceRootType.TEST_SOURCE; + module.addSourceRoot(rootType, sourceUrl, new JavaSourceRootProperties(packagePrefix)); + } + for (Element excludeElement : getChildren(contentElement, "excludeFolder")) { + module.getExcludeRootsList().addUrl(excludeElement.getAttributeValue(URL_ATTRIBUTE)); + } + } + + final JpsDependenciesList dependenciesList = module.getDependenciesList(); + final JpsElementFactory elementFactory = JpsElementFactory.getInstance(); + int moduleLibraryNum = 0; + for (Element orderEntry : getChildren(rootModelComponent, "orderEntry")) { + String type = orderEntry.getAttributeValue("type"); + if ("sourceFolder".equals(type)) { + dependenciesList.addModuleSourceDependency(); + } + else if ("jdk".equals(type)) { + String sdkName = orderEntry.getAttributeValue("jdkName"); + String sdkTypeId = orderEntry.getAttributeValue("jskType"); + final JpsSdkType sdkType = getSdkType(sdkTypeId); + dependenciesList.addSdkDependency(sdkType); + module.getSdkReferencesTable() + .setSdkReference(sdkType, elementFactory.createLibraryReference(sdkName, elementFactory.createGlobalReference())); + } + else if ("inheritedJdk".equals(type)) { + dependenciesList.addSdkDependency(JpsJavaSdkType.INSTANCE); + } + else if ("library".equals(type)) { + String name = orderEntry.getAttributeValue("name"); + String level = orderEntry.getAttributeValue("level"); + final JpsLibraryDependency dependency = + dependenciesList.addLibraryDependency(elementFactory.createLibraryReference(name, createLibraryTableReference(level))); + loadModuleDependencyProperties(dependency, orderEntry); + } + else if ("module-library".equals(type)) { + final Element moduleLibraryElement = orderEntry.getChild("library"); + final JpsLibrary library = JpsLibraryTableLoader.loadLibrary(moduleLibraryElement); + module.addModuleLibrary(library); + + final JpsLibraryDependency dependency = dependenciesList.addLibraryDependency(library); + loadModuleDependencyProperties(dependency, orderEntry); + moduleLibraryNum++; + } + else if ("module".equals(type)) { + String name = orderEntry.getAttributeValue("module-name"); + final JpsModuleDependency dependency = dependenciesList.addModuleDependency(elementFactory.createModuleReference(name)); + loadModuleDependencyProperties(dependency, orderEntry); + } + } + + for (JpsModelLoaderExtension extension : getLoaderExtensions()) { + extension.loadRootModel(module, rootModelComponent); + } + } + + private static void loadModuleDependencyProperties(JpsDependencyElement dependency, Element orderEntry) { + for (JpsModelLoaderExtension extension : getLoaderExtensions()) { + extension.loadModuleDependencyProperties(dependency, orderEntry); + } + } + + private static JpsElementReference createLibraryTableReference(String level) { + JpsElementFactory elementFactory = JpsElementFactory.getInstance(); + if (level.equals("project")) { + return elementFactory.createProjectReference(); + } + if (level.equals("application")) { + return elementFactory.createGlobalReference(); + } + for (JpsModelLoaderExtension extension : getLoaderExtensions()) { + final JpsElementReference reference = extension.createLibraryTableReference(level); + if (reference != null) { + return reference; + } + } + throw new UnsupportedOperationException(); + } + + private static Iterable getLoaderExtensions() { + return JpsServiceManager.getInstance().getExtensions(JpsModelLoaderExtension.class); + } + + public static JpsSdkType getSdkType(String typeId) { + for (JpsModelLoaderExtension extension : getLoaderExtensions()) { + final JpsSdkType type = extension.getSdkType(typeId); + if (type != null) { + return type; + } + } + return JpsJavaSdkType.INSTANCE; + } +} diff --git a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsProjectLoader.java b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsProjectLoader.java new file mode 100644 index 000000000000..9e68ed669178 --- /dev/null +++ b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsProjectLoader.java @@ -0,0 +1,144 @@ +package org.jetbrains.jps.model.serialization; + +import com.intellij.openapi.components.ExpandMacroToPathMap; +import com.intellij.openapi.util.JDOMUtil; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.io.FileUtil; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jps.model.JpsElementFactory; +import org.jetbrains.jps.model.JpsGlobal; +import org.jetbrains.jps.model.JpsProject; +import org.jetbrains.jps.model.java.JpsJavaModuleType; +import org.jetbrains.jps.model.library.JpsLibrary; +import org.jetbrains.jps.model.module.JpsModule; +import org.jetbrains.jps.model.module.JpsModuleType; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; + +/** + * @author nik + */ +public class JpsProjectLoader { + private final JpsGlobal myGlobal; + private final JpsProject myProject; + private ExpandMacroToPathMap myMacroToPathMap; + + public JpsProjectLoader(JpsGlobal global, JpsProject project) { + myGlobal = global; + myProject = project; + } + + public static void loadProject(JpsGlobal global, final JpsProject project, String projectPath) throws IOException { + new JpsProjectLoader(global, project).loadFromPath(projectPath); + } + + public void loadFromPath(String path) throws IOException { + File file = new File(path).getCanonicalFile(); + if (file.isFile() && path.endsWith(".ipr")) { + loadFromIpr(file); + } + else if (file.getName().equals(".idea")) { + loadFromDirectory(file); + } + else { + File ideaDirectory = new File(file, ".idea"); + if (ideaDirectory.exists()) { + loadFromDirectory(ideaDirectory); + } + else { + throw new IOException("Cannot find IntelliJ IDEA project files at " + path); + } + } + } + + private void loadFromDirectory(File dir) { + initMacroMap(dir.getParentFile()); + loadModules(loadRootElement(new File(dir, "modules.xml"))); + final File[] libraryFiles = new File(dir, "libraries").listFiles(); + if (libraryFiles != null) { + for (File libraryFile : libraryFiles) { + if (isXmlFile(libraryFile)) { + loadProjectLibraries(loadRootElement(libraryFile)); + } + } + } + } + + private void loadFromIpr(File iprFile) { + initMacroMap(iprFile.getParentFile()); + final Element root = loadRootElement(iprFile); + loadModules(root); + loadProjectLibraries(findComponent(root, "libraryTable")); + } + + private void initMacroMap(File projectBaseDir) { + myMacroToPathMap = new ExpandMacroToPathMap(); + myMacroToPathMap.addMacroExpand("PROJECT_DIR", FileUtil.toSystemIndependentName(projectBaseDir.getAbsolutePath())); + } + + private Element loadRootElement(final File file) { + try { + final Element element = JDOMUtil.loadDocument(file).getRootElement(); + myMacroToPathMap.substitute(element, SystemInfo.isFileSystemCaseSensitive); + return element; + } + catch (JDOMException e) { + throw new RuntimeException(e); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + private static boolean isXmlFile(File file) { + return file.isFile() && FileUtil.getNameWithoutExtension(file).equalsIgnoreCase("xml"); + } + + private void loadProjectLibraries(Element libraryTableElement) { + final ArrayList libraries = new ArrayList(); + JpsLibraryTableLoader.loadLibraries(libraryTableElement, libraries); + for (JpsLibrary library : libraries) { + myProject.addLibrary(library); + } + } + + private void loadModules(Element root) { + Element componentRoot = findComponent(root, "ProjectModuleManager"); + if (componentRoot == null) return; + final Element modules = componentRoot.getChild("modules"); + for (Element moduleElement : JDOMUtil.getChildren(modules, "module")) { + final String path = moduleElement.getAttributeValue("filepath"); + JpsModule module = loadModule(path); + myProject.addModule(module); + } + } + + private JpsModule loadModule(String path) { + final File file = new File(path); + String name = FileUtil.getNameWithoutExtension(file); + final Element moduleRoot = loadRootElement(file); + final String typeId = moduleRoot.getAttributeValue("type"); + final JpsModule module = JpsElementFactory.getInstance().createModule(name, getModuleType(typeId)); + JpsModuleLoader.loadRootModel(module, findComponent(moduleRoot, "NewModuleRootManager")); + return module; + } + + @Nullable + private static Element findComponent(Element root, String componentName) { + for (Element element : JDOMUtil.getChildren(root, "component")) { + if (componentName.equals(element.getAttributeValue("name"))) { + return element; + } + } + return null; + } + + private static JpsModuleType getModuleType(@NotNull String typeId) { + return JpsJavaModuleType.INSTANCE; + } +} diff --git a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/java/JpsJavaModelLoaderExtension.java b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/java/JpsJavaModelLoaderExtension.java new file mode 100644 index 000000000000..79f70d0383c4 --- /dev/null +++ b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/java/JpsJavaModelLoaderExtension.java @@ -0,0 +1,83 @@ +package org.jetbrains.jps.model.serialization.java; + +import com.intellij.openapi.util.JDOMUtil; +import org.jdom.Element; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.model.JpsUrlList; +import org.jetbrains.jps.model.java.*; +import org.jetbrains.jps.model.library.JpsOrderRootType; +import org.jetbrains.jps.model.module.JpsDependencyElement; +import org.jetbrains.jps.model.module.JpsModule; +import org.jetbrains.jps.model.serialization.JpsModelLoaderExtension; + +/** + * @author nik + */ +public class JpsJavaModelLoaderExtension extends JpsModelLoaderExtension { + @Override + public void loadRootModel(@NotNull JpsModule module, @NotNull Element rootModel) { + loadExplodedDirectoryExtension(module, rootModel); + loadJavaModuleExtension(module, rootModel); + } + + @Override + public void loadModuleDependencyProperties(JpsDependencyElement dependency, Element entry) { + boolean exported = entry.getAttributeValue("exported") != null; + String scopeName = entry.getAttributeValue("scope"); + JpsJavaDependencyScope scope = scopeName != null ? JpsJavaDependencyScope.valueOf(scopeName) : JpsJavaDependencyScope.COMPILE; + + final JpsJavaDependencyExtension extension = JpsJavaExtensionService.getInstance().getOrCreateDependencyExtension(dependency); + extension.setExported(exported); + extension.setScope(scope); + } + + @Override + public JpsOrderRootType getRootType(@NotNull String typeId) { + if (typeId.equals("JAVADOC")) { + return JpsOrderRootType.DOCUMENTATION; + } + else if (typeId.equals("ANNOTATIONS")) { + return JpsAnnotationRootType.INSTANCE; + } + return null; + } + + private static void loadExplodedDirectoryExtension(JpsModule module, Element rootModelComponent) { + final Element exploded = rootModelComponent.getChild("exploded"); + if (exploded != null) { + final ExplodedDirectoryModuleExtension extension = + JpsJavaExtensionService.getInstance().getOrCreateExplodedDirectoryExtension(module); + extension.setExcludeExploded(rootModelComponent.getChild("exclude-exploded") != null); + extension.setExplodedUrl(exploded.getAttributeValue("url")); + } + } + + private static void loadJavaModuleExtension(JpsModule module, Element rootModelComponent) { + final JpsJavaModuleExtension extension = JpsJavaExtensionService.getInstance().getOrCreateModuleExtension(module); + final Element outputTag = rootModelComponent.getChild("output"); + if (outputTag != null) { + extension.setOutputUrl(outputTag.getAttributeValue("url")); + } + final Element testOutputTag = rootModelComponent.getChild("output-test"); + if (testOutputTag != null) { + extension.setOutputUrl(testOutputTag.getAttributeValue("url")); + } + extension.setInheritOutput(Boolean.parseBoolean(rootModelComponent.getAttributeValue("inherit-compiler-output"))); + extension.setExcludeOutput(rootModelComponent.getChild("exclude-output") != null); + + loadAdditionalRoots(rootModelComponent, "annotation-paths", extension.getAnnotationRoots()); + loadAdditionalRoots(rootModelComponent, "javadoc-paths", extension.getJavadocRoots()); + + final String languageLevel = rootModelComponent.getAttributeValue("LANGUAGE_LEVEL"); + if (languageLevel != null) { + extension.setLanguageLevel(LanguageLevel.valueOf(languageLevel)); + } + } + + private static void loadAdditionalRoots(Element rootModelComponent, final String rootsTagName, final JpsUrlList result) { + final Element roots = rootModelComponent.getChild(rootsTagName); + for (Element root : JDOMUtil.getChildren(roots, "root")) { + result.addUrl(root.getAttributeValue("url")); + } + } +} diff --git a/jps/model-serialization/testData/iprProject/iprProject.iml b/jps/model-serialization/testData/iprProject/iprProject.iml new file mode 100644 index 000000000000..dbf84a250f51 --- /dev/null +++ b/jps/model-serialization/testData/iprProject/iprProject.iml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/model-serialization/testData/iprProject/iprProject.ipr b/jps/model-serialization/testData/iprProject/iprProject.ipr new file mode 100644 index 000000000000..341eae6831cd --- /dev/null +++ b/jps/model-serialization/testData/iprProject/iprProject.ipr @@ -0,0 +1,59 @@ + + + + + $PROJECT_DIR$/out/artifacts/explodedWar + + + + + + + + + + + + + + + $PROJECT_DIR$/out/artifacts/archive + + + + + + + + + + + $PROJECT_DIR$/out/artifacts/files + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsModuleSerializationTest.java b/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsModuleSerializationTest.java new file mode 100644 index 000000000000..20087a1e0326 --- /dev/null +++ b/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsModuleSerializationTest.java @@ -0,0 +1,31 @@ +package org.jetbrains.jps.model.serialization; + +import com.intellij.openapi.application.PathManager; +import org.jetbrains.jps.model.JpsModelTestCase; +import org.jetbrains.jps.model.library.JpsLibrary; +import org.jetbrains.jps.model.module.JpsModule; + +import java.io.IOException; + +/** + * @author nik + */ +public class JpsModuleSerializationTest extends JpsModelTestCase { + public void test() { + loadProject("iprProject/iprProject.ipr"); + final JpsModule module = assertOneElement(myModel.getProject().getModules()); + assertEquals("iprProject", module.getName()); + final JpsLibrary library = assertOneElement(myModel.getProject().getLibraries()); + assertEquals("junit", library.getName()); + } + + private void loadProject(final String path) { + try { + final String projectPath = PathManager.getHomePath() + "/community/jps/model-serialization/testData/" + path; + JpsProjectLoader.loadProject(myModel.getGlobal(), myModel.getProject(), projectPath); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } +} From 261a14a841aaf1edbe3f58e5e514638eef098ac7 Mon Sep 17 00:00:00 2001 From: Alexander Doroshko Date: Thu, 14 Jun 2012 17:16:53 +0400 Subject: [PATCH 167/172] IDEA-87131 Go to test should suggest to create test source root if none exist --- .../intellij/ide/projectView/actions/MarkRootAction.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkRootAction.java b/platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkRootAction.java index 218937ed2dd4..b821f227bbac 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkRootAction.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkRootAction.java @@ -23,8 +23,9 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.roots.*; import com.intellij.openapi.util.Ref; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -88,11 +89,11 @@ public class MarkRootAction extends AnAction { } @Nullable - private static ContentEntry findContentEntry(ModifiableRootModel model, VirtualFile vFile) { + public static ContentEntry findContentEntry(@NotNull ModuleRootModel model, @NotNull VirtualFile vFile) { final ContentEntry[] contentEntries = model.getContentEntries(); for (ContentEntry contentEntry : contentEntries) { final VirtualFile contentEntryFile = contentEntry.getFile(); - if (contentEntryFile != null && VfsUtil.isAncestor(contentEntryFile, vFile, false)) { + if (contentEntryFile != null && VfsUtilCore.isAncestor(contentEntryFile, vFile, false)) { return contentEntry; } } From c6c62110e317c12c6dd72e3589ca1b0485371e2d Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Thu, 14 Jun 2012 17:28:19 +0400 Subject: [PATCH 168/172] Show/Hide column header --- .../designer/propertyTable/PropertyTable.java | 11 +++-- .../propertyTable/PropertyTablePanel.java | 15 +++--- .../propertyTable/actions/ShowColumns.java | 48 +++++++++++++++++++ .../src/messages/DesignerBundle.properties | 3 +- 4 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/actions/ShowColumns.java diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/PropertyTable.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/PropertyTable.java index bcc840cd979e..a4d6b53f2345 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/PropertyTable.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/PropertyTable.java @@ -85,10 +85,7 @@ public final class PropertyTable extends JBTable implements ComponentSelectionLi public PropertyTable() { setModel(myModel); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - - JTableHeader tableHeader = getTableHeader(); - tableHeader.setVisible(false); - tableHeader.setPreferredSize(new Dimension()); + showColumns(false); addMouseListener(new MouseTableListener()); getSelectionModel().addListSelectionListener(new ListSelectionListener() { @@ -103,6 +100,12 @@ public final class PropertyTable extends JBTable implements ComponentSelectionLi // TODO: Updates UI after LAF updated } + public void showColumns(boolean value) { + JTableHeader tableHeader = getTableHeader(); + tableHeader.setVisible(value); + tableHeader.setPreferredSize(value ? null : new Dimension()); + } + public void initQuickFixManager(JViewport viewPort) { myQuickFixManager = new QuickFixManager(this, viewPort); } diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/PropertyTablePanel.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/PropertyTablePanel.java index 4fdaa227e41d..b37c2fa9bb6d 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/PropertyTablePanel.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/PropertyTablePanel.java @@ -16,10 +16,7 @@ package com.intellij.designer.propertyTable; import com.intellij.designer.DesignerBundle; -import com.intellij.designer.propertyTable.actions.IPropertyTableAction; -import com.intellij.designer.propertyTable.actions.RestoreDefault; -import com.intellij.designer.propertyTable.actions.ShowExpert; -import com.intellij.designer.propertyTable.actions.ShowJavadoc; +import com.intellij.designer.propertyTable.actions.*; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.impl.ActionButton; import com.intellij.ui.IdeBorderFactory; @@ -61,10 +58,6 @@ public final class PropertyTablePanel extends JPanel implements ListSelectionLis actionGroup.add(new ShowExpert(myPropertyTable)); - PopupHandler.installPopupHandler(myPropertyTable, actionGroup, - ActionPlaces.GUI_DESIGNER_PROPERTY_INSPECTOR_POPUP, - actionManager); - myActions = actionGroup.getChildren(null); for (int i = 0; i < myActions.length; i++) { AnAction action = myActions[i]; @@ -75,6 +68,12 @@ public final class PropertyTablePanel extends JPanel implements ListSelectionLis } } + actionGroup.add(new ShowColumns(myPropertyTable)); + + PopupHandler.installPopupHandler(myPropertyTable, actionGroup, + ActionPlaces.GUI_DESIGNER_PROPERTY_INSPECTOR_POPUP, + actionManager); + myPropertyTable.getSelectionModel().addListSelectionListener(this); valueChanged(null); diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/actions/ShowColumns.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/actions/ShowColumns.java new file mode 100644 index 000000000000..034b9111bbee --- /dev/null +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/actions/ShowColumns.java @@ -0,0 +1,48 @@ +/* + * 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.designer.propertyTable.actions; + +import com.intellij.designer.DesignerBundle; +import com.intellij.designer.propertyTable.PropertyTable; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.Presentation; +import com.intellij.openapi.actionSystem.ToggleAction; + +/** + * @author Alexander Lobas + */ +public class ShowColumns extends ToggleAction { + private final PropertyTable myTable; + + public ShowColumns(PropertyTable table) { + myTable = table; + + Presentation presentation = getTemplatePresentation(); + String text = DesignerBundle.message("designer.properties.show.columns"); + presentation.setText(text); + presentation.setDescription(text); + } + + @Override + public boolean isSelected(AnActionEvent e) { + return myTable.getTableHeader().isVisible(); + } + + @Override + public void setSelected(AnActionEvent e, boolean state) { + myTable.showColumns(state); + } +} \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/messages/DesignerBundle.properties b/plugins/ui-designer/ui-designer-new/src/messages/DesignerBundle.properties index 87decad7bb4b..a1c32a1a728a 100644 --- a/plugins/ui-designer/ui-designer-new/src/messages/DesignerBundle.properties +++ b/plugins/ui-designer/ui-designer-new/src/messages/DesignerBundle.properties @@ -7,7 +7,8 @@ command.set.property.value=Set Property Value designer.properties.title=Properties designer.properties.show.expert=Show expert properties -designer.properties.show.javadoc=Show Documentation +designer.properties.show.columns=Show columns +designer.properties.show.javadoc=Show documentation designer.properties.javadoc.title=Documentation for {0} property designer.properties.restore_default=Restore default value designer.properties.column1=Property From 6df0d05daa845850d989c4694df532c44220d6de Mon Sep 17 00:00:00 2001 From: irengrig Date: Thu, 14 Jun 2012 17:38:58 +0400 Subject: [PATCH 169/172] vcs: mark content revision to allow easy vcs discovery inside same vcs plugin; do not show "Compare Subversion Properties" in git log; allow to compare properties when called from "Browse Subversion Repository" --- .../vcs/changes/MarkerVcsContentRevision.java | 28 +++++++++++++++++++ .../idea/svn/SvnContentRevision.java | 9 +++++- .../AbstractShowPropertiesDiffAction.java | 28 ++++++++++++++++--- .../SvnLazyPropertyContentRevision.java | 10 +++++-- .../history/SvnRepositoryContentRevision.java | 9 +++++- 5 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 platform/vcs-api/src/com/intellij/openapi/vcs/changes/MarkerVcsContentRevision.java diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/MarkerVcsContentRevision.java b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/MarkerVcsContentRevision.java new file mode 100644 index 000000000000..d7c3f1464c49 --- /dev/null +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/MarkerVcsContentRevision.java @@ -0,0 +1,28 @@ +/* + * 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.vcs.changes; + +import com.intellij.openapi.vcs.VcsKey; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/14/12 + * Time: 5:13 PM + */ +public interface MarkerVcsContentRevision { + VcsKey getVcsKey(); +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnContentRevision.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnContentRevision.java index 4b8a373c4e15..34dceaffd3e7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnContentRevision.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnContentRevision.java @@ -20,7 +20,9 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.Throwable2Computable; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsException; +import com.intellij.openapi.vcs.VcsKey; import com.intellij.openapi.vcs.changes.ContentRevision; +import com.intellij.openapi.vcs.changes.MarkerVcsContentRevision; import com.intellij.openapi.vcs.history.VcsRevisionNumber; import com.intellij.openapi.vcs.impl.ContentRevisionCache; import com.intellij.openapi.vcs.impl.CurrentRevisionProvider; @@ -39,7 +41,7 @@ import java.io.IOException; /** * @author yole */ -public class SvnContentRevision implements ContentRevision { +public class SvnContentRevision implements ContentRevision, MarkerVcsContentRevision { private final SvnVcs myVcs; protected final FilePath myFile; private final SVNRevision myRevision; @@ -145,4 +147,9 @@ public class SvnContentRevision implements ContentRevision { public String toString() { return myFile.getPath(); } + + @Override + public VcsKey getVcsKey() { + return SvnVcs.getKey(); + } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java index fdac020cc209..c9b7f6c08c79 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java @@ -31,6 +31,7 @@ import com.intellij.openapi.vcs.VcsDataKeys; import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vcs.changes.ChangesUtil; import com.intellij.openapi.vcs.changes.ContentRevision; +import com.intellij.openapi.vcs.changes.MarkerVcsContentRevision; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -70,11 +71,30 @@ public abstract class AbstractShowPropertiesDiffAction extends AnAction implemen public void update(final AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final Project project = PlatformDataKeys.PROJECT.getData(dataContext); - final Change[] changes = e.getData(getChangesKey()); final Presentation presentation = e.getPresentation(); - presentation.setVisible(VcsDataKeys.CHANGES.getData(dataContext) != null); - presentation.setEnabled(enabled(project, changes)); + final Change[] data = VcsDataKeys.CHANGES.getData(dataContext); + boolean showAction = checkThatChangesAreUnderSvn(data); + presentation.setVisible(data != null && showAction); + presentation.setEnabled(showAction); + } + + private boolean checkThatChangesAreUnderSvn(Change[] data) { + boolean showAction = false; + if (data != null) { + for (Change change : data) { + final ContentRevision before = change.getBeforeRevision(); + if (before != null) { + showAction = showAction || before instanceof MarkerVcsContentRevision && SvnVcs.getKey().equals(((MarkerVcsContentRevision)before).getVcsKey()); + } + final ContentRevision after = change.getAfterRevision(); + if (after != null) { + showAction = showAction || after instanceof MarkerVcsContentRevision && SvnVcs.getKey().equals(((MarkerVcsContentRevision)after).getVcsKey()); + } + if (showAction) break; + } + } + return showAction; } private boolean enabled(final Project project, final Change[] changes) { @@ -107,7 +127,7 @@ public abstract class AbstractShowPropertiesDiffAction extends AnAction implemen final Project project = PlatformDataKeys.PROJECT.getData(dataContext); final Change[] changes = e.getData(getChangesKey()); - if (! enabled(project, changes)) { + if (! checkThatChangesAreUnderSvn(changes)) { return; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnLazyPropertyContentRevision.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnLazyPropertyContentRevision.java index 141858d4d11b..aaa4247e7d56 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnLazyPropertyContentRevision.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnLazyPropertyContentRevision.java @@ -18,11 +18,12 @@ package org.jetbrains.idea.svn.history; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Ref; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsException; +import com.intellij.openapi.vcs.VcsKey; import com.intellij.openapi.vcs.changes.ContentRevision; +import com.intellij.openapi.vcs.changes.MarkerVcsContentRevision; import com.intellij.openapi.vcs.history.VcsRevisionNumber; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnBundle; @@ -39,7 +40,7 @@ import org.tmatesoft.svn.core.wc.SVNWCClient; * Date: 2/22/12 * Time: 10:28 AM */ -public class SvnLazyPropertyContentRevision implements ContentRevision { +public class SvnLazyPropertyContentRevision implements ContentRevision, MarkerVcsContentRevision { private final FilePath myPath; private final VcsRevisionNumber myNumber; private final Project myProject; @@ -101,4 +102,9 @@ public class SvnLazyPropertyContentRevision implements ContentRevision { public VcsRevisionNumber getRevisionNumber() { return myNumber; } + + @Override + public VcsKey getVcsKey() { + return SvnVcs.getKey(); + } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRepositoryContentRevision.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRepositoryContentRevision.java index 801f18105b72..836f6b4c83b1 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRepositoryContentRevision.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRepositoryContentRevision.java @@ -30,8 +30,10 @@ import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.util.Throwable2Computable; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsException; +import com.intellij.openapi.vcs.VcsKey; import com.intellij.openapi.vcs.actions.VcsContextFactory; import com.intellij.openapi.vcs.changes.ContentRevision; +import com.intellij.openapi.vcs.changes.MarkerVcsContentRevision; import com.intellij.openapi.vcs.history.VcsRevisionNumber; import com.intellij.openapi.vcs.impl.ContentRevisionCache; import org.jetbrains.annotations.NotNull; @@ -47,7 +49,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; -public class SvnRepositoryContentRevision implements ContentRevision { +public class SvnRepositoryContentRevision implements ContentRevision, MarkerVcsContentRevision { private final String myRepositoryRoot; private final SvnVcs myVcs; private final String myPath; @@ -180,4 +182,9 @@ public class SvnRepositoryContentRevision implements ContentRevision { public String getPath() { return myPath; } + + @Override + public VcsKey getVcsKey() { + return SvnVcs.getKey(); + } } From 23fa1f8ee7f295d7ec507107f4a2873a7a2ee283 Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Thu, 14 Jun 2012 18:26:46 +0400 Subject: [PATCH 170/172] custom Printer per SMTestProxy instance and its children --- .../sm/SMTestRunnerConnectionUtil.java | 15 +++++++--- ...eralIdBasedToSMTRunnerEventsConvertor.java | 15 ++++++++++ .../sm/runner/GeneralTestEventsProcessor.java | 2 ++ .../GeneralToSMTRunnerEventsConvertor.java | 4 +++ .../testframework/sm/runner/SMTestProxy.java | 26 ++++++++++++++-- .../sm/runner/TestProxyPrinterProvider.java | 30 +++++++++++++++++++ .../runner/events/BaseStartedNodeEvent.java | 28 ++++++++++++++++- .../sm/runner/events/TestStartedEvent.java | 10 +++++-- .../runner/events/TestSuiteStartedEvent.java | 10 +++++-- ...MockGeneralTestEventsProcessorAdapter.java | 4 +++ 10 files changed, 131 insertions(+), 13 deletions(-) create mode 100644 platform/smRunner/src/com/intellij/execution/testframework/sm/runner/TestProxyPrinterProvider.java diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java index 7c1567c9c435..2fe057da6a9b 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java @@ -90,7 +90,8 @@ public class SMTestRunnerConnectionUtil { runnerSettings, configurationSettings, new CompositeTestLocationProvider(locator), - false); + false, + null); } public static SMTRunnerConsoleView createConsoleWithCustomLocator(@NotNull final String testFrameworkName, @@ -98,7 +99,8 @@ public class SMTestRunnerConnectionUtil { final RunnerSettings runnerSettings, final ConfigurationPerRunnerSettings configurationSettings, @Nullable final TestLocationProvider locator, - final boolean idBasedTreeConstruction) { + final boolean idBasedTreeConstruction, + @Nullable final TestProxyPrinterProvider printerProvider) { // Console final String splitterPropertyName = testFrameworkName + ".Splitter.Proportion"; final SMTRunnerConsoleView console = @@ -109,7 +111,8 @@ public class SMTestRunnerConnectionUtil { super.attachToProcess(processHandler); attachEventsProcessors(consoleProperties, getResultsViewer(), getResultsViewer().getStatisticsPane(), - processHandler, testFrameworkName, locator, idBasedTreeConstruction); + processHandler, testFrameworkName, locator, idBasedTreeConstruction, + printerProvider); } }; console.setHelpId("reference.runToolWindow.testResultsTab"); @@ -213,7 +216,8 @@ public class SMTestRunnerConnectionUtil { final ProcessHandler processHandler, @NotNull final String testFrameworkName, @Nullable final TestLocationProvider locator, - boolean idBasedTreeConstruction) { + boolean idBasedTreeConstruction, + @Nullable TestProxyPrinterProvider printerProvider) { //build messages consumer final OutputToGeneralTestEventsConverter outputConsumer; if (consoleProperties instanceof SMCustomMessagesParsing) { @@ -233,6 +237,9 @@ public class SMTestRunnerConnectionUtil { if (locator != null) { eventsProcessor.setLocator(locator); } + if (printerProvider != null) { + eventsProcessor.setPrinterProvider(printerProvider); + } // ui actions final SMTRunnerUIActionsHandler uiActionsHandler = new SMTRunnerUIActionsHandler(consoleProperties); diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralIdBasedToSMTRunnerEventsConvertor.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralIdBasedToSMTRunnerEventsConvertor.java index 88ce640ae88f..6c9e4153429f 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralIdBasedToSMTRunnerEventsConvertor.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralIdBasedToSMTRunnerEventsConvertor.java @@ -18,6 +18,7 @@ package com.intellij.execution.testframework.sm.runner; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.intellij.execution.process.ProcessOutputTypes; +import com.intellij.execution.testframework.Printer; import com.intellij.execution.testframework.sm.SMRunnerUtil; import com.intellij.execution.testframework.sm.SMTestRunnerConnectionUtil; import com.intellij.execution.testframework.sm.runner.events.*; @@ -48,6 +49,7 @@ public class GeneralIdBasedToSMTRunnerEventsConvertor implements GeneralTestEven private final String myTestFrameworkName; private boolean myIsTestingFinished = false; private TestLocationProvider myLocator = null; + private TestProxyPrinterProvider myTestProxyPrinterProvider = null; public GeneralIdBasedToSMTRunnerEventsConvertor(@NotNull SMTestProxy.SMRootTestProxy testsRootProxy, @NotNull String testFrameworkName) { @@ -112,6 +114,11 @@ public class GeneralIdBasedToSMTRunnerEventsConvertor implements GeneralTestEven }); } + @Override + public void setPrinterProvider(@NotNull TestProxyPrinterProvider printerProvider) { + myTestProxyPrinterProvider = printerProvider; + } + public void onTestStarted(@NotNull final TestStartedEvent testStartedEvent) { SMRunnerUtil.addToInvokeLater(new Runnable() { public void run() { @@ -145,6 +152,14 @@ public class GeneralIdBasedToSMTRunnerEventsConvertor implements GeneralTestEven } SMTestProxy childProxy = new SMTestProxy(startedNodeEvent.getName(), suite, startedNodeEvent.getLocationUrl(), true); + TestProxyPrinterProvider printerProvider = myTestProxyPrinterProvider; + String nodeType = startedNodeEvent.getNodeType(); + if (printerProvider != null && nodeType != null) { + Printer printer = printerProvider.getPrinterByType(nodeType, startedNodeEvent.getNodeArgs()); + if (printer != null) { + childProxy.setPreferredPrinter(printer); + } + } childNode = new Node(startedNodeEvent.getId(), parentNode, childProxy); myNodeByIdMap.put(nodeId, childNode); myRunningNodes.add(childNode); diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java index 62f9564789df..98f62d10ff1a 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java @@ -74,4 +74,6 @@ public interface GeneralTestEventsProcessor extends Disposable { void addEventsListener(@NotNull SMTRunnerEventsListener viewer); void onFinishTesting(); + + void setPrinterProvider(@NotNull TestProxyPrinterProvider printerProvider); } diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java index 2e38c07d0594..4f6d1357283e 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java @@ -113,6 +113,10 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce }); } + @Override + public void setPrinterProvider(@NotNull TestProxyPrinterProvider printerProvider) { + } + public void onTestStarted(@NotNull final TestStartedEvent testStartedEvent) { SMRunnerUtil.addToInvokeLater(new Runnable() { public void run() { diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java index edc1b91d5391..c8833bd7de58 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java @@ -60,6 +60,7 @@ public class SMTestProxy extends AbstractTestProxy { private boolean myIsEmpty = true; TestLocationProvider myLocator = null; private final boolean myPreservePresentableName; + private Printer myPreferredPrinter = null; public SMTestProxy(final String testName, final boolean isSuite, @Nullable final String locationUrl) { @@ -79,6 +80,10 @@ public class SMTestProxy extends AbstractTestProxy { myLocator = locator; } + public void setPreferredPrinter(@NotNull Printer preferredPrinter) { + myPreferredPrinter = preferredPrinter; + } + public boolean isInProgress() { //final SMTestProxy parent = getParent(); @@ -172,8 +177,24 @@ public class SMTestProxy extends AbstractTestProxy { // if parent is being printed then all childs output // should be also send to the same printer child.setPrinter(myPrinter); + if (myPreferredPrinter != null && child.myPreferredPrinter == null) { + child.setPreferredPrinter(myPreferredPrinter); + } } + @Nullable + private Printer getRightPrinter(@Nullable Printer printer) { + if (myPreferredPrinter != null && printer != null) { + return myPreferredPrinter; + } + return printer; + } + + public void setPrinter(Printer printer) { + super.setPrinter(getRightPrinter(printer)); + } + + public String getName() { return myName; } @@ -397,13 +418,14 @@ public class SMTestProxy extends AbstractTestProxy { * @param printer Printer */ public void printOn(final Printer printer) { - super.printOn(printer); + final Printer rightPrinter = getRightPrinter(printer); + super.printOn(rightPrinter); invokeInAlarm(new Runnable() { @Override public void run() { //Tests State, that provide and formats additional output - myState.printOn(printer); + myState.printOn(rightPrinter); } }); } diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/TestProxyPrinterProvider.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/TestProxyPrinterProvider.java new file mode 100644 index 000000000000..7ce468d5d1f5 --- /dev/null +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/TestProxyPrinterProvider.java @@ -0,0 +1,30 @@ +/* + * 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.execution.testframework.sm.runner; + +import com.intellij.execution.testframework.Printer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Sergey Simonchik + */ +public interface TestProxyPrinterProvider { + + @Nullable + Printer getPrinterByType(@NotNull String nodeType, @Nullable String arguments); + +} diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/events/BaseStartedNodeEvent.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/events/BaseStartedNodeEvent.java index 9182d4619b8d..8d597ecbd439 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/events/BaseStartedNodeEvent.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/events/BaseStartedNodeEvent.java @@ -26,14 +26,20 @@ public abstract class BaseStartedNodeEvent extends TreeNodeEvent { private final int myParentId; private final String myLocationUrl; + private final String myNodeType; + private final String myNodeArgs; protected BaseStartedNodeEvent(@NotNull String name, int id, int parentId, - @Nullable final String locationUrl) { + @Nullable final String locationUrl, + @Nullable String nodeType, + @Nullable String nodeArgs) { super(name, id); myParentId = parentId; myLocationUrl = locationUrl; + myNodeType = nodeType; + myNodeArgs = nodeArgs; validate(); } @@ -58,6 +64,16 @@ public abstract class BaseStartedNodeEvent extends TreeNodeEvent { return myLocationUrl; } + @Nullable + public String getNodeType() { + return myNodeType; + } + + @Nullable + public String getNodeArgs() { + return myNodeArgs; + } + @Override protected void appendToStringInfo(@NotNull StringBuilder buf) { append(buf, "parentId", myParentId); @@ -68,4 +84,14 @@ public abstract class BaseStartedNodeEvent extends TreeNodeEvent { return TreeNodeEvent.getIntAttribute(message, "parentNodeId"); } + @Nullable + public static String getNodeType(@NotNull MessageWithAttributes message) { + return message.getAttributes().get("nodeType"); + } + + @Nullable + public static String getNodeArgs(@NotNull MessageWithAttributes message) { + return message.getAttributes().get("nodeArgs"); + } + } diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/events/TestStartedEvent.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/events/TestStartedEvent.java index 05ba2638e401..c1e15f87f012 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/events/TestStartedEvent.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/events/TestStartedEvent.java @@ -26,11 +26,15 @@ public class TestStartedEvent extends BaseStartedNodeEvent { public TestStartedEvent(@NotNull TestStarted testStarted, @Nullable String locationUrl) { - super(testStarted.getTestName(), TreeNodeEvent.getNodeId(testStarted), - getParentNodeId(testStarted), locationUrl); + super(testStarted.getTestName(), + TreeNodeEvent.getNodeId(testStarted), + getParentNodeId(testStarted), + locationUrl, + BaseStartedNodeEvent.getNodeType(testStarted), + BaseStartedNodeEvent.getNodeArgs(testStarted)); } public TestStartedEvent(@NotNull String name, @Nullable String locationUrl) { - super(name, -1, -1, locationUrl); + super(name, -1, -1, locationUrl, null, null); } } diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/events/TestSuiteStartedEvent.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/events/TestSuiteStartedEvent.java index 4c761e7471a1..89b279e7a905 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/events/TestSuiteStartedEvent.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/events/TestSuiteStartedEvent.java @@ -26,12 +26,16 @@ public class TestSuiteStartedEvent extends BaseStartedNodeEvent { public TestSuiteStartedEvent(@NotNull TestSuiteStarted suiteStarted, @Nullable String locationUrl) { - super(suiteStarted.getSuiteName(), TreeNodeEvent.getNodeId(suiteStarted), - getParentNodeId(suiteStarted), locationUrl); + super(suiteStarted.getSuiteName(), + TreeNodeEvent.getNodeId(suiteStarted), + getParentNodeId(suiteStarted), + locationUrl, + BaseStartedNodeEvent.getNodeType(suiteStarted), + BaseStartedNodeEvent.getNodeArgs(suiteStarted)); } public TestSuiteStartedEvent(@NotNull String name, @Nullable String locationUrl) { - super(name, -1, -1, locationUrl); + super(name, -1, -1, locationUrl, null, null); } } diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/MockGeneralTestEventsProcessorAdapter.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/MockGeneralTestEventsProcessorAdapter.java index 822e4e11520b..c4177badf2b7 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/MockGeneralTestEventsProcessorAdapter.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/MockGeneralTestEventsProcessorAdapter.java @@ -100,6 +100,10 @@ public class MockGeneralTestEventsProcessorAdapter implements GeneralTestEventsP public void onFinishTesting() { } + @Override + public void setPrinterProvider(@NotNull TestProxyPrinterProvider printerProvider) { + } + @Override public void dispose() { myOutputBuffer.setLength(0); From 6424e8fffac11fd298591dfc4d5689769be51450 Mon Sep 17 00:00:00 2001 From: irengrig Date: Thu, 14 Jun 2012 19:22:31 +0400 Subject: [PATCH 171/172] favorites: export to file --- .../FavoritesTreeNodeDescriptor.java | 10 +- .../FavoritesTreeViewPanel.java | 121 +++++++++++++++++- .../UsageProjectTreeNode.java | 8 ++ 3 files changed, 129 insertions(+), 10 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeNodeDescriptor.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeNodeDescriptor.java index 87b5cea954c8..dfae403c17eb 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeNodeDescriptor.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeNodeDescriptor.java @@ -55,7 +55,11 @@ public class FavoritesTreeNodeDescriptor extends PresentableNodeDescriptor previousNode = new Ref(); + final int[] depth = new int[1]; + depth[0] = 0; + final Object[] elements = myBuilder.getStructure().getChildElements(myBuilder.getRoot()); + + final TreeUtil.Traverse traverse = new TreeUtil.Traverse() { + @Override + public boolean accept(Object node) { + if (node instanceof LoadingNode) return true; + final AbstractTreeNode abstractTreeNode = (AbstractTreeNode)node; + final AbstractTreeNode parent = abstractTreeNode.getParent(); + if (Comparing.equal(previousNode.get(), parent)) { + ++depth[0]; + } + else if (previousNode.get() != null && Comparing.equal(previousNode.get().getParent(), parent)) { + //-- depth[0]; + } + else if (previousNode.get() != null) { + --depth[0]; + } + if (sb.length() > 0) { + sb.append('\n'); + } + assert depth[0] >= 0; + for (int i = 0; i < depth[0]; i++) { + sb.append('\t'); + } + abstractTreeNode.update(); + final PresentationData presentation = abstractTreeNode.getPresentation(); + sb.append(presentation.getPresentableText()); + String locationString = presentation.getLocationString(); + if (locationString == null) { + locationString = FavoritesTreeNodeDescriptor.getLocation(abstractTreeNode, myProject); + } + if (locationString != null) { + sb.append(" (").append(locationString).append(")"); + } + previousNode.set(abstractTreeNode); + return true; + } + }; + for (Object element : elements) { + traveseDepth((AbstractTreeNode)element, traverse); + } + return sb.toString(); + } + + @Override + public String getDefaultFilePath() { + return myProject.getBasePath() + File.separator + "CurrentTask.txt"; + } + + @Override + public void exportedTo(String filePath) { + } + + @Override + public boolean canExport() { + return true; + } + }; + } + + private boolean traveseDepth(final AbstractTreeNode node, final TreeUtil.Traverse traverse) { + if (! traverse.accept(node)) return false; + final Collection children = node.getChildren(); + for (Object child : children) { + if (! traveseDepth((AbstractTreeNode)child, traverse)) return false; + } + return true; + } + public void selectElement(final Object selector, final VirtualFile file, final boolean requestFocus) { myBuilder.select(selector, file, requestFocus); } diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageProjectTreeNode.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageProjectTreeNode.java index 5e95607ef707..1e1268bf9fab 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageProjectTreeNode.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageProjectTreeNode.java @@ -19,6 +19,7 @@ import com.intellij.ide.projectView.PresentationData; import com.intellij.ide.projectView.ViewSettings; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; import com.intellij.ui.SimpleTextAttributes; @@ -26,6 +27,7 @@ import com.intellij.usageView.UsageInfo; import com.intellij.usages.TextChunk; import com.intellij.usages.UsageInfo2UsageAdapter; import com.intellij.usages.UsagePresentation; +import com.intellij.util.Function; import org.jetbrains.annotations.NotNull; /** @@ -64,6 +66,12 @@ public class UsageProjectTreeNode extends ProjectViewNodeWithChildrenList() { + @Override + public String fun(TextChunk chunk) { + return chunk.getText(); + } + }, "")); } public static void updatePresentationWithTextChunks(PresentationData presentation, TextChunk[] text) { From 4c7fcf9b11f11e70a7100ccb848877dea06732de Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Thu, 14 Jun 2012 19:28:44 +0400 Subject: [PATCH 172/172] IDEA-86565 (Maven -> Refactor -> Extract Property results in "You have entered malformed...") --- .../dom/refactorings/introduce/IntroducePropertyAction.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyAction.java index 16be043e6cf9..32e68155c541 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyAction.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyAction.java @@ -228,6 +228,8 @@ public class IntroducePropertyAction extends BaseRefactoringAction { findModel.setStringToReplace(replaceWith); findModel.setReplaceState(true); findModel.setPromptOnReplace(true); + findModel.setCaseSensitive(true); + findModel.setRegularExpressions(false); return findModel; }