Skip to content

Commit 188ced8

Browse files
committed
refactor
1 parent a25af0e commit 188ced8

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

src/comments/handlers/ContractDefinition.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,21 @@ function handleContractDefinitionComments(
2626
options.locEnd
2727
);
2828

29-
// In this scenario we are in between jus after a base contract declaration.
30-
if (precedingNode && precedingNode.type === 'InheritanceSpecifier') {
31-
if (
32-
(followingNode && followingNode.type === 'InheritanceSpecifier') ||
33-
nextCharacter === '{'
34-
) {
35-
addTrailingComment(precedingNode, comment);
36-
return true;
37-
}
38-
}
39-
40-
// In this scenario we have a comment just after the contract's name
41-
// TODO: at the moment we prepended it but this should be kept after the name.
29+
// The comment is behind the start of the Block `{}` or behind a base contract
4230
if (
4331
(followingNode && followingNode.type === 'InheritanceSpecifier') ||
4432
nextCharacter === '{'
4533
) {
34+
// In this scenario the comment belongs to a base contract.
35+
// contract A is B, /* comment for B */ C /* comment for C */ {}
36+
if (precedingNode && precedingNode.type === 'InheritanceSpecifier') {
37+
addTrailingComment(precedingNode, comment);
38+
return true;
39+
}
40+
41+
// In this scenario the comment belongs to the contract's name.
42+
// contract A /* comment for A */ is B, C {}
43+
// TODO: at the moment we prepended it but this should be kept after the name.
4644
addLeadingComment(enclosingNode, comment);
4745
return true;
4846
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ contract Comments6 is
121121
122122
contract Comments7 {
123123
function someFunction(
124-
uint a, // the first value
125-
uint b, // the second value
126-
uint c // the lats value
124+
uint256 a, // the first value
125+
uint256 b, // the second value
126+
uint256 c // the lats value
127127
) {
128128
someFunction(
129129
a, // the first value

0 commit comments

Comments
 (0)