mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] geb: fix type string in completion for field based page content
https://github.com/JetBrains/intellij-community/pull/779
This commit is contained in:
committed by
Daniil Ovchinnikov
parent
6ec33c4986
commit
58e816a402
@@ -114,8 +114,10 @@ public class GebUtil {
|
||||
GrLightField field = new GrLightField(pageOrModuleClass, name, objectType, invokedExpression) {
|
||||
|
||||
@Override
|
||||
public PsiType getTypeGroovy() {
|
||||
return block.getReturnType();
|
||||
@NotNull
|
||||
public PsiType getType() {
|
||||
PsiType type = block.getReturnType();
|
||||
return type != null ? type : super.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -95,6 +95,24 @@ class PageWithContent extends geb.Page {
|
||||
TestUtils.checkCompletionContains(myFixture, "button", "formField()")
|
||||
}
|
||||
|
||||
void testContentElementsCompletionType() {
|
||||
myFixture.configureByText("PageWithContent.groovy", """
|
||||
class PageWithContent extends geb.Page {
|
||||
static content = {
|
||||
button { \$('button') }
|
||||
formField { String name -> \$('input', name: name) }
|
||||
}
|
||||
|
||||
def someMethod() {
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
""")
|
||||
|
||||
TestUtils.checkCompletionType(myFixture, "button", "geb.navigator.Navigator")
|
||||
TestUtils.checkCompletionType(myFixture, "formField", "geb.navigator.Navigator")
|
||||
}
|
||||
|
||||
void testContentMethodReturnType() {
|
||||
myFixture.configureByText("PageWithContent.groovy", """
|
||||
class PageWithContent extends geb.Page {
|
||||
|
||||
@@ -215,6 +215,31 @@ public abstract class TestUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkCompletionType(JavaCodeInsightTestFixture fixture, String lookupString, String expectedTypeCanonicalText) {
|
||||
LookupElement[] lookupElements = fixture.completeBasic();
|
||||
PsiType type = null;
|
||||
|
||||
for (LookupElement lookupElement : lookupElements) {
|
||||
if (lookupElement.getLookupString().equals(lookupString)) {
|
||||
PsiElement element = lookupElement.getPsiElement();
|
||||
if (element instanceof PsiField) {
|
||||
type = ((PsiField)element).getType();
|
||||
break;
|
||||
}
|
||||
if (element instanceof PsiMethod) {
|
||||
type = ((PsiMethod)element).getReturnType();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
Assert.fail("No field or method called '" + lookupString + "' found in completion lookup elements");
|
||||
}
|
||||
|
||||
Assert.assertEquals(expectedTypeCanonicalText, type.getCanonicalText());
|
||||
}
|
||||
|
||||
public static void checkResolve(PsiFile file, final String ... expectedUnresolved) {
|
||||
final List<String> actualUnresolved = new ArrayList<>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user