mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-223316 Name suggestions are not available when variable type is unresolved
GitOrigin-RevId: 20601bf806f770a4cf07c3a0a8c1d856f9c017fb
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fc82e319c3
commit
bb7a79b54a
+9
-1
@@ -106,7 +106,11 @@ public class JavaMemberNameCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
|
||||
PsiType type = var.getType();
|
||||
if (type instanceof PsiClassType && ((PsiClassType)type).resolve() == null) return;
|
||||
if (type instanceof PsiClassType &&
|
||||
((PsiClassType)type).resolve() == null &&
|
||||
seemsMistypedKeyword(((PsiClassType)type).getClassName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
SuggestedNameInfo suggestedNameInfo = codeStyleManager.suggestVariableName(variableKind, propertyName, null, type, StringUtil.isEmpty(matcher.getPrefix()));
|
||||
suggestedNameInfo = codeStyleManager.suggestUniqueVariableName(suggestedNameInfo, var, false);
|
||||
@@ -138,6 +142,10 @@ public class JavaMemberNameCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean seemsMistypedKeyword(String className) {
|
||||
return className != null && !StringUtil.isCapitalized(className);
|
||||
}
|
||||
|
||||
private static boolean hasStartMatches(PrefixMatcher matcher, Set<String> set) {
|
||||
for (String s : set) {
|
||||
if (matcher.isStartMatch(s)) {
|
||||
|
||||
+12
@@ -307,4 +307,16 @@ class C {
|
||||
assert myFixture.completeBasic()?.size() == 0
|
||||
}
|
||||
|
||||
void "test suggest variable name when the type is unresolved but does not seem a mistyped keyword"() {
|
||||
myFixture.configureByText 'a.java', '''
|
||||
class C {
|
||||
{
|
||||
UndefinedType <caret>
|
||||
}
|
||||
}
|
||||
'''
|
||||
myFixture.completeBasic()
|
||||
myFixture.assertPreferredCompletionItems 0, 'undefinedType', 'type'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user