[PATCH] D54781: [clangd] Add 'Switch header/source' command in clangd-vscode

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 22 01:44:00 PST 2018


ilya-biryukov added a comment.

Overall LG, merely stylistic NITs.



================
Comment at: clangd/clients/clangd-vscode/src/extension.ts:69
+        const docIdentifier = TextDocumentIdentifier.create(uri.toString());
+        clangdClient.sendRequest(SwitchSourceHeaderRequest.type, docIdentifier).then(sourceUri => {
+            if (sourceUri !== undefined) {
----------------
Maybe use async/await to improve readabiity? I.e.

```
/*...*/push(registerCommand('...', async() => {
        // ...
        const sourceUri = await clangdClient.sendRequest(SwitchSourceHeaderRequest.type, docIdentifier);
        if (!sourceUri) {
           return;
        }
        const doc = await // ....
}
```



================
Comment at: clangd/clients/clangd-vscode/src/extension.ts:70
+        clangdClient.sendRequest(SwitchSourceHeaderRequest.type, docIdentifier).then(sourceUri => {
+            if (sourceUri !== undefined) {
+                vscode.workspace.openTextDocument(vscode.Uri.parse(sourceUri)).then(doc => vscode.window.showTextDocument(doc));
----------------
Maybe do `if (!sourceUri)` to use consistent style with the first check in the lambda (i.e. `if (!uri)`)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54781





More information about the cfe-commits mailing list