diff --git a/src/analyzer.rs b/src/analyzer.rs index c89e326d..034af1df 100644 --- a/src/analyzer.rs +++ b/src/analyzer.rs @@ -123,8 +123,6 @@ pub struct StaticDependencyDescriptor { pub specifier: String, /// The range of the specifier. pub specifier_range: PositionRange, - /// The range of the import statement. - pub range: PositionRange, /// Import attributes for this dependency. #[serde(skip_serializing_if = "ImportAttributes::is_none", default)] pub import_attributes: ImportAttributes, @@ -174,7 +172,6 @@ pub struct DynamicDependencyDescriptor { pub argument: DynamicArgument, /// The range of the argument. pub argument_range: PositionRange, - pub range: PositionRange, /// Import attributes for this dependency. #[serde(skip_serializing_if = "ImportAttributes::is_none", default)] pub import_attributes: ImportAttributes, @@ -378,16 +375,6 @@ mod test { character: 4, }, }, - range: PositionRange { - start: Position { - line: 1, - character: 0, - }, - end: Position { - line: 3, - character: 5, - }, - }, import_attributes: ImportAttributes::None, } .into(), @@ -398,10 +385,6 @@ mod test { start: Position::zeroed(), end: Position::zeroed(), }, - range: PositionRange { - start: Position::zeroed(), - end: Position::zeroed(), - }, import_attributes: ImportAttributes::Known(HashMap::from([ ("key".to_string(), ImportAttribute::Unknown), ( @@ -421,6 +404,8 @@ mod test { }; run_serialization_test( &module_info, + // WARNING: Deserialization MUST be backwards compatible in order + // to load data from JSR. json!({ "dependencies": [{ "type": "static", @@ -431,12 +416,10 @@ mod test { }, "specifier": "./test", "specifierRange": [[1, 2], [3, 4]], - "range": [[1, 0], [3, 5]], }, { "type": "dynamic", "argument": "./test2", "argumentRange": [[0, 0], [0, 0]], - "range": [[0, 0], [0, 0]], "importAttributes": { "known": { "key": null, @@ -476,6 +459,8 @@ mod test { }; run_serialization_test( &module_info, + // WARNING: Deserialization MUST be backwards compatible in order + // to load data from JSR. json!({ "tsReferences": [{ "type": "path", @@ -508,6 +493,8 @@ mod test { }; run_serialization_test( &module_info, + // WARNING: Deserialization MUST be backwards compatible in order + // to load data from JSR. json!({ "selfTypesSpecifier": { "text": "a", @@ -535,6 +522,8 @@ mod test { }; run_serialization_test( &module_info, + // WARNING: Deserialization MUST be backwards compatible in order + // to load data from JSR. json!({ "jsxImportSource": { "text": "a", @@ -562,6 +551,8 @@ mod test { }; run_serialization_test( &module_info, + // WARNING: Deserialization MUST be backwards compatible in order + // to load data from JSR. json!({ "jsxImportSourceTypes": { "text": "a", @@ -589,6 +580,8 @@ mod test { }; run_serialization_test( &module_info, + // WARNING: Deserialization MUST be backwards compatible in order + // to load data from JSR. json!({ "jsdocImports": [{ "text": "a", @@ -615,14 +608,12 @@ mod test { start: Position::zeroed(), end: Position::zeroed(), }, - range: PositionRange { - start: Position::zeroed(), - end: Position::zeroed(), - }, import_attributes: ImportAttributes::Unknown, }); run_serialization_test( &descriptor, + // WARNING: Deserialization MUST be backwards compatible in order + // to load data from JSR. json!({ "type": "static", "kind": "exportEquals", @@ -632,7 +623,6 @@ mod test { }, "specifier": "./test", "specifierRange": [[0, 0], [0, 0]], - "range": [[0, 0], [0, 0]], "importAttributes": "unknown", }), ); @@ -654,12 +644,10 @@ mod test { start: Position::zeroed(), end: Position::zeroed(), }, - range: PositionRange { - start: Position::zeroed(), - end: Position::zeroed(), - }, import_attributes: ImportAttributes::Unknown, }), + // WARNING: Deserialization MUST be backwards compatible in order + // to load data from JSR. json!({ "type": "dynamic", "typesSpecifier": { @@ -667,7 +655,6 @@ mod test { "range": [[0, 0], [0, 0]], }, "argumentRange": [[0, 0], [0, 0]], - "range": [[0, 0], [0, 0]], "importAttributes": "unknown", }), ); @@ -680,17 +667,14 @@ mod test { start: Position::zeroed(), end: Position::zeroed(), }, - range: PositionRange { - start: Position::zeroed(), - end: Position::zeroed(), - }, import_attributes: ImportAttributes::Unknown, }), + // WARNING: Deserialization MUST be backwards compatible in order + // to load data from JSR. json!({ "type": "dynamic", "argument": "test", "argumentRange": [[0, 0], [0, 0]], - "range": [[0, 0], [0, 0]], "importAttributes": "unknown", }), ); @@ -709,6 +693,8 @@ mod test { }, DynamicTemplatePart::Expr, ]), + // WARNING: Deserialization MUST be backwards compatible in order + // to load data from JSR. json!([{ "type": "string", "value": "test", @@ -762,16 +748,6 @@ mod test { character: 4, }, }, - range: PositionRange { - start: Position { - line: 1, - character: 0, - }, - end: Position { - line: 3, - character: 5, - }, - }, types_specifier: Some(SpecifierWithRange { text: "./a.d.ts".to_string(), range: PositionRange { @@ -800,7 +776,6 @@ mod test { "kind": "import", "specifier": "./a.js", "specifierRange": [[1, 2], [3, 4]], - "range": [[1, 0], [3, 5]], "leadingComments": [{ "text": " @deno-types=\"./a.d.ts\"", "range": [[0, 0], [0, 25]], @@ -827,16 +802,6 @@ mod test { character: 4, }, }, - range: PositionRange { - start: Position { - line: 1, - character: 0, - }, - end: Position { - line: 3, - character: 5, - }, - }, types_specifier: None, import_attributes: ImportAttributes::None, }, @@ -853,7 +818,6 @@ mod test { "kind": "import", "specifier": "./a.js", "specifierRange": [[1, 2], [3, 4]], - "range": [[1, 0], [3, 5]], }] }); run_v1_deserialization_test(json, &expected); diff --git a/src/ast.rs b/src/ast.rs index f7ed79ba..62f71574 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -462,7 +462,6 @@ fn analyze_dependencies( d.specifier_range, text_info, ), - range: PositionRange::from_source_range(d.range, text_info), import_attributes: d.import_attributes, }) } @@ -499,7 +498,6 @@ fn analyze_dependencies( d.argument_range, text_info, ), - range: PositionRange::from_source_range(d.range, text_info), import_attributes: d.import_attributes, }) } diff --git a/src/graph.rs b/src/graph.rs index 967d9597..0a182420 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -671,8 +671,6 @@ pub struct Import { pub kind: ImportKind, #[serde(rename = "range")] pub specifier_range: Range, - #[serde(skip_serializing)] - pub full_range: Option, #[serde(skip_serializing_if = "is_false")] pub is_dynamic: bool, // Don't include attributes in `deno info --json` until someone has a need. @@ -2418,7 +2416,6 @@ pub(crate) fn parse_js_module_from_module_info( specifier: specifier.text, kind: ImportKind::TsReferencePath, specifier_range: range, - full_range: None, is_dynamic: false, attributes: Default::default(), }); @@ -2457,7 +2454,6 @@ pub(crate) fn parse_js_module_from_module_info( specifier: specifier.text, kind: ImportKind::TsReferenceTypes, specifier_range: range, - full_range: None, is_dynamic: false, attributes: Default::default(), }); @@ -2580,7 +2576,6 @@ pub(crate) fn parse_js_module_from_module_info( specifier: specifier_text, kind: ImportKind::JsxImportSource, specifier_range: range, - full_range: None, is_dynamic: false, attributes: Default::default(), }); @@ -2610,7 +2605,6 @@ pub(crate) fn parse_js_module_from_module_info( specifier: specifier.text, kind: ImportKind::JsDoc, specifier_range, - full_range: None, is_dynamic: false, attributes: Default::default(), }); @@ -2725,8 +2719,6 @@ fn fill_module_dependencies( module_specifier.clone(), desc.specifier_range, ); - let full_range = - Range::from_position_range(module_specifier.clone(), desc.range); ( vec![Import { specifier: desc.specifier, @@ -2735,7 +2727,6 @@ fn fill_module_dependencies( false => ImportKind::Es, }, specifier_range, - full_range: Some(full_range), is_dynamic: false, attributes: desc.import_attributes, }], @@ -2769,8 +2760,6 @@ fn fill_module_dependencies( module_specifier.clone(), desc.argument_range, ); - let full_range = - Range::from_position_range(module_specifier.clone(), desc.range); ( specifiers .into_iter() @@ -2778,7 +2767,6 @@ fn fill_module_dependencies( specifier, kind: ImportKind::Es, specifier_range: specifier_range.clone(), - full_range: Some(full_range.clone()), is_dynamic: true, attributes: import_attributes.clone(), }) @@ -5185,11 +5173,6 @@ mod tests { character: 27, }, }, - full_range: Some(Range { - specifier: specifier.clone(), - start: Position::new(2, 16), - end: Position::new(2, 65), - }), is_dynamic: false, attributes: Default::default(), }, @@ -5207,11 +5190,6 @@ mod tests { character: 27, }, }, - full_range: Some(Range { - specifier: specifier.clone(), - start: Position::new(2, 16), - end: Position::new(2, 65), - }), is_dynamic: false, attributes: Default::default(), }, @@ -5863,7 +5841,6 @@ mod tests { character: 52, }, }, - full_range: None, is_dynamic: false, attributes: ImportAttributes::None, }, @@ -5881,7 +5858,6 @@ mod tests { character: 53, }, }, - full_range: None, is_dynamic: false, attributes: ImportAttributes::None, }, @@ -5899,11 +5875,6 @@ mod tests { character: 39, }, }, - full_range: Some(Range { - specifier: Url::parse("file:///foo.ts").unwrap(), - start: Position::new(4, 16), - end: Position::new(4, 40), - }), is_dynamic: false, attributes: ImportAttributes::None, }, @@ -5921,11 +5892,6 @@ mod tests { character: 45, }, }, - full_range: Some(Range { - specifier: Url::parse("file:///foo.ts").unwrap(), - start: Position::new(5, 22), - end: Position::new(5, 46), - }), is_dynamic: true, attributes: ImportAttributes::None, }, @@ -5943,11 +5909,6 @@ mod tests { character: 45, }, }, - full_range: Some(Range { - specifier: Url::parse("file:///foo.ts").unwrap(), - start: Position::new(6, 22), - end: Position::new(6, 68), - }), is_dynamic: true, attributes: ImportAttributes::Unknown, }, @@ -5965,11 +5926,6 @@ mod tests { character: 52, }, }, - full_range: Some(Range { - specifier: Url::parse("file:///foo.ts").unwrap(), - start: Position::new(8, 16), - end: Position::new(8, 53), - }), is_dynamic: false, attributes: ImportAttributes::None, }, @@ -5991,11 +5947,6 @@ mod tests { character: 41, }, }, - full_range: Some(Range { - specifier: Url::parse("file:///foo.ts").unwrap(), - start: Position::new(7, 16), - end: Position::new(7, 66), - }), is_dynamic: false, attributes: ImportAttributes::Known(HashMap::from_iter(vec![( "type".to_string(), diff --git a/src/lib.rs b/src/lib.rs index 9e6281ab..bc936627 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3321,11 +3321,6 @@ export const foo = 'bar';"#, start: Position::new(2, 22), end: Position::new(2, 30), }, - full_range: Some(Range { - specifier: specifier.clone(), - start: Position::new(2, 4), - end: Position::new(2, 31), - }), is_dynamic: false, attributes: Default::default(), }],