|
| 1 | +/* |
| 2 | + * This program is free software; you can redistribute it and/or |
| 3 | + * modify it under the terms of the GNU General Public License |
| 4 | + * as published by the Free Software Foundation; either version 2 |
| 5 | + * of the License, or (at your option) any later version. |
| 6 | + * |
| 7 | + * This program is distributed in the hope that it will be useful, |
| 8 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | + * GNU General Public License for more details. |
| 11 | + * |
| 12 | + * You should have received a copy of the GNU General Public License |
| 13 | + * along with this program; if not, write to the Free Software |
| 14 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.mediawiki; |
| 18 | + |
| 19 | +import com.intellij.lang.javascript.JavaScriptFileType; |
| 20 | +import com.intellij.lang.javascript.JavascriptLanguage; |
| 21 | +import com.intellij.psi.codeStyle.CodeStyleSettings; |
| 22 | +import com.intellij.psi.codeStyle.CommonCodeStyleSettings; |
| 23 | +import com.intellij.psi.codeStyle.PredefinedCodeStyle; |
| 24 | + |
| 25 | +/** |
| 26 | + * @author Reedy |
| 27 | + */ |
| 28 | +public class MediaWikiJsPredefinedCodeStyle extends PredefinedCodeStyle { |
| 29 | + public MediaWikiJsPredefinedCodeStyle() { |
| 30 | + super("MediaWiki", JavascriptLanguage.INSTANCE); |
| 31 | + } |
| 32 | + |
| 33 | + @Override |
| 34 | + public void apply(CodeStyleSettings settings) { |
| 35 | + CommonCodeStyleSettings commonSettings = settings.getCommonSettings(getLanguage()); |
| 36 | + |
| 37 | + commonSettings.SPACE_WITHIN_PARENTHESES = true; |
| 38 | + commonSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = true; |
| 39 | + commonSettings.SPACE_WITHIN_METHOD_PARENTHESES = true; |
| 40 | + commonSettings.SPACE_WITHIN_IF_PARENTHESES = true; |
| 41 | + commonSettings.SPACE_WITHIN_WHILE_PARENTHESES = true; |
| 42 | + commonSettings.SPACE_WITHIN_FOR_PARENTHESES = true; |
| 43 | + commonSettings.SPACE_WITHIN_CATCH_PARENTHESES = true; |
| 44 | + commonSettings.SPACE_WITHIN_SWITCH_PARENTHESES = true; |
| 45 | + commonSettings.SPACE_WITHIN_ARRAY_INITIALIZER_BRACES = true; |
| 46 | + commonSettings.SPACE_AFTER_TYPE_CAST = true; |
| 47 | + |
| 48 | + CodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(JavaScriptFileType.INSTANCE); |
| 49 | + indentOptions.USE_TAB_CHARACTER = true; |
| 50 | + indentOptions.SMART_TABS = true; |
| 51 | + indentOptions.TAB_SIZE = 4; |
| 52 | + indentOptions.INDENT_SIZE = 4; |
| 53 | + indentOptions.CONTINUATION_INDENT_SIZE = 4; |
| 54 | + indentOptions.LABEL_INDENT_SIZE = 0; |
| 55 | + indentOptions.LABEL_INDENT_ABSOLUTE = false; |
| 56 | + indentOptions.USE_RELATIVE_INDENTS = false; |
| 57 | + } |
| 58 | +} |
0 commit comments