summaryrefslogtreecommitdiff
path: root/support/texlab/src/features/definition/entry.rs
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-12-30 03:01:26 +0000
committerNorbert Preining <norbert@preining.info>2022-12-30 03:01:26 +0000
commit844019377157163b461e0fd4a66592e61963a530 (patch)
tree32f61991c6a5acc3a3359ffc2cdefdd2aa004268 /support/texlab/src/features/definition/entry.rs
parent55c69feeef908f49007708be194b7bb1c607f302 (diff)
CTAN sync 202212300301
Diffstat (limited to 'support/texlab/src/features/definition/entry.rs')
-rw-r--r--support/texlab/src/features/definition/entry.rs24
1 files changed, 9 insertions, 15 deletions
diff --git a/support/texlab/src/features/definition/entry.rs b/support/texlab/src/features/definition/entry.rs
index 1dcd983af1..a945b18c41 100644
--- a/support/texlab/src/features/definition/entry.rs
+++ b/support/texlab/src/features/definition/entry.rs
@@ -1,24 +1,21 @@
-use std::sync::Arc;
-
-use lsp_types::GotoDefinitionParams;
use rowan::ast::AstNode;
use crate::{
- features::cursor::CursorContext,
syntax::{
bibtex::{self, HasName},
latex,
},
+ util::cursor::CursorContext,
};
use super::DefinitionResult;
-pub(super) fn goto_entry_definition(
- context: &CursorContext<GotoDefinitionParams>,
-) -> Option<Vec<DefinitionResult>> {
+pub(super) fn goto_definition(context: &CursorContext) -> Option<Vec<DefinitionResult>> {
+ let db = context.db;
+
let word = context
.cursor
- .as_latex()
+ .as_tex()
.filter(|token| token.kind() == latex::WORD)?;
let key = latex::Key::cast(word.parent()?)?;
@@ -27,16 +24,13 @@ pub(super) fn goto_entry_definition(
let origin_selection_range = latex::small_range(&key);
- for document in context.request.workspace.documents_by_uri.values() {
- if let Some(data) = document.data.as_bibtex() {
- for entry in bibtex::SyntaxNode::new_root(data.green.clone())
- .children()
- .filter_map(bibtex::Entry::cast)
- {
+ for document in context.related() {
+ if let Some(data) = document.parse(db).as_bib() {
+ for entry in data.root(db).children().filter_map(bibtex::Entry::cast) {
if let Some(key) = entry.name_token().filter(|k| k.text() == word.text()) {
return Some(vec![DefinitionResult {
origin_selection_range,
- target_uri: Arc::clone(&document.uri),
+ target: document,
target_selection_range: key.text_range(),
target_range: entry.syntax().text_range(),
}]);