Commit Graph
91 Commits
Author SHA1 Message Date
José Valim 95ec1be78a Clean up private elixir_config API 2018-07-19 23:27:52 +02:00
José Valim 658b90c399 Properly add parens around when with keywords as argument 2018-07-13 00:12:58 +02:00
José Valim 35ac568044 Require Erlang/OTP 20+ 2018-07-12 12:12:00 +02:00
José Valim beb596d37c Warn on unnecessary quotes (#7838) 2018-07-10 10:27:02 +02:00
José Valim 4db36e08d7 Do not force clauses with comments to be unfit (#7843) 2018-07-09 12:54:50 +02:00
José Valim 383066aef5 Check for no_generators? once 2018-07-03 23:35:20 +02:00
José Valim b0cc54468e Unify handling of keywords with and without parens 2018-07-03 17:57:13 +02:00
Sihui Huang 47f1107a7a When fn is followed by a newline, use multi-clause formatting style (#7737) 2018-06-10 17:45:02 +02:00
Sihui Huang 76e5a3237d Erlang typespec vars should be fully converted to elixir variables (#7724) 2018-06-04 13:42:18 +02:00
Fernando Tapia Rico ca21a7b12c Fix reference in Code.Formatter's doc (#7690) 2018-05-16 19:05:41 +02:00
José Valim 05656c4937 Remove and clarify notes regarding OTP versions 2018-04-17 12:49:44 +02:00
José Valim a6ab0d99ae Fix formatter for tilde inside bitstrings, closes #7558 2018-04-17 08:52:53 +02:00
José Valim a7219b6c93 Preserve user choice on calls without parens when we have one arg per line 2018-04-11 18:56:32 +02:00
José Valim cb67649dff Keep the user's choice on parens call with next break fits
Closes #7535
2018-04-06 15:30:09 +02:00
Adi Iyengar 8d47d0d238 Fix typo in formatter (#7504) 2018-03-28 10:45:17 +02:00
José Valim 4f14aea9f6 Split Kernel.Typespec into Kernel.Typespec and Code.Typespec (#7462)
Kernel.Typespec will be responsible for handling typespec
logic during compilation, such as definitions, conversion to
Erlang and warnings. Its API shall never be public.

Code.Typespec will handle the runtime aspects, such as reading
from .beam files and conversion back to Elixir AST. Its API
may be made public in the future but it is currently private.

This PR also simplifies definition of typespecs internally by
avoiding multiple macro passes and speeds up typespec processing
on OTP 20+ by skipping the translation pass from Elixir to Erlang.

The test suite was also reorganized and made async: true.
2018-03-18 22:45:44 +01:00
José Valim d0bd8692dd Do not escape quoted keywords on formatting, closes #7451 2018-03-14 10:10:44 +01:00
José Valim 6b968fdef9 Avoid protocol dispatch and multiple lists conversion in the formatter 2018-03-10 23:18:44 +01:00
José Valim f0a7f19ff4 Consider commas when breaking groups, closes #7406 2018-03-03 00:19:22 +01:00
José Valim 6d94ee76e5 Ensure proper precedence between & and operators, closes #7412 2018-03-02 23:23:44 +01:00
Andrea Leopardi 36395a248c Add a bunch of backticks to some docs in Code.Identifier
[ci skip]
2018-02-19 14:05:30 -08:00
José Valim 2cbd5cee83 Ensure -> does not pass line lengths, closes #7279 2018-02-10 20:37:59 +01:00
José Valim b3e7587bf8 Consistently preserve the user choice in regards to parens, closes #7286 2018-01-31 13:50:17 -02:00
José Valim 12153869c5 Support comments in the middle of pipelines and type expressions
Closes #7231
2018-01-24 13:09:19 +01:00
José Valim 5dedbed881 Ensure do blocks do not exceed line length on single arguments
Closes #7232
2018-01-21 00:53:04 +01:00
José Valim bfa3cfba19 Only rearrange not in if explicitly opted-in
Closes #7227.
2018-01-19 10:54:39 +01:00
José Valim c480b68b2d Automatically translate deprecated code calls 2018-01-18 23:19:39 +01:00
Jean-Philippe Cugnet c6a9bf37dc Don’t add parens for defrecord/3 and defrecordp/3 (#7204) 2018-01-13 19:56:05 +01:00
José Valim a719605abf Use flex_glue for bitstrings and tuples in the formatter (#7183)
Closes #7152
2018-01-11 10:07:48 +01:00
José Valim 8ece3b9748 Fix precedence of & in regards to =, closes #7188 2018-01-09 14:13:45 +01:00
José Valim 9941745afb Do not move comments from first argument of no parens calls, closes #7130 2017-12-22 11:27:32 +01:00
José Valim b4aac2d7be Do not indent right-side of pipelines in the formatter (#7103) 2017-12-11 21:07:30 +01:00
José Valim c063093d32 Inspect tuples closer to the formatter, closes #6509 2017-12-06 12:01:48 +01:00
Donald Little 3086b68636 Show UTF-8 BOM on inspected strings (#7085) 2017-12-03 14:04:52 +01:00
José Valim ce4e0099e2 Properly take "do" into account on line breaks, closes #7052 2017-11-21 14:54:42 -02:00
Eric Meadows-Jönsson 1303d09f61 Fix precedence of bitwise XOR (^^^) in formatter (#7036)
Closes #7034.
2017-11-15 19:53:20 +01:00
José Valim 384e88ca43 Only consider a document doesn't fit if it has breaks
Closes #7007
2017-11-07 16:03:48 +01:00
José Valim 887c40b258 Group operands but not the operator
Closes #7007
2017-11-07 13:08:37 +01:00
José Valim 5ea7321562 Consider comments inside function calls
Closes #6994
2017-11-07 10:50:11 +01:00
José Valim ca75fc66ee Pass the proper precedence to binary operator handling, closes #7005 2017-11-07 09:37:02 +01:00
Chris Keele 6ab811c638 Adds Kernel.defguard/1 macro to build guard-safe macros
This makes defining guards easier, since it does the boilerplate
for you and raises at compile time in the defguard macro when
you do something not allowed in guards (as opposed to whenever
the new guard happens to be used as a guard).

It takes a `defguard name(args) when implementation` invocation,
passes the implementation through `:elixir_expand.expand/2` in
a guard context, and if nothing is raised, transforms the impl
into a macro that works both inside and outside of guard contexts.

Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2017-11-06 12:39:53 +01:00
José Valim 2ec40468a4 Inline expressions when possible 2017-10-31 10:53:14 +01:00
José Valim 794928efe1 Restrict next break fits and eols on operators and function calls
* Whitelist which operators support next_break_fits
  * No longer consider tuples as part of next_break_fits
  * Do not consider eol for = and ::
  * Do not consider eol for calls with one next_break_fits arg
2017-10-27 12:34:09 +02:00
Andrea Leopardi 3ac72777b7 Fix formatting of multiline "foo.{...}" calls (#6979) 2017-10-26 13:59:37 +02:00
José Valim 3d84aec0f9 Respect the user's choice on calls
Closes #6977
2017-10-26 13:19:21 +02:00
José Valim 7f8136915f Treat => and : as operators in the formatter
This means that the right side will break on its own line
when it doesn't fit and be indented by two spaces.

Closes #6976.
2017-10-26 12:43:02 +02:00
José Valim 47dd73e7be Consistently add spaces after not 2017-10-25 19:38:56 +02:00
José Valim f09657180f Support next break fits inside tuples
This only applies if the tuple has not been "spaced out".
2017-10-25 19:36:34 +02:00
José Valim 0a2b8ad756 Run the formatter in the formatter and remove code duplication 2017-10-24 14:16:38 +02:00
José Valim baeed3a69e Recognize hashbangs in the formatter
Those are known instructions in UNIX systems.

Closes #6969.
2017-10-24 14:00:10 +02:00