DEV Community

Discussion on: Building a Visual Studio Code Extension

thespiciestdev profile image
James Allen

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?

tbhesswebber profile image
Tanner B. Hess Webber

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.

clarkio profile image
Brian Clark 💡 Author

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 ->

Hope this helps