exception in inspection visitor must not crash other inspections to fix IJPL-207109 exception in grazie inspection should not halt the entire highlighting

GitOrigin-RevId: 43f00601ed8bed117f38843fcdb7607dcfb7e9a0
This commit is contained in:
Alexey Kudravtsev
2025-09-11 17:08:13 +00:00
committed by intellij-monorepo-bot
parent 25a4044131
commit cbd248b3c7
@@ -88,7 +88,7 @@ class InspectionRunner {
// The containing file this tool was called for. In the case of injected context, this will be the injected file.
@NotNull PsiFile psiFile) {
@Override
public String toString() {
public @NotNull String toString() {
return tool +"; inside:"+elementsInside().size()+"; outside:"+elementsOutside().size();
}
}
@@ -403,15 +403,22 @@ class InspectionRunner {
* (starting from this inspection's most fertile elements if any),
* maintaining parallelism during this process (i.e., several visitors from {@code init} can be executed concurrently, but elements from the list head get higher priority than the list tail).
*/
private static void processContext(@NotNull InspectionContext context, List<? extends PsiElement> psiElements,
private static void processContext(@NotNull InspectionContext context,
@NotNull @Unmodifiable List<? extends PsiElement> psiElements,
@NotNull InspectionVisitorOptimizer optimizer) {
if (LOG.isTraceEnabled()) {
LOG.trace("processContext: " +
context + "; elements(" + psiElements.size() + "): " + StringUtil.join(psiElements, e-> e + "(" + e.getClass() + ")", ", ") + "; accepts=" + context.acceptingPsiTypes());
}
optimizer.acceptElements(psiElements,
context.acceptingPsiTypes,
psiElement -> context.holder.visitElement(psiElement, context.visitor));
try {
optimizer.acceptElements(psiElements,
context.acceptingPsiTypes,
psiElement -> context.holder.visitElement(psiElement, context.visitor));
}
catch (Throwable t) {
if (Logger.shouldRethrow(t)) throw t;
LOG.error(t);
}
}
private void injectedFound(@NotNull PsiFile injectedPsi, @NotNull PsiElement host, @NotNull LocalInspectionToolSession session,