Find Usages: Disable by-convention search of invoke(). Improve scanner
accuracy when indexing possible references to component functions
This commit is contained in:
@@ -41,10 +41,11 @@ class KotlinWordsScanner() : WordsScanner {
|
|||||||
lexer.start(fileText)
|
lexer.start(fileText)
|
||||||
|
|
||||||
val occurrence = WordOccurrence(null, 0, 0, null)
|
val occurrence = WordOccurrence(null, 0, 0, null)
|
||||||
|
var valOrVarBefore: Boolean = false
|
||||||
|
|
||||||
stream { lexer.getTokenType() }.forEach { elementType ->
|
stream { lexer.getTokenType() }.forEach { elementType ->
|
||||||
// todo: replace with when
|
// todo: replace with when
|
||||||
if (ALL_SEARCHABLE_OPERATIONS.contains(elementType)) {
|
if (ALL_SEARCHABLE_OPERATIONS.contains(elementType) || (valOrVarBefore && elementType == JetTokens.LPAR)) {
|
||||||
occurrence.init(lexer.getBufferSequence(), lexer.getTokenStart(), lexer.getTokenEnd(), WordOccurrence.Kind.CODE)
|
occurrence.init(lexer.getBufferSequence(), lexer.getTokenStart(), lexer.getTokenEnd(), WordOccurrence.Kind.CODE)
|
||||||
processor.process(occurrence)
|
processor.process(occurrence)
|
||||||
}
|
}
|
||||||
@@ -52,6 +53,10 @@ class KotlinWordsScanner() : WordsScanner {
|
|||||||
else if (JetTokens.STRINGS.contains(elementType)) scanWords(WordOccurrence.Kind.LITERALS, processor)
|
else if (JetTokens.STRINGS.contains(elementType)) scanWords(WordOccurrence.Kind.LITERALS, processor)
|
||||||
else scanWords(WordOccurrence.Kind.CODE, processor)
|
else scanWords(WordOccurrence.Kind.CODE, processor)
|
||||||
|
|
||||||
|
if (elementType !in JetTokens.WHITE_SPACE_OR_COMMENT_BIT_SET) {
|
||||||
|
valOrVarBefore = elementType == JetTokens.VAL_KEYWORD || elementType == JetTokens.VAR_KEYWORD
|
||||||
|
}
|
||||||
|
|
||||||
lexer.advance()
|
lexer.advance()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ public fun Name.getOperationSymbolsToSearch(): Set<JetToken> {
|
|||||||
EQUALS -> return EQUALS_OPERATIONS
|
EQUALS -> return EQUALS_OPERATIONS
|
||||||
IDENTITY_EQUALS -> return IDENTITY_EQUALS_OPERATIONS
|
IDENTITY_EQUALS -> return IDENTITY_EQUALS_OPERATIONS
|
||||||
CONTAINS -> return IN_OPERATIONS_TO_SEARCH
|
CONTAINS -> return IN_OPERATIONS_TO_SEARCH
|
||||||
INVOKE_OPERATION_NAME -> return ImmutableSet.of<JetToken>(JetTokens.LPAR)
|
|
||||||
ITERATOR_OPERATION_NAME -> return ImmutableSet.of<JetToken>(JetTokens.IN_KEYWORD)
|
ITERATOR_OPERATION_NAME -> return ImmutableSet.of<JetToken>(JetTokens.IN_KEYWORD)
|
||||||
in INDEXING_OPERATION_NAMES -> return ImmutableSet.of<JetToken>(JetTokens.LBRACKET)
|
in INDEXING_OPERATION_NAMES -> return ImmutableSet.of<JetToken>(JetTokens.LBRACKET)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
Function call (9: 10) B(1).invoke(2)
|
Function call (9: 10) B(1).invoke(2)
|
||||||
Implicit 'invoke' (10: 5) B(1)(2)
|
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ class A(val n: Int) {
|
|||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
A(1).foo(2)
|
A(1).foo(2)
|
||||||
A(1).foo(2)
|
A(1)(2)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user