microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1d2f76e63ca3b68b75bc0cbd77d067a3d5f03901

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

language_service/src/protocol.rs

91lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4use qsc::{PackageType, TargetProfile};
5
6/// Workspace configuration
7#[derive(Clone, Debug, Default)]
8pub 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)]
15pub struct Span {
16 pub start: u32,
17 pub end: u32,
18}
19
20#[derive(Copy, Clone, Debug, PartialEq)]
21#[allow(clippy::module_name_repetitions)]
22pub 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)]
34pub struct CompletionList {
35 pub items: Vec<CompletionItem>,
36}
37
38#[derive(Debug)]
39#[allow(clippy::module_name_repetitions)]
40pub 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
48impl 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)]
62pub struct Definition {
63 pub source: String,
64 pub offset: u32,
65}
66
67#[derive(Debug, PartialEq)]
68pub struct Hover {
69 pub contents: String,
70 pub span: Span,
71}
72
73#[derive(Debug, PartialEq)]
74pub struct SignatureHelp {
75 pub signatures: Vec<SignatureInformation>,
76 pub active_signature: u32,
77 pub active_parameter: u32,
78}
79
80#[derive(Debug, PartialEq)]
81pub struct SignatureInformation {
82 pub label: String,
83 pub documentation: Option<String>,
84 pub parameters: Vec<ParameterInformation>,
85}
86
87#[derive(Debug, PartialEq)]
88pub struct ParameterInformation {
89 pub label: Span,
90 pub documentation: Option<String>,
91}
92