Merge branch 'dlang-community:master' into master
This commit is contained in:
commit
3e1e643972
|
@ -1,12 +1,9 @@
|
|||
[submodule "libdparse"]
|
||||
path = libdparse
|
||||
url = https://github.com/dlang-community/libdparse.git
|
||||
[submodule "makd"]
|
||||
path = makd
|
||||
url = https://github.com/sociomantic-tsunami/makd
|
||||
[submodule "beaver"]
|
||||
path = beaver
|
||||
url = https://github.com/sociomantic-tsunami/beaver.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
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
set -e
|
||||
|
||||
if [[ $BUILD == dub ]]; then
|
||||
dub build --build=release
|
||||
rdmd ./d-test-utils/test_with_package.d $LIBDPARSE_VERSION libdparse -- dub build --build=release
|
||||
elif [[ $DC == ldc2 ]]; then
|
||||
git submodule update --init --recursive
|
||||
make ldc -j2
|
||||
|
|
80
.travis.yml
80
.travis.yml
|
@ -1,51 +1,30 @@
|
|||
sudo: false
|
||||
language: d
|
||||
d:
|
||||
#- dmd-nightly
|
||||
- dmd-beta
|
||||
- dmd
|
||||
- ldc-beta
|
||||
- ldc
|
||||
|
||||
os:
|
||||
- linux
|
||||
# - osx # disabled until travis has more mac resources
|
||||
- osx
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- /^v\d+\.\d+\.\d+([+-]\S*)*$/
|
||||
|
||||
env:
|
||||
- BUILD=
|
||||
- BUILD=dub
|
||||
- BUILD=dub LIBDPARSE_VERSION=min
|
||||
- BUILD=dub LIBDPARSE_VERSION=max
|
||||
|
||||
script: ./.travis.sh
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- stage: Build & Upload Package
|
||||
if: tag IS present
|
||||
# Which package to deploy
|
||||
env:
|
||||
- DMD=2.076.*
|
||||
- DIST=xenial
|
||||
- PATH="$(git config -f .gitmodules submodule.beaver.path)/bin:$PATH"
|
||||
language: generic
|
||||
sudo: required
|
||||
services:
|
||||
- docker
|
||||
git:
|
||||
submodules: false
|
||||
before_install: git submodule update --init
|
||||
install: beaver dlang install
|
||||
script:
|
||||
- beaver dlang make pkg
|
||||
deploy:
|
||||
provider: script
|
||||
script: beaver bintray upload -d dlang-community/apt/dfmt build/last/pkg/*.deb
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true # must be a git tag
|
||||
repo: dlang-community/dfmt # must be a tag on dlang-community
|
||||
- stage: GitHub Release
|
||||
#if: tag IS present
|
||||
d: ldc-1.8.0
|
||||
d: ldc-1.13.0
|
||||
os: linux
|
||||
script: echo "Deploying to GitHub releases ..." && ./release.sh
|
||||
deploy:
|
||||
|
@ -59,7 +38,7 @@ jobs:
|
|||
tags: true
|
||||
- stage: GitHub Release
|
||||
#if: tag IS present
|
||||
d: ldc-1.8.0
|
||||
d: ldc-1.13.0
|
||||
os: osx
|
||||
script: echo "Deploying to GitHub releases ..." && ./release.sh
|
||||
deploy:
|
||||
|
@ -82,16 +61,35 @@ jobs:
|
|||
apt:
|
||||
packages:
|
||||
- p7zip-full
|
||||
- wine
|
||||
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
|
||||
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)
|
||||
|
|
120
README.md
120
README.md
|
@ -5,50 +5,57 @@
|
|||
**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 --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/```.
|
||||
|
||||
### Installing with DUB
|
||||
|
||||
```sh
|
||||
> dub fetch --version='~master' dfmt && dub run dfmt -- -h
|
||||
```
|
||||
### 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 | -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
|
||||
* **--brace_style**: See **brace_style** below
|
||||
* **--end_of_line**: See **end_of_line** below
|
||||
* **--indent_size**: See **indent_size** below
|
||||
* **--indent_style | -t**: 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
|
||||
* **--single_template_constraint_indent**: See **dfmt_template_constraint_style** below
|
||||
* **--space_after_cast**: See **dfmt_space_after_cast** below
|
||||
* **--space_before_function_parameters**: See **dfmt_space_before_function_parameters** 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
|
||||
* **--template_constraint_style**: See **dfmt_template_constraint_style** 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_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)*
|
||||
|
||||
### Example
|
||||
```
|
||||
|
@ -67,7 +74,7 @@ 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
|
||||
getopt(args,
|
||||
|
@ -82,31 +89,34 @@ 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 | `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)
|
||||
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)
|
||||
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` | `true` | 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_space_before_function_parameters | `true`, `false` | `false` | Insert space before the opening paren of a function parameter list.
|
||||
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.
|
||||
dfmt_template_constraint_style | `conditional_newline_indent` `conditional_newline` `always_newline` `always_newline_indent` | `conditional_newline_indent` | Control the formatting of template constraints.
|
||||
dfmt_single_template_constraint_indent | `true`, `false` | `false` | Set if the constraints are indented by a single tab instead of two. Has only an effect for if indentation style if set to `always_newline_indent` or `conditional_newline_indent`.
|
||||
Property Name | Allowed Values | Description
|
||||
--------------|----------------|------------
|
||||
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_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_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.
|
||||
|
||||
## Terminology
|
||||
* Braces - `{` and `}`
|
||||
|
|
|
@ -24,6 +24,7 @@ skip_tags: false
|
|||
branches:
|
||||
only:
|
||||
- master
|
||||
- /^v\d+\.\d+\.\d+([+-]\S*)*$/
|
||||
|
||||
install:
|
||||
- ps: function ResolveLatestDMD
|
||||
|
|
1
beaver
1
beaver
|
@ -1 +0,0 @@
|
|||
Subproject commit 82f8c8f6bbd9f0fbd9753a134377bec134a5956c
|
|
@ -1,6 +0,0 @@
|
|||
# Copyright sociomantic labs GmbH 2017.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
FROM sociomantictsunami/dlang:v4
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 206a2e6abd97b4462f3a320e4f2d23986fad3cff
|
4
dub.json
4
dub.json
|
@ -4,7 +4,7 @@
|
|||
"targetType": "autodetect",
|
||||
"license": "BSL-1.0",
|
||||
"dependencies": {
|
||||
"libdparse": "~>0.9.10"
|
||||
"libdparse": ">=0.14.0 <1.0.0"
|
||||
},
|
||||
"targetPath" : "bin/",
|
||||
"targetName" : "dfmt",
|
||||
|
@ -15,6 +15,6 @@
|
|||
"built_with_dub"
|
||||
],
|
||||
"preGenerateCommands" : [
|
||||
"rdmd --eval=\"auto dir=environment.get(\\\"DUB_PACKAGE_DIR\\\"); dir.buildPath(\\\"bin\\\").mkdirRecurse; auto gitVer = (\\\"git -C \\\"~dir~\\\" describe --tags\\\").executeShell; (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.toFile(dir.buildPath(\\\"bin\\\", \\\"dubhash.txt\\\"));\""
|
||||
"rdmd \"$PACKAGE_DIR/dubhash.d\""
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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 f8460d0d3581bebd41ee8629bd3e253c94c8a387
|
||||
Subproject commit 7112880dae3f25553d96dae53a445c16261de7f9
|
1
makd
1
makd
|
@ -1 +0,0 @@
|
|||
Subproject commit d735c1df67399693f699f8315418173a55de5313
|
3
makefile
3
makefile
|
@ -8,6 +8,9 @@ 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
|
||||
LDC ?= ldc2
|
||||
GDC ?= gdc
|
||||
|
|
31
pkg/dfmt.pkg
31
pkg/dfmt.pkg
|
@ -1,31 +0,0 @@
|
|||
# dfmt packaging configuration
|
||||
# ============================
|
||||
|
||||
dfmt_bindir='bin'
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Define the keyword arguments to pass to fpm (via the OPTS dict)
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
OPTS.update(
|
||||
name = "dfmt",
|
||||
url = 'https://github.com/dlang-community/dfmt',
|
||||
maintainer = 'Stefan Koch <stefan.koch@sociomantic.com>',
|
||||
vendor = 'Sociomantic Labs GmbH',
|
||||
provides = "dfmt",
|
||||
description = '''\
|
||||
D source code formatter
|
||||
''',
|
||||
depends = FUN.autodeps('dfmt', path=dfmt_bindir),
|
||||
)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Define the positional arguments to pass to fpm (via the ARGS list)
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
ARGS.extend(FUN.mapfiles(dfmt_bindir, '/usr/bin', 'dfmt'))
|
||||
ARGS.extend([
|
||||
'bash-completion/completions/dfmt=/usr/share/bash-completion/completions/dfmt'
|
||||
])
|
||||
|
||||
# vim: set ft=python tw=80 :
|
|
@ -1,26 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
# Build the Windows binaries under Linux (requires wine)
|
||||
# Build the Windows binaries under Linux
|
||||
set -eux -o pipefail
|
||||
VERSION=$(git describe --abbrev=0 --tags)
|
||||
OS=windows
|
||||
ARCH_SUFFIX="x86"
|
||||
|
||||
BIN_NAME=dfmt
|
||||
|
||||
# Allow the script to be run from anywhere
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
cd $DIR
|
||||
|
||||
# Step 1: download the DMD binaries
|
||||
if [ ! -d dmd2 ] ; then
|
||||
wget http://downloads.dlang.org/releases/2.x/2.079.0/dmd.2.079.0.windows.7z
|
||||
7z x dmd.2.079.0.windows.7z > /dev/null
|
||||
fi
|
||||
source setup-ldc-windows.sh
|
||||
|
||||
# Step 2: Run DMD via wineconsole
|
||||
archiveName="dfmt-$VERSION-$OS-$ARCH_SUFFIX.zip"
|
||||
# Run LDC with cross-compilation
|
||||
archiveName="$BIN_NAME-$VERSION-$OS-$ARCH_SUFFIX.zip"
|
||||
echo "Building $archiveName"
|
||||
mkdir -p bin
|
||||
git describe --tags > bin/githash.txt # no git installed under Wine
|
||||
DC="$DIR/dmd2/windows/bin/dmd.exe" wine cmd /C build.bat
|
||||
DC=ldmd2 make ldc
|
||||
|
||||
cd bin
|
||||
zip "$archiveName" dfmt.exe
|
||||
mv "${BIN_NAME}" "${BIN_NAME}.exe"
|
||||
zip "$archiveName" "${BIN_NAME}.exe"
|
||||
|
|
|
@ -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
|
||||
|
|
@ -23,6 +23,12 @@ struct BraceIndentInfo
|
|||
uint beginIndentLevel;
|
||||
}
|
||||
|
||||
struct StructInitializerInfo
|
||||
{
|
||||
size_t startLocation;
|
||||
size_t endLocation;
|
||||
}
|
||||
|
||||
/// AST information that is needed by the formatter.
|
||||
struct ASTInformation
|
||||
{
|
||||
|
@ -45,6 +51,7 @@ struct ASTInformation
|
|||
sort(conditionalWithElseLocations);
|
||||
sort(conditionalStatementLocations);
|
||||
sort(arrayStartLocations);
|
||||
sort(assocArrayStartLocations);
|
||||
sort(contractLocations);
|
||||
sort(constraintLocations);
|
||||
sort(constructorDestructorLocations);
|
||||
|
@ -52,6 +59,8 @@ struct ASTInformation
|
|||
sort(sharedStaticConstructorDestructorLocations);
|
||||
sort!((a,b) => a.endLocation < b.endLocation)
|
||||
(indentInfoSortedByEndLocation);
|
||||
sort!((a,b) => a.endLocation < b.endLocation)
|
||||
(structInfoSortedByEndLocation);
|
||||
sort(ufcsHintLocations);
|
||||
ufcsHintLocations = ufcsHintLocations.uniq().array();
|
||||
}
|
||||
|
@ -86,6 +95,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;
|
||||
|
||||
|
@ -95,6 +110,9 @@ 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;
|
||||
|
||||
|
@ -114,6 +132,9 @@ struct ASTInformation
|
|||
size_t[] ufcsHintLocations;
|
||||
|
||||
BraceIndentInfo[] indentInfoSortedByEndLocation;
|
||||
|
||||
/// Opening & closing braces of struct initializers
|
||||
StructInitializerInfo[] structInfoSortedByEndLocation;
|
||||
}
|
||||
|
||||
/// Collects information from the AST that is useful for the formatter
|
||||
|
@ -136,6 +157,19 @@ 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;
|
||||
|
@ -172,6 +206,18 @@ final class FormatVisitor : ASTVisitor
|
|||
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.hasElse)
|
||||
|
@ -214,9 +260,9 @@ final class FormatVisitor : ASTVisitor
|
|||
|
||||
override void visit(const FunctionLiteralExpression funcLit)
|
||||
{
|
||||
if (funcLit.functionBody !is null)
|
||||
if (funcLit.specifiedFunctionBody !is null)
|
||||
{
|
||||
const bs = funcLit.functionBody.blockStatement;
|
||||
const bs = funcLit.specifiedFunctionBody.blockStatement;
|
||||
|
||||
astInformation.funLitStartLocations ~= bs.startLocation;
|
||||
astInformation.funLitEndLocations ~= bs.endLocation;
|
||||
|
@ -244,21 +290,19 @@ 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);
|
||||
|
||||
|
@ -279,12 +323,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);
|
||||
}
|
||||
|
@ -367,12 +414,24 @@ final class FormatVisitor : ASTVisitor
|
|||
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;
|
||||
|
|
|
@ -16,7 +16,9 @@ enum BraceStyle
|
|||
/// $(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
|
||||
|
@ -55,6 +57,12 @@ struct Config
|
|||
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;
|
||||
|
||||
mixin StandardEditorConfigFields;
|
||||
|
||||
|
@ -82,6 +90,9 @@ struct Config
|
|||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
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 '/'
|
||||
// ** added to take over the old meaning of *
|
||||
bool globMatchEditorConfig(CaseSensitive cs = CaseSensitive.osDefault, C, Range)(
|
||||
Range path, const(C)[] pattern) @safe pure nothrow
|
||||
Range path, const(C)[] pattern) @safe pure nothrow
|
||||
if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range)
|
||||
&& isSomeChar!C && is(Unqual!C == Unqual!(ElementEncodingType!Range)))
|
||||
in
|
||||
|
@ -23,7 +23,7 @@ in
|
|||
assert(balancedParens(pattern, '[', ']', 0));
|
||||
assert(balancedParens(pattern, '{', '}', 0));
|
||||
}
|
||||
body
|
||||
do
|
||||
{
|
||||
alias RC = Unqual!(ElementEncodingType!Range);
|
||||
|
||||
|
|
|
@ -5,8 +5,12 @@
|
|||
|
||||
module dfmt.indentation;
|
||||
|
||||
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
|
||||
*/
|
||||
|
@ -29,6 +33,31 @@ 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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the indent size at the most recent occurrence of the given indent type
|
||||
*/
|
||||
|
@ -55,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++;
|
||||
}
|
||||
|
@ -66,8 +95,20 @@ 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;
|
||||
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
|
||||
|
@ -91,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--;
|
||||
}
|
||||
|
||||
|
@ -100,7 +141,7 @@ struct IndentStack
|
|||
*/
|
||||
void popTempIndents() pure nothrow @safe @nogc
|
||||
{
|
||||
while (index > 0 && isTempIndent(arr[index - 1]))
|
||||
while (index > 0 && details[index - 1].temp)
|
||||
index--;
|
||||
}
|
||||
|
||||
|
@ -125,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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -133,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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -156,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();
|
||||
|
@ -169,13 +231,16 @@ struct IndentStack
|
|||
/**
|
||||
* Dumps the current state of the indentation stack to `stderr`. Used for debugging.
|
||||
*/
|
||||
void dump(string file = __FILE__, uint line = __LINE__)
|
||||
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;
|
||||
|
||||
stderr.writefln("\033[31m%s:%d %(%s %)\033[0m", file, line, arr[0 .. index].map!(a => str(a)));
|
||||
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:
|
||||
|
@ -183,6 +248,7 @@ 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
|
||||
{
|
||||
|
@ -196,17 +262,22 @@ private:
|
|||
{
|
||||
immutable int pc = (arr[i] == tok!"!" || arr[i] == tok!"(" || arr[i] == tok!")") ? parenCount + 1
|
||||
: parenCount;
|
||||
if ((isWrapIndent(arr[i]) || arr[i] == tok!"(") && parenCount > 1)
|
||||
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 currentIsNonWrapTemp = !isWrapIndent(arr[i])
|
||||
&& isTempIndent(arr[i]) && arr[i] != tok!")" && arr[i] != tok!"!";
|
||||
}
|
||||
|
||||
immutable currentIsNonWrapTemp = !details[i].wrap
|
||||
&& details[i].temp && arr[i] != tok!")" && arr[i] != tok!"!";
|
||||
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!"{"))
|
||||
|
@ -221,15 +292,23 @@ private:
|
|||
continue;
|
||||
}
|
||||
}
|
||||
else if (parenCount == 0 && arr[i] == tok!"(")
|
||||
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
|
||||
|
|
|
@ -19,14 +19,14 @@ static immutable VERSION = () {
|
|||
|
||||
version (built_with_dub)
|
||||
{
|
||||
enum DFMT_VERSION = import("dubhash.txt").strip;
|
||||
enum DFMT_VERSION = import("dubhash.txt").strip;
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* Current build's Git commit hash
|
||||
*/
|
||||
enum DFMT_VERSION = import("githash.txt").strip;
|
||||
/**
|
||||
* Current build's Git commit hash
|
||||
*/
|
||||
enum DFMT_VERSION = import("githash.txt").strip;
|
||||
}
|
||||
|
||||
return DFMT_VERSION ~ DEBUG_SUFFIX;
|
||||
|
@ -89,6 +89,15 @@ else
|
|||
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 "keep_line_breaks":
|
||||
optConfig.dfmt_keep_line_breaks = optVal;
|
||||
break;
|
||||
case "single_indent":
|
||||
optConfig.dfmt_single_indent = optVal;
|
||||
break;
|
||||
default:
|
||||
assert(false, "Invalid command-line switch");
|
||||
}
|
||||
|
@ -116,8 +125,11 @@ else
|
|||
"split_operator_at_line_end", &handleBooleans,
|
||||
"compact_labeled_statements", &handleBooleans,
|
||||
"single_template_constraint_indent", &handleBooleans,
|
||||
"space_before_aa_colon", &handleBooleans,
|
||||
"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);
|
||||
// dfmt on
|
||||
}
|
||||
catch (GetOptException e)
|
||||
|
@ -169,7 +181,7 @@ else
|
|||
|
||||
if (!exists(explicitConfigDir) || !isDir(explicitConfigDir))
|
||||
{
|
||||
stderr.writeln("--config_dir|c must specify existing directory path");
|
||||
stderr.writeln("--config|c must specify existing directory path");
|
||||
return 1;
|
||||
}
|
||||
explicitConfig = getConfigFor!Config(explicitConfigDir);
|
||||
|
@ -207,7 +219,9 @@ else
|
|||
else
|
||||
break;
|
||||
}
|
||||
format("stdin", buffer, output.lockingTextWriter(), &config);
|
||||
immutable bool formatSuccess = format("stdin", buffer,
|
||||
output.lockingTextWriter(), &config);
|
||||
return formatSuccess ? 0 : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -215,6 +229,7 @@ else
|
|||
|
||||
if (args.length >= 2)
|
||||
inplace = true;
|
||||
int retVal;
|
||||
while (args.length > 0)
|
||||
{
|
||||
const path = args.front;
|
||||
|
@ -249,11 +264,13 @@ else
|
|||
f.rawRead(buffer);
|
||||
if (inplace)
|
||||
output = File(path, "wb");
|
||||
format(path, buffer, output.lockingTextWriter(), &config);
|
||||
immutable bool formatSuccess = format(path, buffer, output.lockingTextWriter(), &config);
|
||||
if (!formatSuccess)
|
||||
retVal = 1;
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,7 +310,7 @@ https://github.com/dlang-community/dfmt
|
|||
Options:
|
||||
--help, -h Print this help message
|
||||
--inplace, -i Edit files in place
|
||||
--config_dir, -c Path to directory to load .editorconfig file from.
|
||||
--config, -c Path to directory to load .editorconfig file from.
|
||||
--version Print the version number and then exit
|
||||
|
||||
Formatting Options:
|
||||
|
@ -304,6 +321,7 @@ Formatting Options:
|
|||
--indent_size
|
||||
--indent_style, -t `,
|
||||
optionsToString!(typeof(Config.indent_style)), `
|
||||
--keep_line_breaks
|
||||
--soft_max_line_length
|
||||
--max_line_length
|
||||
--outdent_attributes
|
||||
|
@ -314,6 +332,8 @@ Formatting Options:
|
|||
--split_operator_at_line_end
|
||||
--compact_labeled_statements
|
||||
--template_constraint_style
|
||||
--space_before_aa_colon
|
||||
--single_indent
|
||||
`,
|
||||
optionsToString!(typeof(Config.dfmt_template_constraint_style)));
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ in
|
|||
{
|
||||
assert(tokens[0].type == tok!"(");
|
||||
}
|
||||
body
|
||||
do
|
||||
{
|
||||
uint length = 0;
|
||||
size_t i = 1;
|
||||
|
@ -134,7 +134,6 @@ int breakCost(IdType p, IdType c) pure nothrow @safe @nogc
|
|||
case tok!"||":
|
||||
case tok!"&&":
|
||||
case tok!",":
|
||||
case tok!":":
|
||||
case tok!"?":
|
||||
return 0;
|
||||
case tok!"(":
|
||||
|
@ -184,6 +183,10 @@ int breakCost(IdType p, IdType c) 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 p == tok!")" ? 0 : 300;
|
||||
default:
|
||||
|
@ -227,7 +230,7 @@ private string generateFixedLengthCases()
|
|||
"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",
|
||||
"union", "unittest", "ushort", "version", "void", "wchar",
|
||||
"while", "with", "__DATE__", "__EOF__", "__FILE__",
|
||||
"__FUNCTION__", "__gshared", "__LINE__", "__MODULE__", "__parameters",
|
||||
"__PRETTY_FUNCTION__", "__TIME__", "__TIMESTAMP__",
|
||||
|
|
|
@ -172,9 +172,6 @@ size_t[] chooseLineBreakTokens(size_t index, const Token[] tokens,
|
|||
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, min;
|
||||
import std.array : insertInPlace;
|
||||
|
||||
foreach (i, token; tokens)
|
||||
{
|
||||
if (!isBreakToken(token.type) || (((1 << i) & current) != 0))
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b7778fd6bf5f9aaaa87dd27f989cefbf9b3b365f
|
||||
Subproject commit ae237cabd1843774cc78aad0729c914a3dd579db
|
|
@ -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"]];
|
|
@ -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"]
|
||||
];
|
|
@ -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]
|
||||
]);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
void main()
|
||||
{
|
||||
string key;
|
||||
|
||||
int[string] var = [
|
||||
key: 5
|
||||
];
|
||||
}
|
|
@ -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
|
||||
];
|
||||
}
|
|
@ -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))
|
||||
]
|
||||
])
|
||||
])
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
|
@ -13,8 +13,8 @@ do
|
|||
}
|
||||
|
||||
int bar(int arg)
|
||||
in(arg > 0)
|
||||
out(; true)
|
||||
in (arg > 0)
|
||||
out (; true)
|
||||
out /*Major*/ ( /*Tom*/ result /*To ground control*/ ; result == 0)
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -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
|
||||
];
|
||||
|
|
|
@ -9,25 +9,28 @@ 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__", ",", ".", "..",
|
||||
"...", "/", "/=", "!", "!<", "!<=", "!<>", "!<>=", "!=", "!>", "!>=",
|
||||
"$", "%", "%=", "&", "&&", "&=", "(", ")", "*", "*=", "+", "++",
|
||||
"+=", "-", "--", "-=", ":", ";", "<", "<<", "<<=", "<=", "<>", "<>=",
|
||||
"=", "==", "=>", ">", ">=", ">>", ">>=", ">>>", ">>>=", "?", "@", "[",
|
||||
"]", "^", "^=", "^^", "^^=", "{", "|", "|=", "||", "}", "~", "~="
|
||||
"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__",
|
||||
",", ".", "..", "...", "/", "/=", "!", "!<", "!<=", "!<>", "!<>=",
|
||||
"!=", "!>", "!>=", "$", "%", "%=", "&", "&&", "&=", "(", ")", "*",
|
||||
"*=", "+", "++", "+=", "-", "--", "-=", ":", ";", "<", "<<", "<<=",
|
||||
"<=", "<>", "<>=", "=", "==", "=>", ">", ">=", ">>", ">>=", ">>>",
|
||||
">>>=", "?", "@", "[", "]", "^", "^=", "^^", "^^=", "{", "|", "|=", "||",
|
||||
"}", "~", "~="
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
auto fun = function() { };
|
||||
auto fun = () { };
|
||||
auto fun = function() {};
|
||||
auto fun = () {};
|
||||
auto fun = {};
|
||||
|
||||
auto fun = { int i; };
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
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,3 +1,3 @@
|
|||
alias foo = typeof({ import std.math; });
|
||||
alias bar = typeof({ write("aaa"); });
|
||||
alias baz = typeof({ });
|
||||
alias baz = typeof({});
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
void foo() /**/
|
||||
in
|
||||
{
|
||||
}
|
||||
body
|
||||
{
|
||||
}
|
||||
|
||||
void bar() /**/
|
||||
out
|
||||
{
|
||||
}
|
||||
body
|
||||
{
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import std.stdio;
|
||||
|
||||
@safe extern (C) void main()
|
||||
{
|
||||
writeln("Hello World!");
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
void f(bool body)
|
||||
{
|
||||
if (body)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
int abs(int x)
|
||||
{
|
||||
if (x < 0) // x negative, must negate
|
||||
return -x;
|
||||
else // x already non-negative, just return it
|
||||
return x;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
extern (Objective-C) int a;
|
|
@ -0,0 +1,4 @@
|
|||
struct S
|
||||
{
|
||||
invariant (true);
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
@nogc //
|
||||
void foo();
|
|
@ -0,0 +1,10 @@
|
|||
void main()
|
||||
{
|
||||
format!"%s" //
|
||||
("");
|
||||
format!("%s") //
|
||||
("");
|
||||
format!("%s") //
|
||||
("", argument1, argument2, argument3, argument4, argument5,
|
||||
argument6, argument7, argument8, argument9, argument10);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
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;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
string BuildForwardCall()
|
||||
{
|
||||
return `static if (is(typeof(mocked___.` ~ methodString ~ argsPassed ~ `)))
|
||||
{
|
||||
return (mocked___.` ~ methodString ~ argsPassed ~ `);
|
||||
}`;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
module tests.issue0483;
|
||||
|
||||
void main()
|
||||
{
|
||||
switch (0)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
label:
|
||||
case 3:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
void main()
|
||||
{
|
||||
int a;
|
||||
int[int] hashmap = [a : a, a : a, a : a];
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
void main()
|
||||
{
|
||||
auto someAutoVariableName = this.firstLink.secondLink
|
||||
.filter!(shouldBeProbablySomeIdentifierOrNot);
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
alias f1 = S function();
|
||||
alias f2 = S!"foo" function();
|
||||
alias f3 = S!5 function();
|
||||
alias f4 = S!S function();
|
||||
alias f5 = S!(S) function();
|
|
@ -0,0 +1,4 @@
|
|||
void main()
|
||||
{
|
||||
auto aa = ["aaa": 1, "bbb": 2];
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
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()
|
||||
{
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
struct S
|
||||
{
|
||||
@safe invariant
|
||||
{
|
||||
assert(true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
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
|
|
@ -0,0 +1,7 @@
|
|||
struct S
|
||||
{
|
||||
ref S foo() return
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
public int f() return
|
||||
in (true)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int g() return
|
||||
out (; true)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int h() return
|
||||
body
|
||||
{
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
void f() return
|
||||
do
|
||||
{
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
unittest
|
||||
{
|
||||
f([
|
||||
x
|
||||
]);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
unittest
|
||||
{
|
||||
functionLengthDoesMatter([
|
||||
firstFunctionInChain("A").seconFunctionInChain("B").value,
|
||||
firstFunctionInChain("A").seconFunctionInChain("B").value
|
||||
]);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
@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,
|
||||
];
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
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);
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
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);
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
unittest
|
||||
{
|
||||
foo([target.value.region[1], target.value.region[1], target.value.region[1], target.value.region[1], target.value.region[1]]);
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
--keep_line_breaks=true
|
|
@ -0,0 +1,8 @@
|
|||
void main()
|
||||
{
|
||||
string key;
|
||||
|
||||
int[string] var = [
|
||||
key: 5
|
||||
];
|
||||
}
|
|
@ -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];
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
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))]])
|
||||
])]
|
||||
]]);
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
import std.stdio; void main() { writeln("\eee8Hello"); int a = 5; }
|
|
@ -1,10 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
argsFile=$1.args
|
||||
if [ -e ${argsFile} ]; then
|
||||
args=$(cat ${argsFile})
|
||||
fi
|
||||
echo "Args:" ${args}
|
||||
dfmt --brace_style=allman ${args} $1.d > allman/$1.d.ref
|
||||
dfmt --brace_style=otbs ${args} $1.d > otbs/$1.d.ref
|
||||
../bin/dfmt --brace_style=allman ${args} $1.d > allman/$1.d.ref
|
||||
../bin/dfmt --brace_style=otbs ${args} $1.d > otbs/$1.d.ref
|
||||
|
||||
echo "------------------"
|
||||
echo "allman:"
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
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();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
--space_before_aa_colon=true
|
|
@ -0,0 +1,11 @@
|
|||
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";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
void main()
|
||||
{
|
||||
auto myTid = runTask({
|
||||
auto conn = connectTCP("localhost", 4222);
|
||||
|
||||
auto l = Lexer(conn);
|
||||
foreach (t;
|
||||
l)
|
||||
{
|
||||
|
||||
}
|
||||
conn.close();
|
||||
});
|
||||
|
||||
// foo
|
||||
runEventLoop();
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
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
|
||||
};
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
void foo() /**/
|
||||
in
|
||||
{
|
||||
}
|
||||
body
|
||||
{
|
||||
}
|
||||
|
||||
void bar() /**/
|
||||
out
|
||||
{
|
||||
}
|
||||
body
|
||||
{
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import std.stdio;
|
||||
|
||||
@safe extern(C) void main() {
|
||||
writeln("Hello World!");
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
void f(bool body) {
|
||||
if (body) {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
int abs(int x) {
|
||||
if (x < 0)
|
||||
// x negative, must negate
|
||||
return -x;
|
||||
else
|
||||
// x already non-negative, just return it
|
||||
return x;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
extern (Objective-C) int a;
|
|
@ -0,0 +1,4 @@
|
|||
struct S
|
||||
{
|
||||
invariant(true);
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
@nogc
|
||||
//
|
||||
void foo();
|
|
@ -0,0 +1,9 @@
|
|||
void main()
|
||||
{
|
||||
format!"%s" //
|
||||
("");
|
||||
format!("%s") //
|
||||
("");
|
||||
format!("%s") //
|
||||
("", argument1, argument2, argument3, argument4, argument5, argument6, argument7, argument8, argument9, argument10);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
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;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
string BuildForwardCall()
|
||||
{
|
||||
return `static if (is(typeof(mocked___.` ~ methodString ~ argsPassed ~ `)))
|
||||
{
|
||||
return (mocked___.` ~ methodString ~ argsPassed ~ `);
|
||||
}`;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
--align_switch_statements=false
|
|
@ -0,0 +1,15 @@
|
|||
module tests.issue0483;
|
||||
|
||||
void main()
|
||||
{
|
||||
switch (0)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
label:
|
||||
case 3:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
--space_before_aa_colon true
|
|
@ -0,0 +1,5 @@
|
|||
void main()
|
||||
{
|
||||
int a;
|
||||
int[int] hashmap = [a : a, a : a, a : a];
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
--keep_line_breaks=true
|
|
@ -0,0 +1,5 @@
|
|||
void main()
|
||||
{
|
||||
auto someAutoVariableName = this.firstLink.secondLink
|
||||
.filter!(shouldBeProbablySomeIdentifierOrNot);
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
alias f1 = S function();
|
||||
alias f2 = S!"foo" function();
|
||||
alias f3 = S!5 function();
|
||||
alias f4 = S!S function();
|
||||
alias f5 = S!(S) function();
|
|
@ -0,0 +1,4 @@
|
|||
void main()
|
||||
{
|
||||
auto aa = ["aaa": 1, "bbb":2];
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
--keep_line_breaks=true
|
|
@ -0,0 +1,40 @@
|
|||
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()
|
||||
{
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue