Export wrap on typing property as boolean

This commit is contained in:
Rustam Vishnyakov
2019-01-28 19:40:50 +03:00
parent 1e7c61c182
commit f3709c55b8
5 changed files with 34 additions and 2 deletions
@@ -258,7 +258,8 @@
"while_on_new_line": "false",
"wrap_comments": "false",
"wrap_first_method_in_call_chain": "false",
"wrap_long_lines": "false"
"wrap_long_lines": "false",
"wrap_on_typing": "true"
}
}
]
@@ -241,7 +241,8 @@
"while_on_new_line": "false",
"wrap_comments": "false",
"wrap_first_method_in_call_chain": "false",
"wrap_long_lines": "false"
"wrap_long_lines": "false",
"wrap_on_typing": "true"
}
}
]
@@ -82,6 +82,7 @@ public class JavaCodeStyleSettingsTest extends CodeStyleTestCase {
final CommonCodeStyleSettings commonJavaSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
commonJavaSettings.METHOD_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
commonJavaSettings.CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
commonJavaSettings.WRAP_ON_TYPING = CommonCodeStyleSettings.WrapOnTyping.WRAP.intValue;
final JavaCodeStyleSettings javaSettings = settings.getCustomSettings(JavaCodeStyleSettings.class);
javaSettings.FIELD_NAME_PREFIX = "m_";
javaSettings.STATIC_FIELD_NAME_SUFFIX = "_s";
@@ -65,6 +65,9 @@ class PropertyAccessorFactory {
}
return new BooleanAccessor(codeStyleObject, myField);
case INT:
if ("WRAP_ON_TYPING".equals(myField.getName())) {
return new WrapOnTypingAccessor(codeStyleObject, myField);
}
return new IntegerAccessor(codeStyleObject, myField);
case STRING:
CommaSeparatedValues annotation = myField.getAnnotation(CommaSeparatedValues.class);
@@ -0,0 +1,26 @@
// 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.psi.codeStyle.CommonCodeStyleSettings;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field;
public class WrapOnTypingAccessor extends IntegerAccessor {
WrapOnTypingAccessor(@NotNull Object object, @NotNull Field field) {
super(object, field);
}
@NotNull
@Override
protected String toExternal(@NotNull Integer value) {
return value == CommonCodeStyleSettings.WrapOnTyping.WRAP.intValue ? "true" : "false";
}
@Override
protected Integer fromExternal(@NotNull String str) {
return "true".equalsIgnoreCase(str) ?
CommonCodeStyleSettings.WrapOnTyping.WRAP.intValue :
CommonCodeStyleSettings.WrapOnTyping.NO_WRAP.intValue;
}
}