本文整理汇总了Java中com.intellij.formatting.Alignment.createAlignment方法的典型用法代码示例。如果您正苦于以下问题:Java Alignment.createAlignment方法的具体用法?Java Alignment.createAlignment怎么用?Java Alignment.createAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.formatting.Alignment
的用法示例。
在下文中一共展示了Alignment.createAlignment方法的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: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: buildBlocks
import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
public List<Block> buildBlocks()
{
final Wrap wrap = Wrap.createWrap(getWrapType(myJavaSettings.ANNOTATION_PARAMETER_WRAP), false);
final Alignment alignment = myJavaSettings.ALIGN_MULTILINE_ANNOTATION_PARAMETERS ? Alignment.createAlignment() : null;
ChildrenBlocksBuilder.Config config = new ChildrenBlocksBuilder.Config().setDefaultIndent(Indent.getContinuationWithoutFirstIndent()).setIndent(JavaTokenType.RPARENTH, Indent.getNoneIndent()
).setIndent(JavaTokenType.LPARENTH, Indent.getNoneIndent())
.setDefaultWrap(wrap).setNoWrap(JavaTokenType.COMMA).setNoWrap(JavaTokenType.RPARENTH).setNoWrap(JavaTokenType.LPARENTH)
.setDefaultAlignment(alignment).setNoAlignment(JavaTokenType.COMMA).setNoAlignment(JavaTokenType.LPARENTH).setNoAlignmentIf(JavaTokenType.RPARENTH, node -> {
PsiElement prev = PsiTreeUtil.skipSiblingsBackward(node.getPsi(), PsiWhiteSpace.class);
if(prev == null)
{
return false;
}
return prev instanceof PsiNameValuePair && !PsiTreeUtil.hasErrorElements(prev);
});
return config.createBuilder().buildNodeChildBlocks(myNode, myFactory);
}
示例8: buildBlocks
import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
public List<Block> buildBlocks()
{
Wrap wrap = Wrap.createWrap(getWrapType(mySettings.ARRAY_INITIALIZER_WRAP), false);
Alignment alignment = mySettings.ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION ? Alignment.createAlignment() : null;
ChildrenBlocksBuilder.Config config = new ChildrenBlocksBuilder.Config().setDefaultIndent(Indent.getContinuationWithoutFirstIndent()).setIndent(JavaTokenType.RBRACE, Indent.getNoneIndent())
.setIndent(JavaTokenType.LBRACE, Indent.getNoneIndent())
.setDefaultWrap(wrap).setNoWrap(JavaTokenType.COMMA).setNoWrap(JavaTokenType.RBRACE).setNoWrap(JavaTokenType.LBRACE)
.setDefaultAlignment(alignment).setNoAlignment(JavaTokenType.COMMA).setNoAlignment(JavaTokenType.LBRACE).setNoAlignmentIf(JavaTokenType.RBRACE, node -> {
PsiElement prev = PsiTreeUtil.skipSiblingsBackward(node.getPsi(), PsiWhiteSpace.class);
if(prev == null)
{
return false;
}
return prev.getNode().getElementType() != JavaTokenType.COMMA;
});
return config.createBuilder().buildNodeChildBlocks(myNode, myBlockFactory);
}
示例9: createModel
import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
@NotNull
@Override
public FormattingModel createModel(
final PsiElement element, final CodeStyleSettings settings
) {
final Block block = new FlexibleSearchBlock(
element.getNode(),
null,
Alignment.createAlignment(),
createSpaceBuilder(settings)
);
return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), block, settings);
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:15,代码来源:FlexibleSearchFormattingModelBuilder.java
示例10: createModel
import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
@NotNull
@Override
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
PsiFile containingFile = element.getContainingFile().getViewProvider().getPsi(ProtoLanguage.INSTANCE);
ASTNode fileNode = containingFile.getNode();
Wrap wrap = Wrap.createWrap(WrapType.NONE, false);
Alignment alignment = Alignment.createAlignment();
ProtoFileBlock block = new ProtoFileBlock(fileNode, wrap, alignment, settings);
return FormattingModelProvider.createFormattingModelForPsiFile(containingFile, block, settings);
}
示例11: appendProtoBlocks
import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
private void appendProtoBlocks(ASTNode protoRootNode, List<Block> blocks) {
ASTNode child = protoRootNode.getFirstChildNode();
Alignment alignment = Alignment.createAlignment();
while (child != null) {
if (!FormatterUtil.containsWhiteSpacesOnly(child)) {
Block block = createBlock(child, alignment, Indent.getNoneIndent(), settings);
blocks.add(block);
}
child = child.getTreeNext();
}
}
示例12: createModel
import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
@NotNull
@Override
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
final com.amazon.ion.plugin.intellij.formatting.IonBlock rootBlock = new com.amazon.ion.plugin.intellij.formatting.IonBlock(element.getNode(),
Wrap.createWrap(WrapType.NONE, false),
Alignment.createAlignment(true),
createSpaceBuilder(settings), settings);
return FormattingModelProvider.createFormattingModelForPsiFile(
element.getContainingFile(),
rootBlock, settings);
}
示例13: buildBlocks
import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
public List<Block> buildBlocks() {
final Wrap wrap = Wrap.createWrap(getWrapType(myJavaSettings.ANNOTATION_PARAMETER_WRAP), false);
final Alignment alignment = myJavaSettings.ALIGN_MULTILINE_ANNOTATION_PARAMETERS ? Alignment.createAlignment() : null;
ChildrenBlocksBuilder.Config config = new ChildrenBlocksBuilder.Config()
.setDefaultIndent(Indent.getContinuationWithoutFirstIndent())
.setIndent(JavaTokenType.RPARENTH, Indent.getNoneIndent())
.setIndent(JavaTokenType.LPARENTH, Indent.getNoneIndent())
.setDefaultWrap(wrap)
.setNoWrap(JavaTokenType.COMMA)
.setNoWrap(JavaTokenType.RPARENTH)
.setNoWrap(JavaTokenType.LPARENTH)
.setDefaultAlignment(alignment)
.setNoAlignment(JavaTokenType.COMMA)
.setNoAlignment(JavaTokenType.LPARENTH)
.setNoAlignmentIf(JavaTokenType.RPARENTH, new Condition<ASTNode>() {
@Override
public boolean value(ASTNode node) {
PsiElement prev = PsiTreeUtil.skipSiblingsBackward(node.getPsi(), PsiWhiteSpace.class);
if (prev == null) return false;
return prev instanceof PsiNameValuePair && !PsiTreeUtil.hasErrorElements(prev);
}
});
return config.createBuilder().buildNodeChildBlocks(myNode, myFactory);
}
示例14: buildBlocks
import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
public List<Block> buildBlocks() {
Wrap wrap = Wrap.createWrap(getWrapType(mySettings.ARRAY_INITIALIZER_WRAP), false);
Alignment alignment = mySettings.ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION ? Alignment.createAlignment() : null;
ChildrenBlocksBuilder.Config config = new ChildrenBlocksBuilder.Config()
.setDefaultIndent(Indent.getContinuationWithoutFirstIndent())
.setIndent(JavaTokenType.RBRACE, Indent.getNoneIndent())
.setIndent(JavaTokenType.LBRACE, Indent.getNoneIndent())
.setDefaultWrap(wrap)
.setNoWrap(JavaTokenType.COMMA)
.setNoWrap(JavaTokenType.RBRACE)
.setNoWrap(JavaTokenType.LBRACE)
.setDefaultAlignment(alignment)
.setNoAlignment(JavaTokenType.COMMA)
.setNoAlignment(JavaTokenType.LBRACE)
.setNoAlignmentIf(JavaTokenType.RBRACE, new Condition<ASTNode>() {
@Override
public boolean value(ASTNode node) {
PsiElement prev = PsiTreeUtil.skipSiblingsBackward(node.getPsi(), PsiWhiteSpace.class);
if (prev == null) return false;
return prev.getNode().getElementType() != JavaTokenType.COMMA;
}
});
return config.createBuilder().buildNodeChildBlocks(myNode, myBlockFactory);
}
示例15: buildChildren
import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
@Override
protected List<Block> buildChildren() {
final ArrayList<Block> result = new ArrayList<Block>();
ArrayList<Block> elementsExceptKeyword = new ArrayList<Block>();
myChildAlignment = createChildAlignment();
myChildIndent = Indent.getContinuationIndent(myIndentSettings.USE_RELATIVE_INDENTS);
myUseChildAttributes = true;
Wrap childWrap = createChildWrap();
ASTNode child = myNode.getFirstChildNode();
Alignment alignment = alignList() ? Alignment.createAlignment() : null;
while (child != null) {
if (!FormatterUtil.containsWhiteSpacesOnly(child) && child.getTextLength() > 0){
if (ElementType.KEYWORD_BIT_SET.contains(child.getElementType())) {
if (!elementsExceptKeyword.isEmpty()) {
result.add(new SyntheticCodeBlock(elementsExceptKeyword, null, mySettings, Indent.getNoneIndent(), null));
elementsExceptKeyword = new ArrayList<Block>();
}
result.add(createJavaBlock(child, mySettings, myChildIndent, arrangeChildWrap(child, childWrap), alignment));
} else {
if (myAlignmentStrategy != null) {
Alignment candidate = myAlignmentStrategy.getAlignment(child.getElementType());
if (candidate != null) {
alignment = myChildAlignment = candidate;
}
}
processChild(elementsExceptKeyword, child, myChildAlignment, childWrap, myChildIndent);
}
}
child = child.getTreeNext();
}
if (!elementsExceptKeyword.isEmpty()) {
result.add(new SyntheticCodeBlock(elementsExceptKeyword, alignment, mySettings, Indent.getNoneIndent(), null));
}
return result;
}