Skip to content

Commit fb9d154

Browse files
committed
fixing rebase
1 parent 188ced8 commit fb9d154

File tree

4 files changed

+17
-29
lines changed

4 files changed

+17
-29
lines changed

src/nodes/ContractDefinition.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const inheritance = (node, path, print) =>
1717
: line;
1818

1919
const body = (node, path, options, print) =>
20-
node.subNodes.length > 0
20+
node.subNodes.length > 0 || node.comments
2121
? concat([
2222
indent(
2323
concat([

src/nodes/print-comments.js

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,10 @@
11
const {
22
doc: {
3-
builders: { concat, join, line }
3+
builders: { join, line }
44
}
55
} = require('prettier');
66

7-
const printComments = (node, path, options) => {
8-
const parts = [];
9-
if (node.comments) {
10-
let first = true;
11-
path.each(commentPath => {
12-
const comment = commentPath.getValue();
13-
if (comment.trailing || comment.leading) {
14-
return;
15-
}
16-
17-
if (first) {
18-
first = false;
19-
} else {
20-
parts.push(line);
21-
}
22-
23-
comment.printed = true;
24-
parts.push(options.printer.printComment(commentPath, options));
25-
}, 'comments');
26-
}
27-
return concat(parts);
28-
};
29-
30-
const printCommentsNew = (node, path, options) =>
7+
const printComments = (node, path, options) =>
318
node.comments
329
? join(
3310
line,

tests/Comments/Comments.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ contract Comments3 is Interface1, Interface2, Interface3, Interface4, Interface5
2222

2323
function someFunction() {
2424

25-
}
25+
}/*1*//*2
26+
*/
2627
}
2728

2829
contract Comments4 is Interface1, Interface2, Interface3, Interface4, Interface5, Interface6 {

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ contract Comments3 is Interface1, Interface2, Interface3, Interface4, Interface5
2525
2626
function someFunction() {
2727
28-
}
28+
}/*1*//*2
29+
*/
2930
}
3031
3132
contract Comments4 is Interface1, Interface2, Interface3, Interface4, Interface5, Interface6 {
@@ -56,6 +57,7 @@ contract Comments7 {
5657
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5758
pragma solidity ^0.4.24;
5859
60+
5961
contract Comments1 {
6062
function() {
6163
// solhint-disable-previous-line no-empty-blocks
@@ -74,10 +76,12 @@ contract Comments1 {
7476
}
7577
}
7678
79+
7780
contract Comments2 {
7881
// solhint-disable-previous-line no-empty-blocks
7982
}
8083
84+
8185
contract Comments3 is
8286
Interface1,
8387
Interface2,
@@ -88,9 +92,12 @@ contract Comments3 is
8892
{
8993
// solhint-disable-previous-line no-empty-blocks
9094
91-
function someFunction() {}
95+
function someFunction() {} /*1*/
96+
/*2
97+
*/
9298
}
9399
100+
94101
contract Comments4 is
95102
Interface1,
96103
Interface2,
@@ -102,11 +109,13 @@ contract Comments4 is
102109
// solhint-disable-previous-line no-empty-blocks
103110
}
104111
112+
105113
/*nice name*/
106114
contract Comments5 {
107115
// solhint-disable-previous-line no-empty-blocks
108116
}
109117
118+
110119
/*why the name \`Comments6\`*/
111120
contract Comments6 is
112121
Interface1, /*why we used Interface1*/
@@ -119,6 +128,7 @@ contract Comments6 is
119128
// solhint-disable-previous-line no-empty-blocks
120129
}
121130
131+
122132
contract Comments7 {
123133
function someFunction(
124134
uint256 a, // the first value

0 commit comments

Comments
 (0)