Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Formatter #724

Merged
merged 152 commits into from Jul 8, 2017
Merged

Code Formatter #724

merged 152 commits into from Jul 8, 2017

Commits on Jul 7, 2017

  1. Copy the full SHA
    ee40dc9 View commit details
    Browse the repository at this point in the history
  2. Space around =

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    3907f3f View commit details
    Browse the repository at this point in the history
  3. Space around <- and \\

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    2e1c805 View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    4d1a6c3 View commit details
    Browse the repository at this point in the history
  5. Copy the full SHA
    3f5cc20 View commit details
    Browse the repository at this point in the history
  6. Treat SIGNIFICANT_WHITE_SPACE as whitespace

    Don't build a Block for SIGNIFICANT_WHITE_SPACE ASTNodes since
    Whitespace class will consume them.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    37b9ccb View commit details
    Browse the repository at this point in the history
  7. Copy the full SHA
    6f38fb4 View commit details
    Browse the repository at this point in the history
  8. Copy the full SHA
    46cbda5 View commit details
    Browse the repository at this point in the history
  9. Separate not from other unary operators

    `not` must be a separate token (NOT_OPERATOR) from the symbolic unary
    operators (UNARY_OPERATOR) as the symbolic operators in most styles have
    no space around them, but `not`, being a word, requires a space so that
    it doesn't merge with its argument to form an IDENTIFIER.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    f11c05b View commit details
    Browse the repository at this point in the history
  10. Flatten END_OF_EXPRESSION to separate COMMENTs

    END_OF_EXPRESSION was being treated as an EOL if its first child was an
    EOL, but this was a bug because I forgot that it could include COMMENT
    interleaved with EOL because COMMENT never appears in Elixir.bnf, which
    was using to make Block.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    d32a759 View commit details
    Browse the repository at this point in the history
  11. Copy the full SHA
    e8fb1e7 View commit details
    Browse the repository at this point in the history
  12. Copy the full SHA
    117ff76 View commit details
    Browse the repository at this point in the history
  13. Copy the full SHA
    9320454 View commit details
    Browse the repository at this point in the history
  14. Space after fn

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    e2cb81f View commit details
    Browse the repository at this point in the history
  15. Copy the full SHA
    159748e View commit details
    Browse the repository at this point in the history
  16. Copy the full SHA
    7f5255d View commit details
    Browse the repository at this point in the history
  17. Disable broken tests

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    97cdac0 View commit details
    Browse the repository at this point in the history
  18. Copy the full SHA
    7acf512 View commit details
    Browse the repository at this point in the history
  19. Space after &

    Allow to configure whether there is a space after capture operator, but
    prevent & before another & from being combined and forming a &&.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    948211d View commit details
    Browse the repository at this point in the history
  20. Copy the full SHA
    6a8e73a View commit details
    Browse the repository at this point in the history
  21. Spaces around when

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    856fb0a View commit details
    Browse the repository at this point in the history
  22. Copy the full SHA
    38d9c61 View commit details
    Browse the repository at this point in the history
  23. Copy the full SHA
    eb7b089 View commit details
    Browse the repository at this point in the history
  24. Space around ::

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    c3fd8c3 View commit details
    Browse the repository at this point in the history
  25. Copy the full SHA
    ea8d747 View commit details
    Browse the repository at this point in the history
  26. Space around or operators

    Space around || and ||| is customizable, but space around `or` is fixed
    to 1 space to prevent fusion with surrounding identifiers.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    de64376 View commit details
    Browse the repository at this point in the history
  27. Space around and operators

    Always 1 space around `and`.  Space around `&&` and `&&&` is
    configurable.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    b433814 View commit details
    Browse the repository at this point in the history
  28. Copy the full SHA
    9bbbb99 View commit details
    Browse the repository at this point in the history
  29. Copy the full SHA
    1bffa17 View commit details
    Browse the repository at this point in the history
  30. Copy the full SHA
    20f0348 View commit details
    Browse the repository at this point in the history
  31. Copy the full SHA
    dcf0571 View commit details
    Browse the repository at this point in the history
  32. Copy the full SHA
    c195ae7 View commit details
    Browse the repository at this point in the history
  33. Space around in

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    1ad2ccc View commit details
    Browse the repository at this point in the history
  34. Space around ^^^

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    b2226c8 View commit details
    Browse the repository at this point in the history
  35. Copy the full SHA
    aefd9fa View commit details
    Browse the repository at this point in the history
  36. No spaces by default around ..

    Separate .. from other two operators as most style guides don't have a
    space around .. when it's used as a range operator.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    7cb299e View commit details
    Browse the repository at this point in the history
  37. No space around .

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    406f5db View commit details
    Browse the repository at this point in the history
  38. No space after @

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    a16b8c1 View commit details
    Browse the repository at this point in the history
  39. Space within curly braces

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    86cc7ef View commit details
    Browse the repository at this point in the history
  40. Space within << >>

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    dcc233b View commit details
    Browse the repository at this point in the history
  41. Space within brackets

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    d6f3e70 View commit details
    Browse the repository at this point in the history
  42. Space within parentheses

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    f652905 View commit details
    Browse the repository at this point in the history
  43. Space before comma

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    5bf54e3 View commit details
    Browse the repository at this point in the history
  44. Space after comma

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    a06b415 View commit details
    Browse the repository at this point in the history
  45. Spaces around =>

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    145ea74 View commit details
    Browse the repository at this point in the history
  46. Space after after

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    ea7be3b View commit details
    Browse the repository at this point in the history
  47. Space after catch

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    9f3b794 View commit details
    Browse the repository at this point in the history
  48. Indent after else keyword

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    3920844 View commit details
    Browse the repository at this point in the history
  49. Indent before else

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    92d806c View commit details
    Browse the repository at this point in the history
  50. Space after rescue

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    b805462 View commit details
    Browse the repository at this point in the history
  51. Copy the full SHA
    5e4ea9b View commit details
    Browse the repository at this point in the history
  52. Copy the full SHA
    668c439 View commit details
    Browse the repository at this point in the history
  53. Copy the full SHA
    c91fda9 View commit details
    Browse the repository at this point in the history
  54. Copy the full SHA
    7e53da6 View commit details
    Browse the repository at this point in the history
  55. Copy the full SHA
    88d2edb View commit details
    Browse the repository at this point in the history
  56. Copy the full SHA
    6714b50 View commit details
    Browse the repository at this point in the history
  57. Copy the full SHA
    2bc1f3c View commit details
    Browse the repository at this point in the history
  58. Copy the full SHA
    f298ffa View commit details
    Browse the repository at this point in the history
  59. Copy the full SHA
    9f042f4 View commit details
    Browse the repository at this point in the history
  60. Copy the full SHA
    6e6412c View commit details
    Browse the repository at this point in the history
  61. Copy the full SHA
    33eedb5 View commit details
    Browse the repository at this point in the history
  62. Copy the full SHA
    d05113c View commit details
    Browse the repository at this point in the history
  63. Copy the full SHA
    97103c2 View commit details
    Browse the repository at this point in the history
  64. Copy the full SHA
    20e7b2d View commit details
    Browse the repository at this point in the history
  65. BlockListReducer

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    17c3af7 View commit details
    Browse the repository at this point in the history
  66. Copy the full SHA
    0e8bdfe View commit details
    Browse the repository at this point in the history
  67. CONTINUATION_INDENT_SIZE = 2

    Looking at my actual code, I use the same size for normal and
    continuation indent.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    257c7bb View commit details
    Browse the repository at this point in the history
  68. Copy the full SHA
    e747aed View commit details
    Browse the repository at this point in the history
  69. Copy the full SHA
    e8b9ed2 View commit details
    Browse the repository at this point in the history
  70. Copy the full SHA
    46ae448 View commit details
    Browse the repository at this point in the history
  71. Copy the full SHA
    db7e246 View commit details
    Browse the repository at this point in the history
  72. Copy the full SHA
    b5ea8e9 View commit details
    Browse the repository at this point in the history
  73. Copy the full SHA
    0467beb View commit details
    Browse the repository at this point in the history
  74. Copy the full SHA
    782917b View commit details
    Browse the repository at this point in the history
  75. assertFormatted

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    3c97593 View commit details
    Browse the repository at this point in the history
  76. Copy the full SHA
    5266936 View commit details
    Browse the repository at this point in the history
  77. List element indent

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    719e8f2 View commit details
    Browse the repository at this point in the history
  78. Indent comment after fn

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    5649786 View commit details
    Browse the repository at this point in the history
  79. Copy the full SHA
    6963411 View commit details
    Browse the repository at this point in the history
  80. tailWrap gets document once

    Inline getLineNumber(ASTNode), so that document is only gotten once, for
    the parent node as it will be the same for boh children.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    e1eb6e4 View commit details
    Browse the repository at this point in the history
  81. Tuple indent

    Redo list indent and do tuple indent like anonymous functions, so that
    unindenting of final argument works for tuples and lists too with the
    special handling of single argument calls with
    UNINDENTED_ONLY_ARGUMENT_TOKEN_SET.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    e4fb39a View commit details
    Browse the repository at this point in the history
  82. buildContainerChildren

    Unify buildListChildren and buildTupleChildren
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    a64593a View commit details
    Browse the repository at this point in the history
  83. Use buildContainerChildren for maps and structs

    Map handling can be vastly simplified by using LESS Alignments and
    allowing the default alignment rules to work.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    929534c View commit details
    Browse the repository at this point in the history
  84. Copy the full SHA
    cb4d36b View commit details
    Browse the repository at this point in the history
  85. Copy the full SHA
    4e26d93 View commit details
    Browse the repository at this point in the history
  86. Align two operands

    Align two operands, so that multiline concatenated strings line up on
    the left.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    313a7f1 View commit details
    Browse the repository at this point in the history
  87. Copy the full SHA
    a6fc45b View commit details
    Browse the repository at this point in the history
  88. Copy the full SHA
    6ee9eae View commit details
    Browse the repository at this point in the history
  89. Don't align line children

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    3d463d8 View commit details
    Browse the repository at this point in the history
  90. Flatten body in line.

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    a75e649 View commit details
    Browse the repository at this point in the history
  91. Flatten IDENTIFIER in calls to IDENTIFIER_TOKEN

    IDENTIFER is in grammar only so that getNameIdentifier can be called on
    the PsiElement.  It serves no purpose for formatting.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    29d2392 View commit details
    Browse the repository at this point in the history
  92. Copy the full SHA
    7fdc2d9 View commit details
    Browse the repository at this point in the history
  93. Align pipe operands

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    381c76d View commit details
    Browse the repository at this point in the history
  94. Copy the full SHA
    44dcf1a View commit details
    Browse the repository at this point in the history
  95. Align boolean operands

    So that guards don't use a continuation indent when wrapping.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    7425111 View commit details
    Browse the repository at this point in the history
  96. Unmatched Call Align Do Block To

    * Call
    * Line
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    5102d5e View commit details
    Browse the repository at this point in the history
  97. Match Operation Enforce Indent to Children

    Ensures that do block in match indents to align with start of match
    instead of line when used in an assert.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    00cc919 View commit details
    Browse the repository at this point in the history
  98. Comparison operation enforce indent to children

    Ensure that == as argument to assert has the right operand wrap and
    align with left operand of ==.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    c05cd40 View commit details
    Browse the repository at this point in the history
  99. Copy the full SHA
    bb4cd5c View commit details
    Browse the repository at this point in the history
  100. Comment Indent After Stab

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    82e4cb2 View commit details
    Browse the repository at this point in the history
  101. Treate parentheticalStab same as fn and do blocks

    Ensures that that stabs are flattened the same
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    6b31679 View commit details
    Browse the repository at this point in the history
  102. Extend buildCapturedMultiplicationOperationChildren to matched calls

    Ensures that `/` in `&NAME/ARITY` and `&QUALIFIER.NAME/ARITY` has no
    spaces around it when function reference is an argument to a call
    because the outer call is unmatched while the argument is matched.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    a6db174 View commit details
    Browse the repository at this point in the history
  103. stab->stabBody->* wrap

    Don't wrap internals of parentheses, but do wrap after do and block
    items that don't have stab operations instead of always wrapping
    stab->stabBody->*.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    b39c63d View commit details
    Browse the repository at this point in the history
  104. Copy the full SHA
    1ab1bb4 View commit details
    Browse the repository at this point in the history
  105. Comments in spec align with operands

    Comments end up being children of the `|` operator rule, so they didn't
    have the same alignment as the operands.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    1a0d907 View commit details
    Browse the repository at this point in the history
  106. Compact wrapping and alignment of multiple aliases

    Unlike tuples, only wrap when necessary in multiple aliases curly braces
    and align aliases inside curly braces instead of to the opening curly
    brace.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    bcf3d2e View commit details
    Browse the repository at this point in the history
  107. Copy the full SHA
    acb4652 View commit details
    Browse the repository at this point in the history
  108. Always wrap keys nested under keys

    Extend keyword under keywords to associations too.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    3484480 View commit details
    Browse the repository at this point in the history
  109. Copy the full SHA
    575fb7c View commit details
    Browse the repository at this point in the history
  110. Flatten endOfExpression in containers

    Interpolation is a container and it can have endOfExpression because
    inside interpolation is elixirFile, which has endOfExpression for the
    root newlines.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    eaec41d View commit details
    Browse the repository at this point in the history
  111. Compact interpolation wrapping

    For the majority of Line children mark them as WrapType.NONE, as adding
    new spaces or newlines in a string will change its meaning.  Only things
    inside interpolation or the closing curly itself will allowed to wrap,
    to prevent injection of significant spaces or newlines.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    e25f2c8 View commit details
    Browse the repository at this point in the history
  112. Flatten blockList

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    92edcda View commit details
    Browse the repository at this point in the history
  113. Copy the full SHA
    21e5c9f View commit details
    Browse the repository at this point in the history
  114. Copy the full SHA
    38152ed View commit details
    Browse the repository at this point in the history
  115. Flatten sigilModifiers

    By flattening, empty sigilModifiers can be completely removed, which is
    good because empty blocks screw up spacing.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    1eeb453 View commit details
    Browse the repository at this point in the history
  116. Remove newlines from pipelines

    Allows converting |> at end of line to |> at start of line.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    4bcba1c View commit details
    Browse the repository at this point in the history
  117. noParenthesesKeyword alignment

    Ensure that containers that are keyword values align their closing
    element to the keyword value start so that it doesn't lead to the None
    indent going all the way to the start of the noParenthesesOneArgument
    call.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    ca2a17c View commit details
    Browse the repository at this point in the history
  118. Use Indent and flattening for containers that are keyword values

    by flattening the opening and closing elements into the same block as
    the keyword key, the closing element can be indented None relative to
    the direct parent of the keyword key.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    1413d4e View commit details
    Browse the repository at this point in the history
  119. Format code

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    7e39f9f View commit details
    Browse the repository at this point in the history
  120. Copy the full SHA
    fd29bad View commit details
    Browse the repository at this point in the history
  121. Copy the full SHA
    1be4604 View commit details
    Browse the repository at this point in the history
  122. Copy the full SHA
    c35e77c View commit details
    Browse the repository at this point in the history
  123. Copy the full SHA
    1c8444c View commit details
    Browse the repository at this point in the history
  124. Structure bitString the same as tuple

    `tuple` has `containerArgument? EOL*` while `bitString` had
    `(containerArguments EOL*)?`, which lead to false parse errors for some
    keywords in tuple test cases.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    13637fe View commit details
    Browse the repository at this point in the history
  125. Format bitstrings

    No bitstrings in alembic, calcinator, or retort, so need to add
    synthetic tests based on tuple cases.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    23221a4 View commit details
    Browse the repository at this point in the history
  126. Do not indent import keywords

    The `name: arity` keyword pairs for selective `import` using `only:` or
    `except:` are always neste keywords, but the usage of `import` with the
    selective import is meant to allow for compact import, so it doesn't
    make sense to apply keyword exclusivity to import.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    3a70884 View commit details
    Browse the repository at this point in the history
  127. Do not ALWAY wrap keywords under unmatch call do:

    Ensure that `def` and `defp` one-liners remain one-liners, but the
    formatter will still show when it really needs to be manually converted
    to do block format.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    192a25e View commit details
    Browse the repository at this point in the history
  128. Search for keywords and containers at correct level in maps/structs

    When switching to use `containerValueWrap` for maps and structs, failed
    to take into account that (1) maps use both keywords and associations
    and (2) those pair collections aren't direct children of the map/struct,
    but under the mapArguments's update or construction arguments.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    9533ac0 View commit details
    Browse the repository at this point in the history
  129. Copy the full SHA
    f9c18d4 View commit details
    Browse the repository at this point in the history
  130. Copy the full SHA
    f97f820 View commit details
    Browse the repository at this point in the history
  131. Copy the full SHA
    c8279c3 View commit details
    Browse the repository at this point in the history
  132. Copy the full SHA
    1bdcc9e View commit details
    Browse the repository at this point in the history
  133. Copy the full SHA
    5941cd2 View commit details
    Browse the repository at this point in the history
  134. Copy the full SHA
    caf58cb View commit details
    Browse the repository at this point in the history
  135. Copy the full SHA
    16abd4c View commit details
    Browse the repository at this point in the history
  136. Don't build zero-length children blocks

    Empty blocks result in an error before IntelliJ IDEA 2016.3.
    SIGIL_MODIFIERS were empty blocks.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    2ebfd2d View commit details
    Browse the repository at this point in the history
  137. Don't build HeredocLinWhiteSpaceTokenBlock shorter than prefix

    It results in an zero-length effective TextRange, which makes it an
    empty block, which is in error before 2016.3.
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    25220f9 View commit details
    Browse the repository at this point in the history
  138. Disable DUMP_FORMATTING_AST

    Printing AST clogs log and slows formatting
    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    8a01288 View commit details
    Browse the repository at this point in the history
  139. Copy the full SHA
    40af1b5 View commit details
    Browse the repository at this point in the history
  140. Copy the full SHA
    1082752 View commit details
    Browse the repository at this point in the history
  141. Remove unused parameter

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    34aa759 View commit details
    Browse the repository at this point in the history
  142. Flatten nested if

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    9b82735 View commit details
    Browse the repository at this point in the history
  143. Copy the full SHA
    abbcf32 View commit details
    Browse the repository at this point in the history
  144. Remove unused parameter

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    d472145 View commit details
    Browse the repository at this point in the history
  145. Don't reassign parameter

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    87b785d View commit details
    Browse the repository at this point in the history
  146. Copy the full SHA
    889d7ac View commit details
    Browse the repository at this point in the history
  147. Combine nested ifs

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    4ade102 View commit details
    Browse the repository at this point in the history
  148. Flatten nested ifs

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    4c18571 View commit details
    Browse the repository at this point in the history
  149. Remove unused constant

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    4338fea View commit details
    Browse the repository at this point in the history
  150. Remove unused method

    KronicDeth committed Jul 7, 2017
    Copy the full SHA
    7cba506 View commit details
    Browse the repository at this point in the history
  151. Copy the full SHA
    c1630c3 View commit details
    Browse the repository at this point in the history
  152. Copy the full SHA
    f476614 View commit details
    Browse the repository at this point in the history