@@ -6,17 +6,37 @@ import {
66 printSeparatedList
77} from '../common/printer-helpers.js' ;
88
9- const { group, line, hardline } = doc . builders ;
9+ const { group, hardline , ifBreak , line, softline } = doc . builders ;
1010
11- const inheritance = ( node , path , print ) =>
12- node . baseContracts . length > 0
13- ? [
14- ' is' ,
15- printSeparatedList ( path . map ( print , 'baseContracts' ) , {
16- firstSeparator : line
17- } )
18- ]
19- : line ;
11+ const specifiers = ( node , path , print ) => {
12+ const document = [ ] ;
13+ if ( node . baseContracts . length > 0 ) {
14+ document . push ( [
15+ 'is' ,
16+ printSeparatedList ( path . map ( print , 'baseContracts' ) , {
17+ firstSeparator : line
18+ } )
19+ ] ) ;
20+ }
21+ if ( node . storageLayout ) {
22+ document . push ( [
23+ 'layout at' ,
24+ printSeparatedItem ( path . call ( print , 'storageLayout' ) , {
25+ firstSeparator : line
26+ } )
27+ ] ) ;
28+ }
29+ if ( document . length === 0 ) return line ;
30+ if ( document . length === 1 ) return [ ' ' , document ] ;
31+ const groupId = Symbol ( 'ContractSpecifiers.inheritance' ) ;
32+ return printSeparatedList (
33+ [ group ( document [ 0 ] , { id : groupId } ) , document [ 1 ] ] ,
34+ {
35+ firstSeparator : line ,
36+ separator : ifBreak ( '' , softline , { groupId } )
37+ }
38+ ) ;
39+ } ;
2040
2141const body = ( node , path , options , print ) => {
2242 const comments = printComments ( node , path , options ) ;
@@ -34,7 +54,7 @@ export const ContractDefinition = {
3454 node . kind === 'abstract' ? 'abstract contract' : node . kind ,
3555 ' ' ,
3656 node . name ,
37- inheritance ( node , path , print ) ,
57+ specifiers ( node , path , print ) ,
3858 '{'
3959 ] ) ,
4060 body ( node , path , options , print ) ,
0 commit comments