Skip to content

Commit 0c35acf

Browse files
committed
Start of a Javascript code style
1 parent 3fb11cb commit 0c35acf

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

META-INF/plugin.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<idea-plugin version="2">
22
<id>org.mediawiki</id>
33
<name>MediaWiki Support</name>
4-
<version>0.2</version>
4+
<version>0.3</version>
55
<vendor email="[email protected]" url="https://github.com/reedy/phpstorm-plugin-mediawiki">Sam Reed (reedy)</vendor>
66

77
<description><![CDATA[
@@ -13,6 +13,11 @@
1313

1414
<change-notes><![CDATA[
1515
<p>
16+
<strong>Version 0.3</strong>
17+
<ul>
18+
<li>Javascript Code Style</li>
19+
</ul>
20+
1621
<strong>Version 0.2</strong>
1722
<ul>
1823
<li>Search MediaWiki.org via right click menus with selected text</li>
@@ -36,12 +41,14 @@
3641
<idea-version since-build="131"/>
3742

3843
<depends>com.jetbrains.php</depends>
44+
<depends>com.intellij.modules.lang</depends>
3945
<depends>com.intellij.modules.ultimate</depends>
4046

4147
<extensions defaultExtensionNs="com.intellij">
4248
<predefinedCodeStyle implementation="org.mediawiki.MediaWikiPhpPredefinedCodeStyle"/>
4349
<predefinedCodeStyle implementation="org.mediawiki.MediaWikiCssPredefinedCodeStyle"/>
4450
<predefinedCodeStyle implementation="org.mediawiki.MediaWikiHTMLPredefinedCodeStyle"/>
51+
<predefinedCodeStyle implementation="org.mediawiki.MediaWikiJsPredefinedCodeStyle"/>
4552
</extensions>
4653

4754
<application-components>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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

Comments
 (0)