2685: Simplify r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2019-12-30 11:32:34 +00:00 committed by GitHub
commit 9cad88dd95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 46 deletions

View file

@ -1,4 +1,4 @@
**
!out/extension.js
!out/main.js
!package.json
!package-lock.json

View file

@ -43,7 +43,7 @@
"onCommand:rust-analyzer.collectGarbage",
"workspaceContains:**/Cargo.toml"
],
"main": "./out/extension",
"main": "./out/main",
"contributes": {
"taskDefinitions": [
{

View file

@ -4,7 +4,7 @@ import commonjs from '@rollup/plugin-commonjs';
import nodeBuiltins from 'builtin-modules';
export default {
input: 'src/extension.ts',
input: 'src/main.ts',
plugins: [
typescript(),
resolve({
@ -19,7 +19,7 @@ export default {
],
external: [...nodeBuiltins, 'vscode'],
output: {
file: './out/extension.js',
file: './out/main.js',
format: 'cjs'
}
};

View file

@ -1,14 +1,48 @@
import * as vscode from 'vscode';
import { Server } from '../server';
// Shows status of rust-analyzer (for debugging)
const statusUri = vscode.Uri.parse('rust-analyzer-status://status');
export function makeCommand(context: vscode.ExtensionContext) {
let poller: NodeJS.Timer | null = null;
const tdcp = new TextDocumentContentProvider();
export class TextDocumentContentProvider
context.subscriptions.push(
vscode.workspace.registerTextDocumentContentProvider(
'rust-analyzer-status',
tdcp,
),
);
context.subscriptions.push({
dispose() {
if (poller != null) {
clearInterval(poller);
}
},
});
return async function handle() {
if (poller == null) {
poller = setInterval(
() => tdcp.eventEmitter.fire(tdcp.uri),
1000,
);
}
const document = await vscode.workspace.openTextDocument(tdcp.uri);
return vscode.window.showTextDocument(
document,
vscode.ViewColumn.Two,
true,
);
};
}
class TextDocumentContentProvider
implements vscode.TextDocumentContentProvider {
public eventEmitter = new vscode.EventEmitter<vscode.Uri>();
public syntaxTree: string = 'Not available';
uri = vscode.Uri.parse('rust-analyzer-status://status');
eventEmitter = new vscode.EventEmitter<vscode.Uri>();
public provideTextDocumentContent(
provideTextDocumentContent(
_uri: vscode.Uri,
): vscode.ProviderResult<string> {
const editor = vscode.window.activeTextEditor;
@ -25,40 +59,3 @@ export class TextDocumentContentProvider
return this.eventEmitter.event;
}
}
let poller: NodeJS.Timer | null = null;
// Shows status of rust-analyzer (for debugging)
export function makeCommand(context: vscode.ExtensionContext) {
const textDocumentContentProvider = new TextDocumentContentProvider();
context.subscriptions.push(
vscode.workspace.registerTextDocumentContentProvider(
'rust-analyzer-status',
textDocumentContentProvider,
),
);
context.subscriptions.push({
dispose() {
if (poller != null) {
clearInterval(poller);
}
},
});
return async function handle() {
if (poller == null) {
poller = setInterval(
() => textDocumentContentProvider.eventEmitter.fire(statusUri),
1000,
);
}
const document = await vscode.workspace.openTextDocument(statusUri);
return vscode.window.showTextDocument(
document,
vscode.ViewColumn.Two,
true,
);
};
}