mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-69253 completion in type elements of parameters after dot
This commit is contained in:
+8
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -32,6 +32,8 @@ import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.ReferenceElement.ReferenceElementResult.*;
|
||||
|
||||
/**
|
||||
* @author: Dmitry.Krasilschikov, ilyas
|
||||
*/
|
||||
@@ -47,7 +49,7 @@ public class ParameterDeclaration implements GroovyElementTypes {
|
||||
|
||||
final ReferenceElement.ReferenceElementResult result = TypeSpec.parseStrict(builder, true);
|
||||
|
||||
if (result == ReferenceElement.ReferenceElementResult.FAIL && !hasModifiers) {
|
||||
if (result == FAIL && !hasModifiers) {
|
||||
rb.drop();
|
||||
pdMarker.rollbackTo();
|
||||
return false;
|
||||
@@ -90,9 +92,10 @@ public class ParameterDeclaration implements GroovyElementTypes {
|
||||
if (mIDENT.equals(builder.getTokenType()) || (mTRIPLE_DOT.equals(builder.getTokenType()))) {
|
||||
rb.drop();
|
||||
}
|
||||
else if (result == ReferenceElement.ReferenceElementResult.REF_WITH_TYPE_PARAMS) {
|
||||
else if (result == REF_WITH_TYPE_PARAMS || result == PATH_REF) {
|
||||
rb.drop();
|
||||
pdMarker.error(GroovyBundle.message("identifier.expected"));
|
||||
pdMarker.drop();
|
||||
builder.error(GroovyBundle.message("identifier.expected"));
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@@ -135,7 +138,7 @@ public class ParameterDeclaration implements GroovyElementTypes {
|
||||
rb.drop();
|
||||
rb = builder.mark();
|
||||
final ReferenceElement.ReferenceElementResult result = TypeSpec.parseStrict(builder, false);
|
||||
if (result == ReferenceElement.ReferenceElementResult.FAIL && ParserUtils.lookAhead(builder, mBOR)) {
|
||||
if (result == FAIL && ParserUtils.lookAhead(builder, mBOR)) {
|
||||
builder.error(GroovyBundle.message("type.expected"));
|
||||
}
|
||||
else {
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ public class ReferenceElement implements GroovyElementTypes {
|
||||
}
|
||||
|
||||
public enum ReferenceElementResult {
|
||||
IDENTIFIER, PATH_REF, REF_WITH_TYPE_PARAMS, PATH_REF_WITHOUT_NAME_ELEMENT, FAIL
|
||||
IDENTIFIER, PATH_REF, REF_WITH_TYPE_PARAMS, FAIL
|
||||
}
|
||||
|
||||
public static ReferenceElementResult parseForImport(@NotNull PsiBuilder builder) {
|
||||
|
||||
+7
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -139,14 +139,18 @@ class GroovyAutoPopupTest extends CompletionAutoPopupTestCase {
|
||||
myFixture.addClass("class Foo { static class Bar {} }")
|
||||
myFixture.configureByText "a.groovy", "void foo(Foo<caret>[] a) { }"
|
||||
type '.'
|
||||
assert !lookup
|
||||
assert lookup
|
||||
type '.'
|
||||
myFixture.checkResult('void foo(Foo..<caret>[] a) { }')
|
||||
}
|
||||
|
||||
public void testTypingFirstVarargDot2() {
|
||||
myFixture.addClass("class Foo { static class Bar {} }")
|
||||
myFixture.configureByText "a.groovy", "void foo(Foo<caret>) { }"
|
||||
type '.'
|
||||
assert !lookup
|
||||
assert lookup
|
||||
type '.'
|
||||
myFixture.checkResult('void foo(Foo..<caret>) { }')
|
||||
}
|
||||
|
||||
public void testDotDot() {
|
||||
|
||||
@@ -51,5 +51,9 @@ public class TypesParsingTest extends GroovyParsingTestCase {
|
||||
public void testStaticInitializer() throws Throwable { doTest(); }
|
||||
public void testInterfaceWithGroovyDoc() throws Throwable { doTest(); }
|
||||
|
||||
public void testIncorrectParam1() { doTest() }
|
||||
public void testIncorrectParam2() { doTest() }
|
||||
public void testIncorrectParam3() { doTest() }
|
||||
|
||||
public void testEmptyTypeArgs() {doTest()}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
def foo(A a, A. b) {}
|
||||
-----
|
||||
Groovy script
|
||||
Method
|
||||
Modifiers
|
||||
PsiElement(def)('def')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(identifier)('foo')
|
||||
PsiElement(()('(')
|
||||
Parameter list
|
||||
Parameter
|
||||
Modifiers
|
||||
<empty list>
|
||||
Type element
|
||||
Reference element
|
||||
PsiElement(identifier)('A')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(identifier)('a')
|
||||
PsiElement(,)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
Modifiers
|
||||
<empty list>
|
||||
Type element
|
||||
Reference element
|
||||
Reference element
|
||||
PsiElement(identifier)('A')
|
||||
PsiElement(.)('.')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(identifier)('b')
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiElement())(')')
|
||||
PsiWhiteSpace(' ')
|
||||
Throw clause
|
||||
<empty list>
|
||||
Open block
|
||||
PsiElement({)('{')
|
||||
PsiElement(})('}')
|
||||
@@ -0,0 +1,28 @@
|
||||
def foo(A. B) {}
|
||||
-----
|
||||
Groovy script
|
||||
Method
|
||||
Modifiers
|
||||
PsiElement(def)('def')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(identifier)('foo')
|
||||
PsiElement(()('(')
|
||||
Parameter list
|
||||
Modifiers
|
||||
<empty list>
|
||||
Type element
|
||||
Reference element
|
||||
Reference element
|
||||
PsiElement(identifier)('A')
|
||||
PsiElement(.)('.')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(identifier)('B')
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiElement())(')')
|
||||
PsiWhiteSpace(' ')
|
||||
Throw clause
|
||||
<empty list>
|
||||
Open block
|
||||
PsiElement({)('{')
|
||||
PsiElement(})('}')
|
||||
@@ -0,0 +1,38 @@
|
||||
def foo(A. b, A c) {}
|
||||
-----
|
||||
Groovy script
|
||||
Method
|
||||
Modifiers
|
||||
PsiElement(def)('def')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(identifier)('foo')
|
||||
PsiElement(()('(')
|
||||
Parameter list
|
||||
Modifiers
|
||||
<empty list>
|
||||
Type element
|
||||
Reference element
|
||||
Reference element
|
||||
PsiElement(identifier)('A')
|
||||
PsiElement(.)('.')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(identifier)('b')
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiElement(,)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
Parameter
|
||||
Modifiers
|
||||
<empty list>
|
||||
Type element
|
||||
Reference element
|
||||
PsiElement(identifier)('A')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(identifier)('c')
|
||||
PsiElement())(')')
|
||||
PsiWhiteSpace(' ')
|
||||
Throw clause
|
||||
<empty list>
|
||||
Open block
|
||||
PsiElement({)('{')
|
||||
PsiElement(})('}')
|
||||
Reference in New Issue
Block a user