Compare commits
23 Commits
v0.15.0-be
...
master
Author | SHA1 | Date |
---|---|---|
|
d8e43e23ec | |
|
0ea0572e86 | |
|
5ea76cd293 | |
|
fa463b472c | |
|
2ea6c43a66 | |
|
9f377100f0 | |
|
20b8badf8c | |
|
35e55bc9b2 | |
|
08fe5d6855 | |
|
c0452dbd11 | |
|
876bbe33c1 | |
|
1e765fb781 | |
|
c43803575d | |
|
470e65f7cc | |
|
6f41b20d5b | |
|
49b9fe4051 | |
|
fec7394175 | |
|
727472c365 | |
|
840aeee45e | |
|
a91f044958 | |
|
dba8c87ebc | |
|
a4fbc6f881 | |
|
57f57d95de |
15
.travis.sh
15
.travis.sh
|
@ -1,15 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [[ $BUILD == dub ]]; then
|
|
||||||
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
|
|
||||||
else
|
|
||||||
git submodule update --init --recursive
|
|
||||||
make debug -j2
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd tests && ./test.d
|
|
95
.travis.yml
95
.travis.yml
|
@ -1,95 +0,0 @@
|
||||||
sudo: false
|
|
||||||
language: d
|
|
||||||
d:
|
|
||||||
- dmd
|
|
||||||
- ldc
|
|
||||||
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
- osx
|
|
||||||
|
|
||||||
branches:
|
|
||||||
only:
|
|
||||||
- master
|
|
||||||
- /^v\d+\.\d+\.\d+([+-]\S*)*$/
|
|
||||||
|
|
||||||
env:
|
|
||||||
- BUILD=
|
|
||||||
- BUILD=dub LIBDPARSE_VERSION=min
|
|
||||||
- BUILD=dub LIBDPARSE_VERSION=max
|
|
||||||
|
|
||||||
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)
|
|
10
README.md
10
README.md
|
@ -1,4 +1,5 @@
|
||||||
# dfmt [](https://travis-ci.org/dlang-community/dfmt)
|
# dfmt [](https://github.com/dlang-community/dfmt/actions?query=workflow%3A%22D%22)
|
||||||
|
|
||||||
**dfmt** is a formatter for D source code
|
**dfmt** is a formatter for D source code
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
@ -51,11 +52,15 @@ 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)*
|
* `--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
|
||||||
```
|
```
|
||||||
|
@ -115,8 +120,11 @@ 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_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_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 `}`
|
||||||
|
|
2
dub.json
2
dub.json
|
@ -4,7 +4,7 @@
|
||||||
"targetType": "autodetect",
|
"targetType": "autodetect",
|
||||||
"license": "BSL-1.0",
|
"license": "BSL-1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"libdparse": ">=0.14.0 <1.0.0"
|
"libdparse": ">=0.19.2 <1.0.0"
|
||||||
},
|
},
|
||||||
"targetPath" : "bin/",
|
"targetPath" : "bin/",
|
||||||
"targetName" : "dfmt",
|
"targetName" : "dfmt",
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7112880dae3f25553d96dae53a445c16261de7f9
|
Subproject commit fe6d1e38fb4fc04323170389cfec67ed7fd4e24a
|
56
makefile
56
makefile
|
@ -1,53 +1,63 @@
|
||||||
|
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")
|
||||||
$(shell find stdx-allocator/source -name "*.d")
|
IMPORTS := -Ilibdparse/src -Isrc -Jbin
|
||||||
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
|
||||||
|
|
||||||
.PHONY: dmd ldc gdc test
|
DMD_COMMON_FLAGS := -w $(IMPORTS)
|
||||||
|
DMD_DEBUG_FLAGS := -debug -g $(DMD_COMMON_FLAGS)
|
||||||
|
DMD_FLAGS := -O -inline $(DMD_COMMON_FLAGS)
|
||||||
|
DMD_TEST_FLAGS := -unittest -g $(DMD_COMMON_FLAGS)
|
||||||
|
LDC_FLAGS := -g -w -oq $(IMPORTS)
|
||||||
|
GDC_FLAGS := -g -w -oq $(IMPORTS)
|
||||||
|
override DMD_FLAGS += $(DFLAGS)
|
||||||
|
override LDC_FLAGS += $(DFLAGS)
|
||||||
|
override GDC_FLAGS += $(DFLAGS)
|
||||||
|
|
||||||
dmd: bin/dfmt
|
.PHONY: all clean install debug dmd ldc gdc pkg release test
|
||||||
|
|
||||||
githash:
|
all: bin/dfmt
|
||||||
|
|
||||||
|
bin/githash.txt:
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
git describe --tags > bin/githash.txt
|
git describe --tags > bin/githash.txt
|
||||||
|
|
||||||
ldc: githash
|
dmd: bin/dfmt
|
||||||
|
|
||||||
|
ldc: bin/githash.txt
|
||||||
$(LDC) $(SRC) $(LDC_FLAGS) -ofbin/dfmt
|
$(LDC) $(SRC) $(LDC_FLAGS) -ofbin/dfmt
|
||||||
-rm -f *.o
|
-rm -f *.o
|
||||||
|
|
||||||
gdc:githash
|
gdc: bin/githash.txt
|
||||||
$(GDC) $(SRC) $(GDC_FLAGS) -obin/dfmt
|
$(GDC) $(SRC) $(GDC_FLAGS) -obin/dfmt
|
||||||
|
|
||||||
test: debug
|
test: debug
|
||||||
cd tests && ./test.d
|
cd tests && ./test.d
|
||||||
|
|
||||||
bin/dfmt-test: githash $(SRC)
|
bin/dfmt-test: bin/githash.txt $(SRC)
|
||||||
$(DC) $(DMD_TEST_FLAGS) $^ -of$@
|
$(DC) $(DMD_TEST_FLAGS) $(filter %.d,$^) -of$@
|
||||||
|
|
||||||
bin/dfmt: githash $(SRC)
|
bin/dfmt: bin/githash.txt $(SRC)
|
||||||
$(DC) $(DMD_FLAGS) $(filter %.d,$^) -of$@
|
$(DC) $(DMD_FLAGS) $(filter %.d,$^) -of$@
|
||||||
|
|
||||||
debug: githash $(SRC)
|
debug: bin/githash.txt $(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
|
$(RM) bin/dfmt bin/dfmt-test bin/githash.txt
|
||||||
|
|
||||||
|
install:
|
||||||
|
chmod +x bin/dfmt
|
||||||
|
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
||||||
|
cp -f bin/dfmt $(DESTDIR)$(PREFIX)/bin/dfmt
|
||||||
|
|
||||||
release:
|
release:
|
||||||
./release.sh
|
./release.sh
|
||||||
githash
|
$(MAKE) bin/githash.txt
|
||||||
|
|
|
@ -63,6 +63,8 @@ struct ASTInformation
|
||||||
(structInfoSortedByEndLocation);
|
(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
|
||||||
|
@ -135,6 +137,12 @@ struct ASTInformation
|
||||||
|
|
||||||
/// Opening & closing braces of struct initializers
|
/// Opening & closing braces of struct initializers
|
||||||
StructInitializerInfo[] structInfoSortedByEndLocation;
|
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
|
||||||
|
@ -438,6 +446,43 @@ 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)
|
||||||
|
{
|
||||||
|
// Check if function has any arguments.
|
||||||
|
if (functionCall.arguments.namedArgumentList is null)
|
||||||
|
{
|
||||||
|
functionCall.accept(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (item; functionCall.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
functionCall.accept(this);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTInformation* astInformation;
|
ASTInformation* astInformation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,12 @@ struct Config
|
||||||
OptionalBoolean dfmt_keep_line_breaks;
|
OptionalBoolean dfmt_keep_line_breaks;
|
||||||
///
|
///
|
||||||
OptionalBoolean dfmt_single_indent;
|
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;
|
||||||
|
|
||||||
|
@ -93,6 +99,8 @@ struct Config
|
||||||
dfmt_space_before_aa_colon = OptionalBoolean.f;
|
dfmt_space_before_aa_colon = OptionalBoolean.f;
|
||||||
dfmt_keep_line_breaks = OptionalBoolean.f;
|
dfmt_keep_line_breaks = OptionalBoolean.f;
|
||||||
dfmt_single_indent = OptionalBoolean.f;
|
dfmt_single_indent = OptionalBoolean.f;
|
||||||
|
dfmt_reflow_property_chains = OptionalBoolean.t;
|
||||||
|
dfmt_space_before_named_arg_colon = OptionalBoolean.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -203,7 +203,7 @@ private:
|
||||||
|
|
||||||
/// Tracks paren depth on a single line. This information can be used to
|
/// Tracks paren depth on a single line. This information can be used to
|
||||||
/// indent array literals inside parens, since arrays are indented only once
|
/// indent array literals inside parens, since arrays are indented only once
|
||||||
/// and paren indentation is ignored.line breaks and "[" reset the counter.
|
/// and paren indentation is ignored. Line breaks and "[" reset the counter.
|
||||||
int parenDepthOnLine;
|
int parenDepthOnLine;
|
||||||
|
|
||||||
string eolStringFromInput() const
|
string eolStringFromInput() const
|
||||||
|
@ -247,9 +247,9 @@ private:
|
||||||
else if (currentIs(tok!"return"))
|
else if (currentIs(tok!"return"))
|
||||||
{
|
{
|
||||||
writeToken();
|
writeToken();
|
||||||
if (!currentIs(tok!";") && !currentIs(tok!")") && !currentIs(tok!"{")
|
if (hasCurrent && (!currentIs(tok!";") && !currentIs(tok!")") && !currentIs(tok!"{")
|
||||||
&& !currentIs(tok!"in") && !currentIs(tok!"out") && !currentIs(tok!"do")
|
&& !currentIs(tok!"in") && !currentIs(tok!"out") && !currentIs(tok!"do")
|
||||||
&& (hasCurrent && tokens[index].text != "body"))
|
&& tokens[index].text != "body"))
|
||||||
write(" ");
|
write(" ");
|
||||||
}
|
}
|
||||||
else if (currentIs(tok!"with"))
|
else if (currentIs(tok!"with"))
|
||||||
|
@ -257,16 +257,20 @@ private:
|
||||||
if (indents.length == 0 || !indents.topIsOneOf(tok!"switch", tok!"with"))
|
if (indents.length == 0 || !indents.topIsOneOf(tok!"switch", tok!"with"))
|
||||||
indents.push(tok!"with");
|
indents.push(tok!"with");
|
||||||
writeToken();
|
writeToken();
|
||||||
write(" ");
|
if (config.dfmt_space_after_keywords) {
|
||||||
if (currentIs(tok!"("))
|
write(" ");
|
||||||
|
}
|
||||||
|
if (hasCurrent && currentIs(tok!"("))
|
||||||
writeParens(false);
|
writeParens(false);
|
||||||
if (!currentIs(tok!"switch") && !currentIs(tok!"with")
|
if (hasCurrent && !currentIs(tok!"switch") && !currentIs(tok!"with")
|
||||||
&& !currentIs(tok!"{") && !(currentIs(tok!"final") && peekIs(tok!"switch")))
|
&& !currentIs(tok!"{") && !(currentIs(tok!"final") && peekIs(tok!"switch")))
|
||||||
{
|
{
|
||||||
newline();
|
newline();
|
||||||
}
|
}
|
||||||
else if (!currentIs(tok!"{"))
|
else if (hasCurrent && !currentIs(tok!"{"))
|
||||||
|
{
|
||||||
write(" ");
|
write(" ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (currentIs(tok!"switch"))
|
else if (currentIs(tok!"switch"))
|
||||||
{
|
{
|
||||||
|
@ -351,7 +355,7 @@ private:
|
||||||
else if (isBasicType(current.type))
|
else if (isBasicType(current.type))
|
||||||
{
|
{
|
||||||
writeToken();
|
writeToken();
|
||||||
if (currentIs(tok!"identifier") || isKeyword(current.type) || inAsm)
|
if (hasCurrent && (currentIs(tok!"identifier") || isKeyword(current.type) || inAsm))
|
||||||
write(" ");
|
write(" ");
|
||||||
}
|
}
|
||||||
else if (isOperator(current.type))
|
else if (isOperator(current.type))
|
||||||
|
@ -720,13 +724,18 @@ private:
|
||||||
|
|
||||||
void revertParenIndentation()
|
void revertParenIndentation()
|
||||||
{
|
{
|
||||||
|
import std.algorithm.searching : canFind, until;
|
||||||
|
|
||||||
|
if (tokens[index .. $].until!(tok => tok.line != current.line).canFind!(x => x.type == tok!"]"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (parenDepthOnLine)
|
if (parenDepthOnLine)
|
||||||
{
|
{
|
||||||
foreach (i; 0 .. parenDepthOnLine)
|
foreach (i; 0 .. parenDepthOnLine)
|
||||||
{
|
{
|
||||||
indents.pop();
|
indents.pop();
|
||||||
}
|
}
|
||||||
indents.popTempIndents();
|
|
||||||
}
|
}
|
||||||
parenDepthOnLine = 0;
|
parenDepthOnLine = 0;
|
||||||
}
|
}
|
||||||
|
@ -826,12 +835,13 @@ private:
|
||||||
{
|
{
|
||||||
import dfmt.editorconfig : OptionalBoolean;
|
import dfmt.editorconfig : OptionalBoolean;
|
||||||
import std.algorithm : canFind, any;
|
import std.algorithm : canFind, any;
|
||||||
|
|
||||||
immutable bool isCase = astInformation.caseEndLocations.canFindIndex(current.index);
|
immutable bool isCase = astInformation.caseEndLocations.canFindIndex(current.index);
|
||||||
immutable bool isAttribute = astInformation.attributeDeclarationLines.canFindIndex(
|
immutable bool isAttribute = astInformation.attributeDeclarationLines.canFindIndex(
|
||||||
current.line);
|
current.line);
|
||||||
immutable bool isStructInitializer = astInformation.structInfoSortedByEndLocation
|
immutable bool isStructInitializer = astInformation.structInfoSortedByEndLocation
|
||||||
.canFind!(st => st.startLocation < current.index && current.index < st.endLocation);
|
.canFind!(st => st.startLocation < current.index && current.index < st.endLocation);
|
||||||
|
immutable bool isTernary = astInformation.ternaryColonLocations.canFindIndex(current.index);
|
||||||
|
immutable bool isNamedArg = astInformation.namedArgumentColonLocations.canFindIndex(current.index);
|
||||||
|
|
||||||
if (isCase || isAttribute)
|
if (isCase || isAttribute)
|
||||||
{
|
{
|
||||||
|
@ -847,11 +857,17 @@ private:
|
||||||
newline();
|
newline();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (indents.topIs(tok!"]")) // Associative array
|
else if (indents.topIs(tok!"]") && !isTernary) // Associative array
|
||||||
{
|
{
|
||||||
write(config.dfmt_space_before_aa_colon ? " : " : ": ");
|
write(config.dfmt_space_before_aa_colon ? " : " : ": ");
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
|
// Named function or struct constructor arguments.
|
||||||
|
else if (isNamedArg)
|
||||||
|
{
|
||||||
|
write(config.dfmt_space_before_named_arg_colon ? " : " : ": ");
|
||||||
|
++index;
|
||||||
|
}
|
||||||
else if (peekBackIs(tok!"identifier")
|
else if (peekBackIs(tok!"identifier")
|
||||||
&& [tok!"{", tok!"}", tok!";", tok!":", tok!","]
|
&& [tok!"{", tok!"}", tok!";", tok!":", tok!","]
|
||||||
.any!((ptrdiff_t token) => peekBack2Is(cast(IdType)token, true))
|
.any!((ptrdiff_t token) => peekBack2Is(cast(IdType)token, true))
|
||||||
|
@ -1044,6 +1060,21 @@ private:
|
||||||
if (niBraceDepth > 0)
|
if (niBraceDepth > 0)
|
||||||
niBraceDepth--;
|
niBraceDepth--;
|
||||||
|
|
||||||
|
// Account for possible function literals in this array which offset
|
||||||
|
// the previously set index (pos). Fixes issue #432.
|
||||||
|
size_t newPos = pos;
|
||||||
|
while(astInformation.indentInfoSortedByEndLocation[newPos].endLocation <
|
||||||
|
tokens[index].index)
|
||||||
|
{
|
||||||
|
newPos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (astInformation.indentInfoSortedByEndLocation[newPos].endLocation ==
|
||||||
|
tokens[index].index)
|
||||||
|
{
|
||||||
|
pos = newPos;
|
||||||
|
}
|
||||||
|
|
||||||
auto indentInfo = astInformation.indentInfoSortedByEndLocation[pos];
|
auto indentInfo = astInformation.indentInfoSortedByEndLocation[pos];
|
||||||
if (indentInfo.flags & BraceIndentInfoFlags.tempIndent)
|
if (indentInfo.flags & BraceIndentInfoFlags.tempIndent)
|
||||||
{
|
{
|
||||||
|
@ -1113,7 +1144,10 @@ private:
|
||||||
indents.pop();
|
indents.pop();
|
||||||
indents.push(tok!"switch");
|
indents.push(tok!"switch");
|
||||||
writeToken(); // switch
|
writeToken(); // switch
|
||||||
write(" ");
|
if (config.dfmt_space_after_keywords)
|
||||||
|
{
|
||||||
|
write(" ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void formatBlockHeader()
|
void formatBlockHeader()
|
||||||
|
@ -1144,16 +1178,26 @@ private:
|
||||||
|
|
||||||
if (currentIs(tok!"("))
|
if (currentIs(tok!"("))
|
||||||
{
|
{
|
||||||
write(" ");
|
if (config.dfmt_space_after_keywords)
|
||||||
|
{
|
||||||
|
write(" ");
|
||||||
|
}
|
||||||
writeParens(false);
|
writeParens(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasCurrent)
|
if (hasCurrent)
|
||||||
{
|
{
|
||||||
if (currentIs(tok!"switch") || (currentIs(tok!"final") && peekIs(tok!"switch")))
|
if (currentIs(tok!"switch") || (currentIs(tok!"final") && peekIs(tok!"switch")))
|
||||||
write(" ");
|
{
|
||||||
|
if (config.dfmt_space_after_keywords)
|
||||||
|
{
|
||||||
|
write(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (currentIs(tok!"comment"))
|
else if (currentIs(tok!"comment"))
|
||||||
|
{
|
||||||
formatStep();
|
formatStep();
|
||||||
|
}
|
||||||
else if (!shouldPushIndent)
|
else if (!shouldPushIndent)
|
||||||
{
|
{
|
||||||
if (!currentIs(tok!"{") && !currentIs(tok!";"))
|
if (!currentIs(tok!"{") && !currentIs(tok!";"))
|
||||||
|
@ -1234,7 +1278,7 @@ private:
|
||||||
break;
|
break;
|
||||||
case tok!"cast":
|
case tok!"cast":
|
||||||
writeToken();
|
writeToken();
|
||||||
if (currentIs(tok!"("))
|
if (hasCurrent && currentIs(tok!"("))
|
||||||
writeParens(config.dfmt_space_after_cast == OptionalBoolean.t);
|
writeParens(config.dfmt_space_after_cast == OptionalBoolean.t);
|
||||||
break;
|
break;
|
||||||
case tok!"out":
|
case tok!"out":
|
||||||
|
@ -1246,14 +1290,14 @@ private:
|
||||||
write(" ");
|
write(" ");
|
||||||
}
|
}
|
||||||
writeToken();
|
writeToken();
|
||||||
if (!currentIs(tok!"{") && !currentIs(tok!"comment"))
|
if (hasCurrent && !currentIs(tok!"{") && !currentIs(tok!"comment"))
|
||||||
write(" ");
|
write(" ");
|
||||||
break;
|
break;
|
||||||
case tok!"try":
|
case tok!"try":
|
||||||
case tok!"finally":
|
case tok!"finally":
|
||||||
indents.push(current.type);
|
indents.push(current.type);
|
||||||
writeToken();
|
writeToken();
|
||||||
if (!currentIs(tok!"{"))
|
if (hasCurrent && !currentIs(tok!"{"))
|
||||||
newline();
|
newline();
|
||||||
break;
|
break;
|
||||||
case tok!"identifier":
|
case tok!"identifier":
|
||||||
|
@ -1278,6 +1322,8 @@ private:
|
||||||
write(" ");
|
write(" ");
|
||||||
}
|
}
|
||||||
writeToken();
|
writeToken();
|
||||||
|
if (!hasCurrent)
|
||||||
|
return;
|
||||||
immutable isFunctionLit = astInformation.funLitStartLocations.canFindIndex(
|
immutable isFunctionLit = astInformation.funLitStartLocations.canFindIndex(
|
||||||
current.index);
|
current.index);
|
||||||
if (isFunctionLit && config.dfmt_brace_style == BraceStyle.allman)
|
if (isFunctionLit && config.dfmt_brace_style == BraceStyle.allman)
|
||||||
|
@ -1290,12 +1336,12 @@ private:
|
||||||
tok!"}", tok!"=", tok!"&&", tok!"||") && !peekBackIsKeyword())
|
tok!"}", tok!"=", tok!"&&", tok!"||") && !peekBackIsKeyword())
|
||||||
write(" ");
|
write(" ");
|
||||||
writeToken();
|
writeToken();
|
||||||
if (!currentIs(tok!"(") && !currentIs(tok!"{") && !currentIs(tok!"comment"))
|
if (hasCurrent && !currentIs(tok!"(") && !currentIs(tok!"{") && !currentIs(tok!"comment"))
|
||||||
write(" ");
|
write(" ");
|
||||||
break;
|
break;
|
||||||
case tok!"case":
|
case tok!"case":
|
||||||
writeToken();
|
writeToken();
|
||||||
if (!currentIs(tok!";"))
|
if (hasCurrent && !currentIs(tok!";"))
|
||||||
write(" ");
|
write(" ");
|
||||||
break;
|
break;
|
||||||
case tok!"enum":
|
case tok!"enum":
|
||||||
|
@ -1309,7 +1355,7 @@ private:
|
||||||
write(" ");
|
write(" ");
|
||||||
indents.push(tok!"enum");
|
indents.push(tok!"enum");
|
||||||
writeToken();
|
writeToken();
|
||||||
if (!currentIs(tok!":") && !currentIs(tok!"{"))
|
if (hasCurrent && !currentIs(tok!":") && !currentIs(tok!"{"))
|
||||||
write(" ");
|
write(" ");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1333,7 +1379,7 @@ private:
|
||||||
goto default;
|
goto default;
|
||||||
case tok!"invariant":
|
case tok!"invariant":
|
||||||
writeToken();
|
writeToken();
|
||||||
if (currentIs(tok!"("))
|
if (hasCurrent && currentIs(tok!"("))
|
||||||
write(" ");
|
write(" ");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1457,7 +1503,8 @@ private:
|
||||||
break;
|
break;
|
||||||
case tok!".":
|
case tok!".":
|
||||||
regenLineBreakHintsIfNecessary(index);
|
regenLineBreakHintsIfNecessary(index);
|
||||||
immutable bool ufcsWrap = astInformation.ufcsHintLocations.canFindIndex(current.index);
|
immutable bool ufcsWrap = config.dfmt_reflow_property_chains == OptionalBoolean.t
|
||||||
|
&& astInformation.ufcsHintLocations.canFindIndex(current.index);
|
||||||
if (ufcsWrap || linebreakHints.canFind(index) || onNextLine
|
if (ufcsWrap || linebreakHints.canFind(index) || onNextLine
|
||||||
|| (linebreakHints.length == 0 && currentLineLength + nextTokenLength() > config.max_line_length))
|
|| (linebreakHints.length == 0 && currentLineLength + nextTokenLength() > config.max_line_length))
|
||||||
{
|
{
|
||||||
|
@ -1626,6 +1673,10 @@ private:
|
||||||
const commaLine = tokens[index].line;
|
const commaLine = tokens[index].line;
|
||||||
|
|
||||||
writeToken();
|
writeToken();
|
||||||
|
if (indents.topIsWrap && !indents.topIs(tok!","))
|
||||||
|
{
|
||||||
|
indents.pop;
|
||||||
|
}
|
||||||
if (!currentIs(tok!")") && !currentIs(tok!"]")
|
if (!currentIs(tok!")") && !currentIs(tok!"]")
|
||||||
&& !currentIs(tok!"}") && !currentIs(tok!"comment"))
|
&& !currentIs(tok!"}") && !currentIs(tok!"comment"))
|
||||||
{
|
{
|
||||||
|
@ -1644,6 +1695,10 @@ private:
|
||||||
{
|
{
|
||||||
pushWrapIndent();
|
pushWrapIndent();
|
||||||
writeToken();
|
writeToken();
|
||||||
|
if (indents.topIsWrap && !indents.topIs(tok!","))
|
||||||
|
{
|
||||||
|
indents.pop;
|
||||||
|
}
|
||||||
newline();
|
newline();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1703,8 +1758,6 @@ private:
|
||||||
import std.algorithm : max, canFind;
|
import std.algorithm : max, canFind;
|
||||||
import dfmt.editorconfig : OptionalBoolean;
|
import dfmt.editorconfig : OptionalBoolean;
|
||||||
|
|
||||||
parenDepthOnLine = 0;
|
|
||||||
|
|
||||||
if (currentIs(tok!"comment") && index > 0 && current.line == tokenEndLine(tokens[index - 1]))
|
if (currentIs(tok!"comment") && index > 0 && current.line == tokenEndLine(tokens[index - 1]))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1822,7 +1875,19 @@ private:
|
||||||
if (indents.topIs(tok!"]"))
|
if (indents.topIs(tok!"]"))
|
||||||
{
|
{
|
||||||
indents.pop();
|
indents.pop();
|
||||||
indentLevel = indents.indentLevel;
|
}
|
||||||
|
// Find the initial indentation of constructs like "if" and
|
||||||
|
// "foreach" without removing them from the stack, since they
|
||||||
|
// still can be used later to indent "else".
|
||||||
|
auto savedIndents = IndentStack(config);
|
||||||
|
while (indents.length >= 0 && indents.topIsTemp) {
|
||||||
|
savedIndents.push(indents.top, indents.topDetails);
|
||||||
|
indents.pop;
|
||||||
|
}
|
||||||
|
indentLevel = indents.indentLevel;
|
||||||
|
while (savedIndents.length > 0) {
|
||||||
|
indents.push(savedIndents.top, savedIndents.topDetails);
|
||||||
|
savedIndents.pop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (astInformation.attributeDeclarationLines.canFindIndex(current.line))
|
else if (astInformation.attributeDeclarationLines.canFindIndex(current.line))
|
||||||
|
@ -1853,6 +1918,7 @@ private:
|
||||||
}
|
}
|
||||||
indent();
|
indent();
|
||||||
}
|
}
|
||||||
|
parenDepthOnLine = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write(string str)
|
void write(string str)
|
||||||
|
|
|
@ -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 nothrow
|
Range path, const(C)[] pattern) @safe pure
|
||||||
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
|
||||||
|
|
|
@ -278,6 +278,12 @@ private:
|
||||||
|
|
||||||
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!"{"))
|
||||||
|
|
|
@ -92,12 +92,21 @@ 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":
|
case "keep_line_breaks":
|
||||||
optConfig.dfmt_keep_line_breaks = optVal;
|
optConfig.dfmt_keep_line_breaks = optVal;
|
||||||
break;
|
break;
|
||||||
case "single_indent":
|
case "single_indent":
|
||||||
optConfig.dfmt_single_indent = optVal;
|
optConfig.dfmt_single_indent = optVal;
|
||||||
break;
|
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");
|
||||||
}
|
}
|
||||||
|
@ -120,16 +129,19 @@ 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,
|
"keep_line_breaks", &handleBooleans,
|
||||||
"single_indent", &handleBooleans);
|
"single_indent", &handleBooleans,
|
||||||
|
"reflow_property_chains", &handleBooleans);
|
||||||
// dfmt on
|
// dfmt on
|
||||||
}
|
}
|
||||||
catch (GetOptException e)
|
catch (GetOptException e)
|
||||||
|
@ -334,13 +346,16 @@ Formatting Options:
|
||||||
--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
|
--single_indent
|
||||||
|
--reflow_property_chains
|
||||||
`,
|
`,
|
||||||
optionsToString!(typeof(Config.dfmt_template_constraint_style)));
|
optionsToString!(typeof(Config.dfmt_template_constraint_style)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
class C
|
||||||
|
{
|
||||||
|
void f()
|
||||||
|
{
|
||||||
|
if (true)
|
||||||
|
{
|
||||||
|
f(map.map.map.map.map.map.map.map.map.map.map.map.map.map.map.map
|
||||||
|
.map.map.map.map.map.map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
|
||||||
|
__FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
|
||||||
|
__FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __LINE__);
|
||||||
|
|
||||||
|
g(map && map && map && map && map && map && map && map && map && map && map
|
||||||
|
&& map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
|
||||||
|
__FILE__, __FILE__, __LINE__);
|
||||||
|
h(map || map || map || map || map || map || map || map || map || map || map
|
||||||
|
|| map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
|
||||||
|
__FILE__, __FILE__, __LINE__);
|
||||||
|
i(map + map + map + map + map + map + map + map + map + map + map + map + map
|
||||||
|
+ map + map + map + map + map, __FILE__, __FILE__, __FILE__,
|
||||||
|
__FILE__, __FILE__, __FILE__, __FILE__, __LINE__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
class C
|
||||||
|
{
|
||||||
|
void f()
|
||||||
|
{
|
||||||
|
if (true)
|
||||||
|
{
|
||||||
|
f(
|
||||||
|
array.map!(a => a.prop)
|
||||||
|
.array
|
||||||
|
.to!string,
|
||||||
|
__FILE__,
|
||||||
|
__LINE__);
|
||||||
|
|
||||||
|
g(
|
||||||
|
map &&
|
||||||
|
map,
|
||||||
|
__FILE__,
|
||||||
|
__LINE__);
|
||||||
|
h(
|
||||||
|
map ||
|
||||||
|
map,
|
||||||
|
__FILE__,
|
||||||
|
__LINE__);
|
||||||
|
i(
|
||||||
|
map
|
||||||
|
+ map,
|
||||||
|
__FILE__,
|
||||||
|
__LINE__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
alias u8 = ubyte
|
|
@ -0,0 +1,40 @@
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
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
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
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;
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
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];
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
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);
|
||||||
|
}
|
|
@ -4,3 +4,8 @@ unittest
|
||||||
x
|
x
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void f(T[] x,
|
||||||
|
const U y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
void main(string[] args)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < 10; ++i)
|
||||||
|
{
|
||||||
|
if(i == 9)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(i; 0 .. 9)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
--single_indent=true
|
|
@ -0,0 +1,60 @@
|
||||||
|
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__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
--single_indent=true
|
||||||
|
--keep_line_breaks=true
|
|
@ -0,0 +1,31 @@
|
||||||
|
class C
|
||||||
|
{
|
||||||
|
void f()
|
||||||
|
{
|
||||||
|
if (true)
|
||||||
|
{
|
||||||
|
f(
|
||||||
|
array.map!(a => a.prop)
|
||||||
|
.array
|
||||||
|
.to!string,
|
||||||
|
__FILE__,
|
||||||
|
__LINE__);
|
||||||
|
|
||||||
|
g(
|
||||||
|
map &&
|
||||||
|
map,
|
||||||
|
__FILE__,
|
||||||
|
__LINE__);
|
||||||
|
h(
|
||||||
|
map ||
|
||||||
|
map,
|
||||||
|
__FILE__,
|
||||||
|
__LINE__);
|
||||||
|
i(
|
||||||
|
map
|
||||||
|
+ map,
|
||||||
|
__FILE__,
|
||||||
|
__LINE__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
alias u8 = ubyte
|
|
@ -0,0 +1,38 @@
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
--keep_line_breaks=true
|
|
@ -0,0 +1,74 @@
|
||||||
|
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
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
--reflow_property_chains=false
|
|
@ -0,0 +1,14 @@
|
||||||
|
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;
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
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];
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
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);
|
||||||
|
}
|
|
@ -4,3 +4,8 @@ unittest
|
||||||
x
|
x
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void f(T[] x,
|
||||||
|
const U y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
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__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
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__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
alias u8 = ubyte
|
|
@ -0,0 +1,38 @@
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
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 {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
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;
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
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];
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
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);
|
||||||
|
}
|
|
@ -3,3 +3,8 @@ unittest {
|
||||||
x
|
x
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void f(T[] x,
|
||||||
|
const U y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
void main(string[] args)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < 10; ++i) {
|
||||||
|
if(i == 9)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while(false) {
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(i; 0 .. 9) {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
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__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
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__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
alias u8 = ubyte
|
|
@ -0,0 +1,36 @@
|
||||||
|
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() {
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
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 {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
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;
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
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];
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
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);
|
||||||
|
}
|
|
@ -3,3 +3,7 @@ unittest {
|
||||||
x
|
x
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void f(T[] x,
|
||||||
|
const U y) {
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
void main(string[] args) {
|
||||||
|
for(int i = 0; i < 10; ++i) {
|
||||||
|
if(i == 9)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while(false) {
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(i; 0 .. 9) {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
--space_after_keywords=false
|
|
@ -0,0 +1,10 @@
|
||||||
|
void main(string[] args)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 10; ++i) {
|
||||||
|
if (i == 9) break;
|
||||||
|
}
|
||||||
|
while (false) {}
|
||||||
|
|
||||||
|
foreach (i; 0 .. 9) {
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue