Commit Graph
211 Commits
Author SHA1 Message Date
Eksperimental 99d919e0c8 Use "code point" instead of "codepoint" (#8774)
That's the term it is used in the Unicode standard.
2019-02-06 11:21:03 +01:00
Eksperimental 5bd907d126 Use hexadecimal notation in code points in tokenizer error msg (#8669) 2019-01-22 13:39:40 +01:00
José Valim 0ce62a2add Rely on IO.warn whenever possible 2019-01-18 14:59:20 +01:00
José Valim 0c1df34645 Standardize more TODOs 2018-12-21 13:42:54 +01:00
Eksperimental f2d1b4209b ascii -> ASCII (#8499) 2018-12-10 09:24:34 +01:00
José Valim 050f10e849 Improve message for unnecessary quotes, closes #8197 2018-09-14 22:05:23 +02:00
José Valim 95ec1be78a Clean up private elixir_config API 2018-07-19 23:27:52 +02:00
Jean-Philippe Cugnet 3b030b009e Fix a typo in the unnecessary quotes warning (#7934)
[ci skip]
2018-07-19 19:44:58 +02:00
José Valim beb596d37c Warn on unnecessary quotes (#7838) 2018-07-10 10:27:02 +02:00
José Valim 6cf3d8c20a Return error tuple for long quoted atoms 2018-07-09 10:49:38 +02:00
Adrian Cruz dd880e209c Return an error tuple for interpolation in function call (#7836) 2018-07-09 10:24:26 +02:00
José Valim 2ece95c1db Handle other unescaped tokens in tokenizer 2018-07-03 12:14:16 +02:00
Adrian Cruz 9707843134 Return error on bad hex escaping (#7809)
As discussed in #7270, it would help if we return error tuples
instead of exceptions. This PR does it for string unescaping.
2018-07-03 12:03:43 +02:00
José Valim 22245a44fe Only show mismatch hints for fn+do/end 2018-06-21 14:08:30 +02:00
José Valim 5edb1d2739 Add hints on mismatched do/end and others pairs
When you are working on large files and you add new code,
you may forget to add a `do` or an `end`. In those cases,
the error message usually points to the first `do` or the
last `end` in the file, which are usually far away from
the source of the error.

This pull request adds a simple heuristic based on the
indentation of the tokens, to try to provide hints of
where the source may be. Those hints are not deterministic
but they may be able to point users to the source of the
problem.

For example, in this case:

    defmodule MyApp do
      def one do
      # end

      def two do
      end
    end

we know that we now that `def two do` is happening on the
same indentation as `def one do`, which may mean that
`def one do` was not closed properly. We store this as a
hint in case the terminators do not match later.

Similarly, in the case below:

    defmodule MyApp do
      def one
      end

      def two do
      end
    end

The `end` on line 3 will end-up closing the defmodule `do`,
on line 1. Because their indentation do not match, it may
be that there is a missing `do`, where the `end` was supposed
to align.

Some basic testing show those heuristics work on the majority
of the cases, but we will only be sure when we have enough
feedback from the community.
2018-06-10 13:55:49 +02:00
René Föhring 1ade3c0dd9 Fix column in :elixir_tokenizer for double quotes in keyword identifiers (#7722)
This fixes cases where `:elixir_tokenizer` does not account for double
quotes in keyword identifiers when determining the column for the next
token.
2018-06-04 16:06:42 +02:00
Andrea Leopardi 1aba6f72c6 Warn when a variable/atom that ends in / or ? is followed by = with no space (#7608) 2018-04-27 16:49:11 -03:00
José Valim cfaf9dbbcd Improve warning about escaped codepoints in ? 2018-04-11 09:25:42 +02:00
René Föhring 901752a4fe Fix column in :elixir_tokenizer for sigils with modifiers (#7529)
This fixes cases where :elixir_tokenizer does not account for sigil modifiers
when determining the column for the next token.
2018-04-03 13:16:02 +02:00
Andrea Leopardi ae6fb479b5 Remove a useless guard in elixir_tokenizer 2018-03-27 12:32:42 +02:00
Glauber Campinho 0757cf8028 Optimize tokenizer for commas (#7493)
Small optimization skipping the `handle_terminator` function
for commas since they don't require terminators.
2018-03-26 22:31:58 +02:00
Glauber Campinho add3a9666f Fix column count on heredoc tokenizer (#7486) 2018-03-25 12:37:15 +02:00
Andrea Leopardi f30b29aca1 Prevent operators with many of same char to have same char after them (#7344) 2018-02-14 09:43:55 +01:00
José Valim 4b134c8cf5 Raise on invalid map syntax, closes #7268 2018-01-28 11:04:25 -02:00
Andrea Leopardi 8c05bb078d Fix a typo in a heredoc-related warning
[ci skip]
2018-01-08 14:23:39 +01:00
José Valim f34d74913c Warn if heredoc is outdented, closes #7174 2018-01-07 17:46:42 +01:00
José Valim ad190b0889 Raise on reserved tokens, closes #6532 2017-11-06 17:15:44 +01:00
Blake Tan 554d595009 Better handling of non existing atoms (#6978) 2017-10-26 20:25:00 +02:00
José Valim d3a85bfd21 Remove end column information from tokens
If we want to store this information, we need to store it
alongside the end line, otherwise it is ambiguous.
2017-10-25 11:56:31 +02:00
José Valim c5f6271872 Keep integer/float underscores in the formatter, closes #6931 2017-10-16 16:44:53 +02:00
José Valim 34651f1034 Format errors_test.exs 2017-10-12 09:35:58 +02:00
José Valim 41ca9abfc7 Properly render :-> as an atom 2017-10-09 22:55:07 +02:00
José Valim 9b5af3303d Also preserve user newlines if trailing commas exist 2017-10-09 09:17:35 +02:00
José Valim 4387576126 Add more metadata to containers 2017-10-07 00:18:22 +02:00
José Valim 455c2c3f3b Rely on side effects for preserving comments
The previous implementation would not lead to parsing
errors in interpolations since code inside interpolation
is parsed immediately.
2017-10-05 13:27:25 +02:00
Artur Cygan c0fd3d2655 Improve error message on oversized atom (#6612) 2017-09-28 14:04:29 +02:00
José Valim 28bd48ed21 Do not prematurely raise on end tokens, closes #6567 2017-09-12 21:58:46 +02:00
José Valim a8bafae468 Store eol info in arrow ops 2017-09-01 00:58:15 +02:00
José Valim 97ece16b11 Add more formatter metadata 2017-08-30 17:21:17 +02:00
José Valim 6030be5ae5 Add literal annotation for aliases 2017-08-28 23:59:45 +02:00
José Valim a378154652 Make terminator binaries 2017-08-27 12:39:40 +02:00
José Valim 4f9f2cea24 Add String.Tokenizer back to tokenizer scope 2017-08-23 17:55:29 +02:00
José Valim 1e648fc73e Allow strings/atoms/charlists to be emitted unescaped 2017-08-23 17:36:09 +02:00
Andrea Leopardi 4cfce073c1 Keep the representation of "float" tokens like we do for "int" tokens (#6501) 2017-08-23 12:57:10 +02:00
Andrea Leopardi bd1508cc23 Fix integer token representation for decimal integers 2017-08-23 12:07:46 +02:00
Andrea Leopardi 2f9b651011 Merge integer tokens into the "int" token (#6499) 2017-08-23 11:55:12 +02:00
Andrea Leopardi 8cd9b8a75a Change the format of tokens (#6495)
Right now, tokens are "{Token, Location}" or "{Token, Location, Value}".
This commit changes "Location" from "{Line, StartColumn, EndColumn}" to
"{Line, {StartColumn, EndColumn}, Meta}" where "Meta" can be anything.
This will be used for things such as storing the format of integers.
2017-08-22 21:12:30 +02:00
Andrea Leopardi 1dd4c16958 Rename the "hexadecimal" token to "hex" 2017-08-22 00:07:03 +02:00
José Valim 0beeef8b1f Do not crash IEx on :init.stop 2017-08-01 21:10:29 +02:00
Alex Jiao 921f17e21d Add heredoc info to heredoc list/binary literals when parsing (#6372) 2017-07-25 00:04:23 +02:00