Skip to content

Commit

Permalink
Added Nette code style [closes #20]
Browse files Browse the repository at this point in the history
  • Loading branch information
matej21 committed Jul 12, 2015
1 parent da429c8 commit 16165e4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
groupName="Nette"
implementationClass="cz.juzna.intellij.nette.inspections.CreateComponentReturnFormTypeInspection"
level="WARNING" enabledByDefault="true"/>
<predefinedCodeStyle implementation="cz.juzna.intellij.nette.codeStyle.NetteCodeStyle"/>
</extensions>

<actions>
Expand Down
38 changes: 38 additions & 0 deletions src/cz/juzna/intellij/nette/codeStyle/NetteCodeStyle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cz.juzna.intellij.nette.codeStyle;

import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.jetbrains.php.lang.PhpFileType;
import com.jetbrains.php.lang.formatter.PhpCodeStyleSettings;
import com.jetbrains.php.lang.formatter.ui.PhpLanguageCodeStyleSettingsProvider;

public class NetteCodeStyle extends PhpLanguageCodeStyleSettingsProvider.PSR1PSR2CodeStyle {

public NetteCodeStyle() {
super("Nette");
}

@Override
public void apply(CodeStyleSettings settings) {
super.apply(settings);

CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(PhpFileType.INSTANCE);
indentOptions.INDENT_SIZE = 4;
indentOptions.TAB_SIZE = 4;
indentOptions.CONTINUATION_INDENT_SIZE = 4;
indentOptions.USE_TAB_CHARACTER = true;

CommonCodeStyleSettings commonSettings = settings.getCommonSettings(this.getLanguage());
commonSettings.BLANK_LINES_AFTER_CLASS_HEADER = 0;
commonSettings.ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION = false;

PhpCodeStyleSettings phpSettings = settings.getCustomSettings(PhpCodeStyleSettings.class);
phpSettings.PHPDOC_BLANK_LINE_BEFORE_TAGS = false;
phpSettings.LOWER_CASE_BOOLEAN_CONST = false;
phpSettings.LOWER_CASE_NULL_CONST = false;
phpSettings.UPPER_CASE_NULL_CONST = true;
phpSettings.UPPER_CASE_BOOLEAN_CONST = true;
phpSettings.BLANK_LINE_BEFORE_RETURN_STATEMENT = false;

}
}

0 comments on commit 16165e4

Please sign in to comment.