Building a Visual Studio Code Extension

Brian Clark 💡 on March 30, 2019

Visual Studio Code Extension Development I don't like long introductions in posts because you know what brought you here and don't need ... [Read Full]
markdown guide

Hi Brian, your write up here has me want to ask... could an extension read the user's code and render something in-line? Like if I have a comment in my code such as...

/* Azure DevOps: Project ABC
 * #255127 - My user story's name here

I'd like an extension to replace that with a link to my Azure DevOps ABC project's ticket 255127.

I've found the restrictions page in Code's API docs and I'm assuming I cannot have an extension do this. Is there anything possible you're aware of?


At the very worst, you should be able to use something like Acorns to generate an AST and then walk the tree to find comments that match that pattern, query your DevOps source of truth, and add text to the second line. That's a lot of overhead, so hopefully you can find a better way.

On a single instance basis, you should be able to do this easily just by highlighting the comment, running the command, parsing the comment, querying your source of truth, and then using the "editBuilder" API to populate the ticket info. You may have to wrestle with some auth stuff, but that shouldn't be terrible.


Hi James I know this is very delayed but I don't believe those restrictions will hinder you from what you're trying to accomplish. I'm not entirely sure but I'd look into the Programmatic Language features and specifically the refactoring capabilities to see if that would work for your scenario.

link -> code.visualstudio.com/api/language...

Hope this helps


Hey Brian,

Great post! I'm curious if you know of (or have written) any good resources for testing extensions as you build them. So far, this has been my biggest hurdle with extension development

Thanks in advance for any help!


Hey Tanner,

My bad for the very delayed response. I haven't dug deep into doing this just yet but when I do I'll be using John Papa's VS Code extension, Peacock, as a reference: github.com/johnpapa/vscode-peacock


Oh, that's a great repo for really exploring what you can do! I've now built a few internal extensions for my company and have yet to add tests to them (TDD is my jam, so this is a sad thing for me). Time to go back and add in tests! Thanks a lot!

Wow, exactly what I was looking for as well. I wasn't sure how to go about testing an extension! Thanks!

code of conduct - report abuse