diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java index 121ad9908699..d03a74e5c619 100644 --- a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java @@ -133,12 +133,12 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase texts.add(intentionAction.getText()); } Collection infos = quickFix.doHighlighting(); - fail("Action with text '" + text + "' is not available in test " + testFullPath+"\nAvailable actions: "+texts+"\n"+actions+"\nErrors:"+infos); + fail("Action with text '" + text + "' is not available in test " + testFullPath+"\nAvailable actions ("+texts.size()+"): "+texts+"\n"+actions+"\nInfos:"+infos); } } else { if (!actionShouldBeAvailable) { - fail("Action '" + text + "' is available in test " + testFullPath); + fail("Action '" + text + "' is available (but must not) in test " + testFullPath); } quickFix.invoke(action); UIUtil.dispatchAllInvocationEvents(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoComposite.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoComposite.java index 0e219704aeb2..822255428fff 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoComposite.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoComposite.java @@ -19,13 +19,18 @@ */ package com.intellij.codeInsight.daemon.impl; +import com.intellij.openapi.editor.RangeMarker; +import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; public class HighlightInfoComposite extends HighlightInfo { @NonNls private static final String HTML_HEADER = ""; @@ -35,21 +40,24 @@ public class HighlightInfoComposite extends HighlightInfo { @NonNls private static final String LINE_BREAK = "\n
"; public HighlightInfoComposite(@NotNull List infos) { - super(infos.get(0).type, infos.get(0).startOffset, infos.get(0).endOffset, createCompositeDescription(infos), - createCompositeTooltip(infos)); + super(infos.get(0).type, infos.get(0).startOffset, infos.get(0).endOffset, createCompositeDescription(infos), createCompositeTooltip(infos)); text = infos.get(0).text; highlighter = infos.get(0).highlighter; group = infos.get(0).group; - quickFixActionMarkers = ContainerUtil.createEmptyCOWList(); - quickFixActionRanges = ContainerUtil.createEmptyCOWList(); + List> markers = null; + List> ranges = null; for (HighlightInfo info : infos) { if (info.quickFixActionMarkers != null) { - quickFixActionMarkers.addAll(info.quickFixActionMarkers); + if (markers == null) markers = new ArrayList>(); + markers.addAll(info.quickFixActionMarkers); } if (info.quickFixActionRanges != null) { - quickFixActionRanges.addAll(info.quickFixActionRanges); + if (ranges == null) ranges = new ArrayList>(); + ranges.addAll(info.quickFixActionRanges); } } + quickFixActionMarkers = markers == null ? ContainerUtil.>createEmptyCOWList() : new CopyOnWriteArrayList>(markers); + quickFixActionRanges = ranges == null ? ContainerUtil.>createEmptyCOWList() : new CopyOnWriteArrayList>(ranges); } @Nullable diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java index 1ee2b413a854..49bc17d515d0 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java @@ -122,11 +122,10 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass { public void doCollectInformation(ProgressIndicator progress) { if (!ApplicationManager.getApplication().isUnitTestMode() && !myEditor.getContentComponent().hasFocus()) return; TemplateState state = TemplateManagerImpl.getTemplateState(myEditor); - if (state == null || state.isFinished()) { - DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject); - getIntentionActionsToShow(); - updateActions(codeAnalyzer); - } + if (state != null && !state.isFinished()) return; + DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject); + getIntentionActionsToShow(); + updateActions(codeAnalyzer); } public void doApplyInformationToEditor() { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixAction.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixAction.java index 00f9650e32cf..441ad5dbea5f 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixAction.java @@ -114,13 +114,13 @@ public final class QuickFixAction { return result; } - private static void addAvailableActionsForGroups(HighlightInfo info, + private static void addAvailableActionsForGroups(@NotNull HighlightInfo info, Editor editor, - PsiFile file, - List outList, + @NotNull PsiFile file, + @NotNull List outList, int group, int offset) { - if (info == null || info.quickFixActionMarkers == null) return; + if (info.quickFixActionMarkers == null) return; if (group != -1 && group != info.group) return; for (Pair pair : info.quickFixActionMarkers) { HighlightInfo.IntentionActionDescriptor actionInGroup = pair.first;