correcty index escaped identifiers

#KT-8846 Fixed
This commit is contained in:
Dmitry Jemerov
2015-08-21 16:58:15 +02:00
parent d9a854608b
commit 056d8dfd9f
5 changed files with 37 additions and 2 deletions
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.idea.search.usagesSearch.ALL_SEARCHABLE_OPERATIONS
import org.jetbrains.kotlin.kdoc.lexer.KDocTokens
import org.jetbrains.kotlin.lexer.JetLexer
import org.jetbrains.kotlin.lexer.JetTokens
import java.util.ArrayDeque
import java.util.*
val KOTLIN_NAMED_ARGUMENT_SEARCH_CONTEXT: Short = 0x20
@@ -66,6 +66,15 @@ class KotlinFilterLexer(private val occurrenceConsumer: OccurrenceConsumer): Bas
}
}
JetTokens.IDENTIFIER -> {
if (myDelegate.tokenText.startsWith("`")) {
scanWordsInToken(UsageSearchContext.IN_CODE.toInt(), false, false)
}
else {
addOccurrenceInToken(UsageSearchContext.IN_CODE.toInt())
}
}
in codeTokens -> addOccurrenceInToken(UsageSearchContext.IN_CODE.toInt())
in JetTokens.STRINGS -> scanWordsInToken(UsageSearchContext.IN_STRINGS + UsageSearchContext.IN_FOREIGN_LANGUAGES, false, true)
@@ -98,7 +107,7 @@ class KotlinFilterLexer(private val occurrenceConsumer: OccurrenceConsumer): Bas
class KotlinIdIndexer: LexerBasedIdIndexer() {
override fun createLexer(consumer: OccurrenceConsumer): Lexer = KotlinFilterLexer(consumer)
override fun getVersion() = 2
override fun getVersion() = 3
}
class KotlinTodoIndexer: LexerBasedTodoIndexer(), IdAndToDoScannerBasedOnFilterLexer {
@@ -0,0 +1,7 @@
package testing.rename
public open class C {
public fun second() = 1
public fun foo() = second()
}
@@ -0,0 +1,7 @@
package testing.rename
public open class C {
public fun `first`() = 1
public fun foo() = `first`()
}
@@ -0,0 +1,6 @@
{
"type": "KOTLIN_FUNCTION",
"classId": "testing/rename/C",
"oldName": "first",
"newName": "second"
}
@@ -281,6 +281,12 @@ public class RenameTestGenerated extends AbstractRenameTest {
doTest(fileName);
}
@TestMetadata("renameKotlinMethodWithEscapedName/renameKotlinMethodWithEscapedName.test")
public void testRenameKotlinMethodWithEscapedName_RenameKotlinMethodWithEscapedName() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/rename/renameKotlinMethodWithEscapedName/renameKotlinMethodWithEscapedName.test");
doTest(fileName);
}
@TestMetadata("renameKotlinPackage/renameInOtherFile.test")
public void testRenameKotlinPackage_RenameInOtherFile() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/rename/renameKotlinPackage/renameInOtherFile.test");