mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
index only non-private static members; correct groovy second smart completion results
This commit is contained in:
@@ -157,9 +157,16 @@ public abstract class JavaMethodElementType extends JavaStubElementType<PsiMetho
|
||||
|
||||
public static boolean isJavaStaticMemberStub(StubElement<?> stub) {
|
||||
StubElement<PsiModifierList> type = stub.findChildStubByType(JavaStubElementTypes.MODIFIER_LIST);
|
||||
if (type instanceof PsiModifierListStub) {
|
||||
return ClsModifierListImpl.hasMaskModifierProperty(PsiModifier.STATIC, ((PsiModifierListStub)type).getModifiersMask());
|
||||
if (!(type instanceof PsiModifierListStub)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int mask = ((PsiModifierListStub)type).getModifiersMask();
|
||||
if (ClsModifierListImpl.hasMaskModifierProperty(PsiModifier.PRIVATE, mask) ||
|
||||
!ClsModifierListImpl.hasMaskModifierProperty(PsiModifier.STATIC, mask)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import java.io.IOException;
|
||||
* @author max
|
||||
*/
|
||||
public class JavaFileElementType extends ILightStubFileElementType<PsiJavaFileStub> {
|
||||
public static final int STUB_VERSION = 13;
|
||||
public static final int STUB_VERSION = 14;
|
||||
|
||||
public JavaFileElementType() {
|
||||
super("java.FILE", JavaLanguage.INSTANCE);
|
||||
|
||||
+5
-3
@@ -1,5 +1,3 @@
|
||||
import java.lang.Object;
|
||||
|
||||
class Super<T> {
|
||||
}
|
||||
|
||||
@@ -10,6 +8,10 @@ class SubInt extends Super<Integer> { }
|
||||
class SubGeneric<T> extends Super<T> { }
|
||||
class SubRaw extends Super { }
|
||||
|
||||
interface Constants {
|
||||
SubString SUBSTRING = null
|
||||
}
|
||||
|
||||
class Factory {
|
||||
public static Object createObject() {}
|
||||
public static <T> Super<T> createExpected() {}
|
||||
@@ -21,7 +23,7 @@ class Factory {
|
||||
|
||||
class Intermediate {
|
||||
|
||||
Super<String> s = create<caret>x
|
||||
Super<String> s = <caret>
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -206,7 +206,7 @@ public class SecondSmartTypeCompletionTest extends LightFixtureCompletionTestCas
|
||||
|
||||
public void testGlobalFactoryMethods() {
|
||||
configure();
|
||||
assertStringItems("createExpected", "createSubGeneric", "createSubRaw", "createSubString");
|
||||
assertStringItems("createExpected", "Constants.SUBSTRING", "createSubGeneric", "createSubRaw", "createSubString");
|
||||
}
|
||||
|
||||
public void testEmptyMapPresentation() {
|
||||
|
||||
+5
-6
@@ -17,11 +17,9 @@ package org.jetbrains.plugins.groovy.lang.completion;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionParameters;
|
||||
import com.intellij.codeInsight.completion.JavaCompletionUtil;
|
||||
import com.intellij.codeInsight.completion.SmartCompletionDecorator;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.psi.PsiClassType;
|
||||
import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.filters.getters.MembersGetter;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
@@ -55,7 +53,8 @@ class GroovyMembersGetter extends MembersGetter {
|
||||
|
||||
@Override
|
||||
protected LookupElement createMethodElement(PsiMethod method) {
|
||||
PsiType type = method.getReturnType();
|
||||
PsiSubstitutor substitutor = SmartCompletionDecorator.calculateMethodReturnTypeSubstitutor(method, myExpectedType);
|
||||
PsiType type = substitutor.substitute(method.getReturnType());
|
||||
if (!isSuitableType(type)) {
|
||||
return null;
|
||||
}
|
||||
@@ -64,6 +63,6 @@ class GroovyMembersGetter extends MembersGetter {
|
||||
}
|
||||
|
||||
private boolean isSuitableType(PsiType type) {
|
||||
return type != null && TypesUtil.isAssignable(myExpectedType, type, (GroovyPsiElement)myPlace.getParent());
|
||||
return type != null && TypesUtil.isAssignable(myExpectedType, type, (GroovyPsiElement)myPlace.getParent(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,11 +94,26 @@ public class GrStubUtils {
|
||||
}
|
||||
|
||||
public static boolean isGroovyStaticMemberStub(StubElement<?> stub) {
|
||||
StubElement<GrModifierList> type = stub.findChildStubByType(GroovyElementTypes.MODIFIERS);
|
||||
if (type instanceof GrModifierListStub) {
|
||||
return GrModifierListImpl.hasMaskExplicitModifier(PsiModifier.STATIC, ((GrModifierListStub)type).getModifiersFlags());
|
||||
StubElement<?> modifierOwner = stub instanceof GrMethodStub ? stub : stub.getParentStub();
|
||||
StubElement<GrModifierList> type = modifierOwner.findChildStubByType(GroovyElementTypes.MODIFIERS);
|
||||
if (!(type instanceof GrModifierListStub)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
int mask = ((GrModifierListStub)type).getModifiersFlags();
|
||||
if (GrModifierListImpl.hasMaskExplicitModifier(PsiModifier.PRIVATE, mask)) {
|
||||
return false;
|
||||
}
|
||||
if (GrModifierListImpl.hasMaskExplicitModifier(PsiModifier.STATIC, mask)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
StubElement parent = modifierOwner.getParentStub();
|
||||
StubElement classStub = parent == null ? null : parent.getParentStub();
|
||||
if (classStub instanceof GrTypeDefinitionStub &&
|
||||
(((GrTypeDefinitionStub)classStub).isAnnotationType() || ((GrTypeDefinitionStub)classStub).isInterface())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+12
@@ -87,6 +87,18 @@ public class GroovySmartCompletionTest extends GroovyCompletionTestBase {
|
||||
checkResult()
|
||||
}
|
||||
|
||||
public void testGlobalStaticMembers() {
|
||||
myFixture.configureByFile(getTestName(false) + ".groovy");
|
||||
myFixture.complete(CompletionType.SMART, 2);
|
||||
assertOrderedEquals(myFixture.lookupElementStrings, 'SUBSTRING', 'createExpected', 'createSubGeneric', 'SUB_RAW')
|
||||
}
|
||||
|
||||
public void testGlobalListCreators() {
|
||||
myFixture.configureByFile(getTestName(false) + ".groovy");
|
||||
myFixture.complete(CompletionType.SMART, 2);
|
||||
assertOrderedEquals(myFixture.lookupElementStrings, 'createGenericList', 'createStringList')
|
||||
}
|
||||
|
||||
void testNativeList() {doSmartCompletion('a1', 'a2')};
|
||||
|
||||
public void testMembersImportStatically() {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
class Factory {
|
||||
public static <T> List<T> createGenericList() {}
|
||||
public static List<Integer> createIntList() {}
|
||||
public static List<String> createStringList() {}
|
||||
}
|
||||
|
||||
class Intermediate {
|
||||
|
||||
List<String> s = create<caret>
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
class Super<T> { }
|
||||
class SubString extends Super<String> { }
|
||||
class SubInt extends Super<Integer> { }
|
||||
class SubGeneric<T> extends Super<T> { }
|
||||
class SubRaw extends Super { }
|
||||
|
||||
interface Constants {
|
||||
SubString SUBSTRING = null
|
||||
}
|
||||
|
||||
class Factory {
|
||||
public static Object createObject() {}
|
||||
public static <T> Super<T> createExpected() {}
|
||||
public static Super<Integer> createSuperInt() {}
|
||||
public static SubInt createSubInt() {}
|
||||
public static <T> SubGeneric<T> createSubGeneric() {}
|
||||
public static final SubRaw SUB_RAW = null
|
||||
public static Super<String> NON_FINAL
|
||||
public final Super<String> NON_STATIC
|
||||
}
|
||||
|
||||
class Intermediate {
|
||||
|
||||
Super<String> s = <caret>
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user