Keep line break after function attributes

Fixes #504.
This commit is contained in:
Eugen Wissner 2020-09-01 17:34:48 +02:00 committed by The Dlang Bot
parent d100c40dab
commit 94351246f6
5 changed files with 130 additions and 26 deletions

View File

@ -713,13 +713,13 @@ private:
{
writeToken();
if (spaceAfterParens || parenDepth > 0)
write(" ");
writeSpace();
}
else if ((peekIsKeyword() || peekIs(tok!"@")) && spaceAfterParens
&& !peekIs(tok!"in") && !peekIs(tok!"is") && !peekIs(tok!"if"))
{
writeToken();
write(" ");
writeSpace();
}
else
writeToken();
@ -769,14 +769,7 @@ private:
|| currentIs(tok!"identifier"))
&& !currentIsIndentedTemplateConstraint())
{
if (onNextLine)
{
newline();
}
else
{
write(" ");
}
writeSpace();
}
}
@ -1289,14 +1282,7 @@ private:
default:
if (peekBackIs(tok!"identifier"))
{
if (onNextLine)
{
newline();
}
else
{
write(" ");
}
writeSpace();
}
if (index + 1 < tokens.length)
{
@ -1310,14 +1296,7 @@ private:
writeToken();
if (!currentIsIndentedTemplateConstraint())
{
if (onNextLine)
{
newline();
}
else
{
write(" ");
}
writeSpace();
}
}
}
@ -1943,6 +1922,18 @@ private:
indents.push(type, detail);
}
void writeSpace()
{
if (onNextLine)
{
newline();
}
else
{
write(" ");
}
}
const pure @safe @nogc:
size_t expressionEndIndex(size_t i, bool matchComma = false) nothrow

View File

@ -0,0 +1,40 @@
deprecated("foo")
void test()
{
}
package(foo)
void bar()
{
}
@uda()
void baz()
{
}
deprecated
deprecated_()
{
}
@uda
void uda_()
{
}
@property
void property()
{
}
deprecated("Reason") @uda
void propertyuda()
{
}
deprecated("Reason")
@uda
void udaproperty()
{
}

1
tests/issue0504.args Normal file
View File

@ -0,0 +1 @@
--keep_line_breaks=true

40
tests/issue0504.d Normal file
View File

@ -0,0 +1,40 @@
deprecated("foo")
void test()
{
}
package(foo)
void bar()
{
}
@uda()
void baz()
{
}
deprecated
deprecated_()
{
}
@uda
void uda_()
{
}
@property
void property()
{
}
deprecated("Reason") @uda
void propertyuda()
{
}
deprecated("Reason")
@uda
void udaproperty()
{
}

View File

@ -0,0 +1,32 @@
deprecated("foo")
void test() {
}
package(foo)
void bar() {
}
@uda()
void baz() {
}
deprecated
deprecated_() {
}
@uda
void uda_() {
}
@property
void property() {
}
deprecated("Reason") @uda
void propertyuda() {
}
deprecated("Reason")
@uda
void udaproperty() {
}