Implement common Diagnostic(Factory/Renderer) in related FIR classes

This commit is contained in:
Mikhail Glukhikh
2020-11-17 12:22:13 +03:00
parent d47e16331c
commit 1795c4f3e5
36 changed files with 232 additions and 350 deletions
@@ -45,7 +45,7 @@ class AnnotationPresentationInfo(
if (fixes.isEmpty()) {
// if there are no quick fixes we need to register an EmptyIntentionAction to enable 'suppress' actions
annotation.newFix(EmptyIntentionAction(diagnostic.factory.name)).registerFix()
annotation.newFix(EmptyIntentionAction(diagnostic.factory.name!!)).registerFix()
}
}
}
@@ -37,7 +37,7 @@ class KotlinSuppressableWarningProblemGroup(
}
fun createSuppressWarningActions(element: PsiElement, diagnosticFactory: DiagnosticFactory<*>): List<SuppressIntentionAction> =
createSuppressWarningActions(element, diagnosticFactory.severity, diagnosticFactory.name)
createSuppressWarningActions(element, diagnosticFactory.severity, diagnosticFactory.name!!)
fun createSuppressWarningActions(element: PsiElement, severity: Severity, suppressionKey: String): List<SuppressIntentionAction> {
@@ -42,7 +42,7 @@ internal abstract class AbstractFirIdeDiagnosticsCollector(
override fun report(diagnostic: FirDiagnostic<*>?) {
if (diagnostic !is FirPsiDiagnostic<*>) return
if (diagnostic.element.psi !is KtElement) return
onDiagnostic(diagnostic.asPsiBasedDiagnostic())
onDiagnostic(diagnostic)
}
}
@@ -261,7 +261,7 @@ class KotlinBytecodeToolWindow(private val myProject: Project, private val toolW
answer.append("// ================\n")
for (diagnostic in diagnostics) {
answer.append("// Error at ")
.append(diagnostic.psiFile.name)
.append(diagnostic.psiFile?.name)
.append(join(diagnostic.textRanges, ","))
.append(": ")
.append(DefaultErrorMessages.render(diagnostic))
@@ -46,7 +46,7 @@ class MigrateDiagnosticSuppressionInspection : AbstractKotlinInspection(), Clean
}
class ReplaceDiagnosticNameFix(private val diagnosticFactory: DiagnosticFactory<*>) : LocalQuickFix {
override fun getName() = KotlinBundle.message("replace.diagnostic.name.fix.text", familyName, diagnosticFactory.name)
override fun getName() = KotlinBundle.message("replace.diagnostic.name.fix.text", familyName, diagnosticFactory.name!!)
override fun getFamilyName() = KotlinBundle.message("replace.diagnostic.name.fix.family.name")
@@ -128,7 +128,7 @@ class AddFunctionToSupertypeFix private constructor(
val descriptors = generateFunctionsToAdd(function)
if (descriptors.isEmpty()) return null
val project = diagnostic.psiFile.project
val project = diagnostic.psiFile!!.project
val functionData = descriptors.mapNotNull { createFunctionData(it, project) }
if (functionData.isEmpty()) return null
@@ -102,7 +102,7 @@ class AddPropertyToSupertypeFix private constructor(
val descriptors = generatePropertiesToAdd(property)
if (descriptors.isEmpty()) return null
val project = diagnostic.psiFile.project
val project = diagnostic.psiFile!!.project
val propertyData = descriptors.mapNotNull { createPropertyData(it, property.initializer, project) }
if (propertyData.isEmpty()) return null
@@ -82,7 +82,7 @@ open class DiagnosticCodeMetaInfoRenderConfiguration(
}
fun getTag(codeMetaInfo: DiagnosticCodeMetaInfo): String {
return codeMetaInfo.diagnostic.factory.name
return codeMetaInfo.diagnostic.factory.name!!
}
}