public void testBracePlacement2() throws Exception {
   final CommonCodeStyleSettings settings = getSettings(DartLanguage.INSTANCE);
   settings.KEEP_LINE_BREAKS = false;
   settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
   settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
   doTest();
 }
 @Override
 public void apply(CodeStyleSettings settings) {
   CommonCodeStyleSettings commonSettings = settings.getCommonSettings(myLanguage);
   commonSettings.setArrangementSettings(createSettings());
   if (myForceArrangementPanel != null) {
     commonSettings.FORCE_REARRANGE_MODE = myForceArrangementPanel.getRearrangeMode();
   }
 }
 public void testAlignment() throws Exception {
   final CommonCodeStyleSettings settings = getSettings(DartLanguage.INSTANCE);
   settings.ALIGN_MULTILINE_PARAMETERS = true;
   settings.ALIGN_MULTILINE_BINARY_OPERATION = true;
   settings.ALIGN_MULTILINE_TERNARY_OPERATION = true;
   settings.KEEP_LINE_BREAKS = true;
   doTest();
 }
 public void apply(@NotNull CodeStyleSettings settings) {
   CommonCodeStyleSettings langSettings = settings.getCommonSettings(myLanguage);
   if (langSettings != settings) {
     if (myDefaultGeneralCheckBox.isSelected()) {
       langSettings.RIGHT_MARGIN = -1;
     } else {
       langSettings.RIGHT_MARGIN = getFieldRightMargin(settings.getDefaultRightMargin());
     }
   }
 }
 public void testSpaceLeftBraces() throws Exception {
   final CommonCodeStyleSettings settings = getSettings(DartLanguage.INSTANCE);
   settings.KEEP_LINE_BREAKS = false;
   settings.SPACE_BEFORE_METHOD_LBRACE = false;
   settings.SPACE_BEFORE_IF_LBRACE = false;
   settings.SPACE_BEFORE_ELSE_LBRACE = false;
   settings.SPACE_BEFORE_FOR_LBRACE = false;
   settings.SPACE_BEFORE_WHILE_LBRACE = false;
   settings.SPACE_BEFORE_SWITCH_LBRACE = false;
   settings.SPACE_BEFORE_TRY_LBRACE = false;
   settings.SPACE_BEFORE_CATCH_LBRACE = false;
   doTest();
 }
 public void testSpaceBeforeParentheses() throws Exception {
   final CommonCodeStyleSettings settings = getSettings(DartLanguage.INSTANCE);
   settings.KEEP_LINE_BREAKS = false;
   settings.SPACE_BEFORE_METHOD_CALL_PARENTHESES = true;
   settings.SPACE_BEFORE_METHOD_PARENTHESES = true;
   settings.SPACE_BEFORE_IF_PARENTHESES = false;
   settings.SPACE_BEFORE_FOR_PARENTHESES = false;
   settings.SPACE_BEFORE_WHILE_PARENTHESES = false;
   settings.SPACE_BEFORE_SWITCH_PARENTHESES = false;
   settings.SPACE_BEFORE_CATCH_PARENTHESES = false;
   doTest();
 }
 public void testSpaceWithin() throws Exception {
   final CommonCodeStyleSettings settings = getSettings(DartLanguage.INSTANCE);
   settings.KEEP_LINE_BREAKS = false;
   settings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = true;
   settings.SPACE_WITHIN_METHOD_PARENTHESES = true;
   settings.SPACE_WITHIN_IF_PARENTHESES = true;
   settings.SPACE_WITHIN_FOR_PARENTHESES = true;
   settings.SPACE_WITHIN_WHILE_PARENTHESES = true;
   settings.SPACE_WITHIN_SWITCH_PARENTHESES = true;
   settings.SPACE_WITHIN_CATCH_PARENTHESES = true;
   doTest();
 }
  // PY-12409
  public void testResultExceedsRightMargin() {
    final CodeStyleSettings settings = getCodeStyleSettings();
    final CommonCodeStyleSettings commonSettings =
        settings.getCommonSettings(PythonLanguage.getInstance());

    final int oldRightMargin = settings.getRightMargin(PythonLanguage.getInstance());
    final boolean oldWrapLongLines = commonSettings.WRAP_LONG_LINES;

    settings.setRightMargin(PythonLanguage.getInstance(), 80);
    commonSettings.WRAP_LONG_LINES = true;
    try {
      doTest();
    } finally {
      commonSettings.WRAP_LONG_LINES = oldWrapLongLines;
      settings.setRightMargin(PythonLanguage.getInstance(), oldRightMargin);
    }
  }
 public void testSpaceAroundOperators() throws Exception {
   final CommonCodeStyleSettings settings = getSettings(DartLanguage.INSTANCE);
   settings.KEEP_LINE_BREAKS = false;
   settings.SPACE_AROUND_ASSIGNMENT_OPERATORS = false;
   settings.SPACE_AROUND_LOGICAL_OPERATORS = false;
   settings.SPACE_AROUND_EQUALITY_OPERATORS = false;
   settings.SPACE_AROUND_RELATIONAL_OPERATORS = false;
   settings.SPACE_AROUND_ADDITIVE_OPERATORS = false;
   settings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS = false;
   doTest();
 }
 @Override
 public void importTo(@NotNull final CodeStyleSettings settings) {
   CommonCodeStyleSettings javaSettings = getJavaSettings(settings);
   if (noEmptyLinesBetweenFields) {
     javaSettings.BLANK_LINES_AROUND_FIELD = 0;
   } else if (appliesTo(TokenTypes.VARIABLE_DEF)) {
     javaSettings.BLANK_LINES_AROUND_FIELD = 1;
   }
   if (appliesTo(TokenTypes.PACKAGE_DEF)) {
     javaSettings.BLANK_LINES_AFTER_PACKAGE = 1;
   }
   if (appliesTo(TokenTypes.IMPORT)) {
     javaSettings.BLANK_LINES_AFTER_IMPORTS = 1;
   }
   if (appliesTo(TokenTypes.METHOD_DEF)) {
     javaSettings.BLANK_LINES_AROUND_METHOD = 1;
   }
 }
 public void testExpressions() throws Exception {
   final CommonCodeStyleSettings settings = getSettings(DartLanguage.INSTANCE);
   settings.RIGHT_MARGIN = 40;
   settings.KEEP_LINE_BREAKS = false; // TODO Decide whether this should be the default -- risky!
   doTest();
 }
  public static Block generateBlock(
      ASTNode node, Indent indent, Alignment alignment, CommonCodeStyleSettings styleSettings) {
    PsiElement psi = node.getPsi();
    if (psi instanceof GoBlockStatement)
      return new GoBlockStatementBlock(node, indent, styleSettings);

    if (psi instanceof GoFile) return generateGoFileBlock(node, styleSettings);

    if (psi instanceof GoPackageDeclaration) return generatePackageBlock(node, styleSettings);

    if (psi instanceof GoBinaryExpression) {
      return new GoBinaryExpressionBlock(node, alignment, NO_WRAP, styleSettings);
    }

    if (psi instanceof GoFunctionDeclaration) {
      return new GoFunctionDeclarationBlock(node, alignment, indent, styleSettings);
    }

    IElementType elementType = node.getElementType();
    if (elementType == GoTokenTypes.pLPAREN) {
      return new GoLeafBlock(node, null, indent, NO_WRAP, styleSettings);
    } else if (elementType == GoTokenTypes.pRCURLY) {
      if (node.getTreeParent().getElementType() == GoElementTypes.LITERAL_COMPOSITE_VALUE) {
        boolean inFunctionCall = false;
        ASTNode nodeParent = node;
        while (nodeParent != null) {
          if (nodeParent.getElementType() == GoElementTypes.CALL_OR_CONVERSION_EXPRESSION) {
            int indentTabSize =
                styleSettings.getIndentOptions() == null
                    ? 4
                    : styleSettings.getIndentOptions().INDENT_SIZE;
            return new GoLeafBlock(
                node, null, Indent.getSpaceIndent(indentTabSize * -1), NO_WRAP, styleSettings);
          }

          nodeParent = nodeParent.getTreeParent();
        }
      }
    } else if (elementType == GoTokenTypes.kPACKAGE || elementType == GoTokenTypes.oSEMI) {
      return new GoLeafBlock(
          node,
          null,
          Indent.getAbsoluteNoneIndent(),
          Wrap.createWrap(WrapType.NONE, false),
          styleSettings);
    } else if (GoTokenTypeSets.COMMENTS.contains(elementType)) {
      return new GoLeafBlock(
          node, alignment, indent, Wrap.createWrap(WrapType.NONE, false), styleSettings);
    } else if (ALIGN_LIST_BLOCK_STATEMENTS.contains(elementType)) {
      return new GoAssignListBlock(node, alignment, indent, styleSettings);
    } else if (elementType == GoElementTypes.TYPE_STRUCT) {
      return new GoTypeStructBlock(node, alignment, indent, styleSettings);
      //        } else if (elementType == GoElementTypes.TYPE_INTERFACE) {
      //            return new GoTypeInterfaceBlock(node, alignment, indent, styleSettings);
    } else if (elementType == GoElementTypes.EXPRESSION_LIST) {
      return new GoExpressionListBlock(node, alignment, indent, styleSettings);
    } else if (elementType == GoElementTypes.UNARY_EXPRESSION) {
      return new GoUnaryExpressionBlock(node, alignment, indent, NO_WRAP, styleSettings);
    } else if (GoElementTypes.FUNCTION_CALL_SETS.contains(elementType)) {
      return new GoCallOrConvExpressionBlock(node, alignment, indent, NO_WRAP, styleSettings);
    } else if (elementType == GoElementTypes.PARENTHESISED_EXPRESSION) {
      return new GoParenthesisedExpressionBlock(node, alignment, indent, styleSettings);
    } else if (elementType == GoElementTypes.LABELED_STATEMENT) {
      return new GoLabeledStatmentBlock(node, styleSettings);
    } else if (elementType == GoElementTypes.FUNCTION_PARAMETER_LIST) {
      return new GoFunctionParameterListBlock(node, indent, styleSettings);
    } else if (elementType == GoElementTypes.FUNCTION_PARAMETER) {
      return new GoFunctionParameterBlock(node, indent, styleSettings);
    }

    return new GoBlock(node, alignment, indent, NO_WRAP, styleSettings);
  }
 private static void useSpacesAroundAssignmentOperator(
     boolean value, Project project, Language language) {
   CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(project);
   CommonCodeStyleSettings common = settings.getCommonSettings(language);
   common.SPACE_AROUND_ASSIGNMENT_OPERATORS = value;
 }
 @Override
 public CommonCodeStyleSettings getDefaultCommonSettings() {
   CommonCodeStyleSettings commonCodeStyleSettings = new CommonCodeStyleSettings(getLanguage());
   commonCodeStyleSettings.initIndentOptions();
   return commonCodeStyleSettings;
 }
 public void testWrappingMeth() throws Exception {
   final CommonCodeStyleSettings settings = getSettings(DartLanguage.INSTANCE);
   settings.METHOD_ANNOTATION_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
   settings.METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE = true;
   settings.METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE = true;
   settings.CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
   settings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE = true;
   settings.CALL_PARAMETERS_RPAREN_ON_NEXT_LINE = true;
   settings.ELSE_ON_NEW_LINE = true;
   settings.SPECIAL_ELSE_IF_TREATMENT = true;
   settings.FOR_STATEMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
   settings.FOR_STATEMENT_LPAREN_ON_NEXT_LINE = true;
   settings.FOR_STATEMENT_RPAREN_ON_NEXT_LINE = true;
   settings.WHILE_ON_NEW_LINE = true;
   settings.CATCH_ON_NEW_LINE = true;
   settings.BINARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
   settings.BINARY_OPERATION_SIGN_ON_NEXT_LINE = true;
   settings.PARENTHESES_EXPRESSION_LPAREN_WRAP = true;
   settings.PARENTHESES_EXPRESSION_RPAREN_WRAP = true;
   settings.ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
   settings.PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE = true;
   settings.TERNARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
   settings.TERNARY_OPERATION_SIGNS_ON_NEXT_LINE = true;
   settings.BLOCK_COMMENT_AT_FIRST_COLUMN = true;
   settings.KEEP_LINE_BREAKS = true;
   doTest();
 }
 public SyntheticBlockBuilder(
     @NotNull CommonCodeStyleSettings settings, @NotNull JavaCodeStyleSettings javaSettings) {
   mySettings = settings;
   myIndentSettings = settings.getIndentOptions();
   myJavaSettings = javaSettings;
 }
 public void testFileComments() throws Exception {
   final CommonCodeStyleSettings settings = getSettings(DartLanguage.INSTANCE);
   settings.RIGHT_MARGIN = 40;
   doTest();
 }
 public void testSpaceOthers() throws Exception {
   final CommonCodeStyleSettings settings = getSettings(DartLanguage.INSTANCE);
   settings.KEEP_LINE_BREAKS = false;
   settings.SPACE_BEFORE_WHILE_KEYWORD = false;
   settings.SPACE_BEFORE_CATCH_KEYWORD = false;
   settings.SPACE_BEFORE_ELSE_KEYWORD = false;
   settings.SPACE_BEFORE_QUEST = false;
   settings.SPACE_AFTER_QUEST = false;
   settings.SPACE_BEFORE_COLON = false;
   settings.SPACE_AFTER_COLON = false;
   settings.SPACE_BEFORE_COMMA = true;
   settings.SPACE_AFTER_COMMA = false;
   settings.SPACE_BEFORE_SEMICOLON = true;
   settings.SPACE_AFTER_SEMICOLON = false;
   doTest();
 }
 public void testOddCases() throws Exception {
   final CommonCodeStyleSettings settings = getSettings(DartLanguage.INSTANCE);
   settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
   doTest();
 }