mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-106104 Groovy: complete 'class', 'enum' etc in the following case
This commit is contained in:
+31
-1
@@ -400,6 +400,21 @@ public class GroovyCompletionData {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@Anno
|
||||
cl<caret>
|
||||
*/
|
||||
if (parent instanceof GrVariable && context == ((GrVariable)parent).getNameIdentifierGroovy()) {
|
||||
final PsiElement decl = parent.getParent();
|
||||
if (decl instanceof GrVariableDeclaration &&
|
||||
!((GrVariableDeclaration)decl).isTuple() &&
|
||||
((GrVariableDeclaration)decl).getTypeElementGroovy() == null &&
|
||||
(decl.getParent() instanceof GrTypeDefinitionBody || decl.getParent() instanceof GroovyFile)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
final PsiElement leaf = getLeafByOffset(context.getTextRange().getStartOffset() - 1, context);
|
||||
if (leaf != null) {
|
||||
PsiElement prev = leaf;
|
||||
@@ -589,7 +604,8 @@ public class GroovyCompletionData {
|
||||
}
|
||||
if (asSimpleVariable(context) ||
|
||||
asTypedMethod(context) ||
|
||||
asVariableInBlock(context)) {
|
||||
asVariableInBlock(context) ||
|
||||
asVariableAfterModifiers(context)) {
|
||||
return true;
|
||||
}
|
||||
if ((parent instanceof GrParameter &&
|
||||
@@ -617,6 +633,20 @@ public class GroovyCompletionData {
|
||||
isNewStatement(context, false);
|
||||
}
|
||||
|
||||
private static boolean asVariableAfterModifiers(PsiElement context) {
|
||||
final PsiElement parent = context.getParent();
|
||||
if (parent instanceof GrVariable && context == ((GrVariable)parent).getNameIdentifierGroovy()) {
|
||||
final PsiElement decl = parent.getParent();
|
||||
if (decl instanceof GrVariableDeclaration &&
|
||||
!((GrVariableDeclaration)decl).isTuple() &&
|
||||
((GrVariableDeclaration)decl).getTypeElementGroovy() == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isInfixOperatorPosition(PsiElement context) {
|
||||
if (context.getParent() != null &&
|
||||
context.getParent() instanceof GrReferenceExpression &&
|
||||
|
||||
+2
@@ -102,6 +102,8 @@ public class KeywordCompletionTest extends CompletionTestBase {
|
||||
void testDefaultInAnnotation() { doTest() }
|
||||
void testElse1() { doTest() }
|
||||
void testElse2() { doTest() }
|
||||
void testClassAfterAnnotation(){ doTest() }
|
||||
void testClassAfterAnno2() { doTest() }
|
||||
|
||||
String basePath = TestUtils.testDataPath + 'groovy/oldCompletion/keyword'
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
@Anno
|
||||
public <caret>
|
||||
-----
|
||||
abstract
|
||||
boolean
|
||||
byte
|
||||
char
|
||||
class
|
||||
def
|
||||
double
|
||||
enum
|
||||
final
|
||||
float
|
||||
int
|
||||
interface
|
||||
long
|
||||
native
|
||||
short
|
||||
static
|
||||
strictfp
|
||||
synchronized
|
||||
transient
|
||||
void
|
||||
volatile
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
@Anno
|
||||
<caret>
|
||||
-----
|
||||
abstract
|
||||
boolean
|
||||
byte
|
||||
char
|
||||
class
|
||||
double
|
||||
enum
|
||||
final
|
||||
float
|
||||
if
|
||||
int
|
||||
interface
|
||||
long
|
||||
native
|
||||
private
|
||||
protected
|
||||
public
|
||||
short
|
||||
static
|
||||
strictfp
|
||||
synchronized
|
||||
transient
|
||||
void
|
||||
volatile
|
||||
Reference in New Issue
Block a user