Compare commits
No commits in common. "master" and "v0.15.0-beta.2" have entirely different histories.
master
...
v0.15.0-be
|
@ -0,0 +1,15 @@
|
||||||
|
#!/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
|
|
@ -0,0 +1,95 @@
|
||||||
|
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,5 +1,4 @@
|
||||||
# dfmt [](https://github.com/dlang-community/dfmt/actions?query=workflow%3A%22D%22)
|
# dfmt [](https://travis-ci.org/dlang-community/dfmt)
|
||||||
|
|
||||||
**dfmt** is a formatter for D source code
|
**dfmt** is a formatter for D source code
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
@ -52,15 +51,11 @@ 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
|
||||||
```
|
```
|
||||||
|
@ -120,11 +115,8 @@ 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.19.2 <1.0.0"
|
"libdparse": ">=0.14.0 <1.0.0"
|
||||||
},
|
},
|
||||||
"targetPath" : "bin/",
|
"targetPath" : "bin/",
|
||||||
"targetName" : "dfmt",
|
"targetName" : "dfmt",
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit fe6d1e38fb4fc04323170389cfec67ed7fd4e24a
|
Subproject commit 7112880dae3f25553d96dae53a445c16261de7f9
|
60
makefile
60
makefile
|
@ -1,63 +1,53 @@
|
||||||
PREFIX = /usr/local
|
|
||||||
|
|
||||||
SRC := $(shell find src -name "*.d") \
|
SRC := $(shell find src -name "*.d") \
|
||||||
$(shell find libdparse/src -name "*.d")
|
$(shell find libdparse/src -name "*.d") \
|
||||||
IMPORTS := -Ilibdparse/src -Isrc -Jbin
|
$(shell find stdx-allocator/source -name "*.d")
|
||||||
|
INCLUDE_PATHS := -Ilibdparse/src -Istdx-allocator/source -Isrc -Jbin
|
||||||
|
DMD_COMMON_FLAGS := -dip25 -w $(INCLUDE_PATHS)
|
||||||
|
DMD_DEBUG_FLAGS := -debug -g $(DMD_COMMON_FLAGS)
|
||||||
|
DMD_FLAGS := -O -inline $(DMD_COMMON_FLAGS)
|
||||||
|
DMD_TEST_FLAGS := -unittest -g $(DMD_COMMON_FLAGS)
|
||||||
|
LDC_FLAGS := -g -w -oq $(INCLUDE_PATHS)
|
||||||
|
GDC_FLAGS := -g -w -oq $(INCLUDE_PATHS)
|
||||||
|
override DMD_FLAGS += $(DFLAGS)
|
||||||
|
override LDC_FLAGS += $(DFLAGS)
|
||||||
|
override GDC_FLAGS += $(DFLAGS)
|
||||||
DC ?= dmd
|
DC ?= dmd
|
||||||
LDC ?= ldc2
|
LDC ?= ldc2
|
||||||
GDC ?= gdc
|
GDC ?= gdc
|
||||||
|
|
||||||
DMD_COMMON_FLAGS := -w $(IMPORTS)
|
.PHONY: dmd ldc gdc test
|
||||||
DMD_DEBUG_FLAGS := -debug -g $(DMD_COMMON_FLAGS)
|
|
||||||
DMD_FLAGS := -O -inline $(DMD_COMMON_FLAGS)
|
|
||||||
DMD_TEST_FLAGS := -unittest -g $(DMD_COMMON_FLAGS)
|
|
||||||
LDC_FLAGS := -g -w -oq $(IMPORTS)
|
|
||||||
GDC_FLAGS := -g -w -oq $(IMPORTS)
|
|
||||||
override DMD_FLAGS += $(DFLAGS)
|
|
||||||
override LDC_FLAGS += $(DFLAGS)
|
|
||||||
override GDC_FLAGS += $(DFLAGS)
|
|
||||||
|
|
||||||
.PHONY: all clean install debug dmd ldc gdc pkg release test
|
|
||||||
|
|
||||||
all: bin/dfmt
|
|
||||||
|
|
||||||
bin/githash.txt:
|
|
||||||
mkdir -p bin
|
|
||||||
git describe --tags > bin/githash.txt
|
|
||||||
|
|
||||||
dmd: bin/dfmt
|
dmd: bin/dfmt
|
||||||
|
|
||||||
ldc: bin/githash.txt
|
githash:
|
||||||
|
mkdir -p bin
|
||||||
|
git describe --tags > bin/githash.txt
|
||||||
|
|
||||||
|
ldc: githash
|
||||||
$(LDC) $(SRC) $(LDC_FLAGS) -ofbin/dfmt
|
$(LDC) $(SRC) $(LDC_FLAGS) -ofbin/dfmt
|
||||||
-rm -f *.o
|
-rm -f *.o
|
||||||
|
|
||||||
gdc: bin/githash.txt
|
gdc:githash
|
||||||
$(GDC) $(SRC) $(GDC_FLAGS) -obin/dfmt
|
$(GDC) $(SRC) $(GDC_FLAGS) -obin/dfmt
|
||||||
|
|
||||||
test: debug
|
test: debug
|
||||||
cd tests && ./test.d
|
cd tests && ./test.d
|
||||||
|
|
||||||
bin/dfmt-test: bin/githash.txt $(SRC)
|
bin/dfmt-test: githash $(SRC)
|
||||||
$(DC) $(DMD_TEST_FLAGS) $(filter %.d,$^) -of$@
|
$(DC) $(DMD_TEST_FLAGS) $^ -of$@
|
||||||
|
|
||||||
bin/dfmt: bin/githash.txt $(SRC)
|
bin/dfmt: githash $(SRC)
|
||||||
$(DC) $(DMD_FLAGS) $(filter %.d,$^) -of$@
|
$(DC) $(DMD_FLAGS) $(filter %.d,$^) -of$@
|
||||||
|
|
||||||
debug: bin/githash.txt $(SRC)
|
debug: githash $(SRC)
|
||||||
$(DC) $(DMD_DEBUG_FLAGS) $(filter %.d,$^) -ofbin/dfmt
|
$(DC) $(DMD_DEBUG_FLAGS) $(filter %.d,$^) -ofbin/dfmt
|
||||||
|
|
||||||
pkg: dmd
|
pkg: dmd
|
||||||
$(MAKE) -f makd/Makd.mak pkg
|
$(MAKE) -f makd/Makd.mak pkg
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) bin/dfmt bin/dfmt-test bin/githash.txt
|
$(RM) bin/dfmt
|
||||||
|
|
||||||
install:
|
|
||||||
chmod +x bin/dfmt
|
|
||||||
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
|
||||||
cp -f bin/dfmt $(DESTDIR)$(PREFIX)/bin/dfmt
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
./release.sh
|
./release.sh
|
||||||
$(MAKE) bin/githash.txt
|
githash
|
||||||
|
|
|
@ -63,8 +63,6 @@ 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
|
||||||
|
@ -137,12 +135,6 @@ 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
|
||||||
|
@ -446,43 +438,6 @@ final class FormatVisitor : ASTVisitor
|
||||||
outStatement.accept(this);
|
outStatement.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
override void visit(const TernaryExpression ternaryExpression)
|
|
||||||
{
|
|
||||||
astInformation.ternaryColonLocations ~= ternaryExpression.colon.index;
|
|
||||||
ternaryExpression.accept(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
override void visit(const FunctionCallExpression functionCall)
|
|
||||||
{
|
|
||||||
// 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,12 +63,6 @@ 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;
|
||||||
|
|
||||||
|
@ -99,8 +93,6 @@ 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -247,9 +247,9 @@ private:
|
||||||
else if (currentIs(tok!"return"))
|
else if (currentIs(tok!"return"))
|
||||||
{
|
{
|
||||||
writeToken();
|
writeToken();
|
||||||
if (hasCurrent && (!currentIs(tok!";") && !currentIs(tok!")") && !currentIs(tok!"{")
|
if (!currentIs(tok!";") && !currentIs(tok!")") && !currentIs(tok!"{")
|
||||||
&& !currentIs(tok!"in") && !currentIs(tok!"out") && !currentIs(tok!"do")
|
&& !currentIs(tok!"in") && !currentIs(tok!"out") && !currentIs(tok!"do")
|
||||||
&& tokens[index].text != "body"))
|
&& (hasCurrent && tokens[index].text != "body"))
|
||||||
write(" ");
|
write(" ");
|
||||||
}
|
}
|
||||||
else if (currentIs(tok!"with"))
|
else if (currentIs(tok!"with"))
|
||||||
|
@ -257,20 +257,16 @@ 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();
|
||||||
if (config.dfmt_space_after_keywords) {
|
write(" ");
|
||||||
write(" ");
|
if (currentIs(tok!"("))
|
||||||
}
|
|
||||||
if (hasCurrent && currentIs(tok!"("))
|
|
||||||
writeParens(false);
|
writeParens(false);
|
||||||
if (hasCurrent && !currentIs(tok!"switch") && !currentIs(tok!"with")
|
if (!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 (hasCurrent && !currentIs(tok!"{"))
|
else if (!currentIs(tok!"{"))
|
||||||
{
|
|
||||||
write(" ");
|
write(" ");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (currentIs(tok!"switch"))
|
else if (currentIs(tok!"switch"))
|
||||||
{
|
{
|
||||||
|
@ -355,7 +351,7 @@ private:
|
||||||
else if (isBasicType(current.type))
|
else if (isBasicType(current.type))
|
||||||
{
|
{
|
||||||
writeToken();
|
writeToken();
|
||||||
if (hasCurrent && (currentIs(tok!"identifier") || isKeyword(current.type) || inAsm))
|
if (currentIs(tok!"identifier") || isKeyword(current.type) || inAsm)
|
||||||
write(" ");
|
write(" ");
|
||||||
}
|
}
|
||||||
else if (isOperator(current.type))
|
else if (isOperator(current.type))
|
||||||
|
@ -724,12 +720,6 @@ 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)
|
||||||
|
@ -835,13 +825,12 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -857,17 +846,11 @@ private:
|
||||||
newline();
|
newline();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (indents.topIs(tok!"]") && !isTernary) // Associative array
|
else if (indents.topIs(tok!"]")) // 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))
|
||||||
|
@ -1060,21 +1043,6 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -1144,10 +1112,7 @@ private:
|
||||||
indents.pop();
|
indents.pop();
|
||||||
indents.push(tok!"switch");
|
indents.push(tok!"switch");
|
||||||
writeToken(); // switch
|
writeToken(); // switch
|
||||||
if (config.dfmt_space_after_keywords)
|
write(" ");
|
||||||
{
|
|
||||||
write(" ");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void formatBlockHeader()
|
void formatBlockHeader()
|
||||||
|
@ -1178,26 +1143,16 @@ private:
|
||||||
|
|
||||||
if (currentIs(tok!"("))
|
if (currentIs(tok!"("))
|
||||||
{
|
{
|
||||||
if (config.dfmt_space_after_keywords)
|
write(" ");
|
||||||
{
|
|
||||||
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!";"))
|
||||||
|
@ -1278,7 +1233,7 @@ private:
|
||||||
break;
|
break;
|
||||||
case tok!"cast":
|
case tok!"cast":
|
||||||
writeToken();
|
writeToken();
|
||||||
if (hasCurrent && currentIs(tok!"("))
|
if (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":
|
||||||
|
@ -1290,14 +1245,14 @@ private:
|
||||||
write(" ");
|
write(" ");
|
||||||
}
|
}
|
||||||
writeToken();
|
writeToken();
|
||||||
if (hasCurrent && !currentIs(tok!"{") && !currentIs(tok!"comment"))
|
if (!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 (hasCurrent && !currentIs(tok!"{"))
|
if (!currentIs(tok!"{"))
|
||||||
newline();
|
newline();
|
||||||
break;
|
break;
|
||||||
case tok!"identifier":
|
case tok!"identifier":
|
||||||
|
@ -1322,8 +1277,6 @@ 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)
|
||||||
|
@ -1336,12 +1289,12 @@ private:
|
||||||
tok!"}", tok!"=", tok!"&&", tok!"||") && !peekBackIsKeyword())
|
tok!"}", tok!"=", tok!"&&", tok!"||") && !peekBackIsKeyword())
|
||||||
write(" ");
|
write(" ");
|
||||||
writeToken();
|
writeToken();
|
||||||
if (hasCurrent && !currentIs(tok!"(") && !currentIs(tok!"{") && !currentIs(tok!"comment"))
|
if (!currentIs(tok!"(") && !currentIs(tok!"{") && !currentIs(tok!"comment"))
|
||||||
write(" ");
|
write(" ");
|
||||||
break;
|
break;
|
||||||
case tok!"case":
|
case tok!"case":
|
||||||
writeToken();
|
writeToken();
|
||||||
if (hasCurrent && !currentIs(tok!";"))
|
if (!currentIs(tok!";"))
|
||||||
write(" ");
|
write(" ");
|
||||||
break;
|
break;
|
||||||
case tok!"enum":
|
case tok!"enum":
|
||||||
|
@ -1355,7 +1308,7 @@ private:
|
||||||
write(" ");
|
write(" ");
|
||||||
indents.push(tok!"enum");
|
indents.push(tok!"enum");
|
||||||
writeToken();
|
writeToken();
|
||||||
if (hasCurrent && !currentIs(tok!":") && !currentIs(tok!"{"))
|
if (!currentIs(tok!":") && !currentIs(tok!"{"))
|
||||||
write(" ");
|
write(" ");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1379,7 +1332,7 @@ private:
|
||||||
goto default;
|
goto default;
|
||||||
case tok!"invariant":
|
case tok!"invariant":
|
||||||
writeToken();
|
writeToken();
|
||||||
if (hasCurrent && currentIs(tok!"("))
|
if (currentIs(tok!"("))
|
||||||
write(" ");
|
write(" ");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1503,8 +1456,7 @@ private:
|
||||||
break;
|
break;
|
||||||
case tok!".":
|
case tok!".":
|
||||||
regenLineBreakHintsIfNecessary(index);
|
regenLineBreakHintsIfNecessary(index);
|
||||||
immutable bool ufcsWrap = config.dfmt_reflow_property_chains == OptionalBoolean.t
|
immutable bool ufcsWrap = astInformation.ufcsHintLocations.canFindIndex(current.index);
|
||||||
&& 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))
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ import std.path : filenameCharCmp, isDirSeparator;
|
||||||
// * changes meaning to match all characters except '/'
|
// * changes meaning to match all characters except '/'
|
||||||
// ** added to take over the old meaning of *
|
// ** added to take over the old meaning of *
|
||||||
bool globMatchEditorConfig(CaseSensitive cs = CaseSensitive.osDefault, C, Range)(
|
bool globMatchEditorConfig(CaseSensitive cs = CaseSensitive.osDefault, C, Range)(
|
||||||
Range path, const(C)[] pattern) @safe pure
|
Range path, const(C)[] pattern) @safe pure nothrow
|
||||||
if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range)
|
if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range)
|
||||||
&& isSomeChar!C && is(Unqual!C == Unqual!(ElementEncodingType!Range)))
|
&& isSomeChar!C && is(Unqual!C == Unqual!(ElementEncodingType!Range)))
|
||||||
in
|
in
|
||||||
|
|
|
@ -92,21 +92,12 @@ 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");
|
||||||
}
|
}
|
||||||
|
@ -129,19 +120,16 @@ 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)
|
||||||
|
@ -346,16 +334,13 @@ 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)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
alias u8 = ubyte
|
|
|
@ -1,40 +0,0 @@
|
||||||
struct S1
|
|
||||||
{
|
|
||||||
ulong x;
|
|
||||||
ulong y;
|
|
||||||
ulong function(ulong) f;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct S2
|
|
||||||
{
|
|
||||||
ulong x;
|
|
||||||
ulong y;
|
|
||||||
ulong z;
|
|
||||||
ulong w;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Example 1
|
|
||||||
// Anonymous function in struct, long struct initializer
|
|
||||||
|
|
||||||
immutable S1 s1 = {
|
|
||||||
1111111111111111111, 1111111111111111111, (x) { return x + 1111; },
|
|
||||||
};
|
|
||||||
|
|
||||||
void f1()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Example 2
|
|
||||||
// Anonymous function anywhere, long struct initializer
|
|
||||||
|
|
||||||
int function(int) f2 = (x) { return x + 1111; };
|
|
||||||
|
|
||||||
immutable S2 s = {
|
|
||||||
1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111,
|
|
||||||
};
|
|
||||||
|
|
||||||
void f2()
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
string f()
|
|
||||||
{
|
|
||||||
return duration.total!"seconds".to!string;
|
|
||||||
}
|
|
||||||
|
|
||||||
string g()
|
|
||||||
{
|
|
||||||
return duration.total!"seconds"().to!string;
|
|
||||||
}
|
|
||||||
|
|
||||||
string h()
|
|
||||||
{
|
|
||||||
return duration.total!"seconds"().to!string.to!string.to!string.to!string.to!string.to!string
|
|
||||||
.to!string.to!string.to!string;
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
void f()
|
|
||||||
{
|
|
||||||
auto t = true ? 1 : 0;
|
|
||||||
auto a = [true ? 1 : 0];
|
|
||||||
auto aa1 = [0: true ? 1 : 0];
|
|
||||||
auto aa2 = [0: true ? (false ? 1 : 2) : 3];
|
|
||||||
auto aa3 = [0: true ? false ? 1 : 2 : 3];
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
void temp(int v1, int v2)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int f(int i)
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct S
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
}
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
temp(v1: 1, v2: 2);
|
|
||||||
temp(v1: 1, v2: 2,);
|
|
||||||
|
|
||||||
auto s = S(5, j: 3);
|
|
||||||
|
|
||||||
temp(v1: 1, v2: f(i: 2));
|
|
||||||
|
|
||||||
temp(v1: true ? i : false ? 2 : f(i: 3), v2: 4);
|
|
||||||
|
|
||||||
temp(v1: () { S s = S(i: 5); return s.i; }, v2: 1);
|
|
||||||
}
|
|
|
@ -4,8 +4,3 @@ unittest
|
||||||
x
|
x
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void f(T[] x,
|
|
||||||
const U y)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
void main(string[] args)
|
|
||||||
{
|
|
||||||
for(int i = 0; i < 10; ++i)
|
|
||||||
{
|
|
||||||
if(i == 9)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
while(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(i; 0 .. 9)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
alias u8 = ubyte
|
|
|
@ -1,38 +0,0 @@
|
||||||
struct S1
|
|
||||||
{
|
|
||||||
ulong x;
|
|
||||||
ulong y;
|
|
||||||
ulong function(ulong)f;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct S2
|
|
||||||
{
|
|
||||||
ulong x;
|
|
||||||
ulong y;
|
|
||||||
ulong z;
|
|
||||||
ulong w;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Example 1
|
|
||||||
// Anonymous function in struct, long struct initializer
|
|
||||||
|
|
||||||
immutable S1 s1 = {
|
|
||||||
1111111111111111111, 1111111111111111111, (x) { return x + 1111; },};
|
|
||||||
|
|
||||||
void f1()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Example 2
|
|
||||||
// Anonymous function anywhere, long struct initializer
|
|
||||||
|
|
||||||
int function(int) f2 = (x) { return x + 1111; };
|
|
||||||
|
|
||||||
immutable S2 s = {
|
|
||||||
1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111,};
|
|
||||||
|
|
||||||
void f2()
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
--reflow_property_chains=false
|
|
|
@ -1,14 +0,0 @@
|
||||||
string f()
|
|
||||||
{
|
|
||||||
return duration.total!"seconds".to!string;
|
|
||||||
}
|
|
||||||
|
|
||||||
string g()
|
|
||||||
{
|
|
||||||
return duration.total!"seconds"().to!string;
|
|
||||||
}
|
|
||||||
|
|
||||||
string h()
|
|
||||||
{
|
|
||||||
return duration.total!"seconds"().to!string.to!string.to!string.to!string.to!string.to!string.to!string.to!string.to!string;
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
void f()
|
|
||||||
{
|
|
||||||
auto t = true ? 1 : 0;
|
|
||||||
auto a = [true ? 1: 0];
|
|
||||||
auto aa1 = [0: true ? 1: 0];
|
|
||||||
auto aa2 = [0: true ? (false ? 1: 2): 3];
|
|
||||||
auto aa3 = [0: true ? false ? 1: 2: 3];
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
void temp(int v1, int v2)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int f(int i)
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct S
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
}
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
temp(v1: 1, v2: 2);
|
|
||||||
temp(
|
|
||||||
v1: 1,
|
|
||||||
v2: 2,
|
|
||||||
);
|
|
||||||
|
|
||||||
auto s = S(5, j: 3);
|
|
||||||
|
|
||||||
temp(v1: 1, v2: f(i: 2));
|
|
||||||
|
|
||||||
temp(v1: true ? i : false ? 2 : f(i: 3), v2: 4);
|
|
||||||
|
|
||||||
temp(v1: () { S s = S(i: 5); return s.i; }, v2: 1);
|
|
||||||
}
|
|
|
@ -4,8 +4,3 @@ unittest
|
||||||
x
|
x
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void f(T[] x,
|
|
||||||
const U y)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
alias u8 = ubyte
|
|
|
@ -1,38 +0,0 @@
|
||||||
struct S1 {
|
|
||||||
ulong x;
|
|
||||||
ulong y;
|
|
||||||
ulong function(ulong) f;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct S2 {
|
|
||||||
ulong x;
|
|
||||||
ulong y;
|
|
||||||
ulong z;
|
|
||||||
ulong w;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Example 1
|
|
||||||
// Anonymous function in struct, long struct initializer
|
|
||||||
|
|
||||||
immutable S1 s1 = {
|
|
||||||
1111111111111111111, 1111111111111111111, (x) { return x + 1111; },
|
|
||||||
};
|
|
||||||
|
|
||||||
void f1()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Example 2
|
|
||||||
// Anonymous function anywhere, long struct initializer
|
|
||||||
|
|
||||||
int function(int) f2 = (x) { return x + 1111; };
|
|
||||||
|
|
||||||
immutable S2 s = {
|
|
||||||
1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111,
|
|
||||||
};
|
|
||||||
|
|
||||||
void f2()
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
string f()
|
|
||||||
{
|
|
||||||
return duration.total!"seconds".to!string;
|
|
||||||
}
|
|
||||||
|
|
||||||
string g()
|
|
||||||
{
|
|
||||||
return duration.total!"seconds"().to!string;
|
|
||||||
}
|
|
||||||
|
|
||||||
string h()
|
|
||||||
{
|
|
||||||
return duration.total!"seconds"().to!string.to!string.to!string.to!string.to!string.to!string
|
|
||||||
.to!string.to!string.to!string;
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
void f()
|
|
||||||
{
|
|
||||||
auto t = true ? 1 : 0;
|
|
||||||
auto a = [true ? 1 : 0];
|
|
||||||
auto aa1 = [0: true ? 1 : 0];
|
|
||||||
auto aa2 = [0: true ? (false ? 1 : 2) : 3];
|
|
||||||
auto aa3 = [0: true ? false ? 1 : 2 : 3];
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
void temp(int v1, int v2)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int f(int i)
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct S {
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
}
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
temp(v1: 1, v2: 2);
|
|
||||||
temp(v1: 1, v2: 2,);
|
|
||||||
|
|
||||||
auto s = S(5, j: 3);
|
|
||||||
|
|
||||||
temp(v1: 1, v2: f(i: 2));
|
|
||||||
|
|
||||||
temp(v1: true ? i : false ? 2 : f(i: 3), v2: 4);
|
|
||||||
|
|
||||||
temp(v1: () { S s = S(i: 5); return s.i; }, v2: 1);
|
|
||||||
}
|
|
|
@ -3,8 +3,3 @@ unittest {
|
||||||
x
|
x
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void f(T[] x,
|
|
||||||
const U y)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
void main(string[] args)
|
|
||||||
{
|
|
||||||
for(int i = 0; i < 10; ++i) {
|
|
||||||
if(i == 9)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
while(false) {
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(i; 0 .. 9) {
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
alias u8 = ubyte
|
|
|
@ -1,36 +0,0 @@
|
||||||
struct S1 {
|
|
||||||
ulong x;
|
|
||||||
ulong y;
|
|
||||||
ulong function(ulong) f;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct S2 {
|
|
||||||
ulong x;
|
|
||||||
ulong y;
|
|
||||||
ulong z;
|
|
||||||
ulong w;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Example 1
|
|
||||||
// Anonymous function in struct, long struct initializer
|
|
||||||
|
|
||||||
immutable S1 s1 = {
|
|
||||||
1111111111111111111, 1111111111111111111, (x) { return x + 1111; },
|
|
||||||
};
|
|
||||||
|
|
||||||
void f1() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Example 2
|
|
||||||
// Anonymous function anywhere, long struct initializer
|
|
||||||
|
|
||||||
int function(int) f2 = (x) { return x + 1111; };
|
|
||||||
|
|
||||||
immutable S2 s = {
|
|
||||||
1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111,
|
|
||||||
};
|
|
||||||
|
|
||||||
void f2() {
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
string f() {
|
|
||||||
return duration.total!"seconds".to!string;
|
|
||||||
}
|
|
||||||
|
|
||||||
string g() {
|
|
||||||
return duration.total!"seconds"().to!string;
|
|
||||||
}
|
|
||||||
|
|
||||||
string h() {
|
|
||||||
return duration.total!"seconds"().to!string.to!string.to!string.to!string.to!string.to!string
|
|
||||||
.to!string.to!string.to!string;
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
void f() {
|
|
||||||
auto t = true ? 1 : 0;
|
|
||||||
auto a = [true ? 1 : 0];
|
|
||||||
auto aa1 = [0: true ? 1 : 0];
|
|
||||||
auto aa2 = [0: true ? (false ? 1 : 2) : 3];
|
|
||||||
auto aa3 = [0: true ? false ? 1 : 2 : 3];
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
void temp(int v1, int v2) {
|
|
||||||
}
|
|
||||||
|
|
||||||
int f(int i) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct S {
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
}
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
temp(v1: 1, v2: 2);
|
|
||||||
temp(v1: 1, v2: 2,);
|
|
||||||
|
|
||||||
auto s = S(5, j: 3);
|
|
||||||
|
|
||||||
temp(v1: 1, v2: f(i: 2));
|
|
||||||
|
|
||||||
temp(v1: true ? i : false ? 2 : f(i: 3), v2: 4);
|
|
||||||
|
|
||||||
temp(v1: () { S s = S(i: 5); return s.i; }, v2: 1);
|
|
||||||
}
|
|
|
@ -3,7 +3,3 @@ unittest {
|
||||||
x
|
x
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void f(T[] x,
|
|
||||||
const U y) {
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
void main(string[] args) {
|
|
||||||
for(int i = 0; i < 10; ++i) {
|
|
||||||
if(i == 9)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
while(false) {
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(i; 0 .. 9) {
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
--space_after_keywords=false
|
|
|
@ -1,10 +0,0 @@
|
||||||
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