mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] KTIJ-36297 always use expensive renderers in completion handler tests
Expensive renderers are used by the Kotlin plugin during completion to calculate expensive entities like shorten commands only on demand. Without using expensive expensive renderers, the tests do not truly reflect what will happen in real IDEA instances. GitOrigin-RevId: 416400de53757f27897464471af1af1e24da1313
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4252fbae15
commit
d075e210a3
@@ -5,4 +5,3 @@ fun test(): Int? {
|
||||
}
|
||||
|
||||
// ELEMENT: SortedSet
|
||||
// USE_EXPENSIVE_RENDERER
|
||||
|
||||
-1
@@ -7,4 +7,3 @@ fun test(): Int? {
|
||||
}
|
||||
|
||||
// ELEMENT: SortedSet
|
||||
// USE_EXPENSIVE_RENDERER
|
||||
|
||||
@@ -4,5 +4,4 @@
|
||||
|
||||
val test : <caret>
|
||||
|
||||
// ELEMENT: Int
|
||||
// USE_EXPENSIVE_RENDERER
|
||||
// ELEMENT: Int
|
||||
+1
-2
@@ -4,5 +4,4 @@
|
||||
|
||||
val test : Int
|
||||
|
||||
// ELEMENT: Int
|
||||
// USE_EXPENSIVE_RENDERER
|
||||
// ELEMENT: Int
|
||||
-2
@@ -78,7 +78,6 @@ abstract class AbstractCompletionHandlerTest(private val defaultCompletionType:
|
||||
val lookupString = InTextDirectivesUtils.findStringWithPrefixes(fileText, LOOKUP_STRING_PREFIX)
|
||||
val itemText = InTextDirectivesUtils.findStringWithPrefixes(fileText, ELEMENT_TEXT_PREFIX)
|
||||
val tailText = InTextDirectivesUtils.findStringWithPrefixes(fileText, TAIL_TEXT_PREFIX)
|
||||
val useExpensiveRenderer = InTextDirectivesUtils.isDirectiveDefined(fileText, USE_EXPENSIVE_RENDERER)
|
||||
val completionChars = completionChars(fileText)
|
||||
val typeAfterCompletion = InTextDirectivesUtils.findStringWithPrefixes(fileText, COMPLETION_TYPE_AFTER_COMPLETED_PREFIX)
|
||||
|
||||
@@ -114,7 +113,6 @@ abstract class AbstractCompletionHandlerTest(private val defaultCompletionType:
|
||||
completionChars,
|
||||
testFile.name + ".after",
|
||||
typeAfterCompletion = typeAfterCompletion,
|
||||
useExpensiveRenderer = useExpensiveRenderer
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+5
-9
@@ -27,7 +27,6 @@ abstract class CompletionHandlerTestBase : KotlinLightCodeInsightFixtureTestCase
|
||||
completionChars: String,
|
||||
afterFilePath: String,
|
||||
actions: List<String>? = emptyList(),
|
||||
useExpensiveRenderer: Boolean = false,
|
||||
typeAfterCompletion: String? = null,
|
||||
afterTypingBlock: () -> Unit = {}
|
||||
) {
|
||||
@@ -50,7 +49,7 @@ abstract class CompletionHandlerTestBase : KotlinLightCodeInsightFixtureTestCase
|
||||
}
|
||||
|
||||
if (lookupString != null || itemText != null || tailText != null) {
|
||||
val item = getExistentLookupElement(fixture.project, lookupString, itemText, tailText, useExpensiveRenderer)
|
||||
val item = getExistentLookupElement(fixture.project, lookupString, itemText, tailText)
|
||||
if (item != null) {
|
||||
selectItem(item, completionChars.last())
|
||||
}
|
||||
@@ -82,7 +81,6 @@ abstract class CompletionHandlerTestBase : KotlinLightCodeInsightFixtureTestCase
|
||||
lookupString: String?,
|
||||
itemText: String?,
|
||||
tailText: String?,
|
||||
useExpensiveRenderer: Boolean
|
||||
): LookupElement? {
|
||||
val lookup = LookupManager.getInstance(project)?.activeLookup as LookupImpl? ?: return null
|
||||
val items = lookup.items
|
||||
@@ -101,12 +99,10 @@ abstract class CompletionHandlerTestBase : KotlinLightCodeInsightFixtureTestCase
|
||||
if (lookupOk) {
|
||||
lookupElement.renderElement(presentation)
|
||||
|
||||
if (useExpensiveRenderer) {
|
||||
timeoutRunBlocking {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
(lookupElement.expensiveRenderer as? LookupElementRenderer<LookupElement>)
|
||||
?.renderElement(lookupElement, presentation)
|
||||
}
|
||||
timeoutRunBlocking {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
(lookupElement.expensiveRenderer as? LookupElementRenderer<LookupElement>)
|
||||
?.renderElement(lookupElement, presentation)
|
||||
}
|
||||
|
||||
val textOk = if (itemText != null) {
|
||||
|
||||
+3
-6
@@ -75,7 +75,6 @@ abstract class AbstractPerformanceCompletionHandlerTests(
|
||||
val lookupString = InTextDirectivesUtils.findStringWithPrefixes(fileText, LOOKUP_STRING_PREFIX)
|
||||
val itemText = InTextDirectivesUtils.findStringWithPrefixes(fileText, ELEMENT_TEXT_PREFIX)
|
||||
val tailText = InTextDirectivesUtils.findStringWithPrefixes(fileText, TAIL_TEXT_PREFIX)
|
||||
val useExpensiveRenderer = InTextDirectivesUtils.isDirectiveDefined(fileText, USE_EXPENSIVE_RENDERER)
|
||||
val completionChars = completionChars(fileText)
|
||||
|
||||
val completionType = ExpectedCompletionUtils.getCompletionType(fileText) ?: defaultCompletionType
|
||||
@@ -101,7 +100,7 @@ abstract class AbstractPerformanceCompletionHandlerTests(
|
||||
|
||||
doPerfTestWithTextLoaded(
|
||||
testPath, completionType, invocationCount, lookupString,
|
||||
itemText, tailText, completionChars, useExpensiveRenderer
|
||||
itemText, tailText, completionChars
|
||||
)
|
||||
}
|
||||
} finally {
|
||||
@@ -118,7 +117,6 @@ abstract class AbstractPerformanceCompletionHandlerTests(
|
||||
itemText: String?,
|
||||
tailText: String?,
|
||||
completionChars: String,
|
||||
useExpensiveRenderer: Boolean,
|
||||
) {
|
||||
performanceTest<Unit, Unit> {
|
||||
name(name())
|
||||
@@ -127,7 +125,7 @@ abstract class AbstractPerformanceCompletionHandlerTests(
|
||||
setUpFixture(testPath)
|
||||
}
|
||||
test {
|
||||
perfTestCore(completionType, time, lookupString, itemText, tailText, completionChars, useExpensiveRenderer)
|
||||
perfTestCore(completionType, time, lookupString, itemText, tailText, completionChars)
|
||||
}
|
||||
tearDown {
|
||||
runWriteAction {
|
||||
@@ -154,7 +152,6 @@ abstract class AbstractPerformanceCompletionHandlerTests(
|
||||
itemText: String?,
|
||||
tailText: String?,
|
||||
completionChars: String,
|
||||
useExpensiveRenderer: Boolean,
|
||||
) {
|
||||
completionChars.let {
|
||||
for (idx in 0 until it.length - 1) {
|
||||
@@ -165,7 +162,7 @@ abstract class AbstractPerformanceCompletionHandlerTests(
|
||||
fixture.complete(completionType, time)
|
||||
|
||||
if (lookupString != null || itemText != null || tailText != null) {
|
||||
val item = getExistentLookupElement(project, lookupString, itemText, tailText, useExpensiveRenderer)
|
||||
val item = getExistentLookupElement(project, lookupString, itemText, tailText)
|
||||
if (item != null) {
|
||||
selectItem(item, completionChars.last())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user