Skip to content

Commit

Permalink
BREAKING: revert storing full range in serialized module info (#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Oct 8, 2024
1 parent 914f245 commit 019728c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 112 deletions.
76 changes: 20 additions & 56 deletions src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
Expand All @@ -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),
(
Expand All @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -632,7 +623,6 @@ mod test {
},
"specifier": "./test",
"specifierRange": [[0, 0], [0, 0]],
"range": [[0, 0], [0, 0]],
"importAttributes": "unknown",
}),
);
Expand All @@ -654,20 +644,17 @@ 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": {
"text": "a",
"range": [[0, 0], [0, 0]],
},
"argumentRange": [[0, 0], [0, 0]],
"range": [[0, 0], [0, 0]],
"importAttributes": "unknown",
}),
);
Expand All @@ -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",
}),
);
Expand All @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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]],
Expand All @@ -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,
},
Expand All @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
Expand Down Expand Up @@ -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,
})
}
Expand Down
Loading

0 comments on commit 019728c

Please sign in to comment.