Fast search of assignment operations

This commit is contained in:
Valentin Kipyatkov
2016-09-02 15:34:16 +03:00
parent cdf328475e
commit eeea85c86a
3 changed files with 13 additions and 3 deletions

View File

@@ -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)

View File

@@ -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
}

View 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