Commit Graph
275 Commits
Author SHA1 Message Date
José Valim 7b73407af8 Respect line breaks after =
Many editors use indentation for collapsing
so folks may want to use `var =` followed by
new line to collapse. This PR makes it possible
and aligns `=` with other operators.
2023-01-04 12:06:58 +01:00
José Valim 3186819506 Apply rearrange ops only inside parens, closes #12296 2022-12-10 19:27:26 +01:00
sabiwara 7ebfcc7de9 Fix formatter error on nested do without parenthesis (#12274) 2022-11-27 15:15:18 +01:00
José Valim ef5916bb67 Refactor and normalize format 2022-10-27 23:29:09 +02:00
José Valim 8f57c0ed1b Update notes on | 2022-10-25 10:36:40 +02:00
José Valim 0a1a5991d9 Remove unecessary parens in nullary type funs 2022-10-14 13:55:23 +02:00
José Valim 9fb3cf6030 Fix ambiguity in &INT with brackets 2022-10-08 10:52:37 +02:00
José Valim 9aca91ce06 Improve error message for too many arguments in access 2022-09-27 17:51:23 +02:00
José Valim 29ed6925b3 Warn for nested calls without parens inside keywords 2022-09-24 16:50:07 +02:00
José Valim 3ee1e83eef Remove parser ambiguity within stepped ranges 2022-09-10 00:32:13 +02:00
José Valim f97d8585e8 Deprecate ... as a valid function call identifier 2022-08-15 15:10:54 +02:00
José Valim df64d5c6a1 Change import metadata to imports as a list
This is preparation to better ambiguity solving
of quoted expressions.
2022-05-08 17:00:09 +02:00
José Valim d93577ecfa Clarify what the correct xor precedence should have been 2022-04-16 13:50:35 +02:00
José Valim b52f274406 Add .. as a nullary operator that returns 0..-1//1 (#11623) 2022-02-13 15:18:53 +01:00
Michał Łępicki 9e898f8b5a Remove references to HiPE (#11543)
* Fix typo in Dialyzer CI step name

* Remove references to HiPE
2022-01-05 13:37:17 +01:00
José Valim 8c2ec72875 Do not emit warnings on Cursor.Fragment.container_cursor_to_quoted/2 2021-12-16 16:13:39 +01:00
José Valim acbc04a902 Warn on trailing commas on calls, closes #11399 2021-11-19 11:46:46 +01:00
José Valim 65ab34224f Include column in warnings emitted by compiler (#11339)
We also extend Mix.Tasks.Compiler.Diagnostic
to include {line, column} as possible position.
We also explicitly document the behaviour of
line=0, which is equivalent to unknown line.
Elixir was already setting the line to zero in
multiple occasions prior to this patch, so this
patch makes it official and we stop returning `nil`
for said cases.
2021-10-24 16:28:36 +02:00
José Valim f2bd03273f Include column in more errors whenever possible 2021-10-24 15:58:19 +02:00
José Valim e480151fe7 Add Code.Fragment.container_cursor_to_quoted/2 (#11315) 2021-10-16 15:12:09 +02:00
José Valim 7a9a00d9e2 Add power operator (#11241) 2021-09-14 11:08:34 +02:00
José Valim 1789c1eb9b Handle OP/ARITY syntax more consistently 2021-08-27 21:39:14 +02:00
Dorgan 1c8ba7489d Preserve heredoc indentation metadata (#11128) 2021-07-20 08:16:21 +02:00
Dorgan 41dd2ab9f4 Add more token metadata to aliases and remote calls (#11038) 2021-06-05 19:22:40 +02:00
José Valim b44bbe536c Do not assume that literals in blocks have been normalized 2021-05-27 13:15:46 +02:00
José Valim effa61ac96 Improve error message for expression after keyword
For maps and lists:

    $ elixir -e "%{foo: :bar, :baz => :bat}"
    ** (SyntaxError) nofile:1: unexpected expression after keyword list. Keyword lists must always come last in lists and maps. Therefore, this is not allowed:

        [some: :value, :another]
        %{some: :value, another => value}

    Instead, reorder it to be the last entry:

        [:another, some: :value]
        %{another => value, some: :value}

    Syntax error after: ','
        (elixir 1.13.0-dev) lib/code.ex:655: Code.eval_string_with_error_handling/3

For calls:

    $ elixir -e "call foo: :bar, :baz"
    ** (SyntaxError) nofile:1: unexpected expression after keyword list. Keyword lists must always come as the last argument. Therefore, this is not allowed:

        function_call(1, some: :option, 2)

    Instead, wrap the keyword in brackets:

        function_call(1, [some: :option], 2)

    Syntax error after: ','
        (elixir 1.13.0-dev) lib/code.ex:655: Code.eval_string_with_error_handling/3

Closes #10973.
2021-05-12 13:34:06 +02:00
José Valim a1989d01f8 Respect keywords in access in code formatter 2021-05-11 12:37:52 +02:00
José Valim 6055a7eb2c Allow unquote_splicing inside maps with no parens 2021-05-04 23:59:38 +02:00
José Valim a080002de9 Improve warnings 2021-03-26 13:19:04 +01:00
José Valim b849235472 Support stepped ranges (#10810) 2021-03-25 07:32:06 +01:00
José Valim c9a171da5b Deprecate ^^^ 2021-03-23 10:23:58 +01:00
José Valim 9da5cb8b9e Rewrite not (foo in bar) to foo not in bar 2021-03-07 20:00:08 +01:00
José Valim ae3ef6732c Generalize operator completion on IEx' parser 2021-02-12 14:19:31 +01:00
Eksperimental 6944a67965 Revise use of Note and Notice verbs (#10264) 2020-08-14 07:59:34 +02:00
José Valim cd2ed7c7cf Revert "Consistently handle empty blocks"
Actually, we don't allow `-> [EMPTY]` anywhere else.

This reverts commit 00a6401f3f.
2020-06-25 12:32:07 +02:00
José Valim 00a6401f3f Consistently handle empty blocks 2020-06-24 20:48:05 +02:00
José Valim fbaba1cce1 Handle ; inside empty parens, closes #9964 2020-04-26 11:42:20 +02:00
Ivan Rublev 0ae5f4fda5 Add +++ and --- with right associativity to the list of custom operators (#9954) 2020-04-21 13:03:31 +02:00
Wojtek Mach e922211913 Use new ExDoc extras auto-links (#9912) 2020-03-27 00:05:48 +01:00
José Valim 48dc01829f Do not warn on nullary calls without parens 2020-03-12 13:11:11 +01:00
José Valim 9f50f7de7e Do not emit invalid code when formatting assocs in maps, closes #9771 2020-02-01 11:18:28 +01:00
Wojtek Mach 1303afef90 Fix bug: move :indentation from sigil meta to binary meta (#9738)
We need it there so we can retrieve it like this:

    defmacro sigil_E({:<<>>, meta, [expr]}, []) do
      options = [
        line: __CALLER__.line + 1,
        indentation: meta[:indentation] || 0
      ]

      EEx.compile_string(expr, options)
    end
2020-01-15 16:11:38 +01:00
Wojtek Mach c3752ac4df Add :indentation to sigil heredoc meta (#9725) 2020-01-14 20:45:24 +01:00
Devon Estes fc0ef36880 Always capture delimiter metadata for sigils (#9671)
This makes it so we're always capturing delimiter metadata for sigils
instead of requiring the `token_metadata` option. This means that we can
now show the correct sigils in ExUnit diffs (and elsewhere) for code
examples.
2020-01-05 16:07:58 +01:00
Eksperimental e8378b83da Replace usage of "e.g." (#9571) 2019-11-22 11:26:23 +01:00
José Valim 08d6fe8cb8 Add parens to static remote nullary calls
test/erlang/module_test.erl have also been removed
as they have been ported elsewhere.
2019-11-08 17:59:08 +01:00
José Valim 2493ff907d Remove unused funtionality and erase pdict properly 2019-10-25 15:29:46 +02:00
José Valim 8c5c466a71 Add literal encoder option to Code.string_to_quoted 2019-06-19 00:04:08 +02:00
José Valim 0803049293 Add end of expression token information
This also renames pairing_metadata to token_metadata,
as it mostly contains information about related tokens
and not necessarily pairs.
2019-06-18 00:25:22 +02:00
José Valim e7097d778a Exposing pairing metadata (#9146)
This introduces five new metadata nodes:

  * `do` - contains metadata about do location in a function call with
    `do/end` blocks
  * `end` - contains metadata about end location in a function call with
    `do/end` blocks
  * `closing` - contains metadata about the closing pair, such as a `}`
    in a tuple or in a map, or such as the closing `)` in a function call
    with parens
  * `eol` - is set to true when the opening pair, such as `{` or `(`, are
    followed by the end of the line
  * `delimiter` - contains the opening for sigils (such as `"{"`, `"/"`,
    etc)
2019-06-17 16:38:52 +02:00