本文整理汇总了Java中com.intellij.psi.codeStyle.CodeStyleSettings类的典型用法代码示例。如果您正苦于以下问题:Java CodeStyleSettings类的具体用法?Java CodeStyleSettings怎么用?Java CodeStyleSettings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CodeStyleSettings类属于com.intellij.psi.codeStyle包,在下文中一共展示了CodeStyleSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createModel
import com.intellij.psi.codeStyle.CodeStyleSettings; //导入依赖的package包/类
@NotNull
@Override
public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
final Block impexBlock = new ImpexBlock(
element.getNode(),
null,
Alignment.createAlignment(),
createSpaceBuilder(settings)
);
return FormattingModelProvider.createFormattingModelForPsiFile(
element.getContainingFile(),
impexBlock,
settings
);
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:18,代码来源:ImpexFormattingModelBuilder.java
示例2: createModel
import com.intellij.psi.codeStyle.CodeStyleSettings; //导入依赖的package包/类
@NotNull
@Override
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
ASTNode root = CsvFormatHelper.getRoot(element.getNode());
CsvFormattingInfo formattingInfo = new CsvFormattingInfo(
settings,
CsvFormatHelper.createSpaceBuilder(settings),
CsvFormatHelper.createColumnInfoMap(root, settings)
);
return FormattingModelProvider.createFormattingModelForPsiFile(
element.getContainingFile(),
new CsvBlock(root, formattingInfo),
settings
);
}
示例3: createColumnInfoMap
import com.intellij.psi.codeStyle.CodeStyleSettings; //导入依赖的package包/类
public static Map<Integer, CsvColumnInfo<ASTNode>> createColumnInfoMap(ASTNode root, CodeStyleSettings settings) {
Map<Integer, CsvColumnInfo<ASTNode>> columnInfoMap = new HashMap<>();
ASTNode child = root.getFirstChildNode();
while (child != null) {
if (child.getElementType() == CsvTypes.RECORD) {
Integer column = 0;
ASTNode subChild = child.getFirstChildNode();
while (subChild != null) {
if (subChild.getElementType() == CsvTypes.FIELD) {
int length = getTextLength(subChild, settings);
if (!columnInfoMap.containsKey(column)) {
columnInfoMap.put(column, new CsvColumnInfo(column, length));
} else if (columnInfoMap.get(column).getMaxLength() < length) {
columnInfoMap.get(column).setMaxLength(length);
}
columnInfoMap.get(column).addElement(subChild);
++column;
}
subChild = subChild.getTreeNext();
}
}
child = child.getTreeNext();
}
return columnInfoMap;
}
示例4: getSpacing
import com.intellij.psi.codeStyle.CodeStyleSettings; //导入依赖的package包/类
private static Spacing getSpacing(ASTNode node, CodeStyleSettings settings) {
LuaSpacingProcessor spacingProcessor = mySharedProcessorAllocator.get();
try {
if (spacingProcessor == null) {
spacingProcessor = new LuaSpacingProcessor(new MyLuaSpacingVisitor(node, settings));
mySharedProcessorAllocator.set(spacingProcessor);
} else {
spacingProcessor.setVisitor(new MyLuaSpacingVisitor(node, settings));
}
spacingProcessor.doInit();
return spacingProcessor.getResult();
}
catch (Exception e) {
LOG.error(e);
return null;
}
finally {
spacingProcessor.clear();
}
}
示例5: generateForBinaryExpr
import com.intellij.psi.codeStyle.CodeStyleSettings; //导入依赖的package包/类
/**
* Generates blocks for binary expressions
*
* @param node
* @return
*/
private static List<Block> generateForBinaryExpr(final ASTNode node, Wrap myWrap, CodeStyleSettings mySettings) {
final ArrayList<Block> subBlocks = new ArrayList<Block>();
Alignment alignment = mySettings.ALIGN_MULTILINE_BINARY_OPERATION ? Alignment.createAlignment() : null;
LuaBinaryExpression myExpr = (LuaBinaryExpression) node.getPsi();
ASTNode[] children = node.getChildren(null);
if (myExpr.getLeftExpression() instanceof LuaBinaryExpression) {
addBinaryChildrenRecursively(myExpr.getLeftExpression(), subBlocks, Indent.getContinuationWithoutFirstIndent(), alignment, myWrap, mySettings);
}
for (ASTNode childNode : children) {
if (canBeCorrectBlock(childNode) &&
!(childNode.getPsi() instanceof LuaBinaryExpression)) {
subBlocks.add(new LuaFormattingBlock(childNode, alignment, Indent.getContinuationWithoutFirstIndent(), myWrap, mySettings));
}
}
if (myExpr.getRightExpression() instanceof LuaBinaryExpression) {
addBinaryChildrenRecursively(myExpr.getRightExpression(), subBlocks, Indent.getContinuationWithoutFirstIndent(), alignment, myWrap, mySettings);
}
return subBlocks;
}
示例6: addBinaryChildrenRecursively
import com.intellij.psi.codeStyle.CodeStyleSettings; //导入依赖的package包/类
/**
* Adds all children of specified element to given list
*
* @param elem
* @param list
* @param indent
* @param alignment
*/
private static void addBinaryChildrenRecursively(PsiElement elem,
List<Block> list,
Indent indent,
Alignment alignment, Wrap myWrap, CodeStyleSettings mySettings) {
if (elem == null) return;
ASTNode[] children = elem.getNode().getChildren(null);
// For binary expressions
if ((elem instanceof LuaBinaryExpression)) {
LuaBinaryExpression myExpr = ((LuaBinaryExpression) elem);
if (myExpr.getLeftExpression() instanceof LuaBinaryExpression) {
addBinaryChildrenRecursively(myExpr.getLeftExpression(), list, Indent.getContinuationWithoutFirstIndent(), alignment, myWrap, mySettings);
}
for (ASTNode childNode : children) {
if (canBeCorrectBlock(childNode) &&
!(childNode.getPsi() instanceof LuaBinaryExpression)) {
list.add(new LuaFormattingBlock(childNode, alignment, indent, myWrap, mySettings));
}
}
if (myExpr.getRightExpression() instanceof LuaBinaryExpression) {
addBinaryChildrenRecursively(myExpr.getRightExpression(), list, Indent.getContinuationWithoutFirstIndent(), alignment, myWrap, mySettings);
}
}
}
示例7: testCommentAfterDeclaration
import com.intellij.psi.codeStyle.CodeStyleSettings; //导入依赖的package包/类
public void testCommentAfterDeclaration() throws Exception {
CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject());
CommonCodeStyleSettings javaSettings = codeStyleSettings.getCommonSettings(JavaLanguage.INSTANCE);
int oldMargin = codeStyleSettings.getDefaultRightMargin();
int oldWrap = javaSettings.ASSIGNMENT_WRAP;
try {
codeStyleSettings.setDefaultRightMargin(20);
javaSettings.ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
doMethodTest(
"int i=0; //comment comment",
"int i =\n" +
" 0; //comment comment"
);
}
finally {
codeStyleSettings.setDefaultRightMargin(oldMargin);
javaSettings.ASSIGNMENT_WRAP = oldWrap;
}
}
示例8: doProcess
import com.intellij.psi.codeStyle.CodeStyleSettings; //导入依赖的package包/类
@NotNull
private static TextRange doProcess(@NotNull PsiElement source, @NotNull TextRange range, @NotNull CodeStyleSettings settings) {
ASTNode node = source.getNode();
if (node == null) {
return range;
}
Language language = source.getLanguage();
if (language != JavaLanguage.INSTANCE) {
// We had the only complaint for tabs not being converted to spaces for now. It was for the java code which has
// a single block for the multi-line comment. This check should be removed if it is decided to generalize
// this logic to other languages as well.
return range;
}
if (!source.isValid()) return range;
PsiFile file = source.getContainingFile();
CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptionsByFile(file, range);
boolean useTabs = indentOptions.USE_TAB_CHARACTER;
boolean smartTabs = indentOptions.SMART_TABS;
int tabWidth = indentOptions.TAB_SIZE;
return processViaPsi(node, range, new TreeHelperImpl(), useTabs, smartTabs, tabWidth);
}
示例9: apply
import com.intellij.psi.codeStyle.CodeStyleSettings; //导入依赖的package包/类
@Override
public void apply(CodeStyleSettings settings) {
settings.LINE_SEPARATOR = getSelectedLineSeparator();
settings.setDefaultRightMargin(getRightMargin());
settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = myCbWrapWhenTypingReachesRightMargin.isSelected();
settings.FORMATTER_TAGS_ENABLED = myEnableFormatterTags.isSelected();
settings.FORMATTER_TAGS_ACCEPT_REGEXP = myAcceptRegularExpressionsCheckBox.isSelected();
settings.FORMATTER_OFF_TAG = getTagText(myFormatterOffTagField, settings.FORMATTER_OFF_TAG);
settings.setFormatterOffPattern(compilePattern(settings, myFormatterOffTagField, settings.FORMATTER_OFF_TAG));
settings.FORMATTER_ON_TAG = getTagText(myFormatterOnTagField, settings.FORMATTER_ON_TAG);
settings.setFormatterOnPattern(compilePattern(settings, myFormatterOnTagField, settings.FORMATTER_ON_TAG));
settings.AUTODETECT_INDENTS = myAutodetectIndentsBox.isSelected();
if (myShowDetectedIndentNotification.isEnabled()) {
FileIndentOptionsProvider.setShowNotification(myShowDetectedIndentNotification.isSelected());
}
for (GeneralCodeStyleOptionsProvider option : myAdditionalOptions) {
option.apply(settings);
}
}
示例10: testLastLineIndent
import com.intellij.psi.codeStyle.CodeStyleSettings; //导入依赖的package包/类
public void testLastLineIndent() throws Exception{
final String initialText = "a\n";
final TestFormattingModel model = new TestFormattingModel(initialText);
model.setRootBlock(new FormattingModelXmlReader(model).readTestBlock("lineIndent"));
final CommonCodeStyleSettings.IndentOptions indentOptions = new CommonCodeStyleSettings.IndentOptions();
indentOptions.CONTINUATION_INDENT_SIZE = 8;
indentOptions.INDENT_SIZE = 4;
indentOptions.LABEL_INDENT_SIZE = 1;
final CodeStyleSettings settings = new CodeStyleSettings(false);
settings.setDefaultRightMargin(myRightMargin);
try {
FormatterEx.getInstanceEx().adjustLineIndent(model, settings, indentOptions, initialText.length() - 1, new TextRange(0, initialText.length()));
}
catch (IncorrectOperationException e) {
fail();
}
assertEquals("a\n ", FormatterImpl.getText(model));
}
示例11: sortItemsAccordingToSettings
import com.intellij.psi.codeStyle.CodeStyleSettings; //导入依赖的package包/类
public static List<Pair<String, Boolean>> sortItemsAccordingToSettings(List<Pair<String, Boolean>> names, final CodeStyleSettings settings) {
int[] entryForName = ArrayUtil.newIntArray(names.size());
PackageEntry[] entries = settings.IMPORT_LAYOUT_TABLE.getEntries();
for(int i = 0; i < names.size(); i++){
Pair<String, Boolean> pair = names.get(i);
String packageName = pair.getFirst();
Boolean isStatic = pair.getSecond();
entryForName[i] = findEntryIndex(packageName, isStatic, entries);
}
List<Pair<String, Boolean>> resultList = new ArrayList<Pair<String, Boolean>>(names.size());
for(int i = 0; i < entries.length; i++){
for(int j = 0; j < names.size(); j++){
if (entryForName[j] == i){
resultList.add(names.get(j));
names.set(j, null);
}
}
}
for (Pair<String, Boolean> name : names) {
if (name != null) resultList.add(name);
}
return resultList;
}
示例12: getCodeStyleIntent
import com.intellij.psi.codeStyle.CodeStyleSettings; //导入依赖的package包/类
@NotNull
public static String getCodeStyleIntent(InsertionContext insertionContext) {
final CodeStyleSettings currentSettings =
CodeStyleSettingsManager.getSettings(insertionContext.getProject());
final CommonCodeStyleSettings.IndentOptions indentOptions =
currentSettings.getIndentOptions(insertionContext.getFile().getFileType());
return indentOptions.USE_TAB_CHARACTER ?
"\t" :
StringUtil.repeatSymbol(' ', indentOptions.INDENT_SIZE);
}
示例13: AppleScriptBlock
import com.intellij.psi.codeStyle.CodeStyleSettings; //导入依赖的package包/类
AppleScriptBlock(ASTNode node, @Nullable Wrap wrap, @Nullable Alignment alignment, CodeStyleSettings settings) {
super(node, wrap, alignment);
mySettings = settings;
myIndentProcessor = new AppleScriptIndentProcessor(settings.getCommonSettings(AppleScriptLanguage.INSTANCE));
myIndent = myIndentProcessor.getChildIndent(myNode);
mySpacingProcessor = new AppleScriptSpacingProcessor(node, settings.getCommonSettings(AppleScriptLanguage.INSTANCE));
myWrappingProcessor = new AppleScriptWrappingProcessor(node, settings.getCommonSettings(AppleScriptLanguage.INSTANCE));
}
示例14: createModel
import com.intellij.psi.codeStyle.CodeStyleSettings; //导入依赖的package包/类
@NotNull
@Override
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
PsiFile containingFile = element.getContainingFile().getViewProvider().getPsi(AppleScriptLanguage.INSTANCE);
assert containingFile != null : element.getContainingFile();
ASTNode astNode = containingFile.getNode();
assert astNode != null;
CommonCodeStyleSettings appleScriptSettings = settings.getCommonSettings(AppleScriptLanguage.INSTANCE);
final AppleScriptBlock rootBlock = new AppleScriptBlock(astNode, null, null, settings);
return new AppleScriptFormattingModel(containingFile, rootBlock, FormattingDocumentModelImpl.createOn(containingFile));
}
示例15: createTemplateLanguageBlock
import com.intellij.psi.codeStyle.CodeStyleSettings; //导入依赖的package包/类
@Override
public TemplateLanguageBlock createTemplateLanguageBlock(
@NotNull ASTNode node,
@Nullable Wrap wrap,
@Nullable Alignment alignment,
@Nullable List<DataLanguageBlockWrapper> foreignChildren,
@NotNull CodeStyleSettings codeStyleSettings) {
final FormattingDocumentModelImpl documentModel =
FormattingDocumentModelImpl.createOn(node.getPsi().getContainingFile());
if (node.getPsi() instanceof TagElement) {
return new SoyTagBlock(
this,
codeStyleSettings,
node,
foreignChildren,
new HtmlPolicy(codeStyleSettings, documentModel));
} else if(node.getPsi() instanceof TagBlockElement) {
return new SoyTagBlockBlock(
this,
codeStyleSettings,
node,
foreignChildren,
new HtmlPolicy(codeStyleSettings, documentModel));
} else if (node.getPsi() instanceof SoyStatementList) {
return new SoyStatementListBlock(
this,
codeStyleSettings,
node,
foreignChildren,
new HtmlPolicy(codeStyleSettings, documentModel));
} else {
return new SoyBlock(
this,
codeStyleSettings,
node,
foreignChildren,
new HtmlPolicy(codeStyleSettings, documentModel));
}
}