本文整理汇总了Java中com.intellij.formatting.Alignment类的典型用法代码示例。如果您正苦于以下问题:Java Alignment类的具体用法?Java Alignment怎么用?Java Alignment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Alignment类属于com.intellij.formatting包,在下文中一共展示了Alignment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createModel
import com.intellij.formatting.Alignment; //导入依赖的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: getAlignment
import com.intellij.formatting.Alignment; //导入依赖的package包/类
@Override
public Alignment getAlignment(@NotNull final ASTNode currentNode) {
Validate.notNull(currentNode);
final Alignment alignment;
if (isNewColumn(currentNode)) {
if (columnNumber >= alignments.size()) {
alignment = Alignment.createAlignment(true, Alignment.Anchor.LEFT);
alignments.add(alignment);
} else {
alignment = alignments.get(columnNumber);
}
columnNumber++;
} else {
alignment = Alignment.createAlignment();
}
return alignment;
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:21,代码来源:ColumnsAlignmentStrategy.java
示例3: generateForBinaryExpr
import com.intellij.formatting.Alignment; //导入依赖的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;
}
示例4: addBinaryChildrenRecursively
import com.intellij.formatting.Alignment; //导入依赖的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);
}
}
}
示例5: generateForNestedExpr
import com.intellij.formatting.Alignment; //导入依赖的package包/类
/**
* Generates blocks for nested expressions like a.b.c etc.
*
* @param node
* @return
*/
private static List<Block> generateForNestedExpr(final ASTNode node, Alignment myAlignment, Wrap myWrap, CodeStyleSettings mySettings) {
final ArrayList<Block> subBlocks = new ArrayList<Block>();
ASTNode children[] = node.getChildren(null);
if (children.length > 0 && false /* NESTED.contains(children[0].getElementType()) */) {
addNestedChildrenRecursively(children[0].getPsi(), subBlocks, myAlignment, myWrap, mySettings);
} else if (canBeCorrectBlock(children[0])) {
subBlocks.add(new LuaFormattingBlock(children[0], myAlignment, Indent.getContinuationWithoutFirstIndent(), myWrap, mySettings));
}
if (children.length > 1) {
for (ASTNode childNode : children) {
if (canBeCorrectBlock(childNode) &&
children[0] != childNode) {
subBlocks.add(new LuaFormattingBlock(childNode, myAlignment, Indent.getContinuationWithoutFirstIndent(), myWrap, mySettings));
}
}
}
return subBlocks;
}
示例6: addNestedChildrenRecursively
import com.intellij.formatting.Alignment; //导入依赖的package包/类
/**
* Adds nested children for paths
*
* @param elem
* @param list
* @param myAlignment
* @param mySettings
*/
private static void addNestedChildrenRecursively(PsiElement elem,
List<Block> list, Alignment myAlignment, Wrap myWrap, CodeStyleSettings mySettings) {
ASTNode[] children = elem.getNode().getChildren(null);
// For path expressions
if (children.length > 0) {
addNestedChildrenRecursively(children[0].getPsi(), list, myAlignment, myWrap, mySettings);
} else if (canBeCorrectBlock(children[0])) {
list.add(new LuaFormattingBlock(children[0], myAlignment, Indent.getContinuationWithoutFirstIndent(), myWrap, mySettings));
}
if (children.length > 1) {
for (ASTNode childNode : children) {
if (canBeCorrectBlock(childNode) &&
children[0] != childNode) {
if (elem.getNode() != null) {
list.add(new LuaFormattingBlock(childNode, myAlignment, Indent.getContinuationWithoutFirstIndent(), myWrap, mySettings));
} else {
list.add(new LuaFormattingBlock(childNode, myAlignment, Indent.getNoneIndent(), myWrap, mySettings));
}
}
}
}
}
示例7: buildChildren
import com.intellij.formatting.Alignment; //导入依赖的package包/类
@Override
protected List<Block> buildChildren() {
List<Block> blocks = new ArrayList<>();
ASTNode child = myNode.getFirstChildNode();
while (child != null) {
if (!FormatterUtil.containsWhiteSpacesOnly(child)) {
IElementType elementType = child.getElementType();
if (ProtoParserDefinition.rule(ProtoParser.RULE_proto).equals(elementType)) {
appendProtoBlocks(child, blocks);
} else {
// Comments are not part of root rule, we have to append them separately
blocks.add(new LeafBlock(child, Alignment.createAlignment(), Indent.getNoneIndent(), settings));
}
}
child = child.getTreeNext();
}
return blocks;
}
示例8: buildChildren
import com.intellij.formatting.Alignment; //导入依赖的package包/类
@SuppressWarnings("ConstantConditions")
@Override
protected List<Block> buildChildren() {
List<Block> blocks = new ArrayList<Block>();
if (myNode.getElementType() == STRUCT) {
goDeep(blocks, myNode, myAlignment, Alignment.createAlignment(), false, pairContainers);
} else if (myNode.getElementType() == ARRAY) {
goDeep(blocks, myNode, myAlignment, Alignment.createAlignment(), false, arrayContainers);
} else if (myNode.getElementType() == EXPRESSION) {
goDeep(blocks, myNode, myAlignment, Alignment.createAlignment(), false, expressionContainers);
} else {
ASTNode child = myNode.getFirstChildNode();
while (child != null) {
if (child.getElementType() != TokenType.WHITE_SPACE) {
Block block = new IonBlock(child, Wrap.createWrap(WrapType.NORMAL, false), myAlignment, spacingBuilder, settings);
blocks.add(block);
}
child = child.getTreeNext();
}
}
return blocks;
}
示例9: buildNodeChildBlocks
import com.intellij.formatting.Alignment; //导入依赖的package包/类
public List<Block> buildNodeChildBlocks(ASTNode node, BlockFactory factory) {
List<Block> blocks = ContainerUtil.newArrayList();
for (ASTNode child : node.getChildren(null)) {
if (FormatterUtil.isWhitespaceOrEmpty(child) || child.getTextLength() == 0) {
continue;
}
Alignment alignment = myConfig.getAlignment(child);
IElementType type = child.getElementType();
Indent indent = myConfig.getIndent(type);
Wrap wrap = myConfig.getWrap(type);
blocks.add(factory.createBlock(child, indent, alignment, wrap));
}
return blocks;
}
示例10: create
import com.intellij.formatting.Alignment; //导入依赖的package包/类
@NotNull
public Block create(@NotNull final List<ASTNode> subNodes, final Wrap wrap, @Nullable final Alignment alignment) {
final ArrayList<Block> subBlocks = new ArrayList<Block>();
final ASTNode firstNode = subNodes.get(0);
if (firstNode.getElementType() == JavaTokenType.DOT) {
AlignmentStrategy strategy = AlignmentStrategy.getNullStrategy();
Block block = newJavaBlock(firstNode, mySettings, myJavaSettings, Indent.getNoneIndent(), null, strategy);
subBlocks.add(block);
subNodes.remove(0);
if (!subNodes.isEmpty()) {
subBlocks.add(create(subNodes, wrap, null));
}
return new SyntheticCodeBlock(subBlocks, alignment, mySettings, myJavaSettings, Indent.getContinuationIndent(myIndentSettings.USE_RELATIVE_INDENTS), wrap);
}
return new SyntheticCodeBlock(createJavaBlocks(subNodes), alignment, mySettings, myJavaSettings, Indent.getContinuationWithoutFirstIndent(myIndentSettings.USE_RELATIVE_INDENTS), null);
}
示例11: getAlignment
import com.intellij.formatting.Alignment; //导入依赖的package包/类
@Nullable
public Alignment getAlignment(@NotNull PsiElement e) {
final Set<PsiElement> set = myTree.get(e);
if (set == null) {
return null;
}
Alignment alignment = myAlignments.get(set);
if (alignment != null) return alignment;
Alignment.Anchor anchor = myAnchor.get(set);
if (anchor == null) {
myAnchor.put(set, Alignment.Anchor.LEFT);
anchor = Alignment.Anchor.LEFT;
}
alignment = Alignment.createAlignment(myAllowBackwardShift.get(set), anchor);
myAlignments.put(set, alignment);
return alignment;
}
示例12: buildChildren
import com.intellij.formatting.Alignment; //导入依赖的package包/类
@Override
protected List<Block> buildChildren() {
List<Block> blocks = new ArrayList<Block>();
ASTNode child = myNode.getFirstChildNode();
while (child != null) {
IElementType type = child.getElementType();
if (!TokenType.WHITE_SPACE.equals(type) && !CndTypes.CRLF.equals(type)) {
Block block = new CndBlock(child, Wrap.createWrap(WrapType.NONE, false), Alignment.createAlignment(), spacingBuilder);
blocks.add(block);
}
child = child.getTreeNext();
}
return blocks;
}
示例13: createChildAlignment
import com.intellij.formatting.Alignment; //导入依赖的package包/类
@Nullable
public static Alignment createChildAlignment(ASTNode child, ASTNode myNode, CommonCodeStyleSettings cmSettings, SquirrelCodeStyleSettings sqSettings) {
IElementType elementType = myNode.getElementType();
Alignment myBaseAlignment = Alignment.createAlignment();
if (BINARY_EXPRESSIONS.contains(elementType) && cmSettings.ALIGN_MULTILINE_BINARY_OPERATION) {
return myBaseAlignment;
}
if (elementType == TERNARY_EXPRESSION && cmSettings.ALIGN_MULTILINE_TERNARY_OPERATION) {
return myBaseAlignment;
}
if (elementType == PARAMETER_LIST) {
if (cmSettings.ALIGN_MULTILINE_PARAMETERS) {
return myBaseAlignment;
}
}
if (elementType == ARGUMENTS) {
if (cmSettings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS) {
return myBaseAlignment;
}
}
return null;
}
示例14: BuckBlock
import com.intellij.formatting.Alignment; //导入依赖的package包/类
public BuckBlock(@Nullable final BuckBlock parent,
@NotNull final ASTNode node,
@NotNull CodeStyleSettings settings,
@Nullable final Alignment alignment,
@NotNull final Indent indent,
@Nullable final Wrap wrap) {
myParent = parent;
myAlignment = alignment;
myIndent = indent;
myNode = node;
myPsiElement = node.getPsi();
myWrap = wrap;
mySettings = settings;
mySpacingBuilder = BuckFormattingModelBuilder.createSpacingBuilder(settings);
if (myPsiElement instanceof BuckArrayElements ||
myPsiElement instanceof BuckRuleBody ||
myPsiElement instanceof BuckListElements ||
myPsiElement instanceof BuckObjectElements) {
myChildWrap = Wrap.createWrap(CommonCodeStyleSettings.WRAP_ALWAYS, true);
} else {
myChildWrap = null;
}
}
示例15: create
import com.intellij.formatting.Alignment; //导入依赖的package包/类
@NotNull
public Block create(@NotNull final List<ASTNode> subNodes, final Wrap wrap, @Nullable final Alignment alignment)
{
final ArrayList<Block> subBlocks = new ArrayList<>();
final ASTNode firstNode = subNodes.get(0);
if(firstNode.getElementType() == JavaTokenType.DOT)
{
AlignmentStrategy strategy = AlignmentStrategy.getNullStrategy();
Block block = newJavaBlock(firstNode, mySettings, myJavaSettings, Indent.getNoneIndent(), null, strategy);
subBlocks.add(block);
subNodes.remove(0);
if(!subNodes.isEmpty())
{
subBlocks.add(create(subNodes, wrap, null));
}
return new SyntheticCodeBlock(subBlocks, alignment, mySettings, myJavaSettings, Indent.getContinuationIndent(myIndentSettings.USE_RELATIVE_INDENTS), wrap);
}
return new SyntheticCodeBlock(createJavaBlocks(subNodes), alignment, mySettings, myJavaSettings, Indent.getContinuationWithoutFirstIndent(myIndentSettings.USE_RELATIVE_INDENTS), null);
}