mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 05:21:29 +07:00
java completion: don't suggest a variable name after a misspelled keyword (IDEA-215451)
GitOrigin-RevId: 2224a09bdaaee8026dc1ec97cb8884366a26abfd
This commit is contained in:
committed by
intellij-monorepo-bot
parent
16f141a0ec
commit
10ff3f3713
@@ -105,7 +105,9 @@ public class JavaMemberNameCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
}
|
||||
|
||||
final PsiType type = var.getType();
|
||||
PsiType type = var.getType();
|
||||
if (type instanceof PsiClassType && ((PsiClassType)type).resolve() == null) return;
|
||||
|
||||
SuggestedNameInfo suggestedNameInfo = codeStyleManager.suggestVariableName(variableKind, propertyName, null, type, StringUtil.isEmpty(matcher.getPrefix()));
|
||||
suggestedNameInfo = codeStyleManager.suggestUniqueVariableName(suggestedNameInfo, var, false);
|
||||
final String[] suggestedNames = suggestedNameInfo.names;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Foo {
|
||||
void test(Object o) {
|
||||
o <caret>
|
||||
o <caret>x
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
public class MyFirstTestClassFoo {
|
||||
public class Eee {
|
||||
|
||||
void foo(int a, Eee e<caret>){
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
public class MyFirstTestClassFoo {
|
||||
public class Eee {
|
||||
|
||||
void foo(int a, Eee eee<caret>){
|
||||
}
|
||||
|
||||
@@ -296,4 +296,15 @@ class FooFoo {
|
||||
myFixture.assertPreferredCompletionItems 0, 'materialQualities', 'materialQualities1', 'qualities', 'materialQualityIterable', 'qualityIterable', 'iterable'
|
||||
}
|
||||
|
||||
void "test no name suggestions when the type is unresolved because it is actually a mistyped keyword"() {
|
||||
myFixture.configureByText 'a.java', '''
|
||||
class C {
|
||||
{
|
||||
retur Fi<caret>x
|
||||
}
|
||||
}
|
||||
'''
|
||||
assert myFixture.completeBasic()?.size() == 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user