diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2021-07-25 15:33:42 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-25 15:33:42 +1000 |
commit | 72ac9c3ae0c5db99af1e1f5d2191fb82dc092acd (patch) | |
tree | d1120201acc158155ea9a76d4b7896221489c9e9 /cli/lsp/documents.rs | |
parent | 74c7559d2029539eb6ab7459c06061c00b3e0c1a (diff) |
fix(lsp): handle importmaps properly (#11496)
Fixes: #11146
Fixes: #11456
Fixes: #10439
Diffstat (limited to 'cli/lsp/documents.rs')
-rw-r--r-- | cli/lsp/documents.rs | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs index 00a4aa156..911e30389 100644 --- a/cli/lsp/documents.rs +++ b/cli/lsp/documents.rs @@ -81,7 +81,7 @@ pub struct DocumentData { bytes: Option<Vec<u8>>, dependencies: Option<HashMap<String, analysis::Dependency>>, dependency_ranges: Option<analysis::DependencyRanges>, - language_id: LanguageId, + pub(crate) language_id: LanguageId, line_index: Option<LineIndex>, maybe_navigation_tree: Option<tsc::NavigationTree>, specifier: ModuleSpecifier, @@ -180,7 +180,7 @@ impl DocumentData { #[derive(Debug, Clone, Default)] pub struct DocumentCache { dependents_graph: HashMap<ModuleSpecifier, HashSet<ModuleSpecifier>>, - pub docs: HashMap<ModuleSpecifier, DocumentData>, + pub(crate) docs: HashMap<ModuleSpecifier, DocumentData>, } impl DocumentCache { @@ -272,16 +272,29 @@ impl DocumentCache { &self, specifier: &ModuleSpecifier, ) -> Option<HashMap<String, analysis::Dependency>> { - let doc = self.docs.get(specifier)?; - doc.dependencies.clone() + self + .docs + .get(specifier) + .map(|doc| doc.dependencies.clone()) + .flatten() + } + + pub fn get_language_id( + &self, + specifier: &ModuleSpecifier, + ) -> Option<LanguageId> { + self.docs.get(specifier).map(|doc| doc.language_id.clone()) } pub fn get_navigation_tree( &self, specifier: &ModuleSpecifier, ) -> Option<tsc::NavigationTree> { - let doc = self.docs.get(specifier)?; - doc.maybe_navigation_tree.clone() + self + .docs + .get(specifier) + .map(|doc| doc.maybe_navigation_tree.clone()) + .flatten() } /// Determines if the specifier should be processed for diagnostics and other |