mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[command-completion] IDEA-381534 Some fixes are unavailable after closed brackets
(cherry picked from commit 36e9573c3722ae6cfb0119059b579a4e523e109c) IJ-CR-180941 GitOrigin-RevId: aea8e6d4111a024157051510d58f038bafe4b5f2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
87c49a2389
commit
815ab749c5
+44
-4
@@ -11,6 +11,7 @@ import com.intellij.codeInsight.intention.preview.IntentionPreviewInfo
|
||||
import com.intellij.codeInsight.lookup.LookupElementPresentation
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl
|
||||
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection
|
||||
import com.intellij.codeInspection.streamMigration.StreamApiMigrationInspection
|
||||
import com.intellij.ide.highlighter.JavaFileType
|
||||
import com.intellij.openapi.actionSystem.IdeActions
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
@@ -26,6 +27,7 @@ import com.intellij.platform.backend.documentation.DocumentationData
|
||||
import com.intellij.psi.CommonClassNames.JAVA_LANG_CLASS
|
||||
import com.intellij.psi.JavaPsiFacade
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import com.intellij.testFramework.NeedsIndex
|
||||
import com.intellij.testFramework.replaceService
|
||||
import com.siyeh.ig.style.SizeReplaceableByIsEmptyInspection
|
||||
@@ -35,6 +37,10 @@ import javax.swing.JComponent
|
||||
@NeedsIndex.SmartMode(reason = "it requires highlighting")
|
||||
class JavaCommandsCompletionTest : LightFixtureCompletionTestCase() {
|
||||
|
||||
override fun getProjectDescriptor(): LightProjectDescriptor {
|
||||
return JAVA_21
|
||||
}
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
Registry.get("ide.completion.command.enabled").setValue(false, getTestRootDisposable())
|
||||
@@ -762,6 +768,40 @@ class JavaCommandsCompletionTest : LightFixtureCompletionTestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
fun testInspectionFromAnotherLine() {
|
||||
Registry.get("ide.completion.command.force.enabled").setValue(true, getTestRootDisposable())
|
||||
myFixture.enableInspections(StreamApiMigrationInspection())
|
||||
myFixture.configureByText(JavaFileType.INSTANCE, """
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Test {
|
||||
void main() throws IOException {
|
||||
var reader = new BufferedReader(new FileReader("input.txt"));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
}<caret>
|
||||
}
|
||||
}""".trimIndent())
|
||||
myFixture.doHighlighting()
|
||||
myFixture.type(".")
|
||||
val elements = myFixture.completeBasic()
|
||||
selectItem(elements.first { element -> element.lookupString.contains("Collapse loop with stream 'forEach()'", ignoreCase = true) })
|
||||
myFixture.checkResult("""
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Test {
|
||||
void main() throws IOException {
|
||||
var reader = new BufferedReader(new FileReader("input.txt"));
|
||||
reader.lines().forEach(System.out::println);
|
||||
}
|
||||
}""".trimIndent())
|
||||
}
|
||||
|
||||
fun testChangeSignature() {
|
||||
Registry.get("ide.completion.command.force.enabled").setValue(true, getTestRootDisposable())
|
||||
var text = """
|
||||
@@ -1079,7 +1119,7 @@ class JavaCommandsCompletionTest : LightFixtureCompletionTestCase() {
|
||||
|
||||
public class A {
|
||||
void foo() {
|
||||
ArrayList<String> strings = new ArrayList<String>();
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
""".trimIndent())
|
||||
@@ -1109,7 +1149,7 @@ class JavaCommandsCompletionTest : LightFixtureCompletionTestCase() {
|
||||
|
||||
public class A {
|
||||
void foo() {
|
||||
ArrayList<String> strings = new ArrayList<String>();
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
new ArrayList<String>(strings);
|
||||
}
|
||||
}
|
||||
@@ -1142,7 +1182,7 @@ class JavaCommandsCompletionTest : LightFixtureCompletionTestCase() {
|
||||
|
||||
public class A {
|
||||
void foo() {
|
||||
ArrayList<String> strings = new ArrayList<String>();
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
""".trimIndent())
|
||||
@@ -1173,7 +1213,7 @@ class JavaCommandsCompletionTest : LightFixtureCompletionTestCase() {
|
||||
|
||||
public class A {
|
||||
void foo() {
|
||||
ArrayList<String> strings = new ArrayList<String>();
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
""".trimIndent())
|
||||
|
||||
+1
-1
@@ -241,7 +241,7 @@ internal class DirectIntentionCommandProvider : CommandProvider {
|
||||
val profileToUse = getInstance(psiFile.project).getCurrentProfile()
|
||||
val inspectionWrapper = InspectionProfileWrapper(profileToUse)
|
||||
val inspectionTools = getInspectionTools(inspectionWrapper, originalFile)
|
||||
val lineRange = getLineRange(topLevelFile, topLevelOffset)
|
||||
val lineRange = getLineRange(topLevelFile, currentOffset)
|
||||
val indicator = EmptyProgressIndicator()
|
||||
val inspectionResult = jobToIndicator(coroutineContext.job, indicator) {
|
||||
if (!isInjected) {
|
||||
|
||||
Reference in New Issue
Block a user