This repository has been archived by the owner on Dec 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
/
types.js
93 lines (83 loc) · 2.31 KB
/
types.js
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
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
* @format
*/
/**
* Consumers of the "datatip" service get an instance of this service.
* You can register providers (which will be triggered on mouseover) or manually
* create pinned datatips on-demand.
*/
export type DatatipService = {
addProvider(provider: DatatipProvider): IDisposable,
addModifierProvider(provider: ModifierDatatipProvider): IDisposable,
createPinnedDataTip(
datatip: Datatip,
editor: TextEditor,
options?: PinnedDatatipOptions,
): IDisposable,
};
export type PinnedDatatipOptions = {|
// Defaults to 'end-of-line'.
position?: PinnedDatatipPosition,
// Defaults to true.
showRangeHighlight?: boolean,
|};
export type PinnedDatatipPosition = 'end-of-line' | 'above-range';
export type DatatipProvider = {
priority: number,
grammarScopes?: Array<string>,
// 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,
datatip(
editor: atom$TextEditor,
bufferPosition: atom$Point,
): Promise<?Datatip>,
};
export type ModifierDatatipProvider = {
priority: number,
grammarScopes?: Array<string>,
providerName: string,
modifierDatatip(
editor: atom$TextEditor,
bufferPosition: atom$Point,
heldKeys: Set<ModifierKey>,
): Promise<?Datatip>,
};
export type AnyDatatipProvider = DatatipProvider | ModifierDatatipProvider;
export type Datatip =
| {|
component: React$ComponentType<any>,
range: atom$Range,
pinnable?: boolean,
|}
| {|
markedStrings: Array<MarkedString>,
range: atom$Range,
pinnable?: boolean,
|};
// Borrowed from the LSP API.
export type MarkedString =
| {
type: 'markdown',
value: string,
}
| {
type: 'snippet',
grammar: atom$Grammar,
value: string,
};
export const ModifierKeys = Object.freeze({
META: 'metaKey',
SHIFT: 'shiftKey',
ALT: 'altKey',
CTRL: 'ctrlKey',
});
export type ModifierKey = 'metaKey' | 'shiftKey' | 'altKey' | 'ctrlKey';