Commit Graph

16 Commits

Author SHA1 Message Date
wrvsrx c0da4a5a74 mformat: try to detect meson.format in source files' parent directories 2025-01-31 08:53:35 -08:00
Charles Brunet 38051a5a4b format: allow input from stdin
Fixes #13791
2024-12-06 10:59:18 -08:00
Charles Brunet 37c5bffbff mformat: better handling of continuation lines
Fixes #13566. Fixes #13567.
2024-09-06 11:17:59 -07:00
Charles Brunet d3ef02b2e4 mformat: detect invalid config
- detect unknown config keys in format config
- add test for detection of invalid config values
- detect invalid .editorconfig values

Fixes #13569
2024-09-06 14:14:44 -04:00
Benjamin Gilbert 6d92547e6c mformat: regenerate long lines even if they're already multiline
If kwargs_force_multiline is enabled, an ArgumentNode in a kwarg value can
already be marked multiline by the time we notice that the line needs to
be broken for length.  Ensure we still break the line in this case.

Fixes: #13512
2024-09-05 11:31:26 -04:00
Dylan Baker 1e6e4c8d57 mformat: provide nice error message instead of backtrace for invalid value
I ran into this with `option = true;` (note the trailing `;`). Now we
provide a nicer message instead of an uncaught Python backtrace.

Closes: #13565
2024-09-04 23:12:44 +03:00
Dylan Baker df70680723 mformat: A triple string with a ' in it cannot be simplified
The following is valid meson:
```meson
a = '''This string can't be simplified'''
```
which cannot be simplified because of the `'` in it, as
```meson
a = 'This string can't be simplified'
```
Is invalid.

Potentially we could convert that with escapes, but it seems reasonable
to me to leave this, since it may be desirable to not have lots of
escapes in a string. `'''I can't believe it's her's!'''` is much more
readable than `'I can\'t believe it\'s her\'s!'`, for example.

Closes: #13564
2024-08-20 11:41:00 -07:00
Charles Brunet d9ba42217f format: fix indentation of comments
Fixes #13508

- Fix indentation of comments in arrays
- Fix indentation of comments in dicts
- Fix indentation of comments in if clauses
- Fix indentation of comments in foreach clauses
2024-08-20 09:38:27 -07:00
Dylan Baker 18f4a058bf mformat: correctly handle editorconfig files without the root setting
Which happens when a .editorconfig is in a subdirectory, not the root.
In this case we need Set the fallback value to `False`, which is what
editorconfig expects.

Closes: #13568
2024-08-19 21:05:41 -04:00
Charles Brunet fa4f233946 mformat: fix formatting of empty build file
Running meson format multiple times on an empty file was adding a new line each time, which is bad for pre-commit checks...
2024-08-01 12:09:58 -07:00
Eli Schwartz 4a352dd8bd
flake8: move unused typing-only imports to TYPE_CHECKING 2024-07-30 14:13:11 -04:00
Charles Brunet dbfd3e8c41 format: fix edge case with empty functions
format was adding a new empty line each time when trying to split a long line containing a function with no arguments
2024-06-26 15:44:49 -04:00
Charles Brunet 8967090149 mformat: fix else token not correctly indented
fixes #13316
2024-06-19 00:09:29 -04:00
Charles Brunet bef2fbf75b Fix crash in meson format
There was a case where a trailing comma was missing a whitespaces attribute

Fixes #13242
2024-06-19 00:07:01 -04:00
Charles Brunet 9f4253164a Catch format configuration parse error 2024-06-19 00:07:01 -04:00
Charles Brunet 2b37101998 meson format command 2024-04-08 10:43:57 -07:00