typescript-language-server 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +77 -0
- package/README.md +253 -31
- package/lib/calls.js +9 -9
- package/lib/calls.js.map +1 -1
- package/lib/cli.js +6 -11
- package/lib/cli.js.map +1 -1
- package/lib/commands.d.ts +4 -1
- package/lib/commands.d.ts.map +1 -1
- package/lib/commands.js +5 -2
- package/lib/commands.js.map +1 -1
- package/lib/completion.d.ts.map +1 -1
- package/lib/completion.js +60 -34
- package/lib/completion.js.map +1 -1
- package/lib/diagnostic-queue.d.ts +4 -4
- package/lib/diagnostic-queue.d.ts.map +1 -1
- package/lib/diagnostic-queue.js +3 -3
- package/lib/diagnostic-queue.js.map +1 -1
- package/lib/document-symbol.js +8 -8
- package/lib/document-symbol.js.map +1 -1
- package/lib/file-lsp-server.spec.js +27 -5
- package/lib/file-lsp-server.spec.js.map +1 -1
- package/lib/hover.js +6 -6
- package/lib/hover.js.map +1 -1
- package/lib/lsp-connection.d.ts.map +1 -1
- package/lib/lsp-connection.js +3 -0
- package/lib/lsp-connection.js.map +1 -1
- package/lib/lsp-protocol.calls.proposed.d.ts.map +1 -1
- package/lib/lsp-protocol.calls.proposed.js.map +1 -1
- package/lib/lsp-protocol.inlayHints.proposed.d.ts +36 -0
- package/lib/lsp-protocol.inlayHints.proposed.d.ts.map +1 -0
- package/lib/lsp-protocol.inlayHints.proposed.js +25 -0
- package/lib/lsp-protocol.inlayHints.proposed.js.map +1 -0
- package/lib/lsp-server.d.ts +10 -2
- package/lib/lsp-server.d.ts.map +1 -1
- package/lib/lsp-server.js +241 -118
- package/lib/lsp-server.js.map +1 -1
- package/lib/lsp-server.spec.js +294 -47
- package/lib/lsp-server.spec.js.map +1 -1
- package/lib/modules-resolver.spec.js +1 -1
- package/lib/modules-resolver.spec.js.map +1 -1
- package/lib/organize-imports.d.ts +2 -1
- package/lib/organize-imports.d.ts.map +1 -1
- package/lib/organize-imports.js +7 -5
- package/lib/organize-imports.js.map +1 -1
- package/lib/organize-imports.spec.js +15 -8
- package/lib/organize-imports.spec.js.map +1 -1
- package/lib/protocol-translation.d.ts +8 -4
- package/lib/protocol-translation.d.ts.map +1 -1
- package/lib/protocol-translation.js +22 -11
- package/lib/protocol-translation.js.map +1 -1
- package/lib/quickfix.js +1 -1
- package/lib/quickfix.js.map +1 -1
- package/lib/test-utils.js +4 -4
- package/lib/test-utils.js.map +1 -1
- package/lib/ts-protocol.d.ts +11 -1
- package/lib/ts-protocol.d.ts.map +1 -1
- package/lib/ts-protocol.js.map +1 -1
- package/lib/tsp-client.d.ts +2 -0
- package/lib/tsp-client.d.ts.map +1 -1
- package/lib/tsp-client.js +20 -11
- package/lib/tsp-client.js.map +1 -1
- package/lib/tsp-client.spec.js +28 -8
- package/lib/tsp-client.spec.js.map +1 -1
- package/lib/tsp-command-types.d.ts +14 -1
- package/lib/tsp-command-types.d.ts.map +1 -1
- package/lib/tsp-command-types.js +21 -1
- package/lib/tsp-command-types.js.map +1 -1
- package/lib/utils/api.d.ts +45 -0
- package/lib/utils/api.d.ts.map +1 -0
- package/lib/utils/api.js +95 -0
- package/lib/utils/api.js.map +1 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,83 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
## [0.7.0] - 2021-11-09
|
|
5
|
+
|
|
6
|
+
### Breaking
|
|
7
|
+
|
|
8
|
+
Changes to default options sent to tsserver could affect behavior (hopefully for the better). Read changes below for more details.
|
|
9
|
+
|
|
10
|
+
### Changes
|
|
11
|
+
|
|
12
|
+
- **feat**: include import specifier for import completions (#281)
|
|
13
|
+
For completions that import from another package, the completions will include a "detail" field with the name of the module.
|
|
14
|
+
|
|
15
|
+
Also aligned some other logic with the typescript language services used in VSCode:
|
|
16
|
+
* annotate the completions with the local name of the import when completing a path in import foo from '...'
|
|
17
|
+
* update completion "sortText" regardless if the completion "isRecommended"
|
|
18
|
+
|
|
19
|
+
- **feat**: allow skip destructive actions on running OrganizeImports (#228)
|
|
20
|
+
Add support for the new skipDestructiveCodeActions argument to TypeScript's organize imports feature - [1] to support [2].
|
|
21
|
+
|
|
22
|
+
Support is added in two places:
|
|
23
|
+
* Automatically inferring the proper value based on diagnostics for the file when returning code actions.
|
|
24
|
+
* Supporting sending it when manually executing the organize imports action.
|
|
25
|
+
|
|
26
|
+
Also added documentation to the readme about the supported commands that can be manually executed.
|
|
27
|
+
|
|
28
|
+
[1] https://github.com/microsoft/TypeScript/issues/43051
|
|
29
|
+
[2] https://github.com/apexskier/nova-typescript/issues/273
|
|
30
|
+
|
|
31
|
+
- **feat**: support running server on files without root workspace (#286)
|
|
32
|
+
The tsserver seems to be good at inferring the project configuration when opening single files without a workspace so don't crash on missing `rootPath`.
|
|
33
|
+
|
|
34
|
+
- **feat**: add `disableAutomaticTypingAcquisition` option to disable automatic type acquisition (#285)
|
|
35
|
+
- **feat**: update default tsserver options (#284)
|
|
36
|
+
Set the following additional options by default:
|
|
37
|
+
```
|
|
38
|
+
allowRenameOfImportPath: true,
|
|
39
|
+
displayPartsForJSDoc: true,
|
|
40
|
+
generateReturnInDocTemplate: true,
|
|
41
|
+
includeAutomaticOptionalChainCompletions: true,
|
|
42
|
+
includeCompletionsForImportStatements: true,
|
|
43
|
+
includeCompletionsWithSnippetText: true,
|
|
44
|
+
```
|
|
45
|
+
This aligns more with the default options of the typescript language services in VSCode.
|
|
46
|
+
- **feat**: announce support for "source.organizeImports.ts-ls" action (#283)
|
|
47
|
+
Announcing support for that code action allows editors that support
|
|
48
|
+
running code actions on save to automatically run the code action if
|
|
49
|
+
the user has configured the editor with settings like
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
"codeActionsOnSave": {
|
|
53
|
+
"source.organizeImports": true,
|
|
54
|
+
// or
|
|
55
|
+
"source.organizeImports.ts-ls": true,
|
|
56
|
+
},
|
|
57
|
+
```
|
|
58
|
+
- **chore**: change default log level from "warn" to "info" (#287)
|
|
59
|
+
|
|
60
|
+
## [0.6.5] - 2021-11-03
|
|
61
|
+
|
|
62
|
+
- fix: normalize client and tsserver paths (#275)
|
|
63
|
+
This should ensure consistent behavior regradless of the platform. Previously some functionality could be malfunctioning on Windows depending on the LSP client used due to using non-normalized file paths.
|
|
64
|
+
- Handle the `APPLY_COMPLETION_CODE_ACTION` command internally (#270)
|
|
65
|
+
This means that the clients that have implemented a custom handling for the `_typescript.applyCompletionCodeAction` command can remove that code.
|
|
66
|
+
Without removing the custom handling everything should work as before but some edge cases might work better when custom handling is removed.
|
|
67
|
+
- fix: ignore empty code blocks in content returned from `textDocument/hover` (#276)
|
|
68
|
+
- fix: remove unsupported --node-ipc and --socket options (#278)
|
|
69
|
+
|
|
70
|
+
## [0.6.4] - 2021-10-12
|
|
71
|
+
|
|
72
|
+
- Fix broken logging (#267)
|
|
73
|
+
- Add support for `workspace/didChangeConfiguration` and setting formatting options per language (#268)
|
|
74
|
+
- Add option to set inlayHints preferences by language (#266)
|
|
75
|
+
|
|
76
|
+
## [0.6.3] - 2021-10-27
|
|
77
|
+
|
|
78
|
+
- Implement experimental inlay hints (#259) ([documentation](https://github.com/typescript-language-server/typescript-language-server#typescriptinlayhints-experimental-supported-from-typescript-v442))
|
|
79
|
+
- Send diagnostics even to clients that don't signal support (#261) (reverts #229)
|
|
80
|
+
|
|
4
81
|
## [0.6.2] - 2021-08-16
|
|
5
82
|
|
|
6
83
|
- Mark completion items as deprecated if JSDoc says so (#227)
|
package/README.md
CHANGED
|
@@ -11,13 +11,13 @@ Based on concepts and ideas from https://github.com/prabirshrestha/typescript-la
|
|
|
11
11
|
|
|
12
12
|
Maintained by a [community of contributors](https://github.com/typescript-language-server/typescript-language-server/graphs/contributors) like you
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
## Installing
|
|
15
15
|
|
|
16
16
|
```sh
|
|
17
17
|
npm install -g typescript-language-server
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
## Running the language server
|
|
21
21
|
|
|
22
22
|
```
|
|
23
23
|
typescript-language-server --stdio
|
|
@@ -32,10 +32,8 @@ typescript-language-server --stdio
|
|
|
32
32
|
Options:
|
|
33
33
|
|
|
34
34
|
-V, --version output the version number
|
|
35
|
-
--stdio use stdio
|
|
36
|
-
--
|
|
37
|
-
--log-level <log-level> A number indicating the log level (4 = log, 3 = info, 2 = warn, 1 = error). Defaults to `2`.
|
|
38
|
-
--socket <port> use socket. example: --socket=5000
|
|
35
|
+
--stdio use stdio (required option)
|
|
36
|
+
--log-level <log-level> A number indicating the log level (4 = log, 3 = info, 2 = warn, 1 = error). Defaults to `3`.
|
|
39
37
|
--tsserver-log-file <tsServerLogFile> Specify a tsserver log file. example: --tsserver-log-file=ts-logs.txt
|
|
40
38
|
--tsserver-log-verbosity <verbosity> Specify tsserver log verbosity (off, terse, normal, verbose). Defaults to `normal`. example: --tsserver-log-verbosity=verbose
|
|
41
39
|
--tsserver-path <path> Specify path to tsserver. example: --tsserver-path=tsserver
|
|
@@ -49,53 +47,59 @@ The language server accepts various settings through the `initializationOptions`
|
|
|
49
47
|
| Setting | Type | Description |
|
|
50
48
|
|:------------------|:---------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
51
49
|
| hostInfo | string | Information about the host, for example `"Emacs 24.4"` or `"Sublime Text v3075"`. **Default**: `undefined` |
|
|
52
|
-
|
|
|
50
|
+
| disableAutomaticTypingAcquisition | boolean | Disables tsserver from automatically fetching missing type definitions (`@types` packages) for external modules. |
|
|
51
|
+
| logVerbosity | string | The verbosity level of the information printed in the log by `tsserver`. Accepts values: `"off"`, `"terse"`, `"normal"`, `"requesttime"`, `"verbose"`. **Default**: `undefined` (`"off"`). |
|
|
53
52
|
| maxTsServerMemory | number | The maximum size of the V8's old memory section in megabytes (for example `4096` means 4GB). The default value is dynamically configured by Node so can differ per system. Increase for very big projects that exceed allowed memory usage. **Default**: `undefined` |
|
|
54
53
|
| plugins | object[] | An array of `{ name: string, location: string }` objects for registering a Typescript plugins. **Default**: [] |
|
|
55
54
|
| preferences | object | Preferences passed to the Typescript (`tsserver`) process. See below for more info. |
|
|
56
55
|
|
|
57
|
-
The `preferences` object is an object specifying preferences for the internal `tsserver` process. Those options depend on the version of Typescript used but at the time of writing Typescript v4.3
|
|
56
|
+
The `preferences` object is an object specifying preferences for the internal `tsserver` process. Those options depend on the version of Typescript used but at the time of writing Typescript v4.4.3 contains these options:
|
|
58
57
|
|
|
59
58
|
```ts
|
|
60
59
|
interface UserPreferences {
|
|
61
|
-
disableSuggestions
|
|
62
|
-
quotePreference
|
|
60
|
+
disableSuggestions: boolean;
|
|
61
|
+
quotePreference: "auto" | "double" | "single";
|
|
63
62
|
/**
|
|
64
63
|
* If enabled, TypeScript will search through all external modules' exports and add them to the completions list.
|
|
65
64
|
* This affects lone identifier completions but not completions on the right hand side of `obj.`.
|
|
66
65
|
*/
|
|
67
|
-
includeCompletionsForModuleExports
|
|
66
|
+
includeCompletionsForModuleExports: boolean;
|
|
68
67
|
/**
|
|
69
68
|
* Enables auto-import-style completions on partially-typed import statements. E.g., allows
|
|
70
69
|
* `import write|` to be completed to `import { writeFile } from "fs"`.
|
|
71
70
|
*/
|
|
72
|
-
includeCompletionsForImportStatements
|
|
71
|
+
includeCompletionsForImportStatements: boolean;
|
|
73
72
|
/**
|
|
74
73
|
* Allows completions to be formatted with snippet text, indicated by `CompletionItem["isSnippet"]`.
|
|
75
74
|
*/
|
|
76
|
-
includeCompletionsWithSnippetText
|
|
75
|
+
includeCompletionsWithSnippetText: boolean;
|
|
77
76
|
/**
|
|
78
77
|
* If enabled, the completion list will include completions with invalid identifier names.
|
|
79
78
|
* For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`.
|
|
80
79
|
*/
|
|
81
|
-
includeCompletionsWithInsertText
|
|
80
|
+
includeCompletionsWithInsertText: boolean;
|
|
82
81
|
/**
|
|
83
82
|
* Unless this option is `false`, or `includeCompletionsWithInsertText` is not enabled,
|
|
84
83
|
* member completion lists triggered with `.` will include entries on potentially-null and potentially-undefined
|
|
85
84
|
* values, with insertion text to replace preceding `.` tokens with `?.`.
|
|
86
85
|
*/
|
|
87
|
-
includeAutomaticOptionalChainCompletions
|
|
88
|
-
|
|
86
|
+
includeAutomaticOptionalChainCompletions: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Allows import module names to be resolved in the initial completions request.
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
allowIncompleteCompletions: boolean;
|
|
92
|
+
importModuleSpecifierPreference: "shortest" | "project-relative" | "relative" | "non-relative";
|
|
89
93
|
/** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */
|
|
90
|
-
importModuleSpecifierEnding
|
|
91
|
-
allowTextChangesInNewFiles
|
|
92
|
-
lazyConfiguredProjectsFromExternalProject
|
|
93
|
-
providePrefixAndSuffixTextForRename
|
|
94
|
-
provideRefactorNotApplicableReason
|
|
95
|
-
allowRenameOfImportPath
|
|
96
|
-
includePackageJsonAutoImports
|
|
97
|
-
displayPartsForJSDoc
|
|
98
|
-
generateReturnInDocTemplate
|
|
94
|
+
importModuleSpecifierEnding: "auto" | "minimal" | "index" | "js";
|
|
95
|
+
allowTextChangesInNewFiles: boolean;
|
|
96
|
+
lazyConfiguredProjectsFromExternalProject: boolean;
|
|
97
|
+
providePrefixAndSuffixTextForRename: boolean;
|
|
98
|
+
provideRefactorNotApplicableReason: boolean;
|
|
99
|
+
allowRenameOfImportPath: boolean;
|
|
100
|
+
includePackageJsonAutoImports: "auto" | "on" | "off";
|
|
101
|
+
displayPartsForJSDoc: boolean;
|
|
102
|
+
generateReturnInDocTemplate: boolean;
|
|
99
103
|
}
|
|
100
104
|
```
|
|
101
105
|
|
|
@@ -103,18 +107,232 @@ From the `preferences` options listed above, this server explicilty sets the fol
|
|
|
103
107
|
|
|
104
108
|
```js
|
|
105
109
|
{
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
allowIncompleteCompletions: true,
|
|
111
|
+
allowRenameOfImportPath: true,
|
|
112
|
+
allowTextChangesInNewFiles: true,
|
|
113
|
+
displayPartsForJSDoc: true,
|
|
114
|
+
generateReturnInDocTemplate: true,
|
|
115
|
+
includeAutomaticOptionalChainCompletions: true,
|
|
116
|
+
includeCompletionsForImportStatements: true,
|
|
117
|
+
includeCompletionsForModuleExports: true,
|
|
118
|
+
includeCompletionsWithInsertText: true,
|
|
119
|
+
includeCompletionsWithSnippetText: true,
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## workspace/didChangeConfiguration
|
|
124
|
+
|
|
125
|
+
Some of the preferences can be controlled through the `workspace/didChangeConfiguration` notification. Below is a list of supported options that can be passed. Note that the settings are specified separately for the typescript and javascript files so `[language]` can be either `javascript` or `typescript`.
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
// Formatting preferences
|
|
129
|
+
[language].format.baseIndentSize: number;
|
|
130
|
+
[language].format.convertTabsToSpaces: boolean;
|
|
131
|
+
[language].format.indentSize: number;
|
|
132
|
+
[language].format.indentStyle: 'None' | 'Block' | 'Smart';
|
|
133
|
+
[language].format.insertSpaceAfterCommaDelimiter: boolean;
|
|
134
|
+
[language].format.insertSpaceAfterConstructor: boolean;
|
|
135
|
+
[language].format.insertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean;
|
|
136
|
+
[language].format.insertSpaceAfterKeywordsInControlFlowStatements: boolean;
|
|
137
|
+
[language].format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces: boolean;
|
|
138
|
+
[language].format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: boolean;
|
|
139
|
+
[language].format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: boolean;
|
|
140
|
+
[language].format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean;
|
|
141
|
+
[language].format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
|
|
142
|
+
[language].format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
|
|
143
|
+
[language].format.insertSpaceAfterSemicolonInForStatements: boolean;
|
|
144
|
+
[language].format.insertSpaceAfterTypeAssertion: boolean;
|
|
145
|
+
[language].format.insertSpaceBeforeAndAfterBinaryOperators: boolean;
|
|
146
|
+
[language].format.insertSpaceBeforeFunctionParenthesis: boolean;
|
|
147
|
+
[language].format.insertSpaceBeforeTypeAnnotation: boolean;
|
|
148
|
+
[language].format.newLineCharacter: string;
|
|
149
|
+
[language].format.placeOpenBraceOnNewLineForControlBlocks: boolean;
|
|
150
|
+
[language].format.placeOpenBraceOnNewLineForFunctions: boolean;
|
|
151
|
+
[language].format.semicolons: 'ignore' | 'insert' | 'remove';
|
|
152
|
+
[language].format.tabSize: number;
|
|
153
|
+
[language].format.trimTrailingWhitespace: boolean;
|
|
154
|
+
// Inlay Hints preferences
|
|
155
|
+
[language].inlayHints.includeInlayEnumMemberValueHints: boolean;
|
|
156
|
+
[language].inlayHints.includeInlayFunctionLikeReturnTypeHints: boolean;
|
|
157
|
+
[language].inlayHints.includeInlayFunctionParameterTypeHints: boolean;
|
|
158
|
+
[language].inlayHints.includeInlayParameterNameHints: 'none' | 'literals' | 'all';
|
|
159
|
+
[language].inlayHints.includeInlayParameterNameHintsWhenArgumentMatchesName: boolean;
|
|
160
|
+
[language].inlayHints.includeInlayPropertyDeclarationTypeHints: boolean;
|
|
161
|
+
[language].inlayHints.includeInlayVariableTypeHints: boolean;
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Code actions on save
|
|
165
|
+
|
|
166
|
+
Server announces support for the `source.organizeImports.ts-ls` code action which allows editors that support running code actions on save to automatically organize imports on saving. The user can enable it with a setting similar to (can vary per-editor):
|
|
167
|
+
|
|
168
|
+
```js
|
|
169
|
+
"codeActionsOnSave": {
|
|
170
|
+
"source.organizeImports": true,
|
|
171
|
+
// or
|
|
172
|
+
"source.organizeImports.ts-ls": true,
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Workspace commands (`workspace/executeCommand`)
|
|
177
|
+
|
|
178
|
+
See [LSP specification](https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#workspace_executeCommand).
|
|
179
|
+
|
|
180
|
+
Most of the time, you'll execute commands with arguments retrieved from another request like `textDocument/codeAction`. There are some use cases for calling them manually.
|
|
181
|
+
|
|
182
|
+
Supported commands:
|
|
183
|
+
|
|
184
|
+
`lsp` refers to the language server protocol, `tsp` refers to the typescript server protocol.
|
|
185
|
+
|
|
186
|
+
* `_typescript.applyWorkspaceEdit`
|
|
187
|
+
```ts
|
|
188
|
+
type Arguments = [lsp.WorkspaceEdit]
|
|
189
|
+
```
|
|
190
|
+
* `_typescript.applyCodeAction`
|
|
191
|
+
```ts
|
|
192
|
+
type Arguments = [tsp.CodeAction]
|
|
193
|
+
```
|
|
194
|
+
* `_typescript.applyRefactoring`
|
|
195
|
+
```ts
|
|
196
|
+
type Arguments = [tsp.GetEditsForRefactorRequestArgs]
|
|
197
|
+
```
|
|
198
|
+
* `_typescript.organizeImports`
|
|
199
|
+
```ts
|
|
200
|
+
// The "skipDestructiveCodeActions" argument is supported from Typescript 4.4+
|
|
201
|
+
type Arguments = [string] | [string, { skipDestructiveCodeActions?: boolean }]
|
|
202
|
+
```
|
|
203
|
+
* `_typescript.applyRenameFile`
|
|
204
|
+
```ts
|
|
205
|
+
type Arguments = [{ sourceUri: string; targetUri: string; }]
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Inlay hints (`typescript/inlayHints`) (experimental)
|
|
209
|
+
|
|
210
|
+
Supports experimental inline hints.
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
type Request = {
|
|
214
|
+
textDocument: TextDocumentIdentifier,
|
|
215
|
+
range?: Range,
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
type Response = {
|
|
219
|
+
inlayHints: InlayHint[];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
type InlayHint = {
|
|
223
|
+
text: string;
|
|
224
|
+
position: lsp.Position;
|
|
225
|
+
kind: 'Type' | 'Parameter' | 'Enum';
|
|
226
|
+
whitespaceBefore?: boolean;
|
|
227
|
+
whitespaceAfter?: boolean;
|
|
228
|
+
};
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
For the request to return any results, some or all of the following options need to be enabled through `preferences`:
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
// Not officially part of UserPreferences yet but you can send them along with the UserPreferences just fine:
|
|
235
|
+
export interface InlayHintsOptions extends UserPreferences {
|
|
236
|
+
includeInlayParameterNameHints: 'none' | 'literals' | 'all';
|
|
237
|
+
includeInlayParameterNameHintsWhenArgumentMatchesName: boolean;
|
|
238
|
+
includeInlayFunctionParameterTypeHints: boolean;
|
|
239
|
+
includeInlayVariableTypeHints: boolean;
|
|
240
|
+
includeInlayPropertyDeclarationTypeHints: boolean;
|
|
241
|
+
includeInlayFunctionLikeReturnTypeHints: boolean;
|
|
242
|
+
includeInlayEnumMemberValueHints: boolean;
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Callers and callees (`textDocument/calls`) (experimental)
|
|
247
|
+
|
|
248
|
+
Supports showing callers and calles for a given symbol. If the editor has support for appropriate UI, it can generate a tree of callers and calles for a document.
|
|
249
|
+
|
|
250
|
+
```ts
|
|
251
|
+
type Request = {
|
|
252
|
+
/**
|
|
253
|
+
* The text document.
|
|
254
|
+
*/
|
|
255
|
+
textDocument: TextDocumentIdentifier;
|
|
256
|
+
/**
|
|
257
|
+
* The position inside the text document.
|
|
258
|
+
*/
|
|
259
|
+
position: Position;
|
|
260
|
+
/**
|
|
261
|
+
* Outgoing direction for callees.
|
|
262
|
+
* The default is incoming for callers.
|
|
263
|
+
*/
|
|
264
|
+
direction?: CallDirection;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export enum CallDirection {
|
|
268
|
+
/**
|
|
269
|
+
* Incoming calls aka. callers
|
|
270
|
+
*/
|
|
271
|
+
Incoming = 'incoming',
|
|
272
|
+
/**
|
|
273
|
+
* Outgoing calls aka. callees
|
|
274
|
+
*/
|
|
275
|
+
Outgoing = 'outgoing',
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
type Result = {
|
|
279
|
+
/**
|
|
280
|
+
* The symbol of a definition for which the request was made.
|
|
281
|
+
*
|
|
282
|
+
* If no definition is found at a given text document position, the symbol is undefined.
|
|
283
|
+
*/
|
|
284
|
+
symbol?: DefinitionSymbol;
|
|
285
|
+
/**
|
|
286
|
+
* List of calls.
|
|
287
|
+
*/
|
|
288
|
+
calls: Call[];
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
interface Call {
|
|
292
|
+
/**
|
|
293
|
+
* Actual location of a call to a definition.
|
|
294
|
+
*/
|
|
295
|
+
location: Location;
|
|
296
|
+
/**
|
|
297
|
+
* Symbol refered to by this call. For outgoing calls this is a callee,
|
|
298
|
+
* otherwise a caller.
|
|
299
|
+
*/
|
|
300
|
+
symbol: DefinitionSymbol;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
interface DefinitionSymbol {
|
|
304
|
+
/**
|
|
305
|
+
* The name of this symbol.
|
|
306
|
+
*/
|
|
307
|
+
name: string;
|
|
308
|
+
/**
|
|
309
|
+
* More detail for this symbol, e.g the signature of a function.
|
|
310
|
+
*/
|
|
311
|
+
detail?: string;
|
|
312
|
+
/**
|
|
313
|
+
* The kind of this symbol.
|
|
314
|
+
*/
|
|
315
|
+
kind: SymbolKind;
|
|
316
|
+
/**
|
|
317
|
+
* The range enclosing this symbol not including leading/trailing whitespace but everything else
|
|
318
|
+
* like comments. This information is typically used to determine if the the clients cursor is
|
|
319
|
+
* inside the symbol to reveal in the symbol in the UI.
|
|
320
|
+
*/
|
|
321
|
+
location: Location;
|
|
322
|
+
/**
|
|
323
|
+
* The range that should be selected and revealed when this symbol is being picked, e.g the name of a function.
|
|
324
|
+
* Must be contained by the the `range`.
|
|
325
|
+
*/
|
|
326
|
+
selectionRange: Range;
|
|
108
327
|
}
|
|
109
328
|
```
|
|
110
329
|
|
|
111
|
-
|
|
330
|
+
## Supported Protocol features
|
|
112
331
|
|
|
113
332
|
- [x] textDocument/didChange (incremental)
|
|
114
333
|
- [x] textDocument/didClose
|
|
115
334
|
- [x] textDocument/didOpen
|
|
116
335
|
- [x] textDocument/didSave
|
|
117
|
-
|
|
118
336
|
- [x] textDocument/codeAction
|
|
119
337
|
- [x] textDocument/completion (incl. completion/resolve)
|
|
120
338
|
- [x] textDocument/definition
|
|
@@ -127,9 +345,13 @@ From the `preferences` options listed above, this server explicilty sets the fol
|
|
|
127
345
|
- [x] textDocument/rename
|
|
128
346
|
- [x] textDocument/references
|
|
129
347
|
- [x] textDocument/signatureHelp
|
|
348
|
+
- [x] textDocument/calls (experimental)
|
|
349
|
+
- [x] typescript/inlayHints (experimental, supported from Typescript v4.4.2)
|
|
130
350
|
- [x] workspace/symbol
|
|
351
|
+
- [x] workspace/didChangeConfiguration
|
|
352
|
+
- [x] workspace/executeCommand
|
|
131
353
|
|
|
132
|
-
|
|
354
|
+
## Development
|
|
133
355
|
|
|
134
356
|
### Build
|
|
135
357
|
|
|
@@ -137,7 +359,7 @@ From the `preferences` options listed above, this server explicilty sets the fol
|
|
|
137
359
|
yarn
|
|
138
360
|
```
|
|
139
361
|
|
|
140
|
-
|
|
362
|
+
### Test
|
|
141
363
|
|
|
142
364
|
```sh
|
|
143
365
|
yarn test
|
package/lib/calls.js
CHANGED
|
@@ -50,7 +50,7 @@ function computeCallers(tspClient, args) {
|
|
|
50
50
|
if (!symbol) {
|
|
51
51
|
continue;
|
|
52
52
|
}
|
|
53
|
-
const location = protocol_translation_1.toLocation(callerReference, undefined);
|
|
53
|
+
const location = (0, protocol_translation_1.toLocation)(callerReference, undefined);
|
|
54
54
|
calls.push({
|
|
55
55
|
location,
|
|
56
56
|
symbol
|
|
@@ -83,7 +83,7 @@ function computeCallees(tspClient, args, documentProvider) {
|
|
|
83
83
|
if (!definitionSymbol) {
|
|
84
84
|
continue;
|
|
85
85
|
}
|
|
86
|
-
const location = protocol_translation_1.toLocation(reference, undefined);
|
|
86
|
+
const location = (0, protocol_translation_1.toLocation)(reference, undefined);
|
|
87
87
|
calls.push({
|
|
88
88
|
location,
|
|
89
89
|
symbol: definitionSymbol
|
|
@@ -132,7 +132,7 @@ function findOutgoingCalls(tspClient, contextSymbol, documentProvider) {
|
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
134
|
const calls = [];
|
|
135
|
-
const file = protocol_translation_1.uriToPath(contextSymbol.location.uri);
|
|
135
|
+
const file = (0, protocol_translation_1.uriToPath)(contextSymbol.location.uri);
|
|
136
136
|
const document = documentProvider(file);
|
|
137
137
|
if (!document) {
|
|
138
138
|
return calls;
|
|
@@ -149,7 +149,7 @@ function findOutgoingCalls(tspClient, contextSymbol, documentProvider) {
|
|
|
149
149
|
}
|
|
150
150
|
function getDefinition(tspClient, args) {
|
|
151
151
|
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
const file = protocol_translation_1.uriToPath(args.textDocument.uri);
|
|
152
|
+
const file = (0, protocol_translation_1.uriToPath)(args.textDocument.uri);
|
|
153
153
|
if (!file) {
|
|
154
154
|
return undefined;
|
|
155
155
|
}
|
|
@@ -174,13 +174,13 @@ function findEnclosingSymbol(tspClient, args) {
|
|
|
174
174
|
if (!symbol) {
|
|
175
175
|
return undefined;
|
|
176
176
|
}
|
|
177
|
-
const uri = protocol_translation_1.pathToUri(file, undefined);
|
|
177
|
+
const uri = (0, protocol_translation_1.pathToUri)(file, undefined);
|
|
178
178
|
return lspcalls.DefinitionSymbol.create(uri, symbol);
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
function findEnclosingSymbolInTree(parent, range) {
|
|
182
182
|
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
-
const inSpan = (span) => !!protocol_translation_1.Range.intersection(protocol_translation_1.asRange(span), range);
|
|
183
|
+
const inSpan = (span) => !!protocol_translation_1.Range.intersection((0, protocol_translation_1.asRange)(span), range);
|
|
184
184
|
const inTree = (tree) => tree.spans.some(span => inSpan(span));
|
|
185
185
|
let candidate = inTree(parent) ? parent : undefined;
|
|
186
186
|
outer: while (candidate) {
|
|
@@ -197,17 +197,17 @@ function findEnclosingSymbolInTree(parent, range) {
|
|
|
197
197
|
return undefined;
|
|
198
198
|
}
|
|
199
199
|
const span = candidate.spans.find(span => inSpan(span));
|
|
200
|
-
const spanRange = protocol_translation_1.asRange(span);
|
|
200
|
+
const spanRange = (0, protocol_translation_1.asRange)(span);
|
|
201
201
|
let selectionRange = spanRange;
|
|
202
202
|
if (candidate.nameSpan) {
|
|
203
|
-
const nameRange = protocol_translation_1.asRange(candidate.nameSpan);
|
|
203
|
+
const nameRange = (0, protocol_translation_1.asRange)(candidate.nameSpan);
|
|
204
204
|
if (protocol_translation_1.Range.intersection(spanRange, nameRange)) {
|
|
205
205
|
selectionRange = nameRange;
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
return {
|
|
209
209
|
name: candidate.text,
|
|
210
|
-
kind: protocol_translation_1.toSymbolKind(candidate.kind),
|
|
210
|
+
kind: (0, protocol_translation_1.toSymbolKind)(candidate.kind),
|
|
211
211
|
range: spanRange,
|
|
212
212
|
selectionRange: selectionRange
|
|
213
213
|
};
|
package/lib/calls.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calls.js","sourceRoot":"","sources":["../src/calls.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,gEAAkD;AAClD,wEAA0D;AAG1D,iEAAwG;AAGxG,SAAsB,cAAc,CAAC,SAAoB,EAAE,IAAoC;;QAC3F,MAAM,UAAU,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;QACjC,MAAM,iBAAiB,GAAG,MAAM,aAAa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I,CAAC,KAAK,CAAC,IAAI;YACrB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;SAC5B,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;YACd,OAAO,EAAE,CAAC;SACb;QACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;IAC5B,CAAC;CAAA"}
|
package/lib/cli.js
CHANGED
|
@@ -30,35 +30,30 @@ const commander_1 = require("commander");
|
|
|
30
30
|
const utils_1 = require("./utils");
|
|
31
31
|
const lsp_connection_1 = require("./lsp-connection");
|
|
32
32
|
const lsp = __importStar(require("vscode-languageserver/node"));
|
|
33
|
+
const DEFAULT_LOG_LEVEL = lsp.MessageType.Info;
|
|
33
34
|
const program = new commander_1.Command('typescript-language-server')
|
|
34
35
|
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
35
36
|
.version(require('../package.json').version)
|
|
36
|
-
.
|
|
37
|
-
.option('--node-ipc', 'use node-ipc')
|
|
37
|
+
.requiredOption('--stdio', 'use stdio')
|
|
38
38
|
.option('--log-level <logLevel>', 'A number indicating the log level (4 = log, 3 = info, 2 = warn, 1 = error). Defaults to `2`.')
|
|
39
|
-
.option('--socket <port>', 'use socket. example: --socket=5000')
|
|
40
39
|
.option('--tsserver-log-file <tsserverLogFile>', 'Specify a tsserver log file. example: --tsserver-log-file ts-logs.txt')
|
|
41
40
|
.option('--tsserver-log-verbosity <tsserverLogVerbosity>', 'Specify a tsserver log verbosity (terse, normal, verbose). Defaults to `normal`.' +
|
|
42
41
|
' example: --tsserver-log-verbosity verbose')
|
|
43
|
-
.option('--tsserver-path <path>', `Specify path to tsserver. example: --tsserver-path=${utils_1.getTsserverExecutable()}`)
|
|
42
|
+
.option('--tsserver-path <path>', `Specify path to tsserver. example: --tsserver-path=${(0, utils_1.getTsserverExecutable)()}`)
|
|
44
43
|
.parse(process.argv);
|
|
45
44
|
const options = program.opts();
|
|
46
|
-
if (!(options.stdio || options.socket || options.nodeIpc)) {
|
|
47
|
-
console.error('Connection type required (stdio, node-ipc, socket). Refer to --help for more details.');
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
45
|
if (options.tsserverLogFile && !options.tsserverLogVerbosity) {
|
|
51
46
|
options.tsserverLogVerbosity = 'normal';
|
|
52
47
|
}
|
|
53
|
-
let logLevel =
|
|
48
|
+
let logLevel = DEFAULT_LOG_LEVEL;
|
|
54
49
|
if (options.logLevel) {
|
|
55
50
|
logLevel = parseInt(options.logLevel, 10);
|
|
56
51
|
if (logLevel && (logLevel < 1 || logLevel > 4)) {
|
|
57
52
|
console.error(`Invalid '--log-level ${logLevel}'. Falling back to 'info' level.`);
|
|
58
|
-
logLevel =
|
|
53
|
+
logLevel = DEFAULT_LOG_LEVEL;
|
|
59
54
|
}
|
|
60
55
|
}
|
|
61
|
-
lsp_connection_1.createLspConnection({
|
|
56
|
+
(0, lsp_connection_1.createLspConnection)({
|
|
62
57
|
tsserverPath: options.tsserverPath,
|
|
63
58
|
tsserverLogFile: options.tsserverLogFile,
|
|
64
59
|
tsserverLogVerbosity: options.tsserverLogVerbosity,
|
package/lib/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AACA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;AAEH,yCAAoC;AACpC,mCAAgD;AAChD,qDAAuD;AACvD,gEAAkD;AAElD,MAAM,OAAO,GAAG,IAAI,mBAAO,CAAC,4BAA4B,CAAC;IACrD,qGAAqG;KACpG,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC;KAC3C,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AACA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;AAEH,yCAAoC;AACpC,mCAAgD;AAChD,qDAAuD;AACvD,gE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AChD,CAAC,CAAC,MAAM,EAAE,CAAC"}
|
package/lib/commands.d.ts
CHANGED
|
@@ -4,8 +4,11 @@ export declare const Commands: {
|
|
|
4
4
|
APPLY_REFACTORING: string;
|
|
5
5
|
ORGANIZE_IMPORTS: string;
|
|
6
6
|
APPLY_RENAME_FILE: string;
|
|
7
|
-
/** Commands below should be implemented by the client */
|
|
8
7
|
APPLY_COMPLETION_CODE_ACTION: string;
|
|
8
|
+
/** Commands below should be implemented by the client */
|
|
9
9
|
SELECT_REFACTORING: string;
|
|
10
10
|
};
|
|
11
|
+
export declare const CodeActions: {
|
|
12
|
+
SourceOrganizeImportsTsLs: string;
|
|
13
|
+
};
|
|
11
14
|
//# sourceMappingURL=commands.d.ts.map
|
package/lib/commands.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,QAAQ;;;;;;;IAOjB,yDAAyD;;CAE5D,CAAC;AAEF,eAAO,MAAM,WAAW;;CAEvB,CAAC"}
|
package/lib/commands.js
CHANGED
|
@@ -6,15 +6,18 @@
|
|
|
6
6
|
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.Commands = void 0;
|
|
9
|
+
exports.CodeActions = exports.Commands = void 0;
|
|
10
10
|
exports.Commands = {
|
|
11
11
|
APPLY_WORKSPACE_EDIT: '_typescript.applyWorkspaceEdit',
|
|
12
12
|
APPLY_CODE_ACTION: '_typescript.applyCodeAction',
|
|
13
13
|
APPLY_REFACTORING: '_typescript.applyRefactoring',
|
|
14
14
|
ORGANIZE_IMPORTS: '_typescript.organizeImports',
|
|
15
15
|
APPLY_RENAME_FILE: '_typescript.applyRenameFile',
|
|
16
|
-
/** Commands below should be implemented by the client */
|
|
17
16
|
APPLY_COMPLETION_CODE_ACTION: '_typescript.applyCompletionCodeAction',
|
|
17
|
+
/** Commands below should be implemented by the client */
|
|
18
18
|
SELECT_REFACTORING: '_typescript.selectRefactoring'
|
|
19
19
|
};
|
|
20
|
+
exports.CodeActions = {
|
|
21
|
+
SourceOrganizeImportsTsLs: 'source.organizeImports.ts-ls'
|
|
22
|
+
};
|
|
20
23
|
//# sourceMappingURL=commands.js.map
|
package/lib/commands.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,QAAQ,GAAG;IACpB,oBAAoB,EAAE,gCAAgC;IACtD,iBAAiB,EAAE,6BAA6B;IAChD,iBAAiB,EAAE,8BAA8B;IACjD,gBAAgB,EAAE,6BAA6B;IAC/C,iBAAiB,EAAE,6BAA6B;IAChD,
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,QAAQ,GAAG;IACpB,oBAAoB,EAAE,gCAAgC;IACtD,iBAAiB,EAAE,6BAA6B;IAChD,iBAAiB,EAAE,8BAA8B;IACjD,gBAAgB,EAAE,6BAA6B;IAC/C,iBAAiB,EAAE,6BAA6B;IAChD,4BAA4B,EAAE,uCAAuC;IACrE,yDAAyD;IACzD,kBAAkB,EAAE,+BAA+B;CACtD,CAAC;AAEW,QAAA,WAAW,GAAG;IACvB,yBAAyB,EAAE,8BAA8B;CAC5D,CAAC"}
|