Skip to content

Commit 3ac105d

Browse files
authored
Merge pull request #513 from prettier-solidity/switch_case
dedenting cases in Switch statement
2 parents 5f2fac6 + 731a675 commit 3ac105d

3 files changed

Lines changed: 22 additions & 27 deletions

File tree

src/nodes/AssemblySwitch.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
const {
22
doc: {
3-
builders: { hardline }
3+
builders: { hardline, join }
44
}
55
} = require('prettier/standalone');
66

7-
const printSeparatedList = require('./print-separated-list');
8-
97
const AssemblySwitch = {
108
print: ({ path, print }) => [
119
'switch ',
1210
path.call(print, 'expression'),
13-
printSeparatedList(path.map(print, 'cases'), {
14-
firstSeparator: hardline,
15-
separator: hardline,
16-
lastSeparator: ''
17-
})
11+
hardline,
12+
join(hardline, path.map(print, 'cases'))
1813
]
1914
};
2015

tests/Assembly/__snapshots__/jsfmt.spec.js.snap

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,18 @@ contract Assembly {
200200
function caseAssembly() {
201201
assembly {
202202
switch value
203-
case 0 {
204-
mstore(
205-
0,
206-
0x0000000000000000000000000000000000000000000000000000000000000000
207-
)
208-
}
209-
case 1 {
210-
mstore(
211-
0,
212-
0x1111111111111111111111111111111111111111111111111111111111111111
213-
)
214-
}
203+
case 0 {
204+
mstore(
205+
0,
206+
0x0000000000000000000000000000000000000000000000000000000000000000
207+
)
208+
}
209+
case 1 {
210+
mstore(
211+
0,
212+
0x1111111111111111111111111111111111111111111111111111111111111111
213+
)
214+
}
215215
}
216216
}
217217

tests/Proxy/__snapshots__/jsfmt.spec.js.snap

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ contract Proxy {
108108
returndatacopy(0, 0, returndatasize)
109109
110110
switch result
111-
// delegatecall returns 0 on error.
112-
case 0 {
113-
revert(0, returndatasize)
114-
}
115-
default {
116-
return(0, returndatasize)
117-
}
111+
// delegatecall returns 0 on error.
112+
case 0 {
113+
revert(0, returndatasize)
114+
}
115+
default {
116+
return(0, returndatasize)
117+
}
118118
}
119119
}
120120

0 commit comments

Comments
 (0)