This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
/
index.d.ts
331 lines (279 loc) · 9.15 KB
/
index.d.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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
declare module 'atom-ide' {
import { Disposable, Grammar, Point, Range, TextEditor } from 'atom';
export interface OutlineProvider {
name: string;
// If there are multiple providers for a given grammar, the one with the highest priority will be
// used.
priority: number;
grammarScopes: string[];
updateOnEdit?: boolean;
getOutline: (editor: TextEditor) => Promise<Outline | null>;
}
export interface OutlineTree {
icon?: string; // from atom$Octicon | atom$OcticonsPrivate (types not allowed over rpc so we use string)
// Must be one or the other. If both are present, tokenizedText is preferred.
plainText?: string;
tokenizedText?: TokenizedText;
representativeName?: string;
startPosition: Point;
endPosition?: Point;
children: OutlineTree[];
}
export interface Outline {
outlineTrees: OutlineTree[];
}
export type TokenKind =
| 'keyword'
| 'class-name'
| 'constructor'
| 'method'
| 'param'
| 'string'
| 'whitespace'
| 'plain'
| 'type';
export interface TextToken {
kind: TokenKind;
value: string;
}
export type TokenizedText = TextToken[];
export interface DefinitionProvider {
name: string;
priority: number;
grammarScopes: string[];
getDefinition: (editor: TextEditor, position: Point) => Promise<DefinitionQueryResult | null>;
}
export type IdeUri = string;
export interface Definition {
path: IdeUri;
position: Point;
range?: Range;
id?: string;
name?: string;
language: string;
projectRoot?: IdeUri;
}
export interface DefinitionQueryResult {
queryRange: Range[];
definitions: Definition[];
}
export interface FindReferencesProvider {
// Return true if your provider supports finding references for the provided TextEditor.
isEditorSupported(editor: TextEditor): boolean | Promise<boolean>;
// `findReferences` will only be called if `isEditorSupported` previously returned true
// for the given TextEditor.
findReferences(editor: TextEditor, position: Point): Promise<FindReferencesReturn | null>;
}
export interface Reference {
uri: IdeUri; // URI of the file path
name: string | null; // name of calling method/function/symbol
range: Range;
}
export interface FindReferencesData {
type: 'data';
baseUri: IdeUri;
referencedSymbolName: string;
references: Reference[];
}
export interface FindReferencesError {
type: 'error';
message: string;
}
export type FindReferencesReturn = FindReferencesData | FindReferencesError;
export type MarkedString =
| {
type: 'markdown',
value: string,
}
| {
type: 'snippet',
grammar: Grammar,
value: string,
};
// This omits the React variant.
export interface Datatip {
markedStrings: MarkedString[];
range: Range;
pinnable?: boolean;
}
export interface DatatipProvider {
datatip(
editor: TextEditor,
bufferPosition: Point,
// The mouse event that triggered the datatip.
// This is null for manually toggled datatips.
mouseEvent: MouseEvent | null,
): Promise<Datatip>;
validForScope(scopeName: string): boolean;
// A unique name for the provider to be used for analytics.
// It is recommended that it be the name of the provider's package.
providerName: string;
priority: number;
grammarScopes: string[];
}
export interface DatatipService {
addProvider(provider: DatatipProvider): Disposable;
}
export interface FileCodeFormatProvider {
formatEntireFile: (editor: TextEditor, range: Range) => Promise<TextEdit[]>;
priority: number;
grammarScopes: string[];
}
export interface RangeCodeFormatProvider {
formatCode: (editor: TextEditor, range: Range) => Promise<TextEdit[]>;
priority: number;
grammarScopes: string[];
}
export interface OnSaveCodeFormatProvider {
formatOnSave: (editor: TextEditor) => Promise<TextEdit[]>;
priority: number;
grammarScopes: string[];
}
export interface OnTypeCodeFormatProvider {
formatAtPosition: (editor: TextEditor, position: Point, character: string) => Promise<TextEdit[]>;
priority: number;
grammarScopes: string[];
}
export interface TextEdit {
oldRange: Range;
newText: string;
// If included, this will be used to verify that the edit still applies cleanly.
oldText?: string;
}
export interface CodeHighlightProvider {
highlight(editor: TextEditor, bufferPosition: Point): Promise<Range[] | null>;
priority: number;
grammarScopes: string[];
}
export type DiagnosticType = 'Error' | 'Warning' | 'Info';
export interface Diagnostic {
providerName: string;
type: DiagnosticType;
filePath: string;
text?: string;
range: Range;
}
export interface CodeAction {
apply(): Promise<void>;
getTitle(): Promise<string>;
dispose(): void;
}
export interface CodeActionProvider {
grammarScopes: string[];
priority: number;
getCodeActions(
editor: TextEditor,
range: Range,
diagnostics: Diagnostic[],
): Promise<CodeAction[] | null>;
}
export interface BusySignalOptions {
// Can say that a busy signal will only appear when a given file is open.
// Default = null, meaning the busy signal applies to all files.
onlyForFile?: IdeUri;
// Is user waiting for computer to finish a task? (traditional busy spinner)
// or is the computer waiting for user to finish a task? (action required)
// Default = spinner.
waitingFor?: 'computer' | 'user';
// Debounce it? default = true for busy-signal, and false for action-required.
debounce?: boolean;
// If onClick is set, then the tooltip will be clickable. Default = null.
onDidClick?: () => void;
}
export interface BusySignalService {
// Activates the busy signal with the given title and returns the promise
// from the provided callback.
// The busy signal automatically deactivates when the returned promise
// either resolves or rejects.
reportBusyWhile<T>(
title: string,
f: () => Promise<T>,
options?: BusySignalOptions,
): Promise<T>;
// Activates the busy signal. Set the title in the returned BusySignal
// object (you can update the title multiple times) and dispose it when done.
reportBusy(title: string, options?: BusySignalOptions): BusyMessage;
// This is a no-op. When someone consumes the busy service, they get back a
// reference to the single shared instance, so disposing of it would be wrong.
dispose(): void;
}
export interface BusyMessage {
// You can set/update the title.
setTitle(title: string): void;
// Dispose of the signal when done to make it go away.
dispose(): void;
}
export type SignatureHelpRegistry = (provider: SignatureHelpProvider) => Disposable;
/**
* Signature help is activated when:
* - upon keystroke, any provider with a matching grammar scope contains
* the pressed key inside its triggerCharacters set
* - the signature-help:show command is manually activated
*
* Once signature help has been triggered, the provider will be queried immediately
* with the current cursor position, and then repeatedly upon cursor movements
* until a null/empty signature is returned.
*
* Returned signatures will be displayed in a small datatip at the current cursor.
* The highest-priority provider with a non-null result will be used.
*/
export interface SignatureHelpProvider {
priority: number;
grammarScopes: string[];
// A set of characters that will trigger signature help when typed.
// If a null/empty set is provided, only manual activation of the command works.
triggerCharacters?: Set<string>;
getSignatureHelp(editor: TextEditor, point: Point): Promise<SignatureHelp | null>;
}
export interface SignatureHelp {
signatures: Signature[];
activeSignature?: number;
activeParameter?: number;
}
export interface Signature {
label: string;
documentation?: string;
parameters?: SignatureParameter[];
}
export interface SignatureParameter {
label: string;
documentation?: string;
}
export interface SourceInfo {
id: string;
name: string;
start?: () => void;
stop?: () => void;
}
// Console service
export type ConsoleService = (options: SourceInfo) => ConsoleApi;
export interface ConsoleApi {
setStatus(status: OutputProviderStatus): void;
append(message: Message): void;
dispose(): void;
log(object: string): void;
error(object: string): void;
warn(object: string): void;
info(object: string): void;
}
export type OutputProviderStatus = 'starting' | 'running' | 'stopped';
export interface Message {
text: string;
level: Level;
tags?: string[] | null;
kind?: MessageKind | null;
scopeName?: string | null;
}
export type TaskLevelType = 'info' | 'log' | 'warning' | 'error' | 'debug' | 'success';
export type Level = TaskLevelType | Color;
type Color =
| 'red'
| 'orange'
| 'yellow'
| 'green'
| 'blue'
| 'purple'
| 'violet'
| 'rainbow';
export type MessageKind = 'message' | 'request' | 'response';
}