summaryrefslogtreecommitdiff
path: root/cli/lsp/analysis.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/lsp/analysis.rs')
-rw-r--r--cli/lsp/analysis.rs40
1 files changed, 18 insertions, 22 deletions
diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs
index a1d6d909d..9994f147b 100644
--- a/cli/lsp/analysis.rs
+++ b/cli/lsp/analysis.rs
@@ -377,34 +377,30 @@ pub fn analyze_dependencies(
let dep = dependencies.entry(desc.specifier.to_string()).or_default();
dep.is_dynamic = desc.is_dynamic;
+ let start = parsed_module
+ .source_map
+ .lookup_char_pos(desc.specifier_span.lo);
+ let end = parsed_module
+ .source_map
+ .lookup_char_pos(desc.specifier_span.hi);
+ let range = Range {
+ start: Position {
+ line: (start.line - 1) as u32,
+ character: start.col_display as u32,
+ },
+ end: Position {
+ line: (end.line - 1) as u32,
+ character: end.col_display as u32,
+ },
+ };
match desc.kind {
swc_ecmascript::dep_graph::DependencyKind::ExportType
| swc_ecmascript::dep_graph::DependencyKind::ImportType => {
- dep.maybe_type_specifier_range = Some(Range {
- start: Position {
- line: (desc.specifier_line - 1) as u32,
- character: desc.specifier_col as u32,
- },
- end: Position {
- line: (desc.specifier_line - 1) as u32,
- character: (desc.specifier_col + desc.specifier.chars().count() + 2)
- as u32,
- },
- });
+ dep.maybe_type_specifier_range = Some(range);
dep.maybe_type = Some(resolved_import)
}
_ => {
- dep.maybe_code_specifier_range = Some(Range {
- start: Position {
- line: (desc.specifier_line - 1) as u32,
- character: desc.specifier_col as u32,
- },
- end: Position {
- line: (desc.specifier_line - 1) as u32,
- character: (desc.specifier_col + desc.specifier.chars().count() + 2)
- as u32,
- },
- });
+ dep.maybe_code_specifier_range = Some(range);
dep.maybe_code = Some(resolved_import);
}
}