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