Java Code Examples for com.intellij.formatting.Indent#getNormalIndent()
The following examples show how to use
com.intellij.formatting.Indent#getNormalIndent() .
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: JSGraphQLEndpointBlock.java From js-graphql-intellij-plugin with MIT License | 6 votes |
@Override public Indent getIndent() { if (INDENT_EXCLUSIONS.contains(myNode.getElementType())) { return Indent.getNoneIndent(); } if (parent != null) { final IElementType elementType = parent.myNode.getElementType(); if (INDENT_PARENTS.contains(elementType)) { return Indent.getNormalIndent(); } } // default is no indentation return Indent.getNoneIndent(); }
Example 2
Source File: BashIndentProcessor.java From BashSupport with Apache License 2.0 | 6 votes |
/** * Calculates indent, based on code style, between parent block and child node * * @param parent parent block * @param child child node * @param prevChildNode previous child node * @return indent */ @NotNull public static Indent getChildIndent(@NotNull final BashBlock parent, @Nullable final ASTNode prevChildNode, @NotNull final ASTNode child) { ASTNode node = parent.getNode(); IElementType nodeType = node.getElementType(); PsiElement psiElement = node.getPsi(); // For Bash file if (psiElement instanceof BashFile) { return Indent.getNoneIndent(); } if (BLOCKS.contains(nodeType)) { return indentForBlock(psiElement, child); } //subshell as function body ASTNode parentNode = node.getTreeParent(); if (parentNode != null && parentNode.getElementType() == SUBSHELL_COMMAND) { if (parentNode.getTreeParent() != null && parentNode.getTreeParent().getElementType() == FUNCTION_DEF_COMMAND) { return Indent.getNormalIndent(); } } return Indent.getNoneIndent(); }
Example 3
Source File: CSharpIndentProcessor.java From consulo-csharp with Apache License 2.0 | 6 votes |
@RequiredReadAction @Nonnull public Indent getChildIndent() { IElementType elementType = myBlock.getNode().getElementType(); if(elementType == CSharpStubElements.FILE || elementType == CSharpElements.MODIFIER_LIST || elementType == CSharpElements.IF_STATEMENT || elementType == CSharpElements.TRY_STATEMENT || elementType == CSharpStubElements.MODIFIER_LIST) { return Indent.getNoneIndent(); } return Indent.getNormalIndent(); }
Example 4
Source File: SoyBlock.java From bamboo-soy with Apache License 2.0 | 5 votes |
@Override public Indent getChildIndent() { PsiElement element = myNode.getPsi(); if (element instanceof TagBlockElement) { return Indent.getNormalIndent(); } else if (myNode.getPsi() instanceof TagElement) { return Indent.getContinuationWithoutFirstIndent(); } else { return Indent.getNoneIndent(); } }
Example 5
Source File: GraphQLBlockWrapper.java From js-graphql-intellij-plugin with MIT License | 5 votes |
@Nullable @Override protected Indent getChildIndent() { if(myNode.getPsi() instanceof JSStringTemplateExpression) { // enter in a top-level block inside template indents, e.g. queries etc. return Indent.getNormalIndent(); } if(wrapped != null) { return wrapped.getChildAttributes(0).getChildIndent(); } if(parent == null) { return Indent.getNoneIndent(); } return Indent.getIndent(Indent.Type.NORMAL, false, false); }
Example 6
Source File: GraphQLBlockWrapper.java From js-graphql-intellij-plugin with MIT License | 5 votes |
@Override public Indent getIndent() { if(myNode.getPsi() instanceof JSStringTemplateExpression) { // we're a GraphQL block for a JS string template expression, so return normal indent to indent queries inside the template string return Indent.getNormalIndent(); } if(wrapped != null) { Indent indent = wrapped.getIndent(); if(indent != null) { return indent; } } return Indent.getNoneIndent(); }
Example 7
Source File: JSGraphQLEndpointBlock.java From js-graphql-intellij-plugin with MIT License | 5 votes |
@Nullable @Override protected Indent getChildIndent() { if (parent == null) { return Indent.getNoneIndent(); } if (INDENT_PARENTS.contains(myNode.getElementType())) { return Indent.getNormalIndent(); } return Indent.getNoneIndent(); }
Example 8
Source File: BuckBlock.java From Buck-IntelliJ-Plugin with Apache License 2.0 | 5 votes |
@NotNull @Override public ChildAttributes getChildAttributes(int newChildIndex) { if (hasElementType(myNode, BUCK_CONTAINERS)) { return new ChildAttributes(Indent.getNormalIndent(), null); } else if (myNode.getPsi() instanceof PsiFile) { return new ChildAttributes(Indent.getNoneIndent(), null); } else { return new ChildAttributes(null, null); } }
Example 9
Source File: BashIndentProcessor.java From BashSupport with Apache License 2.0 | 5 votes |
/** * Indent for common block * * @param psiBlock * @param child * @return */ private static Indent indentForBlock(PsiElement psiBlock, ASTNode child) { if (LEFT_CURLY.equals(child.getElementType()) || RIGHT_CURLY.equals(child.getElementType())) { return Indent.getNoneIndent(); } return Indent.getNormalIndent(); }
Example 10
Source File: XQueryFormattingBlock.java From intellij-xquery with Apache License 2.0 | 5 votes |
private Indent calculateChildIndent(IElementType type, boolean fromCalculatedType) { if (type == ENCLOSED_EXPRESSION || type == FUNCTION_DECL || (! fromCalculatedType && type == PARENTHESIZED_EXPR) || type == LET_BINDING || type == OP_ASSIGN || type == RETURN_CLAUSE || (! fromCalculatedType && type == TRY_CLAUSE) || (! fromCalculatedType && type == CATCH_CLAUSE) || type == CATCH_CLAUSE_EXPRESSION) return Indent.getNormalIndent(); return null; }
Example 11
Source File: ParentBlock.java From protobuf-jetbrains-plugin with Apache License 2.0 | 4 votes |
@Nullable @Override protected Indent getChildIndent() { return Indent.getNormalIndent(); }
Example 12
Source File: CypherBlock.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 4 votes |
@NotNull private Indent calcIndent(@NotNull ASTNode node) { IElementType parentType = this.node.getElementType(); IElementType type = node.getElementType(); if ((parentType == CypherTypes.SINGLE_PART_QUERY || parentType == CypherTypes.MULTI_PART_QUERY) && (type == CypherTypes.READING_CLAUSE || type == CypherTypes.UPDATING_CLAUSE || type == CypherTypes.READING_WITH_RETURN)) { return Indent.getNoneIndent(); } if (parentType == CypherTypes.READING_WITH_RETURN && type == CypherTypes.READING_CLAUSE) { return Indent.getNoneIndent(); } if (type == CypherTypes.READING_CLAUSE || type == CypherTypes.UPDATING_CLAUSE) { return Indent.getNormalIndent(); } if (type == CypherTypes.MERGE_ACTION) { return Indent.getNormalIndent(); } if (isReturnBodyKeywords(node)) { return Indent.getNormalIndent(); } if (type == CypherTypes.PATTERN_PART || type == CypherTypes.RELATIONSHIP_PATTERN) { return Indent.getContinuationIndent(); } if (type == CypherTypes.RETURN_ITEM) { return Indent.getContinuationIndent(); } if (type == CypherTypes.WHERE) { return Indent.getNormalIndent(); } if (parentType == CypherTypes.CASE_EXPRESSION || parentType == CypherTypes.CASE_ALTERNATIVES) { if (type == CypherTypes.K_WHEN || type == CypherTypes.K_ELSE || type == CypherTypes.K_END) { return Indent.getContinuationIndent(); } } if (type == CypherTypes.PROPERTY_KEY_NAME) { return Indent.getContinuationIndent(); } if (parentType == CypherTypes.ARRAY && type == CypherTypes.EXPRESSION) { return Indent.getContinuationIndent(); } return Indent.getNoneIndent(); }
Example 13
Source File: CSharpDisabledFormattingBlock.java From consulo-csharp with Apache License 2.0 | 4 votes |
@Nullable @Override public Indent getIndent() { return Indent.getNormalIndent(); }
Example 14
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(); }
Example 15
Source File: XQueryFormattingBlock.java From intellij-xquery with Apache License 2.0 | 4 votes |
@Override public Indent getIndent() { IElementType type = myNode.getElementType(); ASTNode parent = myNode.getTreeParent(); IElementType parentType = parent != null ? parent.getElementType() : null; IElementType prevType = getTypeOfPreviousElement(myNode); if (parent == null) return Indent.getNoneIndent(); if (isExpressionAfterBrace(type, prevType) || isExpressionAfterParenthesis(type, prevType) || isXmlChild(type) || isForOrLetBinding(parentType) || isExprInsideOfEnclosedExpr(type, parentType)) return Indent.getNormalIndent(); if (isASingleExpression()) { if (parentType == IF_EXPR) { return Indent.getNormalIndent(); } if (parentType == WHERE_CLAUSE || parentType == RETURN_CLAUSE || parentType == VAR_VALUE || parentType == ORDER_SPEC || parentType == SWITCH_RETURN_CLAUSE) { return Indent.getNormalIndent(); } } if (type == SWITCH_RETURN_CLAUSE || type == SWITCH_DEFAULT_RETURN_CLAUSE || type == TYPESWITCH_DEFAULT_RETURN_CLAUSE || type == CASE_CLAUSE || type == SWITCH_CASE_CLAUSE) { return Indent.getNormalIndent(); } if (isParamOrArgumentList(parentType) && (type != L_PAR && type != R_PAR)) { return Indent.getContinuationIndent(); } if (isChildOfSingleExpression()) { if (BIN_OPERATORS.contains(type) || BIN_OPERATORS.contains(prevType)) { return Indent.getContinuationIndent(); } if (((type == SLASH || type == SLASH_SLASH || type == RELATIVE_PATH_OPERATOR) && (prevType == STEP_EXPR)) || ((type == STEP_EXPR) && (prevType == SLASH || prevType == SLASH_SLASH || prevType == RELATIVE_PATH_OPERATOR))) { return Indent.getContinuationIndent(); } } return Indent.getNoneIndent(); }