11import { util as prettierUtil , doc } from "prettier" ;
2- const {
3- breakParent,
4- join,
5- line,
6- lineSuffix,
7- group,
8- conditionalGroup,
9- indent,
10- dedent,
11- ifBreak,
12- hardline,
13- softline,
14- literalline,
15- align,
16- dedentToRoot,
17- } = doc . builders ;
18- const { willBreak } = doc . utils ;
19- const { isNextLineEmptyAfterIndex, hasNewline, hasNewlineInRange } =
20- prettierUtil ;
212import {
223 printAllComments ,
234 hasTrailingComment ,
@@ -57,10 +38,33 @@ import {
5738 isReferenceLikeNode ,
5839 getNextNode ,
5940 normalizeMagicMethodName ,
41+ } from "./util.js" ;
42+
43+ const {
44+ breakParent,
45+ join,
46+ line,
47+ lineSuffix,
48+ group,
49+ conditionalGroup,
50+ indent,
51+ dedent,
52+ ifBreak,
53+ hardline,
54+ softline,
55+ literalline,
56+ align,
57+ dedentToRoot,
58+ } = doc . builders ;
59+ const { willBreak } = doc . utils ;
60+ const {
61+ isNextLineEmptyAfterIndex,
62+ hasNewline,
63+ hasNewlineInRange,
6064 getNextNonSpaceNonCommentCharacterIndex,
6165 isNextLineEmpty,
6266 isPreviousLineEmpty,
63- } from "./util.js" ;
67+ } = prettierUtil ;
6468
6569function isMinVersion ( actualVersion , requiredVersion ) {
6670 return parseFloat ( actualVersion ) >= parseFloat ( requiredVersion ) ;
@@ -197,8 +201,7 @@ function printMemberChain(path, options, print) {
197201 const { originalText } = options ;
198202 const nextCharIndex = getNextNonSpaceNonCommentCharacterIndex (
199203 originalText ,
200- node ,
201- options
204+ locEnd ( node )
202205 ) ;
203206 const nextChar = originalText . charAt ( nextCharIndex ) ;
204207
@@ -212,7 +215,7 @@ function printMemberChain(path, options, print) {
212215 ) ;
213216 }
214217
215- return isNextLineEmpty ( originalText , node , options ) ;
218+ return isNextLineEmpty ( originalText , locEnd ( node ) ) ;
216219 }
217220
218221 function traverse ( path ) {
@@ -592,7 +595,7 @@ function printArgumentsList(path, options, print, argumentsKey = "arguments") {
592595
593596 if ( isLast ) {
594597 // do nothing
595- } else if ( isNextLineEmpty ( options . originalText , arg , options ) ) {
598+ } else if ( isNextLineEmpty ( options . originalText , locEnd ( arg ) ) ) {
596599 if ( isFirst ) {
597600 hasEmptyLineFollowingFirstArg = true ;
598601 }
@@ -859,7 +862,7 @@ function printArrayItems(path, options, print) {
859862
860863 separatorParts = [ "," , line ] ;
861864
862- if ( node && isNextLineEmpty ( options . originalText , node , options ) ) {
865+ if ( node && isNextLineEmpty ( options . originalText , locEnd ( node ) ) ) {
863866 separatorParts . push ( softline ) ;
864867 }
865868 } , "items" ) ;
@@ -941,7 +944,7 @@ function printLines(path, options, print, childrenAttribute = "children") {
941944 printedPath ,
942945 canPrintBlankLine ? hardline : "" ,
943946 canPrintBlankLine &&
944- isNextLineEmpty ( options . originalText , childNode , options )
947+ isNextLineEmpty ( options . originalText , locEnd ( childNode ) )
945948 ? hardline
946949 : "" ,
947950 ] ;
@@ -1081,7 +1084,7 @@ function printLines(path, options, print, childrenAttribute = "children") {
10811084 ? hardline
10821085 : ""
10831086 : " " ,
1084- isNextLineEmpty ( options . originalText , lastNode , options )
1087+ isNextLineEmpty ( options . originalText , locEnd ( lastNode ) )
10851088 ? hardline
10861089 : "" ,
10871090 ]
@@ -1107,7 +1110,7 @@ function printStatements(path, options, print, childrenAttribute) {
11071110 if ( ! isLastStatement ( path ) ) {
11081111 parts . push ( hardline ) ;
11091112
1110- if ( isNextLineEmpty ( options . originalText , path . node , options ) ) {
1113+ if ( isNextLineEmpty ( options . originalText , locEnd ( path . node ) ) ) {
11111114 parts . push ( hardline ) ;
11121115 }
11131116 }
@@ -1854,7 +1857,7 @@ function printNode(path, options, print) {
18541857
18551858 if ( hasDanglingComments ( node ) ) {
18561859 parts . push (
1857- isNextLineEmpty ( options . originalText , node . body , options )
1860+ isNextLineEmpty ( options . originalText , locEnd ( node . body ) )
18581861 ? hardline
18591862 : "" ,
18601863 printDanglingComments ( path , options , true ) ,
@@ -2828,7 +2831,7 @@ function printNode(path, options, print) {
28282831 const body = print ( "body" ) ;
28292832 const maybeEmptyLineBetweenArms =
28302833 ! path . isFirst &&
2831- isPreviousLineEmpty ( options . originalText , armNode , options )
2834+ isPreviousLineEmpty ( options . originalText , locStart ( armNode ) )
28322835 ? hardline
28332836 : "" ;
28342837
0 commit comments