microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
language_service/src/protocol.rs
91lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | use qsc::{PackageType, TargetProfile}; |
| 5 | |
| 6 | /// Workspace configuration |
| 7 | #[derive(Clone, Debug, Default)] |
| 8 | pub struct WorkspaceConfigurationUpdate { |
| 9 | pub target_profile: Option<TargetProfile>, |
| 10 | pub package_type: Option<PackageType>, |
| 11 | } |
| 12 | |
| 13 | /// Represents a span of text used by the Language Server API |
| 14 | #[derive(Debug, PartialEq)] |
| 15 | pub struct Span { |
| 16 | pub start: u32, |
| 17 | pub end: u32, |
| 18 | } |
| 19 | |
| 20 | #[derive(Copy, Clone, Debug, PartialEq)] |
| 21 | #[allow(clippy::module_name_repetitions)] |
| 22 | pub enum CompletionItemKind { |
| 23 | // It would have been nice to match these enum values to the ones used by |
| 24 | // VS Code and Monaco, but unfortunately those two disagree on the values. |
| 25 | // So we define our own unique enum here to reduce confusion. |
| 26 | Function, |
| 27 | Interface, |
| 28 | Keyword, |
| 29 | Module, |
| 30 | } |
| 31 | |
| 32 | #[derive(Debug)] |
| 33 | #[allow(clippy::module_name_repetitions)] |
| 34 | pub struct CompletionList { |
| 35 | pub items: Vec<CompletionItem>, |
| 36 | } |
| 37 | |
| 38 | #[derive(Debug)] |
| 39 | #[allow(clippy::module_name_repetitions)] |
| 40 | pub struct CompletionItem { |
| 41 | pub label: String, |
| 42 | pub kind: CompletionItemKind, |
| 43 | pub sort_text: Option<String>, |
| 44 | pub detail: Option<String>, |
| 45 | pub additional_text_edits: Option<Vec<(Span, String)>>, |
| 46 | } |
| 47 | |
| 48 | impl CompletionItem { |
| 49 | #[must_use] |
| 50 | pub fn new(label: String, kind: CompletionItemKind) -> Self { |
| 51 | CompletionItem { |
| 52 | label, |
| 53 | kind, |
| 54 | sort_text: None, |
| 55 | detail: None, |
| 56 | additional_text_edits: None, |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | #[derive(Debug, PartialEq)] |
| 62 | pub struct Definition { |
| 63 | pub source: String, |
| 64 | pub offset: u32, |
| 65 | } |
| 66 | |
| 67 | #[derive(Debug, PartialEq)] |
| 68 | pub struct Hover { |
| 69 | pub contents: String, |
| 70 | pub span: Span, |
| 71 | } |
| 72 | |
| 73 | #[derive(Debug, PartialEq)] |
| 74 | pub struct SignatureHelp { |
| 75 | pub signatures: Vec<SignatureInformation>, |
| 76 | pub active_signature: u32, |
| 77 | pub active_parameter: u32, |
| 78 | } |
| 79 | |
| 80 | #[derive(Debug, PartialEq)] |
| 81 | pub struct SignatureInformation { |
| 82 | pub label: String, |
| 83 | pub documentation: Option<String>, |
| 84 | pub parameters: Vec<ParameterInformation>, |
| 85 | } |
| 86 | |
| 87 | #[derive(Debug, PartialEq)] |
| 88 | pub struct ParameterInformation { |
| 89 | pub label: Span, |
| 90 | pub documentation: Option<String>, |
| 91 | } |
| 92 | |