Do not invalidate package caches on generic events, KT-25264
This commit is contained in:
+5
@@ -0,0 +1,5 @@
|
||||
package org.jetbrains.annotations
|
||||
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@Target(AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.FIELD)
|
||||
public annotation class PropertyKey(public val resourceBundle: String)
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
foobar = 0
|
||||
foo.bar = 1
|
||||
bar.baz = 2
|
||||
@@ -0,0 +1,10 @@
|
||||
import org.jetbrains.annotations.PropertyKey
|
||||
|
||||
fun message(@PropertyKey(resourceBundle = "MessageBundle1.dependency") key: String) = key
|
||||
|
||||
fun test() {
|
||||
message("<caret>")
|
||||
}
|
||||
|
||||
// ELEMENT: foo.bar
|
||||
// CHARS: 'foo\n'
|
||||
@@ -0,0 +1,10 @@
|
||||
import org.jetbrains.annotations.PropertyKey
|
||||
|
||||
fun message(@PropertyKey(resourceBundle = "MessageBundle1.dependency") key: String) = key
|
||||
|
||||
fun test() {
|
||||
message("foo.bar")
|
||||
}
|
||||
|
||||
// ELEMENT: foo.bar
|
||||
// CHARS: 'foo\n'
|
||||
+14
-7
@@ -24,6 +24,7 @@ abstract class AbstractCompletionHandlerTest(private val defaultCompletionType:
|
||||
private val ELEMENT_TEXT_PREFIX = "ELEMENT_TEXT:"
|
||||
private val TAIL_TEXT_PREFIX = "TAIL_TEXT:"
|
||||
private val COMPLETION_CHAR_PREFIX = "CHAR:"
|
||||
private val COMPLETION_CHARS_PREFIX = "CHARS:"
|
||||
private val CODE_STYLE_SETTING_PREFIX = "CODE_STYLE_SETTING:"
|
||||
|
||||
protected open fun doTest(testPath: String) {
|
||||
@@ -42,12 +43,10 @@ abstract class AbstractCompletionHandlerTest(private val defaultCompletionType:
|
||||
val itemText = InTextDirectivesUtils.findStringWithPrefixes(fileText, ELEMENT_TEXT_PREFIX)
|
||||
val tailText = InTextDirectivesUtils.findStringWithPrefixes(fileText, TAIL_TEXT_PREFIX)
|
||||
|
||||
val completionCharString = InTextDirectivesUtils.findStringWithPrefixes(fileText, COMPLETION_CHAR_PREFIX)
|
||||
val completionChar = when(completionCharString) {
|
||||
"\\n", null -> '\n'
|
||||
"\\t" -> '\t'
|
||||
else -> completionCharString.singleOrNull() ?: error("Incorrect completion char: \"$completionCharString\"")
|
||||
}
|
||||
val completionChars = completionChars(
|
||||
char = InTextDirectivesUtils.findStringWithPrefixes(fileText, COMPLETION_CHAR_PREFIX),
|
||||
chars = InTextDirectivesUtils.findStringWithPrefixes(fileText, COMPLETION_CHARS_PREFIX)
|
||||
)
|
||||
|
||||
val completionType = ExpectedCompletionUtils.getCompletionType(fileText) ?: defaultCompletionType
|
||||
|
||||
@@ -70,7 +69,15 @@ abstract class AbstractCompletionHandlerTest(private val defaultCompletionType:
|
||||
}
|
||||
}
|
||||
|
||||
doTestWithTextLoaded(completionType, invocationCount, lookupString, itemText, tailText, completionChar, File(testPath).name + ".after")
|
||||
doTestWithTextLoaded(
|
||||
completionType,
|
||||
invocationCount,
|
||||
lookupString,
|
||||
itemText,
|
||||
tailText,
|
||||
completionChars,
|
||||
File(testPath).name + ".after"
|
||||
)
|
||||
} finally {
|
||||
if (configured) {
|
||||
rollbackCompilerOptions(project, module)
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ class BasicCompletionHandlerTest : CompletionHandlerTestBase(){
|
||||
|
||||
private fun doTest(time: Int, lookupString: String?, itemText: String?, tailText: String?, completionChar: Char) {
|
||||
fixture.configureByFile(fileName())
|
||||
doTestWithTextLoaded(CompletionType.BASIC, time, lookupString, itemText, tailText, completionChar, fileName() + ".after")
|
||||
doTestWithTextLoaded(CompletionType.BASIC, time, lookupString, itemText, tailText, completionChar.toString(), fileName() + ".after")
|
||||
}
|
||||
|
||||
fun testClassCompletionImport() = doTest(2, "SortedSet", null, '\n')
|
||||
|
||||
+6
-1
@@ -26,7 +26,7 @@ public class CompletionCharFilterTestGenerated extends AbstractCompletionCharFil
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInCharFilter() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/handlers/charFilter"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/handlers/charFilter"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("Colon.kt")
|
||||
@@ -144,6 +144,11 @@ public class CompletionCharFilterTestGenerated extends AbstractCompletionCharFil
|
||||
runTest("idea/idea-completion/testData/handlers/charFilter/LParenth.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("MessageBundle1.kt")
|
||||
public void testMessageBundle1() throws Exception {
|
||||
runTest("idea/idea-completion/testData/handlers/charFilter/MessageBundle1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NamedParameter1.kt")
|
||||
public void testNamedParameter1() throws Exception {
|
||||
runTest("idea/idea-completion/testData/handlers/charFilter/NamedParameter1.kt");
|
||||
|
||||
+23
-9
@@ -20,26 +20,40 @@ abstract class CompletionHandlerTestBase() : KotlinLightCodeInsightFixtureTestCa
|
||||
get() = myFixture
|
||||
|
||||
protected fun doTestWithTextLoaded(
|
||||
completionType: CompletionType,
|
||||
time: Int,
|
||||
lookupString: String?,
|
||||
itemText: String?,
|
||||
tailText: String?,
|
||||
completionChar: Char,
|
||||
afterFilePath: String
|
||||
completionType: CompletionType,
|
||||
time: Int,
|
||||
lookupString: String?,
|
||||
itemText: String?,
|
||||
tailText: String?,
|
||||
completionChars: String,
|
||||
afterFilePath: String
|
||||
) {
|
||||
for (idx in 0 until completionChars.length - 1) {
|
||||
fixture.type(completionChars[idx])
|
||||
}
|
||||
|
||||
fixture.complete(completionType, time)
|
||||
|
||||
if (lookupString != null || itemText != null || tailText != null) {
|
||||
val item = getExistentLookupElement(lookupString, itemText, tailText)
|
||||
if (item != null) {
|
||||
selectItem(item, completionChar)
|
||||
selectItem(item, completionChars.last())
|
||||
}
|
||||
}
|
||||
|
||||
fixture.checkResultByFile(afterFilePath)
|
||||
}
|
||||
|
||||
protected fun completionChars(char: String?, chars: String?): String =
|
||||
when (char) {
|
||||
null -> when (chars) {
|
||||
null -> "\n"
|
||||
else -> chars.replace("\\n", "\n").replace("\\t", "\t")
|
||||
}
|
||||
"\\n" -> "\n"
|
||||
"\\t" -> "\t"
|
||||
else -> char.single().toString() ?: error("Incorrect completion char: \"$char\"")
|
||||
}
|
||||
|
||||
protected fun getExistentLookupElement(lookupString: String?, itemText: String?, tailText: String?): LookupElement? {
|
||||
val lookup = LookupManager.getInstance(project)?.activeLookup as LookupImpl? ?: return null
|
||||
val items = lookup.items
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ fun CodeInsightTestFixture.configureWithExtraFile(path: String, vararg extraName
|
||||
val fileName = File(path).name
|
||||
|
||||
val noExtensionPath = FileUtil.getNameWithoutExtension(fileName)
|
||||
val extensions = arrayOf("kt", "java")
|
||||
val extensions = arrayOf("kt", "java", "properties")
|
||||
val extraPaths: List<String> = extraNameParts
|
||||
.flatMap { extensions.map { ext -> "$noExtensionPath$it.$ext" } }
|
||||
.mapNotNull { File(testDataPath, it).takeIf { it.exists() }?.name }
|
||||
|
||||
Reference in New Issue
Block a user