1
1
package org .mediawiki ;
2
2
3
3
import com .intellij .psi .codeStyle .CodeStyleSettings ;
4
+ import com .intellij .psi .codeStyle .CommonCodeStyleSettings ;
4
5
import com .intellij .psi .codeStyle .PredefinedCodeStyle ;
5
6
import com .jetbrains .php .lang .PhpFileType ;
6
7
import com .jetbrains .php .lang .PhpLanguage ;
8
+ import com .jetbrains .php .lang .formatter .PhpCodeStyleSettings ;
7
9
8
10
/**
9
11
* @author Reedy
@@ -15,8 +17,35 @@ public MediaWikiPredefinedCodeStyle() {
15
17
16
18
@ Override
17
19
public void apply (CodeStyleSettings settings ) {
20
+ CommonCodeStyleSettings commonSettings = settings .getCommonSettings (getLanguage ());
21
+ commonSettings .KEEP_BLANK_LINES_IN_CODE = 1 ;
22
+ commonSettings .KEEP_BLANK_LINES_BEFORE_RBRACE = 0 ;
23
+ commonSettings .CLASS_BRACE_STYLE = 1 ;
24
+ commonSettings .METHOD_BRACE_STYLE = 1 ;
25
+ commonSettings .ALIGN_MULTILINE_PARAMETERS = false ;
26
+ commonSettings .SPACE_WITHIN_PARENTHESES = true ;
27
+ commonSettings .SPACE_WITHIN_METHOD_CALL_PARENTHESES = true ;
28
+ commonSettings .SPACE_WITHIN_METHOD_PARENTHESES = true ;
29
+ commonSettings .SPACE_WITHIN_IF_PARENTHESES = true ;
30
+ commonSettings .SPACE_WITHIN_WHILE_PARENTHESES = true ;
31
+ commonSettings .SPACE_WITHIN_FOR_PARENTHESES = true ;
32
+ commonSettings .SPACE_WITHIN_CATCH_PARENTHESES = true ;
33
+ commonSettings .SPACE_WITHIN_SWITCH_PARENTHESES = true ;
34
+ commonSettings .SPACE_WITHIN_ARRAY_INITIALIZER_BRACES = true ;
35
+ commonSettings .SPACE_AFTER_TYPE_CAST = true ;
36
+ commonSettings .IF_BRACE_FORCE = 3 ;
37
+
38
+ PhpCodeStyleSettings phpSettings = settings .getCustomSettings (PhpCodeStyleSettings .class );
39
+ phpSettings .LOWER_CASE_BOOLEAN_CONST = true ;
40
+ phpSettings .LOWER_CASE_NULL_CONST = true ;
41
+ phpSettings .BLANK_LINE_BEFORE_RETURN_STATEMENT = true ;
42
+ phpSettings .KEEP_RPAREN_AND_LBRACE_ON_ONE_LINE = true ;
43
+
18
44
CodeStyleSettings .IndentOptions indentOptions = settings .getIndentOptions (PhpFileType .INSTANCE );
19
45
indentOptions .USE_TAB_CHARACTER = true ;
20
46
indentOptions .SMART_TABS = true ;
47
+ indentOptions .TAB_SIZE = 4 ;
48
+ indentOptions .INDENT_SIZE = 4 ;
49
+ indentOptions .CONTINUATION_INDENT_SIZE = 4 ;
21
50
}
22
51
}
0 commit comments