1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
use insta::assert_json_snapshot;
use lsp_types::{
request::InlayHintRequest, ClientCapabilities, InlayHint, InlayHintParams, Position, Range,
TextDocumentIdentifier,
};
use crate::tests::{client::Client, fixture};
fn check(fixture: &str) -> Vec<InlayHint> {
let mut client = Client::spawn();
client.initialize(ClientCapabilities::default(), None);
let fixture = fixture::parse(fixture);
let uri = client.uri(fixture.files[0].name);
for file in fixture.files {
client.open(file.name, file.lang, file.text);
}
let actual_hints = client
.request::<InlayHintRequest>(InlayHintParams {
text_document: TextDocumentIdentifier::new(uri),
range: Range::new(Position::new(0, 0), Position::new(12, 0)),
work_done_progress_params: Default::default(),
})
.unwrap()
.unwrap_or_default();
client.shutdown();
actual_hints
}
#[test]
fn label_definition() {
assert_json_snapshot!(check(
r#"
%TEX main.tex
%SRC \documentclass{article}
%SRC \usepackage{caption}
%SRC \begin{document}
%SRC \section{Foo}\label{sec:foo}
%SRC \section{Bar}\label{sec:bar}
%SRC \subsection{Baz}\label{sec:baz}
%SRC \begin{figure}
%SRC Test
%SRC \label{fig:qux}
%SRC \caption{Qux}
%SRC \end{figure}
%SRC \end{document}
%TEX main.aux
%SRC \relax
%SRC \providecommand*\caption@xref[2]{\@setref\relax\@undefined{#1}}
%SRC \newlabel{fig:qux}{{\caption@xref {fig:qux}{ on input line 15}}{1}}
%SRC \@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces Qux\relax }}{1}{}\protected@file@percent }
%SRC \@writefile{toc}{\contentsline {section}{\numberline {1}Foo}{1}{}\protected@file@percent }
%SRC \newlabel{sec:foo}{{1}{1}}
%SRC \@writefile{toc}{\contentsline {section}{\numberline {2}Bar}{1}{}\protected@file@percent }
%SRC \newlabel{sec:bar}{{2}{1}}
%SRC \@writefile{toc}{\contentsline {subsection}{\numberline {2.1}Baz}{1}{}\protected@file@percent }
%SRC \newlabel{sec:baz}{{2.1}{1}}
%SRC \gdef \@abspage@last{1}
"#,
));
}
|