mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Export comma-separated values as Json arrays
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
// Copyright 2000-2019 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.application.options.codeStyle.properties;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Marker annotation for fields containing comma-separated values.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface CommaSeparatedValues {
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// Copyright 2000-2019 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.application.options.codeStyle.properties;
|
||||
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
public class CommaSeparatedValuesAccessor extends ValueListPropertyAccessor<String> {
|
||||
public CommaSeparatedValuesAccessor(@NotNull Object object, @NotNull Field field) {
|
||||
super(object, field);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected String fromExternal(@NotNull List<String> extVal) {
|
||||
StringBuilder valueBuilder = new StringBuilder();
|
||||
for (String value : extVal) {
|
||||
if (valueBuilder.length() > 0) {
|
||||
valueBuilder.append(",");
|
||||
}
|
||||
valueBuilder.append(extVal);
|
||||
}
|
||||
return valueBuilder.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected List<String> toExternal(@NotNull String value) {
|
||||
List<String> valueList = ContainerUtil.newArrayList();
|
||||
String[] parts = value.split(",");
|
||||
for (String part : parts) {
|
||||
valueList.add(part.trim());
|
||||
}
|
||||
return valueList;
|
||||
}
|
||||
}
|
||||
+4
@@ -67,6 +67,10 @@ class PropertyAccessorFactory {
|
||||
case INT:
|
||||
return new IntegerAccessor(codeStyleObject, myField);
|
||||
case STRING:
|
||||
CommaSeparatedValues annotation = myField.getAnnotation(CommaSeparatedValues.class);
|
||||
if (annotation != null) {
|
||||
return new CommaSeparatedValuesAccessor(codeStyleObject, myField);
|
||||
}
|
||||
return new StringAccessor(codeStyleObject, myField);
|
||||
case WRAP:
|
||||
return new WrappingAccessor(codeStyleObject, myField);
|
||||
|
||||
@@ -9,5 +9,102 @@
|
||||
"max_line_length": "120",
|
||||
"wrap_on_typing": "false"
|
||||
}
|
||||
},
|
||||
{
|
||||
"language": "html",
|
||||
"options": {
|
||||
"add_new_line_before_tags": [
|
||||
"body",
|
||||
"div",
|
||||
"p",
|
||||
"form",
|
||||
"h1",
|
||||
"h2",
|
||||
"h3"
|
||||
],
|
||||
"align_attributes": "true",
|
||||
"align_text": "false",
|
||||
"attribute_wrap": "normal",
|
||||
"block_comment_at_first_column": "true",
|
||||
"continuation_indent_size": "8",
|
||||
"do_not_align_children_of_min_lines": "0",
|
||||
"do_not_break_if_inline_tags": [
|
||||
"title",
|
||||
"h1",
|
||||
"h2",
|
||||
"h3",
|
||||
"h4",
|
||||
"h5",
|
||||
"h6",
|
||||
"p"
|
||||
],
|
||||
"do_not_indent_children_of_tags": [
|
||||
"html",
|
||||
"body",
|
||||
"thead",
|
||||
"tbody",
|
||||
"tfoot"
|
||||
],
|
||||
"enforce_quotes": "false",
|
||||
"indent_size": "4",
|
||||
"indent_style": "space",
|
||||
"inline_tags": [
|
||||
"a",
|
||||
"abbr",
|
||||
"acronym",
|
||||
"b",
|
||||
"basefont",
|
||||
"bdo",
|
||||
"big",
|
||||
"br",
|
||||
"cite",
|
||||
"cite",
|
||||
"code",
|
||||
"dfn",
|
||||
"em",
|
||||
"font",
|
||||
"i",
|
||||
"img",
|
||||
"input",
|
||||
"kbd",
|
||||
"label",
|
||||
"q",
|
||||
"s",
|
||||
"samp",
|
||||
"select",
|
||||
"span",
|
||||
"strike",
|
||||
"strong",
|
||||
"sub",
|
||||
"sup",
|
||||
"textarea",
|
||||
"tt",
|
||||
"u",
|
||||
"var"
|
||||
],
|
||||
"keep_blank_lines": "2",
|
||||
"keep_indents_on_empty_lines": "false",
|
||||
"keep_line_breaks": "true",
|
||||
"keep_line_breaks_in_text": "true",
|
||||
"keep_whitespaces": "false",
|
||||
"keep_whitespaces_inside": [
|
||||
"span",
|
||||
"pre",
|
||||
"textarea"
|
||||
],
|
||||
"line_comment_at_first_column": "true",
|
||||
"new_line_after_last_attribute": "never",
|
||||
"new_line_before_first_attribute": "never",
|
||||
"quote_style": "double",
|
||||
"remove_new_line_before_tags": [
|
||||
"br"
|
||||
],
|
||||
"smart_tabs": "false",
|
||||
"space_after_tag_name": "false",
|
||||
"space_around_equality_in_attribute": "false",
|
||||
"space_inside_empty_tag": "false",
|
||||
"tab_width": "4",
|
||||
"text_wrap": "normal"
|
||||
}
|
||||
}
|
||||
]
|
||||
+2
-2
@@ -8,7 +8,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class JsonInterchangeTest extends CodeStyleTestCase {
|
||||
|
||||
@@ -16,7 +16,7 @@ public class JsonInterchangeTest extends CodeStyleTestCase {
|
||||
CodeStyleScheme testScheme = createTestScheme();
|
||||
CodeStyleSchemeJsonExporter exporter = new CodeStyleSchemeJsonExporter();
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
exporter.exportScheme(testScheme, outputStream, Collections.singletonList(GeneralCodeStylePropertyMapper.COMMON_DOMAIN_ID));
|
||||
exporter.exportScheme(testScheme, outputStream, Arrays.asList(GeneralCodeStylePropertyMapper.COMMON_DOMAIN_ID, "html"));
|
||||
String expected = loadExpected("json");
|
||||
assertEquals(expected, outputStream.toString());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2017 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.psi.formatter.xml;
|
||||
|
||||
import com.intellij.application.options.codeStyle.properties.CommaSeparatedValues;
|
||||
import com.intellij.configurationStore.Property;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CustomCodeStyleSettings;
|
||||
@@ -42,21 +43,33 @@ public class HtmlCodeStyleSettings extends CustomCodeStyleSettings {
|
||||
public boolean HTML_SPACE_INSIDE_EMPTY_TAG;
|
||||
|
||||
@Property(externalName = "add_new_line_before_tags")
|
||||
@CommaSeparatedValues
|
||||
@NonNls public String HTML_ELEMENTS_TO_INSERT_NEW_LINE_BEFORE = "body,div,p,form,h1,h2,h3";
|
||||
|
||||
@Property(externalName = "remove_new_line_before_tags")
|
||||
@CommaSeparatedValues
|
||||
@NonNls public String HTML_ELEMENTS_TO_REMOVE_NEW_LINE_BEFORE = "br";
|
||||
|
||||
@Property(externalName = "do_not_indent_children_of_tags")
|
||||
@CommaSeparatedValues
|
||||
@NonNls public String HTML_DO_NOT_INDENT_CHILDREN_OF = "html,body,thead,tbody,tfoot";
|
||||
|
||||
@Property(externalName = "do_not_align_children_of_min_lines")
|
||||
public int HTML_DO_NOT_ALIGN_CHILDREN_OF_MIN_LINES;
|
||||
|
||||
@Property(externalName = "keep_whitespaces_inside")
|
||||
@CommaSeparatedValues
|
||||
@NonNls public String HTML_KEEP_WHITESPACES_INSIDE = "span,pre,textarea";
|
||||
|
||||
@Property(externalName = "inline_tags")
|
||||
@CommaSeparatedValues
|
||||
@NonNls public String HTML_INLINE_ELEMENTS =
|
||||
"a,abbr,acronym,b,basefont,bdo,big,br,cite,cite,code,dfn,em,font,i,img,input,kbd,label,q,s,samp,select,span,strike,strong,sub,sup,textarea,tt,u,var";
|
||||
|
||||
@Property(externalName = "do_not_break_if_inline_tags")
|
||||
@CommaSeparatedValues
|
||||
@NonNls public String HTML_DONT_ADD_BREAKS_IF_INLINE_CONTENT = "title,h1,h2,h3,h4,h5,h6,p";
|
||||
|
||||
@Property(externalName = "quote_style")
|
||||
public CodeStyleSettings.QuoteStyle HTML_QUOTE_STYLE = CodeStyleSettings.QuoteStyle.Double;
|
||||
@Property(externalName = "enforce_quotes")
|
||||
|
||||
Reference in New Issue
Block a user