mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
IDEA-167285 Using "complete current statement" with code completion produces broken code
This commit is contained in:
@@ -886,7 +886,9 @@ public class JavaCompletionUtil {
|
||||
context.getDocument().insertString(offset, open);
|
||||
context.getEditor().getCaretModel().moveToOffset(offset + open.length());
|
||||
context.getDocument().insertString(offset + open.length(), escapeXmlIfNeeded(context, ">"));
|
||||
context.setAddCompletionChar(false);
|
||||
if (context.getCompletionChar() != Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
|
||||
context.setAddCompletionChar(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import java.util.*;
|
||||
|
||||
public class Util {
|
||||
int goo() {
|
||||
Map<Object, Object> m = new HasMa<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import java.util.*;
|
||||
|
||||
public class Util {
|
||||
int goo() {
|
||||
Map<Object, Object> m = new HashMap<>();<caret>
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.codeInsight.completion
|
||||
|
||||
import com.intellij.JavaTestUtil
|
||||
import com.intellij.openapi.actionSystem.IdeActions
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import org.jetbrains.annotations.NotNull
|
||||
|
||||
@@ -28,7 +29,7 @@ class Normal17CompletionTest extends LightFixtureCompletionTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return JAVA_LATEST
|
||||
return JAVA_1_7
|
||||
}
|
||||
|
||||
void testOnlyExceptionsInMultiCatch1() { doTest() }
|
||||
@@ -50,7 +51,7 @@ class Normal17CompletionTest extends LightFixtureCompletionTestCase {
|
||||
void testMethodReferenceCallContext() { doTest() }
|
||||
|
||||
void testResourceParentInResourceList() {
|
||||
configureByFile(getTestName(false) + ".java")
|
||||
configureByTestName()
|
||||
assert 'MyOuterResource' == myFixture.lookupElementStrings[0]
|
||||
assert 'MyClass' in myFixture.lookupElementStrings
|
||||
myFixture.type('C\n')
|
||||
@@ -58,14 +59,20 @@ class Normal17CompletionTest extends LightFixtureCompletionTestCase {
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
configureByFile(getTestName(false) + ".java")
|
||||
configureByTestName()
|
||||
myFixture.type('\n')
|
||||
checkResultByFile(getTestName(false) + "_after.java")
|
||||
}
|
||||
|
||||
void testAfterTryWithResources() {
|
||||
configureByFile(getTestName(false) + ".java")
|
||||
configureByTestName()
|
||||
def strings = myFixture.lookupElementStrings
|
||||
assert strings.containsAll(['final', 'finally', 'int', 'Util'])
|
||||
}
|
||||
|
||||
void testNewObjectHashMapWithSmartEnter() {
|
||||
configureByTestName()
|
||||
myFixture.performEditorAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_COMPLETE_STATEMENT)
|
||||
checkResultByFile(getTestName(false) + "_after.java")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user