|
1 | 1 | import { doc } from 'prettier'; |
2 | | -import { coerce, satisfies } from 'semver'; |
| 2 | +import { satisfies } from 'semver'; |
3 | 3 | import { NonterminalKind } from '@nomicfoundation/slang/cst'; |
4 | 4 | import { printSeparatedList } from '../slang-printers/print-separated-list.js'; |
5 | 5 | import { getNodeMetadata, updateMetadata } from '../slang-utils/metadata.js'; |
@@ -38,22 +38,22 @@ export class ImportDeconstructionSymbols implements SlangNode { |
38 | 38 | print( |
39 | 39 | path: AstPath<ImportDeconstructionSymbols>, |
40 | 40 | print: PrintFunction, |
41 | | - options: ParserOptions<AstNode> |
| 41 | + { compiler, bracketSpacing }: ParserOptions<AstNode> |
42 | 42 | ): Doc { |
43 | | - const compiler = coerce(options.compiler); |
| 43 | + const items = path.map(print, 'items'); |
44 | 44 | return printSeparatedList( |
45 | | - path.map(print, 'items'), |
46 | | - compiler && satisfies(compiler, '>=0.7.4') && this.items.length > 1 |
| 45 | + items, |
| 46 | + satisfies(compiler, '>=0.7.4') && items.length > 1 |
47 | 47 | ? { |
48 | 48 | // if the compiler exists and is greater than or equal to 0.7.4 we will |
49 | 49 | // split the ImportDirective. |
50 | | - firstSeparator: options.bracketSpacing ? line : softline, |
| 50 | + firstSeparator: bracketSpacing ? line : softline, |
51 | 51 | separator: [',', line] |
52 | 52 | } |
53 | 53 | : { |
54 | 54 | // if the compiler is not given or is lower than 0.7.4 we will not |
55 | 55 | // split the ImportDirective. |
56 | | - firstSeparator: options.bracketSpacing ? ' ' : '', |
| 56 | + firstSeparator: bracketSpacing ? ' ' : '', |
57 | 57 | separator: ', ' |
58 | 58 | } |
59 | 59 | ); |
|
0 commit comments