当前位置: 首页>>代码示例>>Java>>正文


Java Indent类代码示例

本文整理汇总了Java中com.intellij.formatting.Indent的典型用法代码示例。如果您正苦于以下问题:Java Indent类的具体用法?Java Indent怎么用?Java Indent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Indent类属于com.intellij.formatting包,在下文中一共展示了Indent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateForBinaryExpr

import com.intellij.formatting.Indent; //导入依赖的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;
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:26,代码来源:LuaBlockGenerator.java

示例2: addBinaryChildrenRecursively

import com.intellij.formatting.Indent; //导入依赖的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);
        }
    }
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:32,代码来源:LuaBlockGenerator.java

示例3: addNestedChildrenRecursively

import com.intellij.formatting.Indent; //导入依赖的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));
                }
            }
        }
    }
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:31,代码来源:LuaBlockGenerator.java

示例4: getIndent

import com.intellij.formatting.Indent; //导入依赖的package包/类
/**
 * @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;
}
 
开发者ID:cvette,项目名称:intellij-neos,代码行数:23,代码来源:FusionIndentProcessor.java

示例5: buildChildren

import com.intellij.formatting.Indent; //导入依赖的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;
}
 
开发者ID:protostuff,项目名称:protobuf-jetbrains-plugin,代码行数:19,代码来源:ProtoFileBlock.java

示例6: create

import com.intellij.formatting.Indent; //导入依赖的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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CallChunkBlockBuilder.java

示例7: hasNormalIndent

import com.intellij.formatting.Indent; //导入依赖的package包/类
private static boolean hasNormalIndent(Block block) {
  final TextRange range = block.getTextRange();
  final int startOffset = range.getStartOffset();

  List<Indent.Type> allIndents = getIndentOnStartOffset(block, range, startOffset);

  if (hasOnlyNormalOrNoneIndents(allIndents)) {
    int normalIndents = ContainerUtil.filter(allIndents, new Condition<Indent.Type>() {
    @Override
    public boolean value(Indent.Type type) {
      return type == Indent.Type.NORMAL;
    }
  }).size();
    return normalIndents < 2;
  }
  
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:FormatterBasedLineIndentInfoBuilder.java

示例8: hasOnlyNormalOrNoneIndents

import com.intellij.formatting.Indent; //导入依赖的package包/类
private static boolean hasOnlyNormalOrNoneIndents(List<Indent.Type> indents) {
  Indent.Type outerMostIndent = indents.get(0);
  if (outerMostIndent != Indent.Type.NONE && outerMostIndent != Indent.Type.NORMAL) {
    return false;
  }

  List<Indent.Type> innerIndents = indents.subList(1, indents.size());
  for (Indent.Type indent : innerIndents) {
    if (indent != Indent.Type.NONE && indent != Indent.Type.NORMAL 
        && indent != Indent.Type.CONTINUATION_WITHOUT_FIRST) {
      //continuation without first here because it is CONTINUATION only if it's owner is not the first child
      return false;
    }
  }

  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:FormatterBasedLineIndentInfoBuilder.java

示例9: getIndent

import com.intellij.formatting.Indent; //导入依赖的package包/类
@Override
public Indent getIndent() {
  // This is a special case - comment block that is located at the very start of the line. We don't reformat such a blocks

  ASTNode previous = myNode.getTreePrev();

  // logic taken from AbstractJavaBlock: 783

  CharSequence prevChars;
  if (previous != null && previous.getElementType() == TokenType.WHITE_SPACE && (prevChars = previous.getChars()).length() > 0
      && prevChars.charAt(prevChars.length() - 1) == '\n') {
    return Indent.getNoneIndent();
  }

  return super.getIndent();
}
 
开发者ID:SumoLogic,项目名称:epigraph,代码行数:17,代码来源:LineCommentBlock.java

示例10: visitLabeledStatement

import com.intellij.formatting.Indent; //导入依赖的package包/类
@Override
public void visitLabeledStatement(GrLabeledStatement labeledStatement) {
  if (myChildType == GroovyTokenTypes.mIDENT) {
    CommonCodeStyleSettings.IndentOptions indentOptions = myBlock.getContext().getSettings().getIndentOptions();
    if (indentOptions != null && indentOptions.LABEL_INDENT_ABSOLUTE) {
      myResult = Indent.getAbsoluteLabelIndent();
    }
    else if (!myBlock.getContext().getGroovySettings().INDENT_LABEL_BLOCKS) {
      myResult = Indent.getLabelIndent();
    }
  }
  else {
    if (myBlock.getContext().getGroovySettings().INDENT_LABEL_BLOCKS) {
      myResult = Indent.getLabelIndent();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GroovyIndentProcessor.java

示例11: visitIfStatement

import com.intellij.formatting.Indent; //导入依赖的package包/类
@Override
public void visitIfStatement(GrIfStatement ifStatement) {
  if (TokenSets.BLOCK_SET.contains(myChildType)) {
    if (myChild == ifStatement.getCondition()) {
      myResult = Indent.getContinuationWithoutFirstIndent();
    }
  }
  else if (myChild == ifStatement.getThenBranch()) {
    myResult = Indent.getNormalIndent();
  }
  else if (myChild == ifStatement.getElseBranch()) {
    if (getGroovySettings().SPECIAL_ELSE_IF_TREATMENT && myChildType == GroovyElementTypes.IF_STATEMENT) {
      myResult = Indent.getNoneIndent();
    }
    else {
      myResult = Indent.getNormalIndent();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GroovyIndentProcessor.java

示例12: getChildIndent

import com.intellij.formatting.Indent; //导入依赖的package包/类
Indent getChildIndent(final ASTNode node) {
  final IElementType elementType = node.getElementType();

  if (elementType == BLOCK_BODY || elementType == TOP_BLOCK_BODY || elementType == SCRIPT_BODY) {
    return Indent.getNormalIndent();
  }

  return Indent.getNoneIndent();
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:10,代码来源:AppleScriptIndentProcessor.java

示例13: getChildIndent

import com.intellij.formatting.Indent; //导入依赖的package包/类
@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();
  }
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:12,代码来源:SoyBlock.java

示例14: isParentStatementOrStatementContainerIndented

import com.intellij.formatting.Indent; //导入依赖的package包/类
private boolean isParentStatementOrStatementContainerIndented() {
  BlockWithParent parent = getParent();
  while (parent instanceof SoyBlock || isSynthetic(parent)) {
    if (parent instanceof SoyBlock && ((SoyBlock) parent).isStatementOrStatementContainer()) {
      return ((SoyBlock) parent).getIndent() != Indent.getNoneIndent();
    }
    parent = parent.getParent();
  }
  return false;
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:11,代码来源:SoyBlock.java

示例15: getIndent

import com.intellij.formatting.Indent; //导入依赖的package包/类
@Override
public Indent getIndent() {
    if (this.getNode().getElementType() == FlexibleSearchTypes.LEFT_DOUBLE_BRACE) {
        return Indent.getNormalIndent();
    } else if (this.getNode().getElementType() == FlexibleSearchTypes.QUERY_SPECIFICATION) {
        return Indent.getNoneIndent();
    }
    return Indent.getNoneIndent();
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:10,代码来源:FlexibleSearchBlock.java


注:本文中的com.intellij.formatting.Indent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。