Compare commits

...

425 Commits

Author SHA1 Message Date
Mathis Beer aa49b9035c Tag the constructor arguments in new-anonymous-class calls as named arguments. 2025-10-09 08:25:39 +02:00
Mathis Beer 49612a48a6 Track 'new' expressions in the named argument offset list as well. 2025-09-25 23:29:13 +02:00
Mathis Beer a12e83e8a4 Avoid interpreting named args as labels when indenting newline in keep_line_breaks mode. 2025-09-25 23:29:13 +02:00
Nicholas Wilson d8e43e23ec remove explicit `nothrow` from `globMatchEditorConfig`
The in contract may throw.
2024-08-21 09:58:22 +02:00
Andrei Horodniceanu 0ea0572e86 makefile: Remove stdx-allocator from imports and sources
Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
2024-05-11 20:07:03 +02:00
Andrei Horodniceanu 5ea76cd293 makefile: fix bin/dfmt-test target
Don't call the D compiler with bin/githash.txt as a source file.

Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
2024-05-11 20:07:03 +02:00
Jeremy Baxter fa463b472c improve makefile
o  add 'install' target
 o  shorten the name of INCLUDE_PATHS to IMPORTS
 o  use filename prerequisities and targets rather than phony keywords
 o  add a dependency on .git/refs/tags for the githash target
 o  add githash.txt and dfmt-test to the clean target
 o  add more targets to .PHONY
2024-02-15 10:41:02 +01:00
Daniel Zuncke 2ea6c43a66 Use libdparse to check for named arg
Remove custom named arg parser
2023-10-26 20:10:50 +00:00
Daniel Zuncke 9f377100f0 Remove unnecessary tok!"comment" filter 2023-10-26 20:10:50 +00:00
Daniel Zuncke 20b8badf8c Fix issue #586 2023-10-26 20:10:50 +00:00
Daniel Zuncke 35e55bc9b2
Fix #578 ternary expressions in AA literals not properly formatted (#591) 2023-10-22 17:52:14 +09:00
Daniel Zuncke 08fe5d6855 Confirm token equality, safer loop
Using different variable to iterate to guarantee unchanged behaviour
if anything doesn't work as intended.
2023-10-18 10:22:48 +02:00
Daniel Zuncke c0452dbd11 Update test to include both known cases
I have formatted them both to look like the the individual bad output
and not like the actual output from formatting the issue0432.d file with
the current implementation. The current implementation makes it look
like a new / different problem.
2023-10-18 10:22:48 +02:00
Daniel Zuncke 876bbe33c1 Fix issue #432
Overview:
Array astInformation.structInitEndLocations is used to find index to use
in astInformation.indentInfoSortedByEndLocation.
Both are sorted, first is used to find the array index, second is
accessed at that index to get brace indentation information.

Problem:
structInitEndLocations is generated from struct initializers
exclusively while the brace information array also contains entries
for function literal initializers. Thus when function literal init(s)
are used, we get accumulating off by one errors in the second array:

match value in structInitEndLocations and take that index:
[3, 50]
    ^--> index 1

take brace indent information from that index:
[3, 15, 50]
    |   ^--> the one we want
    ^------> the one we get (function literal init)

Solution:
This guarantees that searching forward works.
While better search strategies than linear are possible, this should be
enough for any sane and most of the insane code files.
2023-10-18 10:22:48 +02:00
WebFreak001 1e765fb781 add knr test variant for no_space_after_keyword
The generator is so outdated and basic that it didn't generate this.
2023-07-26 16:13:48 +02:00
Robert Schadek c43803575d No space after keywords
Readme update

test files
2023-07-26 16:13:48 +02:00
WebFreak001 470e65f7cc bump minimum libdparse version, fix #583 2023-07-19 14:43:24 +02:00
Eugen Wissner 6f41b20d5b Remove travis 2023-05-01 23:01:54 +02:00
Razvan Nitu 49b9fe4051
Merge pull request #579 from belka-ew/bug/revert-array-indent-on-line
Keep "(" indentation with a "]" in the same line
2023-04-07 23:19:48 +08:00
Eugen Wissner fec7394175 Add reflow_property_chains option
Recalculate the splitting of property chains into multiple lines.
2023-03-29 11:29:59 +02:00
Eugen Wissner 727472c365
Keep "(" indentation with a "]" in the same line 2023-03-20 18:23:33 +01:00
WebFreak001 840aeee45e add missing test 2023-03-01 22:07:37 +01:00
WebFreak001 a91f044958 add some missing hasCurrent checks 2023-03-01 22:07:37 +01:00
Eugen Wissner dba8c87ebc Revert operator indentation in an argument list 2023-02-06 10:17:09 +01:00
Eugen Wissner a4fbc6f881 Revert chain indentation in an argument list 2023-01-15 20:51:03 +01:00
Eugen Wissner 57f57d95de Fix else indentation after array literal 2023-01-14 02:18:28 +01:00
WebFreak001 4a6078779a Fix #568, don't output empty files without error
Now when an error in formatting happens, it never outputs anything and
doesn't override the file when working inplace.

Additionally dfmt is no longer able to fail in the middle of a file, as
now we first write everything to a buffer and only if everything was
successful, that buffer is printed to stdout or written to the inplace
file.

This should also guard against segfaults with inplace file formatting
erasing parts of the file, as well as the user thinking it was
successful, even though dfmt didn't finish properly.
2022-10-15 02:33:04 +02:00
Iain Buclaw e251e4343a Remove appveyor.yml
This pipeline isn't in use anymore.
2022-10-06 21:10:01 +02:00
Iain Buclaw 02070df593 Update downloads.dlang.org links to use https 2022-10-06 21:10:01 +02:00
Andrey Proskurin 6744df20f3 Add knr brace style to README 2022-09-14 13:25:04 +02:00
Eugen Wissner 8d42254d47 Fix indentation of callchains with comments
Weird formatting and indentation of multiline callchains with comments
in the middle.
2022-08-06 08:55:43 +02:00
Bastiaan Veelo 2a4af7a2b2
Retain line ending by default. (#553) 2022-07-28 17:21:10 +02:00
Eugen Wissner 026a58e273 Very long chained calls in array literals are indented weirdly 2022-07-28 17:14:01 +02:00
Bastiaan Veelo 4947beec6b CI
Add GitHub action.
2022-07-14 23:19:37 +02:00
belka-ew d862d8aef1
Fix array literal indentation in foreach (#554) 2022-06-14 12:35:54 +00:00
skyline131313 036da91542
Update dub.json to remove dependency on `rdmd` (#547) 2022-06-13 16:23:56 +02:00
Max Haughton ed5fc2ffd2
Merge pull request #551 from veelo/d_test_script
Port `test.sh` to platform independent D.
2022-05-30 00:15:49 +01:00
Bastiaan Veelo b8da7c5cd4 Refactor courtesy WebFreak001.
Co-authored-by: Jan Jurzitza <gh@webfreak.org>
2022-05-27 19:47:47 +02:00
Bastiaan Veelo f6d9d04e43 Port `test.sh` to platform independent D.
This executes also way faster by not spawning GNU diff.
2022-05-26 16:10:07 +02:00
Bastiaan Veelo f81ddeadbd
obey `end_of_line` setting in all tokens (#550)
Multi-line tokens would be written with `LF`, regardless the `end_of_line` setting.

Fixes #228 and also produces end_of_line specified line-endings in strings.
2022-05-25 13:21:07 +02:00
Bastiaan Veelo 3e1e643972
Merge branch 'dlang-community:master' into master 2022-05-23 16:23:20 +02:00
Eugen Wissner 77e2ba4e3d Fix array indentation as argument 2022-05-23 14:09:26 +02:00
RazvanN7 6a24f0dc7c Upgrade libdparse to latest version 2022-01-26 14:05:44 +01:00
Martin Kinkelin b776d5a9b9 Fix tests 2021-10-31 20:37:32 +09:00
Razvan Nitu 2beb819851
Merge pull request #535 from dlang-community/single-indent
Add single_indent option
2021-10-22 16:22:40 +03:00
Jan Jurzitza f1e57135bb
Merge pull request #534 from dlang-community/knr_brace_style 2021-10-09 09:09:50 +02:00
Max Haughton e5e11604f0
Merge pull request #542 from belka-ew/comment-before-contract
Fix comment before contract
2021-09-07 16:46:42 +01:00
Eugen Wissner e8bd41c70d
Fix comment before contract
Fixes #451.
2021-09-07 14:29:45 +02:00
Sönke Ludwig b3b8ff1a43 Avoid possible null pointer access. 2021-08-16 18:09:57 +02:00
Amin Yahyaabadi 0e5615e13e
Fix the CLI help output about the `--config` option (#541) 2021-08-04 00:40:22 +03:00
belka-ew f6490b31c9
Format multiline arrays first (#538) 2021-06-16 17:23:27 +03:00
Eugen Wissner 995c21ab87 Format do like body after function attributes 2021-06-14 21:06:32 +00:00
Eugen Wissner 821b9be9e9 Fix double array indentation inside parens 2021-06-12 05:39:30 +00:00
Eugen Wissner ea36fbf58b
Add single_indent option 2021-05-18 06:36:57 +02:00
Sönke Ludwig 0f61586438 Add tests for "knr" brace style. 2021-04-16 13:57:59 +02:00
Sönke Ludwig e35bde0815 Add Kernighan & Ritchie style brace formatting.
The original K&R style behaves like BraceStyle.otbs, except for function definitions that use Allman style.
2021-04-16 13:57:21 +02:00
WebFreak001 e79ba9f0c8 upgrade libdparse to <0.18.0 2021-04-06 20:14:47 +02:00
Preetpal Sohal 3479e73707
Fix installation instructions on README.md (#531)
* Fix installation instructions on README.md

Fixes Issue #530.
2021-03-11 16:40:44 +02:00
Eugen Wissner 1f21a97713 Don't indent associative array keys as labels 2021-03-09 11:38:33 +01:00
Eugen Wissner c4b6a7e7e3 Don't write a space after the return attribute
Fixes #521.
2021-02-27 16:06:06 +01:00
Eugen Wissner e6199aaa9b Don't output an extra newline after a comment
with keep_line_breaks=true.

Fixes #509 and #490.
2020-10-10 07:25:27 +02:00
Brian Schott e880e00e73
Merge pull request #516 from dlang-community/issue-515
Fix #515
2020-10-07 14:14:03 -07:00
Hackerpilot 41e8c05558 Fix #515 2020-10-07 02:19:55 -07:00
Brian Schott 7659b1ae1a
Fix Issue 508 (#511)
Fix Issue 508
merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
2020-10-01 08:35:20 +02:00
Eugen Wissner eab4cac12f Regenerate line break hints after newline
Fixes #486.
2020-09-04 00:14:25 +02:00
Eugen Wissner 94351246f6 Keep line break after function attributes
Fixes #504.
2020-09-02 09:09:19 +02:00
Eugen Wissner d100c40dab Print colon in AA before identifiers 2020-08-27 09:43:25 +02:00
Eugen Wissner 58b2c6ebc6 Break line on multiline strings
Fixes #476.
2020-08-10 15:25:59 +02:00
Mathis Beer b5dbb0e031 Fix issue 483: indent continuing case statements on the same level 2020-07-22 10:27:52 +02:00
Mathis Beer e4f2f20720 Fix issue 497: insert space before function/delegate in function type that returns template instantiated with parenless value argument 2020-07-20 08:04:51 +02:00
The Dlang Bot d92a6799ac
Merge pull request #493 from WebFreak001/upgrade-libdparse
Upgrade libdparse to <0.16.0
merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
2020-06-28 08:33:28 +02:00
WebFreak001 e5eda5c14a Upgrade libdparse to <0.16.0 2020-06-24 22:26:03 +02:00
The Dlang Bot f80bffcf84
Merge pull request #491 from WebFreak001/add-minmax-libdparse
use test_with_package.d for libdparse for tests
merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
2020-06-09 23:18:25 +02:00
Jan Jurzitza ad00b113a9 use test_with_package for libdparse test
test both minimum and maximum allowed libdparse versions with dub
2020-06-08 14:21:33 +02:00
The Dlang Bot 83f8a4c65d
Merge pull request #488 from WebFreak001/fix-482
switch statement alignment is implemented fix #482
merged-on-behalf-of: Petar Kirov <PetarKirov@users.noreply.github.com>
2020-05-06 06:42:34 +02:00
Jan Jurzitza f59f25bb09 switch statement alignment is implemented fix #482 2020-05-05 14:06:55 +02:00
The Dlang Bot 09caf255e5
Merge pull request #475 from WebFreak001/fix-474
Fix #474
merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
2020-04-03 09:51:49 +02:00
Jan Jurzitza 34810aa928 Fix stuck-while TODO (this is a do-while loop) 2020-04-03 09:19:24 +02:00
Jan Jurzitza cb1dfe091f Check for token before access, fix #474 2020-04-02 13:39:29 +02:00
Jan Jurzitza 7b955c18d1 Add hasCurrent to check if a token is available 2020-04-02 13:38:02 +02:00
Jan Jurzitza 1964f807cf
Merge pull request #473 from belka-ew/break-on-this
keep_line_breaks: multi-line tokens and argument list break
2020-03-24 14:42:25 +01:00
Eugen Wissner ef83514541 keep_line_breaks: Compare with the token end line 2020-03-24 14:39:31 +01:00
Eugen Wissner 394da5d02a Fix break after comma, before this 2020-03-22 17:54:59 +01:00
The Dlang Bot 66faac49f1
Merge pull request #470 from dlang-community/issue-469
Fix Issue #469
merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
2020-03-09 10:03:20 +01:00
Hackerpilot e9034f4fec Fix return value when reading from stdin 2020-03-08 13:23:42 -07:00
Brian Schott b17304accd
Update tests/test.sh
Co-Authored-By: Jan Jurzitza <gh@webfreak.org>
2020-03-08 13:17:48 -07:00
The Dlang Bot c41c0349a2
Merge pull request #471 from belka-ew/feature/keep-line-breaks
Support disabling automatic line breaks
merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
2020-03-07 21:47:03 +01:00
Eugen Wissner 5f0d2843e6 Support disabling automatic line breaks
Support disabling automatic line breaks With --keep_line_breaks.
2020-03-07 21:14:10 +01:00
Hackerpilot 63a29ab757 Update dependency 2020-03-06 13:28:45 -08:00
Hackerpilot 2dc19b6577 Update submodule 2020-03-06 13:11:20 -08:00
Hackerpilot fbd8559ceb Test case for issue 469 2020-03-06 13:10:21 -08:00
Hackerpilot 977318214d Add check for tests that are supposed to error out, and clean up code based on shellcheck suggestions 2020-03-06 13:10:04 -08:00
Hackerpilot 4db5ba44b2 Error out on lexer failure 2020-03-06 13:09:14 -08:00
The Dlang Bot 399041c84f
Merge pull request #467 from Geod24/fix-deps
Replace 'body' with 'do'
merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
2020-02-04 03:36:42 +01:00
Geod24 d38c3d96bf Replace 'body' with 'do'
The former is set to be deprecated in the next (2.091.0) DMD release.
2020-02-04 11:28:21 +09:00
Geod24 da51958770 Remove trailing whitespace 2020-02-04 11:27:58 +09:00
Eugen Wissner 27929e4cc5 Wrap the argument list of a template function
Fixes #454.
2020-01-12 22:49:16 +01:00
Eugen Wissner 0795a477f1 Put space between a comment and an identifier
Fixes #452.
2020-01-05 23:11:18 +01:00
Eugen Wissner 8f779b33bf Put a space in contract expressions
Fixes #448.
2020-01-05 20:28:56 +01:00
Sebastian Wilzbach 024c6e6a63
Merge pull request #460 from WebFreak001/fix-trivials
Fix trivial issues
2019-12-03 02:13:34 +01:00
WebFreak001 8c2076d4f2 better gen_expected script 2019-11-25 17:10:20 +01:00
WebFreak001 70bae7487e add dub build to readme fix #234 2019-11-25 17:09:51 +01:00
WebFreak001 79ae2c09d0 trivially fix #195
probably fixed in previous libdparse
2019-11-25 17:09:51 +01:00
WebFreak001 28b32d9d77 trivially fix #134
was fixed in the past
2019-11-25 17:09:51 +01:00
WebFreak001 d33b878965 fix #430 already working
resolved with previous libdparse update
2019-11-25 17:09:51 +01:00
The Dlang Bot a4d4d94a50
Merge pull request #459 from WebFreak001/libdparse-0-13-z
upgrade libdparse to 0.13.z
merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
2019-11-25 16:41:20 +01:00
WebFreak001 30ab6e103d upgrade libdparse to 0.13.z 2019-11-25 16:22:13 +01:00
The Dlang Bot 3f141b272d
Merge pull request #446 from Sobaya007/fix-issue256
Fix: Issue 256 "named member struct initialisers"
merged-on-behalf-of: Jan Jurzitza <gh@webfreak.org>
2019-08-06 23:22:24 +02:00
sobaya 06881d8654 Fix: assertion message in indent manipulation of struct initializer 2019-08-04 13:05:39 +09:00
sobaya ac8e34815f Fix: Use more readable expression 2019-08-04 13:04:39 +09:00
sobaya b3946b7525 Add: Test for nested struct formatting 2019-08-03 08:55:32 +09:00
sobaya 05db8ae8fa Fix: indentation for wrapping in struct initializer 2019-08-01 17:43:45 +09:00
sobaya 81c607a115 Fix: extrace space after first field 2019-08-01 16:58:41 +09:00
sobaya 1024f16715 Add: struct fields to the test of issue 256 2019-07-30 23:04:02 +09:00
sobaya ac61efe767 Fix: Issue 256 "named member struct initialisers" 2019-07-30 13:02:48 +09:00
The Dlang Bot 4fea171d2f
Merge pull request #442 from kotet/issue-361
Fix #361
merged-on-behalf-of: Basile-z <Basile-z@users.noreply.github.com>
2019-05-14 10:41:32 +02:00
Kotet 3af8edc57f Fix #361 - Unexpected empty new line if function header ends with a comment 2019-05-14 09:00:56 +09:00
The Dlang Bot 6d2a56e15e
Merge pull request #441 from kotet/issue-426
Fix #426
merged-on-behalf-of: Basile-z <Basile-z@users.noreply.github.com>
2019-05-13 11:06:56 +02:00
Kotet f8f34ff097 Fix #426 2019-05-13 17:49:12 +09:00
The Dlang Bot 999c044020
Merge pull request #440 from kotet/issue-0433
Fix #433
merged-on-behalf-of: Basile-z <Basile-z@users.noreply.github.com>
2019-05-13 08:57:58 +02:00
Kotet 2cc1f59235 Fix #433 2019-05-13 12:13:32 +09:00
The Dlang Bot 436d157b4f
Merge pull request #439 from dayllenger/readme
make readme look nicer
merged-on-behalf-of: Basile-z <Basile-z@users.noreply.github.com>
2019-04-14 05:15:26 +02:00
Viktor 0878430125 sort options and make links to "below" 2019-04-13 15:49:31 +03:00
Viktor ac5f8b18aa
make readme look nicer 2019-04-13 15:04:22 +03:00
Sebastian Wilzbach 793a575b1c Build win{32,64} binaries with LDC 2019-04-01 11:05:24 +02:00
Basile-z 313b886799 upgrade dependencies (#438)
upgrade dependencies
merged-on-behalf-of: Basile-z <Basile-z@users.noreply.github.com>
2019-04-01 09:00:24 +02:00
The Dlang Bot 54a84bd927
Merge pull request #437 from dlang-community/issue-436
Fix #436
merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
2019-02-22 03:20:39 +01:00
Hackerpilot b4e97d3381 Fix #436 2019-02-20 11:25:31 -08:00
Laurent Tréguier b34acc9f26 Update libdparse to v0.11.2 (#429)
Update libdparse to v0.11.2
merged-on-behalf-of: Basile-z <Basile-z@users.noreply.github.com>
2019-02-12 18:53:19 +01:00
Laurent Tréguier dae7d85c80 Fix #427 - Crash on invariant (#428)
Fix #427 - Crash on invariant
merged-on-behalf-of: Basile-z <Basile-z@users.noreply.github.com>
2019-02-11 13:55:33 +01:00
The Dlang Bot 6b9eddde5d
Merge pull request #424 from WebFreak001/fix-dubhash-spaces
Fix dubhash with spaces in folder name
merged-on-behalf-of: Jan Jurzitza <gh@webfreak.org>
2019-01-15 01:31:51 +01:00
WebFreak001 a79a43a9dc Fix dubhash with spaces in folder name 2019-01-14 20:33:17 +01:00
The Dlang Bot b00d3490bf
Merge pull request #423 from WebFreak001/aa3
fix array item access regression
merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
2019-01-12 22:01:28 +01:00
WebFreak001 bdac7361a5 Add test for issue0112 without array item 2019-01-12 12:37:06 +01:00
WebFreak001 7f41c8ae7f fix array item access regression 2019-01-12 12:25:46 +01:00
The Dlang Bot 989c0da60c
Merge pull request #422 from WebFreak001/aa2
Fix arrays in AAs, 2D arrays, long arrays
merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
2019-01-11 23:33:42 +01:00
WebFreak001 6dea7b689e fix otbs expected test result for 2d arrays 2019-01-11 22:23:04 +01:00
WebFreak001 98cd73ec80 Fix 2D (assoc) arrays & add tests
Fix #312
2019-01-11 22:06:57 +01:00
WebFreak001 eebd341343 Allow multilineAt to stop at commas 2019-01-11 22:05:41 +01:00
WebFreak001 733898e013 more informative dump function 2019-01-11 22:04:52 +01:00
Brian Schott 188c0dca03
Merge pull request #421 from WebFreak001/aa
Associative array formatting & space_before_aa_colon option
2019-01-11 12:55:15 -08:00
WebFreak001 60b2cff18a Adjust issue0017 for now (minor improvement) 2019-01-11 20:22:30 +01:00
WebFreak001 1da1ca6545 Fix isMultilineAt for array + refactor right bracket
Refactor formatRightBracket into own function
2019-01-11 20:19:50 +01:00
WebFreak001 48b2b84c33 Add documentation/comments & undo minor name change 2019-01-11 01:11:03 +01:00
WebFreak001 fcad21ba61 Improve AA formatting
fix #143, fix Pure-D/code-d#188
2019-01-11 00:50:50 +01:00
WebFreak001 85c7d57167 make multiline checking code modular
Arrays and delegates now use the check whether a line is longer
than the max line length using easy to reuse code
2019-01-11 00:48:59 +01:00
WebFreak001 053b775cd1 Add details to indentation stack
This makes more advanced state handling easily possible.
Also moved isWrapIndent/isTempIndent into this, which allows
for exceptions for certain tokens and more control.
2019-01-11 00:47:50 +01:00
WebFreak001 6e4136a353 Make colon almost never break a line 2019-01-11 00:45:47 +01:00
WebFreak001 3b094b16d9 Add ArrayLiterals into arrayStartLocations list
This is done to properly format arrays in function arguments
2019-01-11 00:44:11 +01:00
BBasile 460096728b Cleanup, remove socimantic stuff, close #406 (#418)
Cleanup, remove sociomantic stuff, close #406
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2019-01-02 16:20:15 +01:00
Jan Jurzitza c3537a5d51 Upgrade to libdparse 0.10.12 (#419)
Upgrade to libdparse 0.10.12
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-12-31 02:00:47 +01:00
Sebastian Wilzbach fc4cb9eecc
Merge pull request #417 from WebFreak001/fix-releases
Build tagged releases in CIs
2018-12-27 16:54:44 +01:00
WebFreak001 909164708a Build tagged releases in CIs 2018-12-27 16:37:32 +01:00
Jan Jurzitza ced64acae0 fix dub dependency build (fix #413) (#414) 2018-12-09 12:56:38 +01:00
The Dlang Bot bb679b1b6e
Merge pull request #411 from LaurentTreguier/issue-407
Fix #407 - `dub run dfmt` keeps building dfmt anew each time
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-11-14 18:51:28 +01:00
Laurent Tréguier 5508e9ced1
Fix #407 - `dub run dfmt` keeps building dfmt anew each time 2018-11-14 17:58:13 +01:00
Laurent Tréguier f4417dc1b5 Update libdparse to v0.10.x (#410)
Update libdparse to v0.10.x
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-11-10 14:02:31 +01:00
The Dlang Bot fd1f2f5161
Merge pull request #409 from LaurentTreguier/empty-braces-double-spaces
Spaces inside empty braces
merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
2018-11-09 10:51:13 +01:00
Laurent Tréguier 67664c2835
Don't put spaces inside empty braces 2018-11-06 16:40:25 +01:00
BBasile dc8e7a087c Prevent running CI twice when PR originated from origin (#408)
Prevent running CI twice when PR originated from origin
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-11-02 06:05:52 +01:00
Bastiaan Veelo 5274e5531e
Merge pull request #1 from dlang-community/master
Allow comments in selective imports. (#403)
2018-10-29 12:04:52 +01:00
Bastiaan Veelo 92d5e1ac8c Allow comments in selective imports. (#403)
Allow comments in selective imports.
merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
2018-10-19 01:45:52 +02:00
Laurent Tréguier 6ad2fbb6fc Fix #287 - Extra space after import in delegate 2018-10-15 10:14:23 +02:00
The Dlang Bot 3917c32925
Merge pull request #402 from some-bot/merge-libdparse-v0.9.10
Update dlibparse to v0.9.10
merged-on-behalf-of: Dlang Community Bot <some-bot@users.noreply.github.com>
2018-10-13 16:02:16 +02:00
some-bot a1cb44eb80 Updated libdparse to v0.9.10. 2018-10-13 12:59:49 +00:00
Laurent Tréguier 049f86ebfd Fix #349 - Wrong indentation of access modifier after break of long line 2018-10-11 05:43:37 +02:00
Laurent Tréguier 2578dbf2a7 Fix #267 - Indentation with debug inconsistent 2018-10-11 05:43:18 +02:00
Laurent Tréguier 908f32e433 Properly recognize debug as block header 2018-10-11 05:43:18 +02:00
The Dlang Bot 18eea577f8
Merge pull request #398 from LaurentTreguier/issue-345
Fix #345 -  Case of trailing white space
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-10-10 13:43:57 +02:00
Laurent Tréguier b928eb6d84
Fix #345 - Case of trailing white space 2018-10-10 13:37:06 +02:00
The Dlang Bot 810e4b464f
Merge pull request #396 from LaurentTreguier/debug-with-param
Debug with param
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-10-09 15:50:10 +02:00
Laurent Tréguier 6ff47e106a
Fix else indentation after debug conditions 2018-10-09 13:19:07 +02:00
Laurent Tréguier 72dd6e83b3
Stop directly accessing top indent token
Accessing the top indent token without using the topIs* () methods is
unsafe and can lead to range violations.
2018-10-09 12:04:44 +02:00
Laurent Tréguier c84db53c7c Fix #372 - Improper indentation after single-line catch (#395)
Fix #372 - Improper indentation after single-line catch
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-10-08 13:32:15 +02:00
Laurent Tréguier f3463cdd34 Fix #326 - Spaces missing after attributes in function literals (#394)
Fix #326 - Spaces missing after attributes in function literals
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-10-07 20:47:28 +02:00
Laurent Tréguier 16c3811261 Fix #286 - Weird indentation in else branch after wrapping expression (#393)
Fix #286 - Weird indentation in else branch after wrapping expression
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-10-07 19:56:08 +02:00
Laurent Tréguier 886903f8ea Fix #246 - Questionable indentation for multiple `with` statements 2018-10-07 12:36:17 +02:00
some-bot 494f70b429 Updated libdparse to v0.9.9. 2018-10-03 15:14:17 +02:00
Basile Burg dca9e15483 fix #244 - Wrong indentation for bool enums 2018-10-03 12:07:54 +02:00
Laurent Tréguier 5e6dd58502 Properly format enum member attributes and parameter attributes 2018-09-29 22:52:49 +02:00
some-bot 0fc4149907 Updated libdparse to v0.9.8. 2018-09-29 14:24:12 +02:00
BBasile 7fb46c9aa5 Use automatic versioning (#379)
Use automatic versioning
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-09-19 15:16:41 +02:00
Laurent Tréguier 647bb6daa9 Support for DIP1009 (new contracts syntax), #375 (#376)
Support for DIP1009 (new contracts syntax), #375
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-09-10 14:15:14 +02:00
BBasile 1fd19a1375 deactivate testing with DMD nightly (#383)
deactivate testing with DMD nightly
merged-on-behalf-of: Laurent Tréguier <LaurentTreguier@users.noreply.github.com>
2018-09-08 13:40:50 +02:00
Brian Schott ae76778801 Add index validity checks to the left paren/bracket code. Fixes #367. (#368)
Add index validity checks to the left paren/bracket code. Fixes #367.
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-09-06 01:01:27 +02:00
BBasile 56097fd106 Deprecate enforce ex (#377)
Deprecate enforce ex
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-09-06 01:01:08 +02:00
Stefan Koch 4256f988bf Merge tag v0.8.2 into v0.x.x 2018-06-19 16:48:23 +02:00
Stefan Koch cff6eb908e Merge tag v0.7.2 into v0.8.x 2018-06-19 16:48:23 +02:00
BBasile c58e54fe71 Handle do as contract header and handle body as identifier (#360)
Handle `do` as contract header and handle `body` as identifier
merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>

* libdparse 687c0ca(687c0ca)...086cf06(086cf06) (28 commits)
  > Merge pull request #242 from BBasile/issue-241
  > Merge pull request #239 from kubo39/add-isIntegerLiteral
  > Merge pull request #237 from BBasile/parse-virt-helpers
  > Merge pull request #236 from JinShil/patch-2
  > Merge pull request #235 from BBasile/upd-stdx-alloc
  (...)
2018-06-19 16:46:39 +02:00
BBasile 46788e53ba Handle do as contract header and handle body as identifier (#360)
Handle `do` as contract header and handle `body` as identifier
merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
2018-06-14 23:29:47 +02:00
Leandro Lucarella c66fea0fe5 v0.7.1
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABCAAGBQJbGrPQAAoJEOPQILQNRairRBoP+wQp3KG8pBYRjYWCUYBCcNrO
 5YgjtI7aEZfjo7mp56a7aYlXHmJpd8zPwR7xC9dwkA7/WzH6Pd6Lz5rz1cZq0KS7
 b+xwv834FRcGP17t7wKh1YqC8cvaL5UxgIIWvsk8L8W8wvt5ZwWXWkWGvUHfCgsp
 yZAjODJHBqUpkVSyCoOPgK8H02iY2wLAhQz1wZDRVyst9oFmNw0bgKprzyYaJrSd
 TkZL+1NZB9emCXBhW54Rh31hBnil5X7BJYvm9gNoEy9NO30uO+M1Z+HtRqY2z/kY
 VeCbk6oIvqQbqX/gbaNDWXhnnYcNJS6T7f6kob0Iu6m0FiCeW7e0PoYit4XmlLvQ
 XuXHx3BMLDYBamMbthEBLZ7iE37df31j+wo26dEj69Ax9lye4xzKEdu7Ke7uPL1C
 DaxInqxdp5DSdzu1CJcKPKpSJbJNslKP3nDPGOEGG119ujBQihV7CfmEbzgi/Py4
 BmK2sBKheRAiPrtbvjDq/HxTMbcjDvZMhqlYur4qNOQsWdei2UfWiRgOY8CFGKdt
 qVDkl/klYAihdYLy9Kh3I3TtbDN/VyRTE+I7O80RgxKB/UYzkTZABuIycsxLhaCp
 45FtPaetBuUUNYl26TTX/tIeEov7MQnvoPidzfg2ldTcswmZV4uz1RGZ7/odxVuV
 VN3VD8zCd6he0EYxdSqH
 =p5+M
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABCAAGBQJbGrPRAAoJEOPQILQNRairLs8P/37fPm1PQIatry/RovNGzu9Q
 CwZEJJDocVz6wc5d9XJoFr5pXnkj0jHzbMd7Bw1JI3/nAnY6H79gKJnK/KJluKkx
 vI79iKmTQyjb4r2mJt9k9XPevDkQlAxFTEpkvP/uAGhqkArQlUbLV1Hp9wPf6oH3
 Qn9mrGi68/h/ENiYpcIAJAbnJj+QUDcHqZeb7c7omX5VKWK3gdl+chBqEqnOCoAm
 1cfKpKDNp3jQHr4dY72MAjYbGBwQRRqRfmwadwjydwKVd22lY4Tc2EnEKRjurlyY
 y/QczFS/0XzPG+Y4Ft11fCkiVJMi/8GJkJZFmCOHi8R49U78Pb5bNpeEbLLRBMCO
 ECMXw/G7YjmlJ1A97AobBAlmGtISNcTT/ia0cgZGEKgZhPmMxNgIIK6ooNYsuOly
 s7M9CYqZ/erH4C94XnJbvWimWbmYai0PwqVb00wOvW4d5vN0YE1Rhq/s4k0UOtnz
 wXpb0acRDVS0sL4m5dyljOBlQ8ChPeJo7+B10yjXj7SBFZ/8XgNtLF+rqQW7Fsyf
 JBgHmj/6nDij4OWa8C8pfv57oXWkMVokopvoChXOWQdiElMF7IyV2wrgAtIsQIKf
 9Sk3pX/E7a2J6cVwrNm/WwlLVWdXNX4PxcK77B7FAXFDxCKBc+fUq3L0jzrKFHAW
 rUWBbzWvK4RHkJO83l67
 =wbJ6
 -----END PGP SIGNATURE-----

Merge tag v0.7.1 into v0.8.x
v0.7.1

# gpg: Signature made Fri 08 Jun 2018 18:50:24 CEST
# gpg:                using RSA key E3D020B40D45A8AB
# gpg: Good signature from "Leandro Lucarella <leandro.lucarella@sociomantic.com>"

* tag 'v0.7.1':
  Update Windows Travis Deploy Regex (#354)
  Deploy binaries to GitHub releases (Linux/MacOS) (#348)
2018-06-08 18:50:25 +02:00
Leandro Lucarella 4fd89f1f41 v0.8.1
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABCAAGBQJbGrPRAAoJEOPQILQNRairbNQQAKDzxypJ5XjWhgBl9mALP4ia
 jPAZhaUXrPNNXmTVc6X09BwMPEqldC51AbMM2x7b81g6IjxEi4mk38yOy+ZAVaaX
 GMEHHXrSX6PspCxBgjICOkYEy2ADZkZ1PfpZrv93fNVLQb1rRdGnOV8sxLqCMdiJ
 IpYasQoFSiJFgjhaZPvY9/mTcV701OXrRQrLjpEhjJM3hWsXjs9x2VukcImebaOE
 OidjUqGDlqVNTBnNRNihJ6n47sZBredUeTyRG5eCdaoXUGQe4kToo96kX2LefObr
 JSXAkAdVuNFq4Ffk9F/wXL6NyR197c1Y5x5MDMFv+bF7COQt7K0PsAIX7whw5y9S
 LHfuopY/2hyHad5qW6T1itIFVESIRXNGk6DkLeZ2MnozbyByjEVam3gOkRCKYdIw
 R205SVyB9CVLOZ/jw/gEROc9dBqDkh0lsIAYhQuWHV3tqr3vxqj2L/X1w8IsJu64
 2ldMvz4ZkgcaE0h2SWm1ZAeyag5nTXJG/rJ2F7lY/lBd3NNDHNtygyKtLtO+cMdd
 i33zwif22tDAm1IF6A8JFIWZvCwONleffX5B3FKnozKWPln60GFdcEP6BUeoPTp+
 DGHpKcHFZpfbWvlqhdpDf4dkCHjehlUuTCSqnG+LWp13GgDxuX+v/iQOmIpMQlSJ
 dJnlL9Or+QrNhqzyqyFE
 =5WQY
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABCAAGBQJbGrPRAAoJEOPQILQNRairJW0P/2+P9IGiHdJtrOrU7OBiT4Ml
 xYawWos4FILLHgoj/W3zPUqSkMCq1w4WcvOKG4A3eHaC6+xnyDQwN6uCysfd2tIO
 Pk8Afam5g+EpFf9ZnjnxChpBKIb3UHplkdKcL0tWCvzBjRbXycR3pxW/UVx8WQ+V
 UY3S9lcgbZW7PBBRZbCPRhviFZnNL48apN+pVGmV7gWc0BNpA8muFTL/I7bA+gpP
 MEZ6xYC+xV+1qKoJ9oyxAC/LUwt0nsw2uWc/y+C55hhKUdOchQDboc8V7ythBdCT
 c83hpvrnElvbxKpaKsWJs6+rL8Cvp3ongKh/4sdGKLK44HKmU/usNk70dbDI7oTa
 dHxjq1Cyl6cPJ4Xmmhpxke2UEvS6vPKdcRXJDVtopKVssWZqGlnfDrPmdGICnFqc
 g0yxKMxu7LN6dHczCaVPmLc77TbBhJyAF4taMnFY539P/ME0cnOXPQNdBSK4uO+C
 44zydEPVLPrf/y1hYQS1u+So/klUNxFR/9JCNBcSat9QqneUL6vS+kx97MSXGq8p
 oNvndoI3uzoju6UmEgKLm3+1iTBLAieZPDRCOgFXvfksgr3HjZEdJU+QyqtKARuV
 hjWMM/QIFO3vutOSn5Asqc/wgQBpyUrHoMmm0dGptGOW3S8XauFkW5D7z78+Slbm
 xD+cPH9UHku04aaY0/Eb
 =6HPM
 -----END PGP SIGNATURE-----

Merge tag v0.8.1 into v0.x.x
v0.8.1

# gpg: Signature made Fri 08 Jun 2018 18:50:25 CEST
# gpg:                using RSA key E3D020B40D45A8AB
# gpg: Good signature from "Leandro Lucarella <leandro.lucarella@sociomantic.com>"

* tag 'v0.8.1':
  Update Windows Travis Deploy Regex (#354)
  Deploy binaries to GitHub releases (Linux/MacOS) (#348)
2018-06-08 18:50:25 +02:00
Stefan Koch 8f76cce8db Clear release notes after release 2018-05-29 16:17:05 +02:00
Stefan Koch b416d72221 Add ufcs formatting relnotes 2018-05-29 16:05:25 +02:00
BBasile 2284d98ef7 Update stdx alloc for future removal of std.c (#357) 2018-05-26 20:04:38 +02:00
Hackerpilot 1753127e74 Update dub file to bring in newer libdparse 2018-05-09 16:06:12 +02:00
Hackerpilot c4b9178e81 Better formatting for UFCS chains 2018-05-09 16:06:12 +02:00
Sebastian Wilzbach c2aea82395
Update Windows Travis Deploy Regex (#354) 2018-05-08 23:43:41 +02:00
Brian Schott 6eb7b95173 Fix #351 (#352)
Fix #351
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-05-07 07:04:19 +02:00
Sebastian Wilzbach c4e7335850
Deploy binaries to GitHub releases (Linux/MacOS) (#348) 2018-04-23 23:17:01 +02:00
notna123 08f73d216b Update main.d (#347)
GIT repo change from "Hackerpilot" to "dlang-community"
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-03-27 08:59:46 +02:00
Stefan Koch 8c95061c1a Clear release notes after release 2018-03-14 16:40:37 +01:00
Stefan Koch 4168c232ab Add relnotes 2018-03-14 16:39:28 +01:00
Stefan Koch 25cdc1f885 Merge branch 'v0.6.x' into v0.x.x 2018-03-14 16:29:35 +01:00
Stefan Koch b3411a3303 Fix Imports to point to the actual symbols rather then wrongly imported ones. 2018-03-08 11:57:07 +01:00
Stefan Koch 0167863b33 Ignore empty files while formatting 2018-03-08 11:57:07 +01:00
Stefan Koch eb576e21fd Add empty test files 2018-03-08 11:57:07 +01:00
Stefan Koch 0cc3543c2b Add tests 2018-03-07 21:18:25 +01:00
Stefan Koch e535f0b2b0 Fix the issue #237
In formatLeftBrace remember if we indented because of a StructInitialzer;
If we did we revert the intdent in formatRightBrace
2018-03-07 21:18:25 +01:00
Stefan Koch dca63110f7 Optionally return position in canFindIndex 2018-03-07 21:18:25 +01:00
Stefan Koch c4a7f9cb04 Add Field to store BraceIndentInfo 2018-03-07 21:18:25 +01:00
BBasile b01c624ef0 fix #236 - Allow constraints to be indented by a single tab (#337)
fix #236 - Allow constraints to be indented by a single tab
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-03-02 16:26:54 +01:00
Stefan Koch 95905cdbf1 Simplify indentStack code 2018-02-28 12:16:16 +01:00
Stefan Koch 8333180e27 Add empty test files 2018-02-27 07:42:18 +01:00
Stefan Koch d04afa8ea7 Ignore empty files while formatting 2018-02-27 07:42:18 +01:00
Sebastian Wilzbach b545048ac1 Fix spacing in the README example (#338)
[trivial] Fix spacing in the README example
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-02-25 03:19:47 +01:00
Stefan Koch 294c975d49 Fix Imports to point to the actual symbols rather then wrongly imported ones. 2018-02-22 20:58:08 +01:00
Stefan Koch 4f7f37d664 Change to more effcient optionsToString template 2018-02-22 10:28:21 +01:00
Stefan Koch 06d58ff83a Fix bad formatting in main.d 2018-02-22 00:02:34 +01:00
Stefan Koch 181f388d17 Merge tag v0.6.1 into v0.x.x 2018-02-20 12:47:20 +01:00
Richard Andrew Cattermole 4725a622c6
Merge pull request #333 from stefan-koch-sociomantic/fix_completion_install
Fix pkg file to put bash-completion into the right place
2018-02-20 23:35:29 +13:00
Stefan Koch 358b6e91ea Fix pkg file to put bash-completion into the right place
The correct directory for completion scripts is bash-completion/completions/dfmt
2018-02-20 10:18:47 +01:00
Stefan Koch 5da7fd4dc9 Clear release notes after release 2018-02-19 17:17:24 +01:00
Stefan Koch e9273c169e Add relnotes 2018-02-19 16:39:32 +01:00
The Dlang Bot aab2f07f16
Merge pull request #332 from some-bot/merge-libdparse-v0.8.0-alpha.5
Update dlibparse to v0.8.0-alpha.5
merged-on-behalf-of: Dlang Community Bot <some-bot@users.noreply.github.com>
2018-02-17 03:16:25 +01:00
some-bot 0b650cc5ae Updated libdparse to v0.8.0-alpha.5. 2018-02-17 01:37:27 +00:00
The Dlang Bot 40f3d5b0a8
Merge pull request #331 from wilzbach/update-dfmt
Bump dependencies
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-02-11 21:01:57 +01:00
Basile Burg c697d88bb2 update bat file for stdx module names 2018-02-11 20:56:46 +01:00
Sebastian Wilzbach 851434ce9d Bump depenencies 2018-02-11 16:11:24 +01:00
The Dlang Bot 35d7da7391
Merge pull request #329 from wilzbach/stdx-allocator
Switch to use the frozen stdx-allocator
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
2018-02-11 16:09:38 +01:00
Sebastian Wilzbach fc3232308a Switch to use the frozen stdx-allocator 2018-02-11 15:20:26 +01:00
The Dlang Bot 89b890241d
Merge pull request #325 from some-bot/merge-libdparse-v0.8.0-alpha.3
Update dlibparse to v0.8.0-alpha.3
merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
2018-02-07 02:09:40 +01:00
Brian Schott 5ce4df17a2
Merge pull request #324 from dlang-community/issue-313
Fix #313, and implement a better fix for #314
2018-02-04 16:58:22 -08:00
some-bot 2856641b12 Updated libdparse to v0.8.0-alpha.3. 2018-02-05 00:53:12 +00:00
Hackerpilot a8ac400830 Fix #313, and implement a better fix for #314 2018-02-02 04:48:57 -08:00
Sebastian Wilzbach 763d61031c
Merge pull request #323 from dlang-community/appveyor-no-nightly
Remove dmd-nightly + dmd-beta from AppVeyor
2018-02-02 11:34:35 +01:00
Sebastian Wilzbach f0b34c9889
Remove dmd-nightly + dmd-beta from AppVeyor 2018-02-02 11:34:20 +01:00
Sebastian Wilzbach 8cebd50ea6
Merge pull request #322 from dlang-community/issue-321
Fix #321
2018-02-02 11:31:51 +01:00
Hackerpilot 5aedb2b84b Fix #321 2018-02-02 00:52:30 -08:00
Stefan Koch 19a869377a Fix bintray upload 2018-01-30 15:39:32 +01:00
Brian Schott 0a351990c2
Merge pull request #318 from dlang-community/issue_314
Issue 314
2018-01-29 19:52:33 -08:00
Hackerpilot ef0c81876a Comment out LDC builds 2018-01-29 17:33:41 -08:00
Hackerpilot 1ca3bd9255 Fix #314 2018-01-29 14:18:59 -08:00
Hackerpilot 19e774ebf7 Un-comment the debug functionality of the indentation stack 2018-01-29 14:17:43 -08:00
stefan-koch-sociomantic 060d3f5a80
Disable osx (#317)
* Disable osx

* Remove "since"
2018-01-26 15:35:13 +01:00
Sebastian Wilzbach 0b71891072
Merge pull request #311 from stefan-koch-sociomantic/add_beaver
Deploy tagged versions from CI
2018-01-25 18:49:32 +01:00
Stefan Koch 30f1d2c8c0 Use beaver to deploy the xenial-package 2018-01-25 18:47:32 +01:00
Stefan Koch a58be55592 Add Beaver as submodule
* beaver ()...v0.3.2(82f8c8f) (1 commits)
  > Fix spelling of BEAVER_DOCKER_IMG
2018-01-25 18:47:17 +01:00
Sebastian Wilzbach 96948fd0da
Merge pull request #315 from some-bot/merge-libdparse-v0.7.2-alpha.6
Updated libdparse to v0.7.2-alpha.6.
2018-01-25 18:45:48 +01:00
Sebastian Wilzbach 6e598c197d
Merge pull request #316 from RazvanN7/Fix_imports
Make alias visit public in src/dfmt/ast_info.FormatVisitor
2018-01-25 12:34:03 +01:00
RazvanN7 d88e1fa5dd Make alias visit public in src/dfmt/ast_info.FormatVisitor 2018-01-25 13:30:34 +02:00
some-bot 6887982cb2 Updated libdparse to v0.7.2-alpha.6. 2018-01-24 22:47:37 +00:00
The Dlang Bot 7004683d9d
Merge pull request #309 from stefan-koch-sociomantic/all_constructors
Put a space behind static and shared constructors as well
merged-on-behalf-of: stefan-koch-sociomantic <stefan-koch-sociomantic@users.noreply.github.com>
2017-12-12 14:22:03 +01:00
Stefan Koch d8f9cfeae1 Put a space behind static and shared constructors as well 2017-12-11 18:07:21 +01:00
The Dlang Bot 23bd2b408c
Merge pull request #307 from stefan-koch-sociomantic/sbfp-fix
Sbfp fix
merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
2017-12-05 12:18:13 +01:00
Stefan Koch ddd86f96d8 make --spaces_before_functoion_parameters work in more cases as well as on constructors 2017-12-04 16:02:22 +01:00
The Dlang Bot 82ec339251
Merge pull request #306 from stefan-koch-sociomantic/fix_sbfp
fix space_before_function_parameters
merged-on-behalf-of: stefan-koch-sociomantic <stefan-koch-sociomantic@users.noreply.github.com>
2017-11-30 06:49:33 +01:00
Stefan Koch aa45bda1a8 fix space_before_function_parameters 2017-11-29 17:20:00 +01:00
The Dlang Bot 4feb467dab
Merge pull request #304 from kotet/issue-303
Add support for `static foreach`
merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
2017-11-29 07:17:03 +01:00
Kotet 01a1716183 Update libdparse to v0.7.2-alpha.3 2017-11-29 06:19:36 +09:00
The Dlang Bot 5ed20e0a3c
Merge pull request #305 from stefan-koch-sociomantic/fix-301
Fix issue #301
merged-on-behalf-of: stefan-koch-sociomantic <stefan-koch-sociomantic@users.noreply.github.com>
2017-11-28 11:57:31 +01:00
Stefan Koch b69e966df6 Fix issue #301
By adding private and static as valid import prefix
2017-11-28 10:56:55 +01:00
Kotet 8cd9265384 Fix test 2017-11-27 07:37:09 +09:00
Kotet abc3e6d47e Use std.algorithm.comparison.among instead of a lot of comparisons 2017-11-27 07:32:05 +09:00
Kotet a163eb105f Add support for `static foreach`
Fix #303
2017-11-25 13:20:49 +09:00
Sebastian Wilzbach b227c66146
Merge pull request #293 from stefan-koch-sociomantic/makd
Build debian package using Makd
2017-11-21 16:12:27 +01:00
Stefan Koch d1974d95fb Build debain package using makd
- Add makd submodule

* makd ()...v2.0.1(d735c1d) (1 commits)
  > Fix calls to `find`
2017-11-06 11:37:29 +01:00
Leandro Lucarella ab45e03701
Merge pull request #294 from stefan-koch-sociomantic/views_version
Generate version-string from git-describe
2017-11-03 16:18:20 +01:00
Stefan Koch 0847016346 add views/VERSION target to generate the version-number from git 2017-11-03 14:08:53 +01:00
Brian Schott 9b4de1a3e5
Merge pull request #299 from stefan-koch-sociomantic/update_completion_2
Add true/false completion for boolean options
2017-11-01 15:52:44 -07:00
Stefan Koch 797b4f2005 Add true/false completion for boolean options 2017-10-30 15:45:10 +01:00
Brian Schott 6de8ff2037
Merge pull request #298 from stefan-koch-sociomantic/fix_sbfp
[UrgentBugifx] Fix space before function parameters
2017-10-29 01:12:49 -07:00
Stefan Koch ec2e223b9a fix bug in --space_before_function_parameters 2017-10-27 16:44:54 +02:00
Brian Schott 3559aa9e52 Merge pull request #297 from dlang-community/issue-248
Fix #248
2017-10-26 13:43:42 -07:00
stefan-koch-sociomantic 1c22b3d5e1 Merge pull request #296 from stefan-koch-sociomantic/add_completion
add --space_before_function_parameters to completion
2017-10-26 10:48:29 +02:00
Hackerpilot 00fda4f5eb Fix #248 2017-10-25 13:26:35 -07:00
Stefan Koch cc39c3fce4 add --space_before_function_parameters to completion 2017-10-24 18:57:29 +02:00
The Dlang Bot e35d41d75e Merge pull request #295 from stefan-koch-sociomantic/document_new_arg
document --space_before_function_parameters
merged-on-behalf-of: Richard Andrew Cattermole <alphaglosined@gmail.com>
2017-10-20 15:50:59 +02:00
Stefan Koch 2de336c39e document --space_before_function_parameters 2017-10-20 13:14:27 +02:00
stefan-koch-sociomantic 7f472d8ddf change repo from Hackerpilot to dlang-community (#292)
change repo from Hackerpilot to dlang-community
merged-on-behalf-of: Petar Kirov <ZombineDev@users.noreply.github.com>
2017-10-16 14:02:08 +02:00
Richard Andrew Cattermole 02a735cb0c Merge pull request #290 from stefan-koch-sociomantic/safp
add --space_before_function_parameters
2017-10-12 21:34:51 +13:00
Stefan Koch 02ba81333e add --space_before_function_parameters 2017-10-11 16:29:14 +02:00
The Dlang Bot 87fd168e06 Merge pull request #289 from stefan-koch-sociomantic/perf_fixes
small perf fix chaching the eol string instead of switching all the time
merged-on-behalf-of: Petar Kirov <ZombineDev@users.noreply.github.com>
2017-10-07 10:24:47 +02:00
Stefan Koch 7c0e4747ed small perf fix chaching the eol string instead of switching all the time 2017-10-06 17:04:01 +02:00
The Dlang Bot 45c2a961a6 Merge pull request #288 from kas-luthor/master
Look for .editorconfig in cwd and parent directories …
merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
2017-09-01 23:22:04 +02:00
kas-luthor 2645e9cc1f Look for .editorconfig in cwd and parent directories when readinf from STDIN and no explicit config dir given on command line 2017-09-01 09:15:13 +02:00
Basile Burg aa93473702 Merge pull request #285 from dlang-community/upd-dparse
update dparse
2017-07-27 10:43:57 +02:00
Basile Burg aba1116775
update dparse 2017-07-27 10:18:20 +02:00
The Dlang Bot ea72aa5492 Merge pull request #283 from WebFreak001/patch-1
Fix README typo
merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
2017-07-02 16:39:31 +02:00
Jan Jurzitza 7480230ee1 Fix README typo 2017-07-02 16:21:04 +02:00
Basile Burg 31e498f3b0 Merge pull request #282 from wilzbach/enable-appveyor
Enable testing on Windows with AppVeyor
2017-06-10 20:44:08 +02:00
Sebastian Wilzbach f26f1f28bd Enable testing on Windows with AppVeyor 2017-06-10 19:48:44 +02:00
Sebastian Wilzbach fef85e388a Set DUB config type to `autodetect` (#281) 2017-05-22 20:21:31 +03:00
Basile Burg 7f9e6ac7b5 Merge pull request #279 from wilzbach/dub-readme
Add installing with DUB instructions
2017-05-22 10:32:15 +02:00
Sebastian Wilzbach 50a3241f04 Add dmd-nightly and ldc-beta to the Travis CI config (#280) 2017-05-20 19:23:56 +03:00
skl131313 b7c3a3686b Merge pull request #278 from skl131313/travis-dub
Refactor travis config to include dub, osx, and ldc.
2017-05-17 11:00:37 -04:00
Sebastian Wilzbach 80fe7c02e6 Add installing with DUB instructions 2017-05-17 13:19:10 +02:00
skl131313 8361a3a153 Refactor travis config to include dub, osx, and ldc. 2017-05-17 01:28:35 -04:00
Brian Schott a93efb66fb Merge pull request #271 from CZDanol/master
Fix -c flag not looking into the *bottom level folder
2017-05-12 14:49:49 -07:00
Brian Schott 0e5d314eb5 Merge pull request #276 from BBasile/badge-address
update badge address
2017-05-09 14:45:10 -07:00
Basile Burg a7f6a0007a update badge address 2017-05-09 16:38:24 +02:00
Hackerpilot 019d42a4dc Fix #273 2017-03-07 16:12:27 -08:00
Hackerpilot 9fb13d0caf Merge branch 'master' of https://github.com/Hackerpilot/dfmt 2017-02-13 11:03:07 -08:00
Hackerpilot fcd2b50e60 Update dependencies 2017-02-13 11:02:50 -08:00
Daniel 'Danol' Čejchan 98aad22f67 Fix -c flag not looking into the top level folder 2017-01-17 12:57:05 +01:00
Brian Schott 4a4704896b Merge pull request #265 from leandro-lucarella-sociomantic/patch-1
Fix typo in help message
2016-12-05 16:15:20 -08:00
Brian Schott b50d36bf12 Merge pull request #264 from BBasile/fix-win-2072
fix #263, Impossible to build under Windows with phobos 2.072
2016-12-05 16:15:02 -08:00
Leandro Lucarella d95d69e31b Fix typo in help message
`.editconfig` should be `.editorconfig` instead.
2016-11-14 16:59:18 +01:00
Basile Burg 593b9885ff fix #263, Impossible to build under Windows with phobos 2.072 2016-11-11 23:04:28 +01:00
Hackerpilot 7961bfc15f #261 2016-11-07 13:18:12 -08:00
Hackerpilot 5da2a71a67 Update libdparse 2016-06-30 17:41:21 -07:00
Hackerpilot 821f9439e4 Fix #251 2016-06-30 17:41:13 -07:00
Brian Schott e3bf26987b Merge pull request #250 from ZombineDev/fix-ms-crt-stdio
Fix compilation in Windows for CRuntime_Microsoft
2016-06-14 12:42:07 -07:00
ZombineDev e92b90bbf8 Fix compilation in Windows for CRuntime_Microsoft
Use _setmode instead of setmode, because it works for all supported C runtimes on Windows.
This should fix compilation errors for dmd -m32coff, m64, and ldc2 (LDC uses only CRuntime_Microsoft).
2016-06-14 18:39:21 +03:00
Brian Schott 90b68b7e57 Merge pull request #242 from shishkander/issue240
Add option to specify where to look for .editorconfig files.
2016-05-04 15:26:31 -07:00
Andrii Shyshkalov afd5799eb1 Add option to specify where to look for .editorconfig files.
Adds a --config|c option which takes a directory in which the search for
.editorconfig files will start.

When --config|c is used together with explicit filenames of files to format,
.editorconfig is searched only in --config directory, and not in directories
where files are.

Fixes #240.
2016-05-04 12:49:21 +02:00
Hackerpilot c353f484a6 Update dparse 2016-04-28 15:27:57 -07:00
Hackerpilot d6861cc5a2 Fix #241 2016-04-28 15:23:00 -07:00
Brian Schott 049b151bac Merge pull request #239 from BBasile/fix-win
windows: fix imports for dmd 2.071 + update bat
2016-04-14 12:36:21 -07:00
Basile Burg 2d18ded428 fix imports for dmd 2.071 + update win bat 2016-04-14 21:08:24 +02:00
Hackerpilot 0f7727e31b Fix #235 2016-03-27 23:29:38 -07:00
Hackerpilot 2031dbdc71 Fix parse error 2016-03-27 22:47:30 -07:00
Hackerpilot 789019fc86 Update parser and fix imports for 2.071 2016-03-27 22:37:15 -07:00
Brian Schott 2145766d89 Merge pull request #233 from gkotian/master
More minor fixes
2016-02-29 15:16:11 -08:00
Gautam Kotian 09867bc3e5 Fix default value in README 2016-02-29 23:56:42 +01:00
Gautam Kotian 1392ef52cf Fix typo 2016-02-29 23:56:24 +01:00
Brian Schott 1a80fd742a Merge pull request #232 from gkotian/master
Minor Fixes
2016-02-27 15:40:03 -08:00
Gautam Kotian d7737c0da5 Add missing parameters in function documentation 2016-02-28 00:13:00 +01:00
Gautam Kotian 649ee08e62 Fix typo in function name 2016-02-28 00:12:11 +01:00
Gautam Kotian be6f5706ae Fix typos 2016-02-28 00:11:19 +01:00
Hackerpilot 65ac0871fd Fix #229 2016-02-25 14:02:12 -08:00
Hackerpilot 19801d4796 Update libdparse 2016-02-25 14:01:40 -08:00
Hackerpilot 1d7ee7b3e7 Update parser 2016-02-05 02:38:23 -08:00
Hackerpilot fd214032a4 Fix bug with multi-line string literals 2016-02-01 00:35:26 -08:00
Hackerpilot 3bc810dcd4 Update libdparse 2016-01-29 02:00:18 -08:00
Hackerpilot 2a4526c8be Update libdparse 2016-01-28 02:39:02 -08:00
Hackerpilot 851affb63c Docopt-style help output 2016-01-26 23:55:56 -08:00
Hackerpilot 845358bb61 Prefer breaking on ternary operators 2016-01-26 13:05:59 -08:00
Hackerpilot c1f189b124 Run dfmt on itself 2016-01-26 13:02:06 -08:00
Hackerpilot 0ea6b340a4 Fix #226 2016-01-26 12:56:19 -08:00
Hackerpilot e6fe5df515 Improve line wrapping heuristics 2016-01-25 05:24:09 -08:00
Hackerpilot 0eea53a628 Fix #225 2016-01-22 19:06:09 -08:00
Hackerpilot e2d23726b9 Fix #224 2016-01-22 18:48:36 -08:00
Hackerpilot 268657831b Fix #219 2016-01-22 04:53:20 -08:00
Hackerpilot 98f443d3f1 Fix #220 2016-01-22 04:48:29 -08:00
Hackerpilot ee8fcd41f4 Fix #223 2016-01-22 01:51:44 -08:00
Hackerpilot 08c2d0c5e8 Fix #222 2016-01-21 22:11:32 -08:00
Hackerpilot db2ad1354b Fix #221 2016-01-20 17:00:46 -08:00
Hackerpilot 3c6ea77a12 Fix an incredibly annoying bug where line break info was being ignored when wrapping at commas 2016-01-20 03:28:31 -08:00
Hackerpilot 74d7644106 Stop using old beta compiler 2016-01-20 03:00:21 -08:00
Hackerpilot cac45e3607 Fix formatting issue 2016-01-20 02:58:42 -08:00
Hackerpilot e8a6b40432 Fix issue where constraints would not be detected correctly while formatting. 2016-01-20 02:43:10 -08:00
Hackerpilot cc7dab0341 Fix problem where bash completion script would not allow user to complete file names 2016-01-20 02:33:16 -08:00
Hackerpilot fa75eedb36 Add another missing item to the readme 2016-01-19 20:28:22 -08:00
Hackerpilot cf27387180 Merge branch 'indentation-madness' 2016-01-19 20:10:44 -08:00
Hackerpilot abe51015c4 Add bash completion support. Fix #218 2016-01-19 20:10:15 -08:00
Hackerpilot 4c5dfb5881 Fix option printing 2016-01-19 20:09:01 -08:00
Hackerpilot fbd28814e7 Fix missing cell in table 2016-01-19 20:03:41 -08:00
Hackerpilot 3d7f55495a Document template constraint formatting options 2016-01-19 19:49:15 -08:00
Hackerpilot 387826ba37 Fix option printing 2016-01-19 19:48:28 -08:00
Brian Schott 87c70065d5 Merge pull request #217 from Hackerpilot/indentation-madness
0.5.0 changes
2016-01-19 05:27:15 -08:00
Hackerpilot 6327175fde Fix build 2016-01-19 05:26:23 -08:00
Hackerpilot ad8debe030 0.5.0-alpha 2016-01-19 05:24:16 -08:00
Hackerpilot 93c80460cd Run dfmt on itself 2016-01-19 05:22:32 -08:00
Hackerpilot 24be6ddc2e Run dfmt on itself and debug some wrapping calculations 2016-01-19 05:20:31 -08:00
Hackerpilot 7ec932a1e3 Indentation rework 2016-01-19 03:58:19 -08:00
Hackerpilot bf0843f321 Attempt to improve indentation code 2016-01-19 01:45:30 -08:00
Hackerpilot 7fa11c8505 Initial work on #215 2016-01-18 17:59:26 -08:00
Hackerpilot 4fe021df97 Increment version number 2016-01-18 15:33:35 -08:00
Hackerpilot ca49180a95 Fix #213 2016-01-18 15:32:49 -08:00
Hackerpilot 7a9a895f64 Fix #210 and run dfmt on itself 2016-01-18 15:10:39 -08:00
Hackerpilot 65a55493da Fix #212 2016-01-18 14:18:09 -08:00
Hackerpilot 75c3278a32 Fix #216 2016-01-18 14:06:47 -08:00
Hackerpilot c53eb5e0e4 bump version number 2016-01-15 18:03:45 -08:00
Hackerpilot bab1a5f592 Fix #209 2016-01-15 18:01:48 -08:00
Hackerpilot 382258eb97 Fix #208 2016-01-15 16:29:00 -08:00
Hackerpilot f14c6e1226 Fix #207 2016-01-14 16:02:24 -08:00
Hackerpilot ebb2db9303 Version bump 2016-01-14 14:40:54 -08:00
Hackerpilot 3e5307f081 Fix #206 2016-01-14 14:40:16 -08:00
Hackerpilot 86b61ce2fc Tests for #205 2016-01-14 14:28:15 -08:00
Hackerpilot 2402978c3a Fix #205 2016-01-14 14:22:23 -08:00
Hackerpilot 0d041834db Fix version number 2016-01-14 03:29:52 -08:00
Hackerpilot 6a8826b379 Update dub config 2016-01-14 00:14:24 -08:00
Hackerpilot 83ad53c53f Update .gitignore 2016-01-14 00:13:02 -08:00
Hackerpilot 9fc36fe587 Fix #204 2016-01-13 20:52:26 -08:00
Hackerpilot 8847c6155b Update libdparse 2016-01-13 20:52:00 -08:00
Hackerpilot 8c3e151561 Better line breaking for UFCS chains 2016-01-13 04:52:32 -08:00
Brian Schott 9f81f0e13e Merge pull request #201 from JohanEngelen/fix_win_EOL
Fix EOL output on Windows. Stdout has to be set to binary mode.
2016-01-12 16:26:54 -08:00
Johan Engelen dd3b48ade0 Fix EOL output on Windows. Stdout has to be set to binary mode. 2016-01-13 00:59:03 +01:00
Hackerpilot 9f5a3dd61d Update libdparse 2016-01-11 17:55:50 -08:00
Hackerpilot c80e1a067e Fix #199 2016-01-11 14:30:40 -08:00
Brian Schott 8e67e52f96 Merge pull request #197 from kkwiatkowski/master
dfmt should be buildable under windows
2016-01-06 17:04:59 -08:00
Konrad Kwiatkowski b04e179400 dfmt should be buildable under windows 2016-01-07 01:32:14 +01:00
Hackerpilot 8035beec4f Run dfmt on itself 2015-12-14 15:31:53 -08:00
Hackerpilot b3faa3103c Fix #194 2015-12-14 15:24:48 -08:00
Brian Schott 43aa8437ba Merge pull request #193 from UplinkCoder/master
add printOption to help
2015-12-09 12:47:32 -08:00
Stefan Koch 7406027c52 add printOption to help 2015-12-09 16:23:08 +00:00
Hackerpilot b8a96bfd7d Update libdparse 2015-10-29 16:19:51 -07:00
Hackerpilot ce5953aaff Remove redundant 'inplace' documentation 2015-10-21 16:24:45 -07:00
Hackerpilot 5ce683bab2 0.4.1 2015-10-21 16:11:04 -07:00
Brian Schott faf006268d Merge pull request #191 from MartinNowak/inplace
allow short opt -i for --inplace
2015-10-21 09:54:23 -07:00
Brian Schott 5bc2d62a1f Merge pull request #192 from MartinNowak/patch-1
wrong default value in readme
2015-10-21 09:48:57 -07:00
Martin Nowak eb147bb1f3 wrong default value in readme 2015-10-21 14:05:48 +02:00
Martin Nowak cf6ffb4399 allow short opt -i for --inplace 2015-10-21 13:45:02 +02:00
Hackerpilot f9b1997283 Fix #190 2015-10-09 14:21:30 -07:00
Hackerpilot 1b6e6a5f4e Update libdparse 2015-10-09 14:19:22 -07:00
Hackerpilot 46db867c41 Fix regression 2015-09-18 10:46:20 -07:00
Hackerpilot a9426cb44f Fix #189 2015-09-17 22:58:39 -07:00
Hackerpilot ac17371c10 0.4.0 2015-09-17 03:11:57 -07:00
Hackerpilot 0ecdc7f3d1 Fix #188 2015-09-17 03:01:29 -07:00
Hackerpilot d771955ad3 Fix #186 2015-09-17 02:52:35 -07:00
Hackerpilot b7f045fd5e Fix #182 2015-09-16 17:58:26 -07:00
Hackerpilot 0389d798d7 Fix #187 2015-09-16 17:20:16 -07:00
Hackerpilot 480e6fe973 Use environment variables to choose compilers 2015-09-16 17:16:49 -07:00
Hackerpilot ad1cea991f Use the beta so that the build will pass 2015-09-16 17:14:37 -07:00
Hackerpilot b0d6da28f5 Fix #185 2015-09-16 17:07:39 -07:00
Brian Schott 23df06cdc9 Merge pull request #179 from Hackerpilot/issue-172
#172
2015-08-24 13:32:11 -07:00
Brian Schott 773e8bcd34 Merge pull request #178 from Hackerpilot/issue-177
Fix #177
2015-08-24 13:30:41 -07:00
Hackerpilot 9cad754411 Show build status for master branch 2015-08-24 13:30:21 -07:00
Hackerpilot 43cfa09e7e Fix #177 2015-08-24 13:28:16 -07:00
Hackerpilot 699ae10458 #172 2015-08-24 12:44:52 -07:00
Brian Schott 46669f8073 Merge pull request #175 from qznc/fix174
enum can also be used in is() expressions
2015-08-21 13:08:06 -07:00
Andreas Zwinkau eea508f930 enum can also be used in is() expressions
fixes #174
2015-08-21 19:13:08 +02:00
Brian Schott e4297a63c3 Merge pull request #171 from btbytes/master
correct installation instruction.
2015-08-10 19:15:06 -07:00
Pradeep Gowda a7c52f4d5d correct installation instruction.
without the `--recursive` option the `experimental_allocator` dependency will not be available.
2015-08-10 21:56:59 -04:00
705 changed files with 10831 additions and 687 deletions

16
.gitattributes vendored Normal file
View File

@ -0,0 +1,16 @@
tests/issue0228.d text eol=lf
tests/allman/issue0228.d.ref text eol=crlf
tests/knr/issue0228.d.ref text eol=crlf
tests/otbs/issue0228.d.ref text eol=crlf
tests/issue0552_lf.d text eol=lf
tests/allman/issue0552_lf.d.ref text eol=lf
tests/knr/issue0552_lf.d.ref text eol=lf
tests/otbs/issue0552_lf.d.ref text eol=lf
tests/issue0552_cr.d text eol=cr
tests/allman/issue0552_cr.d.ref text eol=cr
tests/knr/issue0552_cr.d.ref text eol=cr
tests/otbs/issue0552_cr.d.ref text eol=cr
tests/issue0552_crlf.d text eol=crlf
tests/allman/issue0552_crlf.d.ref text eol=crlf
tests/knr/issue0552_crlf.d.ref text eol=crlf
tests/otbs/issue0552_crlf.d.ref text eol=crlf

34
.github/workflows/d.yml vendored Normal file
View File

@ -0,0 +1,34 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: D
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dlang-community/setup-dlang@4c99aa991ce7d19dd3064de0a4f2f6b2f152e2d7
- name: 'Build & Test'
run: |
# Build the project, with its main file included, without unittests
dub build --compiler=$DC
# Build and run tests, as defined by `unittest` configuration
# In this mode, `mainSourceFile` is excluded and `version (unittest)` are included
# See https://dub.pm/package-format-json.html#configurations
dub test --compiler=$DC
# Run tests
cd tests && rdmd test

2
.gitignore vendored
View File

@ -3,3 +3,5 @@ bin
*.d.out
.dub
dub.selections.json
.gdb_history
bin/dfmt

8
.gitmodules vendored
View File

@ -1,3 +1,9 @@
[submodule "libdparse"]
path = libdparse
url = https://github.com/Hackerpilot/libdparse.git
url = https://github.com/dlang-community/libdparse.git
[submodule "stdx-allocator"]
path = stdx-allocator
url = https://github.com/dlang-community/stdx-allocator
[submodule "d-test-utils"]
path = d-test-utils
url = https://github.com/dlang-community/d-test-utils.git

View File

@ -1,3 +0,0 @@
language: d
script:
- git submodule update --init --recursive && make test

123
README.md
View File

@ -1,46 +1,66 @@
# dfmt [![Build Status](https://travis-ci.org/Hackerpilot/dfmt.svg)](https://travis-ci.org/Hackerpilot/dfmt)
# dfmt [![Build Status](https://github.com/dlang-community/dfmt/actions/workflows/d.yml/badge.svg)](https://github.com/dlang-community/dfmt/actions?query=workflow%3A%22D%22)
**dfmt** is a formatter for D source code
## Status
**dfmt** is beta quality. Make backups of your files or use source control
when using the **--inplace** option.
## Building
### Using Make
## Installation
### Installing with DUB
```sh
> dub run dfmt -- -h
```
### Building from source using Make
* Clone the repository
* Run ```git submodule update --init``` in the dfmt directory
* Run ```git submodule update --init --recursive``` in the dfmt directory
* To compile with DMD, run ```make``` in the dfmt directory. To compile with
LDC, run ```make ldc``` instead. The generated binary will be placed in ```dfmt/bin/```.
### Building from source using dub
* Clone the repository
* run `dub build --build=release`, optionally with `--compiler=ldc2`
## Using
By default, dfmt reads its input from **stdin** and writes to **stdout**.
If a file name is specified on the command line, input will be read from the
file instead, and output will be written to **stdout**.
**dfmt** uses EditorConfig files for configuration. If you run **dfmt** on a
source file it will look for .editorconfig files that apply to that source file.
If no file is specified on the command line, **dfmt** will look for .editorconfig
**dfmt** uses [EditorConfig](http://editorconfig.org/) files for configuration. If you run **dfmt** on a
source file it will look for *.editorconfig* files that apply to that source file.
If no file is specified on the command line, **dfmt** will look for *.editorconfig*
files that would apply to a D file in the current working directory. Command
line options can be used instead of .editorconfig files, or to override options
found in .editorconfig files.
line options can be used instead of *.editorconfig* files, or to override options
found there.
### Options
* **--help**: Display command line options
* **--inplace**: A file name is required and the file will be edited in-place.
* **--align_switch_statements**: See **dfmt_align_switch_statements** below
* **--brace_style**: See **brace_style** below
* **--end_of_line**: See **end_of_line** below
* **--indent_size**: See **indent_size** below
* **--indent_style**: See **indent_style** below
* **--max_line_length**: See **max_line_length** below
* **--soft_max_line_length**: See **dfmt_soft_max_line_length** below
* **--outdent_attributes**: See **dfmt_outdent_attributes** below
* **--space_after_cast**: See **dfmt_space_after_cast** below
* **--split_operator_at_line_end**: See **dfmt_split_operator_at_line_end** below
* **--tab_width**: See **tab_width** below
* **--selective_import_space**: See **dfmt_selective_import_space** below
* **--compact_labeled_statements**: See **dfmt_compact_labeled_statements** below
* `--help | -h`: Display command line options.
* `--inplace | -i`: A file name is required and the file will be edited in-place.
* `--align_switch_statements`: *see dfmt_align_switch_statements [below](#dfmt-specific-properties)*
* `--brace_style`: *see dfmt_brace_style [below](#dfmt-specific-properties)*
* `--compact_labeled_statements`: *see dfmt_compact_labeled_statements [below](#dfmt-specific-properties)*
* `--end_of_line`: *see end_of_line [below](#standard-editorconfig-properties)*
* `--indent_size`: *see indent_size [below](#standard-editorconfig-properties)*
* `--indent_style | -t`: *see indent_style [below](#standard-editorconfig-properties)*
* `--max_line_length`: *see max_line_length [below](#standard-editorconfig-properties)*
* `--outdent_attributes`: *see dfmt_outdent_attributes [below](#dfmt-specific-properties)*
* `--selective_import_space`: *see dfmt_selective_import_space [below](#dfmt-specific-properties)*
* `--single_template_constraint_indent`: *see dfmt_single_template_constraint_indent [below](#dfmt-specific-properties)*
* `--soft_max_line_length`: *see dfmt_soft_max_line_length [below](#dfmt-specific-properties)*
* `--space_after_cast`: *see dfmt_space_after_cast [below](#dfmt-specific-properties)*
* `--space_before_aa_colon`: *see dfmt_space_before_aa_colon [below](#dfmt-specific-properties)*
* `--space_before_named_arg_colon`: *see dfmt_space_before_named_arg_colon [below](#dfmt-specific-properties)*
* `--space_before_function_parameters`: *see dfmt_space_before_function_parameters [below](#dfmt-specific-properties)*
* `--split_operator_at_line_end`: *see dfmt_split_operator_at_line_end [below](#dfmt-specific-properties)*
* `--tab_width`: *see tab_width [below](#standard-editorconfig-properties)*
* `--template_constraint_style`: *see dfmt_template_constraint_style [below](#dfmt-specific-properties)*
* `--keep_line_breaks`: *see dfmt_keep_line_breaks [below](#dfmt-specific-properties)*
* `--single_indent`: *see dfmt_single_indent [below](#dfmt-specific-properties)*
* `--reflow_property_chains`: *see dfmt_property_chains [below](#dfmt-specific-properties)*
* `--space_after_keywords`: *see dfmt_space_after_keywords [below](#dfmt-specific-properties)*
### Example
```
@ -59,9 +79,9 @@ void main(string[] args)
// dfmt has no way of knowing that "getopt" is special, so it wraps the
// argument list normally
getopt(args, "optionOne", &optionOne, "optionTwo", &optionTwo, "optionThree", &optionThree);
getopt(args, "optionOne", &optionOne, "optionTwo", &optionTwo, "optionThree", &optionThree);
// dfmt off
// dfmt off
getopt(args,
"optionOne", &optionOne,
"optionTwo", &optionTwo,
@ -74,28 +94,37 @@ void main(string[] args)
**dfmt** uses [EditorConfig](http://editorconfig.org/) configuration files.
**dfmt**-specific properties are prefixed with *dfmt_*.
### Standard EditorConfig properties
Property Name | Allowed Values | Default Value | Description
--------------|----------------|---------------|------------
end_of_line | `cr`, `crlf` and `lf` | `lf` | [See EditorConfig documentation.](https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#end_of_line)
insert_final_newline | | `true` | Not supported. `dfmt` always inserts a final newline.
charset | | `UTf-8` | Not supported. `dfmt` only works correctly on UTF-8.
indent_style | `tab`, `space` | `space` | [See EditorConfig documentation.](https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#indent_style)
indent_size | positive integers | `4` | [See EditorConfig documentation.](https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#indent_size)
tab_width | positive integers | `8` | [See EditorConfig documentation.](https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#tab_width)
trim_trailing_whitespace | | `true` | Not supported. `dfmt` does not emit trailing whitespace.
max_line_length | positive integers | `120` | [See EditorConfig documentation.](https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#max_line_length)
Property Name | Allowed Values | Description
--------------|----------------|------------
end_of_line | `cr`, `crlf` and `lf` | [See EditorConfig documentation.](https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#end_of_line) When not set, `dfmt` adopts the first line ending in the input.
insert_final_newline | **`true`** | Not supported. `dfmt` always inserts a final newline.
charset | **`UTF-8`** | Not supported. `dfmt` only works correctly on UTF-8.
indent_style | `tab`, **`space`** | [See EditorConfig documentation.](https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#indent_style)
indent_size | positive integers (**`4`**) | [See EditorConfig documentation.](https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#indent_size)
tab_width | positive integers (**`4`**) | [See EditorConfig documentation.](https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#tab_width)
trim_trailing_whitespace | **`true`** | Not supported. `dfmt` does not emit trailing whitespace.
max_line_length | positive integers (**`120`**) | [See EditorConfig documentation.](https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#max_line_length)
### dfmt-specific properties
Property Name | Allowed Values | Default Value | Description
--------------|----------------|---------------|------------
dfmt_brace_style | `allman`, `otbs`, or `stroustrup` | `allman` | [See Wikipedia](https://en.wikipedia.org/wiki/Brace_style)
dfmt_soft_max_line_length | positive integers | `80` | The formatting process will usually keep lines below this length, but they may be up to max_line_length columns long.
dfmt_align_switch_statements (Not yet implemented) | `true`, `false` | `true` | Align labels, cases, and defaults with their enclosing switch
dfmt_outdent_attributes (Not yet implemented) | `true`, `false` | `true` | Decrease the indentation level of attributes
dfmt_split_operator_at_line_end | `true`, `false` | `false` | Place operators on the end of the previous line when splitting lines
dfmt_space_after_cast | `true`, `false` | `false` | Insert space after the closing paren of a `cast` expression
dfmt_space_after_keywords (Not yet implemented) | `true`, `false` | `true` | Insert space after `if`, `while`, `foreach`, etc, and before the `(`
dfmt_selective_import_space | `true`, `false` | `true` | Insert space after the module name and before the `:` for selective imports
dfmt_compact_labeled_statements | `true`, `false` | `true` | Place labels on the same line as the labeled `switch`, `for`, `foreach`, or `while` statement
Property Name | Allowed Values | Description
--------------|----------------|------------
dfmt_brace_style | **`allman`**, `otbs`, `stroustrup` or `knr` | [See Wikipedia](https://en.wikipedia.org/wiki/Brace_style)
dfmt_soft_max_line_length | positive integers (**`80`**) | The formatting process will usually keep lines below this length, but they may be up to *max_line_length* columns long.
dfmt_align_switch_statements | **`true`**, `false` | Align labels, cases, and defaults with their enclosing switch.
dfmt_outdent_attributes (Not yet implemented) | **`true`**, `false`| Decrease the indentation level of attributes.
dfmt_split_operator_at_line_end | `true`, **`false`** | Place operators on the end of the previous line when splitting lines.
dfmt_space_after_cast | **`true`**, `false` | Insert space after the closing paren of a `cast` expression.
dfmt_space_after_keywords (Not yet implemented) | **`true`**, `false` | Insert space after `if`, `while`, `foreach`, etc, and before the `(`.
dfmt_space_before_function_parameters | `true`, **`false`** | Insert space before the opening paren of a function parameter list.
dfmt_selective_import_space | **`true`**, `false` | Insert space after the module name and before the `:` for selective imports.
dfmt_compact_labeled_statements | **`true`**, `false` | Place labels on the same line as the labeled `switch`, `for`, `foreach`, or `while` statement.
dfmt_template_constraint_style | **`conditional_newline_indent`** `conditional_newline` `always_newline` `always_newline_indent` | Control the formatting of template constraints.
dfmt_single_template_constraint_indent | `true`, **`false`** | Set if the constraints are indented by a single tab instead of two. Has only an effect if the style set to `always_newline_indent` or `conditional_newline_indent`.
dfmt_space_before_aa_colon | `true`, **`false`** | Adds a space after an associative array key before the `:` like in older dfmt versions.
dfmt_space_before_named_arg_colon | `true`, **`false`** | Adds a space after a named function argument or named struct constructor argument before the `:`.
dfmt_keep_line_breaks | `true`, **`false`** | Keep existing line breaks if these don't violate other formatting rules.
dfmt_single_indent | `true`, **`false`** | Set if the code in parens is indented by a single tab instead of two.
dfmt_reflow_property_chains | **`true`**, `false` | Recalculate the splitting of property chains into multiple lines.
dfmt_space_after_keywords | **`true`**, `false` | Insert space after keywords (if,while,foreach,for, etc.).
## Terminology
* Braces - `{` and `}`

View File

@ -0,0 +1,67 @@
# Completion for dfmt
_dfmt()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
booleans="--align_switch_statements --outdent_attributes --space_after_cast\
--space_before_function_parameters --selective_import_space\
--split_operator_at_line_end --compact_labeled_statements"
# Uncomment code below to print the list of boolean options incase you edit it
# and replace it in the case below
#
#booleans=${booleans// / }
#booleans=${booleans// / }
#bared_booleans=\"${booleans// /\"|\"}\"
#echo ${bared_booleans}
opts="--help -h --inplace -i --version --brace_style\
--end_of_line --indent_size --indent_style -t --soft_max_line_length\
--max_line_length ${booleans} --template_constraint_style"
eolOpts="lf cr crlf"
boolOpts="true false"
braceOpts="allman otbs stroustrup knr"
indentOpts="tab space"
constraintOpts="conditional_newline_indent conditional_newline always_newline always_newline_indent"
if [[ ${cur} == -* ]]; then
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0;
fi
case "${prev}" in
"--brace_style")
COMPREPLY=($(compgen -W "${braceOpts}" -- ${cur}))
return 0
;;
"--end_of_line")
COMPREPLY=($(compgen -W "${eolOpts}" -- ${cur}))
return 0
;;
"-t")
;&
"--indent_style")
COMPREPLY=($(compgen -W "${indentOpts}" -- ${cur}))
return 0
;;
"--template_constraint_style")
COMPREPLY=($(compgen -W "${constraintOpts}" -- ${cur}))
return 0
;;
"--align_switch_statements"|"--outdent_attributes"|"--space_after_cast"|"--space_before_function_parameters"|"--selective_import_space"|"--split_operator_at_line_end"|"--compact_labeled_statements")
COMPREPLY=($(compgen -W "${boolOpts}" -- ${cur}))
return 0
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
return 0
;;
esac
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
}
complete -F _dfmt dfmt

View File

@ -1,15 +1,37 @@
@echo off
setlocal enabledelayedexpansion
IF "%DC%"=="" SET DC="dmd"
set DFLAGS=-g
set CORE=
set STD=
set STDD=
set STDXALLOCATOR=
set STDXALLOCATORBLOCKS=
set OBIN=bin\dfmt
for %%x in (src\*.d) do set CORE=!CORE! %%x
for %%x in (libdparse\src\std\*.d) do set STD=!STD! %%x
for %%x in (libdparse\src\std\d\*.d) do set STDD=!STDD! %%x
:: git might not be installed, so we provide 0.0.0 as a fallback or use
:: the existing githash file if existent
if not exist "bin" mkdir bin
git describe --tags > bin\githash_.txt
for /f %%i in ("bin\githash_.txt") do set githashsize=%%~zi
if %githashsize% == 0 (
if not exist "bin\githash.txt" (
echo v0.0.0 > bin\githash.txt
)
) else (
move /y bin\githash_.txt bin\githash.txt
)
for %%x in (src\dfmt\*.d) do set CORE=!CORE! %%x
for %%x in (libdparse\src\std\experimental\*.d) do set STD=!STD! %%x
for %%x in (libdparse\src\dparse\*.d) do set STDD=!STDD! %%x
for %%x in (stdx-allocator\source\stdx\allocator\*.d) do set STDXALLOCATOR=!STDXALLOCATOR! %%x
for %%x in (stdx-allocator\source\stdx\allocator\building_blocks\*.d) do set STDXALLOCATORBLOCKS=!STDXALLOCATORBLOCKS! %%x
@echo on
dmd %CORE% %STD% %STDD% %DFLAGS% -ofbin\dfmt.exe
%DC% %CORE% %STD% %STDD% %STDE% %STDXALLOCATOR% %STDXALLOCATORBLOCKS% -I"stdx-allocator\source" -I"libdparse\src" -Jbin %DFLAGS% -of%OBIN%.exe
if exist %OBIN%.obj del %OBIN%.obj

1
d-test-utils Submodule

@ -0,0 +1 @@
Subproject commit 206a2e6abd97b4462f3a320e4f2d23986fad3cff

View File

@ -1,10 +1,20 @@
{
"name": "dfmt",
"description": "Dfmt is a formatter for D source code",
"version": "0.4.0-beta",
"targetType": "executable",
"targetType": "autodetect",
"license": "BSL-1.0",
"dependencies": {
"libdparse": "~master"
}
"libdparse": ">=0.19.2 <1.0.0"
},
"targetPath" : "bin/",
"targetName" : "dfmt",
"stringImportPaths" : [
"bin"
],
"versions" : [
"built_with_dub"
],
"preBuildCommands" : [
"$DC -run \"$PACKAGE_DIR/dubhash.d\""
]
}

23
dubhash.d Normal file
View File

@ -0,0 +1,23 @@
import std.algorithm;
import std.ascii;
import std.conv;
import std.exception;
import std.file;
import std.path;
import std.process;
import std.range;
import std.string;
void main()
{
auto dir = environment.get("DUB_PACKAGE_DIR");
auto hashFile = dir.buildPath("bin", "dubhash.txt");
auto gitVer = executeShell("git -C " ~ dir ~ " describe --tags");
auto ver = (gitVer.status == 0 ? gitVer.output.strip
: "v" ~ dir.dirName.baseName.findSplitAfter(
environment.get("DUB_ROOT_PACKAGE") ~ "-")[1]).ifThrown("0.0.0")
.chain(newline).to!string.strip;
dir.buildPath("bin").mkdirRecurse;
if (!hashFile.exists || ver != hashFile.readText.strip)
hashFile.write(ver);
}

@ -1 +1 @@
Subproject commit b3303ab6fd15e9cbde50c6987b303b6ed296d493
Subproject commit fe6d1e38fb4fc04323170389cfec67ed7fd4e24a

View File

@ -1,33 +1,63 @@
PREFIX = /usr/local
SRC := $(shell find src -name "*.d") \
$(shell find libdparse/src -name "*.d") \
$(shell find libdparse/experimental_allocator/src -name "*.d")
INCLUDE_PATHS := -Ilibdparse/src -Isrc -Ilibdparse/experimental_allocator/src
DMD_COMMON_FLAGS := -dip25 -w $(INCLUDE_PATHS)
DMD_DEBUG_FLAGS := -g $(DMD_COMMON_FLAGS)
$(shell find libdparse/src -name "*.d")
IMPORTS := -Ilibdparse/src -Isrc -Jbin
DC ?= dmd
LDC ?= ldc2
GDC ?= gdc
DMD_COMMON_FLAGS := -w $(IMPORTS)
DMD_DEBUG_FLAGS := -debug -g $(DMD_COMMON_FLAGS)
DMD_FLAGS := -O -inline $(DMD_COMMON_FLAGS)
DMD_TEST_FLAGS := -unittest -g $(DMD_COMMON_FLAGS)
LDC_FLAGS := -g -w -oq $(INCLUDE_PATHS)
GDC_FLAGS := -g -w -oq $(INCLUDE_PATHS)
LDC_FLAGS := -g -w -oq $(IMPORTS)
GDC_FLAGS := -g -w -oq $(IMPORTS)
override DMD_FLAGS += $(DFLAGS)
override LDC_FLAGS += $(DFLAGS)
override GDC_FLAGS += $(DFLAGS)
.PHONY: dmd ldc gdc test
.PHONY: all clean install debug dmd ldc gdc pkg release test
all: bin/dfmt
bin/githash.txt:
mkdir -p bin
git describe --tags > bin/githash.txt
dmd: bin/dfmt
ldc: $(SRC)
ldc2 $(LDC_FLAGS) $^ -ofbin/dfmt
ldc: bin/githash.txt
$(LDC) $(SRC) $(LDC_FLAGS) -ofbin/dfmt
-rm -f *.o
gdc: $(SRC)
gdc $(GDC_FLAGS) $^ -obin/dfmt
gdc: bin/githash.txt
$(GDC) $(SRC) $(GDC_FLAGS) -obin/dfmt
test: bin/dfmt
cd tests && ./test.sh
test: debug
cd tests && ./test.d
bin/dfmt-test: $(SRC)
dmd $(DMD_TEST_FLAGS) $^ -of$@
bin/dfmt-test: bin/githash.txt $(SRC)
$(DC) $(DMD_TEST_FLAGS) $(filter %.d,$^) -of$@
bin/dfmt: $(SRC)
dmd $(DMD_FLAGS) $^ -of$@
bin/dfmt: bin/githash.txt $(SRC)
$(DC) $(DMD_FLAGS) $(filter %.d,$^) -of$@
debug: $(SRC)
dmd $(DMD_DEBUG_FLAGS) $^ -ofbin/dfmt
debug: bin/githash.txt $(SRC)
$(DC) $(DMD_DEBUG_FLAGS) $(filter %.d,$^) -ofbin/dfmt
pkg: dmd
$(MAKE) -f makd/Makd.mak pkg
clean:
$(RM) bin/dfmt bin/dfmt-test bin/githash.txt
install:
chmod +x bin/dfmt
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f bin/dfmt $(DESTDIR)$(PREFIX)/bin/dfmt
release:
./release.sh
$(MAKE) bin/githash.txt

21
release-windows.sh Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Build the Windows binaries under Linux
set -eux -o pipefail
BIN_NAME=dfmt
# Allow the script to be run from anywhere
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
source setup-ldc-windows.sh
# Run LDC with cross-compilation
archiveName="$BIN_NAME-$VERSION-$OS-$ARCH_SUFFIX.zip"
echo "Building $archiveName"
mkdir -p bin
DC=ldmd2 make ldc
cd bin
mv "${BIN_NAME}" "${BIN_NAME}.exe"
zip "$archiveName" "${BIN_NAME}.exe"

23
release.sh Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -eux -o pipefail
VERSION=$(git describe --abbrev=0 --tags)
ARCH="${ARCH:-64}"
LDC_FLAGS=()
unameOut="$(uname -s)"
case "$unameOut" in
Linux*) OS=linux; LDC_FLAGS=("-flto=full" "-linker=gold" "-static") ;;
Darwin*) OS=osx; LDC_FLAGS+=("-L-macosx_version_min" "-L10.7" "-L-lcrt1.o"); ;;
*) echo "Unknown OS: $unameOut"; exit 1
esac
case "$ARCH" in
64) ARCH_SUFFIX="x86_64";;
32) ARCH_SUFFIX="x86";;
*) echo "Unknown ARCH: $ARCH"; exit 1
esac
archiveName="dfmt-$VERSION-$OS-$ARCH_SUFFIX.tar.gz"
echo "Building $archiveName"
${MAKE:-make} ldc LDC_FLAGS="${LDC_FLAGS[*]} -Jbin"
tar cvfz "bin/$archiveName" -C bin dfmt

70
setup-ldc-windows.sh Normal file
View File

@ -0,0 +1,70 @@
#!/usr/bin/env bash
# sets up LDC for cross-compilation. Source this script, s.t. the new LDC is in PATH
LDC_VERSION="1.13.0"
ARCH=${ARCH:-32}
VERSION=$(git describe --abbrev=0 --tags)
OS=windows
# Step 0: install ldc
if [ ! -f install.sh ] ; then
wget https://dlang.org/install.sh
fi
. $(bash ./install.sh -a "ldc-${LDC_VERSION}")
# for the install.sh script only
LDC_PATH="$(dirname $(dirname $(which ldc2)))"
# Step 1a: download the LDC x64 windows binaries
if [ "${ARCH}" == 64 ] && [ ! -d "ldc2-${LDC_VERSION}-windows-x64" ] ; then
wget "https://github.com/ldc-developers/ldc/releases/download/v1.13.0/ldc2-${LDC_VERSION}-windows-x64.7z"
7z x "ldc2-${LDC_VERSION}-windows-x64.7z" > /dev/null
# Step 2a: Add LDC windows binaries to LDC Linux
if [ ! -d "${LDC_PATH}/lib-win64" ] ; then
cp -r ldc2-1.13.0-windows-x64/lib "${LDC_PATH}/lib-win64"
cat >> "$LDC_PATH"/etc/ldc2.conf <<EOF
"x86_64-.*-windows-msvc":
{
switches = [
"-defaultlib=phobos2-ldc,druntime-ldc",
"-link-defaultlib-shared=false",
];
lib-dirs = [
"%%ldcbinarypath%%/../lib-win64",
];
};
EOF
fi
fi
# Step 1b: download the LDC x86 windows binaries
if [ "${ARCH}" == 32 ] && [ ! -d "ldc2-${LDC_VERSION}-windows-x86" ] ; then
wget "https://github.com/ldc-developers/ldc/releases/download/v1.13.0/ldc2-${LDC_VERSION}-windows-x86.7z"
7z x "ldc2-${LDC_VERSION}-windows-x86.7z" > /dev/null
# Step 2b: Add LDC windows binaries to LDC Linux
if [ ! -d "${LDC_PATH}/lib-win32" ] ; then
cp -r ldc2-1.13.0-windows-x86/lib "${LDC_PATH}/lib-win32"
cat >> "$LDC_PATH"/etc/ldc2.conf <<EOF
"i686-.*-windows-msvc":
{
switches = [
"-defaultlib=phobos2-ldc,druntime-ldc",
"-link-defaultlib-shared=false",
];
lib-dirs = [
"%%ldcbinarypath%%/../lib-win32",
];
};
EOF
fi
fi
# set suffices and compilation flags
if [ "$ARCH" == "64" ] ; then
ARCH_SUFFIX="x86_64"
export DFLAGS="-mtriple=x86_64-windows-msvc"
else
ARCH_SUFFIX="x86"
export DFLAGS="-mtriple=i686-windows-msvc"
fi

View File

@ -5,8 +5,29 @@
module dfmt.ast_info;
import std.d.lexer;
import std.d.ast;
import dparse.lexer;
import dparse.ast;
enum BraceIndentInfoFlags
{
tempIndent = 1 << 0,
}
struct BraceIndentInfo
{
size_t startLocation;
size_t endLocation;
uint flags;
uint beginIndentLevel;
}
struct StructInitializerInfo
{
size_t startLocation;
size_t endLocation;
}
/// AST information that is needed by the formatter.
struct ASTInformation
@ -14,12 +35,14 @@ struct ASTInformation
/// Sorts the arrays so that binary search will work on them
void cleanup()
{
import std.algorithm : sort;
import std.algorithm : sort, uniq;
import std.array : array;
sort(doubleNewlineLocations);
sort(spaceAfterLocations);
sort(unaryLocations);
sort(attributeDeclarationLines);
sort(atAttributeStartLocations);
sort(caseEndLocations);
sort(structInitStartLocations);
sort(structInitEndLocations);
@ -28,7 +51,20 @@ struct ASTInformation
sort(conditionalWithElseLocations);
sort(conditionalStatementLocations);
sort(arrayStartLocations);
sort(assocArrayStartLocations);
sort(contractLocations);
sort(constraintLocations);
sort(constructorDestructorLocations);
sort(staticConstructorDestructorLocations);
sort(sharedStaticConstructorDestructorLocations);
sort!((a,b) => a.endLocation < b.endLocation)
(indentInfoSortedByEndLocation);
sort!((a,b) => a.endLocation < b.endLocation)
(structInfoSortedByEndLocation);
sort(ufcsHintLocations);
ufcsHintLocations = ufcsHintLocations.uniq().array();
sort(ternaryColonLocations);
sort(namedArgumentColonLocations);
}
/// Locations of end braces for struct bodies
@ -43,6 +79,9 @@ struct ASTInformation
/// Lines containing attribute declarations
size_t[] attributeDeclarationLines;
/// Lines containing attribute declarations that can be followed by a new line
size_t[] atAttributeStartLocations;
/// Case statement colon locations
size_t[] caseEndLocations;
@ -58,6 +97,12 @@ struct ASTInformation
/// Closing braces of function literals
size_t[] funLitEndLocations;
/// Locations of aggregate bodies (struct, class, union)
size_t[] aggregateBodyLocations;
/// Locations of function bodies
size_t[] funBodyLocations;
/// Conditional statements that have matching "else" statements
size_t[] conditionalWithElseLocations;
@ -67,13 +112,44 @@ struct ASTInformation
/// Locations of start locations of array initializers
size_t[] arrayStartLocations;
/// Locations of start locations of associative array initializers
size_t[] assocArrayStartLocations;
/// Locations of "in" and "out" tokens that begin contracts
size_t[] contractLocations;
/// Locations of template constraint "if" tokens
size_t[] constraintLocations;
/// Locations of constructor/destructor "shared" tokens ?
size_t[] sharedStaticConstructorDestructorLocations;
/// Locations of constructor/destructor "static" tokens ?
size_t[] staticConstructorDestructorLocations;
/// Locations of constructor/destructor "this" tokens ?
size_t[] constructorDestructorLocations;
/// Locations of '.' characters that might be UFCS chains.
size_t[] ufcsHintLocations;
BraceIndentInfo[] indentInfoSortedByEndLocation;
/// Opening & closing braces of struct initializers
StructInitializerInfo[] structInfoSortedByEndLocation;
/// Locations ternary expression colons.
size_t[] ternaryColonLocations;
/// Locations of named arguments of function call or struct constructor.
size_t[] namedArgumentColonLocations;
}
/// Collects information from the AST that is useful for the formatter
final class FormatVisitor : ASTVisitor
{
alias visit = ASTVisitor.visit;
/**
* Params:
* astInformation = the AST information that will be filled in
@ -89,14 +165,76 @@ final class FormatVisitor : ASTVisitor
arrayInitializer.accept(this);
}
override void visit(const ArrayLiteral arrayLiteral)
{
astInformation.arrayStartLocations ~= arrayLiteral.tokens[0].index;
arrayLiteral.accept(this);
}
override void visit(const AssocArrayLiteral assocArrayLiteral)
{
astInformation.arrayStartLocations ~= assocArrayLiteral.tokens[0].index;
astInformation.assocArrayStartLocations ~= assocArrayLiteral.tokens[0].index;
assocArrayLiteral.accept(this);
}
override void visit (const SharedStaticConstructor sharedStaticConstructor)
{
astInformation.sharedStaticConstructorDestructorLocations ~= sharedStaticConstructor.location;
sharedStaticConstructor.accept(this);
}
override void visit (const SharedStaticDestructor sharedStaticDestructor)
{
astInformation.sharedStaticConstructorDestructorLocations ~= sharedStaticDestructor.location;
sharedStaticDestructor.accept(this);
}
override void visit (const StaticConstructor staticConstructor)
{
astInformation.staticConstructorDestructorLocations ~= staticConstructor.location;
staticConstructor.accept(this);
}
override void visit (const StaticDestructor staticDestructor)
{
astInformation.staticConstructorDestructorLocations ~= staticDestructor.location;
staticDestructor.accept(this);
}
override void visit (const Constructor constructor)
{
astInformation.constructorDestructorLocations ~= constructor.location;
constructor.accept(this);
}
override void visit (const Destructor destructor)
{
astInformation.constructorDestructorLocations ~= destructor.index;
destructor.accept(this);
}
override void visit (const FunctionBody functionBody)
{
if (auto bd = functionBody.specifiedFunctionBody)
{
if (bd.blockStatement)
{
astInformation.funBodyLocations ~= bd.blockStatement.startLocation;
}
}
functionBody.accept(this);
}
override void visit(const ConditionalDeclaration dec)
{
if (dec.falseDeclaration !is null)
if (dec.hasElse)
{
auto condition = dec.compileCondition;
if (condition.versionCondition !is null)
{
astInformation.conditionalWithElseLocations ~= condition.versionCondition.versionIndex;
astInformation.conditionalWithElseLocations
~= condition.versionCondition.versionIndex;
}
else if (condition.debugCondition !is null)
{
@ -108,6 +246,12 @@ final class FormatVisitor : ASTVisitor
dec.accept(this);
}
override void visit(const Constraint constraint)
{
astInformation.constraintLocations ~= constraint.location;
constraint.accept(this);
}
override void visit(const ConditionalStatement statement)
{
auto condition = statement.compileCondition;
@ -124,8 +268,15 @@ final class FormatVisitor : ASTVisitor
override void visit(const FunctionLiteralExpression funcLit)
{
astInformation.funLitStartLocations ~= funcLit.functionBody.blockStatement.startLocation;
astInformation.funLitEndLocations ~= funcLit.functionBody.blockStatement.endLocation;
if (funcLit.specifiedFunctionBody !is null)
{
const bs = funcLit.specifiedFunctionBody.blockStatement;
astInformation.funLitStartLocations ~= bs.startLocation;
astInformation.funLitEndLocations ~= bs.endLocation;
astInformation.indentInfoSortedByEndLocation ~=
BraceIndentInfo(bs.startLocation, bs.endLocation);
}
funcLit.accept(this);
}
@ -147,19 +298,22 @@ final class FormatVisitor : ASTVisitor
caseRangeStatement.accept(this);
}
override void visit(const FunctionBody functionBody)
override void visit(const SpecifiedFunctionBody specifiedFunctionBody)
{
if (functionBody.blockStatement !is null)
astInformation.doubleNewlineLocations ~= functionBody.blockStatement.endLocation;
if (functionBody.bodyStatement !is null && functionBody.bodyStatement.blockStatement !is null)
astInformation.doubleNewlineLocations ~= functionBody.bodyStatement.blockStatement.endLocation;
functionBody.accept(this);
if (specifiedFunctionBody.blockStatement !is null)
astInformation.doubleNewlineLocations ~= specifiedFunctionBody.blockStatement.endLocation;
specifiedFunctionBody.accept(this);
}
override void visit(const StructInitializer structInitializer)
{
astInformation.structInitStartLocations ~= structInitializer.startLocation;
astInformation.structInitEndLocations ~= structInitializer.endLocation;
astInformation.structInfoSortedByEndLocation ~=
StructInitializerInfo(structInitializer.startLocation, structInitializer.endLocation);
astInformation.indentInfoSortedByEndLocation ~=
BraceIndentInfo(structInitializer.startLocation, structInitializer.endLocation);
structInitializer.accept(this);
}
@ -177,12 +331,15 @@ final class FormatVisitor : ASTVisitor
override void visit(const Invariant invariant_)
{
astInformation.doubleNewlineLocations ~= invariant_.blockStatement.endLocation;
if (invariant_.blockStatement !is null)
astInformation.doubleNewlineLocations ~= invariant_.blockStatement.endLocation;
invariant_.accept(this);
}
override void visit(const StructBody structBody)
{
astInformation.aggregateBodyLocations ~= structBody.startLocation;
astInformation.doubleNewlineLocations ~= structBody.endLocation;
structBody.accept(this);
}
@ -202,9 +359,29 @@ final class FormatVisitor : ASTVisitor
override void visit(const UnaryExpression unary)
{
import std.typecons : rebindable;
int chainLength;
auto u = rebindable(unary);
while (u !is null)
{
if (u.identifierOrTemplateInstance !is null
&& u.identifierOrTemplateInstance.templateInstance !is null)
chainLength++;
u = u.unaryExpression;
}
if (chainLength > 1)
{
u = unary;
while (u.unaryExpression !is null)
{
astInformation.ufcsHintLocations ~= u.dotLocation;
u = u.unaryExpression;
}
}
if (unary.prefix.type == tok!"~" || unary.prefix.type == tok!"&"
|| unary.prefix.type == tok!"*" || unary.prefix.type == tok!"+"
|| unary.prefix.type == tok!"-")
|| unary.prefix.type == tok!"*"
|| unary.prefix.type == tok!"+" || unary.prefix.type == tok!"-")
{
astInformation.unaryLocations ~= unary.prefix.index;
}
@ -217,19 +394,110 @@ final class FormatVisitor : ASTVisitor
attributeDeclaration.accept(this);
}
override void visit(const FunctionAttribute functionAttribute)
{
if (functionAttribute.atAttribute !is null)
astInformation.atAttributeStartLocations ~= functionAttribute.atAttribute.startLocation;
functionAttribute.accept(this);
}
override void visit(const MemberFunctionAttribute memberFunctionAttribute)
{
if (memberFunctionAttribute.atAttribute !is null)
astInformation.atAttributeStartLocations ~= memberFunctionAttribute.atAttribute.startLocation;
memberFunctionAttribute.accept(this);
}
override void visit(const Attribute attribute)
{
if (attribute.atAttribute !is null)
astInformation.atAttributeStartLocations ~= attribute.atAttribute.startLocation;
attribute.accept(this);
}
override void visit(const StorageClass storageClass)
{
if (storageClass.atAttribute !is null)
astInformation.atAttributeStartLocations ~= storageClass.atAttribute.startLocation;
storageClass.accept(this);
}
override void visit(const InContractExpression inContractExpression)
{
astInformation.contractLocations ~= inContractExpression.inTokenLocation;
inContractExpression.accept(this);
}
override void visit(const InStatement inStatement)
{
astInformation.contractLocations ~= inStatement.inTokenLocation;
inStatement.accept(this);
}
override void visit(const OutContractExpression outContractExpression)
{
astInformation.contractLocations ~= outContractExpression.outTokenLocation;
outContractExpression.accept(this);
}
override void visit(const OutStatement outStatement)
{
astInformation.contractLocations ~= outStatement.outTokenLocation;
outStatement.accept(this);
}
override void visit(const TernaryExpression ternaryExpression)
{
astInformation.ternaryColonLocations ~= ternaryExpression.colon.index;
ternaryExpression.accept(this);
}
override void visit(const FunctionCallExpression functionCall)
{
visit(functionCall.arguments);
functionCall.accept(this);
}
override void visit(const NewExpression newCall)
{
visit(newCall.arguments);
newCall.accept(this);
}
override void visit(const NewAnonClassExpression newAnonClassCall)
{
visit(newAnonClassCall.constructorArguments);
newAnonClassCall.accept(this);
}
private void visit(const Arguments arguments)
{
// Check if call has any arguments.
if (!arguments || arguments.namedArgumentList is null)
{
return;
}
foreach (item; arguments.namedArgumentList.items)
{
// Do nothing if not a named argument.
if (item.name == tok!"")
{
continue;
}
// Find first colon if named argument.
foreach (t; item.tokens)
{
if (t.type == tok!":")
{
astInformation.namedArgumentColonLocations ~= t.index;
break;
}
}
}
}
private:
ASTInformation* astInformation;
alias visit = ASTVisitor.visit;
}

View File

@ -10,13 +10,24 @@ import dfmt.editorconfig;
/// Brace styles
enum BraceStyle
{
unspecified,
_unspecified,
/// $(LINK https://en.wikipedia.org/wiki/Indent_style#Allman_style)
allman,
/// $(LINK https://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS)
otbs,
/// $(LINK https://en.wikipedia.org/wiki/Indent_style#Variant:_Stroustrup)
stroustrup
stroustrup,
/// $(LINK https://en.wikipedia.org/wiki/Indentation_style#K&R_style)
knr,
}
enum TemplateConstraintStyle
{
_unspecified,
conditional_newline_indent,
conditional_newline,
always_newline,
always_newline_indent
}
/// Configuration options for formatting
@ -35,15 +46,32 @@ struct Config
///
OptionalBoolean dfmt_space_after_keywords;
///
OptionalBoolean dfmt_space_before_function_parameters;
///
OptionalBoolean dfmt_split_operator_at_line_end;
///
OptionalBoolean dfmt_selective_import_space;
///
OptionalBoolean dfmt_compact_labeled_statements;
///
TemplateConstraintStyle dfmt_template_constraint_style;
///
OptionalBoolean dfmt_single_template_constraint_indent;
///
OptionalBoolean dfmt_space_before_aa_colon;
///
OptionalBoolean dfmt_keep_line_breaks;
///
OptionalBoolean dfmt_single_indent;
///
OptionalBoolean dfmt_reflow_property_chains;
///
OptionalBoolean dfmt_space_after_statement_keyword;
///
OptionalBoolean dfmt_space_before_named_arg_colon;
mixin StandardEditorConfigFields;
/**
* Initializes the standard EditorConfig properties with default values that
* make sense for D code.
@ -51,7 +79,7 @@ struct Config
void initializeWithDefaults()
{
pattern = "*.d";
end_of_line = EOL.lf;
end_of_line = EOL._default;
indent_style = IndentStyle.space;
indent_size = 4;
tab_width = 4;
@ -62,9 +90,17 @@ struct Config
dfmt_soft_max_line_length = 80;
dfmt_space_after_cast = OptionalBoolean.t;
dfmt_space_after_keywords = OptionalBoolean.t;
dfmt_space_before_function_parameters = OptionalBoolean.f;
dfmt_split_operator_at_line_end = OptionalBoolean.f;
dfmt_selective_import_space = OptionalBoolean.t;
dfmt_compact_labeled_statements = OptionalBoolean.t;
dfmt_template_constraint_style = TemplateConstraintStyle.conditional_newline_indent;
dfmt_single_template_constraint_indent = OptionalBoolean.f;
dfmt_space_before_aa_colon = OptionalBoolean.f;
dfmt_keep_line_breaks = OptionalBoolean.f;
dfmt_single_indent = OptionalBoolean.f;
dfmt_reflow_property_chains = OptionalBoolean.t;
dfmt_space_before_named_arg_colon = OptionalBoolean.f;
}
/**
@ -78,7 +114,7 @@ struct Config
if (dfmt_soft_max_line_length > max_line_length)
{
stderr.writefln("Column hard limit (%d) must be greater than or equal to column soft limit (%d)",
max_line_length, dfmt_soft_max_line_length);
max_line_length, dfmt_soft_max_line_length);
return false;
}
return true;

View File

@ -2,7 +2,7 @@ module dfmt.editorconfig;
import std.regex : ctRegex;
static if (__VERSION__ >= 2067)
import std.traits : FieldNameTuple;
public import std.traits : FieldNameTuple;
else
{
private enum NameOf(alias T) = T.stringof;
@ -26,21 +26,22 @@ private auto commentRe = ctRegex!(`^\s*[#;].*$`);
enum OptionalBoolean : ubyte
{
unspecified = 3,
_unspecified = 3,
t = 1,
f = 0
}
enum IndentStyle : ubyte
{
unspecified,
_unspecified,
tab,
space
}
enum EOL : ubyte
{
unspecified,
_unspecified,
_default,
lf,
cr,
crlf
@ -61,9 +62,10 @@ mixin template StandardEditorConfigFields()
void merge(ref const typeof(this) other, const string fileName)
{
import std.path : globMatch;
import dfmt.globmatch_editorconfig : globMatchEditorConfig;
import std.array : front, popFront, empty, save;
if (other.pattern is null || !fileName.globMatch(other.pattern))
if (other.pattern is null || !ecMatch(fileName, other.pattern))
return;
foreach (N; FieldNameTuple!(typeof(this)))
{
@ -72,16 +74,43 @@ mixin template StandardEditorConfigFields()
auto thisN = &mixin("this." ~ N);
static if (N == "pattern")
continue;
else static if (is (T == enum))
*thisN = otherN != T.unspecified ? otherN : *thisN;
else static if (is (T == int))
else static if (is(T == enum))
*thisN = otherN != T._unspecified ? otherN : *thisN;
else static if (is(T == int))
*thisN = otherN != -1 ? otherN : *thisN;
else static if (is (T == string))
else static if (is(T == string))
*thisN = otherN !is null ? otherN : *thisN;
else
static assert(false);
}
}
private bool ecMatch(string fileName, string patt)
{
import std.algorithm : canFind;
import std.path : baseName;
import dfmt.globmatch_editorconfig : globMatchEditorConfig;
if (!pattern.canFind("/"))
fileName = fileName.baseName;
return fileName.globMatchEditorConfig(patt);
}
}
unittest
{
struct Config
{
mixin StandardEditorConfigFields;
}
Config config1;
Config config2;
config2.pattern = "test.d";
config2.end_of_line = EOL.crlf;
assert(config1.end_of_line != config2.end_of_line);
config1.merge(config2, "a/b/test.d");
assert(config1.end_of_line == config2.end_of_line);
}
/**
@ -94,15 +123,19 @@ EC getConfigFor(EC)(string path)
{
import std.stdio : File;
import std.regex : regex, match;
import std.path : globMatch, dirName, baseName, pathSplitter, buildPath;
import std.path : globMatch, dirName, baseName, pathSplitter, buildPath,
absolutePath;
import std.algorithm : reverse, map, filter;
import std.array : array;
import std.file : isDir;
EC result;
EC[][] configs;
string dir = dirName(path);
immutable string fileName = baseName(path);
string[] pathParts = cast(string[]) pathSplitter(dir).array();
immutable expanded = absolutePath(path);
immutable bool id = isDir(expanded);
immutable string fileName = id ? "dummy.d" : baseName(expanded);
string[] pathParts = cast(string[]) pathSplitter(expanded).array();
for (size_t i = pathParts.length; i > 1; i--)
{
EC[] sections = parseConfig!EC(buildPath(pathParts[0 .. i]));
@ -115,6 +148,7 @@ EC getConfigFor(EC)(string path)
static if (__VERSION__ >= 2067)
{
import std.algorithm : each;
configs.each!(a => a.each!(b => result.merge(b, fileName)))();
}
else

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,239 @@
module dfmt.globmatch_editorconfig;
import std.path : CaseSensitive;
import std.range : isForwardRange, ElementEncodingType;
import std.traits : isSomeChar, isSomeString;
import std.range.primitives : empty, save, front, popFront;
import std.traits : Unqual;
import std.conv : to;
import std.path : filenameCharCmp, isDirSeparator;
// From std.path with changes:
// * changes meaning to match all characters except '/'
// ** added to take over the old meaning of *
bool globMatchEditorConfig(CaseSensitive cs = CaseSensitive.osDefault, C, Range)(
Range path, const(C)[] pattern) @safe pure
if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range)
&& isSomeChar!C && is(Unqual!C == Unqual!(ElementEncodingType!Range)))
in
{
// Verify that pattern[] is valid
import std.algorithm : balancedParens;
assert(balancedParens(pattern, '[', ']', 0));
assert(balancedParens(pattern, '{', '}', 0));
}
do
{
alias RC = Unqual!(ElementEncodingType!Range);
static if (RC.sizeof == 1 && isSomeString!Range)
{
import std.utf : byChar;
return globMatchEditorConfig!cs(path.byChar, pattern);
}
else static if (RC.sizeof == 2 && isSomeString!Range)
{
import std.utf : byWchar;
return globMatchEditorConfig!cs(path.byWchar, pattern);
}
else
{
C[] pattmp;
foreach (ref pi; 0 .. pattern.length)
{
const pc = pattern[pi];
switch (pc)
{
case '*':
if (pi < pattern.length - 1 && pattern[pi + 1] == '*')
{
if (pi + 2 == pattern.length)
return true;
for (; !path.empty; path.popFront())
{
auto p = path.save;
if (globMatchEditorConfig!(cs, C)(p, pattern[pi + 2 .. pattern.length]))
return true;
}
return false;
}
else
{
if (pi + 1 == pattern.length)
return true;
for (; !path.empty; path.popFront())
{
auto p = path.save;
//if (p[0].to!dchar.isDirSeparator() && !pattern[pi+1].isDirSeparator())
// return false;
if (globMatchEditorConfig!(cs, C)(p, pattern[pi + 1 .. pattern.length]))
return true;
if (p[0].to!dchar.isDirSeparator())
return false;
}
return false;
}
case '?':
if (path.empty)
return false;
path.popFront();
break;
case '[':
if (path.empty)
return false;
auto nc = path.front;
path.popFront();
auto not = false;
++pi;
if (pattern[pi] == '!')
{
not = true;
++pi;
}
auto anymatch = false;
while (1)
{
const pc2 = pattern[pi];
if (pc2 == ']')
break;
if (!anymatch && (filenameCharCmp!cs(nc, pc2) == 0))
anymatch = true;
++pi;
}
if (anymatch == not)
return false;
break;
case '{':
// find end of {} section
auto piRemain = pi;
for (; piRemain < pattern.length && pattern[piRemain] != '}'; ++piRemain)
{
}
if (piRemain < pattern.length)
++piRemain;
++pi;
while (pi < pattern.length)
{
const pi0 = pi;
C pc3 = pattern[pi];
// find end of current alternative
for (; pi < pattern.length && pc3 != '}' && pc3 != ','; ++pi)
{
pc3 = pattern[pi];
}
auto p = path.save;
if (pi0 == pi)
{
if (globMatchEditorConfig!(cs, C)(p, pattern[piRemain .. $]))
{
return true;
}
++pi;
}
else
{
/* Match for:
* pattern[pi0..pi-1] ~ pattern[piRemain..$]
*/
if (pattmp.ptr == null) // Allocate this only once per function invocation.
// Should do it with malloc/free, but that would make it impure.
pattmp = new C[pattern.length];
const len1 = pi - 1 - pi0;
pattmp[0 .. len1] = pattern[pi0 .. pi - 1];
const len2 = pattern.length - piRemain;
pattmp[len1 .. len1 + len2] = pattern[piRemain .. $];
if (globMatchEditorConfig!(cs, C)(p, pattmp[0 .. len1 + len2]))
{
return true;
}
}
if (pc3 == '}')
{
break;
}
}
return false;
default:
if (path.empty)
return false;
if (filenameCharCmp!cs(pc, path.front) != 0)
return false;
path.popFront();
break;
}
}
return path.empty;
}
}
unittest
{
assert(globMatchEditorConfig!(CaseSensitive.no)("foo", "Foo"));
assert(!globMatchEditorConfig!(CaseSensitive.yes)("foo", "Foo"));
assert(globMatchEditorConfig("foo", "*"));
assert(globMatchEditorConfig("foo.bar"w, "*"w));
assert(globMatchEditorConfig("foo.bar"d, "*.*"d));
assert(globMatchEditorConfig("foo.bar", "foo*"));
assert(globMatchEditorConfig("foo.bar"w, "f*bar"w));
assert(globMatchEditorConfig("foo.bar"d, "f*b*r"d));
assert(globMatchEditorConfig("foo.bar", "f???bar"));
assert(globMatchEditorConfig("foo.bar"w, "[fg]???bar"w));
assert(globMatchEditorConfig("foo.bar"d, "[!gh]*bar"d));
assert(!globMatchEditorConfig("foo", "bar"));
assert(!globMatchEditorConfig("foo"w, "*.*"w));
assert(!globMatchEditorConfig("foo.bar"d, "f*baz"d));
assert(!globMatchEditorConfig("foo.bar", "f*b*x"));
assert(!globMatchEditorConfig("foo.bar", "[gh]???bar"));
assert(!globMatchEditorConfig("foo.bar"w, "[!fg]*bar"w));
assert(!globMatchEditorConfig("foo.bar"d, "[fg]???baz"d));
assert(!globMatchEditorConfig("foo.di", "*.d")); // test issue 6634: triggered bad assertion
assert(globMatchEditorConfig("foo.bar", "{foo,bif}.bar"));
assert(globMatchEditorConfig("bif.bar"w, "{foo,bif}.bar"w));
assert(globMatchEditorConfig("bar.foo"d, "bar.{foo,bif}"d));
assert(globMatchEditorConfig("bar.bif", "bar.{foo,bif}"));
assert(globMatchEditorConfig("bar.fooz"w, "bar.{foo,bif}z"w));
assert(globMatchEditorConfig("bar.bifz"d, "bar.{foo,bif}z"d));
assert(globMatchEditorConfig("bar.foo", "bar.{biz,,baz}foo"));
assert(globMatchEditorConfig("bar.foo"w, "bar.{biz,}foo"w));
assert(globMatchEditorConfig("bar.foo"d, "bar.{,biz}foo"d));
assert(globMatchEditorConfig("bar.foo", "bar.{}foo"));
assert(globMatchEditorConfig("bar.foo"w, "bar.{ar,,fo}o"w));
assert(globMatchEditorConfig("bar.foo"d, "bar.{,ar,fo}o"d));
assert(globMatchEditorConfig("bar.o", "bar.{,ar,fo}o"));
assert(!globMatchEditorConfig("foo", "foo?"));
assert(!globMatchEditorConfig("foo", "foo[]"));
assert(!globMatchEditorConfig("foo", "foob"));
assert(!globMatchEditorConfig("foo", "foo{b}"));
assert(globMatchEditorConfig(`foo/foo\bar`, "f**b**r"));
assert(globMatchEditorConfig("foo", "**"));
assert(globMatchEditorConfig("foo/bar", "foo/bar"));
assert(globMatchEditorConfig("foo/bar", "foo/*"));
assert(globMatchEditorConfig("foo/bar", "*/bar"));
assert(globMatchEditorConfig("/foo/bar/gluu/sar.png", "**/sar.png"));
assert(globMatchEditorConfig("/foo/bar/gluu/sar.png", "**/*.png"));
assert(!globMatchEditorConfig("/foo/bar/gluu/sar.png", "*/sar.png"));
assert(!globMatchEditorConfig("/foo/bar/gluu/sar.png", "*/*.png"));
static assert(globMatchEditorConfig("foo.bar", "[!gh]*bar"));
}

View File

@ -5,23 +5,27 @@
module dfmt.indentation;
import std.d.lexer;
import dfmt.config;
import dfmt.editorconfig;
import dparse.lexer;
import std.bitmanip : bitfields;
/**
* Returns: true if the given token type is a wrap indent type
*/
bool isWrapIndent(IdType type) pure nothrow @nogc @safe
{
return type != tok!"{" && type != tok!"case" && type != tok!"@"
&& type != tok!"]" && isOperator(type);
return type != tok!"{" && type != tok!"case" && type != tok!"@"
&& type != tok!"]" && type != tok!"(" && type != tok!")" && isOperator(type);
}
/**
* Returns: true if the given token type is a wrap indent type
* Returns: true if the given token type is a temporary indent type
*/
bool isTempIndent(IdType type) pure nothrow @nogc @safe
{
return type != tok!"{" && type != tok!"case" && type != tok!"@";
return type != tok!")" && type != tok!"{" && type != tok!"case" && type != tok!"@";
}
/**
@ -29,9 +33,33 @@ bool isTempIndent(IdType type) pure nothrow @nogc @safe
*/
struct IndentStack
{
/// Configuration
private const Config* config;
this(const Config* config)
{
this.config = config;
}
static struct Details
{
mixin(bitfields!(
// generally true for all operators except {, case, @, ], (, )
bool, "wrap", 1,
// temporary indentation which get's reverted when a block starts
// generally true for all tokens except ), {, case, @
bool, "temp", 1,
// emit minimal newlines
bool, "mini", 1,
// for associative arrays or arrays containing them, break after every item
bool, "breakEveryItem", 1,
// when an item inside an array would break mid-item, definitely break at the comma first
bool, "preferLongBreaking", 1,
uint, "", 27));
}
/**
* Modifies the indent stack to match the state that it had at the most
* recent appearance of the given token type.
* Get the indent size at the most recent occurrence of the given indent type
*/
int indentToMostRecent(IdType item) const
{
@ -56,7 +84,7 @@ struct IndentStack
int tempIndentCount = 0;
for (size_t i = index; i > 0; i--)
{
if (!isWrapIndent(arr[i - 1]) && arr[i - 1] != tok!"]")
if (!details[i - 1].wrap && arr[i - 1] != tok!"]")
break;
tempIndentCount++;
}
@ -67,9 +95,27 @@ struct IndentStack
* Pushes the given indent type on to the stack.
*/
void push(IdType item) pure nothrow
{
Details detail;
detail.wrap = isWrapIndent(item);
detail.temp = isTempIndent(item);
push(item, detail);
}
/**
* Pushes the given indent type on to the stack.
*/
void push(IdType item, Details detail) pure nothrow
{
arr[index] = item;
index = index + 1 == arr.length ? index : index + 1;
details[index] = detail;
//FIXME this is actually a bad thing to do,
//we should not just override when the stack is
//at it's limit
if (index < arr.length)
{
index++;
}
}
/**
@ -77,7 +123,8 @@ struct IndentStack
*/
void pop() pure nothrow
{
index = index == 0 ? index : index - 1;
if (index)
index--;
}
/**
@ -85,7 +132,7 @@ struct IndentStack
*/
void popWrapIndents() pure nothrow @safe @nogc
{
while (index > 0 && isWrapIndent(arr[index - 1]))
while (index > 0 && details[index - 1].wrap)
index--;
}
@ -94,10 +141,18 @@ struct IndentStack
*/
void popTempIndents() pure nothrow @safe @nogc
{
while (index > 0 && isTempIndent(arr[index - 1]))
while (index > 0 && details[index - 1].temp)
index--;
}
bool topAre(IdType[] types...)
{
if (types.length > index)
return false;
return arr[index - types.length .. index] == types;
}
/**
* Returns: `true` if the top of the indent stack is the given indent type.
*/
@ -111,7 +166,15 @@ struct IndentStack
*/
bool topIsTemp()
{
return index > 0 && index <= arr.length && isTempIndent(arr[index - 1]);
return index > 0 && index <= arr.length && details[index - 1].temp;
}
/**
* Returns: `true` if the top of the indent stack is a temporary indent with the specified token
*/
bool topIsTemp(IdType item)
{
return index > 0 && index <= arr.length && arr[index - 1] == item && details[index - 1].temp;
}
/**
@ -119,7 +182,15 @@ struct IndentStack
*/
bool topIsWrap()
{
return index > 0 && index <= arr.length && isWrapIndent(arr[index - 1]);
return index > 0 && index <= arr.length && details[index - 1].wrap;
}
/**
* Returns: `true` if the top of the indent stack is a temporary indent with the specified token
*/
bool topIsWrap(IdType item)
{
return index > 0 && index <= arr.length && arr[index - 1] == item && details[index - 1].wrap;
}
/**
@ -142,6 +213,11 @@ struct IndentStack
return arr[index - 1];
}
Details topDetails() const pure nothrow @property @safe @nogc
{
return details[index - 1];
}
int indentLevel() const pure nothrow @property @safe @nogc
{
return indentSize();
@ -152,34 +228,93 @@ struct IndentStack
return cast(int) index;
}
/**
* Dumps the current state of the indentation stack to `stderr`. Used for debugging.
*/
void dump(size_t pos = size_t.max, string file = __FILE__, uint line = __LINE__) const
{
import dparse.lexer : str;
import std.algorithm.iteration : map;
import std.stdio : stderr;
if (pos == size_t.max)
stderr.writefln("\033[31m%s:%d %(%s %)\033[0m", file, line, arr[0 .. index].map!(a => str(a)));
else
stderr.writefln("\033[31m%s:%d at %d %(%s %)\033[0m", file, line, pos, arr[0 .. index].map!(a => str(a)));
}
private:
size_t index;
IdType[256] arr;
Details[arr.length] details;
int indentSize(const size_t k = size_t.max) const pure nothrow @safe @nogc
{
import std.algorithm : among;
if (index == 0 || k == 0)
return 0;
immutable size_t j = k == size_t.max ? index : k;
int size = 0;
int parenCount;
foreach (i; 0 .. j)
{
immutable int pc = (arr[i] == tok!"!" || arr[i] == tok!"(" || arr[i] == tok!")") ? parenCount + 1
: parenCount;
if ((details[i].wrap || arr[i] == tok!"(") && parenCount > 1)
{
parenCount = pc;
continue;
}
if (i + 1 < index)
{
if (arr[i] == tok!"]")
if (config.dfmt_single_indent == OptionalBoolean.t && skipDoubleIndent(i, parenCount))
{
parenCount = pc;
continue;
immutable bool currentIsTemp = isTempIndent(arr[i]);
immutable bool nextIsTemp = isTempIndent(arr[i + 1]);
immutable bool nextIsSwitch = arr[i + 1] == tok!"switch";
if (currentIsTemp && (!nextIsTemp || nextIsSwitch))
}
immutable currentIsNonWrapTemp = !details[i].wrap
&& details[i].temp && arr[i] != tok!")" && arr[i] != tok!"!";
if (currentIsNonWrapTemp && arr[i + 1] == tok!"]")
{
parenCount = pc;
continue;
}
if (arr[i] == tok!"static"
&& arr[i + 1].among!(tok!"if", tok!"else", tok!"foreach", tok!"foreach_reverse")
&& (i + 2 >= index || arr[i + 2] != tok!"{"))
{
parenCount = pc;
continue;
}
if (currentIsNonWrapTemp && (arr[i + 1] == tok!"switch"
|| arr[i + 1] == tok!"{" || arr[i + 1] == tok!")"))
{
parenCount = pc;
continue;
}
}
else if (parenCount == 0 && arr[i] == tok!"(" && config.dfmt_single_indent == OptionalBoolean.f)
size++;
if (arr[i] == tok!"!")
size++;
parenCount = pc;
size++;
}
return size;
}
bool skipDoubleIndent(size_t i, int parenCount) const pure nothrow @safe @nogc
{
return (details[i + 1].wrap && arr[i] == tok!")")
|| (parenCount == 0 && arr[i + 1] == tok!"," && arr[i] == tok!"(");
}
}
unittest

View File

@ -5,18 +5,46 @@
module dfmt.main;
import std.string : strip;
static immutable VERSION = () {
debug
{
enum DEBUG_SUFFIX = "-debug";
}
else
{
enum DEBUG_SUFFIX = "";
}
version (built_with_dub)
{
enum DFMT_VERSION = import("dubhash.txt").strip;
}
else
{
/**
* Current build's Git commit hash
*/
enum DFMT_VERSION = import("githash.txt").strip;
}
return DFMT_VERSION ~ DEBUG_SUFFIX;
} ();
version (NoMain)
{
}
else
{
import std.array : front, popFront;
import std.stdio : stdout, stdin, stderr, writeln, File;
import dfmt.config : Config;
import dfmt.formatter : format;
import std.path : buildPath, expandTilde;
import dfmt.editorconfig : getConfigFor;
import dfmt.formatter : format;
import std.array : appender, front, popFront;
import std.getopt : getopt, GetOptException;
import std.path : buildPath, dirName, expandTilde;
import std.stdio : File, stderr, stdin, stdout, writeln;
int main(string[] args)
{
@ -24,13 +52,17 @@ else
Config optConfig;
optConfig.pattern = "*.d";
bool showHelp;
bool showVersion;
string explicitConfigDir;
void handleBooleans(string option, string value)
{
import dfmt.editorconfig : OptionalBoolean;
import std.exception : enforceEx;
enforceEx!GetOptException(value == "true" || value == "false", "Invalid argument");
immutable OptionalBoolean optVal = value == "true" ? OptionalBoolean.t : OptionalBoolean.f;
import std.exception : enforce;
enforce!GetOptException(value == "true" || value == "false", "Invalid argument");
immutable OptionalBoolean optVal = value == "true" ? OptionalBoolean.t
: OptionalBoolean.f;
switch (option)
{
case "align_switch_statements":
@ -42,6 +74,9 @@ else
case "space_after_cast":
optConfig.dfmt_space_after_cast = optVal;
break;
case "space_before_function_parameters":
optConfig.dfmt_space_before_function_parameters = optVal;
break;
case "split_operator_at_line_end":
optConfig.dfmt_split_operator_at_line_end = optVal;
break;
@ -51,28 +86,63 @@ else
case "compact_labeled_statements":
optConfig.dfmt_compact_labeled_statements = optVal;
break;
default: assert(false, "Invalid command-line switch");
case "single_template_constraint_indent":
optConfig.dfmt_single_template_constraint_indent = optVal;
break;
case "space_before_aa_colon":
optConfig.dfmt_space_before_aa_colon = optVal;
break;
case "space_before_named_arg_colon":
optConfig.dfmt_space_before_named_arg_colon = optVal;
break;
case "keep_line_breaks":
optConfig.dfmt_keep_line_breaks = optVal;
break;
case "single_indent":
optConfig.dfmt_single_indent = optVal;
break;
case "reflow_property_chains":
optConfig.dfmt_reflow_property_chains = optVal;
break;
case "space_after_keywords":
optConfig.dfmt_space_after_keywords = optVal;
break;
default:
assert(false, "Invalid command-line switch");
}
}
try
{
// dfmt off
getopt(args,
"version", &showVersion,
"align_switch_statements", &handleBooleans,
"brace_style", &optConfig.dfmt_brace_style,
"config|c", &explicitConfigDir,
"end_of_line", &optConfig.end_of_line,
"help|h", &showHelp,
"indent_size", &optConfig.indent_size,
"indent_style|t", &optConfig.indent_style,
"inplace", &inplace,
"inplace|i", &inplace,
"max_line_length", &optConfig.max_line_length,
"soft_max_line_length", &optConfig.dfmt_soft_max_line_length,
"outdent_attributes", &handleBooleans,
"space_after_cast", &handleBooleans,
"space_after_keywords", &handleBooleans,
"selective_import_space", &handleBooleans,
"space_before_function_parameters", &handleBooleans,
"split_operator_at_line_end", &handleBooleans,
"compact_labeled_statements", &handleBooleans,
"tab_width", &optConfig.tab_width);
"single_template_constraint_indent", &handleBooleans,
"space_before_aa_colon", &handleBooleans,
"space_before_named_arg_colon", &handleBooleans,
"tab_width", &optConfig.tab_width,
"template_constraint_style", &optConfig.dfmt_template_constraint_style,
"keep_line_breaks", &handleBooleans,
"single_indent", &handleBooleans,
"reflow_property_chains", &handleBooleans);
// dfmt on
}
catch (GetOptException e)
{
@ -80,6 +150,12 @@ else
return 1;
}
if (showVersion)
{
writeln(VERSION);
return 0;
}
if (showHelp)
{
printHelp();
@ -88,22 +164,62 @@ else
args.popFront();
immutable bool readFromStdin = args.length == 0;
immutable string filePath = createFilePath(readFromStdin, readFromStdin ? null : args[0]);
Config config;
config.initializeWithDefaults();
Config fileConfig = getConfigFor!Config(filePath);
fileConfig.pattern = "*.d";
config.merge(fileConfig, filePath);
config.merge(optConfig, filePath);
if (!config.isValid())
return 1;
version (Windows)
{
// On Windows, set stdout to binary mode (needed for correct EOL writing)
// See Phobos' stdio.File.rawWrite
{
import std.stdio : _O_BINARY;
immutable fd = stdout.fileno;
_setmode(fd, _O_BINARY);
version (CRuntime_DigitalMars)
{
import core.atomic : atomicOp;
import core.stdc.stdio : __fhnd_info, FHND_TEXT;
atomicOp!"&="(__fhnd_info[fd], ~FHND_TEXT);
}
}
}
File output = stdout;
ubyte[] buffer;
Config explicitConfig;
if (explicitConfigDir)
{
import std.file : exists, isDir;
if (!exists(explicitConfigDir) || !isDir(explicitConfigDir))
{
stderr.writeln("--config|c must specify existing directory path");
return 1;
}
explicitConfig = getConfigFor!Config(explicitConfigDir);
explicitConfig.pattern = "*.d";
}
if (readFromStdin)
{
import std.file : getcwd;
auto cwdDummyPath = buildPath(getcwd(), "dummy.d");
Config config;
config.initializeWithDefaults();
if (explicitConfigDir != "")
{
config.merge(explicitConfig, buildPath(explicitConfigDir, "dummy.d"));
}
else
{
Config fileConfig = getConfigFor!Config(getcwd());
fileConfig.pattern = "*.d";
config.merge(fileConfig, cwdDummyPath);
}
config.merge(optConfig, cwdDummyPath);
if (!config.isValid())
return 1;
ubyte[4096] inputBuffer;
ubyte[] b;
while (true)
@ -114,7 +230,9 @@ else
else
break;
}
dfmt.formatter.format("stdin", buffer, output.lockingTextWriter(), &config);
immutable bool formatSuccess = format("stdin", buffer,
stdout.lockingTextWriter(), &config);
return formatSuccess ? 0 : 1;
}
else
{
@ -122,6 +240,7 @@ else
if (args.length >= 2)
inplace = true;
int retVal;
while (args.length > 0)
{
const path = args.front;
@ -130,46 +249,115 @@ else
{
inplace = true;
foreach (string name; dirEntries(path, "*.d", SpanMode.depth))
{
args ~= name;
}
continue;
}
Config config;
config.initializeWithDefaults();
if (explicitConfigDir != "")
{
config.merge(explicitConfig, buildPath(explicitConfigDir, "dummy.d"));
}
else
{
Config fileConfig = getConfigFor!Config(path);
fileConfig.pattern = "*.d";
config.merge(fileConfig, path);
}
config.merge(optConfig, path);
if (!config.isValid())
return 1;
File f = File(path);
buffer = new ubyte[](cast(size_t) f.size);
f.rawRead(buffer);
if (inplace)
output = File(path, "wb");
dfmt.formatter.format(path, buffer, output.lockingTextWriter(), &config);
// ignore empty files
if (f.size)
{
buffer = new ubyte[](cast(size_t) f.size);
f.rawRead(buffer);
auto output = appender!string;
immutable bool formatSuccess = format(path, buffer, output, &config);
if (formatSuccess)
{
if (inplace)
File(path, "wb").rawWrite(output.data);
else
stdout.rawWrite(output.data);
}
else
retVal = 1;
}
}
return retVal;
}
return 0;
}
}
private version (Windows)
{
version(CRuntime_DigitalMars)
{
extern(C) int setmode(int, int) nothrow @nogc;
alias _setmode = setmode;
}
else version(CRuntime_Microsoft)
{
extern(C) int _setmode(int, int) nothrow @nogc;
}
}
template optionsToString(E) if (is(E == enum))
{
import std.algorithm.searching : startsWith;
enum optionsToString = () {
string result = "(";
foreach (s; [__traits(allMembers, E)])
{
if (!s.startsWith("_"))
result ~= s ~ "|";
}
result = result[0 .. $ - 1] ~ ")";
return result;
} ();
}
private void printHelp()
{
writeln(`dfmt 0.4.0-beta
writeln(`dfmt `, VERSION, `
https://github.com/dlang-community/dfmt
Options:
--help | -h Print this help message
--inplace Edit files in place
--help, -h Print this help message
--inplace, -i Edit files in place
--config, -c Path to directory to load .editorconfig file from.
--version Print the version number and then exit
Formatting Options:
--align_switch_statements
--brace_style
--end_of_line
--help|h
--brace_style `, optionsToString!(typeof(Config.dfmt_brace_style)),
`
--end_of_line `, optionsToString!(typeof(Config.end_of_line)), `
--indent_size
--indent_style|t
--inplace
--indent_style, -t `,
optionsToString!(typeof(Config.indent_style)), `
--keep_line_breaks
--soft_max_line_length
--max_line_length
--outdent_attributes
--space_after_cast
--space_before_function_parameters
--space_after_keywords
--selective_import_space
--single_template_constraint_indent
--split_operator_at_line_end
--compact_labeled_statements`);
--compact_labeled_statements
--template_constraint_style
--space_before_aa_colon
--space_before_named_arg_colon
--single_indent
--reflow_property_chains
`,
optionsToString!(typeof(Config.dfmt_template_constraint_style)));
}
private string createFilePath(bool readFromStdin, string fileName)

View File

@ -5,15 +5,38 @@
module dfmt.tokens;
import std.d.lexer;
import dparse.lexer;
/// Length of an invalid token
enum int INVALID_TOKEN_LENGTH = -1;
uint betweenParenLength(const Token[] tokens) pure @safe @nogc
in
{
assert(tokens[0].type == tok!"(");
}
do
{
uint length = 0;
size_t i = 1;
int depth = 1;
while (i < tokens.length && depth > 0)
{
if (tokens[i].type == tok!"(")
depth++;
else if (tokens[i].type == tok!")")
depth--;
length += tokenLength(tokens[i]);
i++;
}
return length;
}
int tokenLength(ref const Token t) pure @safe @nogc
{
import std.algorithm : countUntil;
int c;
switch (t.type)
{
case tok!"doubleLiteral":
@ -33,7 +56,7 @@ int tokenLength(ref const Token t) pure @safe @nogc
case tok!"wstringLiteral":
case tok!"dstringLiteral":
// TODO: Unicode line breaks and old-Mac line endings
auto c = cast(int) t.text.countUntil('\n');
c = cast(int) t.text.countUntil('\n');
if (c == -1)
return cast(int) t.text.length;
else
@ -89,6 +112,7 @@ bool isBreakToken(IdType t) pure nothrow @safe @nogc
case tok!"/":
case tok!"..":
case tok!"*=":
case tok!"*":
case tok!"&=":
case tok!"%=":
case tok!"%":
@ -103,19 +127,19 @@ bool isBreakToken(IdType t) pure nothrow @safe @nogc
}
}
int breakCost(IdType t) pure nothrow @safe @nogc
int breakCost(IdType p, IdType c) pure nothrow @safe @nogc
{
switch (t)
switch (c)
{
case tok!"||":
case tok!"&&":
case tok!",":
case tok!"?":
return 0;
case tok!"(":
return 60;
case tok!"[":
return 400;
case tok!":":
return 300;
case tok!";":
case tok!"^^":
case tok!"^=":
@ -146,11 +170,11 @@ int breakCost(IdType t) pure nothrow @safe @nogc
case tok!"!=":
case tok!"!>=":
case tok!"!>":
case tok!"?":
case tok!"/=":
case tok!"/":
case tok!"..":
case tok!"*=":
case tok!"*":
case tok!"&=":
case tok!"%=":
case tok!"%":
@ -159,8 +183,12 @@ int breakCost(IdType t) pure nothrow @safe @nogc
case tok!"~":
case tok!"+=":
return 200;
case tok!":":
// colon could be after a label or an import, where it should normally wrap like before
// for everything else (associative arrays) try not breaking around colons
return p == tok!"identifier" ? 0 : 300;
case tok!".":
return 900;
return p == tok!")" ? 0 : 300;
default:
return 1000;
}
@ -170,10 +198,9 @@ pure nothrow @safe @nogc unittest
{
foreach (ubyte u; 0 .. ubyte.max)
if (isBreakToken(u))
assert(breakCost(u) != 1000);
assert(breakCost(tok!".", u) != 1000);
}
private string generateFixedLengthCases()
{
import std.algorithm : map;
@ -183,36 +210,34 @@ private string generateFixedLengthCases()
assert(__ctfe);
string[] spacedOperatorTokens = [
",", "..", "...", "/", "/=", "!", "!<", "!<=", "!<>", "!<>=", "!=", "!>",
"!>=", "%", "%=", "&", "&&", "&=", "*", "*=", "+", "+=", "-", "-=", ":",
";", "<", "<<", "<<=", "<=", "<>", "<>=", "=", "==", "=>", ">", ">=",
">>", ">>=", ">>>", ">>>=", "?", "@", "^", "^=", "^^", "^^=", "|", "|=", "||",
"~", "~="
",", "..", "...", "/", "/=", "!", "!<", "!<=", "!<>", "!<>=", "!=",
"!>", "!>=", "%", "%=", "&", "&&", "&=", "*", "*=", "+", "+=", "-",
"-=", ":", ";", "<", "<<", "<<=", "<=", "<>", "<>=", "=", "==", "=>",
">", ">=", ">>", ">>=", ">>>", ">>>=", "?", "@", "^", "^=", "^^",
"^^=", "|", "|=", "||", "~", "~="
];
immutable spacedOperatorTokenCases = spacedOperatorTokens.map!(
a => format(`case tok!"%s": return %d + 1;`, a, a.length)).join("\n\t");
a => format(`case tok!"%s": return %d + 1;`, a, a.length)).join("\n\t");
string[] identifierTokens = [
"abstract", "alias", "align", "asm", "assert", "auto", "body", "bool",
"break", "byte", "case", "cast", "catch", "cdouble", "cent", "cfloat",
"char", "class", "const", "continue", "creal", "dchar", "debug",
"default", "delegate", "delete", "deprecated", "do", "double", "else",
"enum", "export", "extern", "false", "final", "finally", "float", "for",
"foreach", "foreach_reverse", "function", "goto", "idouble", "if",
"ifloat", "immutable", "import", "in", "inout", "int", "interface",
"invariant", "ireal", "is", "lazy", "long", "macro", "mixin", "module",
"new", "nothrow", "null", "out", "override", "package", "pragma",
"private", "protected", "public", "pure", "real", "ref", "return",
"scope", "shared", "short", "static", "struct", "super", "switch",
"synchronized", "template", "this", "throw", "true", "try", "typedef",
"typeid", "typeof", "ubyte", "ucent", "uint", "ulong", "union",
"unittest", "ushort", "version", "void", "volatile", "wchar", "while",
"with", "__DATE__", "__EOF__", "__FILE__", "__FUNCTION__", "__gshared",
"__LINE__", "__MODULE__", "__parameters", "__PRETTY_FUNCTION__",
"__TIME__", "__TIMESTAMP__", "__traits", "__vector", "__VENDOR__",
"__VERSION__", "$", "++", "--", ".", "[", "]", "(", ")", "{", "}"
"abstract", "alias", "align", "asm", "assert", "auto", "bool",
"break", "byte", "case", "cast", "catch", "cdouble", "cent", "cfloat", "char", "class",
"const", "continue", "creal", "dchar", "debug", "default", "delegate", "delete", "deprecated",
"do", "double", "else", "enum", "export", "extern", "false", "final", "finally", "float",
"for", "foreach", "foreach_reverse", "function", "goto", "idouble", "if", "ifloat", "immutable",
"import", "in", "inout", "int", "interface", "invariant", "ireal", "is",
"lazy", "long", "macro", "mixin", "module", "new", "nothrow", "null", "out", "override",
"package", "pragma", "private", "protected", "public", "pure", "real", "ref", "return", "scope",
"shared", "short", "static", "struct", "super", "switch", "synchronized", "template", "this",
"throw", "true", "try", "typedef", "typeid", "typeof", "ubyte", "ucent", "uint", "ulong",
"union", "unittest", "ushort", "version", "void", "wchar",
"while", "with", "__DATE__", "__EOF__", "__FILE__",
"__FUNCTION__", "__gshared", "__LINE__", "__MODULE__", "__parameters",
"__PRETTY_FUNCTION__", "__TIME__", "__TIMESTAMP__",
"__traits", "__vector", "__VENDOR__", "__VERSION__", "$", "++", "--",
".", "[", "]", "(", ")", "{", "}"
];
immutable identifierTokenCases = identifierTokens.map!(
a => format(`case tok!"%s": return %d;`, a, a.length)).join("\n\t");
a => format(`case tok!"%s": return %d;`, a, a.length)).join("\n\t");
return spacedOperatorTokenCases ~ identifierTokenCases;
}

View File

@ -5,62 +5,63 @@
module dfmt.wrapping;
import std.d.lexer;
import dparse.lexer;
import dfmt.tokens;
import dfmt.config;
struct State
{
this(uint breaks, const Token[] tokens, immutable short[] depths,
const Config* config, int currentLineLength, int indentLevel) pure @safe
const Config* config, int currentLineLength, int indentLevel) pure @safe
{
import std.math : abs;
import core.bitop : popcnt, bsf;
import std.algorithm : min, map, sum;
immutable int remainingCharsMultiplier = config.max_line_length - config.dfmt_soft_max_line_length;
immutable int newlinePenalty = remainingCharsMultiplier * 20;
immutable int remainingCharsMultiplier = 25;
immutable int newlinePenalty = 480;
this.breaks = breaks;
this._cost = 0;
this._solved = true;
int ll = currentLineLength;
if (breaks == 0)
{
immutable int l = currentLineLength + tokens.map!(a => tokenLength(a)).sum();
if (l > config.dfmt_soft_max_line_length)
{
immutable int longPenalty = (l - config.dfmt_soft_max_line_length) * remainingCharsMultiplier;
immutable int longPenalty = (l - config.dfmt_soft_max_line_length)
* remainingCharsMultiplier;
this._cost += longPenalty;
this._solved = longPenalty < newlinePenalty;
}
else
this._solved = true;
}
else
{
for (size_t i = 0; i != uint.sizeof * 8; ++i)
foreach (size_t i; 0 .. (uint.sizeof * 8))
{
if (((1 << i) & breaks) == 0)
continue;
immutable b = tokens[i].type;
immutable prevType = i > 0 ? tokens[i - 1].type : tok!"";
immutable currentType = tokens[i].type;
immutable p = abs(depths[i]);
immutable bc = breakCost(b) * (p == 0 ? 1 : p * 2);
this._cost += bc;
immutable bc = breakCost(prevType, currentType) * (p == 0 ? 1 : p * 2);
this._cost += bc + newlinePenalty;
}
int ll = currentLineLength;
size_t i = 0;
foreach (_; 0 .. uint.sizeof * 8)
{
immutable uint k = breaks >>> i;
immutable bool b = k == 0;
immutable uint bits = b ? 0 : bsf(k);
immutable uint bits = b ? ALGORITHMIC_COMPLEXITY_SUCKS : bsf(k);
immutable size_t j = min(i + bits + 1, tokens.length);
ll += tokens[i .. j].map!(a => tokenLength(a)).sum();
if (ll > config.dfmt_soft_max_line_length)
{
immutable int longPenalty = (ll - config.dfmt_soft_max_line_length) * remainingCharsMultiplier;
immutable int longPenalty = (ll - config.dfmt_soft_max_line_length)
* remainingCharsMultiplier;
this._cost += longPenalty;
}
if (ll > config.max_line_length)
@ -69,12 +70,14 @@ struct State
break;
}
i = j;
ll = indentLevel * config.indent_size;
if (indentLevel < 0)
ll = (abs(indentLevel) + 1) * config.indent_size;
else
ll = (indentLevel + (i == 0 ? 0 : 1)) * config.indent_size;
if (b)
break;
}
}
this._cost += popcnt(breaks) * newlinePenalty;
}
int cost() const pure nothrow @safe @property
@ -91,13 +94,12 @@ struct State
{
import core.bitop : bsf, popcnt;
if (_cost < other._cost || (_cost == other._cost && ((breaks != 0
&& other.breaks != 0 && bsf(breaks) > bsf(other.breaks))
|| (_solved && !other.solved))))
{
if (_cost < other._cost)
return -1;
}
return other._cost > _cost;
if (_cost == other._cost && (breaks != 0 && other.breaks != 0
&& bsf(breaks) > bsf(other.breaks)))
return -1;
return _cost > other._cost;
}
bool opEquals(ref const State other) const pure nothrow @safe
@ -117,8 +119,14 @@ private:
bool _solved;
}
private enum ALGORITHMIC_COMPLEXITY_SUCKS = uint.sizeof * 8;
/**
* Note: Negative values for `indentLevel` are treated specially: costs for
* continuation indents are reduced. This is used for array literals.
*/
size_t[] chooseLineBreakTokens(size_t index, const Token[] tokens,
immutable short[] depths, const Config* config, int currentLineLength, int indentLevel)
immutable short[] depths, const Config* config, int currentLineLength, int indentLevel)
{
import std.container.rbtree : RedBlackTree;
import std.algorithm : filter, min;
@ -134,39 +142,36 @@ size_t[] chooseLineBreakTokens(size_t index, const Token[] tokens,
return retVal;
}
enum ALGORITHMIC_COMPLEXITY_SUCKS = uint.sizeof * 8;
immutable size_t tokensEnd = min(tokens.length, ALGORITHMIC_COMPLEXITY_SUCKS);
auto open = new RedBlackTree!State;
open.insert(State(0, tokens[0 .. tokensEnd], depths[0 .. tokensEnd], config,
currentLineLength, indentLevel));
currentLineLength, indentLevel));
State lowest;
while (!open.empty)
lowest._solved = false;
int tries = 0;
while (!open.empty && tries < 10_00)
{
tries++;
State current = open.front();
if (current.cost < lowest.cost)
lowest = current;
open.removeFront();
if (current.solved)
{
return genRetVal(current.breaks, index);
}
validMoves!(typeof(open))(open, tokens[0 .. tokensEnd],
depths[0 .. tokensEnd], current.breaks, config, currentLineLength, indentLevel);
if (current < lowest)
lowest = current;
validMoves!(typeof(open))(open, tokens[0 .. tokensEnd], depths[0 .. tokensEnd],
current.breaks, config, currentLineLength, indentLevel);
}
if (open.empty)
return genRetVal(lowest.breaks, index);
foreach (r; open[].filter!(a => a.solved))
return genRetVal(r.breaks, index);
assert(false);
if (open[].front < lowest)
return genRetVal(open[].front.breaks, index);
else
return genRetVal(lowest.breaks, index);
}
void validMoves(OR)(auto ref OR output, const Token[] tokens,
immutable short[] depths, uint current, const Config* config,
int currentLineLength, int indentLevel)
void validMoves(OR)(auto ref OR output, const Token[] tokens, immutable short[] depths,
uint current, const Config* config, int currentLineLength, int indentLevel)
{
import std.algorithm : sort, canFind;
import std.array : insertInPlace;
foreach (i, token; tokens)
{
if (!isBreakToken(token.type) || (((1 << i) & current) != 0))

1
stdx-allocator Submodule

@ -0,0 +1 @@
Subproject commit ae237cabd1843774cc78aad0729c914a3dd579db

17
tests/2d_arrays.d Normal file
View File

@ -0,0 +1,17 @@
unittest
{
targets = [[RectangleShape.create(tex, vec2(-8 * scale, -32 * scale),
vec2(16 * scale, 48 * scale), vec4(14 / 16.0, 0, 16 / 16.0, 3 / 16.0)),
RectangleShape.create(tex, vec2(-8 * scale, -32 * scale), vec2(16 * scale,
32 * scale), vec4(14 / 16.0, 3 / 16.0, 16 / 16.0, 5 / 16.0))],
[RectangleShape.create(tex, vec2(-8 * scale, -8 * scale), vec2(16 * scale,
16 * scale), vec4(14 / 16.0, 5 / 16.0, 15 / 16.0, 6 / 16.0)), RectangleShape.create(tex,
vec2(-8 * scale, -8 * scale), vec2(16 * scale, 16 * scale),
vec4(15 / 16.0, 5 / 16.0, 16 / 16.0, 6 / 16.0))]];
int[][] foo = [[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32], [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32]];
float[3][3] mat = [[234.3456,42435.8653,23.5],[3.245,235.3,234.664],[14324.6453,23434.645,9678.345]];
}
string[][] globalArray = [["123456789012345678901234567890", "123456789012345678901234567890"], ["123456789012345678901234567890", "123456789012345678901234567890"]];

View File

@ -0,0 +1,38 @@
unittest
{
targets = [
[
RectangleShape.create(tex, vec2(-8 * scale, -32 * scale),
vec2(16 * scale, 48 * scale), vec4(14 / 16.0, 0, 16 / 16.0, 3 / 16.0)),
RectangleShape.create(tex, vec2(-8 * scale, -32 * scale),
vec2(16 * scale, 32 * scale), vec4(14 / 16.0, 3 / 16.0, 16 / 16.0, 5 / 16.0))
],
[
RectangleShape.create(tex, vec2(-8 * scale, -8 * scale),
vec2(16 * scale, 16 * scale), vec4(14 / 16.0, 5 / 16.0, 15 / 16.0, 6 / 16.0)),
RectangleShape.create(tex, vec2(-8 * scale, -8 * scale),
vec2(16 * scale, 16 * scale), vec4(15 / 16.0, 5 / 16.0, 16 / 16.0, 6 / 16.0))
]
];
int[][] foo = [
[
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32
],
[
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32
]
];
float[3][3] mat = [
[234.3456, 42435.8653, 23.5], [3.245, 235.3, 234.664],
[14324.6453, 23434.645, 9678.345]
];
}
string[][] globalArray = [
["123456789012345678901234567890", "123456789012345678901234567890"],
["123456789012345678901234567890", "123456789012345678901234567890"]
];

View File

@ -0,0 +1,23 @@
class C
{
void f()
{
if (true)
{
f(map.map.map.map.map.map.map.map.map.map.map.map.map.map.map.map
.map.map.map.map.map.map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __LINE__);
g(map && map && map && map && map && map && map && map && map && map && map
&& map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __LINE__);
h(map || map || map || map || map || map || map || map || map || map || map
|| map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __LINE__);
i(map + map + map + map + map + map + map + map + map + map + map + map + map
+ map + map + map + map + map, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __FILE__, __FILE__, __LINE__);
}
}
}

View File

@ -0,0 +1,31 @@
class C
{
void f()
{
if (true)
{
f(
array.map!(a => a.prop)
.array
.to!string,
__FILE__,
__LINE__);
g(
map &&
map,
__FILE__,
__LINE__);
h(
map ||
map,
__FILE__,
__LINE__);
i(
map
+ map,
__FILE__,
__LINE__);
}
}
}

View File

@ -0,0 +1,7 @@
unittest
{
foo([
target.value.region[1], target.value.region[1], target.value.region[1],
target.value.region[1], target.value.region[1]
]);
}

View File

@ -0,0 +1,8 @@
void main()
{
string key;
int[string] var = [
key: 5
];
}

View File

@ -0,0 +1,26 @@
unittest
{
Bson base = Bson([
"maps": Bson([
Bson(["id": Bson(4), "comment": Bson("hello")]),
Bson(["id": Bson(49), "comment": Bson(null)])
]),
"short": Bson(["a": "b", "c": "d"]),
"numbers": Bson([
1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2,
3, 4, 5, 6, 7, 8, 9, 0
]),
"shuffleOnReset": serializeToBson([
"all": false,
"selected": true,
"maybe": false
]),
"resetOnEmpty": Bson(false),
"applyMods": Bson(true),
"sendComments": Bson(true)
]);
int[] x = [
1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3,
4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0
];
}

View File

@ -0,0 +1,25 @@
auto find()
{
return Map.findRange([
"$and": [
["deleted": Bson(false)],
[
"$or": Bson([
serializeToBson(["forceUpdate": Bson(true)]),
serializeToBson([
"info.approved": ["$eq": Bson(1)],
"fetchDate": [
"$lte": Bson(BsonDate(currentTime - 60.days))
]
]),
serializeToBson([
"info.approved": ["$ne": Bson(1)],
"fetchDate": [
"$lte": Bson(BsonDate(currentTime - 14.days))
]
])
])
]
]
]);
}

View File

@ -0,0 +1,17 @@
struct SomeStructName
{
static struct InnerStruct
{
version (linux)
{
static if (condition)
{
void longFunctionName(AAAAAAAA)(AAAAAAAA a) @property
if (someThingsAreTrue!AAAAAAAA && long_condition
&& is(elaborate == expression))
{
}
}
}
}
}

View File

@ -0,0 +1,15 @@
unittest
{
{
{
foreach (abcde, def; abcdef.map!(battlecruiser => battlecruiser[123 .. 1231231])
.filter!(bravo => charlie[10] > 90000)
.sum())
{
}
abcdeabcdeabcde(12341234).abcdeabcdeabcde(12341234).abcdeabcdeabcde(12341234)
.abcdeabcdeabcde(12341234).abcdeabcdeabcde(12341234);
}
}
}

View File

@ -2,6 +2,6 @@ int /*sneaky*/ foo( /*comments*/ ) /*everywhere*/
{
// comment on its own line
foo() // comment on same line
.bar(); // also on same line
.bar(); // also on same line
/* again */ // same line
}

View File

@ -0,0 +1,9 @@
void foo()()
if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees
&& cows && sheeps && monkeys && whales)
{
}
void foo()() if (dogs && pigs && birds)
{
}

View File

@ -0,0 +1,10 @@
void foo()()
if (dogs && pigs && birds && ants && foxes && flies && cats && bugs && bees
&& cows && sheeps && monkeys && whales)
{
}
void foo()()
if (dogs && pigs && birds)
{
}

View File

@ -0,0 +1,8 @@
void main()
{
if (true)
debug
{
foo();
}
}

View File

@ -0,0 +1,7 @@
void main()
{
debug (0)
foo();
else
bar();
}

View File

@ -0,0 +1,21 @@
int foo(int arg)
in
{
assert(arg > 0);
}
out (result)
{
assert(result == 0);
}
do
{
return 0;
}
int bar(int arg)
in (arg > 0)
out (; true)
out /*Major*/ ( /*Tom*/ result /*To ground control*/ ; result == 0)
{
return 0;
}

View File

@ -0,0 +1,19 @@
import character.body;
void body() @nogc
in
{
}
body
{
body = null;
}
void body()
in
{
}
do
{
body = null;
}

0
tests/allman/empty.d.ref Normal file
View File

View File

@ -0,0 +1,6 @@
enum Foo
{
deprecated member0,
@UDA(0) member1
}

View File

@ -0,0 +1,54 @@
static foreach (x; [
1,
2,
3,
])
{
}
static foreach_reverse (x; [
1,
2,
3,
])
{
}
void f()
{
foreach (x; [
1,
2,
3,
])
{
}
foreach_reverse (x; [
1,
2,
3,
])
{
}
if (!SymbolTool.instance.workspacesFilesUris.canFind!sameFile(uri))
{
send(TextDocument.publishDiagnostics, new PublishDiagnosticsParams(uri, [
]));
}
foreach (x; map([
1,
2,
3,
]))
{
}
foreach (x; foo!(map!([
1,
2,
3,
])))
{
}
}

View File

@ -0,0 +1 @@
void foo(@UDA(0) @UDA(1) Bar bar);

View File

@ -3,8 +3,7 @@ import std.stdio, std.random, std.typecons, std.conv, std.string, std.range;
void main()
{
immutable interval = tuple(1, 100);
writefln("Guess my target number that is between " ~ "%d and %d (inclusive).\n",
interval[]);
writefln("Guess my target number that is between " ~ "%d and %d (inclusive).\n", interval[]);
immutable target = uniform!"[]"(interval[]);
foreach (immutable i; sequence!q{n})

View File

@ -0,0 +1 @@
alias u8 = ubyte

View File

@ -1,3 +1,4 @@
immutable NameId[] namesA = [{"Aacgr", 0x00386}, // GREEK CAPITAL LETTER ALPHA WITH TONOS
{"aacgr", 0x003AC}, // GREEK SMALL LETTER ALPHA WITH TONOS
immutable NameId[] namesA = [
{"Aacgr", 0x00386}, // GREEK CAPITAL LETTER ALPHA WITH TONOS
{"aacgr", 0x003AC}, // GREEK SMALL LETTER ALPHA WITH TONOS
];

View File

View File

@ -10,27 +10,27 @@ string generateFixedLengthCases()
string[] fixedLengthTokens = [
"abstract", "alias", "align", "asm", "assert", "auto", "body", "bool",
"break", "byte", "case", "cast", "catch", "cdouble", "cent", "cfloat",
"char", "class", "const", "continue", "creal", "dchar", "debug",
"default", "delegate", "delete", "deprecated", "do", "double", "else",
"enum", "export", "extern", "false", "final", "finally", "float",
"for", "foreach", "foreach_reverse", "function", "goto", "idouble",
"if", "ifloat", "immutable", "import", "in", "inout", "int",
"interface", "invariant", "ireal", "is", "lazy", "long", "macro",
"mixin", "module", "new", "nothrow", "null", "out", "override",
"package", "pragma", "private", "protected", "public", "pure", "real",
"ref", "return", "scope", "shared", "short", "static", "struct",
"super", "switch", "synchronized", "template", "this", "throw", "true",
"try", "typedef", "typeid", "typeof", "ubyte", "ucent", "uint",
"ulong", "union", "unittest", "ushort", "version", "void", "volatile",
"wchar", "while", "with", "__DATE__", "__EOF__", "__FILE__",
"__FUNCTION__", "__gshared", "__LINE__", "__MODULE__", "__parameters",
"__PRETTY_FUNCTION__", "__TIME__", "__TIMESTAMP__", "__traits",
"__vector", "__VENDOR__", "__VERSION__", ",", ".", "..", "...", "/",
"/=", "!", "!<", "!<=", "!<>", "!<>=", "!=", "!>", "!>=", "$", "%",
"%=", "&", "&&", "&=", "(", ")", "*", "*=", "+", "++", "+=", "-",
"--", "-=", ":", ";", "<", "<<", "<<=", "<=", "<>", "<>=", "=", "==",
"=>", ">", ">=", ">>", ">>=", ">>>", ">>>=", "?", "@", "[", "]", "^",
"^=", "^^", "^^=", "{", "|", "|=", "||", "}", "~", "~="
"char", "class", "const", "continue", "creal", "dchar", "debug", "default",
"delegate", "delete", "deprecated", "do", "double", "else", "enum",
"export", "extern", "false", "final", "finally", "float", "for", "foreach",
"foreach_reverse", "function", "goto", "idouble", "if", "ifloat",
"immutable", "import", "in", "inout", "int", "interface", "invariant",
"ireal", "is", "lazy", "long", "macro", "mixin", "module", "new",
"nothrow", "null", "out", "override", "package", "pragma", "private",
"protected", "public", "pure", "real", "ref", "return", "scope", "shared",
"short", "static", "struct", "super", "switch", "synchronized", "template",
"this", "throw", "true", "try", "typedef", "typeid", "typeof", "ubyte",
"ucent", "uint", "ulong", "union", "unittest", "ushort", "version", "void",
"volatile", "wchar", "while", "with", "__DATE__", "__EOF__",
"__FILE__", "__FUNCTION__", "__gshared", "__LINE__",
"__MODULE__", "__parameters", "__PRETTY_FUNCTION__", "__TIME__",
"__TIMESTAMP__", "__traits", "__vector", "__VENDOR__", "__VERSION__",
",", ".", "..", "...", "/", "/=", "!", "!<", "!<=", "!<>", "!<>=",
"!=", "!>", "!>=", "$", "%", "%=", "&", "&&", "&=", "(", ")", "*",
"*=", "+", "++", "+=", "-", "--", "-=", ":", ";", "<", "<<", "<<=",
"<=", "<>", "<>=", "=", "==", "=>", ">", ">=", ">>", ">>=", ">>>",
">>>=", "?", "@", "[", "]", "^", "^=", "^^", "^^=", "{", "|", "|=", "||",
"}", "~", "~="
];
}

View File

@ -6,7 +6,7 @@ unittest
{
auto dd = new DtorDeclaration(declLoc, Loc(), stc, Identifier.idPool("__fieldDtor"));
auto dd = new DtorDeclaration(declLoc, Loc(), stc, extraParam,
midLengthFun(param, param), longIdentifier, Identifier.idPool("__fieldDtor"));
midLengthFun(param, param), longIdentifier, Identifier.idPool("__fieldDtor"));
memcpy(&saved_idents, &rvl.saved_idents, (const(char)*).sizeof * VC_SAVED_IDENT_CNT);
memcpy(&saved_types, &rvl.saved_types, (Type).sizeof * VC_SAVED_TYPE_CNT);
@ -16,8 +16,7 @@ unittest
}
void doStuff(const Token[] tokens, ref const State current,
const FormatterConfig* formatterConfig, int currentLineLength, int indentLevel,
int depth)
const FormatterConfig* formatterConfig, int currentLineLength, int indentLevel, int depth)
{
return;
}

View File

@ -2,7 +2,7 @@
{
with (CXTypeKind)
return kind == CXType_FunctionNoProto || kind == CXType_FunctionProto
|| // FIXME: This "hack" shouldn't be needed.
|| // FIXME: This "hack" shouldn't be needed.
func.resultType.isValid;
}

View File

@ -1,8 +1,8 @@
struct Test
{
this(string name, string[] aliasList, string briefDescription, string examDesc,
string onOpenDesc, string openDesc, string onCloseDesc, string closeDesc,
Flag!"canOpen" canOpen, Flag!"canClose" canClose, Flag!"isOpen" isOpen)
this(string name, string[] aliasList, string briefDescription, string examDesc, string onOpenDesc,
string openDesc, string onCloseDesc, string closeDesc,
Flag!"canOpen" canOpen, Flag!"canClose" canClose, Flag!"isOpen" isOpen)
{
}
}

View File

@ -0,0 +1,15 @@
unittest
{
testScene = new Scene("TestScene : Test", sceneDescriptions["TestScene"],
connectDescriptions["TestScene"], delegate(Scene scene) {
import std.stdio;
if (!scene.alreadyEntered)
{
fwriteln(
"This is a test. This is a test. This is a test. This is a test. This is a test. Test12.");
auto p = cast(Portal) sceneManager.previousScene;
scene.destroyCurrentScript();
}
});
}

View File

@ -0,0 +1,15 @@
unittest
{
testScene = new Scene(longArgument, longArgument, longArgument,
longArgument, longArgument, longArgument, delegate(Scene scene) {
import std.stdio;
if (!scene.alreadyEntered)
{
fwriteln(
"This is a test. This is a test. This is a test. This is a test. This is a test. Test12.");
auto p = cast(Portal) sceneManager.previousScene;
scene.destroyCurrentScript();
}
});
}

View File

@ -1,5 +1,5 @@
auto fun = function() { };
auto fun = () { };
auto fun = function() {};
auto fun = () {};
auto fun = {};
auto fun = { int i; };
@ -17,9 +17,8 @@ unittest
});
callFunc({
int i = 10;
foo(alpha_longVarName, bravo_longVarName, charlie_longVarName,
delta_longVarName, echo_longVarName, foxtrot_longVarName,
golf_longVarName, echo_longVarName);
foo(alpha_longVarName, bravo_longVarName, charlie_longVarName, delta_longVarName,
echo_longVarName, foxtrot_longVarName, golf_longVarName, echo_longVarName);
doStuff(withThings, andOtherStuff);
return i;
}, more_stuff);

View File

@ -1,7 +1,7 @@
struct State
{
this(uint breaks, const Token[] tokens, immutable short[] depths,
const Config* config, int currentLineLength, int indentLevel) pure @safe
const Config* config, int currentLineLength, int indentLevel) pure @safe
{
}
}

View File

@ -0,0 +1,15 @@
void foo()
{
string command;
version (Posix)
command ~= " 2> /dev/null 1> /dev/null";
version (Posix)
command ~= " 2> /dev/null 1> /dev/null";
unittest
{
version (Posix)
command ~= " 2> /dev/null 1> /dev/null";
}
}

View File

@ -1,5 +1,5 @@
class Foo(T) : FirstInterfaceWithVeryLongName,
SecondInterfaceWithVeryLongName if (is(T : Bar))
class Foo(T) : FirstInterfaceWithVeryLongName, SecondInterfaceWithVeryLongName
if (is(T : Bar))
{
void foo()
{

View File

@ -1,5 +1,6 @@
@Foo enum Bar
{
a
}
@foo class Baz

View File

@ -1,8 +1,8 @@
void foo(int foobarbazqux1, /* */
int foobarbazqux2, /* */
int foobarbazqux3, /* */
int foobarbazqux4, /* */
int foobarbazqux5, /* */
int foobarbazqux6, /* */
int foobarbazqux7 /* */
int foobarbazqux2, /* */
int foobarbazqux3, /* */
int foobarbazqux4, /* */
int foobarbazqux5, /* */
int foobarbazqux6, /* */
int foobarbazqux7 /* */
);

View File

@ -0,0 +1,7 @@
final class FormatVisitor : ASTVisitor
{
this(ASTInformation* astInformation)
{
this.astInformation = astInformation;
}
}

View File

@ -0,0 +1,5 @@
void merge()
{
static if (is(T == enum))
*thisN = x;
}

View File

@ -0,0 +1,29 @@
unittest
{
{
}
//
{
}
}
unittest
{
{
}
//
{
}
}
unittest
{
{
}
//
{
}
}

View File

@ -0,0 +1,15 @@
unittest
{
do
++a;
while (true);
}
unittest
{
do
{
++a;
}
while (true);
}

View File

@ -0,0 +1,29 @@
void functionName()
{
}
void main()
{
static if (true)
{
if (true && {
functionName();
functionName();
functionName();
functionName();
return true;
}())
{
}
else
{
}
}
else
{
}
}

View File

@ -0,0 +1,3 @@
void doStuff(T)() @safe if (isNumeric!T)
{
}

View File

@ -0,0 +1,21 @@
unittest
{
Test("Something") in
{
abcde_abcde_abcde();
abcde_abcde_abcde();
abcde_abcde_abcde();
abcde_abcde_abcde();
abcde_abcde_abcde();
abcde_abcde_abcde();
};
}
void aFunction(ParamType param)
in
{
assert(stuff);
}
body
{
}

View File

@ -0,0 +1,8 @@
unittest
{
asm
{
dl 12345;
movdqu [R8], XMM0;
}
}

View File

@ -0,0 +1,12 @@
module test;
void main()
{
test("stringLiteral") in
{
foreach (thing; things)
{
doStuff(thing);
}
};
}

View File

@ -0,0 +1,16 @@
void main()
{
auto myTid = runTask({
auto conn = connectTCP("localhost", 4222);
auto l = Lexer(conn);
foreach (t; l)
{
}
conn.close();
});
// foo
runEventLoop();
}

View File

@ -0,0 +1,13 @@
version (Foo)
{
version (D_Version2)
{
public import core.memory;
}
else:
}
version (Bar)
int foo();
else:
int foo(int);

View File

@ -0,0 +1,8 @@
unittest
{
asm
{
}
d[] = a[];
c[] = d[];
}

View File

@ -0,0 +1,8 @@
unittest
{
import std.stdio : stderr;
{
a = 10;
}
}

View File

@ -0,0 +1,11 @@
enum a
{
a,
b,
c,
d,
/* a comment */
e,
f,
g
}

View File

@ -0,0 +1,7 @@
unittest
{
if (a && !is(b == q))
{
}
}

View File

@ -0,0 +1,23 @@
unittest
{
{
public Vector!(T) opBinary(string op, string file = __FILE__, size_t line = __LINE__)(
const Vector!(T) x) const if (op == "*")
in
{
}
body
{
}
}
}
public Vector!(T) opBinary(string op, string file = __FILE__, size_t line = __LINE__)(
const Vector!(T) x) const if (op == "*")
in
{
}
body
{
}

View File

@ -0,0 +1,2 @@
static assert(call(x) !is y);
static assert(call(x) is y);

View File

@ -0,0 +1,4 @@
enum
{
x = 3
}

View File

@ -0,0 +1,6 @@
version (linux)
import core.sys.linux.elf;
else version (FreeBSD)
import core.sys.freebsd.sys.elf;
else version (Solaris)
import core.sys.solaris.elf;

View File

@ -0,0 +1,18 @@
module example;
bool aTemplatedFunction(One)(One alpha) if (isNumeric!One)
{
}
unittest
{
{
bool anotherTemplatedFunction(One, Two, Three)(One alpha, Two bravo,
Three charlie, double delta)
if (isNumeric!One && isNumeric!Two && isNumeric!Three && echo
&& foxtrot && golf && hotel && india && juliet)
{
}
}
}

View File

@ -0,0 +1,18 @@
module example;
bool aTemplatedFunction(One)(One alpha) if (isNumeric!One)
{
}
unittest
{
{
bool anotherTemplatedFunction(One, Two, Three)(One alpha, Two bravo,
Three charlie, double delta)
if (isNumeric!One && isNumeric!Two && isNumeric!Three && echo
&& foxtrot && golf && hotel && india && juliet)
{
}
}
}

View File

@ -0,0 +1,19 @@
module example;
bool aTemplatedFunction(One)(One alpha)
if (isNumeric!One)
{
}
unittest
{
{
bool anotherTemplatedFunction(One, Two, Three)(One alpha, Two bravo,
Three charlie, double delta)
if (isNumeric!One && isNumeric!Two && isNumeric!Three && echo
&& foxtrot && golf && hotel && india && juliet)
{
}
}
}

View File

@ -0,0 +1,19 @@
module example;
bool aTemplatedFunction(One)(One alpha)
if (isNumeric!One)
{
}
unittest
{
{
bool anotherTemplatedFunction(One, Two, Three)(One alpha, Two bravo,
Three charlie, double delta)
if (isNumeric!One && isNumeric!Two && isNumeric!Three && echo
&& foxtrot && golf && hotel && india && juliet)
{
}
}
}

View File

@ -0,0 +1,7 @@
unittest
{
if (something || somethingElse || // I like putting comments here for no good reason
thirdThing)
{
}
}

View File

@ -0,0 +1,6 @@
@OneOf("group1")
{
JSONValue[string] fred;
bool mertz;
bool ethel;
}

View File

@ -0,0 +1,68 @@
static if (someCondition)
void doStuff()
{
}
else
void doStuff()
{
}
static if (someCondition)
void doStuff()
{
}
else static if (otherCondition)
void doStuff()
{
}
static if (someCondition)
void doStuff()
{
}
else static if (otherCondition)
void doStuff()
{
}
else
void doStuff()
{
}
static if (condition)
int a;
else
int b;
static if (condition)
int a;
else static if (otherCondition)
int c;
else
int b;
void doStuff();
static if (stuff)
int a;
else
class C
{
public:
void aFunction();
private:
int a;
int b;
}
static if (condition)
int a;
else
int b;
static if (condition)
int a;
else static if (otherCondition)
int c;
else
int b;

View File

@ -0,0 +1,5 @@
unittest
{
static if (stuff) // comment
things();
}

View File

@ -0,0 +1,5 @@
unittest
{
return (complicated % expression) / //-------------------
(other * complicated + expression);
}

View File

@ -0,0 +1,7 @@
unittest
{
if (info > 0)
throw new ExceptionWithLongName(std.string.format(
"During the LU factorization, it was found that the " ~ "%sth diagonal value is exactly zero.",
info), file, line);
}

View File

@ -0,0 +1,6 @@
unittest
{
int a, /// comment
b, /// comment
c; /// comment
}

View File

@ -0,0 +1,5 @@
static if (condition)
int declaration;
else
{
}

View File

@ -0,0 +1,15 @@
unittest
{
auto a = 1234567890 + 1234567890 + 1234567890 + 1234567890 + 1234567890
+ 1234567890 + 1234567890 + 1234567890 + 1234567890 + 1234567890
+ 1234567890 + 1234567890 + 1234567890 + 1234567890 + 1234567890
+ 1234567890 + 1234567890 + 1234567890;
auto a = 1234567890 - 1234567890 - 1234567890 - 1234567890 - 1234567890
- 1234567890 - 1234567890 - 1234567890 - 1234567890 - 1234567890
- 1234567890 - 1234567890 - 1234567890 - 1234567890 - 1234567890
- 1234567890 - 1234567890 - 1234567890;
auto a = 1234567890 * 1234567890 * 1234567890 * 1234567890 * 1234567890
* 1234567890 * 1234567890 * 1234567890 * 1234567890 * 1234567890
* 1234567890 * 1234567890 * 1234567890 * 1234567890 * 1234567890
* 1234567890 * 1234567890 * 1234567890;
}

View File

@ -0,0 +1,8 @@
/* This test relies on ../.gitattributes to contain these lines:
tests/issue0228.d text eol=lf
tests/allman/issue0228.d.ref text eol=crlf
tests/knr/issue0228.d.ref text eol=crlf
tests/otbs/issue0228.d.ref text eol=crlf
*/

View File

@ -0,0 +1,24 @@
enum
{
SQL_CA2_READ_ONLY_CONCURRENCY = 0x00000001L,
SQL_CA2_LOCK_CONCURRENCY = 0x00000002L,
SQL_CA2_OPT_ROWVER_CONCURRENCY = 0x00000004L,
SQL_CA2_OPT_VALUES_CONCURRENCY = 0x00000008L,
SQL_CA2_SENSITIVITY_ADDITIONS = 0x00000010L,
SQL_CA2_SENSITIVITY_DELETIONS = 0x00000020L,
SQL_CA2_SENSITIVITY_UPDATES = 0x00000040L,
// * semantics of SQL_ATTR_MAX_ROWS *
SQL_CA2_MAX_ROWS_SELECT = 0x00000080L,
SQL_CA2_MAX_ROWS_INSERT = 0x00000100L,
SQL_CA2_MAX_ROWS_DELETE = 0x00000200L,
SQL_CA2_MAX_ROWS_UPDATE = 0x00000400L,
SQL_CA2_MAX_ROWS_CATALOG = 0x00000800L,
SQL_CA2_MAX_ROWS_AFFECTS_ALL = (
SQL_CA2_MAX_ROWS_SELECT | SQL_CA2_MAX_ROWS_INSERT | SQL_CA2_MAX_ROWS_DELETE
| SQL_CA2_MAX_ROWS_UPDATE | SQL_CA2_MAX_ROWS_CATALOG),
SQL_CA2_CRC_EXACT = 0x00001000L,
SQL_CA2_CRC_APPROXIMATE = 0x00002000L,
SQL_CA2_SIMULATE_NON_UNIQUE = 0x00004000L,
SQL_CA2_SIMULATE_TRY_UNIQUE = 0x00008000L,
SQL_CA2_SIMULATE_UNIQUE = 0x00010000L
}

View File

@ -0,0 +1,40 @@
void fn()
{
{
{
{
auto file = {
"integrationtest/feed/etc/config.iniaasdfaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"etc/config.ini"
};
{
int x;
}
}
}
}
}
struct A
{
int x, y, z;
}
int main()
{
int fun()
{
import std.stdio : writeln;
import std.typecons : tuple;
A a = {
tuple(Variant(1))[0].get!int, tuple(Variant(2))[0].get!int,
tuple(Variant(3))[0].get!int
};
A b = {
tuple(Variant(1))[0].get!int, tuple(Variant(2))[0].get!int,
tuple(Variant(3))[0].get!int
};
writeln(a);
}
}

View File

@ -0,0 +1,4 @@
void round()
body
{
}

View File

@ -0,0 +1,5 @@
enum Status : bool
{
abort = true,
ignore = false
}

Some files were not shown because too many files have changed in this diff Show More