use of com.intellij.psi.codeStyle.CodeStyleSettings in project idea-handlebars by dmarcotte.
the class HbFormatterIndentTest method testFormattingInsideDoNotIndentElems1.
public void testFormattingInsideDoNotIndentElems1() {
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
settings.HTML_DO_NOT_INDENT_CHILDREN_OF = "body";
doStringBasedTest("<body>\n" + "{{#foo}}\n" + "<div></div>\n" + "{{/foo}}\n" + "</body>", "<body>\n" + "{{#foo}}\n" + " <div></div>\n" + "{{/foo}}\n" + "</body>");
}
use of com.intellij.psi.codeStyle.CodeStyleSettings in project ideavim by JetBrains.
the class ChangeGroup method indentRange.
public void indentRange(@NotNull Editor editor, @NotNull DataContext context, @NotNull TextRange range, int count, int dir) {
if (logger.isDebugEnabled()) {
logger.debug("count=" + count);
}
// API change - don't merge
Project proj = PlatformDataKeys.PROJECT.getData(context);
int tabSize = 8;
int indentSize = 8;
boolean useTabs = true;
VirtualFile file = EditorData.getVirtualFile(editor);
if (file != null) {
FileType type = FileTypeManager.getInstance().getFileTypeByFile(file);
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(proj);
tabSize = settings.getTabSize(type);
indentSize = settings.getIndentSize(type);
useTabs = settings.useTabCharacter(type);
}
int sline = editor.offsetToLogicalPosition(range.getStartOffset()).line;
int eline = editor.offsetToLogicalPosition(range.getEndOffset()).line;
if (range.isMultiple()) {
int col = editor.offsetToLogicalPosition(range.getStartOffset()).column;
int size = indentSize * count;
if (dir == 1) {
// Right shift blockwise selection
StringBuilder space = new StringBuilder();
int tabCnt = 0;
int spcCnt;
if (useTabs) {
tabCnt = size / tabSize;
spcCnt = size % tabSize;
} else {
spcCnt = size;
}
for (int i = 0; i < tabCnt; i++) {
space.append('\t');
}
for (int i = 0; i < spcCnt; i++) {
space.append(' ');
}
for (int l = sline; l <= eline; l++) {
int len = EditorHelper.getLineLength(editor, l);
if (len > col) {
LogicalPosition spos = new LogicalPosition(l, col);
insertText(editor, editor.logicalPositionToOffset(spos), space.toString());
}
}
} else {
// Left shift blockwise selection
CharSequence chars = editor.getDocument().getCharsSequence();
for (int l = sline; l <= eline; l++) {
int len = EditorHelper.getLineLength(editor, l);
if (len > col) {
LogicalPosition spos = new LogicalPosition(l, col);
LogicalPosition epos = new LogicalPosition(l, col + size - 1);
int wsoff = editor.logicalPositionToOffset(spos);
int weoff = editor.logicalPositionToOffset(epos);
int pos;
for (pos = wsoff; pos <= weoff; pos++) {
if (CharacterHelper.charType(chars.charAt(pos), false) != CharacterHelper.CharacterType.WHITESPACE) {
break;
}
}
if (pos > wsoff) {
deleteText(editor, new TextRange(wsoff, pos), null);
}
}
}
}
} else {
// Shift non-blockwise selection
for (int l = sline; l <= eline; l++) {
int soff = EditorHelper.getLineStartOffset(editor, l);
int eoff = EditorHelper.getLineEndOffset(editor, l, true);
int woff = VimPlugin.getMotion().moveCaretToLineStartSkipLeading(editor, l);
int col = editor.offsetToVisualPosition(woff).column;
int newCol = Math.max(0, col + dir * indentSize * count);
if (col > 0 || soff != eoff) {
StringBuilder space = new StringBuilder();
int tabCnt = 0;
int spcCnt;
if (useTabs) {
tabCnt = newCol / tabSize;
spcCnt = newCol % tabSize;
} else {
spcCnt = newCol;
}
for (int i = 0; i < tabCnt; i++) {
space.append('\t');
}
for (int i = 0; i < spcCnt; i++) {
space.append(' ');
}
replaceText(editor, soff, woff, space.toString());
}
}
}
if (!CommandState.inInsertMode(editor)) {
if (!range.isMultiple()) {
MotionGroup.moveCaret(editor, VimPlugin.getMotion().moveCaretToLineStartSkipLeading(editor, sline));
} else {
MotionGroup.moveCaret(editor, range.getStartOffset());
}
}
EditorData.setLastColumn(editor, editor.getCaretModel().getVisualPosition().column);
}
use of com.intellij.psi.codeStyle.CodeStyleSettings in project android by JetBrains.
the class GradleSpecificInitializer method run.
@Override
public void run() {
setUpNewProjectActions();
setUpWelcomeScreenActions();
replaceProjectPopupActions();
checkInstallPath();
ActionManager actionManager = ActionManager.getInstance();
// "Configure Plugins..." Not sure why it's called StartupWizard.
AnAction pluginAction = actionManager.getAction("StartupWizard");
// Never applicable in the context of android studio, so just set to invisible.
pluginAction.getTemplatePresentation().setVisible(false);
if (AndroidSdkUtils.isAndroidSdkManagerEnabled()) {
try {
// Setup JDK and Android SDK if necessary
setupSdks();
checkAndroidSdkHome();
} catch (Exception e) {
LOG.error("Unexpected error while setting up SDKs: ", e);
}
checkAndSetAndroidSdkSources();
}
registerAppClosing();
// Always reset the Default scheme to match Android standards
// User modifications won't be lost since they are made in a separate scheme (copied off of this default scheme)
CodeStyleScheme scheme = CodeStyleSchemes.getInstance().getDefaultScheme();
if (scheme != null) {
CodeStyleSettings settings = scheme.getCodeStyleSettings();
if (settings != null) {
AndroidCodeStyleSettingsModifier.modify(settings);
}
}
}
use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-plugins by JetBrains.
the class FlexCssCompletionTest method setUp.
@Override
protected void setUp() throws Exception {
VfsRootAccess.allowRootAccess(getTestRootDisposable(), urlToPath(convertFromUrl(FlexSchemaHandler.class.getResource("z.xsd"))), urlToPath(convertFromUrl(FlexStylesIndexableSetContributor.class.getResource("FlexStyles.as"))));
super.setUp();
myAfterCommitRunnable = null;
CodeStyleSettings globalSettings = CodeStyleSettingsManager.getSettings(getProject());
CssCodeStyleSettings settings = globalSettings.getCustomSettings(CssCodeStyleSettings.class);
settings.SPACE_AFTER_COLON = false;
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
}
use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-plugins by JetBrains.
the class CfmlFormatterTest method setTestStyleSettings.
private void setTestStyleSettings() {
Project project = getProject();
CodeStyleSettings currSettings = CodeStyleSettingsManager.getSettings(project);
Assert.assertNotNull(currSettings);
CodeStyleSettings tempSettings = currSettings.clone();
CodeStyleSettings.IndentOptions indentOptions = tempSettings.getIndentOptions(CfmlFileType.INSTANCE);
Assert.assertNotNull(indentOptions);
defineStyleSettings(tempSettings);
CodeStyleSettingsManager.getInstance(project).setTemporarySettings(tempSettings);
}
Aggregations