[PATCH] D55374: [clangd] Show FileStatus in vscode-clangd.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 6 08:21:35 PST 2018
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric.
The file status will be shown in the status bar.
Depends on D55363 <https://reviews.llvm.org/D55363>.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D55374
Files:
clangd/clients/clangd-vscode/src/extension.ts
Index: clangd/clients/clangd-vscode/src/extension.ts
===================================================================
--- clangd/clients/clangd-vscode/src/extension.ts
+++ clangd/clients/clangd-vscode/src/extension.ts
@@ -18,6 +18,37 @@
void, void>('textDocument/switchSourceHeader');
}
+class FileStatus {
+ private statuses = new Map<string, any>();
+ private readonly statusBarItem =
+ vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 10);
+
+ onFileUpdated(fileStatus: any) {
+ const filePath = vscode.Uri.parse(fileStatus.uri);
+ this.statuses.set(filePath.fsPath, fileStatus);
+ this.updateStatus();
+ }
+
+ updateStatus() {
+ const path = vscode.window.activeTextEditor.document.fileName;
+ const status = this.statuses.get(path);
+ if (!status) {
+ this.statusBarItem.hide();
+ return;
+ }
+ this.statusBarItem.text = `clangd: ` + status.state;
+ // FIXME: find a way to show the details in a nicer way.
+ if (status.details.length > 0)
+ this.statusBarItem.tooltip = status.details.map(
+ (detail: any) => detail.message).join('; ');
+ this.statusBarItem.show()
+ }
+
+ dispose() {
+ this.statusBarItem.dispose();
+ }
+}
+
/**
* this method is called when your extension is activate
* your extension is activated the very first time the command is executed
@@ -80,4 +111,13 @@
vscode.Uri.parse(sourceUri));
vscode.window.showTextDocument(doc);
}));
+ const status = new FileStatus();
+ context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(() => {
+ status.updateStatus();
+ }))
+ clangdClient.onReady().then(() => {
+ clangdClient.onNotification('textDocument/fileStatus', (fileStatus) => {
+ status.onFileUpdated(fileStatus)
+ });
+ })
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55374.176982.patch
Type: text/x-patch
Size: 1936 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181206/dee7ecd9/attachment.bin>
More information about the cfe-commits
mailing list