<commit_before>package org.jetbrains.plugins.innerbuilder;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import java.util.ArrayList;
import java.util.List;

import javax.swing.JCheckBox;

import org.jetbrains.annotations.Nullable;

import com.intellij.codeInsight.generation.PsiFieldMember;

import com.intellij.ide.util.MemberChooser;
import com.intellij.ide.util.PropertiesComponent;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;

import com.intellij.ui.NonFocusableCheckBox;

public final class InnerBuilderOptionSelector {
    private static final List<SelectorOption> OPTIONS = createGeneratorOptions();

    private static List<SelectorOption> createGeneratorOptions() {
        final List<SelectorOption> options = new ArrayList<SelectorOption>(6);

        options.add(
            SelectorOption.newBuilder()                               //
            .withCaption("Generate builder methods for final fields") //
            .withMnemonic('f')                                        //
            .withOption(InnerBuilderOption.FINAL_SETTERS)             //
            .build());

        options.add(
            SelectorOption.newBuilder()                         //
            .withCaption("Generate static newBuilder() method") //
            .withMnemonic('n')                                  //
            .withOption(InnerBuilderOption.NEW_BUILDER_METHOD)  //
            .build());

        options.add(
            SelectorOption.newBuilder()                       //
            .withCaption("Generate builder copy constructor") //
            .withMnemonic('o')                                //
            .withOption(InnerBuilderOption.COPY_CONSTRUCTOR)  //
            .build());

        options.add(
            SelectorOption.newBuilder()                                          //
            .withCaption("Use 'with...' notation")                               //
            .withMnemonic('w')                                                   //
            .withToolTip(
                "Generate builder methods that start with 'with', for example: " //
                    + "builder.withName(String name)")                           //
            .withOption(InnerBuilderOption.WITH_NOTATION)                        //
            .build());

        options.add(
            SelectorOption.newBuilder()                                                  //
            .withCaption("JSR-305 @Nonnull w/ Google Guava null check") //
            .withMnemonic('j')                                                           //
            .withToolTip(
                "Add @Nonnull annotations to generated methods and parameters, for example: "
                    + "@Nonnull public Builder withName(@Nonnull String name) { ... }") //
            .withOption(InnerBuilderOption.JSR305_ANNOTATIONS)                          //
            .build());

        options.add(
            SelectorOption.newBuilder()                                     //
            .withCaption("Make all parameters final")                       //
            .withMnemonic('p')                                              //
            .withToolTip(
                "Add the 'final' modifier to all the method parameters, for example: "
                    + "public Builder withName(final String name) { ... }") //
            .withOption(InnerBuilderOption.FINAL_PARAMETERS)                //
            .build());
        return options;
    }

    private InnerBuilderOptionSelector() { }

    @Nullable
    public static List<PsiFieldMember> selectFieldsAndOptions(final List<PsiFieldMember> members,
            final Project project) {
        if (members == null || members.isEmpty()) {
            return null;
        }

        if (ApplicationManager.getApplication().isUnitTestMode()) {
            return members;
        }

        final JCheckBox[] optionCheckBoxes = buildOptionCheckBoxes();

        final PsiFieldMember[] memberArray = members.toArray(new PsiFieldMember[members.size()]);<commit_msg>Minor cleanup.<commit_after>package org.jetbrains.plugins.innerbuilder;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import java.util.ArrayList;
import java.util.List;

import javax.swing.JCheckBox;

import org.jetbrains.annotations.Nullable;

import com.intellij.codeInsight.generation.PsiFieldMember;

import com.intellij.ide.util.MemberChooser;
import com.intellij.ide.util.PropertiesComponent;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;

import com.intellij.ui.NonFocusableCheckBox;

public final class InnerBuilderOptionSelector {
    private static final List<SelectorOption> OPTIONS = createGeneratorOptions();

    private static List<SelectorOption> createGeneratorOptions() {
        final List<SelectorOption> options = new ArrayList<SelectorOption>(6);

        options.add(
            SelectorOption.newBuilder()
            .withCaption("Generate builder methods for final fields")
            .withMnemonic('f')
            .withOption(InnerBuilderOption.FINAL_SETTERS)
            .build());

        options.add(
            SelectorOption.newBuilder()
            .withCaption("Generate static newBuilder() method")
            .withMnemonic('n')
            .withOption(InnerBuilderOption.NEW_BUILDER_METHOD)
            .build());

        options.add(
            SelectorOption.newBuilder()
            .withCaption("Generate builder copy constructor")
            .withMnemonic('o')
            .withOption(InnerBuilderOption.COPY_CONSTRUCTOR)
            .build());

        options.add(
            SelectorOption.newBuilder()
            .withCaption("Use 'with...' notation")
            .withMnemonic('w')
            .withToolTip(
                "Generate builder methods that start with 'with', for example: "
                    + "builder.withName(String name)")
            .withOption(InnerBuilderOption.WITH_NOTATION)
            .build());

        options.add(
            SelectorOption.newBuilder()
            .withCaption("Add JSR-305 @Nonnull annotation")
            .withMnemonic('j')
            .withToolTip(
                "Add @Nonnull annotations to generated methods and parameters, for example: "
                    + "@Nonnull public Builder withName(@Nonnull String name) { ... }")
            .withOption(InnerBuilderOption.JSR305_ANNOTATIONS)
            .build());

        options.add(
            SelectorOption.newBuilder()
            .withCaption("Make all parameters final")
            .withMnemonic('p')
            .withToolTip(
                "Add the 'final' modifier to all the method parameters, for example: "
                    + "public Builder withName(final String name) { ... }")
            .withOption(InnerBuilderOption.FINAL_PARAMETERS)
            .build());
        return options;
    }

    private InnerBuilderOptionSelector() { }

    @Nullable
    public static List<PsiFieldMember> selectFieldsAndOptions(final List<PsiFieldMember> members,
            final Project project) {
        if (members == null || members.isEmpty()) {
            return null;
        }

        if (ApplicationManager.getApplication().isUnitTestMode()) {
            return members;
        }

        final JCheckBox[] optionCheckBoxes = buildOptionCheckBoxes();

        final PsiFieldMember[] memberArray = members.toArray(new PsiFieldMember[members.size()]);
{'fraction_non_alphanumeric': 0.0976965845909452, 'fraction_numerical': 0.0018533227429176596, 'mean_word_length': 1.783714075165807, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '143047', 'n_tokens_mistral': 1883, 'n_tokens_neox': 1787, 'n_words': 361}