Reformat UnusedReceiverParameterInspection
This commit is contained in:
committed by
Nikolay Krasko
parent
68dbeeac7a
commit
d32b53362d
+10
-7
@@ -59,7 +59,8 @@ class UnusedReceiverParameterInspection : AbstractKotlinInspection() {
|
|||||||
if (callableDeclaration.isOverridable() ||
|
if (callableDeclaration.isOverridable() ||
|
||||||
callableDeclaration.hasModifier(KtTokens.OVERRIDE_KEYWORD) ||
|
callableDeclaration.hasModifier(KtTokens.OVERRIDE_KEYWORD) ||
|
||||||
callableDeclaration.hasModifier(KtTokens.OPERATOR_KEYWORD) ||
|
callableDeclaration.hasModifier(KtTokens.OPERATOR_KEYWORD) ||
|
||||||
callableDeclaration.hasModifier(KtTokens.INFIX_KEYWORD)) return
|
callableDeclaration.hasModifier(KtTokens.INFIX_KEYWORD)
|
||||||
|
) return
|
||||||
|
|
||||||
if (callableDeclaration is KtProperty && callableDeclaration.accessors.isEmpty()) return
|
if (callableDeclaration is KtProperty && callableDeclaration.accessors.isEmpty()) return
|
||||||
if (callableDeclaration is KtNamedFunction && !callableDeclaration.hasBody()) return
|
if (callableDeclaration is KtNamedFunction && !callableDeclaration.hasBody()) return
|
||||||
@@ -80,7 +81,8 @@ class UnusedReceiverParameterInspection : AbstractKotlinInspection() {
|
|||||||
if (isUsageOfReceiver(resolvedCall, bindingContext)) {
|
if (isUsageOfReceiver(resolvedCall, bindingContext)) {
|
||||||
used = true
|
used = true
|
||||||
} else if (resolvedCall is VariableAsFunctionResolvedCall
|
} else if (resolvedCall is VariableAsFunctionResolvedCall
|
||||||
&& isUsageOfReceiver(resolvedCall.variableCall, bindingContext)) {
|
&& isUsageOfReceiver(resolvedCall.variableCall, bindingContext)
|
||||||
|
) {
|
||||||
used = true
|
used = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,7 +90,8 @@ class UnusedReceiverParameterInspection : AbstractKotlinInspection() {
|
|||||||
private fun isUsageOfReceiver(resolvedCall: ResolvedCall<*>, bindingContext: BindingContext): Boolean {
|
private fun isUsageOfReceiver(resolvedCall: ResolvedCall<*>, bindingContext: BindingContext): Boolean {
|
||||||
// As receiver of call
|
// As receiver of call
|
||||||
if (resolvedCall.dispatchReceiver.getThisReceiverOwner(bindingContext) == callable ||
|
if (resolvedCall.dispatchReceiver.getThisReceiverOwner(bindingContext) == callable ||
|
||||||
resolvedCall.extensionReceiver.getThisReceiverOwner(bindingContext) == callable) {
|
resolvedCall.extensionReceiver.getThisReceiverOwner(bindingContext) == callable
|
||||||
|
) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// As explicit "this"
|
// As explicit "this"
|
||||||
@@ -101,10 +104,10 @@ class UnusedReceiverParameterInspection : AbstractKotlinInspection() {
|
|||||||
|
|
||||||
if (!used) {
|
if (!used) {
|
||||||
holder.registerProblem(
|
holder.registerProblem(
|
||||||
receiverTypeReference,
|
receiverTypeReference,
|
||||||
KotlinBundle.message("unused.receiver.parameter"),
|
KotlinBundle.message("unused.receiver.parameter"),
|
||||||
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
|
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
|
||||||
MyQuickFix()
|
MyQuickFix()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user