Compare commits
No commits in common. "master" and "v0.10.1" have entirely different histories.
|
|
@ -1,16 +0,0 @@
|
||||||
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
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
# 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
|
|
||||||
|
|
@ -4,6 +4,3 @@
|
||||||
[submodule "stdx-allocator"]
|
[submodule "stdx-allocator"]
|
||||||
path = stdx-allocator
|
path = stdx-allocator
|
||||||
url = https://github.com/dlang-community/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
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [[ $BUILD == dub ]]; then
|
||||||
|
dub build --build=release
|
||||||
|
elif [[ $DC == ldc2 ]]; then
|
||||||
|
git submodule update --init --recursive
|
||||||
|
make ldc -j2
|
||||||
|
else
|
||||||
|
git submodule update --init --recursive
|
||||||
|
make debug -j2
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd tests && ./test.sh
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
sudo: false
|
||||||
|
language: d
|
||||||
|
d:
|
||||||
|
- dmd
|
||||||
|
- ldc
|
||||||
|
|
||||||
|
os:
|
||||||
|
- linux
|
||||||
|
- osx
|
||||||
|
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- /^v\d+\.\d+\.\d+([+-]\S*)*$/
|
||||||
|
|
||||||
|
env:
|
||||||
|
- BUILD=
|
||||||
|
- BUILD=dub
|
||||||
|
|
||||||
|
script: ./.travis.sh
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
include:
|
||||||
|
- stage: GitHub Release
|
||||||
|
#if: tag IS present
|
||||||
|
d: ldc-1.13.0
|
||||||
|
os: linux
|
||||||
|
script: echo "Deploying to GitHub releases ..." && ./release.sh
|
||||||
|
deploy:
|
||||||
|
provider: releases
|
||||||
|
api_key: $GH_REPO_TOKEN
|
||||||
|
file_glob: true
|
||||||
|
file: bin/dfmt-*.tar.gz
|
||||||
|
skip_cleanup: true
|
||||||
|
on:
|
||||||
|
repo: dlang-community/dfmt
|
||||||
|
tags: true
|
||||||
|
- stage: GitHub Release
|
||||||
|
#if: tag IS present
|
||||||
|
d: ldc-1.13.0
|
||||||
|
os: osx
|
||||||
|
script: echo "Deploying to GitHub releases ..." && ./release.sh
|
||||||
|
deploy:
|
||||||
|
provider: releases
|
||||||
|
api_key: $GH_REPO_TOKEN
|
||||||
|
file_glob: true
|
||||||
|
file: bin/dfmt-*.tar.gz
|
||||||
|
skip_cleanup: true
|
||||||
|
on:
|
||||||
|
repo: dlang-community/dfmt
|
||||||
|
tags: true
|
||||||
|
- stage: GitHub Release
|
||||||
|
#if: tag IS present
|
||||||
|
d: dmd
|
||||||
|
os: linux
|
||||||
|
language: generic
|
||||||
|
sudo: yes
|
||||||
|
script: echo "Deploying to GitHub releases ..." && ./release-windows.sh
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- p7zip-full
|
||||||
|
deploy:
|
||||||
|
provider: releases
|
||||||
|
api_key: $GH_REPO_TOKEN
|
||||||
|
file_glob: true
|
||||||
|
file: bin/dfmt-*.zip
|
||||||
|
skip_cleanup: true
|
||||||
|
on:
|
||||||
|
repo: dlang-community/dfmt
|
||||||
|
tags: true
|
||||||
|
- stage: GitHub Release
|
||||||
|
#if: tag IS present
|
||||||
|
d: dmd
|
||||||
|
os: linux
|
||||||
|
language: generic
|
||||||
|
sudo: yes
|
||||||
|
script: echo "Deploying to GitHub releases ..." && ARCH=64 ./release-windows.sh
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- p7zip-full
|
||||||
|
deploy:
|
||||||
|
provider: releases
|
||||||
|
api_key: $GH_REPO_TOKEN
|
||||||
|
file_glob: true
|
||||||
|
file: bin/dfmt-*.zip
|
||||||
|
skip_cleanup: true
|
||||||
|
on:
|
||||||
|
repo: dlang-community/dfmt
|
||||||
|
tags: true
|
||||||
|
stages:
|
||||||
|
- name: test
|
||||||
|
if: type = pull_request or (type = push and branch = master)
|
||||||
38
README.md
38
README.md
|
|
@ -1,28 +1,22 @@
|
||||||
# dfmt [](https://github.com/dlang-community/dfmt/actions?query=workflow%3A%22D%22)
|
# dfmt [](https://travis-ci.org/dlang-community/dfmt)
|
||||||
|
|
||||||
**dfmt** is a formatter for D source code
|
**dfmt** is a formatter for D source code
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
**dfmt** is beta quality. Make backups of your files or use source control
|
**dfmt** is beta quality. Make backups of your files or use source control
|
||||||
when using the **--inplace** option.
|
when using the **--inplace** option.
|
||||||
|
|
||||||
## Installation
|
## Building
|
||||||
|
### Using Make
|
||||||
### Installing with DUB
|
|
||||||
|
|
||||||
```sh
|
|
||||||
> dub run dfmt -- -h
|
|
||||||
```
|
|
||||||
|
|
||||||
### Building from source using Make
|
|
||||||
* Clone the repository
|
* Clone the repository
|
||||||
* Run ```git submodule update --init --recursive``` 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
|
* 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/```.
|
LDC, run ```make ldc``` instead. The generated binary will be placed in ```dfmt/bin/```.
|
||||||
|
|
||||||
### Building from source using dub
|
### Installing with DUB
|
||||||
* Clone the repository
|
|
||||||
* run `dub build --build=release`, optionally with `--compiler=ldc2`
|
```sh
|
||||||
|
> dub fetch --version='~master' dfmt && dub run dfmt -- -h
|
||||||
|
```
|
||||||
|
|
||||||
## Using
|
## Using
|
||||||
By default, dfmt reads its input from **stdin** and writes to **stdout**.
|
By default, dfmt reads its input from **stdin** and writes to **stdout**.
|
||||||
|
|
@ -52,15 +46,10 @@ found there.
|
||||||
* `--soft_max_line_length`: *see dfmt_soft_max_line_length [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_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_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)*
|
* `--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)*
|
* `--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)*
|
* `--tab_width`: *see tab_width [below](#standard-editorconfig-properties)*
|
||||||
* `--template_constraint_style`: *see dfmt_template_constraint_style [below](#dfmt-specific-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
|
### Example
|
||||||
```
|
```
|
||||||
|
|
@ -96,7 +85,7 @@ void main(string[] args)
|
||||||
### Standard EditorConfig properties
|
### Standard EditorConfig properties
|
||||||
Property Name | Allowed Values | Description
|
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.
|
end_of_line | `cr`, `crlf` and **`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.
|
insert_final_newline | **`true`** | Not supported. `dfmt` always inserts a final newline.
|
||||||
charset | **`UTF-8`** | Not supported. `dfmt` only works correctly on UTF-8.
|
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_style | `tab`, **`space`** | [See EditorConfig documentation.](https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#indent_style)
|
||||||
|
|
@ -107,9 +96,9 @@ max_line_length | positive integers (**`120`**) | [See EditorConfig documentatio
|
||||||
### dfmt-specific properties
|
### dfmt-specific properties
|
||||||
Property Name | Allowed Values | Description
|
Property Name | Allowed Values | Description
|
||||||
--------------|----------------|------------
|
--------------|----------------|------------
|
||||||
dfmt_brace_style | **`allman`**, `otbs`, `stroustrup` or `knr` | [See Wikipedia](https://en.wikipedia.org/wiki/Brace_style)
|
dfmt_brace_style | **`allman`**, `otbs`, or `stroustrup` | [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_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_align_switch_statements (Not yet implemented) | **`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_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_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_cast | **`true`**, `false` | Insert space after the closing paren of a `cast` expression.
|
||||||
|
|
@ -120,11 +109,6 @@ dfmt_compact_labeled_statements | **`true`**, `false` | Place labels on the same
|
||||||
dfmt_template_constraint_style | **`conditional_newline_indent`** `conditional_newline` `always_newline` `always_newline_indent` | Control the formatting of template constraints.
|
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_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_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
|
## Terminology
|
||||||
* Braces - `{` and `}`
|
* Braces - `{` and `}`
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,112 @@
|
||||||
|
platform: x64
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- DC: dmd
|
||||||
|
DVersion: stable
|
||||||
|
arch: x64
|
||||||
|
- DC: dmd
|
||||||
|
DVersion: stable
|
||||||
|
arch: x86
|
||||||
|
# - DC: ldc
|
||||||
|
# DVersion: beta
|
||||||
|
# arch: x86
|
||||||
|
# - DC: ldc
|
||||||
|
# DVersion: beta
|
||||||
|
# arch: x64
|
||||||
|
# - DC: ldc
|
||||||
|
# DVersion: stable
|
||||||
|
# arch: x86
|
||||||
|
# - DC: ldc
|
||||||
|
# DVersion: stable
|
||||||
|
# arch: x64
|
||||||
|
|
||||||
|
skip_tags: false
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- /^v\d+\.\d+\.\d+([+-]\S*)*$/
|
||||||
|
|
||||||
|
install:
|
||||||
|
- ps: function ResolveLatestDMD
|
||||||
|
{
|
||||||
|
$version = $env:DVersion;
|
||||||
|
if($version -eq "stable") {
|
||||||
|
$latest = (Invoke-WebRequest "http://downloads.dlang.org/releases/LATEST").toString();
|
||||||
|
$url = "http://downloads.dlang.org/releases/2.x/$($latest)/dmd.$($latest).windows.7z";
|
||||||
|
}elseif($version -eq "beta") {
|
||||||
|
$latest = (Invoke-WebRequest "http://downloads.dlang.org/pre-releases/LATEST").toString();
|
||||||
|
$latestVersion = $latest.split("-")[0].split("~")[0];
|
||||||
|
$url = "http://downloads.dlang.org/pre-releases/2.x/$($latestVersion)/dmd.$($latest).windows.7z";
|
||||||
|
}elseif($version -eq "nightly") {
|
||||||
|
$url = "http://nightlies.dlang.org/dmd-master-2017-05-20/dmd.master.windows.7z"
|
||||||
|
}else {
|
||||||
|
$url = "http://downloads.dlang.org/releases/2.x/$($version)/dmd.$($version).windows.7z";
|
||||||
|
}
|
||||||
|
$env:PATH += ";C:\dmd2\windows\bin;";
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
- ps: function ResolveLatestLDC
|
||||||
|
{
|
||||||
|
$version = $env:DVersion;
|
||||||
|
if($version -eq "stable") {
|
||||||
|
$latest = (Invoke-WebRequest "https://ldc-developers.github.io/LATEST").toString().replace("`n","").replace("`r","");
|
||||||
|
$url = "https://github.com/ldc-developers/ldc/releases/download/v$($latest)/ldc2-$($latest)-win64-msvc.zip";
|
||||||
|
}elseif($version -eq "beta") {
|
||||||
|
$latest = (Invoke-WebRequest "https://ldc-developers.github.io/LATEST_BETA").toString().replace("`n","").replace("`r","");
|
||||||
|
$url = "https://github.com/ldc-developers/ldc/releases/download/v$($latest)/ldc2-$($latest)-win64-msvc.zip";
|
||||||
|
} else {
|
||||||
|
$latest = $version;
|
||||||
|
$url = "https://github.com/ldc-developers/ldc/releases/download/v$($version)/ldc2-$($version)-win64-msvc.zip";
|
||||||
|
}
|
||||||
|
$env:PATH += ";C:\ldc2-$($latest)-win64-msvc\bin";
|
||||||
|
$env:DC = "ldc2";
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
- ps: function SetUpDCompiler
|
||||||
|
{
|
||||||
|
$env:toolchain = "msvc";
|
||||||
|
if($env:DC -eq "dmd"){
|
||||||
|
echo "downloading ...";
|
||||||
|
$url = ResolveLatestDMD;
|
||||||
|
echo $url;
|
||||||
|
Invoke-WebRequest $url -OutFile "c:\dmd.7z";
|
||||||
|
echo "finished.";
|
||||||
|
pushd c:\\;
|
||||||
|
7z x dmd.7z > $null;
|
||||||
|
popd;
|
||||||
|
}
|
||||||
|
elseif($env:DC -eq "ldc"){
|
||||||
|
echo "downloading ...";
|
||||||
|
$url = ResolveLatestLDC;
|
||||||
|
echo $url;
|
||||||
|
Invoke-WebRequest $url -OutFile "c:\ldc.zip";
|
||||||
|
echo "finished.";
|
||||||
|
pushd c:\\;
|
||||||
|
7z x ldc.zip > $null;
|
||||||
|
popd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- ps: SetUpDCompiler
|
||||||
|
|
||||||
|
build_script:
|
||||||
|
- ps: if($env:arch -eq "x86"){
|
||||||
|
$env:compilersetupargs = "x86";
|
||||||
|
$env:Darch = "x86";
|
||||||
|
$env:DConf = "m32";
|
||||||
|
}elseif($env:arch -eq "x64"){
|
||||||
|
$env:compilersetupargs = "amd64";
|
||||||
|
$env:Darch = "x86_64";
|
||||||
|
$env:DConf = "m64";
|
||||||
|
}
|
||||||
|
- ps: $env:compilersetup = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall";
|
||||||
|
- '"%compilersetup%" %compilersetupargs%'
|
||||||
|
|
||||||
|
test_script:
|
||||||
|
- echo %PLATFORM%
|
||||||
|
- echo %Darch%
|
||||||
|
- echo %DC%
|
||||||
|
- echo %PATH%
|
||||||
|
- '%DC% --version'
|
||||||
|
- dub test --arch=%Darch% --compiler=%DC%
|
||||||
|
- git submodule update --init --recursive
|
||||||
|
- build.bat
|
||||||
|
|
@ -24,7 +24,7 @@ _dfmt()
|
||||||
|
|
||||||
eolOpts="lf cr crlf"
|
eolOpts="lf cr crlf"
|
||||||
boolOpts="true false"
|
boolOpts="true false"
|
||||||
braceOpts="allman otbs stroustrup knr"
|
braceOpts="allman otbs stroustrup"
|
||||||
indentOpts="tab space"
|
indentOpts="tab space"
|
||||||
constraintOpts="conditional_newline_indent conditional_newline always_newline always_newline_indent"
|
constraintOpts="conditional_newline_indent conditional_newline always_newline always_newline_indent"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 206a2e6abd97b4462f3a320e4f2d23986fad3cff
|
|
||||||
6
dub.json
6
dub.json
|
|
@ -4,7 +4,7 @@
|
||||||
"targetType": "autodetect",
|
"targetType": "autodetect",
|
||||||
"license": "BSL-1.0",
|
"license": "BSL-1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"libdparse": ">=0.19.2 <1.0.0"
|
"libdparse": "~>0.11.4"
|
||||||
},
|
},
|
||||||
"targetPath" : "bin/",
|
"targetPath" : "bin/",
|
||||||
"targetName" : "dfmt",
|
"targetName" : "dfmt",
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
"versions" : [
|
"versions" : [
|
||||||
"built_with_dub"
|
"built_with_dub"
|
||||||
],
|
],
|
||||||
"preBuildCommands" : [
|
"preGenerateCommands" : [
|
||||||
"$DC -run \"$PACKAGE_DIR/dubhash.d\""
|
"rdmd \"$PACKAGE_DIR/dubhash.d\""
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit fe6d1e38fb4fc04323170389cfec67ed7fd4e24a
|
Subproject commit aae371931a99027465952cd6fdaede4eb4743e76
|
||||||
62
makefile
62
makefile
|
|
@ -1,63 +1,53 @@
|
||||||
PREFIX = /usr/local
|
|
||||||
|
|
||||||
SRC := $(shell find src -name "*.d") \
|
SRC := $(shell find src -name "*.d") \
|
||||||
$(shell find libdparse/src -name "*.d")
|
$(shell find libdparse/src -name "*.d") \
|
||||||
IMPORTS := -Ilibdparse/src -Isrc -Jbin
|
$(shell find stdx-allocator/source -name "*.d")
|
||||||
|
INCLUDE_PATHS := -Ilibdparse/src -Istdx-allocator/source -Isrc -Jbin
|
||||||
|
DMD_COMMON_FLAGS := -dip25 -w $(INCLUDE_PATHS)
|
||||||
|
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)
|
||||||
|
override DMD_FLAGS += $(DFLAGS)
|
||||||
|
override LDC_FLAGS += $(DFLAGS)
|
||||||
|
override GDC_FLAGS += $(DFLAGS)
|
||||||
DC ?= dmd
|
DC ?= dmd
|
||||||
LDC ?= ldc2
|
LDC ?= ldc2
|
||||||
GDC ?= gdc
|
GDC ?= gdc
|
||||||
|
|
||||||
DMD_COMMON_FLAGS := -w $(IMPORTS)
|
.PHONY: dmd ldc gdc test
|
||||||
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 $(IMPORTS)
|
|
||||||
GDC_FLAGS := -g -w -oq $(IMPORTS)
|
|
||||||
override DMD_FLAGS += $(DFLAGS)
|
|
||||||
override LDC_FLAGS += $(DFLAGS)
|
|
||||||
override GDC_FLAGS += $(DFLAGS)
|
|
||||||
|
|
||||||
.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
|
dmd: bin/dfmt
|
||||||
|
|
||||||
ldc: bin/githash.txt
|
githash:
|
||||||
|
mkdir -p bin
|
||||||
|
git describe --tags > bin/githash.txt
|
||||||
|
|
||||||
|
ldc: githash
|
||||||
$(LDC) $(SRC) $(LDC_FLAGS) -ofbin/dfmt
|
$(LDC) $(SRC) $(LDC_FLAGS) -ofbin/dfmt
|
||||||
-rm -f *.o
|
-rm -f *.o
|
||||||
|
|
||||||
gdc: bin/githash.txt
|
gdc:githash
|
||||||
$(GDC) $(SRC) $(GDC_FLAGS) -obin/dfmt
|
$(GDC) $(SRC) $(GDC_FLAGS) -obin/dfmt
|
||||||
|
|
||||||
test: debug
|
test: debug
|
||||||
cd tests && ./test.d
|
cd tests && ./test.sh
|
||||||
|
|
||||||
bin/dfmt-test: bin/githash.txt $(SRC)
|
bin/dfmt-test: githash $(SRC)
|
||||||
$(DC) $(DMD_TEST_FLAGS) $(filter %.d,$^) -of$@
|
$(DC) $(DMD_TEST_FLAGS) $^ -of$@
|
||||||
|
|
||||||
bin/dfmt: bin/githash.txt $(SRC)
|
bin/dfmt: githash $(SRC)
|
||||||
$(DC) $(DMD_FLAGS) $(filter %.d,$^) -of$@
|
$(DC) $(DMD_FLAGS) $(filter %.d,$^) -of$@
|
||||||
|
|
||||||
debug: bin/githash.txt $(SRC)
|
debug: githash $(SRC)
|
||||||
$(DC) $(DMD_DEBUG_FLAGS) $(filter %.d,$^) -ofbin/dfmt
|
$(DC) $(DMD_DEBUG_FLAGS) $(filter %.d,$^) -ofbin/dfmt
|
||||||
|
|
||||||
pkg: dmd
|
pkg: dmd
|
||||||
$(MAKE) -f makd/Makd.mak pkg
|
$(MAKE) -f makd/Makd.mak pkg
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) bin/dfmt bin/dfmt-test bin/githash.txt
|
$(RM) bin/dfmt
|
||||||
|
|
||||||
install:
|
|
||||||
chmod +x bin/dfmt
|
|
||||||
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
|
||||||
cp -f bin/dfmt $(DESTDIR)$(PREFIX)/bin/dfmt
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
./release.sh
|
./release.sh
|
||||||
$(MAKE) bin/githash.txt
|
githash
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,6 @@ struct BraceIndentInfo
|
||||||
uint beginIndentLevel;
|
uint beginIndentLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct StructInitializerInfo
|
|
||||||
{
|
|
||||||
size_t startLocation;
|
|
||||||
size_t endLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// AST information that is needed by the formatter.
|
/// AST information that is needed by the formatter.
|
||||||
struct ASTInformation
|
struct ASTInformation
|
||||||
{
|
{
|
||||||
|
|
@ -59,12 +53,8 @@ struct ASTInformation
|
||||||
sort(sharedStaticConstructorDestructorLocations);
|
sort(sharedStaticConstructorDestructorLocations);
|
||||||
sort!((a,b) => a.endLocation < b.endLocation)
|
sort!((a,b) => a.endLocation < b.endLocation)
|
||||||
(indentInfoSortedByEndLocation);
|
(indentInfoSortedByEndLocation);
|
||||||
sort!((a,b) => a.endLocation < b.endLocation)
|
|
||||||
(structInfoSortedByEndLocation);
|
|
||||||
sort(ufcsHintLocations);
|
sort(ufcsHintLocations);
|
||||||
ufcsHintLocations = ufcsHintLocations.uniq().array();
|
ufcsHintLocations = ufcsHintLocations.uniq().array();
|
||||||
sort(ternaryColonLocations);
|
|
||||||
sort(namedArgumentColonLocations);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Locations of end braces for struct bodies
|
/// Locations of end braces for struct bodies
|
||||||
|
|
@ -97,12 +87,6 @@ struct ASTInformation
|
||||||
/// Closing braces of function literals
|
/// Closing braces of function literals
|
||||||
size_t[] funLitEndLocations;
|
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
|
/// Conditional statements that have matching "else" statements
|
||||||
size_t[] conditionalWithElseLocations;
|
size_t[] conditionalWithElseLocations;
|
||||||
|
|
||||||
|
|
@ -134,15 +118,6 @@ struct ASTInformation
|
||||||
size_t[] ufcsHintLocations;
|
size_t[] ufcsHintLocations;
|
||||||
|
|
||||||
BraceIndentInfo[] indentInfoSortedByEndLocation;
|
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
|
/// Collects information from the AST that is useful for the formatter
|
||||||
|
|
@ -214,18 +189,6 @@ final class FormatVisitor : ASTVisitor
|
||||||
destructor.accept(this);
|
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)
|
override void visit(const ConditionalDeclaration dec)
|
||||||
{
|
{
|
||||||
if (dec.hasElse)
|
if (dec.hasElse)
|
||||||
|
|
@ -309,8 +272,6 @@ final class FormatVisitor : ASTVisitor
|
||||||
{
|
{
|
||||||
astInformation.structInitStartLocations ~= structInitializer.startLocation;
|
astInformation.structInitStartLocations ~= structInitializer.startLocation;
|
||||||
astInformation.structInitEndLocations ~= structInitializer.endLocation;
|
astInformation.structInitEndLocations ~= structInitializer.endLocation;
|
||||||
astInformation.structInfoSortedByEndLocation ~=
|
|
||||||
StructInitializerInfo(structInitializer.startLocation, structInitializer.endLocation);
|
|
||||||
astInformation.indentInfoSortedByEndLocation ~=
|
astInformation.indentInfoSortedByEndLocation ~=
|
||||||
BraceIndentInfo(structInitializer.startLocation, structInitializer.endLocation);
|
BraceIndentInfo(structInitializer.startLocation, structInitializer.endLocation);
|
||||||
|
|
||||||
|
|
@ -339,7 +300,6 @@ final class FormatVisitor : ASTVisitor
|
||||||
|
|
||||||
override void visit(const StructBody structBody)
|
override void visit(const StructBody structBody)
|
||||||
{
|
{
|
||||||
astInformation.aggregateBodyLocations ~= structBody.startLocation;
|
|
||||||
astInformation.doubleNewlineLocations ~= structBody.endLocation;
|
astInformation.doubleNewlineLocations ~= structBody.endLocation;
|
||||||
structBody.accept(this);
|
structBody.accept(this);
|
||||||
}
|
}
|
||||||
|
|
@ -446,58 +406,6 @@ final class FormatVisitor : ASTVisitor
|
||||||
outStatement.accept(this);
|
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:
|
private:
|
||||||
ASTInformation* astInformation;
|
ASTInformation* astInformation;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,20 +10,18 @@ import dfmt.editorconfig;
|
||||||
/// Brace styles
|
/// Brace styles
|
||||||
enum BraceStyle
|
enum BraceStyle
|
||||||
{
|
{
|
||||||
_unspecified,
|
unspecified,
|
||||||
/// $(LINK https://en.wikipedia.org/wiki/Indent_style#Allman_style)
|
/// $(LINK https://en.wikipedia.org/wiki/Indent_style#Allman_style)
|
||||||
allman,
|
allman,
|
||||||
/// $(LINK https://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS)
|
/// $(LINK https://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS)
|
||||||
otbs,
|
otbs,
|
||||||
/// $(LINK https://en.wikipedia.org/wiki/Indent_style#Variant:_Stroustrup)
|
/// $(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
|
enum TemplateConstraintStyle
|
||||||
{
|
{
|
||||||
_unspecified,
|
unspecified,
|
||||||
conditional_newline_indent,
|
conditional_newline_indent,
|
||||||
conditional_newline,
|
conditional_newline,
|
||||||
always_newline,
|
always_newline,
|
||||||
|
|
@ -59,16 +57,6 @@ struct Config
|
||||||
OptionalBoolean dfmt_single_template_constraint_indent;
|
OptionalBoolean dfmt_single_template_constraint_indent;
|
||||||
///
|
///
|
||||||
OptionalBoolean dfmt_space_before_aa_colon;
|
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;
|
mixin StandardEditorConfigFields;
|
||||||
|
|
||||||
|
|
@ -79,7 +67,7 @@ struct Config
|
||||||
void initializeWithDefaults()
|
void initializeWithDefaults()
|
||||||
{
|
{
|
||||||
pattern = "*.d";
|
pattern = "*.d";
|
||||||
end_of_line = EOL._default;
|
end_of_line = EOL.lf;
|
||||||
indent_style = IndentStyle.space;
|
indent_style = IndentStyle.space;
|
||||||
indent_size = 4;
|
indent_size = 4;
|
||||||
tab_width = 4;
|
tab_width = 4;
|
||||||
|
|
@ -97,10 +85,6 @@ struct Config
|
||||||
dfmt_template_constraint_style = TemplateConstraintStyle.conditional_newline_indent;
|
dfmt_template_constraint_style = TemplateConstraintStyle.conditional_newline_indent;
|
||||||
dfmt_single_template_constraint_indent = OptionalBoolean.f;
|
dfmt_single_template_constraint_indent = OptionalBoolean.f;
|
||||||
dfmt_space_before_aa_colon = 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -26,22 +26,21 @@ private auto commentRe = ctRegex!(`^\s*[#;].*$`);
|
||||||
|
|
||||||
enum OptionalBoolean : ubyte
|
enum OptionalBoolean : ubyte
|
||||||
{
|
{
|
||||||
_unspecified = 3,
|
unspecified = 3,
|
||||||
t = 1,
|
t = 1,
|
||||||
f = 0
|
f = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
enum IndentStyle : ubyte
|
enum IndentStyle : ubyte
|
||||||
{
|
{
|
||||||
_unspecified,
|
unspecified,
|
||||||
tab,
|
tab,
|
||||||
space
|
space
|
||||||
}
|
}
|
||||||
|
|
||||||
enum EOL : ubyte
|
enum EOL : ubyte
|
||||||
{
|
{
|
||||||
_unspecified,
|
unspecified,
|
||||||
_default,
|
|
||||||
lf,
|
lf,
|
||||||
cr,
|
cr,
|
||||||
crlf
|
crlf
|
||||||
|
|
@ -75,7 +74,7 @@ mixin template StandardEditorConfigFields()
|
||||||
static if (N == "pattern")
|
static if (N == "pattern")
|
||||||
continue;
|
continue;
|
||||||
else static if (is(T == enum))
|
else static if (is(T == enum))
|
||||||
*thisN = otherN != T._unspecified ? otherN : *thisN;
|
*thisN = otherN != T.unspecified ? otherN : *thisN;
|
||||||
else static if (is(T == int))
|
else static if (is(T == int))
|
||||||
*thisN = otherN != -1 ? otherN : *thisN;
|
*thisN = otherN != -1 ? otherN : *thisN;
|
||||||
else static if (is(T == string))
|
else static if (is(T == string))
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -12,7 +12,7 @@ import std.path : filenameCharCmp, isDirSeparator;
|
||||||
// * changes meaning to match all characters except '/'
|
// * changes meaning to match all characters except '/'
|
||||||
// ** added to take over the old meaning of *
|
// ** added to take over the old meaning of *
|
||||||
bool globMatchEditorConfig(CaseSensitive cs = CaseSensitive.osDefault, C, Range)(
|
bool globMatchEditorConfig(CaseSensitive cs = CaseSensitive.osDefault, C, Range)(
|
||||||
Range path, const(C)[] pattern) @safe pure
|
Range path, const(C)[] pattern) @safe pure nothrow
|
||||||
if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range)
|
if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range)
|
||||||
&& isSomeChar!C && is(Unqual!C == Unqual!(ElementEncodingType!Range)))
|
&& isSomeChar!C && is(Unqual!C == Unqual!(ElementEncodingType!Range)))
|
||||||
in
|
in
|
||||||
|
|
@ -23,7 +23,7 @@ in
|
||||||
assert(balancedParens(pattern, '[', ']', 0));
|
assert(balancedParens(pattern, '[', ']', 0));
|
||||||
assert(balancedParens(pattern, '{', '}', 0));
|
assert(balancedParens(pattern, '{', '}', 0));
|
||||||
}
|
}
|
||||||
do
|
body
|
||||||
{
|
{
|
||||||
alias RC = Unqual!(ElementEncodingType!Range);
|
alias RC = Unqual!(ElementEncodingType!Range);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@
|
||||||
|
|
||||||
module dfmt.indentation;
|
module dfmt.indentation;
|
||||||
|
|
||||||
import dfmt.config;
|
|
||||||
import dfmt.editorconfig;
|
|
||||||
import dparse.lexer;
|
import dparse.lexer;
|
||||||
|
|
||||||
import std.bitmanip : bitfields;
|
import std.bitmanip : bitfields;
|
||||||
|
|
@ -33,14 +31,6 @@ bool isTempIndent(IdType type) pure nothrow @nogc @safe
|
||||||
*/
|
*/
|
||||||
struct IndentStack
|
struct IndentStack
|
||||||
{
|
{
|
||||||
/// Configuration
|
|
||||||
private const Config* config;
|
|
||||||
|
|
||||||
this(const Config* config)
|
|
||||||
{
|
|
||||||
this.config = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct Details
|
static struct Details
|
||||||
{
|
{
|
||||||
mixin(bitfields!(
|
mixin(bitfields!(
|
||||||
|
|
@ -231,7 +221,7 @@ struct IndentStack
|
||||||
/**
|
/**
|
||||||
* Dumps the current state of the indentation stack to `stderr`. Used for debugging.
|
* 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
|
void dump(size_t pos = size_t.max, string file = __FILE__, uint line = __LINE__)
|
||||||
{
|
{
|
||||||
import dparse.lexer : str;
|
import dparse.lexer : str;
|
||||||
import std.algorithm.iteration : map;
|
import std.algorithm.iteration : map;
|
||||||
|
|
@ -270,20 +260,8 @@ private:
|
||||||
|
|
||||||
if (i + 1 < index)
|
if (i + 1 < index)
|
||||||
{
|
{
|
||||||
if (config.dfmt_single_indent == OptionalBoolean.t && skipDoubleIndent(i, parenCount))
|
|
||||||
{
|
|
||||||
parenCount = pc;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
immutable currentIsNonWrapTemp = !details[i].wrap
|
immutable currentIsNonWrapTemp = !details[i].wrap
|
||||||
&& details[i].temp && arr[i] != tok!")" && arr[i] != tok!"!";
|
&& details[i].temp && arr[i] != tok!")" && arr[i] != tok!"!";
|
||||||
|
|
||||||
if (currentIsNonWrapTemp && arr[i + 1] == tok!"]")
|
|
||||||
{
|
|
||||||
parenCount = pc;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (arr[i] == tok!"static"
|
if (arr[i] == tok!"static"
|
||||||
&& arr[i + 1].among!(tok!"if", tok!"else", tok!"foreach", tok!"foreach_reverse")
|
&& arr[i + 1].among!(tok!"if", tok!"else", tok!"foreach", tok!"foreach_reverse")
|
||||||
&& (i + 2 >= index || arr[i + 2] != tok!"{"))
|
&& (i + 2 >= index || arr[i + 2] != tok!"{"))
|
||||||
|
|
@ -298,7 +276,7 @@ private:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (parenCount == 0 && arr[i] == tok!"(" && config.dfmt_single_indent == OptionalBoolean.f)
|
else if (parenCount == 0 && arr[i] == tok!"(")
|
||||||
size++;
|
size++;
|
||||||
|
|
||||||
if (arr[i] == tok!"!")
|
if (arr[i] == tok!"!")
|
||||||
|
|
@ -309,12 +287,6 @@ private:
|
||||||
}
|
}
|
||||||
return 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
|
unittest
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,14 @@ static immutable VERSION = () {
|
||||||
|
|
||||||
version (built_with_dub)
|
version (built_with_dub)
|
||||||
{
|
{
|
||||||
enum DFMT_VERSION = import("dubhash.txt").strip;
|
enum DFMT_VERSION = import("dubhash.txt").strip;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Current build's Git commit hash
|
* Current build's Git commit hash
|
||||||
*/
|
*/
|
||||||
enum DFMT_VERSION = import("githash.txt").strip;
|
enum DFMT_VERSION = import("githash.txt").strip;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DFMT_VERSION ~ DEBUG_SUFFIX;
|
return DFMT_VERSION ~ DEBUG_SUFFIX;
|
||||||
|
|
@ -38,13 +38,13 @@ version (NoMain)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
import std.array : front, popFront;
|
||||||
|
import std.stdio : stdout, stdin, stderr, writeln, File;
|
||||||
import dfmt.config : Config;
|
import dfmt.config : Config;
|
||||||
import dfmt.editorconfig : getConfigFor;
|
|
||||||
import dfmt.formatter : format;
|
import dfmt.formatter : format;
|
||||||
import std.array : appender, front, popFront;
|
|
||||||
import std.getopt : getopt, GetOptException;
|
|
||||||
import std.path : buildPath, dirName, expandTilde;
|
import std.path : buildPath, dirName, expandTilde;
|
||||||
import std.stdio : File, stderr, stdin, stdout, writeln;
|
import dfmt.editorconfig : getConfigFor;
|
||||||
|
import std.getopt : getopt, GetOptException;
|
||||||
|
|
||||||
int main(string[] args)
|
int main(string[] args)
|
||||||
{
|
{
|
||||||
|
|
@ -92,21 +92,6 @@ else
|
||||||
case "space_before_aa_colon":
|
case "space_before_aa_colon":
|
||||||
optConfig.dfmt_space_before_aa_colon = optVal;
|
optConfig.dfmt_space_before_aa_colon = optVal;
|
||||||
break;
|
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:
|
default:
|
||||||
assert(false, "Invalid command-line switch");
|
assert(false, "Invalid command-line switch");
|
||||||
}
|
}
|
||||||
|
|
@ -129,19 +114,14 @@ else
|
||||||
"soft_max_line_length", &optConfig.dfmt_soft_max_line_length,
|
"soft_max_line_length", &optConfig.dfmt_soft_max_line_length,
|
||||||
"outdent_attributes", &handleBooleans,
|
"outdent_attributes", &handleBooleans,
|
||||||
"space_after_cast", &handleBooleans,
|
"space_after_cast", &handleBooleans,
|
||||||
"space_after_keywords", &handleBooleans,
|
|
||||||
"selective_import_space", &handleBooleans,
|
"selective_import_space", &handleBooleans,
|
||||||
"space_before_function_parameters", &handleBooleans,
|
"space_before_function_parameters", &handleBooleans,
|
||||||
"split_operator_at_line_end", &handleBooleans,
|
"split_operator_at_line_end", &handleBooleans,
|
||||||
"compact_labeled_statements", &handleBooleans,
|
"compact_labeled_statements", &handleBooleans,
|
||||||
"single_template_constraint_indent", &handleBooleans,
|
"single_template_constraint_indent", &handleBooleans,
|
||||||
"space_before_aa_colon", &handleBooleans,
|
"space_before_aa_colon", &handleBooleans,
|
||||||
"space_before_named_arg_colon", &handleBooleans,
|
|
||||||
"tab_width", &optConfig.tab_width,
|
"tab_width", &optConfig.tab_width,
|
||||||
"template_constraint_style", &optConfig.dfmt_template_constraint_style,
|
"template_constraint_style", &optConfig.dfmt_template_constraint_style);
|
||||||
"keep_line_breaks", &handleBooleans,
|
|
||||||
"single_indent", &handleBooleans,
|
|
||||||
"reflow_property_chains", &handleBooleans);
|
|
||||||
// dfmt on
|
// dfmt on
|
||||||
}
|
}
|
||||||
catch (GetOptException e)
|
catch (GetOptException e)
|
||||||
|
|
@ -165,13 +145,14 @@ else
|
||||||
args.popFront();
|
args.popFront();
|
||||||
immutable bool readFromStdin = args.length == 0;
|
immutable bool readFromStdin = args.length == 0;
|
||||||
|
|
||||||
|
File output = stdout;
|
||||||
version (Windows)
|
version (Windows)
|
||||||
{
|
{
|
||||||
// On Windows, set stdout to binary mode (needed for correct EOL writing)
|
// On Windows, set stdout to binary mode (needed for correct EOL writing)
|
||||||
// See Phobos' stdio.File.rawWrite
|
// See Phobos' stdio.File.rawWrite
|
||||||
{
|
{
|
||||||
import std.stdio : _O_BINARY;
|
import std.stdio : _O_BINARY;
|
||||||
immutable fd = stdout.fileno;
|
immutable fd = output.fileno;
|
||||||
_setmode(fd, _O_BINARY);
|
_setmode(fd, _O_BINARY);
|
||||||
version (CRuntime_DigitalMars)
|
version (CRuntime_DigitalMars)
|
||||||
{
|
{
|
||||||
|
|
@ -192,7 +173,7 @@ else
|
||||||
|
|
||||||
if (!exists(explicitConfigDir) || !isDir(explicitConfigDir))
|
if (!exists(explicitConfigDir) || !isDir(explicitConfigDir))
|
||||||
{
|
{
|
||||||
stderr.writeln("--config|c must specify existing directory path");
|
stderr.writeln("--config_dir|c must specify existing directory path");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
explicitConfig = getConfigFor!Config(explicitConfigDir);
|
explicitConfig = getConfigFor!Config(explicitConfigDir);
|
||||||
|
|
@ -230,9 +211,7 @@ else
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
immutable bool formatSuccess = format("stdin", buffer,
|
format("stdin", buffer, output.lockingTextWriter(), &config);
|
||||||
stdout.lockingTextWriter(), &config);
|
|
||||||
return formatSuccess ? 0 : 1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -240,7 +219,6 @@ else
|
||||||
|
|
||||||
if (args.length >= 2)
|
if (args.length >= 2)
|
||||||
inplace = true;
|
inplace = true;
|
||||||
int retVal;
|
|
||||||
while (args.length > 0)
|
while (args.length > 0)
|
||||||
{
|
{
|
||||||
const path = args.front;
|
const path = args.front;
|
||||||
|
|
@ -273,21 +251,13 @@ else
|
||||||
{
|
{
|
||||||
buffer = new ubyte[](cast(size_t) f.size);
|
buffer = new ubyte[](cast(size_t) f.size);
|
||||||
f.rawRead(buffer);
|
f.rawRead(buffer);
|
||||||
auto output = appender!string;
|
if (inplace)
|
||||||
immutable bool formatSuccess = format(path, buffer, output, &config);
|
output = File(path, "wb");
|
||||||
if (formatSuccess)
|
format(path, buffer, output.lockingTextWriter(), &config);
|
||||||
{
|
|
||||||
if (inplace)
|
|
||||||
File(path, "wb").rawWrite(output.data);
|
|
||||||
else
|
|
||||||
stdout.rawWrite(output.data);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
retVal = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retVal;
|
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -306,14 +276,12 @@ private version (Windows)
|
||||||
|
|
||||||
template optionsToString(E) if (is(E == enum))
|
template optionsToString(E) if (is(E == enum))
|
||||||
{
|
{
|
||||||
import std.algorithm.searching : startsWith;
|
|
||||||
|
|
||||||
enum optionsToString = () {
|
enum optionsToString = () {
|
||||||
|
|
||||||
string result = "(";
|
string result = "(";
|
||||||
foreach (s; [__traits(allMembers, E)])
|
foreach (s; [__traits(allMembers, E)])
|
||||||
{
|
{
|
||||||
if (!s.startsWith("_"))
|
if (s != "unspecified")
|
||||||
result ~= s ~ "|";
|
result ~= s ~ "|";
|
||||||
}
|
}
|
||||||
result = result[0 .. $ - 1] ~ ")";
|
result = result[0 .. $ - 1] ~ ")";
|
||||||
|
|
@ -329,7 +297,7 @@ https://github.com/dlang-community/dfmt
|
||||||
Options:
|
Options:
|
||||||
--help, -h Print this help message
|
--help, -h Print this help message
|
||||||
--inplace, -i Edit files in place
|
--inplace, -i Edit files in place
|
||||||
--config, -c Path to directory to load .editorconfig file from.
|
--config_dir, -c Path to directory to load .editorconfig file from.
|
||||||
--version Print the version number and then exit
|
--version Print the version number and then exit
|
||||||
|
|
||||||
Formatting Options:
|
Formatting Options:
|
||||||
|
|
@ -340,22 +308,17 @@ Formatting Options:
|
||||||
--indent_size
|
--indent_size
|
||||||
--indent_style, -t `,
|
--indent_style, -t `,
|
||||||
optionsToString!(typeof(Config.indent_style)), `
|
optionsToString!(typeof(Config.indent_style)), `
|
||||||
--keep_line_breaks
|
|
||||||
--soft_max_line_length
|
--soft_max_line_length
|
||||||
--max_line_length
|
--max_line_length
|
||||||
--outdent_attributes
|
--outdent_attributes
|
||||||
--space_after_cast
|
--space_after_cast
|
||||||
--space_before_function_parameters
|
--space_before_function_parameters
|
||||||
--space_after_keywords
|
|
||||||
--selective_import_space
|
--selective_import_space
|
||||||
--single_template_constraint_indent
|
--single_template_constraint_indent
|
||||||
--split_operator_at_line_end
|
--split_operator_at_line_end
|
||||||
--compact_labeled_statements
|
--compact_labeled_statements
|
||||||
--template_constraint_style
|
--template_constraint_style
|
||||||
--space_before_aa_colon
|
--space_before_aa_colon
|
||||||
--space_before_named_arg_colon
|
|
||||||
--single_indent
|
|
||||||
--reflow_property_chains
|
|
||||||
`,
|
`,
|
||||||
optionsToString!(typeof(Config.dfmt_template_constraint_style)));
|
optionsToString!(typeof(Config.dfmt_template_constraint_style)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ in
|
||||||
{
|
{
|
||||||
assert(tokens[0].type == tok!"(");
|
assert(tokens[0].type == tok!"(");
|
||||||
}
|
}
|
||||||
do
|
body
|
||||||
{
|
{
|
||||||
uint length = 0;
|
uint length = 0;
|
||||||
size_t i = 1;
|
size_t i = 1;
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,9 @@ size_t[] chooseLineBreakTokens(size_t index, const Token[] tokens,
|
||||||
void validMoves(OR)(auto ref OR output, const Token[] tokens, immutable short[] depths,
|
void validMoves(OR)(auto ref OR output, const Token[] tokens, immutable short[] depths,
|
||||||
uint current, const Config* config, int currentLineLength, int indentLevel)
|
uint current, const Config* config, int currentLineLength, int indentLevel)
|
||||||
{
|
{
|
||||||
|
import std.algorithm : sort, canFind, min;
|
||||||
|
import std.array : insertInPlace;
|
||||||
|
|
||||||
foreach (i, token; tokens)
|
foreach (i, token; tokens)
|
||||||
{
|
{
|
||||||
if (!isBreakToken(token.type) || (((1 << i) & current) != 0))
|
if (!isBreakToken(token.type) || (((1 << i) & current) != 0))
|
||||||
|
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
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__);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
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__);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
foo([
|
foo([
|
||||||
target.value.region[1], target.value.region[1], target.value.region[1],
|
target.value.region[1], target.value.region[1],
|
||||||
target.value.region[1], target.value.region[1]
|
target.value.region[1], target.value.region[1], target.value.region[1]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
void main()
|
|
||||||
{
|
|
||||||
string key;
|
|
||||||
|
|
||||||
int[string] var = [
|
|
||||||
key: 5
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +1,24 @@
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
Bson base = Bson([
|
Bson base = Bson([
|
||||||
"maps": Bson([
|
"maps": Bson([
|
||||||
Bson(["id": Bson(4), "comment": Bson("hello")]),
|
Bson(["id": Bson(4), "comment": Bson("hello")]),
|
||||||
Bson(["id": Bson(49), "comment": Bson(null)])
|
Bson(["id": Bson(49), "comment": Bson(null)])
|
||||||
]),
|
]),
|
||||||
"short": Bson(["a": "b", "c": "d"]),
|
"short": Bson(["a": "b", "c": "d"]),
|
||||||
"numbers": Bson([
|
"numbers": Bson([
|
||||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2,
|
1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||||
3, 4, 5, 6, 7, 8, 9, 0
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0
|
||||||
]),
|
]),
|
||||||
"shuffleOnReset": serializeToBson([
|
"shuffleOnReset": serializeToBson([
|
||||||
"all": false,
|
"all": false,
|
||||||
"selected": true,
|
"selected": true,
|
||||||
"maybe": false
|
"maybe": false
|
||||||
]),
|
]),
|
||||||
"resetOnEmpty": Bson(false),
|
"resetOnEmpty": Bson(false),
|
||||||
"applyMods": Bson(true),
|
"applyMods": Bson(true),
|
||||||
"sendComments": Bson(true)
|
"sendComments": Bson(true)
|
||||||
]);
|
]);
|
||||||
int[] x = [
|
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,
|
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
|
4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,25 @@
|
||||||
auto find()
|
auto find()
|
||||||
{
|
{
|
||||||
return Map.findRange([
|
return Map.findRange([
|
||||||
"$and": [
|
"$and": [
|
||||||
["deleted": Bson(false)],
|
["deleted": Bson(false)],
|
||||||
[
|
[
|
||||||
"$or": Bson([
|
"$or": Bson([
|
||||||
serializeToBson(["forceUpdate": Bson(true)]),
|
serializeToBson(["forceUpdate": Bson(true)]),
|
||||||
serializeToBson([
|
serializeToBson([
|
||||||
"info.approved": ["$eq": Bson(1)],
|
"info.approved": ["$eq": Bson(1)],
|
||||||
"fetchDate": [
|
"fetchDate": [
|
||||||
"$lte": Bson(BsonDate(currentTime - 60.days))
|
"$lte": Bson(BsonDate(currentTime - 60.days))
|
||||||
]
|
]
|
||||||
]),
|
]),
|
||||||
serializeToBson([
|
serializeToBson([
|
||||||
"info.approved": ["$ne": Bson(1)],
|
"info.approved": ["$ne": Bson(1)],
|
||||||
"fetchDate": [
|
"fetchDate": [
|
||||||
"$lte": Bson(BsonDate(currentTime - 14.days))
|
"$lte": Bson(BsonDate(currentTime - 14.days))
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
]
|
||||||
]
|
]
|
||||||
]
|
]);
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@ int /*sneaky*/ foo( /*comments*/ ) /*everywhere*/
|
||||||
{
|
{
|
||||||
// comment on its own line
|
// comment on its own line
|
||||||
foo() // comment on same line
|
foo() // comment on same line
|
||||||
.bar(); // also on same line
|
.bar(); // also on same line
|
||||||
/* again */ // same line
|
/* again */ // same line
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ do
|
||||||
}
|
}
|
||||||
|
|
||||||
int bar(int arg)
|
int bar(int arg)
|
||||||
in (arg > 0)
|
in(arg > 0)
|
||||||
out (; true)
|
out(; true)
|
||||||
out /*Major*/ ( /*Tom*/ result /*To ground control*/ ; result == 0)
|
out /*Major*/ ( /*Tom*/ result /*To ground control*/ ; result == 0)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
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,
|
|
||||||
])))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
alias u8 = ubyte
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
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";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
void main()
|
|
||||||
{
|
|
||||||
auto myTid = runTask({
|
|
||||||
auto conn = connectTCP("localhost", 4222);
|
|
||||||
|
|
||||||
auto l = Lexer(conn);
|
|
||||||
foreach (t; l)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
conn.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
// foo
|
|
||||||
runEventLoop();
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
/* 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
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
void main()
|
|
||||||
{
|
|
||||||
S s1 = {a: 3};
|
|
||||||
S s2 = {a: 3, b: "test string"};
|
|
||||||
S s3 = {a: 3, b: "test string", c: {x: 3.14, y: 3 + 4}};
|
|
||||||
T t = {
|
|
||||||
someStructMember1: 2, someStructMember2: 42, someStructMember3: null, // foobar
|
|
||||||
someOtherMember1: objA, someOtherMember2: objB, someOtherMember3: 0,
|
|
||||||
somethingMore: null, someFlagInThisStruct: -1
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
void foo() /**/
|
|
||||||
in
|
|
||||||
{
|
|
||||||
}
|
|
||||||
body
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void bar() /**/
|
|
||||||
out
|
|
||||||
{
|
|
||||||
}
|
|
||||||
body
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
import std.stdio;
|
|
||||||
|
|
||||||
@safe extern (C) void main()
|
|
||||||
{
|
|
||||||
writeln("Hello World!");
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
void f(bool body)
|
|
||||||
{
|
|
||||||
if (body)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
struct S1
|
|
||||||
{
|
|
||||||
ulong x;
|
|
||||||
ulong y;
|
|
||||||
ulong function(ulong) f;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct S2
|
|
||||||
{
|
|
||||||
ulong x;
|
|
||||||
ulong y;
|
|
||||||
ulong z;
|
|
||||||
ulong w;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Example 1
|
|
||||||
// Anonymous function in struct, long struct initializer
|
|
||||||
|
|
||||||
immutable S1 s1 = {
|
|
||||||
1111111111111111111, 1111111111111111111, (x) { return x + 1111; },
|
|
||||||
};
|
|
||||||
|
|
||||||
void f1()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Example 2
|
|
||||||
// Anonymous function anywhere, long struct initializer
|
|
||||||
|
|
||||||
int function(int) f2 = (x) { return x + 1111; };
|
|
||||||
|
|
||||||
immutable S2 s = {
|
|
||||||
1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111,
|
|
||||||
};
|
|
||||||
|
|
||||||
void f2()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
int abs(int x)
|
|
||||||
{
|
|
||||||
if (x < 0) // x negative, must negate
|
|
||||||
return -x;
|
|
||||||
else // x already non-negative, just return it
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
struct S
|
|
||||||
{
|
|
||||||
invariant (true);
|
|
||||||
}
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
class C
|
|
||||||
{
|
|
||||||
abstract void f1() //
|
|
||||||
in (true);
|
|
||||||
|
|
||||||
abstract void f2() /* */
|
|
||||||
in (true);
|
|
||||||
|
|
||||||
abstract bool f3() //
|
|
||||||
out (r; r);
|
|
||||||
|
|
||||||
abstract bool f4() /* */
|
|
||||||
out (r; r);
|
|
||||||
|
|
||||||
abstract void f5() //
|
|
||||||
do
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract void f6() /* */
|
|
||||||
do
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract bool f7() //
|
|
||||||
in (true) //
|
|
||||||
out (r; r) //
|
|
||||||
do //
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract bool f8() /* */
|
|
||||||
in (true) /* */
|
|
||||||
out (r; r) /* */
|
|
||||||
do /* */
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
@nogc //
|
|
||||||
void foo();
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
void main()
|
|
||||||
{
|
|
||||||
format!"%s" //
|
|
||||||
("");
|
|
||||||
format!("%s") //
|
|
||||||
("");
|
|
||||||
format!("%s") //
|
|
||||||
("", argument1, argument2, argument3, argument4, argument5,
|
|
||||||
argument6, argument7, argument8, argument9, argument10);
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
bool asdf(const string owner, const string mail) @safe
|
|
||||||
{
|
|
||||||
requestHTTP(url, (scope HTTPClientRequest request) {
|
|
||||||
request.writeFormBody([owner: owner, mail: mail]);
|
|
||||||
}, (scope HTTPClientResponse response) {});
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
string BuildForwardCall()
|
|
||||||
{
|
|
||||||
return `static if (is(typeof(mocked___.` ~ methodString ~ argsPassed ~ `)))
|
|
||||||
{
|
|
||||||
return (mocked___.` ~ methodString ~ argsPassed ~ `);
|
|
||||||
}`;
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
module tests.issue0483;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
switch (0)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
label:
|
|
||||||
case 3:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
void main()
|
|
||||||
{
|
|
||||||
int a;
|
|
||||||
int[int] hashmap = [a : a, a : a, a : a];
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
void main()
|
|
||||||
{
|
|
||||||
auto someAutoVariableName = this.firstLink.secondLink
|
|
||||||
.filter!(shouldBeProbablySomeIdentifierOrNot);
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
void main()
|
|
||||||
{
|
|
||||||
const a1 = [
|
|
||||||
builder.rebuild!((x, y, z) => x + y + z)
|
|
||||||
.rebuild!(x => x)
|
|
||||||
.rebuild!(x => x),
|
|
||||||
];
|
|
||||||
|
|
||||||
const a2 = [
|
|
||||||
builder.rebuild!(x => x)
|
|
||||||
.rebuild!(x => x)
|
|
||||||
.rebuild!(x => x),
|
|
||||||
builder.rebuild!(x => x)
|
|
||||||
.rebuild!(x => x)
|
|
||||||
.rebuild!(x => x),
|
|
||||||
];
|
|
||||||
|
|
||||||
foo([
|
|
||||||
line1,
|
|
||||||
value_line2_bla_bla_bla.propertyCallBlaBlaBla(a, b, c)
|
|
||||||
.propertyCallBlaBlaBla(a, b, c, d).propertyCallBlaBlaBla(a, b, c)
|
|
||||||
.propertyCallBlaBlaBla(a, b, c).value,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void foo()
|
|
||||||
{
|
|
||||||
afdsafds.asdf.flub;
|
|
||||||
}
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
private void selectMember(Args...)(Args args)
|
|
||||||
{
|
|
||||||
static if (true)
|
|
||||||
{
|
|
||||||
static if (args[0])
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (true)
|
|
||||||
{
|
|
||||||
if (args[0])
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void selectMember(Args...)(Args args)
|
|
||||||
{
|
|
||||||
static if (true)
|
|
||||||
{
|
|
||||||
static if ([
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
3,
|
|
||||||
4,
|
|
||||||
])
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (true)
|
|
||||||
{
|
|
||||||
if (args[
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
3,
|
|
||||||
4,
|
|
||||||
])
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void f()
|
|
||||||
{
|
|
||||||
foreach (x; y)
|
|
||||||
if (foo)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
if (a)
|
|
||||||
if (b)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
void main()
|
|
||||||
{
|
|
||||||
const a1 = [
|
|
||||||
builder
|
|
||||||
.rebuild!((x, y, z) => x + y + z)
|
|
||||||
.rebuild!(x => x)
|
|
||||||
.rebuild!(x => x),
|
|
||||||
];
|
|
||||||
|
|
||||||
const a2 = [
|
|
||||||
builder
|
|
||||||
.rebuild!(x => x)
|
|
||||||
.rebuild!(x => x)
|
|
||||||
.rebuild!(x => x),
|
|
||||||
builder
|
|
||||||
.rebuild!(x => x)
|
|
||||||
.rebuild!(x => x)
|
|
||||||
.rebuild!(x => x),
|
|
||||||
];
|
|
||||||
|
|
||||||
foo([
|
|
||||||
line1,
|
|
||||||
value_line2_bla_bla_bla.propertyCallBlaBlaBla(a, b, c)
|
|
||||||
.propertyCallBlaBlaBla(a, b, c, d).propertyCallBlaBlaBla(a, b, c)
|
|
||||||
.propertyCallBlaBlaBla(a, b, c).value,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void foo()
|
|
||||||
{
|
|
||||||
afdsafds
|
|
||||||
.asdf
|
|
||||||
.flub;
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
alias f1 = S function();
|
|
||||||
alias f2 = S!"foo" function();
|
|
||||||
alias f3 = S!5 function();
|
|
||||||
alias f4 = S!S function();
|
|
||||||
alias f5 = S!(S) function();
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
void main()
|
|
||||||
{
|
|
||||||
auto aa = ["aaa": 1, "bbb": 2];
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
string f()
|
|
||||||
{
|
|
||||||
return duration.total!"seconds".to!string;
|
|
||||||
}
|
|
||||||
|
|
||||||
string g()
|
|
||||||
{
|
|
||||||
return duration.total!"seconds"().to!string;
|
|
||||||
}
|
|
||||||
|
|
||||||
string h()
|
|
||||||
{
|
|
||||||
return duration.total!"seconds"().to!string.to!string.to!string.to!string.to!string.to!string
|
|
||||||
.to!string.to!string.to!string;
|
|
||||||
}
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
deprecated("foo")
|
|
||||||
void test()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
package(foo)
|
|
||||||
void bar()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@uda()
|
|
||||||
void baz()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
deprecated
|
|
||||||
deprecated_()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@uda
|
|
||||||
void uda_()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@property
|
|
||||||
void property()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
deprecated("Reason") @uda
|
|
||||||
void propertyuda()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
deprecated("Reason")
|
|
||||||
@uda
|
|
||||||
void udaproperty()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
struct S
|
|
||||||
{
|
|
||||||
@safe invariant
|
|
||||||
{
|
|
||||||
assert(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
void main()
|
|
||||||
{
|
|
||||||
string a = "foo"
|
|
||||||
~ "bar" // bar
|
|
||||||
~ "baz";
|
|
||||||
}
|
|
||||||
|
|
||||||
void foo()
|
|
||||||
{
|
|
||||||
afdsafds
|
|
||||||
.asdf // blah
|
|
||||||
.flub;
|
|
||||||
}
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
string a = "foo"
|
|
||||||
~ "bar" /* bar */
|
|
||||||
~ "baz";
|
|
||||||
}
|
|
||||||
|
|
||||||
void foo()
|
|
||||||
{
|
|
||||||
afdsafds
|
|
||||||
.asdf /* blah */
|
|
||||||
.flub;
|
|
||||||
}
|
|
||||||
|
|
||||||
void foo() // hello
|
|
||||||
{ // world
|
|
||||||
// ok
|
|
||||||
writeln("hi"); // hi!
|
|
||||||
} // done
|
|
||||||
//finish
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
struct S
|
|
||||||
{
|
|
||||||
ref S foo() return
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
public int f() return
|
|
||||||
in (true)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int g() return
|
|
||||||
out (; true)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int h() return
|
|
||||||
body
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
void f() return
|
|
||||||
do
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
/// Testing CR line endings.
void main()
{
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
/// Testing CRLF line endings.
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
/// Testing LF line endings.
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
void f()
|
|
||||||
{
|
|
||||||
auto t = true ? 1 : 0;
|
|
||||||
auto a = [true ? 1 : 0];
|
|
||||||
auto aa1 = [0: true ? 1 : 0];
|
|
||||||
auto aa2 = [0: true ? (false ? 1 : 2) : 3];
|
|
||||||
auto aa3 = [0: true ? false ? 1 : 2 : 3];
|
|
||||||
}
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
void temp(int v1, int v2)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int f(int i)
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct S
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
}
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
temp(v1: 1, v2: 2);
|
|
||||||
temp(v1: 1, v2: 2,);
|
|
||||||
|
|
||||||
auto s = S(5, j: 3);
|
|
||||||
|
|
||||||
temp(v1: 1, v2: f(i: 2));
|
|
||||||
|
|
||||||
temp(v1: true ? i : false ? 2 : f(i: 3), v2: 4);
|
|
||||||
|
|
||||||
temp(v1: () { S s = S(i: 5); return s.i; }, v2: 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test()
|
|
||||||
{
|
|
||||||
return Struct(foo: field.foo, bar: field.bar, baz: field.baz);
|
|
||||||
return new Class(foo: field.foo, bar: field.bar, baz: field.baz);
|
|
||||||
// anonymous class
|
|
||||||
return new class(foo: field.foo, bar: field.bar, baz: field.baz) Class
|
|
||||||
{
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
unittest
|
|
||||||
{
|
|
||||||
f([
|
|
||||||
x
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void f(T[] x,
|
|
||||||
const U y)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
unittest
|
|
||||||
{
|
|
||||||
functionLengthDoesMatter([
|
|
||||||
firstFunctionInChain("A").seconFunctionInChain("B").value,
|
|
||||||
firstFunctionInChain("A").seconFunctionInChain("B").value
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
@safe nothrow
|
|
||||||
@Read
|
|
||||||
@NonNull
|
|
||||||
public
|
|
||||||
int[] func(int argument_1_1, int argument_1_2,
|
|
||||||
int argument_2_1, int argument_2_2,
|
|
||||||
int argument_3_1, int argument_3_2)
|
|
||||||
{
|
|
||||||
if (true && true
|
|
||||||
&& true && true
|
|
||||||
&& true && true)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else if (true && true &&
|
|
||||||
true && true &&
|
|
||||||
true && true)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
func(argument_1_1).func(argument_1_2)
|
|
||||||
.func(argument_2_1)
|
|
||||||
.func(argument_2_2);
|
|
||||||
|
|
||||||
auto x = func(argument_1_1, argument_1_2,
|
|
||||||
this.argument_2_1, this.argument_2_2,
|
|
||||||
argument_3_1, argument_3_2);
|
|
||||||
|
|
||||||
`
|
|
||||||
<html>
|
|
||||||
</html>
|
|
||||||
`.format!"%s";
|
|
||||||
|
|
||||||
return [
|
|
||||||
3, 5,
|
|
||||||
5, 7,
|
|
||||||
11, 13,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
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)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void f()
|
|
||||||
{
|
|
||||||
string a = "foo"
|
|
||||||
~ "bar" /* bar */
|
|
||||||
~ "baz";
|
|
||||||
}
|
|
||||||
|
|
||||||
unittest
|
|
||||||
{
|
|
||||||
if (a)
|
|
||||||
{
|
|
||||||
while (sBraceDepth == 0 && indents.topIsTemp()
|
|
||||||
&& ((indents.top != tok!"if" && indents.top != tok!"version")
|
|
||||||
|| !peekIs(tok!"else")))
|
|
||||||
a();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unittest
|
|
||||||
{
|
|
||||||
callFunc({ int i = 10; return i; });
|
|
||||||
callFunc({
|
|
||||||
int i = 10;
|
|
||||||
foo(alpha, bravo, charlie, delta, echo, foxtrot, golf, echo);
|
|
||||||
doStuff(withThings, andOtherStuff);
|
|
||||||
return i;
|
|
||||||
});
|
|
||||||
callFunc({
|
|
||||||
int i = 10;
|
|
||||||
foo(alpha_longVarName, bravo_longVarName, charlie_longVarName, delta_longVarName,
|
|
||||||
echo_longVarName, foxtrot_longVarName, golf_longVarName, echo_longVarName);
|
|
||||||
doStuff(withThings, andOtherStuff);
|
|
||||||
return i;
|
|
||||||
}, more_stuff);
|
|
||||||
}
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
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)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unittest
|
|
||||||
{
|
|
||||||
if (a)
|
|
||||||
{
|
|
||||||
while (sBraceDepth == 0 && indents.topIsTemp()
|
|
||||||
&& ((indents.top != tok!"if" && indents.top != tok!"version") || !peekIs(tok!"else")))
|
|
||||||
a();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unittest
|
|
||||||
{
|
|
||||||
callFunc({ int i = 10; return i; });
|
|
||||||
callFunc({
|
|
||||||
int i = 10;
|
|
||||||
foo(alpha, bravo, charlie, delta, echo, foxtrot, golf, echo);
|
|
||||||
doStuff(withThings, andOtherStuff);
|
|
||||||
return i;
|
|
||||||
});
|
|
||||||
callFunc({
|
|
||||||
int i = 10;
|
|
||||||
foo(alpha_longVarName, bravo_longVarName, charlie_longVarName, delta_longVarName,
|
|
||||||
echo_longVarName, foxtrot_longVarName, golf_longVarName, echo_longVarName);
|
|
||||||
doStuff(withThings, andOtherStuff);
|
|
||||||
return i;
|
|
||||||
}, more_stuff);
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
void main(string[] args)
|
|
||||||
{
|
|
||||||
for(int i = 0; i < 10; ++i)
|
|
||||||
{
|
|
||||||
if(i == 9)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
while(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(i; 0 .. 9)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
--single_indent=true
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
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__);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
--single_indent=true
|
|
||||||
--keep_line_breaks=true
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
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__);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
--keep_line_breaks=true
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
void main()
|
|
||||||
{
|
|
||||||
string key;
|
|
||||||
|
|
||||||
int[string] var = [
|
|
||||||
key: 5
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
import std.stdio; void main() { writeln("\eee8Hello"); int a = 5; }
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
### This file should not be erased just because it is not formatted correctly
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
--keep_line_breaks true
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
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,
|
|
||||||
])))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,12 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
argsFile=$1.args
|
argsFile=$1.args
|
||||||
if [ -e ${argsFile} ]; then
|
if [ -e ${argsFile} ]; then
|
||||||
args=$(cat ${argsFile})
|
args=$(cat ${argsFile})
|
||||||
fi
|
fi
|
||||||
echo "Args:" ${args}
|
echo "Args:" ${args}
|
||||||
../bin/dfmt --brace_style=allman ${args} $1.d > allman/$1.d.ref
|
dfmt --brace_style=allman ${args} $1.d > allman/$1.d.ref
|
||||||
../bin/dfmt --brace_style=otbs ${args} $1.d > otbs/$1.d.ref
|
dfmt --brace_style=otbs ${args} $1.d > otbs/$1.d.ref
|
||||||
|
|
||||||
echo "------------------"
|
echo "------------------"
|
||||||
echo "allman:"
|
echo "allman:"
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
alias u8 = ubyte
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
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";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
void main()
|
|
||||||
{
|
|
||||||
auto myTid = runTask({
|
|
||||||
auto conn = connectTCP("localhost", 4222);
|
|
||||||
|
|
||||||
auto l = Lexer(conn);
|
|
||||||
foreach (t;
|
|
||||||
l)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
conn.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
// foo
|
|
||||||
runEventLoop();
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
--end_of_line=crlf
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
/* 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
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
void main() {
|
|
||||||
S s1 = { a: 3 };
|
|
||||||
S s2 = { a: 3, b:"test string" };
|
|
||||||
S s3 = { a: 3, b:"test string", c: {x: 3.14, y: 3 + 4} };
|
|
||||||
T t = {
|
|
||||||
someStructMember1: 2,
|
|
||||||
someStructMember2: 42,
|
|
||||||
someStructMember3: null, // foobar
|
|
||||||
someOtherMember1: objA,
|
|
||||||
someOtherMember2: objB,
|
|
||||||
someOtherMember3: 0,
|
|
||||||
somethingMore: null,
|
|
||||||
someFlagInThisStruct: -1
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
void foo() /**/
|
|
||||||
in
|
|
||||||
{
|
|
||||||
}
|
|
||||||
body
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void bar() /**/
|
|
||||||
out
|
|
||||||
{
|
|
||||||
}
|
|
||||||
body
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
import std.stdio;
|
|
||||||
|
|
||||||
@safe extern(C) void main() {
|
|
||||||
writeln("Hello World!");
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
void f(bool body) {
|
|
||||||
if (body) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
struct S1
|
|
||||||
{
|
|
||||||
ulong x;
|
|
||||||
ulong y;
|
|
||||||
ulong function(ulong)f;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct S2
|
|
||||||
{
|
|
||||||
ulong x;
|
|
||||||
ulong y;
|
|
||||||
ulong z;
|
|
||||||
ulong w;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Example 1
|
|
||||||
// Anonymous function in struct, long struct initializer
|
|
||||||
|
|
||||||
immutable S1 s1 = {
|
|
||||||
1111111111111111111, 1111111111111111111, (x) { return x + 1111; },};
|
|
||||||
|
|
||||||
void f1()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Example 2
|
|
||||||
// Anonymous function anywhere, long struct initializer
|
|
||||||
|
|
||||||
int function(int) f2 = (x) { return x + 1111; };
|
|
||||||
|
|
||||||
immutable S2 s = {
|
|
||||||
1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111,};
|
|
||||||
|
|
||||||
void f2()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
int abs(int x) {
|
|
||||||
if (x < 0)
|
|
||||||
// x negative, must negate
|
|
||||||
return -x;
|
|
||||||
else
|
|
||||||
// x already non-negative, just return it
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
struct S
|
|
||||||
{
|
|
||||||
invariant(true);
|
|
||||||
}
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
class C
|
|
||||||
{
|
|
||||||
abstract void f1() //
|
|
||||||
in (true);
|
|
||||||
|
|
||||||
abstract void f2() /* */
|
|
||||||
in (true);
|
|
||||||
|
|
||||||
abstract bool f3() //
|
|
||||||
out (r; r);
|
|
||||||
|
|
||||||
abstract bool f4() /* */
|
|
||||||
out (r; r);
|
|
||||||
|
|
||||||
abstract void f5() //
|
|
||||||
do
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract void f6() /* */
|
|
||||||
do
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract bool f7() //
|
|
||||||
in (true) //
|
|
||||||
out (r; r) //
|
|
||||||
do //
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract bool f8() /* */
|
|
||||||
in (true) /* */
|
|
||||||
out (r; r) /* */
|
|
||||||
do /* */
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
@nogc
|
|
||||||
//
|
|
||||||
void foo();
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
void main()
|
|
||||||
{
|
|
||||||
format!"%s" //
|
|
||||||
("");
|
|
||||||
format!("%s") //
|
|
||||||
("");
|
|
||||||
format!("%s") //
|
|
||||||
("", argument1, argument2, argument3, argument4, argument5, argument6, argument7, argument8, argument9, argument10);
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
bool asdf(const string owner, const string mail) @safe
|
|
||||||
{
|
|
||||||
requestHTTP(url, (scope HTTPClientRequest request) {
|
|
||||||
request.writeFormBody([owner: owner, mail:
|
|
||||||
mail]);
|
|
||||||
}, (scope HTTPClientResponse response) {});
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
string BuildForwardCall()
|
|
||||||
{
|
|
||||||
return `static if (is(typeof(mocked___.` ~ methodString ~ argsPassed ~ `)))
|
|
||||||
{
|
|
||||||
return (mocked___.` ~ methodString ~ argsPassed ~ `);
|
|
||||||
}`;
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue