Java Code Examples for com.intellij.formatting.Wrap#createWrap()
The following examples show how to use
com.intellij.formatting.Wrap#createWrap() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BuckBlock.java From Buck-IntelliJ-Plugin with Apache License 2.0 | 6 votes |
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; } }
Example 2
Source File: HaxeWrappingProcessor.java From intellij-haxe with Apache License 2.0 | 6 votes |
private static Wrap createChildWrap(ASTNode child, int parentWrap, boolean newLineAfterLBrace, boolean newLineBeforeRBrace) { IElementType childType = child.getElementType(); if (childType != PLPAREN && childType != PRPAREN) { if (FormatterUtil.isPrecededBy(child, PLBRACK)) { if (newLineAfterLBrace) { return Wrap.createChildWrap(Wrap.createWrap(parentWrap, true), WrapType.ALWAYS, true); } else { return Wrap.createWrap(WrapType.NONE, true); } } return Wrap.createWrap(WrappingUtil.getWrapType(parentWrap), true); } if (childType == PRBRACK && newLineBeforeRBrace) { return Wrap.createWrap(WrapType.ALWAYS, true); } return Wrap.createWrap(WrapType.NONE, true); }
Example 3
Source File: FormattingModelBuilder.java From protobuf-jetbrains-plugin with Apache License 2.0 | 5 votes |
@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); }
Example 4
Source File: CypherFormattingModelBuilder.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 5 votes |
@NotNull @Override public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { CypherBlock block = new CypherBlock(element.getNode(), Alignment.createAlignment(), Indent.getNoneIndent(), Wrap.createWrap(WrapType.NONE, false), settings, CypherFormattingModelBuilder.createSpacingBuilder(settings) ); return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), block, settings); }
Example 5
Source File: XQueryFormattingBlock.java From intellij-xquery with Apache License 2.0 | 5 votes |
@Override protected List<Block> buildChildren() { List<Block> blocks = new ArrayList<Block>(); ASTNode child = myNode.getFirstChildNode(); while (child != null) { if (child.getElementType() != TokenType.WHITE_SPACE && child.getTextRange().getLength() != 0) { Block block = new XQueryFormattingBlock(child, Wrap.createWrap(WrapType.NONE, false), null, settings, spacingBuilder); blocks.add(block); } child = child.getTreeNext(); } return blocks; }
Example 6
Source File: CypherBlock.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 4 votes |
@NotNull private Wrap calcWrap(@NotNull ASTNode node) { IElementType type = node.getElementType(); if (type == CypherTypes.READING_CLAUSE || type == CypherTypes.UPDATING_CLAUSE || type == CypherTypes.READING_WITH_RETURN || type == CypherTypes.RETURN || type == CypherTypes.WITH) { return Wrap.createWrap(WrapType.ALWAYS, true); } if (type == CypherTypes.K_USING) { return Wrap.createWrap(WrapType.ALWAYS, true); } if (type == CypherTypes.CALL) { return Wrap.createWrap(WrapType.ALWAYS, true); } if (type == CypherTypes.MERGE_ACTION) { return Wrap.createWrap(WrapType.ALWAYS, true); } if (isReturnBodyKeywords(node)) { return Wrap.createWrap(WrapType.ALWAYS, true); } if (type == CypherTypes.PATTERN_PART || type == CypherTypes.RELATIONSHIP_PATTERN) { return Wrap.createWrap(WrapType.CHOP_DOWN_IF_LONG, true); } if (type == CypherTypes.WHERE && TreeUtil.findParent(node, CypherTypes.LIST_COMPREHENSION) != null) { return Wrap.createWrap(WrapType.CHOP_DOWN_IF_LONG, true); } if (type == CypherTypes.WHERE) { return Wrap.createWrap(WrapType.ALWAYS, true); } if (type == CypherTypes.RETURN_ITEM) { return Wrap.createWrap(WrapType.CHOP_DOWN_IF_LONG, true); } if (type == CypherTypes.FOREACH) { return Wrap.createWrap(WrapType.ALWAYS, true); } if (type == CypherTypes.K_ELSE || type == CypherTypes.K_END) { return Wrap.createWrap(WrapType.ALWAYS, true); } if (type == CypherTypes.PROPERTY_KEY_NAME) { return Wrap.createWrap(WrapType.CHOP_DOWN_IF_LONG, true); } if (node.getTreeParent().getElementType() == CypherTypes.ARRAY && type == CypherTypes.EXPRESSION) { return Wrap.createWrap(WrapType.CHOP_DOWN_IF_LONG, true); } if (type == CypherTypes.K_AS) { return Wrap.createWrap(WrapType.CHOP_DOWN_IF_LONG, true); } return Wrap.createWrap(WrapType.NONE, false); }
Example 7
Source File: HaxeWrappingProcessor.java From intellij-haxe with Apache License 2.0 | 4 votes |
Wrap createChildWrap(ASTNode child, Wrap defaultWrap, Wrap childWrap) { final IElementType childType = child.getElementType(); final IElementType elementType = myNode.getElementType(); if (childType == OCOMMA || childType == OSEMI) return defaultWrap; // // Function definition/call // if (elementType == PARAMETER_LIST || elementType == EXPRESSION_LIST) { final ASTNode parent = myNode.getTreeParent(); if (parent == null) { return defaultWrap; } final IElementType parentType = parent.getElementType(); if (parentType == CALL_EXPRESSION && mySettings.CALL_PARAMETERS_WRAP != CommonCodeStyleSettings.DO_NOT_WRAP) { if (myNode.getFirstChildNode() == child) { return createWrap(mySettings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE); } if (!mySettings.PREFER_PARAMETERS_WRAP && childWrap != null) { return Wrap.createChildWrap(childWrap, WrappingUtil.getWrapType(mySettings.CALL_PARAMETERS_WRAP), true); } return Wrap.createWrap(WrappingUtil.getWrapType(mySettings.CALL_PARAMETERS_WRAP), true); } if (FUNCTION_DEFINITION.contains(parentType) && mySettings.METHOD_PARAMETERS_WRAP != CommonCodeStyleSettings.DO_NOT_WRAP) { if (myNode.getFirstChildNode() == child) { return createWrap(mySettings.METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE); } if (childType == PRPAREN) { return createWrap(mySettings.METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE); } return Wrap.createWrap(WrappingUtil.getWrapType(mySettings.METHOD_PARAMETERS_WRAP), true); } } if (elementType == CALL_EXPRESSION) { if (mySettings.CALL_PARAMETERS_WRAP != CommonCodeStyleSettings.DO_NOT_WRAP) { if (childType == PRPAREN) { return createWrap(mySettings.CALL_PARAMETERS_RPAREN_ON_NEXT_LINE); } } } // // If // if (elementType == IF_STATEMENT && childType == KELSE) { return createWrap(mySettings.ELSE_ON_NEW_LINE); } // //Binary expressions // if (BINARY_EXPRESSIONS.contains(elementType) && mySettings.BINARY_OPERATION_WRAP != CommonCodeStyleSettings.DO_NOT_WRAP) { if ((mySettings.BINARY_OPERATION_SIGN_ON_NEXT_LINE && BINARY_OPERATORS.contains(childType)) || (!mySettings.BINARY_OPERATION_SIGN_ON_NEXT_LINE && isRightOperand(child))) { return Wrap.createWrap(WrappingUtil.getWrapType(mySettings.BINARY_OPERATION_WRAP), true); } } // // Assignment // if (elementType == ASSIGN_EXPRESSION && mySettings.ASSIGNMENT_WRAP != CommonCodeStyleSettings.DO_NOT_WRAP) { if (childType != ASSIGN_OPERATION) { if (FormatterUtil.isPrecededBy(child, ASSIGN_OPERATION) && mySettings.PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE) { return Wrap.createWrap(WrapType.NONE, true); } return Wrap.createWrap(WrappingUtil.getWrapType(mySettings.ASSIGNMENT_WRAP), true); } else if (mySettings.PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE) { return Wrap.createWrap(WrapType.NORMAL, true); } } // // Ternary expressions // if (elementType == TERNARY_EXPRESSION) { if (myNode.getFirstChildNode() != child) { if (mySettings.TERNARY_OPERATION_SIGNS_ON_NEXT_LINE) { if (!FormatterUtil.isPrecededBy(child, OQUEST) && !FormatterUtil.isPrecededBy(child, OCOLON)) { return Wrap.createWrap(WrappingUtil.getWrapType(mySettings.TERNARY_OPERATION_WRAP), true); } } else if (childType != OQUEST && childType != OCOLON) { return Wrap.createWrap(WrappingUtil.getWrapType(mySettings.TERNARY_OPERATION_WRAP), true); } } return Wrap.createWrap(WrapType.NONE, true); } return defaultWrap; }
Example 8
Source File: HaxeWrappingProcessor.java From intellij-haxe with Apache License 2.0 | 4 votes |
private static Wrap createWrap(boolean isNormal) { return Wrap.createWrap(isNormal ? WrapType.NORMAL : WrapType.NONE, true); }
Example 9
Source File: WrappingUtil.java From consulo with Apache License 2.0 | 4 votes |
public static Wrap createWrap(int setting) { return Wrap.createWrap(getWrapType(setting), true); }