Skip to content

Commit

Permalink
Merge branch 'main' into exports-module
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaeumer authored Jan 23, 2024
2 parents 9fe572f + c0982bf commit cc2b836
Show file tree
Hide file tree
Showing 18 changed files with 233 additions and 49 deletions.
15 changes: 5 additions & 10 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,11 @@
"name": "Launch TestBed Client",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}/testbed"],
"outFiles": ["${workspaceRoot}/testbed/client/out/**/*.js"],
"sourceMaps": true
},
{
"type": "node",
"request": "attach",
"name": "Attach to Server",
"port": 6012,
"restart": true,
"outFiles": ["${workspaceRoot}/testbed/server/out/**/*.js"],
"outFiles": [
"${workspaceRoot}/testbed/server/out/**/*.js",
"${workspaceRoot}/testbed/client/out/**/*.js"
],
"autoAttachChildProcesses": true,
"sourceMaps": true
},
{
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ This repository contains the code for the following npm modules:
[![NPM Version](https://img.shields.io/npm/v/vscode-jsonrpc.svg)](https://npmjs.org/package/vscode-jsonrpc)
[![NPM Downloads](https://img.shields.io/npm/dm/vscode-jsonrpc.svg)](https://npmjs.org/package/vscode-jsonrpc)

All four npm modules are built using one travis build. Its status is:
All npm modules are built using one Azure Pipeline. Its status is:

[![Build Status](https://travis-ci.org/Microsoft/vscode-languageserver-node.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-languageserver-node)
[![Build Status](https://dev.azure.com/ms/vscode-languageserver-node/_apis/build/status/microsoft.vscode-languageserver-node?branchName=main)](https://dev.azure.com/ms/vscode-languageserver-node/_build/latest?definitionId=439&branchName=main)

Click [here](https://code.visualstudio.com/docs/extensions/example-language-server) for a detailed document on how to use these npm modules to implement
language servers for [VSCode](https://code.visualstudio.com/).
Expand Down
23 changes: 14 additions & 9 deletions client-node-tests/src/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { strictEqual, ok } from 'assert';
import {
Position, Range, TextDocumentIdentifier, TextDocumentItem, VersionedTextDocumentIdentifier, Command, CodeLens, CodeActionContext,
Diagnostic, DiagnosticSeverity, WorkspaceChange, TextDocumentEdit, CreateFile, RenameFile, DeleteFile, ChangeAnnotation,
AnnotatedTextEdit
AnnotatedTextEdit,
TextEdit
} from 'vscode-languageclient';

suite('Protocol Helper Tests', () => {
Expand Down Expand Up @@ -124,17 +125,21 @@ suite('Protocol Helper Tests', () => {
strictEqual(workspaceEdit.documentChanges!.length, 2);
let edits = (workspaceEdit.documentChanges![0] as TextDocumentEdit).edits;
strictEqual(edits.length, 3);
rangeEqual(edits[0].range, Range.create(0,1,0,1));
strictEqual(edits[0].newText, 'insert');
rangeEqual(edits[1].range, Range.create(0,1,2,3));
strictEqual(edits[1].newText, 'replace');
rangeEqual(edits[2].range, Range.create(0,1,2,3));
strictEqual(edits[2].newText, '');
let edit = edits[0] as TextEdit;
rangeEqual(edit.range, Range.create(0,1,0,1));
strictEqual(edit.newText, 'insert');
edit = edits[1] as TextEdit;
rangeEqual(edit.range, Range.create(0,1,2,3));
strictEqual(edit.newText, 'replace');
edit = edits[2] as TextEdit;
rangeEqual(edit.range, Range.create(0,1,2,3));
strictEqual(edit.newText, '');

edits = (workspaceEdit.documentChanges![1] as TextDocumentEdit).edits;
strictEqual(edits.length, 1);
rangeEqual(edits[0].range, Range.create(2,3,2,3));
strictEqual(edits[0].newText, 'insert');
edit = edits[0] as TextEdit;
rangeEqual(edit.range, Range.create(2,3,2,3));
strictEqual(edit.newText, 'insert');

workspaceChange.createFile('file:///create.txt');
workspaceChange.renameFile('file:///old.txt', 'file:///new.txt');
Expand Down
2 changes: 1 addition & 1 deletion client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![NPM Version](https://img.shields.io/npm/v/vscode-languageclient.svg)](https://npmjs.org/package/vscode-languageclient)
[![NPM Downloads](https://img.shields.io/npm/dm/vscode-languageclient.svg)](https://npmjs.org/package/vscode-languageclient)
[![Build Status](https://travis-ci.org/Microsoft/vscode-languageserver-node.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-languageserver-node)
[![Build Status](https://dev.azure.com/ms/vscode-languageserver-node/_apis/build/status/microsoft.vscode-languageserver-node?branchName=main)](https://dev.azure.com/ms/vscode-languageserver-node/_build/latest?definitionId=439&branchName=main)

This npm module allows VSCode extensions to easily integrate language servers adhering to the [language server protocol](https://github.com/Microsoft/vscode-languageserver-protocol)

Expand Down
4 changes: 3 additions & 1 deletion client/src/common/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,8 @@ export abstract class BaseLanguageClient implements FeatureClient<Middleware, La
workspaceEdit.changeAnnotationSupport = {
groupsOnLabel: true
};
workspaceEdit.metadataSupport = true;
workspaceEdit.snippetEditSupport = false;

const diagnostics = ensure(ensure(result, 'textDocument')!, 'publishDiagnostics')!;
diagnostics.relatedInformation = true;
Expand Down Expand Up @@ -1991,7 +1993,7 @@ export abstract class BaseLanguageClient implements FeatureClient<Middleware, La
if (versionMismatch) {
return Promise.resolve({ applied: false });
}
return Is.asPromise(Workspace.applyEdit(converted).then((value) => { return { applied: value }; }));
return Is.asPromise(Workspace.applyEdit(converted, { isRefactoring: params.metadata?.isRefactoring }).then((value) => { return { applied: value }; }));
}

private static RequestsToCancelOnContentModified: Set<string> = new Set([
Expand Down
4 changes: 3 additions & 1 deletion client/src/common/codeAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ export class CodeActionFeature extends TextDocumentLanguageFeature<boolean | Cod
CodeActionKind.Refactor,
CodeActionKind.RefactorExtract,
CodeActionKind.RefactorInline,
CodeActionKind.RefactorMove,
CodeActionKind.RefactorRewrite,
CodeActionKind.Source,
CodeActionKind.SourceOrganizeImports
CodeActionKind.SourceOrganizeImports,
CodeActionKind.Notebook
]
}
};
Expand Down
4 changes: 2 additions & 2 deletions client/src/common/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from 'vscode';

import {
ClientCapabilities, CancellationToken, ServerCapabilities, DocumentSelector, DocumentHighlightRegistrationOptions, DocumentFormattingOptions, DocumentFormattingRequest, TextDocumentRegistrationOptions, DocumentFormattingParams, DocumentRangeFormattingRegistrationOptions, DocumentRangeFormattingOptions, DocumentRangeFormattingRequest, DocumentRangeFormattingParams, DocumentRangesFormattingRequest, DocumentRangesFormattingParams, DocumentOnTypeFormattingOptions, DocumentOnTypeFormattingRegistrationOptions, DocumentOnTypeFormattingRequest, DocumentOnTypeFormattingParams} from 'vscode-languageserver-protocol';
ClientCapabilities, CancellationToken, ServerCapabilities, DocumentSelector, DocumentFormattingOptions, DocumentFormattingRequest, TextDocumentRegistrationOptions, DocumentFormattingParams, DocumentRangeFormattingRegistrationOptions, DocumentRangeFormattingOptions, DocumentRangeFormattingRequest, DocumentRangeFormattingParams, DocumentRangesFormattingRequest, DocumentRangesFormattingParams, DocumentOnTypeFormattingOptions, DocumentOnTypeFormattingRegistrationOptions, DocumentOnTypeFormattingRequest, DocumentOnTypeFormattingParams, DocumentFormattingRegistrationOptions} from 'vscode-languageserver-protocol';

import * as UUID from './utils/uuid';

Expand Down Expand Up @@ -53,7 +53,7 @@ export interface FormattingMiddleware {
}


export class DocumentFormattingFeature extends TextDocumentLanguageFeature<boolean | DocumentFormattingOptions, DocumentHighlightRegistrationOptions, DocumentFormattingEditProvider, FormattingMiddleware> {
export class DocumentFormattingFeature extends TextDocumentLanguageFeature<boolean | DocumentFormattingOptions, DocumentFormattingRegistrationOptions, DocumentFormattingEditProvider, FormattingMiddleware> {

constructor(client: FeatureClient<FormattingMiddleware>) {
super(client, DocumentFormattingRequest.type);
Expand Down
12 changes: 11 additions & 1 deletion client/src/common/notebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,17 @@ class NotebookDocumentSyncFeatureProvider implements NotebookDocumentSyncFeature
}

public handles(textDocument: vscode.TextDocument): boolean {
return vscode.languages.match(this.selector, textDocument) > 0;
if (vscode.languages.match(this.selector, textDocument) > 0) {
return true;
}
// Work around for https://github.com/microsoft/vscode/issues/202163
const key = textDocument.uri.toString();
for (const syncInfo of this.notebookSyncInfo.values()) {
if (syncInfo.uris.has(key)) {
return true;
}
}
return false;
}

public didOpenNotebookCellTextDocument(notebookDocument: vscode.NotebookDocument, cell: vscode.NotebookCell): void {
Expand Down
2 changes: 2 additions & 0 deletions client/src/common/protocolConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,8 @@ export function createConverter(uriConverter: URIConverter | undefined, trustMar
for (const edit of change.edits) {
if (ls.AnnotatedTextEdit.is(edit)) {
result.replace(uri, asRange(edit.range), edit.newText, asMetadata(edit.annotationId));
} else if (ls.SnippetTextEdit.is(edit)) {
result.replace(uri, asRange(edit.range), edit.snippet.value, asMetadata(edit.annotationId));
} else {
result.replace(uri, asRange(edit.range), edit.newText);
}
Expand Down
4 changes: 3 additions & 1 deletion client/src/node/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,9 @@ export class LanguageClient extends BaseLanguageClient {
}).finally(() => {
if (this._serverProcess !== undefined) {
this._serverProcess.on('exit', (code, signal) => {
if (code !== null) {
if (code === 0) {
this.info('Server process exited successfully', undefined, false);
} else if (code !== null) {
this.error(`Server process exited with code ${code}.`, undefined, false);
}
if (signal !== null) {
Expand Down
2 changes: 1 addition & 1 deletion jsonrpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![NPM Version](https://img.shields.io/npm/v/vscode-jsonrpc.svg)](https://npmjs.org/package/vscode-jsonrpc)
[![NPM Downloads](https://img.shields.io/npm/dm/vscode-jsonrpc.svg)](https://npmjs.org/package/vscode-jsonrpc)
[![Build Status](https://travis-ci.org/Microsoft/vscode-languageserver-node.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-languageserver-node)
[![Build Status](https://dev.azure.com/ms/vscode-languageserver-node/_apis/build/status/microsoft.vscode-languageserver-node?branchName=main)](https://dev.azure.com/ms/vscode-languageserver-node/_build/latest?definitionId=439&branchName=main)

This npm module implements the base messaging protocol spoken between a VSCode language server and a VSCode language client.

Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion protocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![NPM Version](https://img.shields.io/npm/v/vscode-languageserver-protocol.svg)](https://npmjs.org/package/vscode-languageclient)
[![NPM Downloads](https://img.shields.io/npm/dm/vscode-languageserver-protocol.svg)](https://npmjs.org/package/vscode-languageclient)
[![Build Status](https://travis-ci.org/Microsoft/vscode-languageserver-node.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-languageserver-node)
[![Build Status](https://dev.azure.com/ms/vscode-languageserver-node/_apis/build/status/microsoft.vscode-languageserver-node?branchName=main)](https://dev.azure.com/ms/vscode-languageserver-node/_build/latest?definitionId=439&branchName=main)

This npm module is a tool independent implementation of the language server protocol and can be used in any type of node application. Please note that the protocol is versioned using the LSP specification version number. Since the protocol depends on the `vscode-jsonrpc` version a a breaking change on that dependencies might not be reflected in a major version change of this module. Changing the major version number in these cases was more confusing this it would result in a version mismatch between the protocol and the LSP specification.

Expand Down
70 changes: 68 additions & 2 deletions protocol/metaModel.json
Original file line number Diff line number Diff line change
Expand Up @@ -5503,6 +5503,17 @@
},
"documentation": "Title of the command, like `save`."
},
{
"name": "tooltip",
"type": {
"kind": "base",
"name": "string"
},
"optional": true,
"documentation": "An optional tooltip.\n\n@since 3.18.0\n@proposed",
"since": "3.18.0",
"proposed": true
},
{
"name": "command",
"type": {
Expand Down Expand Up @@ -7907,7 +7918,7 @@
"name": "trace",
"type": {
"kind": "reference",
"name": "TraceValues"
"name": "TraceValue"
},
"optional": true,
"documentation": "The initial trace setting. If omitted trace is disabled ('off')."
Expand Down Expand Up @@ -9328,6 +9339,20 @@
"optional": true,
"documentation": "CodeActionKinds that this server may return.\n\nThe list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server\nmay list out every specific kind they provide."
},
{
"name": "documentation",
"type": {
"kind": "array",
"element": {
"kind": "reference",
"name": "CodeActionKindDocumentation"
}
},
"optional": true,
"documentation": "Static documentation for a class of code actions.\n\nDocumentation from the provider should be shown in the code actions menu if either:\n\n- Code actions of `kind` are requested by the editor. In this case, the editor will show the documentation that\n most closely matches the requested code action kind. For example, if a provider has documentation for\n both `Refactor` and `RefactorExtract`, when the user requests code actions for `RefactorExtract`,\n the editor will use the documentation for `RefactorExtract` instead of the documentation for `Refactor`.\n\n- Any code actions of `kind` are returned by the provider.\n\nAt most one documentation entry should be shown per provider.\n\n@since 3.18.0\n@proposed",
"since": "3.18.0",
"proposed": true
},
{
"name": "resolveProvider",
"type": {
Expand Down Expand Up @@ -10452,7 +10477,7 @@
}
]
},
"documentation": "The label of this parameter information.\n\nEither a string or an inclusive start and exclusive end offsets within its containing\nsignature label. (see SignatureInformation.label). The offsets are based on a UTF-16\nstring representation as `Position` and `Range` does.\n\n*Note*: a label of type string should be a substring of its containing signature label.\nIts intended use case is to highlight the parameter label part in the `SignatureInformation.label`."
"documentation": "The label of this parameter information.\n\nEither a string or an inclusive start and exclusive end offsets within its containing\nsignature label. (see SignatureInformation.label). The offsets are based on a UTF-16\nstring representation as `Position` and `Range` does.\n\nTo avoid ambiguities a server should use the [start, end] offset value instead of using\na substring. Whether a client support this is controlled via `labelOffsetSupport` client\ncapability.\n\n*Note*: a label of type string should be a substring of its containing signature label.\nIts intended use case is to highlight the parameter label part in the `SignatureInformation.label`."
},
{
"name": "documentation",
Expand All @@ -10475,6 +10500,30 @@
],
"documentation": "Represents a parameter of a callable-signature. A parameter can\nhave a label and a doc-comment."
},
{
"name": "CodeActionKindDocumentation",
"properties": [
{
"name": "kind",
"type": {
"kind": "reference",
"name": "CodeActionKind"
},
"documentation": "The kind of the code action being documented.\n\nIf the kind is generic, such as `CodeActionKind.Refactor`, the documentation will be shown whenever any\nrefactorings are returned. If the kind if more specific, such as `CodeActionKind.RefactorExtract`, the\ndocumentation will only be shown when extract refactoring code actions are returned."
},
{
"name": "command",
"type": {
"kind": "reference",
"name": "Command"
},
"documentation": "Command that is ued to display the documentation to the user.\n\nThe title of this documentation code action is taken from {@linkcode Command.title}"
}
],
"documentation": "Documentation for a class of code actions.\n\n@since 3.18.0\n@proposed",
"since": "3.18.0",
"proposed": true
},
{
"name": "NotebookCellTextDocumentFilter",
"properties": [
Expand Down Expand Up @@ -12281,6 +12330,17 @@
"optional": true,
"documentation": "Whether the client honors the change annotations in\ntext edits and resource operations returned via the\n`CodeAction#edit` property by for example presenting\nthe workspace edit in the user interface and asking\nfor confirmation.\n\n@since 3.16.0",
"since": "3.16.0"
},
{
"name": "documentationSupport",
"type": {
"kind": "base",
"name": "boolean"
},
"optional": true,
"documentation": "Whether the client supports documentation for a class of\ncode actions.\n\n@since 3.18.0\n@proposed",
"since": "3.18.0",
"proposed": true
}
],
"documentation": "The Client Capabilities of a {@link CodeActionRequest}."
Expand Down Expand Up @@ -14331,6 +14391,12 @@
"value": "source.fixAll",
"documentation": "Base kind for auto-fix source actions: `source.fixAll`.\n\nFix all actions automatically fix errors that have a clear fix that do not require user input.\nThey should not suppress errors or perform unsafe fixes such as generating new types or classes.\n\n@since 3.15.0",
"since": "3.15.0"
},
{
"name": "Notebook",
"value": "notebook",
"documentation": "Base kind for all code actions applying to the entire notebook's scope. CodeActionKinds using\nthis should always begin with `notebook.`\n\n@since 3.18.0",
"since": "3.18.0"
}
],
"supportsCustomValues": true,
Expand Down
Loading

0 comments on commit cc2b836

Please sign in to comment.