@@ -25,13 +25,13 @@ import {
25
25
CommentInfo ,
26
26
} from './nodes' ;
27
27
import { blockElements , TagName } from '../lib/elements' ;
28
- import { FastPath } from 'prettier' ;
28
+ import { AstPath } from 'prettier' ;
29
29
import { findLastIndex , isASTNode , isPreTagContent } from './helpers' ;
30
30
import { ParserOptions , isBracketSameLine } from '../options' ;
31
31
32
32
const unsupportedLanguages = [ 'coffee' , 'coffeescript' , 'styl' , 'stylus' , 'sass' ] ;
33
33
34
- export function isInlineElement ( path : FastPath , options : ParserOptions , node : Node ) {
34
+ export function isInlineElement ( path : AstPath , options : ParserOptions , node : Node ) {
35
35
return (
36
36
node && node . type === 'Element' && ! isBlockElement ( node , options ) && ! isPreTagContent ( path )
37
37
) ;
@@ -82,7 +82,7 @@ export function getChildren(node: Node): Node[] {
82
82
/**
83
83
* Returns siblings, that is, the children of the parent.
84
84
*/
85
- export function getSiblings ( path : FastPath ) : Node [ ] {
85
+ export function getSiblings ( path : AstPath ) : Node [ ] {
86
86
let parent : Node = path . getParentNode ( ) ;
87
87
88
88
if ( isASTNode ( parent ) ) {
@@ -95,22 +95,22 @@ export function getSiblings(path: FastPath): Node[] {
95
95
/**
96
96
* Returns the previous sibling node.
97
97
*/
98
- export function getPreviousNode ( path : FastPath ) : Node | undefined {
98
+ export function getPreviousNode ( path : AstPath ) : Node | undefined {
99
99
const node : Node = path . getNode ( ) ;
100
100
return getSiblings ( path ) . find ( ( child ) => child . end === node . start ) ;
101
101
}
102
102
103
103
/**
104
104
* Returns the next sibling node.
105
105
*/
106
- export function getNextNode ( path : FastPath , node : Node = path . getNode ( ) ) : Node | undefined {
106
+ export function getNextNode ( path : AstPath , node : Node = path . getNode ( ) ) : Node | undefined {
107
107
return getSiblings ( path ) . find ( ( child ) => child . start === node . end ) ;
108
108
}
109
109
110
110
/**
111
111
* Returns the comment that is above the current node.
112
112
*/
113
- export function getLeadingComment ( path : FastPath ) : CommentNode | undefined {
113
+ export function getLeadingComment ( path : AstPath ) : CommentNode | undefined {
114
114
const siblings = getSiblings ( path ) ;
115
115
116
116
let node : Node = path . getNode ( ) ;
@@ -135,7 +135,7 @@ export function getLeadingComment(path: FastPath): CommentNode | undefined {
135
135
* Did there use to be any embedded object (that has been snipped out of the AST to be moved)
136
136
* at the specified position?
137
137
*/
138
- export function doesEmbedStartAfterNode ( node : Node , path : FastPath , siblings = getSiblings ( path ) ) {
138
+ export function doesEmbedStartAfterNode ( node : Node , path : AstPath , siblings = getSiblings ( path ) ) {
139
139
// If node is not at the top level of html, an embed cannot start after it,
140
140
// because embeds are only at the top level
141
141
if ( ! isNodeTopLevelHTML ( node , path ) ) {
@@ -151,7 +151,7 @@ export function doesEmbedStartAfterNode(node: Node, path: FastPath, siblings = g
151
151
return embeds . find ( ( n ) => n && n . start >= position && ( ! nextNode || n . end <= nextNode . start ) ) ;
152
152
}
153
153
154
- export function isNodeTopLevelHTML ( node : Node , path : FastPath ) : boolean {
154
+ export function isNodeTopLevelHTML ( node : Node , path : AstPath ) : boolean {
155
155
const root = path . stack [ 0 ] ;
156
156
return ! ! root . html && ! ! root . html . children && root . html . children . includes ( node ) ;
157
157
}
@@ -355,7 +355,7 @@ export function trimTextNodeLeft(node: TextNode): void {
355
355
* Remove all leading whitespace up until the first non-empty text node,
356
356
* and all trailing whitespace from the last non-empty text node onwards.
357
357
*/
358
- export function trimChildren ( children : Node [ ] , path : FastPath ) : void {
358
+ export function trimChildren ( children : Node [ ] , path : AstPath ) : void {
359
359
let firstNonEmptyNode = children . findIndex (
360
360
( n ) => ! isEmptyTextNode ( n ) && ! doesEmbedStartAfterNode ( n , path ) ,
361
361
) ;
@@ -528,7 +528,7 @@ export function checkWhitespaceAtEndOfSvelteBlock(
528
528
return 'none' ;
529
529
}
530
530
531
- export function isInsideQuotedAttribute ( path : FastPath , options : ParserOptions ) : boolean {
531
+ export function isInsideQuotedAttribute ( path : AstPath , options : ParserOptions ) : boolean {
532
532
const stack = path . stack as Node [ ] ;
533
533
534
534
return stack . some (
@@ -544,7 +544,7 @@ export function isInsideQuotedAttribute(path: FastPath, options: ParserOptions):
544
544
*/
545
545
export function canOmitSoftlineBeforeClosingTag (
546
546
node : Node ,
547
- path : FastPath ,
547
+ path : AstPath ,
548
548
options : ParserOptions ,
549
549
) : boolean {
550
550
return (
@@ -566,7 +566,7 @@ function hugsStartOfNextNode(node: Node, options: ParserOptions): boolean {
566
566
return ! options . originalText . substring ( node . end ) . match ( / ^ \s / ) ;
567
567
}
568
568
569
- function isLastChildWithinParentBlockElement ( path : FastPath , options : ParserOptions ) : boolean {
569
+ function isLastChildWithinParentBlockElement ( path : AstPath , options : ParserOptions ) : boolean {
570
570
const parent = path . getParentNode ( ) as Node | undefined ;
571
571
if ( ! parent || ! isBlockElement ( parent , options ) ) {
572
572
return false ;
0 commit comments