<commit_before>// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.java.codeInsight.daemon;

import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.daemon.impl.IntentionsUI;
import com.intellij.codeInsight.daemon.impl.ShowIntentionsPass;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInsight.intention.impl.CachedIntentions;
import com.intellij.codeInspection.unneededThrows.RedundantThrowsDeclarationLocalInspection;
import com.intellij.ide.highlighter.JavaFileType;
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import static com.intellij.testFramework.assertions.Assertions.assertThat;

/**
 * @author <NAME>
 */
public class GutterIntentionsTest extends LightJavaCodeInsightFixtureTestCase {
  public void testEmptyIntentions() {
    myFixture.configureByText(JavaFileType.INSTANCE, "class Foo {\n" +
                                                     "  <caret>   private String test() {\n" +
                                                     "        return null;\n" +
                                                     "     }" +
                                                     "}");
    myFixture.findAllGutters();
    List<IntentionAction> intentions = myFixture.getAvailableIntentions();
    assertEmpty(intentions);
  }

  public void testOptions() {
    myFixture.configureByText(JavaFileType.INSTANCE, "public class Foo {\n" +
                                                     "  public static void <caret>main(String[] args) { someCode(); }" +
                                                     "}");
    assertSize(1, myFixture.findGuttersAtCaret());

    ShowIntentionsPass.IntentionsInfo intentions = ShowIntentionsPass.getActionsToShow(getEditor(), getFile(), false);
    assertThat(intentions.guttersToShow.size()).isGreaterThan(1);
  }

  public void testRunLineMarker() {
    myFixture.addClass("package junit.framework; public class TestCase {}");
    myFixture.configureByText("MainTest.java", "public class Main<caret>Test extends junit.framework.TestCase {\n" +
                                               "    public void testFoo() {\n" +
                                               "    }\n" +
                                               "}");
    myFixture.doHighlighting();
    CachedIntentions intentions = IntentionsUI.getInstance(getProject()).getCachedIntentions(getEditor(), getFile());
    assertThat(intentions.getAllActions().get(0).getText()).startsWith("Run ");
  }

  public void testDoNotIncludeActionGroup() {
    myFixture.configureByText(JavaFileType.INSTANCE, "public class Foo {\n" +
                                                     "  public static void <caret>main(String[] args) { someCode(); }" +
                                                     "}");
    assertSize(1, myFixture.findGuttersAtCaret());

    ShowIntentionsPass.IntentionsInfo intentions = ShowIntentionsPass.getActionsToShow(getEditor(), getFile(), false);
    List<HighlightInfo.IntentionActionDescriptor> descriptors = intentions.guttersToShow;
    Set<String> names = descriptors.stream().map(descriptor -> descriptor.getDisplayName()).collect(Collectors.toSet());
    assertEquals(descriptors.size(), names.size());
  }

  public void testFixesOnTop() {
    myFixture.configureByText(JavaFileType.INSTANCE, "public class Foo extends Bo<caret>o {\n" +
                                                     "  public static void main(String[] args) {}" +
                                                     "}");
    List<IntentionAction> actions = myFixture.getAvailableIntentions();
    assertThat(actions.get(0).getText()).startsWith("Create class ");
  }

  public void testWarningFixesOnTop() {
    myFixture.addClass("package junit.framework; public class TestCase {}");
    myFixture.configureByText("MainTest.java", "public class MainTest extends junit.framework.TestCase {\n" +
                                               "    public void testFoo() throws Exce<caret>ption {\n" +
                                               "    }\n" +
                                               "}");
    myFixture.enableInspections(new RedundantThrowsDeclarationLocalInspection());
    myFixture.doHighlighting();
    CachedIntentions intentions = IntentionsUI.getInstance(getProject()).getCachedIntentions(getEditor(), getFile());
    assertThat(intentions.getAllActions().get(0).getText()).startsWith("Remove ");
  }
}
<commit_msg>fix flaky test<commit_after>// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.java.codeInsight.daemon;

import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.daemon.impl.IntentionsUI;
import com.intellij.codeInsight.daemon.impl.ShowIntentionsPass;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInsight.intention.impl.CachedIntentions;
import com.intellij.codeInspection.unneededThrows.RedundantThrowsDeclarationLocalInspection;
import com.intellij.ide.highlighter.JavaFileType;
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import static com.intellij.testFramework.assertions.Assertions.assertThat;

/**
 * @author <NAME>
 */
public class GutterIntentionsTest extends LightJavaCodeInsightFixtureTestCase {
  public void testEmptyIntentions() {
    myFixture.configureByText(JavaFileType.INSTANCE, "class Foo {\n" +
                                                     "  <caret>   private String test() {\n" +
                                                     "        return null;\n" +
                                                     "     }" +
                                                     "}");
    myFixture.findAllGutters();
    List<IntentionAction> intentions = myFixture.getAvailableIntentions();
    assertEmpty(intentions);
  }

  public void testOptions() {
    myFixture.configureByText(JavaFileType.INSTANCE, "public class Foo {\n" +
                                                     "  public static void <caret>main(String[] args) { someCode(); }" +
                                                     "}");
    assertSize(1, myFixture.findGuttersAtCaret());

    ShowIntentionsPass.IntentionsInfo intentions = ShowIntentionsPass.getActionsToShow(getEditor(), getFile(), false);
    assertThat(intentions.guttersToShow.size()).isGreaterThan(1);
  }

  public void testRunLineMarker() {
    myFixture.addClass("package junit.framework; public class TestCase {}");
    myFixture.configureByText("MainTest.java", "public class Main<caret>Test extends junit.framework.TestCase {\n" +
                                               "    public void testFoo() {\n" +
                                               "    }\n" +
                                               "}");
    myFixture.doHighlighting();
    CachedIntentions intentions = IntentionsUI.getInstance(getProject()).getCachedIntentions(getEditor(), getFile());
    assertThat(intentions.getAllActions().get(0).getText()).startsWith("Run ");
  }

  public void testDoNotIncludeActionGroup() {
    myFixture.configureByText(JavaFileType.INSTANCE, "public class Foo {\n" +
                                                     "  public static void <caret>main(String[] args) { someCode(); }" +
                                                     "}");
    assertSize(1, myFixture.findGuttersAtCaret());

    ShowIntentionsPass.IntentionsInfo intentions = ShowIntentionsPass.getActionsToShow(getEditor(), getFile(), false);
    List<HighlightInfo.IntentionActionDescriptor> descriptors = intentions.guttersToShow;
    Set<String> names = descriptors.stream().map(descriptor -> descriptor.getDisplayName()).collect(Collectors.toSet());
    assertEquals(descriptors.size(), names.size());
  }

  public void testFixesOnTop() {
    myFixture.configureByText(JavaFileType.INSTANCE, "public class Foo extends Bo<caret>o {\n" +
                                                     "  public static void main(String[] args) {}" +
                                                     "}");
    List<IntentionAction> actions = myFixture.getAvailableIntentions();
    assertThat(actions.get(0).getText()).startsWith("Create class ");
  }

  public void testWarningFixesOnTop() {
    myFixture.addClass("package junit.framework; public class TestCase {}");
    myFixture.configureByText("MainTest.java", "public class MainTest extends junit.framework.TestCase {\n" +
                                               "    public void testFoo() throws Exce<caret>ption {\n" +
                                               "    }\n" +
                                               "}");
    myFixture.enableInspections(new RedundantThrowsDeclarationLocalInspection());
    myFixture.doHighlighting();
    List<IntentionAction> actions = myFixture.getAvailableIntentions();
    assertThat(actions.get(0).getText()).startsWith("Remove ");
  }
}

{'fraction_non_alphanumeric': 0.10747262185956624, 'fraction_numerical': 0.003435688211294825, 'mean_word_length': 2.3291636883488205, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 64, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2501715', 'n_tokens_mistral': 2396, 'n_tokens_neox': 2350, 'n_words': 413}