diff options
Diffstat (limited to 'cli/lsp/documents.rs')
| -rw-r--r-- | cli/lsp/documents.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs index 955ca1c78..4cda1f048 100644 --- a/cli/lsp/documents.rs +++ b/cli/lsp/documents.rs @@ -2,6 +2,7 @@ use super::analysis; use super::text::LineIndex; +use super::tsc::NavigationTree; use crate::import_map::ImportMap; use crate::media_type::MediaType; @@ -33,6 +34,7 @@ impl IndexValid { pub struct DocumentData { bytes: Option<Vec<u8>>, line_index: Option<LineIndex>, + navigation_tree: Option<NavigationTree>, dependencies: Option<HashMap<String, analysis::Dependency>>, version: Option<i32>, } @@ -72,6 +74,7 @@ impl DocumentData { } else { Some(LineIndex::new(&content)) }; + self.navigation_tree = None; Ok(()) } @@ -187,6 +190,14 @@ impl DocumentCache { doc.line_index.clone() } + pub fn navigation_tree( + &self, + specifier: &ModuleSpecifier, + ) -> Option<NavigationTree> { + let doc = self.docs.get(specifier)?; + doc.navigation_tree.clone() + } + pub fn open( &mut self, specifier: ModuleSpecifier, @@ -218,6 +229,22 @@ impl DocumentCache { .collect() } + pub fn set_navigation_tree( + &mut self, + specifier: &ModuleSpecifier, + navigation_tree: NavigationTree, + ) -> Result<(), AnyError> { + if let Some(mut doc) = self.docs.get_mut(specifier) { + doc.navigation_tree = Some(navigation_tree); + Ok(()) + } else { + Err(custom_error( + "NotFound", + "The document \"{}\" was unexpectedly missing.", + )) + } + } + pub fn version(&self, specifier: &ModuleSpecifier) -> Option<i32> { self.docs.get(specifier).and_then(|doc| doc.version) } |
