Skip to content

Commit 723e844

Browse files
authored
Extension: Importers View and separate LSP protocol package (#8747)
1 parent e2deeec commit 723e844

24 files changed

+690
-346
lines changed

.vscode/launch.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"outFiles": [
1313
"${workspaceFolder}/packages/utils/parcelforvscode/out/**/*.js"
1414
],
15-
"preLaunchTask": "npm: watch - packages/utils/parcelforvscode",
15+
"preLaunchTask": "Watch VSCode Extension",
1616
"request": "launch",
1717
"type": "extensionHost"
1818
}

.vscode/tasks.json

+38
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
11
{
22
"version": "2.0.0",
33
"tasks": [
4+
{
5+
"path": "packages/utils/parcel-lsp/",
6+
"label": "npm: watch - packages/utils/parcel-lsp",
7+
"type": "npm",
8+
"script": "watch",
9+
"problemMatcher": "$tsc-watch",
10+
"isBackground": true,
11+
"presentation": {
12+
"reveal": "never"
13+
},
14+
"group": {
15+
"kind": "build",
16+
"isDefault": true
17+
}
18+
},
19+
{
20+
"path": "packages/utils/parcel-lsp-protocol/",
21+
"label": "npm: watch - packages/utils/parcel-lsp-protocol",
22+
"type": "npm",
23+
"script": "watch",
24+
"problemMatcher": "$tsc-watch",
25+
"isBackground": true,
26+
"presentation": {
27+
"reveal": "never"
28+
},
29+
"group": {
30+
"kind": "build",
31+
"isDefault": true
32+
}
33+
},
434
{
535
"path": "packages/utils/parcelforvscode/",
636
"label": "npm: watch - packages/utils/parcelforvscode",
@@ -15,6 +45,14 @@
1545
"kind": "build",
1646
"isDefault": true
1747
}
48+
},
49+
{
50+
"label": "Watch VSCode Extension",
51+
"dependsOn": [
52+
"npm: watch - packages/utils/parcel-lsp",
53+
"npm: watch - packages/utils/parcel-lsp-protocol",
54+
"npm: watch - packages/utils/parcelforvscode"
55+
]
1856
}
1957
]
2058
}
+188
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
// @flow
2+
declare module 'vscode-languageserver' {
3+
declare export opaque type ODiagnosticTag;
4+
declare export opaque type ODiagnosticSeverity;
5+
6+
/**
7+
* The diagnostic tags.
8+
*
9+
* @since 3.15.0
10+
*/
11+
declare export var DiagnosticTag: {|
12+
/**
13+
* Unused or unnecessary code.
14+
*
15+
* Clients are allowed to render diagnostics with this tag faded out instead of having
16+
* an error squiggle.
17+
*/
18+
Unnecessary: ODiagnosticTag,
19+
/**
20+
* Deprecated or obsolete code.
21+
*
22+
* Clients are allowed to rendered diagnostics with this tag strike through.
23+
*/
24+
Deprecated: ODiagnosticTag,
25+
|};
26+
27+
/**
28+
* The diagnostic's severity.
29+
*/
30+
declare export var DiagnosticSeverity: {|
31+
/**
32+
* Reports an error.
33+
*/
34+
Error: ODiagnosticSeverity,
35+
/**
36+
* Reports a warning.
37+
*/
38+
Warning: ODiagnosticSeverity,
39+
/**
40+
* Reports an information.
41+
*/
42+
Information: ODiagnosticSeverity,
43+
/**
44+
* Reports a hint.
45+
*/
46+
Hint: ODiagnosticSeverity,
47+
|};
48+
49+
declare export type DocumentUri = string;
50+
51+
/**
52+
* A literal to identify a text document in the client.
53+
*/
54+
declare export type TextDocumentIdentifier = {|
55+
uri: DocumentUri,
56+
|};
57+
58+
/**
59+
* Position in a text document expressed as zero-based line and character
60+
* offset. Prior to 3.17 the offsets were always based on a UTF-16 string
61+
* representation. So a string of the form `a𐐀b` the character offset of the
62+
* character `a` is 0, the character offset of `𐐀` is 1 and the character
63+
* offset of b is 3 since `𐐀` is represented using two code units in UTF-16.
64+
* Since 3.17 clients and servers can agree on a different string encoding
65+
* representation (e.g. UTF-8). The client announces it's supported encoding
66+
* via the client capability [`general.positionEncodings`](#clientCapabilities).
67+
* The value is an array of position encodings the client supports, with
68+
* decreasing preference (e.g. the encoding at index `0` is the most preferred
69+
* one). To stay backwards compatible the only mandatory encoding is UTF-16
70+
* represented via the string `utf-16`. The server can pick one of the
71+
* encodings offered by the client and signals that encoding back to the
72+
* client via the initialize result's property
73+
* [`capabilities.positionEncoding`](#serverCapabilities). If the string value
74+
* `utf-16` is missing from the client's capability `general.positionEncodings`
75+
* servers can safely assume that the client supports UTF-16. If the server
76+
* omits the position encoding in its initialize result the encoding defaults
77+
* to the string value `utf-16`. Implementation considerations: since the
78+
* conversion from one encoding into another requires the content of the
79+
* file / line the conversion is best done where the file is read which is
80+
* usually on the server side.
81+
*
82+
* Positions are line end character agnostic. So you can not specify a position
83+
* that denotes `\r|\n` or `\n|` where `|` represents the character offset.
84+
*
85+
* @since 3.17.0 - support for negotiated position encoding.
86+
*/
87+
declare export type Position = {|line: number, character: number|};
88+
89+
/**
90+
* A range in a text document expressed as (zero-based) start and end positions.
91+
*
92+
* If you want to specify a range that contains a line including the line ending
93+
* character(s) then use an end position denoting the start of the next line.
94+
* For example:
95+
* ```ts
96+
* {
97+
* start: { line: 5, character: 23 }
98+
* end : { line 6, character : 0 }
99+
* }
100+
* ```
101+
*/
102+
declare export type Range = {|start: Position, end: Position|};
103+
104+
/**
105+
* Structure to capture a description for an error code.
106+
*
107+
* @since 3.16.0
108+
*/
109+
declare export type CodeDescription = {|href: string|};
110+
111+
/**
112+
* Represents a location inside a resource, such as a line
113+
* inside a text file.
114+
*/
115+
declare export type Location = {|uri: string, range: Range|};
116+
117+
/**
118+
* The DiagnosticRelatedInformation namespace provides helper functions to work with
119+
* [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.
120+
*/
121+
declare export type DiagnosticRelatedInformation = {|
122+
location: Location,
123+
message: string,
124+
|};
125+
126+
/**
127+
* Represents a diagnostic, such as a compiler error or warning. Diagnostic objects
128+
* are only valid in the scope of a resource.
129+
*/
130+
declare export type Diagnostic = {|
131+
range: Range,
132+
severity?: ODiagnosticSeverity,
133+
code?: number | string,
134+
codeDescription?: CodeDescription,
135+
source?: string,
136+
message: string,
137+
tags?: ODiagnosticTag[],
138+
relatedInformation?: DiagnosticRelatedInformation[],
139+
data?: mixed,
140+
|};
141+
142+
/**
143+
* A parameter literal used in requests to pass a text document and a position inside that
144+
* document.
145+
*/
146+
declare export type TextDocumentPositionParams = {
147+
textDocument: TextDocumentIdentifier,
148+
position: Position,
149+
...
150+
};
151+
152+
/**
153+
* Represents the connection of two locations. Provides additional metadata over normal [locations](#Location),
154+
* including an origin range.
155+
*/
156+
declare export type LocationLink = {|
157+
/**
158+
* Span of the origin of this link.
159+
*
160+
* Used as the underlined span for mouse interaction. Defaults to the word range at
161+
* the definition position.
162+
*/
163+
originSelectionRange?: Range,
164+
/**
165+
* The target resource identifier of this link.
166+
*/
167+
targetUri: DocumentUri,
168+
/**
169+
* The full target range of this link. If the target for example is a symbol then target range is the
170+
* range enclosing this symbol not including leading/trailing whitespace but everything else
171+
* like comments. This information is typically used to highlight the range in the editor.
172+
*/
173+
targetRange: Range,
174+
/**
175+
* The range that should be selected and revealed when this link is being followed, e.g the name of a function.
176+
* Must be contained by the `targetRange`. See also `DocumentSymbol#range`
177+
*/
178+
targetSelectionRange: Range,
179+
|};
180+
181+
/**
182+
* Information about where a symbol is defined.
183+
*
184+
* Provides additional metadata over normal [location](#Location) definitions, including the range of
185+
* the defining symbol
186+
*/
187+
declare export type DefinitionLink = LocationLink;
188+
}

0 commit comments

Comments
 (0)