2

I'd like to integrate my own custom language in Visual Studio.

I'd like to have:

  • Syntax highlighting
  • invoke a custom compiler, producing source files in another compilable language. These shall be compiled in a second phase.
  • some simple tools like rename (not text based, so that a local variable is only renamed within scope), find code lines that reference this function/variable etc.
  • Intellisense (code completion, suggest members, types etc.)

Is there a way to achieve this without too much effort?

I already discovered Xtext (limited to a subset of antlr3) for eclipse, but need a similar tool based on antlr4 for visual studio?

Onur
  • 5,017
  • 5
  • 38
  • 54
  • Related: http://stackoverflow.com/questions/5211018/implementing-a-language-service-by-using-the-managed-package-framework – jessehouwing Jul 23 '14 at 14:57

1 Answers1

2

Check out the Extending Visual Studio chapters in MSDN, especially

There are a few other blogs and tutorials on these topics as well:

And a few language services are open source and provide a great example:

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • Do you know if the mentioned language services use antlr4? I didn't find a clue at first glance. Starting from a "similar" language would be of great help. – Onur Jul 23 '14 at 15:41
  • Not specifically ANTLR4, but once you've generated your tokenizer/parser, then the work on top of it will be very similar. You need to build an AST eventually... The parsing code can be found here: https://ironpython.codeplex.com/SourceControl/latest#IronPython_Main/Languages/IronPython/IronPython/Compiler/Ast/ and http://aspnetwebstack.codeplex.com/SourceControl/latest#src/System.Web.Razor/Parser/ – jessehouwing Jul 23 '14 at 16:01
  • I'll have a look at it – Onur Jul 23 '14 at 16:06
  • And this plugin looks very promising...It's a language service for ANTLR inside Visual Studio. And it looks to be using ANTLR to do it. Reflector is your friend after extracting the vsix with your favorite unzipper... http://visualstudiogallery.msdn.microsoft.com/25b991db-befd-441b-b23b-bb5f8d07ee9f or contact Sam directly on twitter (https://twitter.com/samharwell). – jessehouwing Jul 23 '14 at 16:06
  • I'll also have a look. Antlr4 uses antlr3 to parse the grammar, but maybe that's not true for this extension. I'm using this extension myself - should have realized this as a good starting point myself... – Onur Jul 23 '14 at 16:55
  • Sams extension is quite complex. I'm pretty sure it would take months to understand... Maybe I'll start little by little... – Onur Jul 31 '14 at 16:41