From f55d8f9f4a47328f976a4ffd9417b1ec92bd8413 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 29 Oct 2009 12:40:25 +0300 Subject: [PATCH] do not create recursive element visitor for each tool for injected PSI --- .../daemon/impl/LocalInspectionsPass.java | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java index d9e4d15884..b09bc0095e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java @@ -470,22 +470,23 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass InspectionManager inspectionManager = InspectionManager.getInstance(injectedPsi.getProject()); final ProblemsHolder problemsHolder = new ProblemsHolder(inspectionManager, injectedPsi); final PsiElement host = injectedPsi.getContext(); - for (LocalInspectionTool tool : tools) { - if (host != null && InspectionManagerEx.inspectionResultSuppressed(host, tool)) { - continue; - } - final PsiElementVisitor visitor = tool.buildVisitor(problemsHolder, true); - assert !(visitor instanceof PsiRecursiveElementVisitor) : "The visitor returned from LocalInspectionTool.buildVisitor() must not be recursive. "+tool; - injectedPsi.accept(new PsiRecursiveElementWalkingVisitor() { - @Override public void visitElement(PsiElement element) { + + final PsiElement[] elements = getElementsIntersectingRange(injectedPsi, 0, injectedPsi.getTextLength()); + if (elements.length != 0) { + for (LocalInspectionTool tool : tools) { + if (host != null && InspectionManagerEx.inspectionResultSuppressed(host, tool)) { + continue; + } + final PsiElementVisitor visitor = tool.buildVisitor(problemsHolder, true); + assert !(visitor instanceof PsiRecursiveElementVisitor) : "The visitor returned from LocalInspectionTool.buildVisitor() must not be recursive. "+tool; + for (PsiElement element : elements) { element.accept(visitor); - super.visitElement(element); } - }); - List problems = problemsHolder.getResults(); - if (problems != null && !problems.isEmpty()) { - InjectedPsiInspectionResult res = new InjectedPsiInspectionResult(tool, injectedPsi, new SmartList(problems)); - result.add(res); + List problems = problemsHolder.getResults(); + if (problems != null && !problems.isEmpty()) { + InjectedPsiInspectionResult res = new InjectedPsiInspectionResult(tool, injectedPsi, new SmartList(problems)); + result.add(res); + } } } } -- 2.11.4.GIT