@@ -2,7 +2,6 @@ import type * as babel from '@babel/types';
22
33import type { LocationInformation , NGNode , RawNGSpan } from './types.ts' ;
44import {
5- fitSpans ,
65 getCharacterIndex ,
76 getCharacterLastIndex ,
87 sourceSpanToLocationInformation ,
@@ -23,49 +22,19 @@ export class Source {
2322 return getCharacterLastIndex ( this . text , pattern , index ) ;
2423 }
2524
26- transformSpan (
27- span : RawNGSpan ,
28- { stripSpaces = false , hasParentParens = false } = { } ,
29- ) : LocationInformation {
30- if ( ! stripSpaces ) {
31- return sourceSpanToLocationInformation ( span ) ;
32- }
33-
34- const { outerSpan, innerSpan, hasParens } = fitSpans (
35- span ,
36- this . text ,
37- hasParentParens ,
38- ) ;
39- const locationInformation = sourceSpanToLocationInformation ( innerSpan ) ;
40- if ( hasParens ) {
41- locationInformation . extra = {
42- parenthesized : true ,
43- parenStart : outerSpan . start ,
44- parenEnd : outerSpan . end ,
45- } ;
46- }
47-
48- return locationInformation ;
25+ transformSpan ( span : RawNGSpan ) : LocationInformation {
26+ return sourceSpanToLocationInformation ( span ) ;
4927 }
5028
5129 createNode < T extends NGNode > (
5230 properties : Partial < T > & { type : T [ 'type' ] } & RawNGSpan ,
53- // istanbul ignore next
54- { stripSpaces = true , hasParentParens = false } = { } ,
5531 ) {
56- const { type, start, end } = properties ;
5732 const node = {
5833 ...properties ,
59- ...this . transformSpan (
60- { start, end } ,
61- {
62- stripSpaces,
63- hasParentParens,
64- } ,
65- ) ,
34+ range : [ properties . start , properties . end ] ,
6635 } as T & LocationInformation ;
6736
68- switch ( type ) {
37+ switch ( node . type ) {
6938 case 'NumericLiteral' :
7039 case 'StringLiteral' :
7140 case 'RegExpLiteral' : {
0 commit comments