From b4523b4b7a4149a76802cc64a3e2df5ed5fefaf4 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 13 Dec 2011 10:51:29 +0100 Subject: [PATCH 01/11] javadoc: process {@inheritDoc} for throws tags correctly (IDEA-62524) --- .../javadoc/JavaDocInfoGenerator.java | 17 ++++++++++++++--- .../javadocIG/inheritedDocInThrows.html | 2 ++ .../javadocIG/inheritedDocInThrows.java | 18 ++++++++++++++++++ .../javadocIG/inheritedDocInThrows1.html | 2 ++ .../javadocIG/inheritedDocInThrows1.java | 18 ++++++++++++++++++ .../javadoc/JavaDocInfoGeneratorTest.java | 8 ++++++++ 6 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/javadocIG/inheritedDocInThrows.html create mode 100644 java/java-tests/testData/codeInsight/javadocIG/inheritedDocInThrows.java create mode 100644 java/java-tests/testData/codeInsight/javadocIG/inheritedDocInThrows1.html create mode 100644 java/java-tests/testData/codeInsight/javadocIG/inheritedDocInThrows1.java diff --git a/java/java-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java b/java/java-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java index 96e23317f380..7846ec005367 100644 --- a/java/java-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java +++ b/java/java-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java @@ -1297,8 +1297,8 @@ public class JavaDocInfoGenerator { } @SuppressWarnings({"HardCodedStringLiteral"}) - private void generateThrowsSection(StringBuilder buffer, PsiMethod method, final PsiDocComment comment) { - PsiDocTag[] localTags = getThrowsTags(comment); + private void generateThrowsSection(StringBuilder buffer, final PsiMethod method, final PsiDocComment comment) { + final PsiDocTag[] localTags = getThrowsTags(comment); LinkedList>> collectedTags = new LinkedList>>(); @@ -1317,7 +1317,18 @@ public class JavaDocInfoGenerator { } } - collectedTags.addFirst(new Pair>(localTags[i], ourEmptyProvider)); + final Pair> tag = findInheritDocTag(method, exceptionLocator(valueElement.getText())); + collectedTags.addFirst(new Pair>(localTags[i], new InheritDocProvider() { + @Override + public Pair> getInheritDoc() { + return tag; + } + + @Override + public PsiClass getElement() { + return method.getContainingClass(); + } + })); } } diff --git a/java/java-tests/testData/codeInsight/javadocIG/inheritedDocInThrows.html b/java/java-tests/testData/codeInsight/javadocIG/inheritedDocInThrows.html new file mode 100644 index 000000000000..7a32b50deb34 --- /dev/null +++ b/java/java-tests/testData/codeInsight/javadocIG/inheritedDocInThrows.html @@ -0,0 +1,2 @@ + InheritedDocInThrows
void foo()
+ throws IOException
Overrides:
foo in class A
Throws:
IOException - la-la-la
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/javadocIG/inheritedDocInThrows.java b/java/java-tests/testData/codeInsight/javadocIG/inheritedDocInThrows.java new file mode 100644 index 000000000000..c7dc863f93f7 --- /dev/null +++ b/java/java-tests/testData/codeInsight/javadocIG/inheritedDocInThrows.java @@ -0,0 +1,18 @@ +import java.io.IOException; + +class InheritedDocInThrows extends A{ + /** + * @throws IOException {@inheritDoc} + */ + void foo() throws IOException { + super.foo(); + } +} + +class A { + /** + * @throws IOException la-la-la + */ + void foo() throws IOException { + } +} diff --git a/java/java-tests/testData/codeInsight/javadocIG/inheritedDocInThrows1.html b/java/java-tests/testData/codeInsight/javadocIG/inheritedDocInThrows1.html new file mode 100644 index 000000000000..59796e76cd2a --- /dev/null +++ b/java/java-tests/testData/codeInsight/javadocIG/inheritedDocInThrows1.html @@ -0,0 +1,2 @@ + InheritedDocInThrows1
void foo()
+ throws IOException
Overrides:
foo in class A
Throws:
IOException - comment
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/javadocIG/inheritedDocInThrows1.java b/java/java-tests/testData/codeInsight/javadocIG/inheritedDocInThrows1.java new file mode 100644 index 000000000000..530e5f0301a9 --- /dev/null +++ b/java/java-tests/testData/codeInsight/javadocIG/inheritedDocInThrows1.java @@ -0,0 +1,18 @@ +import java.io.IOException; + +class InheritedDocInThrows1 extends A{ + /** + * @throws java.io.IOException comment + */ + void foo() throws IOException { + super.foo(); + } +} + +class A { + /** + * @throws java.io.IOException la-la-la + */ + void foo() throws IOException { + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java index 2a322062088f..f19d845473e8 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java @@ -33,6 +33,14 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase { public void testMethodTypeParameter() throws Exception { doTestMethod(); } + + public void testInheritedDocInThrows() throws Exception { + doTestMethod(); + } + + public void testInheritedDocInThrows1() throws Exception { + doTestMethod(); + } public void testClassTypeParameter() throws Exception { verifyJavaDoc(getTestClass()); From 369892166fc63e5aabd86ce851cea78e5884707c Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Tue, 13 Dec 2011 13:37:56 +0100 Subject: [PATCH 02/11] focus lost in commit dialog during fix invocation [kirillirill.kalishev@k] --- platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java index 3a0e71967b9a..c0079bafd7d6 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java @@ -596,7 +596,7 @@ public class IdeEventQueue extends EventQueue { boolean mouseEventsAhead = isMouseEventAhead(e); boolean focusTransferred = IdeFocusManager.getGlobalInstance().isFocusBeingTransferred(); - boolean okToFixFocus = !mouseEventsAhead && (!focusTransferred || !Registry.is("actionSystem.fixLostTyping")); + boolean okToFixFocus = !mouseEventsAhead && focusTransferred; if (okToFixFocus) { Window showingWindow = mgr.getActiveWindow(); From 61fc5902992c4f54771cc944a438f4fa0f4621d0 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 13 Dec 2011 14:37:01 +0100 Subject: [PATCH 03/11] yet another internal action throwing an exception --- resources/src/idea/JavaActions.xml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/resources/src/idea/JavaActions.xml b/resources/src/idea/JavaActions.xml index f76529a259ca..4688bab71e6e 100644 --- a/resources/src/idea/JavaActions.xml +++ b/resources/src/idea/JavaActions.xml @@ -111,15 +111,13 @@ - + - - - - - + + + From 215f03a95ed5785ac20e438c30d23f9293b75e38 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 13 Dec 2011 15:02:08 +0100 Subject: [PATCH 04/11] remove useless groovy anno pair psi element (IDEA-78587) --- .../groovy/lang/parser/GroovyPsiCreator.java | 1 - .../annotations/AnnotationArguments.java | 8 +-- .../groovy/lang/psi/GroovyElementVisitor.java | 4 -- .../GrAnnotationNameValuePairs.java | 26 --------- .../GrAnnotationArgumentListImpl.java | 3 +- .../GrAnnotationNameValuePairsImpl.java | 47 --------------- .../parsing/groovy/annotations/ann1.test | 23 ++++---- .../parsing/groovy/annotations/ann2.test | 43 +++++++------- .../parsing/groovy/annotations/ann4.test | 23 ++++---- .../parsing/groovy/annotations/ann5.test | 57 +++++++++---------- .../parsing/groovy/annotations/ann7.test | 27 +++++---- 11 files changed, 89 insertions(+), 173 deletions(-) delete mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/auxiliary/modifiers/annotation/GrAnnotationNameValuePairs.java delete mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/annotation/GrAnnotationNameValuePairsImpl.java diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyPsiCreator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyPsiCreator.java index 4cc19b43574e..30c697c579a0 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyPsiCreator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyPsiCreator.java @@ -105,7 +105,6 @@ public class GroovyPsiCreator implements GroovyElementTypes { if (elem == ANNOTATION_ARGUMENTS) return new GrAnnotationArgumentListImpl(node); if (elem == ANNOTATION_ARRAY_INITIALIZER) return new GrAnnotationArrrayInitializerImpl(node); if (elem == ANNOTATION_MEMBER_VALUE_PAIR) return new GrAnnotationNameValuePairImpl(node); - if (elem == ANNOTATION_MEMBER_VALUE_PAIRS) return new GrAnnotationNameValuePairsImpl(node); if (elem == DEFAULT_ANNOTATION_VALUE) return new GrDefaultAnnotationValueImpl(node); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/annotations/AnnotationArguments.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/annotations/AnnotationArguments.java index c9d5da85445e..720ab13428dd 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/annotations/AnnotationArguments.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/annotations/AnnotationArguments.java @@ -93,10 +93,10 @@ public class AnnotationArguments implements GroovyElementTypes { */ private static boolean parseAnnotationMemberValuePairs(PsiBuilder builder, GroovyParser parser) { - PsiBuilder.Marker annmvps = builder.mark(); + PsiBuilder.Marker start = builder.mark(); if (!parseAnnotationMemberValueSinglePair(builder, parser)) { - annmvps.rollbackTo(); + start.rollbackTo(); return false; } @@ -104,12 +104,12 @@ public class AnnotationArguments implements GroovyElementTypes { ParserUtils.getToken(builder, mNLS); if (!parseAnnotationMemberValueSinglePair(builder, parser)) { - annmvps.rollbackTo(); + start.rollbackTo(); return false; } } + start.drop(); - annmvps.done(ANNOTATION_MEMBER_VALUE_PAIRS); return true; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyElementVisitor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyElementVisitor.java index 89a2b8f7b93b..e63cbe060690 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyElementVisitor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyElementVisitor.java @@ -321,10 +321,6 @@ public abstract class GroovyElementVisitor { visitElement(nameValuePair); } - public void visitAnnotationNameValuePairs(GrAnnotationNameValuePairs nameValuePair) { - visitElement(nameValuePair); - } - public void visitAnnotation(GrAnnotation annotation) { visitElement(annotation); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/auxiliary/modifiers/annotation/GrAnnotationNameValuePairs.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/auxiliary/modifiers/annotation/GrAnnotationNameValuePairs.java deleted file mode 100644 index 63487ef05c4c..000000000000 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/auxiliary/modifiers/annotation/GrAnnotationNameValuePairs.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation; - -import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement; - -/** - * @author: Dmitry.Krasilschikov - * @date: 04.04.2007 - */ -public interface GrAnnotationNameValuePairs extends GroovyPsiElement { -} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/annotation/GrAnnotationArgumentListImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/annotation/GrAnnotationArgumentListImpl.java index c89fa58f9daa..f09e8dd87e61 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/annotation/GrAnnotationArgumentListImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/annotation/GrAnnotationArgumentListImpl.java @@ -52,8 +52,7 @@ public class GrAnnotationArgumentListImpl extends GroovyPsiElementImpl implement @NotNull public GrAnnotationNameValuePair[] getAttributes() { - final GrAnnotationNameValuePairsImpl pairs = findChildByClass(GrAnnotationNameValuePairsImpl.class); - return pairs == null ? findChildrenByClass(GrAnnotationNameValuePair.class) : pairs.getAttributes(); + return findChildrenByClass(GrAnnotationNameValuePair.class); } @Override diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/annotation/GrAnnotationNameValuePairsImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/annotation/GrAnnotationNameValuePairsImpl.java deleted file mode 100644 index bf7c36684749..000000000000 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/annotation/GrAnnotationNameValuePairsImpl.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary.annotation; - -import com.intellij.lang.ASTNode; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor; -import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationNameValuePair; -import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationNameValuePairs; -import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl; - -/** - * @author: Dmitry.Krasilschikov - * @date: 04.04.2007 - */ -public class GrAnnotationNameValuePairsImpl extends GroovyPsiElementImpl implements GrAnnotationNameValuePairs { - public GrAnnotationNameValuePairsImpl(@NotNull ASTNode node) { - super(node); - } - - @NotNull - public GrAnnotationNameValuePair[] getAttributes() { - return findChildrenByClass(GrAnnotationNameValuePair.class); - } - - public void accept(GroovyElementVisitor visitor) { - visitor.visitAnnotationNameValuePairs(this); - } - - public String toString() { - return "Annotation member value pairs"; - } -} diff --git a/plugins/groovy/testdata/parsing/groovy/annotations/ann1.test b/plugins/groovy/testdata/parsing/groovy/annotations/ann1.test index 2bb471c5950c..f8d55041009a 100644 --- a/plugins/groovy/testdata/parsing/groovy/annotations/ann1.test +++ b/plugins/groovy/testdata/parsing/groovy/annotations/ann1.test @@ -11,18 +11,17 @@ Groovy script PsiWhiteSpace(' ') Annotation arguments PsiElement(()('(') - Annotation member value pairs - Annotation member value pair - PsiElement(identifier)('a') - PsiWhiteSpace(' ') - PsiElement(=)('=') - PsiWhiteSpace(' ') - Annotation - PsiElement(@)('@') - Reference element - PsiElement(identifier)('notnull') - Annotation arguments - + Annotation member value pair + PsiElement(identifier)('a') + PsiWhiteSpace(' ') + PsiElement(=)('=') + PsiWhiteSpace(' ') + Annotation + PsiElement(@)('@') + Reference element + PsiElement(identifier)('notnull') + Annotation arguments + PsiElement())(')') PsiElement(new line)('\n') PsiElement(def)('def') diff --git a/plugins/groovy/testdata/parsing/groovy/annotations/ann2.test b/plugins/groovy/testdata/parsing/groovy/annotations/ann2.test index 15cb085d4a4a..564bd355c47e 100644 --- a/plugins/groovy/testdata/parsing/groovy/annotations/ann2.test +++ b/plugins/groovy/testdata/parsing/groovy/annotations/ann2.test @@ -10,29 +10,28 @@ Groovy script PsiWhiteSpace(' ') Annotation arguments PsiElement(()('(') - Annotation member value pairs - Annotation member value pair - PsiElement(identifier)('a') - PsiWhiteSpace(' ') - PsiElement(=)('=') - PsiWhiteSpace(' ') - Conditional expression - Method call - Reference expression - PsiElement(identifier)('isNull') - Arguments - PsiElement(()('(') - PsiElement())(')') - PsiWhiteSpace(' ') - PsiElement(?)('?') - PsiWhiteSpace(' ') + Annotation member value pair + PsiElement(identifier)('a') + PsiWhiteSpace(' ') + PsiElement(=)('=') + PsiWhiteSpace(' ') + Conditional expression + Method call Reference expression - PsiElement(identifier)('b') - PsiWhiteSpace(' ') - PsiElement(:)(':') - PsiWhiteSpace(' ') - Reference expression - PsiElement(identifier)('c') + PsiElement(identifier)('isNull') + Arguments + PsiElement(()('(') + PsiElement())(')') + PsiWhiteSpace(' ') + PsiElement(?)('?') + PsiWhiteSpace(' ') + Reference expression + PsiElement(identifier)('b') + PsiWhiteSpace(' ') + PsiElement(:)(':') + PsiWhiteSpace(' ') + Reference expression + PsiElement(identifier)('c') PsiElement())(')') PsiWhiteSpace(' ') PsiElement(identifier)('a') diff --git a/plugins/groovy/testdata/parsing/groovy/annotations/ann4.test b/plugins/groovy/testdata/parsing/groovy/annotations/ann4.test index 51be976a04f5..0450d860fbdb 100644 --- a/plugins/groovy/testdata/parsing/groovy/annotations/ann4.test +++ b/plugins/groovy/testdata/parsing/groovy/annotations/ann4.test @@ -10,18 +10,17 @@ Groovy script PsiWhiteSpace(' ') Annotation arguments PsiElement(()('(') - Annotation member value pairs - Annotation member value pair - PsiElement(identifier)('a') - PsiWhiteSpace(' ') - PsiElement(=)('=') - PsiWhiteSpace(' ') - Annotation - PsiElement(@)('@') - Reference element - PsiElement(identifier)('b') - Annotation arguments - + Annotation member value pair + PsiElement(identifier)('a') + PsiWhiteSpace(' ') + PsiElement(=)('=') + PsiWhiteSpace(' ') + Annotation + PsiElement(@)('@') + Reference element + PsiElement(identifier)('b') + Annotation arguments + PsiElement())(')') PsiWhiteSpace(' ') PsiElement(class)('class') diff --git a/plugins/groovy/testdata/parsing/groovy/annotations/ann5.test b/plugins/groovy/testdata/parsing/groovy/annotations/ann5.test index 5f49eb6f9f2b..5ab0089248f5 100644 --- a/plugins/groovy/testdata/parsing/groovy/annotations/ann5.test +++ b/plugins/groovy/testdata/parsing/groovy/annotations/ann5.test @@ -10,38 +10,37 @@ Groovy script PsiWhiteSpace(' ') Annotation arguments PsiElement(()('(') - Annotation member value pairs - Annotation member value pair - PsiElement(identifier)('a') - PsiWhiteSpace(' ') - PsiElement(=)('=') - PsiWhiteSpace(' ') - Annotation - PsiElement(@)('@') - Reference element - PsiElement(identifier)('Ann1') - Annotation arguments - - PsiElement(,)(',') + Annotation member value pair + PsiElement(identifier)('a') PsiWhiteSpace(' ') - Annotation member value pair - PsiElement(identifier)('b') + PsiElement(=)('=') + PsiWhiteSpace(' ') + Annotation + PsiElement(@)('@') + Reference element + PsiElement(identifier)('Ann1') + Annotation arguments + + PsiElement(,)(',') + PsiWhiteSpace(' ') + Annotation member value pair + PsiElement(identifier)('b') + PsiWhiteSpace(' ') + PsiElement(=)('=') + PsiWhiteSpace(' ') + Conditional expression + Literal + PsiElement(true)('true') PsiWhiteSpace(' ') - PsiElement(=)('=') + PsiElement(?)('?') PsiWhiteSpace(' ') - Conditional expression - Literal - PsiElement(true)('true') - PsiWhiteSpace(' ') - PsiElement(?)('?') - PsiWhiteSpace(' ') - Reference expression - PsiElement(identifier)('c') - PsiWhiteSpace(' ') - PsiElement(:)(':') - PsiWhiteSpace(' ') - Literal - PsiElement(false)('false') + Reference expression + PsiElement(identifier)('c') + PsiWhiteSpace(' ') + PsiElement(:)(':') + PsiWhiteSpace(' ') + Literal + PsiElement(false)('false') PsiElement())(')') PsiWhiteSpace(' ') Type element diff --git a/plugins/groovy/testdata/parsing/groovy/annotations/ann7.test b/plugins/groovy/testdata/parsing/groovy/annotations/ann7.test index d878edfd986c..d1ab3276f07f 100644 --- a/plugins/groovy/testdata/parsing/groovy/annotations/ann7.test +++ b/plugins/groovy/testdata/parsing/groovy/annotations/ann7.test @@ -11,21 +11,20 @@ Groovy script PsiWhiteSpace(' ') Annotation arguments PsiElement(()('(') - Annotation member value pairs - Annotation member value pair - PsiElement(identifier)('foo') + Annotation member value pair + PsiElement(identifier)('foo') + PsiWhiteSpace(' ') + PsiElement(=)('=') + PsiWhiteSpace(' ') + Annotation array initializer + PsiElement([)('[') + Literal + PsiElement(Integer)('1') + PsiElement(,)(',') PsiWhiteSpace(' ') - PsiElement(=)('=') - PsiWhiteSpace(' ') - Annotation array initializer - PsiElement([)('[') - Literal - PsiElement(Integer)('1') - PsiElement(,)(',') - PsiWhiteSpace(' ') - Literal - PsiElement(Integer)('2') - PsiElement(])(']') + Literal + PsiElement(Integer)('2') + PsiElement(])(']') PsiElement())(')') PsiElement(new line)('\n') PsiElement(class)('class') From 4c190aa04b2d4ca38e0ddebc2ffb0fdeb3f16f2c Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Tue, 13 Dec 2011 09:28:37 +0400 Subject: [PATCH 05/11] 1. Stacktrace filter for JRuby stack traces (java/ruby code) 2. EP for attaching stacktrace filters for Ruby run configurations --- .../execution/runners/AbstractConsoleRunnerWithHistory.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/lang-impl/src/com/intellij/execution/runners/AbstractConsoleRunnerWithHistory.java b/platform/lang-impl/src/com/intellij/execution/runners/AbstractConsoleRunnerWithHistory.java index 44ee034f3a44..f016f4c63258 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/AbstractConsoleRunnerWithHistory.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/AbstractConsoleRunnerWithHistory.java @@ -308,4 +308,8 @@ public abstract class AbstractConsoleRunnerWithHistory Date: Tue, 13 Dec 2011 19:34:08 +0400 Subject: [PATCH 06/11] Support for performance tests separation --- .../ide/plugins/VersionCompareTest.java | 4 - .../src/com/intellij/TestAll.java | 95 +++++++++++++++---- .../src/com/intellij/TestCaseLoader.java | 71 +++++--------- 3 files changed, 99 insertions(+), 71 deletions(-) diff --git a/platform/platform-impl/testSrc/com/intellij/ide/plugins/VersionCompareTest.java b/platform/platform-impl/testSrc/com/intellij/ide/plugins/VersionCompareTest.java index 59ad9f7437fb..c830d138674f 100644 --- a/platform/platform-impl/testSrc/com/intellij/ide/plugins/VersionCompareTest.java +++ b/platform/platform-impl/testSrc/com/intellij/ide/plugins/VersionCompareTest.java @@ -27,10 +27,6 @@ import junit.framework.TestSuite; * To change this template use Options | File Templates. */ public class VersionCompareTest extends TestCase { - public static TestSuite suite () { - return new TestSuite (VersionCompareTest.class); - } - public void testEqual () { String v1 = "0.0.1"; String v2 = "0.0.1"; diff --git a/platform/testFramework/src/com/intellij/TestAll.java b/platform/testFramework/src/com/intellij/TestAll.java index f522cebb64b5..e21d4140dec1 100644 --- a/platform/testFramework/src/com/intellij/TestAll.java +++ b/platform/testFramework/src/com/intellij/TestAll.java @@ -31,6 +31,10 @@ import com.intellij.testFramework.*; import com.intellij.tests.ExternalClasspathClassLoader; import com.intellij.util.ArrayUtil; import junit.framework.*; +import org.jetbrains.annotations.Nullable; +import org.junit.runner.Description; +import org.junit.runner.manipulation.Filter; +import org.junit.runner.manipulation.NoTestsRemainException; import java.io.File; import java.io.IOException; @@ -62,9 +66,37 @@ public class TestAll implements Test { private static final int FILTER_CLASSES = 16; public static int ourMode = SAVE_MEMORY_SNAPSHOT /*| START_GUARD | RUN_GC | CHECK_MEMORY*/ | FILTER_CLASSES; + private static final boolean PERFORMANCE_TESTS_ONLY = System.getProperty(TestCaseLoader.PERFORMANCE_TESTS_ONLY_FLAG) != null; private int myLastTestTestMethodCount = 0; public static final int MAX_FAILURE_TEST_COUNT = 150; + private static final Filter PERFORMANCE_ONLY = new Filter() { + @Override + public boolean shouldRun(Description description) { + String className = description.getClassName(); + String methodName = description.getMethodName(); + return className != null && hasPerformance(className) || + methodName != null && hasPerformance(methodName); + } + + @Override + public String describe() { + return "Performance Tests Only"; + } + }; + + private static final Filter NO_PERFORMANCE = new Filter() { + @Override + public boolean shouldRun(Description description) { + return !PERFORMANCE_ONLY.shouldRun(description); + } + + @Override + public String describe() { + return "All Except Performance"; + } + }; + @Override public int countTestCases() { List classes = myTestCaseLoader.getClasses(); @@ -247,16 +279,36 @@ public class TestAll implements Test { return realFreeMemory < needed; } - private static Test getTest(Class testCaseClass) { + private static boolean isPerformanceTestsRun() { + return PERFORMANCE_TESTS_ONLY; + } + + @Nullable + private static Test getTest(final Class testCaseClass) { if ((testCaseClass.getModifiers() & Modifier.PUBLIC) == 0) return null; - try { - Method suiteMethod = testCaseClass.getMethod("suite", ArrayUtil.EMPTY_CLASS_ARRAY); - return (Test)suiteMethod.invoke(null, ArrayUtil.EMPTY_CLASS_ARRAY); + Method suiteMethod = safeFindMethod(testCaseClass, "suite"); + if (suiteMethod != null && !isPerformanceTestsRun()) { + try { + return (Test)suiteMethod.invoke(null, ArrayUtil.EMPTY_CLASS_ARRAY); + } + catch (Exception e) { + System.err.println("Failed to execute suite ()"); + e.printStackTrace(); + } } - catch (NoSuchMethodException e) { + else { if (TestRunnerUtil.isJUnit4TestClass(testCaseClass)) { - return new JUnit4TestAdapter(testCaseClass); + JUnit4TestAdapter adapter = new JUnit4TestAdapter(testCaseClass); + if (!hasPerformance(testCaseClass.getSimpleName()) || !isPerformanceTestsRun()) { + try { + adapter.filter(isPerformanceTestsRun() ? PERFORMANCE_ONLY : NO_PERFORMANCE); + } + catch (NoTestsRemainException e1) { + // Ignore + } + } + return adapter; } return new TestSuite(testCaseClass){ @Override @@ -264,6 +316,8 @@ public class TestAll implements Test { if (!(test instanceof TestCase)) { super.addTest(test); } else { + if (isPerformanceTestsRun() ^ (hasPerformance(((TestCase)test).getName()) || hasPerformance(testCaseClass.getSimpleName()))) return; + Method method = findTestMethod((TestCase)test); if (method == null || !TestCaseLoader.isBombed(method)) { super.addTest(test); @@ -272,24 +326,30 @@ public class TestAll implements Test { } + @Nullable private Method findTestMethod(final TestCase testCase) { - try { - return testCase.getClass().getMethod(testCase.getName()); - } - catch (NoSuchMethodException e1) { - return null; - } + return safeFindMethod(testCase.getClass(), testCase.getName()); } }; } - catch (Exception e) { - System.err.println("Failed to execute suite ()"); - e.printStackTrace(); - } return null; } + private static boolean hasPerformance(String name) { + return name.toLowerCase().contains("performance"); + } + + @Nullable + private static Method safeFindMethod(Class klass, String name) { + try { + return klass.getMethod(name); + } + catch (NoSuchMethodException e) { + return null; + } + } + public static String[] getClassRoots() { String testRoots = System.getProperty("test.roots"); if (testRoots != null) { @@ -325,7 +385,7 @@ public class TestAll implements Test { if (Boolean.parseBoolean(System.getProperty("idea.ignore.predefined.groups")) || (ourMode & FILTER_CLASSES) == 0) { classFilterName = ""; } - myTestCaseLoader = new TestCaseLoader(classFilterName); + myTestCaseLoader = new TestCaseLoader(classFilterName, isPerformanceTestsRun()); myTestCaseLoader.addFirstTest(Class.forName("_FirstInSuiteTest")); myTestCaseLoader.addLastTest(Class.forName("_LastInSuiteTest")); @@ -348,7 +408,6 @@ public class TestAll implements Test { } log("Number of test classes found: " + testCaseLoader.getClasses().size()); - testCaseLoader.checkClassesExist(); } private static void log(String message) { diff --git a/platform/testFramework/src/com/intellij/TestCaseLoader.java b/platform/testFramework/src/com/intellij/TestCaseLoader.java index 7ad2b70a33b9..816161729755 100644 --- a/platform/testFramework/src/com/intellij/TestCaseLoader.java +++ b/platform/testFramework/src/com/intellij/TestCaseLoader.java @@ -25,8 +25,6 @@ package com.intellij; import com.intellij.idea.Bombed; -import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.testFramework.PlatformTestUtil; import com.intellij.testFramework.TestRunnerUtil; @@ -39,7 +37,7 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.*; -@SuppressWarnings({"HardCodedStringLiteral"}) +@SuppressWarnings({"HardCodedStringLiteral", "UseOfSystemOutOrSystemErr", "CallToPrintStackTrace", "TestOnlyProblems"}) public class TestCaseLoader { /** Holds name of JVM property that is assumed to define target test group name. */ @@ -48,28 +46,31 @@ public class TestCaseLoader { /** Holds name of JVM property that is assumed to define filtering rules for test classes. */ private static final String TARGET_TEST_PATTERNS = "idea.test.patterns"; - /** Holds name of JVM property that is assumed to determine if only 'fast' tests should be executed. */ - private static final String FAST_TESTS_ONLY_FLAG = "idea.fast.only"; + public static final String PERFORMANCE_TESTS_ONLY_FLAG = "idea.performance.tests"; private final List myClassList = new ArrayList(); private Class myFirstTestClass; private Class myLastTestClass; private final TestClassesFilter myTestClassesFilter; - private final String myTestGroupName; - private final Set blockedTests = new HashSet(); - private final String[] slowTestNames; + private boolean myIsPerformanceTestsRun; public TestCaseLoader(String classFilterName) { + this(classFilterName, false); + } + + public TestCaseLoader(String classFilterName, boolean isPerformanceTestsRun) { + myIsPerformanceTestsRun = isPerformanceTestsRun; InputStream excludedStream = StringUtil.isEmpty(classFilterName) ? null : getClass().getClassLoader().getResourceAsStream(classFilterName); String preconfiguredGroup = System.getProperty(TARGET_TEST_GROUP); - if (preconfiguredGroup == null || "".equals(preconfiguredGroup.trim())) { - myTestGroupName = ""; + String testGroupName; + if (preconfiguredGroup == null || preconfiguredGroup.trim().isEmpty()) { + testGroupName = ""; } else { - myTestGroupName = preconfiguredGroup.trim(); + testGroupName = preconfiguredGroup.trim(); } if (excludedStream != null) { try { - myTestClassesFilter = GroupBasedTestClassFilter.createOn(new InputStreamReader(excludedStream), myTestGroupName); + myTestClassesFilter = GroupBasedTestClassFilter.createOn(new InputStreamReader(excludedStream), testGroupName); } finally { try { @@ -90,40 +91,7 @@ public class TestCaseLoader { } } - String[] names; - try { - InputStream stream = getClass().getClassLoader().getResourceAsStream("tests/slowTests.txt"); - names = FileUtil.loadTextAndClose(new InputStreamReader(stream)).split("\\s"); - } - catch (Exception e) { - // no luck - names = new String[0]; - } - slowTestNames = names; - if (Comparing.equal(System.getProperty(FAST_TESTS_ONLY_FLAG), "true")) { - blockedTests.addAll(Arrays.asList(slowTestNames)); - } - else { - checkClassesExist(); - } - System.out.println("Using test group: [" + myTestGroupName +"]"); - } - - void checkClassesExist() { - String s = ""; - for (String slowTestName : slowTestNames) { - if (slowTestName.trim().length() == 0) continue; - if (blockedTests.contains(slowTestName)) continue; - try { - Class.forName(slowTestName); - } - catch (ClassNotFoundException e) { - s += "\n" + slowTestName; - } - } - if (s.length() != 0) { - throw new RuntimeException("Tests in slowTests.txt which cannot be instantiated: "+s); - } + System.out.println("Using test group: [" + testGroupName +"]"); } /* @@ -165,7 +133,10 @@ public class TestCaseLoader { //System.out.println("testCaseClass = " + testCaseClass); return true; } - } catch (NoSuchMethodException e) { } + } + catch (NoSuchMethodException e) { + // can't be + } return TestRunnerUtil.isJUnit4TestClass(testCaseClass); } @@ -174,8 +145,10 @@ public class TestCaseLoader { * Determine if we should exclude this test case. */ private boolean shouldExcludeTestClass(Class testCaseClass) { - return !myTestClassesFilter.matches(testCaseClass.getName()) || isBombed(testCaseClass) - || blockedTests.contains(testCaseClass.getName()); + String className = testCaseClass.getName(); + if (className.toLowerCase().contains("performance") && !myIsPerformanceTestsRun) return true; + + return !myTestClassesFilter.matches(className) || isBombed(testCaseClass); } public static boolean isBombed(final Method method) { From f4ef26fdf97cb703b182c9743c0a7306d489e4b5 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 13 Dec 2011 16:35:47 +0100 Subject: [PATCH 07/11] provide a message with explanation why the suite was not run (IDEA-78806) --- .../junit_rt/src/com/intellij/junit3/TestRunnerUtil.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/junit_rt/src/com/intellij/junit3/TestRunnerUtil.java b/plugins/junit_rt/src/com/intellij/junit3/TestRunnerUtil.java index a6713e299ebd..db09301dbab4 100644 --- a/plugins/junit_rt/src/com/intellij/junit3/TestRunnerUtil.java +++ b/plugins/junit_rt/src/com/intellij/junit3/TestRunnerUtil.java @@ -117,7 +117,12 @@ public class TestRunnerUtil { } try { //noinspection SSBasedInspection - test = (Test)suiteMethod.invoke(null, new Class[0]); // static method + test = (Test)suiteMethod.invoke(null, new Class[0]); // static method + if (test == null) { + return new FailedTestCase(testClass, BaseTestRunner.SUITE_METHODNAME, + MessageFormat.format(ourBundle.getString("junit.failed.to.invoke.suite"), new Object[]{"method " + suiteClassName + ".suite() evaluates to null"}), + null); + } test = new SuiteMethodWrapper(test, suiteClassName); } catch (final InvocationTargetException e) { From 78810ccf1cca1314b6e5548ae1d3b3a07e44a1b1 Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Tue, 13 Dec 2011 19:53:49 +0400 Subject: [PATCH 08/11] haml: bundled color schemes updated --- .../src/colorSchemes/all_hallows_eve.xml | 25 ++++++++++++++++ colorSchemes/src/colorSchemes/blackboard.xml | 24 +++++++++++++++ colorSchemes/src/colorSchemes/cobalt.xml | 30 +++++++++++++++++++ colorSchemes/src/colorSchemes/monokai.xml | 26 ++++++++++++++++ colorSchemes/src/colorSchemes/rails_casts.xml | 24 +++++++++++++++ colorSchemes/src/colorSchemes/twilight.xml | 24 +++++++++++++++ colorSchemes/src/colorSchemes/vibrant_ink.xml | 28 +++++++++++++++++ 7 files changed, 181 insertions(+) diff --git a/colorSchemes/src/colorSchemes/all_hallows_eve.xml b/colorSchemes/src/colorSchemes/all_hallows_eve.xml index 667867a556ca..4341b2a6d87f 100644 --- a/colorSchemes/src/colorSchemes/all_hallows_eve.xml +++ b/colorSchemes/src/colorSchemes/all_hallows_eve.xml @@ -600,6 +600,9 @@ + + + + + + +