Skip to content

Commit 7f48044

Browse files
authored
Assembly Blocks now print comments (#435)
1 parent aa33e47 commit 7f48044

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/nodes/AssemblyBlock.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@ const {
55
} = require('prettier/standalone');
66

77
const printSeparatedItem = require('./print-separated-item');
8+
const printComments = require('./print-comments');
89
const printPreservingEmptyLines = require('./print-preserving-empty-lines');
910

1011
const AssemblyBlock = {
11-
print: ({ options, path, print }) =>
12+
print: ({ node, options, path, print }) =>
1213
concat([
1314
'{',
1415
printSeparatedItem(
15-
printPreservingEmptyLines(path, 'operations', options, print),
16+
concat([
17+
printPreservingEmptyLines(path, 'operations', options, print),
18+
printComments(node, path, options)
19+
]),
1620
{ firstSeparator: hardline }
1721
),
1822
'}'

tests/Assembly/Assembly.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,12 @@ function $somefn(somearg) {
160160
offset := x.offset
161161
}
162162
}
163+
164+
function commentsInAssemblyBlock () {
165+
166+
assembly {
167+
/* foo bar baz */
168+
/* foobbbbbb */
169+
}
170+
}
163171
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ function $somefn(somearg) {
163163
offset := x.offset
164164
}
165165
}
166+
167+
function commentsInAssemblyBlock () {
168+
169+
assembly {
170+
/* foo bar baz */
171+
/* foobbbbbb */
172+
}
173+
}
166174
}
167175
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
168176
contract Assembly {
@@ -362,6 +370,13 @@ contract Assembly {
362370
offset := x.offset
363371
}
364372
}
373+
374+
function commentsInAssemblyBlock() {
375+
assembly {
376+
/* foo bar baz */
377+
/* foobbbbbb */
378+
}
379+
}
365380
}
366381
367382
`;

0 commit comments

Comments
 (0)