Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/nodes/ContractDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const specifiers = (node, path, print) => {
document.push([
'layout at',
printSeparatedItem(path.call(print, 'storageLayout'), {
firstSeparator: line
firstSeparator: line,
lastSeparator: node.baseContracts.length === 0 ? line : ''
})
]);
}
Expand Down
7 changes: 6 additions & 1 deletion src/slang-nodes/StorageLayoutSpecifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ export class StorageLayoutSpecifier extends SlangNode {
return [
'layout at',
printSeparatedItem(path.call(print, 'expression'), {
firstSeparator: line
firstSeparator: line,
// If this is the second ContractSpecifier we have to delegate printing
// the line to the ContractSpecifiers node.
lastSeparator: path.callParent((parentPath) => parentPath.isFirst)
? line
: ''
})
];
}
Expand Down
4 changes: 1 addition & 3 deletions tests/format/Comments/__snapshots__/format.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,7 @@ contract Comments4c
Interface4,
Interface5,
Interface6 /*why we used Interface6*/
layout at
/*where should this go?*/ f(123 + 456) /*why we used this layout*/

layout at /*where should this go?*/ f(123 + 456) /*why we used this layout*/
{
// solhint-disable-previous-line no-empty-blocks
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ contract StorageLayoutSpecifier2 layout at
)
{}

contract StorageLayoutSpecifier3 is Contract1 layout at 123 {}
contract StorageLayoutSpecifier3 is Contract1 layout at 123 {}

contract StorageLayoutSpecifier4
is Contract1, Contract2, Contract3, Contract4, Contract5
Expand All @@ -100,7 +100,6 @@ contract StorageLayoutSpecifier6
12345678901234567890 -
12345678901234567890
)

{}

contract StorageLayoutSpecifier7
Expand Down Expand Up @@ -143,7 +142,6 @@ contract StorageLayoutSpecifier9
12345678901234567890 -
12345678901234567890
)

{}

contract InheritanceSpecifier1 is SomeOtherContract(1234, false) {}
Expand All @@ -167,7 +165,6 @@ contract InheritanceSpecifier4
12345678901234567890 -
12345678901234567890
)

{}

contract LongInheritanceSpecifier1 is
Expand Down Expand Up @@ -212,7 +209,6 @@ contract LongInheritanceSpecifier4
12345678901234567890 -
12345678901234567890
)

{}

================================================================================
Expand Down
Loading