mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-completion] IDEA-269952 Code completion results in invalid code
GitOrigin-RevId: 5cc2df6d2be5315d0520d44d766a89c45b9e974d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0be177e19e
commit
090b19388c
@@ -815,6 +815,9 @@ public final class JavaCompletionUtil {
|
||||
private static boolean insertTail(InsertionContext context, LookupElement item, TailType tailType, boolean hasTail) {
|
||||
TailType toInsert = tailType;
|
||||
LookupItem<?> lookupItem = item.as(LookupItem.CLASS_CONDITION_KEY);
|
||||
if (toInsert == EqTailType.INSTANCE) {
|
||||
toInsert = TailType.UNKNOWN;
|
||||
}
|
||||
if (lookupItem == null || lookupItem.getAttribute(LookupItem.TAIL_TYPE_ATTR) != TailType.UNKNOWN) {
|
||||
if (!hasTail && item.getObject() instanceof PsiMethod && PsiType.VOID.equals(((PsiMethod)item.getObject()).getReturnType())) {
|
||||
PsiDocumentManager.getInstance(context.getProject()).commitAllDocuments();
|
||||
|
||||
+67
@@ -218,6 +218,7 @@ class NormalCompletionTest extends NormalCompletionTestCase {
|
||||
protected void tearDown() throws Exception {
|
||||
CodeInsightSettings.instance.AUTOCOMPLETE_ON_CODE_COMPLETION = true
|
||||
CodeInsightSettings.instance.setCompletionCaseSensitive(CodeInsightSettings.FIRST_LETTER)
|
||||
CodeInsightSettings.instance.setSelectAutopopupSuggestionsByChars(false)
|
||||
CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET = true
|
||||
super.tearDown()
|
||||
}
|
||||
@@ -2443,4 +2444,70 @@ class Abc {
|
||||
myFixture.completeBasic()
|
||||
assert myFixture.getLookupElementStrings() == ["demoEntity", "demo", "entity"]
|
||||
}
|
||||
|
||||
@NeedsIndex.Full
|
||||
void testCompleteByEqualsAssignment() {
|
||||
CodeInsightSettings.instance.setSelectAutopopupSuggestionsByChars(true)
|
||||
myFixture.configureByText("Test.java", "public class Test {\n" +
|
||||
" public static void main(final String[] args) {\n" +
|
||||
" Test test = new Test();\n" +
|
||||
" Test test2 = new Test();\n" +
|
||||
" tes<caret>\n" +
|
||||
" }\n" +
|
||||
"}")
|
||||
myFixture.completeBasic()
|
||||
myFixture.type('=')
|
||||
myFixture.checkResult("public class Test {\n" +
|
||||
" public static void main(final String[] args) {\n" +
|
||||
" Test test = new Test();\n" +
|
||||
" Test test2 = new Test();\n" +
|
||||
" test = <caret>\n" +
|
||||
" }\n" +
|
||||
"}")
|
||||
}
|
||||
|
||||
@NeedsIndex.Full
|
||||
void testCompleteByEqualsDeclaration() {
|
||||
CodeInsightSettings.instance.setSelectAutopopupSuggestionsByChars(true)
|
||||
CodeInsightSettings.instance.AUTOCOMPLETE_ON_CODE_COMPLETION = false
|
||||
myFixture.configureByText("Test.java", "public class Test {\n" +
|
||||
" public static void main(final String[] args) {\n" +
|
||||
" String str<caret>\n" +
|
||||
" }\n" +
|
||||
"}")
|
||||
myFixture.completeBasic()
|
||||
myFixture.type('=')
|
||||
myFixture.checkResult("public class Test {\n" +
|
||||
" public static void main(final String[] args) {\n" +
|
||||
" String string = <caret>\n" +
|
||||
" }\n" +
|
||||
"}")
|
||||
}
|
||||
|
||||
@NeedsIndex.Full
|
||||
void testCompleteByEquals() {
|
||||
CodeInsightSettings.instance.setSelectAutopopupSuggestionsByChars(true)
|
||||
myFixture.configureByText("Test.java", "public class Test {\n" +
|
||||
" public static void main(final String[] args) {\n" +
|
||||
" final Test test = new Test();\n" +
|
||||
" if (test.get<caret>)\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" public String getFoo() {\n" +
|
||||
" return \"\";\n" +
|
||||
" }\n" +
|
||||
"}")
|
||||
myFixture.completeBasic()
|
||||
myFixture.type('=')
|
||||
myFixture.checkResult("public class Test {\n" +
|
||||
" public static void main(final String[] args) {\n" +
|
||||
" final Test test = new Test();\n" +
|
||||
" if (test.getFoo()=)\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" public String getFoo() {\n" +
|
||||
" return \"\";\n" +
|
||||
" }\n" +
|
||||
"}")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user