Skip to content

Commit

Permalink
feat!: drop experimental textDocument/calls, typescript/inlayHints (
Browse files Browse the repository at this point in the history
#647)

BREAKING CHANGE: Remove experimental and legacy implementations of inlay hints and call hierarchy. Use to the official `textDocument/inlayHint` and `textDocument/prepareCallHierarchy` implementations instead.
  • Loading branch information
rchl committed Dec 27, 2022
1 parent f0f04e5 commit b15f8a7
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 725 deletions.
119 changes: 2 additions & 117 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ Maintained by a [community of contributors](https://github.com/typescript-langua
- [Organize Imports](#organize-imports)
- [Rename File](#rename-file)
- [Configure plugin](#configure-plugin)
- [Inlay hints \(`typescript/inlayHints`\) \(experimental\)](#inlay-hints-typescriptinlayhints-experimental)
- [Callers and callees \(`textDocument/calls`\) \(experimental\)](#callers-and-callees-textdocumentcalls-experimental)
- [Inlay hints \(`textDocument/inlayHint`\)](#inlay-hints-textdocumentinlayhint)
- [Supported Protocol features](#supported-protocol-features)
- [Experimental](#experimental)
- [Development](#development)
- [Build](#build)
- [Test](#test)
Expand Down Expand Up @@ -484,35 +482,11 @@ Most of the time, you'll execute commands with arguments retrieved from another
void
```

## Inlay hints (`typescript/inlayHints`) (experimental)

> !!! This implementation is deprecated. Use the spec-compliant `textDocument/inlayHint` request instead. !!!
Supports experimental inline hints.

```ts
type Request = {
textDocument: TextDocumentIdentifier,
range?: Range,
}

type Response = {
inlayHints: InlayHint[];
}

type InlayHint = {
text: string;
position: lsp.Position;
kind: 'Type' | 'Parameter' | 'Enum';
whitespaceBefore?: boolean;
whitespaceAfter?: boolean;
};
```
## Inlay hints (`textDocument/inlayHint`)

For the request to return any results, some or all of the following options need to be enabled through `preferences`:

```ts
// Not officially part of UserPreferences yet but you can send them along with the UserPreferences just fine:
export interface InlayHintsOptions extends UserPreferences {
includeInlayParameterNameHints: 'none' | 'literals' | 'all';
includeInlayParameterNameHintsWhenArgumentMatchesName: boolean;
Expand All @@ -525,90 +499,6 @@ export interface InlayHintsOptions extends UserPreferences {
}
```

## Callers and callees (`textDocument/calls`) (experimental)

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.

```ts
type Request = {
/**
* The text document.
*/
textDocument: TextDocumentIdentifier;
/**
* The position inside the text document.
*/
position: Position;
/**
* Outgoing direction for callees.
* The default is incoming for callers.
*/
direction?: CallDirection;
}

export enum CallDirection {
/**
* Incoming calls aka. callers
*/
Incoming = 'incoming',
/**
* Outgoing calls aka. callees
*/
Outgoing = 'outgoing',
}

type Result = {
/**
* The symbol of a definition for which the request was made.
*
* If no definition is found at a given text document position, the symbol is undefined.
*/
symbol?: DefinitionSymbol;
/**
* List of calls.
*/
calls: Call[];
}

interface Call {
/**
* Actual location of a call to a definition.
*/
location: Location;
/**
* Symbol refered to by this call. For outgoing calls this is a callee,
* otherwise a caller.
*/
symbol: DefinitionSymbol;
}

interface DefinitionSymbol {
/**
* The name of this symbol.
*/
name: string;
/**
* More detail for this symbol, e.g the signature of a function.
*/
detail?: string;
/**
* The kind of this symbol.
*/
kind: SymbolKind;
/**
* The range enclosing this symbol not including leading/trailing whitespace but everything else
* like comments. This information is typically used to determine if the the clients cursor is
* inside the symbol to reveal in the symbol in the UI.
*/
location: Location;
/**
* The range that should be selected and revealed when this symbol is being picked, e.g the name of a function.
* Must be contained by the the `range`.
*/
selectionRange: Range;
}
```

## Supported Protocol features

- [x] textDocument/codeAction
Expand All @@ -634,11 +524,6 @@ interface DefinitionSymbol {
- [x] workspace/didChangeConfiguration
- [x] workspace/executeCommand

### Experimental

- [x] textDocument/calls (experimental)
- [x] typescript/inlayHints (experimental, supported from Typescript v4.4.2) DEPRECATED (use `textDocument/inlayHint` instead)

## Development

### Build
Expand Down
205 changes: 0 additions & 205 deletions src/calls.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/semantic-tokens.ts → src/features/semantic-tokens.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LspDocument } from './document.js';
import type { LspDocument } from '../document.js';

// copied from https://github.com/microsoft/TypeScript/blob/main/src/services/classifier2020.ts
enum TokenEncodingConsts {
Expand Down
12 changes: 2 additions & 10 deletions src/lsp-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
*/

import lsp from 'vscode-languageserver/node.js';
import * as lspcalls from './lsp-protocol.calls.proposed.js';
import * as lspinlayHints from './lsp-protocol.inlayHints.proposed.js';
import { LspClientLogger } from './utils/logger.js';
import { LspServer } from './lsp-server.js';
import { LspClientImpl } from './lsp-client.js';
Expand Down Expand Up @@ -58,14 +56,8 @@ export function createLspConnection(options: LspConnectionOptions): lsp.Connecti
connection.onWorkspaceSymbol(server.workspaceSymbol.bind(server));
connection.onFoldingRanges(server.foldingRanges.bind(server));
connection.languages.inlayHint.on(server.inlayHints.bind(server));

// proposed `textDocument/calls` request
connection.onRequest(lspcalls.CallsRequest.type, server.calls.bind(server));

connection.onRequest(lspinlayHints.type, server.inlayHintsLegacy.bind(server));

connection.onRequest(lsp.SemanticTokensRequest.type, server.semanticTokensFull.bind(server));
connection.onRequest(lsp.SemanticTokensRangeRequest.type, server.semanticTokensRange.bind(server));
connection.languages.semanticTokens.on(server.semanticTokensFull.bind(server));
connection.languages.semanticTokens.onRange(server.semanticTokensRange.bind(server));

return connection;
}

0 comments on commit b15f8a7

Please sign in to comment.