1use serde::{Deserialize, Serialize};
2
3use crate::{
4 DynamicRegistrationClientCapabilities, PartialResultParams, TextDocumentPositionParams,
5 TextDocumentRegistrationOptions, WorkDoneProgressOptions, WorkDoneProgressParams,
6};
7
8pub type MonikerClientCapabilities = DynamicRegistrationClientCapabilities;
9
10#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
11#[serde(untagged)]
12pub enum MonikerServerCapabilities {
13 Options(MonikerOptions),
14 RegistrationOptions(MonikerRegistrationOptions),
15}
16
17#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
18pub struct MonikerOptions {
19 #[serde(flatten)]
20 pub work_done_progress_options: WorkDoneProgressOptions,
21}
22
23#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
24#[serde(rename_all = "camelCase")]
25pub struct MonikerRegistrationOptions {
26 #[serde(flatten)]
27 pub text_document_registration_options: TextDocumentRegistrationOptions,
28
29 #[serde(flatten)]
30 pub moniker_options: MonikerOptions,
31}
32
33/// Moniker uniqueness level to define scope of the moniker.
34#[derive(Debug, Eq, PartialEq, Deserialize, Serialize, Copy, Clone)]
35#[serde(rename_all = "camelCase")]
36pub enum UniquenessLevel {
37 /// The moniker is only unique inside a document
38 Document,
39 /// The moniker is unique inside a project for which a dump got created
40 Project,
41 /// The moniker is unique inside the group to which a project belongs
42 Group,
43 /// The moniker is unique inside the moniker scheme.
44 Scheme,
45 /// The moniker is globally unique
46 Global,
47}
48
49/// The moniker kind.
50#[derive(Debug, Eq, PartialEq, Deserialize, Serialize, Copy, Clone)]
51#[serde(rename_all = "camelCase")]
52pub enum MonikerKind {
53 /// The moniker represent a symbol that is imported into a project
54 Import,
55 /// The moniker represent a symbol that is exported into a project
56 Export,
57 /// The moniker represents a symbol that is local to a project (e.g. a local
58 /// variable of a function, a class not visible outside the project, ...)
59 Local,
60}
61
62#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
63#[serde(rename_all = "camelCase")]
64pub struct MonikerParams {
65 #[serde(flatten)]
66 pub text_document_position_params: TextDocumentPositionParams,
67
68 #[serde(flatten)]
69 pub work_done_progress_params: WorkDoneProgressParams,
70
71 #[serde(flatten)]
72 pub partial_result_params: PartialResultParams,
73}
74
75/// Moniker definition to match LSIF 0.5 moniker definition.
76#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
77#[serde(rename_all = "camelCase")]
78pub struct Moniker {
79 /// The scheme of the moniker. For example tsc or .Net
80 pub scheme: String,
81
82 /// The identifier of the moniker. The value is opaque in LSIF however
83 /// schema owners are allowed to define the structure if they want.
84 pub identifier: String,
85
86 /// The scope in which the moniker is unique
87 pub unique: UniquenessLevel,
88
89 /// The moniker kind if known.
90 #[serde(skip_serializing_if = "Option::is_none")]
91 pub kind: Option<MonikerKind>,
92}
93