Indentation rework

This commit is contained in:
Hackerpilot 2016-01-19 03:58:19 -08:00
parent bf0843f321
commit 7ec932a1e3
27 changed files with 76 additions and 85 deletions

View File

@ -1271,6 +1271,12 @@ private:
indentLevel = config.dfmt_align_switch_statements indentLevel = config.dfmt_align_switch_statements
== OptionalBoolean.t ? l : indents.indentLevel; == OptionalBoolean.t ? l : indents.indentLevel;
} }
else if (currentIs(tok!")"))
{
if (indents.topIs(tok!"("))
indents.pop();
indentLevel = indents.indentLevel;
}
else if (currentIs(tok!"{")) else if (currentIs(tok!"{"))
{ {
indents.popWrapIndents(); indents.popWrapIndents();
@ -1326,7 +1332,7 @@ private:
if (indents.topIsTemp() && (peekBackIsOneOf(true, tok!"}", if (indents.topIsTemp() && (peekBackIsOneOf(true, tok!"}",
tok!";") && indents.top != tok!";")) tok!";") && indents.top != tok!";"))
indents.popTempIndents(); indents.popTempIndents();
indentLevel = indents.indentLevel + parenDepth; indentLevel = indents.indentLevel;
} }
indent(); indent();
} }

View File

@ -169,13 +169,14 @@ private:
{ {
if (arr[i] == tok!"]") if (arr[i] == tok!"]")
continue; continue;
immutable bool currentIsTemp = isTempIndent(arr[i]); immutable currentIsNonWrapTemp = !isWrapIndent(arr[i]) && isTempIndent(arr[i]);
immutable bool nextIsTemp = isTempIndent(arr[i + 1]); immutable nextIsParenOrSwitch = arr[i + 1] == tok!"("
immutable bool nextIsSwitch = arr[i + 1] == tok!"switch"; || arr[i + 1] == tok!"switch" || arr[i + 1] == tok!"{";
immutable bool nextIsWrap = isWrapIndent(arr[i + 1]); if (currentIsNonWrapTemp && nextIsParenOrSwitch)
if (((nextIsSwitch || nextIsWrap) && currentIsTemp))
continue; continue;
} }
if (arr[i] == tok!"!")
size++;
size++; size++;
} }
return size; return size;

View File

@ -1,8 +1,9 @@
struct Test struct Test
{ {
this(string name, string[] aliasList, string briefDescription, string examDesc, this(string name, string[] aliasList, string briefDescription, string examDesc,
string onOpenDesc, string openDesc, string onCloseDesc, string closeDesc, string onOpenDesc, string openDesc, string onCloseDesc,
Flag!"canOpen" canOpen, Flag!"canClose" canClose, Flag!"isOpen" isOpen) string closeDesc, Flag!"canOpen" canOpen, Flag!"canClose" canClose,
Flag!"isOpen" isOpen)
{ {
} }
} }

View File

@ -1,6 +1,7 @@
struct Test { struct Test {
this(string name, string[] aliasList, string briefDescription, string examDesc, this(string name, string[] aliasList, string briefDescription, string examDesc,
string onOpenDesc, string openDesc, string onCloseDesc, string closeDesc, string onOpenDesc, string openDesc, string onCloseDesc,
Flag!"canOpen" canOpen, Flag!"canClose" canClose, Flag!"isOpen" isOpen) { string closeDesc, Flag!"canOpen" canOpen, Flag!"canClose" canClose,
Flag!"isOpen" isOpen) {
} }
} }

View File

@ -1,18 +0,0 @@
#!/usr/bin/env bash
set -e
for braceStyle in allman otbs
do
for source in *.d
do
echo "${source}.ref" "${braceStyle}/${source}.out"
argsFile=$(basename ${source} .d).args
if [ -e ${argsFile} ]; then
args=$(cat ${argsFile})
else
args=
fi
../bin/dfmt --brace_style=${braceStyle} ${args} "${source}" > "${braceStyle}/${source}.out"
diff -u "${braceStyle}/${source}.ref" "${braceStyle}/${source}.out"
done
done