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() ||
|
||||
callableDeclaration.hasModifier(KtTokens.OVERRIDE_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 KtNamedFunction && !callableDeclaration.hasBody()) return
|
||||
@@ -80,7 +81,8 @@ class UnusedReceiverParameterInspection : AbstractKotlinInspection() {
|
||||
if (isUsageOfReceiver(resolvedCall, bindingContext)) {
|
||||
used = true
|
||||
} else if (resolvedCall is VariableAsFunctionResolvedCall
|
||||
&& isUsageOfReceiver(resolvedCall.variableCall, bindingContext)) {
|
||||
&& isUsageOfReceiver(resolvedCall.variableCall, bindingContext)
|
||||
) {
|
||||
used = true
|
||||
}
|
||||
}
|
||||
@@ -88,7 +90,8 @@ class UnusedReceiverParameterInspection : AbstractKotlinInspection() {
|
||||
private fun isUsageOfReceiver(resolvedCall: ResolvedCall<*>, bindingContext: BindingContext): Boolean {
|
||||
// As receiver of call
|
||||
if (resolvedCall.dispatchReceiver.getThisReceiverOwner(bindingContext) == callable ||
|
||||
resolvedCall.extensionReceiver.getThisReceiverOwner(bindingContext) == callable) {
|
||||
resolvedCall.extensionReceiver.getThisReceiverOwner(bindingContext) == callable
|
||||
) {
|
||||
return true
|
||||
}
|
||||
// As explicit "this"
|
||||
@@ -101,10 +104,10 @@ class UnusedReceiverParameterInspection : AbstractKotlinInspection() {
|
||||
|
||||
if (!used) {
|
||||
holder.registerProblem(
|
||||
receiverTypeReference,
|
||||
KotlinBundle.message("unused.receiver.parameter"),
|
||||
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
|
||||
MyQuickFix()
|
||||
receiverTypeReference,
|
||||
KotlinBundle.message("unused.receiver.parameter"),
|
||||
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
|
||||
MyQuickFix()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user