@@ -10,44 +10,44 @@ import {
1010 type JavaParserOptions
1111} from "./printers/helpers.js" ;
1212
13- const formatterOffOnRangesByCst = new WeakMap <
13+ const prettierIgnoreRangesByCst = new WeakMap <
1414 JavaNode ,
15- FormatterOffOnRange [ ]
15+ PrettierIgnoreRange [ ]
1616> ( ) ;
1717
18- export function determineFormatterOffOnRanges ( cst : JavaNonTerminal ) {
18+ export function determinePrettierIgnoreRanges ( cst : JavaNonTerminal ) {
1919 const { comments } = cst ;
2020 if ( ! comments ) {
2121 return ;
2222 }
2323 const ranges = comments
2424 . filter ( ( { image } ) =>
25- / ^ ( \/ \/ \s * @ f o r m a t t e r : ( o f f | o n ) \s * | \/ \ *\s * @ f o r m a t t e r : ( o f f | o n ) \s * \* \/ ) $ / . test (
25+ / ^ \/ (?: \/ \s * (?: p r e t t i e r - i g n o r e - (?: s t a r t | e n d ) | @ f o r m a t t e r : (?: o f f | o n ) ) \s * | \* \s * (?: p r e t t i e r - i g n o r e - (?: s t a r t | e n d ) | @ f o r m a t t e r : (?: o f f | o n ) ) \s * \* \/ ) $ / . test (
2626 image
2727 )
2828 )
2929 . reduce ( ( ranges , { image, startOffset } ) => {
3030 const previous = ranges . at ( - 1 ) ;
31- if ( image . endsWith ( "off" ) ) {
32- if ( previous ?. on !== Infinity ) {
33- ranges . push ( { off : startOffset , on : Infinity } ) ;
31+ if ( image . includes ( "start" ) || image . includes ( "off" ) ) {
32+ if ( previous ?. end !== Infinity ) {
33+ ranges . push ( { start : startOffset , end : Infinity } ) ;
3434 }
35- } else if ( previous ?. on === Infinity ) {
36- previous . on = startOffset ;
35+ } else if ( previous ?. end === Infinity ) {
36+ previous . end = startOffset ;
3737 }
3838 return ranges ;
39- } , new Array < FormatterOffOnRange > ( ) ) ;
40- formatterOffOnRangesByCst . set ( cst , ranges ) ;
39+ } , new Array < PrettierIgnoreRange > ( ) ) ;
40+ prettierIgnoreRangesByCst . set ( cst , ranges ) ;
4141}
4242
43- export function isFullyBetweenFormatterOffOn ( path : AstPath < JavaNode > ) {
43+ export function isFullyBetweenPrettierIgnore ( path : AstPath < JavaNode > ) {
4444 const { node, root } = path ;
4545 const start = parser . locStart ( node ) ;
4646 const end = parser . locEnd ( node ) ;
4747 return (
48- formatterOffOnRangesByCst
48+ prettierIgnoreRangesByCst
4949 . get ( root )
50- ?. some ( range => range . off < start && end < range . on ) === true
50+ ?. some ( range => range . start < start && end < range . end ) === true
5151 ) ;
5252}
5353
@@ -300,7 +300,7 @@ export type JavaComment = IToken & {
300300 followingNode ?: JavaNode ;
301301} ;
302302
303- type FormatterOffOnRange = {
304- off : number ;
305- on : number ;
303+ type PrettierIgnoreRange = {
304+ start : number ;
305+ end : number ;
306306} ;
0 commit comments