@@ -28,6 +28,7 @@ import {
2828 hasLeadingOwnLineComment ,
2929} from "./comments.js" ;
3030import pathNeedsParens from "./needs-parens.js" ;
31+ import { locStart , locEnd } from "./loc.js" ;
3132
3233import {
3334 getLast ,
@@ -1069,8 +1070,8 @@ function printLines(path, options, print, childrenAttribute = "children") {
10691070 ? [
10701071 hasNewlineInRange (
10711072 options . originalText . trimEnd ( ) ,
1072- options . locEnd ( lastNode ) ,
1073- options . locEnd ( node )
1073+ locEnd ( lastNode ) ,
1074+ locEnd ( node )
10741075 )
10751076 ? ! (
10761077 lastNode . kind === "inline" &&
@@ -1502,7 +1503,7 @@ function printAssignmentRight(
15021503) {
15031504 const ref = hasRef ? "&" : "" ;
15041505
1505- if ( hasLeadingOwnLineComment ( options . originalText , rightNode , options ) ) {
1506+ if ( hasLeadingOwnLineComment ( options . originalText , rightNode ) ) {
15061507 return indent ( [ hardline , ref , printedRight ] ) ;
15071508 }
15081509
@@ -1545,13 +1546,13 @@ function stringHasNewLines(node) {
15451546 return node . raw . includes ( "\n" ) ;
15461547}
15471548
1548- function isStringOnItsOwnLine ( node , text , options ) {
1549+ function isStringOnItsOwnLine ( node , text ) {
15491550 return (
15501551 ( node . kind === "string" ||
15511552 ( node . kind === "encapsed" &&
15521553 ( node . type === "string" || node . type === "shell" ) ) ) &&
15531554 stringHasNewLines ( node ) &&
1554- ! hasNewline ( text , options . locStart ( node ) , { backwards : true } )
1555+ ! hasNewline ( text , locStart ( node ) , { backwards : true } )
15551556 ) ;
15561557}
15571558
@@ -1632,11 +1633,7 @@ function printNode(path, options, print) {
16321633 ? ""
16331634 : [
16341635 hardline ,
1635- isNextLineEmptyAfterNamespace (
1636- options . originalText ,
1637- node ,
1638- options . locStart
1639- )
1636+ isNextLineEmptyAfterNamespace ( options . originalText , node )
16401637 ? hardline
16411638 : "" ,
16421639 ] ,
@@ -2039,7 +2036,7 @@ function printNode(path, options, print) {
20392036 // Multiline strings as single arguments
20402037 if (
20412038 node . arguments . length === 1 &&
2042- isStringOnItsOwnLine ( node . arguments [ 0 ] , options . originalText , options )
2039+ isStringOnItsOwnLine ( node . arguments [ 0 ] , options . originalText )
20432040 ) {
20442041 return [
20452042 print ( "what" ) ,
@@ -2064,7 +2061,7 @@ function printNode(path, options, print) {
20642061 if (
20652062 ! isAnonymousClassNode &&
20662063 node . arguments . length === 1 &&
2067- isStringOnItsOwnLine ( node . arguments [ 0 ] , options . originalText , options )
2064+ isStringOnItsOwnLine ( node . arguments [ 0 ] , options . originalText )
20682065 ) {
20692066 return [
20702067 "new " ,
@@ -2156,7 +2153,7 @@ function printNode(path, options, print) {
21562153 node . useDie ? "die" : "exit" ,
21572154 "(" ,
21582155 node . expression
2159- ? isStringOnItsOwnLine ( node . expression , options . originalText , options )
2156+ ? isStringOnItsOwnLine ( node . expression , options . originalText )
21602157 ? print ( "expression" )
21612158 : [ indent ( [ softline , print ( "expression" ) ] ) , softline ]
21622159 : printDanglingComments ( path , options ) ,
@@ -2199,7 +2196,7 @@ function printNode(path, options, print) {
21992196 case "eval" :
22002197 return group ( [
22012198 "eval(" ,
2202- isStringOnItsOwnLine ( node . source , options . originalText , options )
2199+ isStringOnItsOwnLine ( node . source , options . originalText )
22032200 ? print ( "source" )
22042201 : [ indent ( [ softline , print ( "source" ) ] ) , softline ] ,
22052202 ")" ,
@@ -2388,15 +2385,15 @@ function printNode(path, options, print) {
23882385
23892386 const [ firstProperty ] = node . items
23902387 . filter ( ( node ) => node . kind !== "noop" )
2391- . sort ( ( a , b ) => options . locStart ( a ) - options . locStart ( b ) ) ;
2388+ . sort ( ( a , b ) => locStart ( a ) - locStart ( b ) ) ;
23922389 const isAssociative = ! ! ( firstProperty && firstProperty . key ) ;
23932390 const shouldBreak =
23942391 isAssociative &&
23952392 firstProperty &&
23962393 hasNewlineInRange (
23972394 options . originalText ,
2398- options . locStart ( node ) ,
2399- options . locStart ( firstProperty )
2395+ locStart ( node ) ,
2396+ locStart ( firstProperty )
24002397 ) ;
24012398
24022399 return group (
0 commit comments