Search in sources :

Example 1 with JSCodeStyleSettings

use of com.intellij.lang.javascript.formatter.JSCodeStyleSettings in project intellij-plugins by JetBrains.

the class FlexEditorTest method testInsertBraceOnEnter.

public void testInsertBraceOnEnter() throws Exception {
    _testInsertBraceOnEnter("", "js2");
    _testInsertBraceOnEnter("2", "js2");
    final JSCodeStyleSettings codeSettings = CodeStyleSettingsManager.getSettings(getProject()).getCustomSettings(ECMA4CodeStyleSettings.class);
    try {
        codeSettings.INDENT_PACKAGE_CHILDREN = JSCodeStyleSettings.INDENT;
        _testInsertBraceOnEnter("3", "js2");
    } finally {
        codeSettings.INDENT_PACKAGE_CHILDREN = JSCodeStyleSettings.DO_NOT_INDENT;
    }
}
Also used : JSCodeStyleSettings(com.intellij.lang.javascript.formatter.JSCodeStyleSettings)

Example 2 with JSCodeStyleSettings

use of com.intellij.lang.javascript.formatter.JSCodeStyleSettings in project intellij-plugins by JetBrains.

the class AngularTypedHandlerTest method testInsertWhitespace.

public void testInsertWhitespace() {
    myFixture.configureByText(HtmlFileType.INSTANCE, "{<caret>");
    JSCodeStyleSettings settings = JSCodeStyleSettings.getSettings(myFixture.getFile());
    boolean oldWhitespace = settings.SPACES_WITHIN_INTERPOLATION_EXPRESSIONS;
    try {
        settings.SPACES_WITHIN_INTERPOLATION_EXPRESSIONS = true;
        myFixture.type("{");
        myFixture.checkResult("{{ <caret> }}");
    } finally {
        settings.SPACES_WITHIN_INTERPOLATION_EXPRESSIONS = oldWhitespace;
    }
}
Also used : JSCodeStyleSettings(com.intellij.lang.javascript.formatter.JSCodeStyleSettings)

Example 3 with JSCodeStyleSettings

use of com.intellij.lang.javascript.formatter.JSCodeStyleSettings in project intellij-plugins by JetBrains.

the class FlexOptimizeImportsTest method testNoSemicolons.

@JSTestOptions({ JSTestOption.WithJsSupportLoader, JSTestOption.WithFlexSdk })
public void testNoSemicolons() throws Throwable {
    JSTestUtils.addClassesToProject(myFixture, true, "foo.MyClass", "foo.MyClass2", "bar.MyClass3");
    final JSCodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getInstance(myFixture.getProject()).getCurrentSettings().getCustomSettings(ECMA4CodeStyleSettings.class);
    boolean b = codeStyleSettings.USE_SEMICOLON_AFTER_STATEMENT;
    codeStyleSettings.USE_SEMICOLON_AFTER_STATEMENT = false;
    try {
        runOptimizeAction(AS_FILE_EXTENSION);
    } finally {
        codeStyleSettings.USE_SEMICOLON_AFTER_STATEMENT = b;
    }
}
Also used : JSCodeStyleSettings(com.intellij.lang.javascript.formatter.JSCodeStyleSettings) JSTestOptions(com.intellij.lang.javascript.JSTestOptions)

Example 4 with JSCodeStyleSettings

use of com.intellij.lang.javascript.formatter.JSCodeStyleSettings in project intellij-plugins by JetBrains.

the class ActionScriptFormatterTest method testSpaceNearType.

public void testSpaceNearType() throws Exception {
    doFileTest("");
    JSCodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(getProject()).getCustomSettings(ECMA4CodeStyleSettings.class);
    try {
        styleSettings.SPACE_BEFORE_TYPE_COLON = true;
        styleSettings.SPACE_AFTER_TYPE_COLON = true;
        doFileTest("_2");
        styleSettings.SPACE_BEFORE_TYPE_COLON = false;
        styleSettings.SPACE_AFTER_TYPE_COLON = true;
        doFileTest("_3");
    } finally {
        styleSettings.SPACE_BEFORE_TYPE_COLON = false;
        styleSettings.SPACE_AFTER_TYPE_COLON = false;
    }
}
Also used : JSCodeStyleSettings(com.intellij.lang.javascript.formatter.JSCodeStyleSettings)

Example 5 with JSCodeStyleSettings

use of com.intellij.lang.javascript.formatter.JSCodeStyleSettings in project intellij-plugins by JetBrains.

the class ActionScriptFormatterTest method testSpaceBeforeTypeColon.

public void testSpaceBeforeTypeColon() throws Exception {
    final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings();
    final JSCodeStyleSettings jsSettings = settings.getCustomSettings(ECMA4CodeStyleSettings.class);
    boolean spaceBeforeTypeColon = jsSettings.SPACE_BEFORE_TYPE_COLON;
    boolean spaceAfterTypeColon = jsSettings.SPACE_AFTER_TYPE_COLON;
    jsSettings.SPACE_BEFORE_TYPE_COLON = true;
    jsSettings.SPACE_AFTER_TYPE_COLON = false;
    doTest("package aaa {\n" + "class XXX {\n" + "    private var _field:int;\n" + "    function get field():int {\n" + "        return _field;\n" + "    }\n" + "\n" + "    function set field(val:int):void {\n" + "        varName = val;\n" + "    }\n" + "}", "package aaa {\n" + "class XXX {\n" + "    private var _field :int;\n" + "    function get field() :int {\n" + "        return _field;\n" + "    }\n" + "\n" + "    function set field(val :int) :void {\n" + "        varName = val;\n" + "    }\n" + "}", ".as");
    jsSettings.SPACE_BEFORE_TYPE_COLON = spaceBeforeTypeColon;
    jsSettings.SPACE_AFTER_TYPE_COLON = spaceAfterTypeColon;
}
Also used : JSCodeStyleSettings(com.intellij.lang.javascript.formatter.JSCodeStyleSettings) CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) XmlCodeStyleSettings(com.intellij.psi.formatter.xml.XmlCodeStyleSettings) ECMA4CodeStyleSettings(com.intellij.lang.javascript.formatter.ECMA4CodeStyleSettings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) JSCodeStyleSettings(com.intellij.lang.javascript.formatter.JSCodeStyleSettings)

Aggregations

JSCodeStyleSettings (com.intellij.lang.javascript.formatter.JSCodeStyleSettings)9 ECMA4CodeStyleSettings (com.intellij.lang.javascript.formatter.ECMA4CodeStyleSettings)2 CodeStyleSettings (com.intellij.psi.codeStyle.CodeStyleSettings)2 CommonCodeStyleSettings (com.intellij.psi.codeStyle.CommonCodeStyleSettings)2 XmlCodeStyleSettings (com.intellij.psi.formatter.xml.XmlCodeStyleSettings)2 JSTestOptions (com.intellij.lang.javascript.JSTestOptions)1 Document (com.intellij.openapi.editor.Document)1 MultiplePsiFilesPerDocumentFileViewProvider (com.intellij.psi.MultiplePsiFilesPerDocumentFileViewProvider)1