Java Code Examples for com.intellij.formatting.Indent#getAbsoluteNoneIndent()
The following examples show how to use
com.intellij.formatting.Indent#getAbsoluteNoneIndent() .
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: FusionIndentProcessor.java From intellij-neos with GNU General Public License v3.0 | 6 votes |
/** * @param node An ASTNode * @return The calculated indent for the given node */ public static Indent getIndent(ASTNode node) { IElementType type = node.getElementType(); Indent indent = Indent.getNoneIndent(); ASTNode parent = node.getTreeParent(); if (parent == null) { return indent; } if (TYPES_WHICH_PROVOKE_AN_INDENT.contains(parent.getElementType())) { indent = Indent.getIndent(Indent.Type.NORMAL, false, true); } if (TYPES_WHICH_DO_NOT_NEED_AN_BEGINNING_INDENT.contains(type)) { indent = Indent.getNoneIndent(); } if (TYPES_WHICH_CANNOT_GET_AN_INDENT.contains(type)) { indent = Indent.getAbsoluteNoneIndent(); } return indent; }
Example 2
Source File: ProtoFileBlock.java From protobuf-jetbrains-plugin with Apache License 2.0 | 4 votes |
@Override public Indent getIndent() { return Indent.getAbsoluteNoneIndent(); }
Example 3
Source File: HaxeIndentProcessor.java From intellij-haxe with Apache License 2.0 | 4 votes |
public Indent getChildIndent(ASTNode node) { final IElementType elementType = node.getElementType(); final ASTNode prevSibling = UsefulPsiTreeUtil.getPrevSiblingSkipWhiteSpacesAndComments(node); final IElementType prevSiblingType = prevSibling == null ? null : prevSibling.getElementType(); final ASTNode parent = node.getTreeParent(); final IElementType parentType = parent != null ? parent.getElementType() : null; final ASTNode superParent = parent == null ? null : parent.getTreeParent(); final IElementType superParentType = superParent == null ? null : superParent.getElementType(); final int braceStyle = FUNCTION_DEFINITION.contains(superParentType) ? settings.METHOD_BRACE_STYLE : settings.BRACE_STYLE; if (parent == null || parent.getTreeParent() == null) { return Indent.getNoneIndent(); } if (COMMENTS.contains(elementType)) { if (settings.KEEP_FIRST_COLUMN_COMMENT && isAtFirstColumn(node)) { return Indent.getAbsoluteNoneIndent(); } return Indent.getNormalIndent(); } if (elementType == PLCURLY || elementType == PRCURLY) { switch (braceStyle) { case CommonCodeStyleSettings.END_OF_LINE: case CommonCodeStyleSettings.NEXT_LINE: case CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED: return Indent.getNoneIndent(); case CommonCodeStyleSettings.NEXT_LINE_SHIFTED: case CommonCodeStyleSettings.NEXT_LINE_SHIFTED2: return Indent.getNormalIndent(); default: return Indent.getNoneIndent(); } } if (parentType == PARENTHESIZED_EXPRESSION) { if (elementType == PLPAREN || elementType == PRPAREN) { return Indent.getNoneIndent(); } return Indent.getNormalIndent(); } if (needIndent(parentType, elementType)) { final PsiElement psi = node.getPsi(); if (psi.getParent() instanceof PsiFile) { return Indent.getNoneIndent(); } return Indent.getNormalIndent(); } if (FUNCTION_DEFINITION.contains(parentType) || parentType == CALL_EXPRESSION) { if (elementType == PARAMETER_LIST || elementType == EXPRESSION_LIST) { return Indent.getNormalIndent(); } } if (parentType == FOR_STATEMENT && prevSiblingType == PRPAREN && elementType != BLOCK_STATEMENT) { return Indent.getNormalIndent(); } if (parentType == WHILE_STATEMENT && prevSiblingType == PRPAREN && elementType != BLOCK_STATEMENT) { return Indent.getNormalIndent(); } if (parentType == DO_WHILE_STATEMENT && prevSiblingType == KDO && elementType != BLOCK_STATEMENT) { return Indent.getNormalIndent(); } if ((parentType == RETURN_STATEMENT || parentType == RETURN_STATEMENT_WITHOUT_SEMICOLON) && prevSiblingType == KRETURN && elementType != BLOCK_STATEMENT) { return Indent.getNormalIndent(); } if (parentType == IF_STATEMENT && (prevSiblingType == PRPAREN || prevSiblingType == KELSE) && elementType != BLOCK_STATEMENT && elementType != IF_STATEMENT) { return Indent.getNormalIndent(); } return Indent.getNoneIndent(); }