gitlab_ci_ls_parser/
lib.rs1use std::collections::HashMap;
2
3use lsp_server::RequestId;
4use lsp_types::Diagnostic;
5
6mod git;
7pub mod handlers;
8mod parser;
9mod parser_utils;
10mod treesitter;
11
12#[derive(Debug, Default)]
13pub struct LSPPosition {
14 pub line: u32,
15 pub character: u32,
16}
17
18#[derive(Debug, Default)]
19pub struct Range {
20 pub start: LSPPosition,
21 pub end: LSPPosition,
22}
23
24#[derive(Debug)]
25pub struct DefinitionResult {
26 pub id: RequestId,
27 pub locations: Vec<LSPLocation>,
28}
29
30#[derive(Debug)]
31pub struct ReferencesResult {
32 pub id: RequestId,
33 pub locations: Vec<GitlabElement>,
34}
35
36#[derive(Debug)]
37pub struct CompletionResult {
38 pub id: RequestId,
39 pub list: Vec<LSPCompletion>,
40}
41
42#[derive(Debug)]
43pub struct LSPCompletion {
44 pub label: String,
45 pub details: Option<String>,
46 pub location: LSPLocation,
47}
48
49#[derive(Debug, Default)]
50pub struct LSPLocation {
51 pub uri: String,
52 pub range: Range,
53}
54
55#[derive(Debug)]
56pub struct HoverResult {
57 pub id: RequestId,
58 pub content: String,
59}
60
61#[derive(Debug)]
62pub struct DiagnosticsResult {
63 pub id: RequestId,
64 pub diagnostics: Vec<Diagnostic>,
65}
66
67#[derive(Debug)]
68pub enum LSPResult {
69 Hover(HoverResult),
70 Completion(CompletionResult),
71 Definition(DefinitionResult),
72 Diagnostics(DiagnosticsResult),
73 References(ReferencesResult),
74}
75
76#[derive(Debug, Clone)]
77pub struct GitlabFile {
78 pub path: String,
79 pub content: String,
80}
81
82#[derive(Debug, Default)]
83pub struct GitlabElement {
84 pub key: String,
85 pub content: Option<String>,
86 pub uri: String,
87 pub range: Range,
88}
89
90#[derive(Debug)]
91pub struct ParseResults {
92 pub files: Vec<GitlabFile>,
93 pub nodes: Vec<GitlabElement>,
94 pub stages: Vec<GitlabElement>,
95 pub variables: Vec<GitlabElement>,
96}
97
98#[derive(Clone, Debug)]
99pub struct LSPConfig {
100 pub root_dir: String,
101 pub cache_path: String,
102 pub package_map: HashMap<String, String>,
103 pub remote_urls: Vec<String>,
104}
105
106#[derive(Debug)]
107pub struct LocalInclude {
108 pub path: String,
109}
110#[derive(Debug, Default)]
111pub struct RemoteInclude {
112 pub project: Option<String>,
113 pub reference: Option<String>,
114 pub file: Option<String>,
115}
116
117impl RemoteInclude {
118 pub fn is_valid(&self) -> bool {
119 self.project.is_some() && self.reference.is_some() && self.file.is_some()
120 }
121}
122
123#[derive(Debug)]
124pub struct IncludeInformation {
125 pub remote: Option<RemoteInclude>,
126 pub local: Option<LocalInclude>,
127}