mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 11:53:49 +07:00
[kotlin] good code red: report AA exceptions
^KTIJ-30174 fixed GitOrigin-RevId: ad54a6c912e2abbd39399a7c3b8c23d662d18415
This commit is contained in:
committed by
intellij-monorepo-bot
parent
02117d5da0
commit
a0c84efca9
@@ -0,0 +1 @@
|
||||
inspection.message.analysis.failed.with.exception=Analysis failed with exception: {0}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.idea.dev.kotlin.internal;
|
||||
|
||||
import com.intellij.DynamicBundle;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class KotlinDevBundle {
|
||||
|
||||
private static final @NonNls String BUNDLE_FQN = "messages.KotlinDevBundle";
|
||||
private static final DynamicBundle BUNDLE = new DynamicBundle(KotlinDevBundle.class, BUNDLE_FQN);
|
||||
|
||||
private KotlinDevBundle() {
|
||||
}
|
||||
|
||||
public static @Nls @NotNull String message(
|
||||
@PropertyKey(resourceBundle = BUNDLE_FQN) @NotNull String key,
|
||||
@Nullable Object @NotNull ... params
|
||||
) {
|
||||
return BUNDLE.getMessage(key, params);
|
||||
}
|
||||
|
||||
public static @NotNull Supplier<@Nls @NotNull String> messagePointer(
|
||||
@PropertyKey(resourceBundle = BUNDLE_FQN) @NotNull String key,
|
||||
@Nullable Object @NotNull ... params
|
||||
) {
|
||||
return BUNDLE.getLazyMessage(key, params);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package org.jetbrains.idea.dev.kotlin.internal
|
||||
|
||||
import com.intellij.codeInspection.ProblemsHolder
|
||||
import com.intellij.dev.codeInsight.internal.GoodCodeRedVisitor
|
||||
import com.intellij.openapi.diagnostic.ControlFlowException
|
||||
import com.intellij.psi.PsiElementVisitor
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.kotlin.analysis.api.analyze
|
||||
@@ -18,14 +19,20 @@ internal class KotlinGoodCodeRedVisitor : GoodCodeRedVisitor {
|
||||
return object : KtVisitor<Unit, Unit>() {
|
||||
override fun visitFile(file: PsiFile) {
|
||||
super.visitFile(file)
|
||||
analyze(file as KtFile) {
|
||||
val diagnostics = file.collectDiagnosticsForFile(KtDiagnosticCheckerFilter.ONLY_COMMON_CHECKERS)
|
||||
for (diagnostic in diagnostics) {
|
||||
if (diagnostic.severity == Severity.ERROR) {
|
||||
holder.registerProblem(diagnostic.psi, diagnostic.defaultMessage)
|
||||
try {
|
||||
analyze(file as KtFile) {
|
||||
val diagnostics = file.collectDiagnosticsForFile(KtDiagnosticCheckerFilter.ONLY_COMMON_CHECKERS)
|
||||
for (diagnostic in diagnostics) {
|
||||
if (diagnostic.severity == Severity.ERROR) {
|
||||
holder.registerProblem(diagnostic.psi, diagnostic.defaultMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e: Exception) {
|
||||
if (e is ControlFlowException) throw e
|
||||
holder.registerProblem(file, KotlinDevBundle.message("inspection.message.analysis.failed.with.exception", e.message))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user