This is an archive of the discontinued LLVM Phabricator instance.

register cuda language activation event and activate for .cuh files
ClosedPublic

Authored by ptaylor on Nov 8 2019, 10:50 PM.

Diff Detail

Event Timeline

ptaylor created this revision.Nov 8 2019, 10:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2019, 10:50 PM

A similar PR has been submitted to the vscode-cpptools repo to enable debugging CUDA files via cuda-gdb with the official Microsoft VSCode C++ plugin: https://github.com/microsoft/vscode-cpptools/pull/4585

Thanks for the patch.

clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
86

I think we could simplify the code, we could move this part to the package.json under the contributes umbrella, something like

"contributes": {
      "languages": [
          {
              "id": "cuda",
              "filenamePatterns": [
                  "**/*.{cu}",
                  "**/*.{cuh}",
              ],
          }
      ]

then in the extension.ts, we only need an entry { scheme: 'file', language: 'cuda' } when initailizing the clientOptions.

ptaylor added inline comments.Nov 14 2019, 10:03 AM
clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
86

Yes that's an option. I chose this approach to stay consistent with the current behavior, because vscode-clangd can do CUDA intellisense and refactoring, it doesn't contribute the CUDA grammar definitions for syntax highlighting.

The VSCode docs aren't clear on whether multiple extensions can contribute separate features for the same language, or what happens when two plugins both contribute languages with the same languageId.

hokein added inline comments.Nov 15 2019, 1:31 AM
clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
86

I chose this approach to stay consistent with the current behavior.

Yes, I was not ware of this approach before.

The VSCode docs aren't clear on whether multiple extensions can contribute separate features for the same language, or what happens when two plugins both contribute languages with the same languageId.

The vscode doc says ontributes.languages can enrich the knowledge about vscode, but doesn't mention about what if there are multiple extensions contribute for the same language, but from our experience (clangd extension also contributes to cpp language for taking some file patterns into account), it seems no problem so far.

Anyway, I'm also fine with the current approach.

93

I'd drop A working ...., I don't know much about vscode-cudacpp. But in theory, clangd extension will work with any extension which provides the cuda language definition.

ptaylor updated this revision to Diff 230301.Nov 20 2019, 11:37 AM
  • add package.json entry to contribute cuda language id
  • remove extra cuda file patterns, update comments
ptaylor updated this revision to Diff 230302.Nov 20 2019, 11:38 AM
  • fix package.json whitespace
ptaylor marked 4 inline comments as done.Nov 20 2019, 11:40 AM
hokein accepted this revision.Nov 26 2019, 6:13 AM

sorry for the delay, looks good, one more nit.

clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
91

This comment seems not correct anymore, I'd just drop it, or rephrase like VSCode does not have CUDA as a supported language yet, but our extension does.

This revision is now accepted and ready to land.Nov 26 2019, 6:13 AM
ptaylor updated this revision to Diff 231742.Dec 2 2019, 11:30 AM

drop comment about vscode cuda syntax highlighting

ptaylor marked an inline comment as done.Dec 2 2019, 11:31 AM
This revision was automatically updated to reflect the committed changes.