mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-91465 inappropriate autocompletion of 'def' to NoClassDefFoundError after block labels in Spock specifications
This commit is contained in:
+2
-1
@@ -405,7 +405,7 @@ public class GroovyCompletionData {
|
||||
}
|
||||
if (GroovyCompletionUtil.isNewStatement(context, true)) {
|
||||
final PsiElement leaf = GroovyCompletionUtil.getLeafByOffset(offset - 1, context);
|
||||
if (leaf != null && leaf.getParent() instanceof GrStatementOwner) {
|
||||
if (leaf != null && (leaf.getParent() instanceof GrStatementOwner || leaf.getParent() instanceof GrLabeledStatement)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -429,6 +429,7 @@ public class GroovyCompletionData {
|
||||
}
|
||||
|
||||
if (superParent instanceof GrStatementOwner ||
|
||||
superParent instanceof GrLabeledStatement ||
|
||||
superParent instanceof GrIfStatement ||
|
||||
superParent instanceof GrForStatement ||
|
||||
superParent instanceof GrWhileStatement) {
|
||||
|
||||
+10
-3
@@ -53,6 +53,7 @@ import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrLabeledStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
|
||||
@@ -140,8 +141,13 @@ public class GroovyCompletionUtil {
|
||||
public static boolean isNewStatement(PsiElement element, boolean canBeAfterBrace) {
|
||||
PsiElement previousLeaf = getLeafByOffset(element.getTextRange().getStartOffset() - 1, element);
|
||||
previousLeaf = PsiImplUtil.realPrevious(previousLeaf);
|
||||
if (previousLeaf != null && canBeAfterBrace && mLCURLY.equals(previousLeaf.getNode().getElementType())) {
|
||||
return true;
|
||||
if (previousLeaf != null) {
|
||||
if (canBeAfterBrace && mLCURLY.equals(previousLeaf.getNode().getElementType())) {
|
||||
return true;
|
||||
}
|
||||
if (mCOLON.equals(previousLeaf.getNode().getElementType()) && previousLeaf.getParent() instanceof GrLabeledStatement) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return (previousLeaf == null || SEPARATORS.contains(previousLeaf.getNode().getElementType()));
|
||||
}
|
||||
@@ -206,7 +212,8 @@ public class GroovyCompletionUtil {
|
||||
if (parent instanceof GrApplicationStatement) {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
if ((parent instanceof GrCodeBlock || parent instanceof GrCaseSection) && isNewStatement(context, true)) {
|
||||
if ((parent instanceof GrCodeBlock || parent instanceof GrCaseSection || parent instanceof GrLabeledStatement) &&
|
||||
isNewStatement(context, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -93,6 +93,7 @@ public class KeywordCompletionTest extends CompletionTestBase {
|
||||
void testAssert() { doTest() }
|
||||
void testReturn() { doTest() }
|
||||
void testAssertInClosure() { doTest() }
|
||||
void testAfterLabel() { doTest() }
|
||||
|
||||
String basePath = TestUtils.testDataPath + 'groovy/oldCompletion/keyword'
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
foo: <caret>
|
||||
-----
|
||||
as
|
||||
assert
|
||||
boolean
|
||||
byte
|
||||
char
|
||||
def
|
||||
double
|
||||
false
|
||||
final
|
||||
float
|
||||
for
|
||||
int
|
||||
long
|
||||
new
|
||||
null
|
||||
return
|
||||
short
|
||||
super
|
||||
switch
|
||||
synchronized
|
||||
this
|
||||
throw
|
||||
true
|
||||
try
|
||||
void
|
||||
while
|
||||
Reference in New Issue
Block a user