use of com.intellij.lang.javascript.formatter.JSCodeStyleSettings in project intellij-plugins by JetBrains.
the class ActionScriptFormatterTest method testActionScriptRestParameter.
public void testActionScriptRestParameter() throws Exception {
final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings();
final JSCodeStyleSettings jsSettings = settings.getCustomSettings(ECMA4CodeStyleSettings.class);
jsSettings.SPACE_AFTER_DOTS_IN_REST_PARAMETER = false;
doTest("class Bar {\n" + " public function foo(... rest):void {\n" + " }\n" + "}", "class Bar {\n" + " public function foo(...rest):void {\n" + " }\n" + "}", ".as");
jsSettings.SPACE_AFTER_DOTS_IN_REST_PARAMETER = true;
doTest("class Bar {\n" + " public function foo(... rest):void {\n" + " }\n" + "}", "class Bar {\n" + " public function foo(... rest):void {\n" + " }\n" + "}", ".as");
}
use of com.intellij.lang.javascript.formatter.JSCodeStyleSettings in project intellij-plugins by JetBrains.
the class ActionScriptHighlightingTest method testPropertyPrefix.
public void testPropertyPrefix() throws Exception {
JSCodeStyleSettings jsCodeStyleSettings = CodeStyleSettingsManager.getSettings(myProject).getCustomSettings(JSCodeStyleSettings.class);
String prefix = jsCodeStyleSettings.PROPERTY_PREFIX;
jsCodeStyleSettings.PROPERTY_PREFIX = "prop";
try {
doSimpleHighlightingWithInvokeFixAndCheckResult("Change PropertyPrefix.ee() signature");
} finally {
jsCodeStyleSettings.PROPERTY_PREFIX = prefix;
}
}
use of com.intellij.lang.javascript.formatter.JSCodeStyleSettings in project intellij-plugins by JetBrains.
the class AngularBracesInterpolationTypedHandler method beforeCharTyped.
@Override
public Result beforeCharTyped(char c, Project project, Editor editor, PsiFile file, FileType fileType) {
if (file.getViewProvider() instanceof MultiplePsiFilesPerDocumentFileViewProvider || DumbService.isDumb(project))
return Result.CONTINUE;
if (!CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET)
return Result.DEFAULT;
// we should use AngularJSBracesUtil here
if (file.getFileType() == HtmlFileType.INSTANCE) {
final Document document = editor.getDocument();
if (c == '{') {
if (!AngularJSBracesUtil.DEFAULT_START.equals(AngularJSBracesUtil.getInjectionStart(project)) || !AngularJSBracesUtil.DEFAULT_END.equals(AngularJSBracesUtil.getInjectionEnd(project)))
return Result.CONTINUE;
JSCodeStyleSettings jsSettings = JSCodeStyleSettings.getSettings(file);
boolean addWhiteSpaceBetweenBraces = jsSettings.SPACES_WITHIN_INTERPOLATION_EXPRESSIONS;
int offset = editor.getCaretModel().getOffset();
String chars = document.getText();
if (offset > 0 && (chars.charAt(offset - 1)) == '{') {
if (offset < 2 || (chars.charAt(offset - 2)) != '{') {
if (alreadyHasEnding(chars, offset)) {
return Result.CONTINUE;
} else {
String interpolation = addWhiteSpaceBetweenBraces ? "{ }" : "{}";
if (offset == chars.length() || (offset < chars.length() && chars.charAt(offset) != '}')) {
interpolation += "}";
}
EditorModificationUtil.insertStringAtCaret(editor, interpolation, true, addWhiteSpaceBetweenBraces ? 2 : 1);
return Result.STOP;
}
}
}
}
if (c == '}') {
if (!AngularJSBracesUtil.DEFAULT_END.equals(AngularJSBracesUtil.getInjectionEnd(project)))
return Result.CONTINUE;
final int offset = editor.getCaretModel().getOffset();
final char charAt;
if (offset < document.getTextLength()) {
charAt = document.getCharsSequence().charAt(offset);
if (charAt == '}') {
editor.getCaretModel().moveCaretRelatively(1, 0, false, false, true);
return Result.STOP;
}
} else if (offset > 0) {
charAt = document.getCharsSequence().charAt(offset - 1);
if (charAt != '}') {
EditorModificationUtil.insertStringAtCaret(editor, "}}", true, 2);
return Result.STOP;
}
}
}
}
return Result.CONTINUE;
}
use of com.intellij.lang.javascript.formatter.JSCodeStyleSettings in project intellij-plugins by JetBrains.
the class ActionScriptFormatterTest method testECMAScript2.
public void testECMAScript2() throws Exception {
doFileTest("");
doFileTest("_2");
final JSCodeStyleSettings codeSettings = CodeStyleSettingsManager.getSettings(getProject()).getCustomSettings(ECMA4CodeStyleSettings.class);
codeSettings.INDENT_PACKAGE_CHILDREN = JSCodeStyleSettings.INDENT;
doFileTest("_3");
}
Aggregations