summaryrefslogtreecommitdiff
path: root/cli/lsp/documents.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/lsp/documents.rs')
-rw-r--r--cli/lsp/documents.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs
index 5fbfcdf52..5e08245cb 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;
use crate::media_type::MediaType;
@@ -66,6 +67,7 @@ pub struct DocumentData {
bytes: Option<Vec<u8>>,
language_id: LanguageId,
line_index: Option<LineIndex>,
+ maybe_navigation_tree: Option<tsc::NavigationTree>,
specifier: ModuleSpecifier,
dependencies: Option<HashMap<String, analysis::Dependency>>,
version: Option<i32>,
@@ -82,6 +84,7 @@ impl DocumentData {
bytes: Some(source.as_bytes().to_owned()),
language_id,
line_index: Some(LineIndex::new(source)),
+ maybe_navigation_tree: None,
specifier,
dependencies: None,
version: Some(version),
@@ -122,6 +125,7 @@ impl DocumentData {
} else {
Some(LineIndex::new(&content))
};
+ self.maybe_navigation_tree = None;
Ok(())
}
@@ -236,6 +240,14 @@ impl DocumentCache {
doc.dependencies.clone()
}
+ pub fn get_navigation_tree(
+ &self,
+ specifier: &ModuleSpecifier,
+ ) -> Option<tsc::NavigationTree> {
+ let doc = self.docs.get(specifier)?;
+ doc.maybe_navigation_tree.clone()
+ }
+
/// Determines if the specifier should be processed for diagnostics and other
/// related language server features.
pub fn is_diagnosable(&self, specifier: &ModuleSpecifier) -> bool {
@@ -340,6 +352,25 @@ impl DocumentCache {
}
}
+ pub fn set_navigation_tree(
+ &mut self,
+ specifier: &ModuleSpecifier,
+ navigation_tree: tsc::NavigationTree,
+ ) -> Result<(), AnyError> {
+ if let Some(doc) = self.docs.get_mut(specifier) {
+ doc.maybe_navigation_tree = Some(navigation_tree);
+ Ok(())
+ } else {
+ Err(custom_error(
+ "NotFound",
+ format!(
+ "The specifier (\"{}\") does not exist in the document cache.",
+ specifier
+ ),
+ ))
+ }
+ }
+
pub fn specifiers(&self) -> Vec<ModuleSpecifier> {
self.docs.keys().cloned().collect()
}