Reformat: can be private inspection
This commit is contained in:
+16
-14
@@ -91,10 +91,13 @@ class MemberVisibilityCanBePrivateInspection : AbstractKotlinInspection() {
|
||||
|
||||
if (descriptor.hasJvmFieldAnnotation()) return false
|
||||
val entryPointsManager = EntryPointsManager.getInstance(declaration.project) as EntryPointsManagerBase
|
||||
if (UnusedSymbolInspection.checkAnnotatedUsingPatterns(declaration,
|
||||
with (entryPointsManager) {
|
||||
additionalAnnotations + ADDITIONAL_ANNOTATIONS
|
||||
})) return false
|
||||
if (UnusedSymbolInspection.checkAnnotatedUsingPatterns(
|
||||
declaration,
|
||||
with(entryPointsManager) {
|
||||
additionalAnnotations + ADDITIONAL_ANNOTATIONS
|
||||
}
|
||||
)
|
||||
) return false
|
||||
|
||||
// properties can be referred by component1/component2, which is too expensive to search, don't analyze them
|
||||
if (declaration is KtParameter && declaration.dataClassComponentFunction() != null) return false
|
||||
@@ -108,8 +111,7 @@ class MemberVisibilityCanBePrivateInspection : AbstractKotlinInspection() {
|
||||
PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES -> return false
|
||||
PsiSearchHelper.SearchCostResult.FEW_OCCURRENCES -> KotlinSourceFilterScope.projectSources(useScope, declaration.project)
|
||||
}
|
||||
}
|
||||
else useScope
|
||||
} else useScope
|
||||
|
||||
var otherUsageFound = false
|
||||
var inClassUsageFound = false
|
||||
@@ -118,8 +120,7 @@ class MemberVisibilityCanBePrivateInspection : AbstractKotlinInspection() {
|
||||
if (classOrObject != usage.getParentOfType<KtClassOrObject>(false)) {
|
||||
otherUsageFound = true
|
||||
false
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
val function = usage.getParentOfType<KtCallableDeclaration>(false)
|
||||
val insideInlineFun = function?.modifierList?.let {
|
||||
it.hasModifier(KtTokens.INLINE_KEYWORD) && !function.isPrivate()
|
||||
@@ -127,8 +128,7 @@ class MemberVisibilityCanBePrivateInspection : AbstractKotlinInspection() {
|
||||
if (insideInlineFun) {
|
||||
otherUsageFound = true
|
||||
false
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
inClassUsageFound = true
|
||||
true
|
||||
}
|
||||
@@ -144,9 +144,11 @@ class MemberVisibilityCanBePrivateInspection : AbstractKotlinInspection() {
|
||||
else -> "Property"
|
||||
}
|
||||
val nameElement = (declaration as? PsiNameIdentifierOwner)?.nameIdentifier ?: return
|
||||
holder.registerProblem(declaration.visibilityModifier() ?: nameElement,
|
||||
"$member '${declaration.getName()}' can be private",
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
|
||||
IntentionWrapper(AddModifierFix(modifierListOwner, KtTokens.PRIVATE_KEYWORD), declaration.containingKtFile))
|
||||
holder.registerProblem(
|
||||
declaration.visibilityModifier() ?: nameElement,
|
||||
"$member '${declaration.getName()}' can be private",
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
|
||||
IntentionWrapper(AddModifierFix(modifierListOwner, KtTokens.PRIVATE_KEYWORD), declaration.containingKtFile)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user