mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix(lsp): retain module dependencies when parse is invalid (#12782)
Fixes #12753
This commit is contained in:
parent
fd78953e1c
commit
cc38580106
5 changed files with 109 additions and 80 deletions
|
@ -987,17 +987,16 @@ impl Inner {
|
|||
let asset_or_document = self.get_cached_asset_or_document(&specifier)?;
|
||||
let line_index = asset_or_document.line_index();
|
||||
|
||||
let req = tsc::RequestMethod::GetNavigationTree(specifier);
|
||||
let navigation_tree: tsc::NavigationTree = self
|
||||
.ts_server
|
||||
.request(self.snapshot()?, req)
|
||||
.await
|
||||
.map_err(|err| {
|
||||
error!("Failed to request to tsserver {}", err);
|
||||
LspError::invalid_request()
|
||||
let navigation_tree =
|
||||
self.get_navigation_tree(&specifier).await.map_err(|err| {
|
||||
error!(
|
||||
"Error getting document symbols for \"{}\": {}",
|
||||
specifier, err
|
||||
);
|
||||
LspError::internal_error()
|
||||
})?;
|
||||
|
||||
let response = if let Some(child_items) = navigation_tree.child_items {
|
||||
let response = if let Some(child_items) = &navigation_tree.child_items {
|
||||
let mut document_symbols = Vec::<DocumentSymbol>::new();
|
||||
for item in child_items {
|
||||
item
|
||||
|
@ -1543,7 +1542,7 @@ impl Inner {
|
|||
let asset_or_doc = self.get_cached_asset_or_document(&specifier)?;
|
||||
let line_index = asset_or_doc.line_index();
|
||||
let req = tsc::RequestMethod::GetReferences((
|
||||
specifier,
|
||||
specifier.clone(),
|
||||
line_index.offset_tsc(params.text_document_position.position)?,
|
||||
));
|
||||
let maybe_references: Option<Vec<tsc::ReferenceEntry>> = self
|
||||
|
@ -1563,9 +1562,14 @@ impl Inner {
|
|||
}
|
||||
let reference_specifier =
|
||||
resolve_url(&reference.document_span.file_name).unwrap();
|
||||
let asset_or_doc =
|
||||
self.get_asset_or_document(&reference_specifier).await?;
|
||||
results.push(reference.to_location(asset_or_doc.line_index(), self));
|
||||
let reference_line_index = if reference_specifier == specifier {
|
||||
line_index.clone()
|
||||
} else {
|
||||
let asset_or_doc =
|
||||
self.get_asset_or_document(&reference_specifier).await?;
|
||||
asset_or_doc.line_index()
|
||||
};
|
||||
results.push(reference.to_location(reference_line_index, self));
|
||||
}
|
||||
|
||||
self.performance.measure(mark);
|
||||
|
@ -2157,8 +2161,8 @@ impl Inner {
|
|||
LspError::invalid_request()
|
||||
})?;
|
||||
|
||||
let semantic_tokens: SemanticTokens =
|
||||
semantic_classification.to_semantic_tokens(line_index);
|
||||
let semantic_tokens =
|
||||
semantic_classification.to_semantic_tokens(line_index)?;
|
||||
let response = if !semantic_tokens.data.is_empty() {
|
||||
Some(SemanticTokensResult::Tokens(semantic_tokens))
|
||||
} else {
|
||||
|
@ -2200,8 +2204,8 @@ impl Inner {
|
|||
LspError::invalid_request()
|
||||
})?;
|
||||
|
||||
let semantic_tokens: SemanticTokens =
|
||||
semantic_classification.to_semantic_tokens(line_index);
|
||||
let semantic_tokens =
|
||||
semantic_classification.to_semantic_tokens(line_index)?;
|
||||
let response = if !semantic_tokens.data.is_empty() {
|
||||
Some(SemanticTokensRangeResult::Tokens(semantic_tokens))
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue