Merge #2685
2685: Simplify r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
9cad88dd95
5 changed files with 43 additions and 46 deletions
|
@ -1,4 +1,4 @@
|
|||
**
|
||||
!out/extension.js
|
||||
!out/main.js
|
||||
!package.json
|
||||
!package-lock.json
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
"onCommand:rust-analyzer.collectGarbage",
|
||||
"workspaceContains:**/Cargo.toml"
|
||||
],
|
||||
"main": "./out/extension",
|
||||
"main": "./out/main",
|
||||
"contributes": {
|
||||
"taskDefinitions": [
|
||||
{
|
||||
|
|
|
@ -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'
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue