cleanup
authorAlexey Kudravtsev <cdr@intellij.com>
Wed, 16 Nov 2016 15:37:44 +0000 (18:37 +0300)
committerAlexey Kudravtsev <cdr@intellij.com>
Thu, 17 Nov 2016 12:42:09 +0000 (15:42 +0300)
java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java
java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java
platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java
platform/util/src/com/intellij/openapi/util/DefaultJDOMExternalizer.java
platform/util/src/com/intellij/util/concurrency/EdtExecutorService.java
spellchecker/src/com/intellij/spellchecker/actions/SpellingPopupActionGroup.java

index ba27a01146494a33c581e31dd852d4a6a583b46c..5748a63335648f20ae14d8b487024a2936365ebf 100644 (file)
@@ -1336,16 +1336,16 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
 
     List<HighlightInfo> warns = doHighlighting(HighlightSeverity.WARNING);
     assertOneElement(warns);
-    List<HighlightInfo.IntentionActionDescriptor> actions = ShowIntentionsPass.getAvailableActions(getEditor(), getFile(), -1);
+    List<HighlightInfo.IntentionActionDescriptor> actions = ShowIntentionsPass.getAvailableFixes(getEditor(), getFile(), -1);
     final HighlightInfo.IntentionActionDescriptor descriptor = assertOneElement(actions);
     WriteCommandAction.runWriteCommandAction(getProject(), () -> descriptor.getAction().invoke(getProject(), getEditor(), getFile()));
 
     highlightErrors();
-    actions = ShowIntentionsPass.getAvailableActions(getEditor(), getFile(), -1);
+    actions = ShowIntentionsPass.getAvailableFixes(getEditor(), getFile(), -1);
     assertEmpty(actions);
   }
 
-  
+
   public void testApplyErrorInTheMiddle() throws Throwable {
     String text = "class <caret>X { ";
     for (int i = 0; i < 100; i++) {
@@ -1373,7 +1373,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
     assertEmpty(errors);
   }
 
-  
+
   public void testErrorInTheEndOutsideVisibleArea() throws Throwable {
     String text = "<xml> \n" + StringUtil.repeatSymbol('\n', 1000) + "</xml>\nxxxxx<caret>";
     configureByText(StdFileTypes.XML, text);
@@ -1427,7 +1427,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
     assertEquals(4, infos.size());
   }
 
-  
+
   public void testTypingNearEmptyErrorElement() throws Throwable {
     String text = "class LQF {\n" +
                   "    public void main() {\n" +
@@ -1446,7 +1446,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
     assertEmpty(infos);
   }
 
-  
+
   public void testLIPGetAllParentsAfterCodeBlockModification() throws Throwable {
     @Language("JAVA")
     String text = "class LQF {\n" +
@@ -1514,7 +1514,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
     assertEquals(new HashSet<>(methodAndParents), new HashSet<>(visitedElements));
   }
 
-  
+
   public void testCancelsItSelfOnTypingInAlienProject() throws Throwable {
     String body = StringUtil.repeat("\"String field = null;\"\n", 1000);
     configureByText(StdFileTypes.JAVA, "class X{ void f() {" + body + "<caret>\n} }");
index 19ec879a4f3585bf685186df6be29246d5b5c39c..aa260c135230c0987bd54c926da77ed0099f767d 100644 (file)
@@ -55,11 +55,6 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
     return false;
   }
 
-  @NotNull
-  protected ActionHint parseActionHintImpl(@NotNull PsiFile file, @NotNull String contents) {
-    return ActionHint.parse(file, contents);
-  }
-
   private static void doTestFor(@NotNull String testName, @NotNull QuickFixTestCase quickFixTestCase) {
     final String relativePath = ObjectUtils.notNull(quickFixTestCase.getBasePath(), "") + "/" + BEFORE_PREFIX + testName;
     final String testFullPath = quickFixTestCase.getTestDataPath().replace(File.separatorChar, '/') + relativePath;
@@ -239,7 +234,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
       @NotNull
       @Override
       public ActionHint parseActionHintImpl(@NotNull PsiFile file, @NotNull String contents) {
-        return LightQuickFixTestCase.this.parseActionHintImpl(file, contents);
+        return ActionHint.parse(file, contents);
       }
 
       @Override
index 3a6c1b94ece72e98d3fa60cac10596ceef9ed7c8..863a16d993429dfa606b2eddc69586b313fdd60b 100644 (file)
@@ -86,9 +86,9 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass {
   private volatile boolean myHasToRecreate;
 
   @NotNull
-  public static List<HighlightInfo.IntentionActionDescriptor> getAvailableActions(@NotNull final Editor editor,
-                                                                                  @NotNull final PsiFile file,
-                                                                                  final int passId) {
+  public static List<HighlightInfo.IntentionActionDescriptor> getAvailableFixes(@NotNull final Editor editor,
+                                                                                @NotNull final PsiFile file,
+                                                                                final int passId) {
     final int offset = ((EditorEx)editor).getExpectedCaretOffset();
     final Project project = file.getProject();
 
@@ -96,16 +96,16 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass {
     DaemonCodeAnalyzerImpl.processHighlightsNearOffset(editor.getDocument(), project, HighlightSeverity.INFORMATION, offset, true,
                                                        new CommonProcessors.CollectProcessor<>(infos));
     List<HighlightInfo.IntentionActionDescriptor> result = new ArrayList<>();
-    infos.forEach(info->addAvailableActionsForGroups(info, editor, file, result, passId, offset));
+    infos.forEach(info-> addAvailableFixesForGroups(info, editor, file, result, passId, offset));
     return result;
   }
 
-  private static void addAvailableActionsForGroups(@NotNull HighlightInfo info,
-                                                   @NotNull Editor editor,
-                                                   @NotNull PsiFile file,
-                                                   @NotNull List<HighlightInfo.IntentionActionDescriptor> outList,
-                                                   int group,
-                                                   int offset) {
+  private static void addAvailableFixesForGroups(@NotNull HighlightInfo info,
+                                                 @NotNull Editor editor,
+                                                 @NotNull PsiFile file,
+                                                 @NotNull List<HighlightInfo.IntentionActionDescriptor> outList,
+                                                 int group,
+                                                 int offset) {
     if (info.quickFixActionMarkers == null) return;
     if (group != -1 && group != info.getGroup()) return;
     boolean fixRangeIsNotEmpty = !info.getFixTextRange().isEmpty();
@@ -157,7 +157,7 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass {
     public final List<HighlightInfo.IntentionActionDescriptor> guttersToShow = ContainerUtil.createLockFreeCopyOnWriteList();
     public final List<HighlightInfo.IntentionActionDescriptor> notificationActionsToShow = ContainerUtil.createLockFreeCopyOnWriteList();
 
-    public void filterActions(@Nullable PsiFile psiFile) {
+    void filterActions(@Nullable PsiFile psiFile) {
       IntentionActionFilter[] filters = IntentionActionFilter.EXTENSION_POINT_NAME.getExtensions();
       filter(intentionsToShow, psiFile, filters);
       filter(errorFixesToShow, psiFile, filters);
@@ -287,7 +287,7 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass {
     int offset = hostEditor.getCaretModel().getOffset();
     final Project project = hostFile.getProject();
 
-    List<HighlightInfo.IntentionActionDescriptor> fixes = getAvailableActions(hostEditor, hostFile, passIdToShowIntentionsFor);
+    List<HighlightInfo.IntentionActionDescriptor> fixes = getAvailableFixes(hostEditor, hostFile, passIdToShowIntentionsFor);
     final DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
     final Document hostDocument = hostEditor.getDocument();
     HighlightInfo infoAtCursor = ((DaemonCodeAnalyzerImpl)codeAnalyzer).findHighlightByOffset(hostDocument, offset, true);
@@ -396,6 +396,7 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass {
         PsiElement el = psiElement;
         while (el != null) {
           elements.add(el);
+          if (el instanceof PsiFile) break;
           el = el.getParent();
         }
 
index 8a6d9d27854a846eef9d9d9c8aaeb30d9a71438e..6c63d2332fe765166937de2f964e7ba1d24da674 100644 (file)
@@ -108,7 +108,6 @@ public class ShowIntentionActionsHandler implements CodeInsightActionHandler {
     return false;
   }
 
-  // returns editor,file where the action is available or null if there are none
   public static boolean availableFor(@NotNull PsiFile psiFile, @NotNull Editor editor, @NotNull IntentionAction action) {
     if (!psiFile.isValid()) return false;
 
index 4489779c8a0cd56c9e0bf9e111aed300770c33b8..4ed7ece3a17563b7a4d9f9105ce0552deaf5ff8a 100644 (file)
@@ -33,7 +33,7 @@ import java.util.List;
  * @deprecated {@link com.intellij.util.xmlb.XmlSerializer} should be used instead
  * @author mike
  */
-@SuppressWarnings({"HardCodedStringLiteral"})
+@SuppressWarnings("HardCodedStringLiteral")
 public class DefaultJDOMExternalizer {
   private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.DefaultJDOMExternalizer");
 
@@ -138,7 +138,7 @@ public class DefaultJDOMExternalizer {
   }
 
   @Nullable
-  public static String filterXMLCharacters(String value) {
+  static String filterXMLCharacters(String value) {
     if (value != null) {
       StringBuilder builder = null;
       for (int i=0; i<value.length();i++) {
index f77bae0a5025170e62fe055134ecc9a7f52ea196..a24ab92f28caf7fd7d2d6d92e7e85532a20e38f7 100644 (file)
@@ -25,7 +25,8 @@ import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
 /**
- * {@link java.util.concurrent.ExecutorService} implementation which delegates tasks for execution to the {@link javax.swing.SwingUtilities#invokeLater(Runnable)}
+ * An {@link ExecutorService} implementation which
+ * delegates tasks to the {@link javax.swing.SwingUtilities#invokeLater(Runnable)} for execution.
  */
 public class EdtExecutorService extends AbstractExecutorService {
   @NotNull
index 94fdc677795d71a35054007c4c19e926280f1288..1836d209c1f4450d245924b7a7df3ebc928d52d3 100644 (file)
@@ -67,7 +67,7 @@ public final class SpellingPopupActionGroup extends ActionGroup {
     Project project = e.getData(LangDataKeys.PROJECT);
     Editor editor = e.getData(LangDataKeys.EDITOR);
     if (psiFile != null && project != null && editor != null) {
-      List<HighlightInfo.IntentionActionDescriptor> quickFixes = ShowIntentionsPass.getAvailableActions(editor, psiFile, -1);
+      List<HighlightInfo.IntentionActionDescriptor> quickFixes = ShowIntentionsPass.getAvailableFixes(editor, psiFile, -1);
       Map<Anchor, List<AnAction>> children = new HashMap<>();
       ArrayList<AnAction> first = new ArrayList<>();
       children.put(Anchor.FIRST, first);