mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-22 08:31:31 +00:00
Fast search of assignment operations
This commit is contained in:
@@ -123,6 +123,11 @@ abstract class OperatorReferenceSearcher<TReferenceElement : KtElement>(
|
||||
return BinaryOperatorReferenceSearcher(declaration, operationTokens, searchScope, consumer, optimizer)
|
||||
}
|
||||
|
||||
val assignmentOp = OperatorConventions.ASSIGNMENT_OPERATIONS.inverse()[name]
|
||||
if (assignmentOp != null) {
|
||||
return BinaryOperatorReferenceSearcher(declaration, listOf(assignmentOp), searchScope, consumer, optimizer)
|
||||
}
|
||||
|
||||
val unaryOp = OperatorConventions.UNARY_OPERATION_NAMES.inverse()[name]
|
||||
if (unaryOp != null) {
|
||||
return UnaryOperatorReferenceSearcher(declaration, unaryOp, searchScope, consumer, optimizer)
|
||||
|
||||
@@ -59,8 +59,5 @@ fun Name.getOperationSymbolsToSearch(): Pair<Set<KtToken>, Class<*>>? {
|
||||
DelegatedPropertyResolver.PROPERTY_DELEGATED_FUNCTION_NAME -> return setOf(KtTokens.BY_KEYWORD) to KtPropertyDelegationMethodsReference::class.java
|
||||
}
|
||||
|
||||
val assignmentOp = ASSIGNMENT_OPERATIONS.inverse()[this]
|
||||
if (assignmentOp != null) return setOf(assignmentOp) to KtSimpleNameReference::class.java
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
8
idea/testData/findUsages/kotlin/conventions/plusAssign.log
vendored
Normal file
8
idea/testData/findUsages/kotlin/conventions/plusAssign.log
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
Checked type of a
|
||||
Resolved a += 1
|
||||
Resolved a += A(1)
|
||||
Searched references to A
|
||||
Searched references to a in Kotlin files
|
||||
Searched references to parameter a of A.plusAssign(a: A) in Kotlin files
|
||||
Used plain search of A.plusAssign(m: Int) in LocalSearchScope:
|
||||
CLASS:A
|
||||
Reference in New Issue
Block a user