Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into rebornix/semver
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Jun 10, 2022
2 parents 19050eb + 797af53 commit bd5cd85
Show file tree
Hide file tree
Showing 24 changed files with 149 additions and 1,085 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dockerfile": "Dockerfile",
"args": {
"INSTALL_NODE": "true",
"NODE_VERSION": "16.13.0"
"NODE_VERSION": "16.14.2"
}
},

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ on:
- Yes, publish pre-release

env:
NODE_VERSION: 16.13.0
NODE_VERSION: 16.14.2
PYTHON_VERSION: 3.8
JULIA_VERSION: 1.5.2
MOCHA_REPORTER_JUNIT: true # Use the mocha-multi-reporters and send output to both console (spec) and JUnit (mocha-junit-reporter). Also enables a reporter which exits the process running the tests if it haven't already.
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.13.0
v16.14.2
11 changes: 1 addition & 10 deletions TELEMETRY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8795,16 +8795,7 @@ No properties for event

## Locations Used

[src/webviews/extension-side/webviewHost.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/webviews/extension-side/webviewHost.ts)
```typescript
this.dispose();
};

@captureTelemetry(Telemetry.WebviewStyleUpdate)
private async handleCssRequest(): Promise<void> {
const isDark = await this.isDark();
return this.postMessageInternal(CssMessages.GetCssResponse, {
```
Event can be removed. Not referenced anywhere

</details>
<details>
Expand Down
196 changes: 78 additions & 118 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"theme": "light"
},
"engines": {
"vscode": "^1.68.0-insider"
"vscode": "^1.69.0-insider"
},
"keywords": [
"jupyter",
Expand Down Expand Up @@ -2141,7 +2141,7 @@
"@nteract/messaging": "^7.0.0",
"@vscode/extension-telemetry": "^0.5.2",
"@vscode/jupyter-ipywidgets": "^1.0.9",
"@vscode/jupyter-lsp-middleware": "0.2.38",
"@vscode/jupyter-lsp-middleware": "^0.2.48",
"ajv-keywords": "^3.5.2",
"ansi-to-html": "^0.6.7",
"arch": "^2.1.0",
Expand Down Expand Up @@ -2205,18 +2205,18 @@
"url-parse": "1.5.8",
"uuid": "^3.3.2",
"vscode-debugprotocol": "^1.41.0",
"vscode-jsonrpc": "6.0.0",
"vscode-languageclient": "7.0.0",
"vscode-languageserver": "7.0.0",
"vscode-languageserver-protocol": "3.16.0",
"vscode-jsonrpc": "8.0.2-next.1",
"vscode-languageclient": "8.0.2-next.4",
"vscode-languageserver": "8.0.2-next.4",
"vscode-languageserver-protocol": "3.17.2-next.5",
"vscode-tas-client": "^0.1.27",
"ws": "^6.2.2",
"zeromq": "^6.0.0-beta.6"
},
"devDependencies": {
"@actions/glob": "^0.3.0",
"@actions/core": "^1.2.6",
"@actions/github": "^4.0.0",
"@actions/glob": "^0.3.0",
"@babel/cli": "^7.15.4",
"@babel/core": "^7.4.4",
"@babel/plugin-transform-runtime": "^7.4.4",
Expand Down
4 changes: 3 additions & 1 deletion src/intellisense/fileBasedCancellationStrategy.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ class FileCancellationSenderStrategy implements CancellationSenderStrategy {
tryRun(() => fs.mkdirSync(folder, { recursive: true }));
}

public sendCancellation(_: MessageConnection, id: CancellationId): void {
public sendCancellation(_: MessageConnection, id: CancellationId): Promise<void> {
const file = getCancellationFilePath(this.folderName, id);
tryRun(() => fs.writeFileSync(file, '', { flag: 'w' }));

return Promise.resolve();
}

public cleanup(id: CancellationId): void {
Expand Down
63 changes: 43 additions & 20 deletions src/intellisense/languageServer.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
DynamicFeature,
ExecuteCommandRegistrationOptions,
ExecuteCommandRequest,
FeatureState,
LanguageClient,
LanguageClientOptions,
RegistrationData,
Expand All @@ -26,7 +27,6 @@ import { NOTEBOOK_SELECTOR, PYTHON_LANGUAGE } from '../platform/common/constants
import { traceInfo } from '../platform/logging';
import { getInterpreterId } from '../platform/pythonEnvironments/info/interpreter';
import { noop } from '../platform/common/utils/misc';
import { sleep } from '../platform/common/utils/async';
import { PythonEnvironment } from '../platform/pythonEnvironments/info';
import { getFilePath } from '../platform/common/platform/fs-paths';

Expand All @@ -39,8 +39,20 @@ function ensure(target: any, key: string) {
}

class NerfedExecuteCommandFeature implements DynamicFeature<ExecuteCommandRegistrationOptions> {
private _id = uuid();
private _commands: Map<string, Disposable[]> = new Map<string, Disposable[]>();

fillInitializeParams = undefined;
preInitialize = undefined;

getState(): FeatureState {
return {
kind: 'workspace',
id: this._id,
registrations: true
};
}

public get registrationType(): RegistrationType<ExecuteCommandRegistrationOptions> {
return ExecuteCommandRequest.type;
}
Expand All @@ -54,7 +66,7 @@ class NerfedExecuteCommandFeature implements DynamicFeature<ExecuteCommandRegist
return;
}
this.register({
id: uuid(),
id: this._id,
registerOptions: Object.assign({}, capabilities.executeCommandProvider)
});
}
Expand Down Expand Up @@ -86,21 +98,41 @@ class NerfedExecuteCommandFeature implements DynamicFeature<ExecuteCommandRegist
* "notebook-intellisense.trace.server.verbosity": "Verbose",
*/
export class LanguageServer implements Disposable {
private _client: LanguageClient | undefined;
private _interpreterId: String;

private constructor(
public client: LanguageClient,
client: LanguageClient,
public interpreter: PythonEnvironment,
private readonly middleware: NotebookMiddleware,
private disposables: Disposable[]
) {
// Client should be already started. We can expose it right away.
this._client = client;
this._interpreterId = getInterpreterId(interpreter);
workspace.onDidChangeNotebookDocument(this.onDidChangeNotebookDocument, this, disposables);
}

public async dispose() {
if (!this._client) {
return;
}

const client = this._client;

// Stop exposing language client so that no one can access it while stopping.
this._client = undefined;

this.disposables.forEach((d) => d.dispose());

// Make sure we dispose middleware before stopping client.
this.middleware.dispose();
await this.client.stop();

await client.stop();
}

public get client(): LanguageClient | undefined {
return this._client;
}

public get interpreterId() {
Expand Down Expand Up @@ -166,33 +198,24 @@ export class LanguageServer implements Disposable {
}
};

languageClient = new LanguageClient('notebook-intellisense', serverOptions, clientOptions);
const client = new LanguageClient('notebook-intellisense', serverOptions, clientOptions);

// Before starting do a little hack to prevent the pylance double command registration (working with Jake to have an option to skip commands)
/* eslint-disable @typescript-eslint/no-explicit-any */
const features: (StaticFeature | DynamicFeature<any>)[] = (languageClient as unknown as any)._features;
const features: (StaticFeature | DynamicFeature<any>)[] = (client as unknown as any)._features;
const minusCommands = features.filter(
(f) => (f as any).registrationType?.method != 'workspace/executeCommand'
);
minusCommands.push(new NerfedExecuteCommandFeature());
(languageClient as any)._features = minusCommands;
(client as any)._features = minusCommands;

// Then start (which will cause the initialize request to be sent to pylance)
const languageClientDisposable = languageClient.start();
await client.start();

// After starting, wait for it to be ready
while (languageClient && !languageClient.initializeResult) {
await sleep(100);
}
if (languageClient) {
await languageClient.onReady();
}
// Expose client once it is fully initialized.
languageClient = client;

return new LanguageServer(languageClient, interpreter, middleware, [
languageClientDisposable,
cancellationStrategy,
outputChannel
]);
return new LanguageServer(client, interpreter, middleware, [cancellationStrategy, outputChannel]);
} else {
// Not creating a server, so dispose of the cancellation strategy
cancellationStrategy.dispose();
Expand Down
8 changes: 0 additions & 8 deletions src/platform/messageTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,6 @@ export interface INotebookModelVersionChange extends INotebookModelChange {
kernelConnection?: KernelConnectionMetadata;
}

export enum CssMessages {
GetCssRequest = 'get_css_request',
GetCssResponse = 'get_css_response',
GetTheme = 'get_theme'
}

export enum SharedMessages {
UpdateSettings = 'update_settings',
Started = 'started',
Expand Down Expand Up @@ -334,8 +328,6 @@ export class IInteractiveWindowMapping {
public [InteractiveWindowMessages.VariableExplorerToggle]: boolean;
public [InteractiveWindowMessages.SetVariableExplorerHeight]: IVariableExplorerHeight;
public [InteractiveWindowMessages.VariableExplorerHeightResponse]: IVariableExplorerHeight;
public [CssMessages.GetCssRequest]: IGetCssRequest;
public [CssMessages.GetCssResponse]: IGetCssResponse;
public [InteractiveWindowMessages.OpenLink]: string | undefined;
public [InteractiveWindowMessages.SavePng]: string | undefined;
public [InteractiveWindowMessages.NotebookClose]: INotebookIdentity;
Expand Down
Loading

0 comments on commit bd5cd85

Please sign in to comment.