use of com.intellij.psi.codeStyle.CommonCodeStyleSettings in project intellij-community by JetBrains.
the class GroovyFormattingModelBuilder method createModel.
@Override
@NotNull
public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
ASTNode node = element.getNode();
assert node != null;
PsiFile containingFile = element.getContainingFile().getViewProvider().getPsi(GroovyLanguage.INSTANCE);
assert containingFile != null : element.getContainingFile();
ASTNode astNode = containingFile.getNode();
assert astNode != null;
CommonCodeStyleSettings groovySettings = settings.getCommonSettings(GroovyLanguage.INSTANCE);
GroovyCodeStyleSettings customSettings = settings.getCustomSettings(GroovyCodeStyleSettings.class);
final AlignmentProvider alignments = new AlignmentProvider();
if (customSettings.USE_FLYING_GEESE_BRACES) {
element.accept(new PsiRecursiveElementVisitor() {
@Override
public void visitElement(PsiElement element) {
if (GeeseUtil.isClosureRBrace(element)) {
GeeseUtil.calculateRBraceAlignment(element, alignments);
} else {
super.visitElement(element);
}
}
});
}
final GroovyBlock block = new GroovyBlock(astNode, Indent.getAbsoluteNoneIndent(), null, new FormattingContext(groovySettings, alignments, customSettings, false));
return new GroovyFormattingModel(containingFile, block, FormattingDocumentModelImpl.createOn(containingFile));
}
use of com.intellij.psi.codeStyle.CommonCodeStyleSettings in project intellij-community by JetBrains.
the class PyWrapTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(myFixture.getProject()).getCurrentSettings();
final CommonCodeStyleSettings pythonSettings = settings.getCommonSettings(PythonLanguage.getInstance());
myOldWrap = settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN;
myOldMargin = pythonSettings.RIGHT_MARGIN;
settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = true;
pythonSettings.RIGHT_MARGIN = 80;
}
use of com.intellij.psi.codeStyle.CommonCodeStyleSettings in project intellij-community by JetBrains.
the class PyWrapTest method tearDown.
@Override
protected void tearDown() throws Exception {
final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(myFixture.getProject()).getCurrentSettings();
final CommonCodeStyleSettings pythonSettings = settings.getCommonSettings(PythonLanguage.getInstance());
settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = myOldWrap;
pythonSettings.RIGHT_MARGIN = myOldMargin;
super.tearDown();
}
use of com.intellij.psi.codeStyle.CommonCodeStyleSettings in project intellij-community by JetBrains.
the class PyWrapTest method testWrapRightMargin.
public void testWrapRightMargin() {
final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(myFixture.getProject()).getCurrentSettings();
final CommonCodeStyleSettings pythonSettings = settings.getCommonSettings(PythonLanguage.getInstance());
int oldValue = pythonSettings.RIGHT_MARGIN;
boolean oldMarginValue = settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN;
pythonSettings.RIGHT_MARGIN = 100;
settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = true;
try {
final String testName = "wrap/" + getTestName(true);
myFixture.configureByFile(testName + ".py");
for (int i = 0; i != 45; ++i) {
myFixture.type(' ');
}
myFixture.checkResultByFile(testName + ".after.py");
} finally {
pythonSettings.RIGHT_MARGIN = oldValue;
settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = oldMarginValue;
}
}
use of com.intellij.psi.codeStyle.CommonCodeStyleSettings in project intellij-community by JetBrains.
the class XmlLanguageCodeStyleSettingsProvider method getDefaultCommonSettings.
@Override
public CommonCodeStyleSettings getDefaultCommonSettings() {
CommonCodeStyleSettings xmlSettings = new CommonCodeStyleSettings(getLanguage());
CommonCodeStyleSettings.IndentOptions indentOptions = xmlSettings.initIndentOptions();
xmlSettings.setForceArrangeMenuAvailable(true);
// HACK [yole]
if (PlatformUtils.isRubyMine()) {
indentOptions.INDENT_SIZE = 2;
}
return xmlSettings;
}
Aggregations