-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathtypes.ts
212 lines (177 loc) · 4.86 KB
/
types.ts
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import * as vscode from "vscode";
import type { Version } from "./version";
type Dict<T> = { [x: string]: T };
export type Tool = { path: string; version: Version };
export type ToolCheckSuccessResult = {
tool: Tool;
error?: undefined;
};
export type ToolCheckErrorResult = {
tool?: undefined;
error: string;
};
type ResultImpl = ToolCheckSuccessResult | ToolCheckErrorResult;
export class ToolCheckResult {
private readonly result: ResultImpl;
private constructor(result: ResultImpl) {
this.result = result;
}
static newError(error: string) {
return new ToolCheckResult({ error });
}
static newTool(tool: Tool) {
return new ToolCheckResult({ tool });
}
private hasErrorImpl(result: ResultImpl): result is ToolCheckErrorResult {
return !!result.error;
}
isError(): boolean {
return this.hasErrorImpl(this.result);
}
get error(): string {
if (!this.hasErrorImpl(this.result)) {
throw new Error("Wrong invocation of getter for 'error', check the state first");
}
return this.result.error;
}
get tool(): Tool {
if (this.hasErrorImpl(this.result)) {
throw new Error("Wrong invocation of getter for 'tool', check the state first");
}
return this.result.tool;
}
}
export type ToolCheckFunc = () => Promise<ToolCheckResult>;
export type LinterConfiguration = {
enabled: boolean;
};
export type LanguageServer = "Swift-MesonLSP" | "mesonlsp" | null;
export type ModifiableExtension = "ms-vscode.cpptools" | "rust-lang.rust-analyzer";
export type FormattingProvider = "muon" | "meson";
export interface ExtensionConfiguration {
configureOnOpen: boolean | "ask";
configureOptions: string[];
configureEnvironment: { [key: string]: string };
setupOptions: string[];
testOptions: string[];
testEnvironment: { [key: string]: string };
benchmarkOptions: string[];
buildFolder: string;
mesonPath: string;
muonPath: string;
linting: { enabled: boolean };
linter: {
muon: LinterConfiguration;
};
formatting: {
enabled: boolean;
provider: FormattingProvider | "auto";
muonConfig: string | null;
mesonConfig: string | null;
};
debugOptions: object;
languageServer: LanguageServer;
languageServerPath: string;
downloadLanguageServer: boolean | "ask";
selectRootDir: boolean;
modifySettings: boolean | ModifiableExtension[];
}
export interface TaskQuickPickItem extends vscode.QuickPickItem {
task: vscode.Task;
}
export type LanguageID = string;
export type TargetType =
| "executable"
| "static library"
| "shared library"
| "shared module"
| "custom"
| "run"
| "jar";
export type OptionType = "string" | "boolean" | "combo" | "integer" | "array";
export interface OptionTypeMap {
string: string;
boolean: boolean;
combo: string[];
integer: number;
array: string[];
}
export type SectionType = "core" | "backend" | "base" | "compiler" | "directory" | "user" | "test";
export interface TargetSource {
language: LanguageID;
compiler: string[];
parameters: string[];
sources: string[] | null;
generated_sources: string[] | null;
}
export interface Target {
name: string;
id: string;
type: TargetType;
defined_in: string;
subproject: string | null;
filename: string[];
build_by_default: boolean;
target_sources?: TargetSource[];
installed: boolean;
install_filename?: string;
}
export interface Subproject {
name: string;
version: string;
descriptive_name: string;
}
export interface ProjectInfo {
version: string;
descriptive_name: string;
subproject_dir: "subprojects";
subprojects: Subproject[];
}
export interface BuildOption<T extends OptionType> {
name: string;
desciption: string;
type: T;
value: OptionTypeMap[T];
machine: OptionTypeMap[T];
}
export interface Dependency {
name: string;
required: boolean;
compile_args: string[];
conditional: boolean;
has_fallback: boolean;
}
export interface CompilerDesc {
id: string;
exelist: string[];
}
export type Compiler = Record<string, CompilerDesc>;
export interface Test {
name: string;
workdir: string | null;
timeout: string;
suite: string[];
is_parallel: boolean;
cmd: string[];
env: Dict<string>;
depends: string[];
}
interface StdDebugEnvironmentConfiguration {
env: { [key: string]: string };
}
interface CppDebugEnvironmentConfiguration {
environment: { name: string; value: string }[];
}
export type DebugEnvironmentConfiguration = StdDebugEnvironmentConfiguration | CppDebugEnvironmentConfiguration;
export type Targets = Target[];
export type BuildOptions = BuildOption<any>[];
export type Dependencies = Dependency[];
export type Compilers = Record<string, Compiler>;
export type Tests = Test[];
export enum SettingsKey {
downloadLanguageServer = "downloadLanguageServer",
languageServer = "languageServer",
configureOnOpen = "configureOnOpen",
selectRootDir = "selectRootDir",
modifySettings = "modifySettings",
}