<commit_before>package org.rust.ide.formatter.settings

import com.intellij.application.options.IndentOptionsEditor
import com.intellij.application.options.SmartIndentOptionsEditor
import com.intellij.lang.Language
import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable
import com.intellij.psi.codeStyle.CommonCodeStyleSettings
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider.SettingsType.*
import org.rust.ide.utils.loadCodeSampleResource
import org.rust.lang.RustLanguage

class RustLanguageCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvider() {
    override fun getLanguage(): Language = RustLanguage

    override fun getCodeSample(settingsType: SettingsType): String =
        // TODO Provide more suitable code samples for specific settings types
        when (settingsType) {
            BLANK_LINES_SETTINGS,
            SPACING_SETTINGS,
            WRAPPING_AND_BRACES_SETTINGS,
            INDENT_SETTINGS -> CODE_SAMPLE

            else            -> ""
        }

    override fun customizeSettings(consumer: CodeStyleSettingsCustomizable, settingsType: SettingsType) {
        when (settingsType) {
            BLANK_LINES_SETTINGS         -> {
                consumer.showStandardOptions(
                    "KEEP_LINE_BREAKS",
                    "KEEP_BLANK_LINES_IN_DECLARATIONS",
                    "KEEP_BLANK_LINES_IN_CODE")
            }

            SPACING_SETTINGS             -> {
                // TODO Implement this.
            }

            WRAPPING_AND_BRACES_SETTINGS -> {
                consumer.showStandardOptions("RIGHT_MARGIN");
            }

            INDENT_SETTINGS              -> {
                // TODO Implement this.
            }

            else                         -> {
            }
        }
    }

    override fun getIndentOptionsEditor(): IndentOptionsEditor? = SmartIndentOptionsEditor()

    override fun getDefaultCommonSettings(): CommonCodeStyleSettings =
        CommonCodeStyleSettings(language).apply {
            RIGHT_MARGIN = 99
        }
<commit_msg>(FMT): save indent options<commit_after>package org.rust.ide.formatter.settings

import com.intellij.application.options.IndentOptionsEditor
import com.intellij.application.options.SmartIndentOptionsEditor
import com.intellij.lang.Language
import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable
import com.intellij.psi.codeStyle.CommonCodeStyleSettings
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider.SettingsType.*
import org.rust.ide.utils.loadCodeSampleResource
import org.rust.lang.RustLanguage

class RustLanguageCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvider() {
    override fun getLanguage(): Language = RustLanguage

    override fun getCodeSample(settingsType: SettingsType): String =
        // TODO Provide more suitable code samples for specific settings types
        when (settingsType) {
            BLANK_LINES_SETTINGS,
            SPACING_SETTINGS,
            WRAPPING_AND_BRACES_SETTINGS,
            INDENT_SETTINGS -> CODE_SAMPLE

            else            -> ""
        }

    override fun customizeSettings(consumer: CodeStyleSettingsCustomizable, settingsType: SettingsType) {
        when (settingsType) {
            BLANK_LINES_SETTINGS         -> {
                consumer.showStandardOptions(
                    "KEEP_LINE_BREAKS",
                    "KEEP_BLANK_LINES_IN_DECLARATIONS",
                    "KEEP_BLANK_LINES_IN_CODE")
            }

            SPACING_SETTINGS             -> {
                // TODO Implement this.
            }

            WRAPPING_AND_BRACES_SETTINGS -> {
                consumer.showStandardOptions("RIGHT_MARGIN");
            }

            INDENT_SETTINGS              -> {
                // TODO Implement this.
            }

            else                         -> {
            }
        }
    }

    override fun getIndentOptionsEditor(): IndentOptionsEditor? = SmartIndentOptionsEditor()

    override fun getDefaultCommonSettings(): CommonCodeStyleSettings =
        CommonCodeStyleSettings(language).apply {
            RIGHT_MARGIN = 99
            initIndentOptions()
        }

{'fraction_non_alphanumeric': 0.06722106722106722, 'fraction_numerical': 0.000924000924000924, 'mean_word_length': 2.258088788562829, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6724892', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1096, 'n_words': 178}