11// Copyright 2020-2022 the Deno authors. All rights reserved. MIT license.
22
3- use deno_ast:: swc:: common:: Spanned ;
43use deno_ast:: ParsedSource ;
4+ use deno_ast:: SourceRangedForSpanned ;
55use serde:: Deserialize ;
66use serde:: Serialize ;
77
@@ -17,7 +17,7 @@ use crate::params::param_to_param_def;
1717use crate :: params:: prop_name_to_string;
1818use crate :: params:: ts_fn_param_to_param_def;
1919use crate :: swc_util:: get_location;
20- use crate :: swc_util:: js_doc_for_span ;
20+ use crate :: swc_util:: js_doc_for_range ;
2121use crate :: ts_type:: infer_ts_type_from_expr;
2222use crate :: ts_type:: maybe_type_param_instantiation_to_type_defs;
2323use crate :: ts_type:: ts_type_ann_to_def;
@@ -247,7 +247,7 @@ pub fn class_to_class_def(
247247
248248 match member {
249249 Constructor ( ctor) => {
250- let ctor_js_doc = js_doc_for_span ( parsed_source, & ctor. span ( ) ) ;
250+ let ctor_js_doc = js_doc_for_range ( parsed_source, & ctor. range ( ) ) ;
251251 let constructor_name =
252252 prop_name_to_string ( Some ( parsed_source) , & ctor. key ) ;
253253
@@ -279,13 +279,13 @@ pub fn class_to_class_def(
279279 accessibility : ctor. accessibility ,
280280 name : constructor_name,
281281 params,
282- location : get_location ( parsed_source, ctor. span . lo ( ) ) ,
282+ location : get_location ( parsed_source, ctor. start ( ) ) ,
283283 } ;
284284 constructors. push ( constructor_def) ;
285285 }
286286 Method ( class_method) => {
287287 let method_js_doc =
288- js_doc_for_span ( parsed_source, & class_method. span ( ) ) ;
288+ js_doc_for_range ( parsed_source, & class_method. range ( ) ) ;
289289 let method_name =
290290 prop_name_to_string ( Some ( parsed_source) , & class_method. key ) ;
291291 let fn_def =
@@ -299,12 +299,12 @@ pub fn class_to_class_def(
299299 name : method_name,
300300 kind : class_method. kind ,
301301 function_def : fn_def,
302- location : get_location ( parsed_source, class_method. span . lo ( ) ) ,
302+ location : get_location ( parsed_source, class_method. start ( ) ) ,
303303 } ;
304304 methods. push ( method_def) ;
305305 }
306306 ClassProp ( class_prop) => {
307- let prop_js_doc = js_doc_for_span ( parsed_source, & class_prop. span ( ) ) ;
307+ let prop_js_doc = js_doc_for_range ( parsed_source, & class_prop. range ( ) ) ;
308308
309309 let ts_type = if let Some ( type_ann) = & class_prop. type_ann {
310310 // if the property has a type annotation, use it
@@ -333,7 +333,7 @@ pub fn class_to_class_def(
333333 accessibility : class_prop. accessibility ,
334334 name : prop_name,
335335 decorators,
336- location : get_location ( parsed_source, class_prop. span . lo ( ) ) ,
336+ location : get_location ( parsed_source, class_prop. start ( ) ) ,
337337 } ;
338338 properties. push ( prop_def) ;
339339 }
@@ -376,7 +376,7 @@ pub fn class_to_class_def(
376376 // JSDoc associated with the class may actually be a leading comment on a
377377 // decorator, and so we should parse out the JSDoc for the first decorator
378378 let js_doc = if !class. decorators . is_empty ( ) {
379- js_doc_for_span ( parsed_source, & class. decorators [ 0 ] . span )
379+ js_doc_for_range ( parsed_source, & class. decorators [ 0 ] . range ( ) )
380380 } else {
381381 JsDoc :: default ( )
382382 } ;
0 commit comments