consider a companion object to be used if it contains any members
This commit is contained in:
@@ -237,10 +237,11 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() {
|
||||
}
|
||||
}
|
||||
|
||||
return (declaration is JetObjectDeclaration && declaration.isCompanion() &&
|
||||
declaration.getBody()?.declarations?.isNotEmpty() == true) ||
|
||||
hasReferences(declaration, useScope) ||
|
||||
hasOverrides(declaration, useScope)
|
||||
|
||||
return hasReferences(declaration, useScope) ||
|
||||
hasOverrides(declaration, useScope) ||
|
||||
hasCompanionObjectMemberUsages(declaration, useScope)
|
||||
}
|
||||
|
||||
private fun hasReferences(declaration: JetNamedDeclaration, useScope: SearchScope): Boolean {
|
||||
@@ -256,12 +257,6 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() {
|
||||
return DefinitionsScopedSearch.search(declaration, useScope).findFirst() != null
|
||||
}
|
||||
|
||||
private fun hasCompanionObjectMemberUsages(declaration: JetNamedDeclaration, useScope: SearchScope): Boolean {
|
||||
if (declaration !is JetObjectDeclaration || !declaration.isCompanion()) return false
|
||||
|
||||
return declaration.declarations.any { it is JetNamedDeclaration && hasReferences(it, useScope) }
|
||||
}
|
||||
|
||||
override fun createOptionsPanel(): JComponent? {
|
||||
val panel = JPanel(GridBagLayout())
|
||||
panel.add(
|
||||
|
||||
Reference in New Issue
Block a user