Java Code Examples for com.intellij.psi.codeStyle.CommonCodeStyleSettings#NEXT_LINE_IF_WRAPPED

The following examples show how to use com.intellij.psi.codeStyle.CommonCodeStyleSettings#NEXT_LINE_IF_WRAPPED . 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: HaxeSpacingProcessor.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
private Spacing setBraceSpace(boolean needSpaceSetting,
                              @CommonCodeStyleSettings.BraceStyleConstant int braceStyleSetting,
                              TextRange textRange) {
  final int spaces = needSpaceSetting ? 1 : 0;
  if (braceStyleSetting == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED && textRange != null) {
    return Spacing.createDependentLFSpacing(spaces, spaces, textRange, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
  }
  else {
    final int lineBreaks = braceStyleSetting == CommonCodeStyleSettings.END_OF_LINE ||
                           braceStyleSetting == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED ? 0 : 1;
    return Spacing.createSpacing(spaces, spaces, lineBreaks, false, 0);
  }
}
 
Example 2
Source File: HaxeIndentProcessor.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
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();
}