Search in sources :

Example 1 with SettingsType

use of com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider.SettingsType in project intellij-community by JetBrains.

the class CodeStyleSettingsNameProvider method moveStandardOption.

@Override
public void moveStandardOption(String fieldName, String newGroup) {
    for (SettingsType settingsType : SettingsType.values()) {
        Map<SettingsGroup, List<CodeStyleSettingPresentation>> standardGroups = mySettings.get(settingsType);
        if (standardGroups == null) {
            standardGroups = ContainerUtil.newLinkedHashMap();
            mySettings.put(settingsType, standardGroups);
        }
        for (Map.Entry<SettingsGroup, List<CodeStyleSettingPresentation>> entry : standardGroups.entrySet()) {
            CodeStyleSettingPresentation moveSetting = null;
            for (CodeStyleSettingPresentation setting : entry.getValue()) {
                if (setting.getFieldName().equals(fieldName)) {
                    moveSetting = setting;
                    break;
                }
            }
            if (moveSetting != null) {
                entry.getValue().remove(moveSetting);
                addSetting(new SettingsGroup(newGroup), moveSetting, null, null);
            }
        }
    }
}
Also used : CodeStyleSettingPresentation(com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation) SettingsGroup(com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation.SettingsGroup) SettingsType(com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider.SettingsType)

Example 2 with SettingsType

use of com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider.SettingsType in project intellij-community by JetBrains.

the class CodeStyleSettingsNameProvider method getSettings.

public String getSettings(List<Value> values) {
    StringBuilder builder = new StringBuilder();
    for (SettingsType settingsType : LanguageCodeStyleSettingsProvider.SettingsType.values()) {
        builder.append("<br><b><u>").append(getSettingsTypeName(settingsType)).append("</u></b>");
        Map<SettingsGroup, List<CodeStyleSettingPresentation>> groups = mySettings.get(settingsType);
        if (groups != null) {
            for (Map.Entry<SettingsGroup, List<CodeStyleSettingPresentation>> entry : groups.entrySet()) {
                boolean firstSettingGroupTop = entry.getKey().isNull();
                boolean groupReported = false;
                for (final CodeStyleSettingPresentation setting : entry.getValue()) {
                    Value myValue = ContainerUtil.find(values, value -> value.state == Value.STATE.SELECTED && value.name.equals(setting.getFieldName()));
                    if (myValue == null) {
                        continue;
                    }
                    if (!groupReported) {
                        if (firstSettingGroupTop) {
                            builder.append("<b>");
                        } else {
                            builder.append("<br><b>").append(entry.getKey().name).append("</b>");
                        }
                    }
                    builder.append("<br>");
                    String postNameSign = setting.getUiName().endsWith(":") ? " " : ": ";
                    builder.append(setting.getUiName()).append(postNameSign).append(setting.getValueUiName(myValue.value));
                    if (!groupReported) {
                        if (firstSettingGroupTop) {
                            builder.append("</b>");
                        }
                    }
                    groupReported = true;
                }
            }
        }
    }
    return builder.toString();
}
Also used : CodeStyleSettingPresentation(com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation) SettingsGroup(com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation.SettingsGroup) SettingsType(com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider.SettingsType) Value(com.intellij.psi.codeStyle.extractor.values.Value)

Example 3 with SettingsType

use of com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider.SettingsType in project intellij-community by JetBrains.

the class CodeErrorReport method getSamplesToTest.

private List<CodeSampleInfo> getSamplesToTest(@NotNull LanguageCodeStyleSettingsProvider provider) {
    Set<String> processedSamples = ContainerUtil.newHashSet();
    List<CodeSampleInfo> sampleInfos = ContainerUtil.newArrayList();
    for (SettingsType setting : mySettingValues) {
        String sample = provider.getCodeSample(setting);
        if (StringUtil.isEmpty(sample) || processedSamples.contains(sample)) {
            continue;
        }
        processedSamples.add(sample);
        sampleInfos.add(new CodeSampleInfo(setting, sample));
    }
    return sampleInfos;
}
Also used : SettingsType(com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider.SettingsType)

Aggregations

SettingsType (com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider.SettingsType)3 CodeStyleSettingPresentation (com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation)2 SettingsGroup (com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation.SettingsGroup)2 Value (com.intellij.psi.codeStyle.extractor.values.Value)1