From 8c4504637d419d277f6595d0de0f8aaaa04234c2 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Sun, 29 Jul 2012 17:31:23 +0400 Subject: [PATCH] IDEA-88549 Auto completion makes it hard to add constructor with int parameter --- .../members/ConstructorDefinition.java | 14 +- .../completion/KeywordCompletionTest.groovy | 203 +++++++++--------- .../keyword/incompleteConstructor.test | 5 + .../typedef/interfaces/members/member2.test | 2 +- .../typedef/interfaces/members/memeber7.test | 2 +- .../statements/typedef/methods/method4.test | 2 +- 6 files changed, 116 insertions(+), 112 deletions(-) create mode 100644 plugins/groovy/testdata/groovy/oldCompletion/keyword/incompleteConstructor.test diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/members/ConstructorDefinition.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/members/ConstructorDefinition.java index 19722caa9425..1c33294b668b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/members/ConstructorDefinition.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/members/ConstructorDefinition.java @@ -51,15 +51,16 @@ public class ConstructorDefinition implements GroovyElementTypes { } if (!ParserUtils.getToken(builder, mLPAREN)) { - builder.error(GroovyBundle.message("lparen.expected")); + constructorMarker.rollbackTo(); + return false; } ParameterList.parse(builder, mRPAREN, parser); ParserUtils.getToken(builder, mNLS); if (!ParserUtils.getToken(builder, mRPAREN)) { - constructorMarker.rollbackTo(); - return false; + constructorMarker.done(CONSTRUCTOR_DEFINITION); + return true; } if (ParserUtils.lookAhead(builder, mNLS, kTHROWS) || ParserUtils.lookAhead(builder, mNLS, mLCURLY)) { @@ -71,12 +72,9 @@ public class ConstructorDefinition implements GroovyElementTypes { if (builder.getTokenType() == mLCURLY || ParserUtils.lookAhead(builder, mNLS, mLCURLY)) { ParserUtils.getToken(builder, mNLS); ConstructorBody.parseConstructorBody(builder, parser); - constructorMarker.done(CONSTRUCTOR_DEFINITION); - return true; } - - constructorMarker.rollbackTo(); - return false; + constructorMarker.done(CONSTRUCTOR_DEFINITION); + return true; } private static boolean parseModifiers(PsiBuilder builder, GroovyParser parser) { diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/KeywordCompletionTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/KeywordCompletionTest.groovy index 5ce4bf978d05..48bc2b0623ba 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/KeywordCompletionTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/KeywordCompletionTest.groovy @@ -1,101 +1,102 @@ -/* - * Copyright 2000-2007 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.completion - -import org.jetbrains.plugins.groovy.util.TestUtils - -/** - * @author ilyas - */ -public class KeywordCompletionTest extends CompletionTestBase { - - void testBr1() { doTest() } - void testCase_return() { doTest() } - void testClass1() { doTest() } - void testClass2() { doTest() } - void testClass3() { doTest() } - void testClass4() { doTest() } - void testExpr1() { doTest() } - void testExpr2() { doTest() } - void testFile11() { doTest() } - void testFile12() { doTest() } - void testFin() { doTest() } - void testFin2() { doTest() } - void testGRVY1064() { doTest() } - void testGrvy1404() { doTest() } - void testImp1() { doTest() } - void testImp2() { doTest() } - void testImp3() { doTest() } - void _testImp4() { doTest() } - void testIns1() { doTest() } - void testIns2() { doTest() } - void testIns3() { doTest() } - void testInt1() { doTest() } - void testLocal1() { doTest() } - void testMod1() { doTest() } - void testMod10() { doTest() } - void testMod11() { doTest() } - void testMod2() { doTest() } - void testMod3() { doTest() } - void testMod4() { doTest() } - void testMod5() { doTest() } - void testMod6() { doTest() } - void testMod7() { doTest() } - void testMod8() { doTest() } - void testMod9() { doTest() } - void testPack1() { doTest() } - void testSt1() { doTest() } - void testSwit1() { doTest() } - void testSwit13() { doTest() } - void testSwit14() { doTest() } - void testSwit2() { doTest() } - void testSwit3() { doTest() } - void testSwit4() { doTest() } - void testSwit5() { doTest() } - void testTag1() { doTest() } - void testTag2() { doTest() } - void testTag3() { doTest() } - void testTag4() { doTest() } - void testTh1() { doTest() } - void testTh2() { doTest() } - void testVar1() { doTest() } - void testVar10() { doTest() } - void testVar13() { doTest() } - void testVar2() { doTest() } - void testVar3() { doTest() } - void testVar4() { doTest() } - void testVar5() { doTest() } - void testVar6() { doTest() } - void testVar7() { doTest() } - void testVar8() { doTest() } - void testWhile55() { doTest() } - void testDefInsideCase() { doTest() } - void testThrows1() { doTest() } - void testThrows2() { doTest() } - void testThrows3() { doTest() } - void testPrimitiveTypes() { doTest() } - - @Override - protected String getBasePath() { - "${TestUtils.testDataPath}groovy/oldCompletion/keyword" - } - - @Override - protected boolean addReferenceVariants() { - false - } - -} +/* + * Copyright 2000-2007 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.completion + +import org.jetbrains.plugins.groovy.util.TestUtils + +/** + * @author ilyas + */ +public class KeywordCompletionTest extends CompletionTestBase { + + void testBr1() { doTest() } + void testCase_return() { doTest() } + void testClass1() { doTest() } + void testClass2() { doTest() } + void testClass3() { doTest() } + void testClass4() { doTest() } + void testExpr1() { doTest() } + void testExpr2() { doTest() } + void testFile11() { doTest() } + void testFile12() { doTest() } + void testFin() { doTest() } + void testFin2() { doTest() } + void testGRVY1064() { doTest() } + void testGrvy1404() { doTest() } + void testImp1() { doTest() } + void testImp2() { doTest() } + void testImp3() { doTest() } + void _testImp4() { doTest() } + void testIns1() { doTest() } + void testIns2() { doTest() } + void testIns3() { doTest() } + void testInt1() { doTest() } + void testLocal1() { doTest() } + void testMod1() { doTest() } + void testMod10() { doTest() } + void testMod11() { doTest() } + void testMod2() { doTest() } + void testMod3() { doTest() } + void testMod4() { doTest() } + void testMod5() { doTest() } + void testMod6() { doTest() } + void testMod7() { doTest() } + void testMod8() { doTest() } + void testMod9() { doTest() } + void testPack1() { doTest() } + void testSt1() { doTest() } + void testSwit1() { doTest() } + void testSwit13() { doTest() } + void testSwit14() { doTest() } + void testSwit2() { doTest() } + void testSwit3() { doTest() } + void testSwit4() { doTest() } + void testSwit5() { doTest() } + void testTag1() { doTest() } + void testTag2() { doTest() } + void testTag3() { doTest() } + void testTag4() { doTest() } + void testTh1() { doTest() } + void testTh2() { doTest() } + void testVar1() { doTest() } + void testVar10() { doTest() } + void testVar13() { doTest() } + void testVar2() { doTest() } + void testVar3() { doTest() } + void testVar4() { doTest() } + void testVar5() { doTest() } + void testVar6() { doTest() } + void testVar7() { doTest() } + void testVar8() { doTest() } + void testWhile55() { doTest() } + void testDefInsideCase() { doTest() } + void testThrows1() { doTest() } + void testThrows2() { doTest() } + void testThrows3() { doTest() } + void testPrimitiveTypes() { doTest() } + void testIncompleteConstructor() { doTest() } + + @Override + protected String getBasePath() { + "${TestUtils.testDataPath}groovy/oldCompletion/keyword" + } + + @Override + protected boolean addReferenceVariants() { + false + } + +} diff --git a/plugins/groovy/testdata/groovy/oldCompletion/keyword/incompleteConstructor.test b/plugins/groovy/testdata/groovy/oldCompletion/keyword/incompleteConstructor.test new file mode 100644 index 000000000000..8b84f7863cc3 --- /dev/null +++ b/plugins/groovy/testdata/groovy/oldCompletion/keyword/incompleteConstructor.test @@ -0,0 +1,5 @@ +class Foo { + Foo(int +} +----- +int \ No newline at end of file diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member2.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member2.test index 470287dbd8c8..830bd928387a 100644 --- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member2.test +++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member2.test @@ -13,7 +13,7 @@ Groovy script Type definition body PsiElement({)('{') PsiWhiteSpace('\n ') - Method + Constructor Modifiers PsiElement(def)('def') PsiWhiteSpace(' ') diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/memeber7.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/memeber7.test index 381aafc32f85..0525791874d5 100644 --- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/memeber7.test +++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/memeber7.test @@ -16,7 +16,7 @@ Groovy script Type definition body PsiElement({)('{') PsiWhiteSpace('\n ') - Method + Constructor Modifiers PsiElement(def)('def') PsiWhiteSpace(' ') diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/methods/method4.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/methods/method4.test index 9c7efc188750..7f4449ed374e 100644 --- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/methods/method4.test +++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/methods/method4.test @@ -13,7 +13,7 @@ Groovy script Type definition body PsiElement({)('{') PsiWhiteSpace('\n ') - Method + Constructor Modifiers PsiElement(def)('def') PsiWhiteSpace(' ')