How to modify JavaScript Intellisense by using Visual Studio Integration Package? - visual-studio

I need to modify some logic of Javascript Intellisense on Visual Studio 2008 SP1 like some build-in function such as ScriptEngine, ScriptEngineBuildVersion and etc. Moreover, I need to dynamically generate function depend on opened docuement.

In Visual Studio, language services are provided via VSPackages. Most built-in language services in Visual Studio 2008 do not really offer any kind of extensibility or customization that would enable what you're trying to achieve.
There are a couple of options you could consider though:
Write your own Javascript language service. Obviously, this would be non-trivial, but it would allow you to get the precise behavior you're after. Language services are responsible for parsing the file to provide colorization, quick info, Intellisense, auto-completion, and other features to the core text editor. The simplest example of a language service is a sample in the Visual Studio 2008 SDK 1.1 called the RegExLangService. There is also a detailed walkthrough for the sample.
You could attempt implementing either an Add-in or a VSPackage which would insert/manipulate text in the editor based on the contents of the open document. Your question doesn't really say exactly what kind of behavior you need (other than dynamically generating a function). This would certainly be possible with the Visual Studio SDK and much less work than writing your own Javascript language service.
Good Luck!

Related

Visual Studio Add-in: How to get selected items in window

Let a "Breakpoints" window (by default opened by Debug>Windows>Breakpoints [ctrl+B, D]) serve as an example. Basically I select few breakpoints in it and I would like to know in my add-in which elements in this window are selected. I am aware that I can get collection of breakpoints in project but I would like to know what elements are selected in "Breakpoints" window.
"Is it possible to get selected items in window or even access its content at all?"
Also I am not sure whenever or not should I post a separate question for this but is there actually a way to capture user activity in IDE like for example capturing an event when user sets (adds) a breakpoint?
Originally I also asked if is it possible to achieve certain things in Visual Studio Express Edition. But this part is irrevelant.
Conclusion:
(after reading jessehouwing's answer)
I guess it is not possible using an Add-ins. Use VSPackages isntead. Also Add-ins are deprecated as of Visual Studio 2013 version.
As mentioned in my comments, what you're trying to accomplish is explicitly prohibited in the Visual Studio Express edition and is a violation of it's license. To extend the product, you need to have at least Visual Studio Professional Edition. many of the extensibility points will actively refuse any communication with 3rd party add-ins.
Almost all the things you're asking are possible using Visual Studio Extensibility once you've installed the professional edition. Products like OzCode show that almost everything is possible. Remember that most features inside visual studio are themselves extensions of the product.
Your question, indeed a whole list of questions, is indeed not the way to ask something on StackOverflow. I can give you some pointers to the documentation, which you've probably already found, and maybe to some open source products that themselves extend parts of Visual Studio that can serve as examples, but from there you'll have to piece something together until you're able to ask more specific questions.
Events you can subscribe to, the breakpoints are a CommandEvents I suspect.
Manipulating windows inside Visual Studio
Projects that extend the debugger that might serve as an example:
PyTools (debugger for Python inside Visual Studio)
Node.js tools for Visual studio (extending the Immediate Window)
But there is no easy answer to your question that fits inside this window. I'd suggest you use a tool like Reflector to look at how Microsoft accomplishes certain things (most of Visual Studio Extensibility is written in .NET anyways) and to look at open source projects that extend visual studio behavior. There are quite a few out there on Codeplex.
I'm not entirely sure what you're trying to accomplish and how it's different from the Breakpoints features inside Visual Studio Professional and up.
I suggest you ask your question in the Visual Studio Extensibility forums over on MSDN, which is in a collaborative forum format, instead of a Q&A format, allowing people to answer your question bit by bit.

How to use the C# editor in a Visual Studio Isolated Shell application?

I wanted to take a look to the Visual Studio extensibility SDK, specifically developing over the Isolated Shell. I would like to be able to use the C# code editor with syntax highlighting, intellisense, etc...
I've already read a bit about how to define your own content to support these features but I understand that for a language already supported like C# the needed package exists in the VSSDK and can be loaded into the isolated shell.
So, when creating an Isolated Shell application from the standard VS template and running the generated project, I can create a new C# file containing a class definition, but it is missing the syntax highlighting and the intellisense. I've found some very basic documentation on extending the Isolated Shell, but I cannot find how to enable the standard editors.
Is it possible to load/enable the standard VS editor extensions? If so, can you point me to any documentation or code example that can guide me a bit?
Thanks!
You can't do that. It's more a licensing issue. If you could put/enable everything in the isolated shell, then nobody would buy Visual Studio anymore.
Here is a more official answer from here: How to connect C# VSPackage to Visual Studio Shell Isolated Mode to have syntax highlighting
VS languages like C#, VB, and C++ cannot be loaded in the isolated
shell. Hence the reason we call it isolated :-)
Additionally it should be noted, the integrated shell does not include
these packages, nor are they licensed for redistribution; as they are
distributed with the Visual Studio product.
The integrated shell is basically the core VS IDE, wherease the
isolated shell is essentially the same IDE, but runs using a different
stub application (so you can customize it to suite your needs). But
the isolated shell does not ship with, or will it load any of the
mainstream language/project services that ship with VS Pro.

Add a new language to Visual Studio 2010 with syntax highlighting and intellisense

I am trying to add support for a different language in Visual Studio 2010. I was hoping to add custom syntax highlighting, and have some sort of basic intellisense work with it. The language I am trying to add is 4Js Genero (a newer version of Informix-4GL). I basically just need support for the .4gl and .per file extensions that are used in Genero/4GL. Does anyone know how to do this, or can point me in the right direction?
It's not really for the faint of heart. Don't underestimate how much work you'll have to put in.
You'll need the Visual Studio 2010 SDK, and then to read (and re-read, and re-read(*)) all about Language Services
The purpose of a language service in Visual Studio is to provide language-specific support for editing source code in the integrated development environment (IDE). You implement a language service as part of a VSPackage.
(*) - unless it all immediately makes sense to you.
This isn't an answer on how to create custom syntax highlighting.
There is an open-source extension for visual studio 2010+ for Genero 4gl language support out of github:
https://github.com/gregfullman/VSGenero/wiki
It should do most of what you're looking for already, and it would certainly make a great starting point for you if you want to do more.

How to write a Visual Studio extension for a template or markup language that supports embedded code snippets

Is it possible to write an extension for Visual Studio 2010 that provides syntax highlighting, intellisense, outlining, etc for a custom template or markup language supporting embedded code snippets, similar to the tooling for Razor in ASP .NET MVC 3? Can this be done without using private APIs, without access to Microsoft-internal documentation and, most importantly, without having to reimplement syntax highlighting, intellisense, etc. for the embedded programming language (i.e. C# or VB)?
The SDK documentation seems to suggest that the Visual Studio editor supports embedded languages via projection buffers, but it doesn't really give any details or examples. Some of the "legacy interop interfaces used for the editor and language services" in Microsoft.VisualStudio.TextManager.Interop also seem to be relevant, e.g. IVsTextBufferCoordinator, but the documentation doesn't say much about how all these pieces fit together.
Provided that projection buffers actually do what I hope, where can I hook into the editor to replace a normal text buffer with a projection buffer?
Does maybe anyone have more information on the APIs relevant for supporting embedded languages or could point me into the right direction?
You should take a look at https://github.com/SparkViewEngine/SparkSense as an example. It was built for the spark view engine to provide intellisense for VS 2010.
"SparkSense is a plugin for Visual Studio 2010 that enables various tooling support and productivity features when using Spark as a View Engine for various MVC frameworks including ASP.NET MVC"
you can write your own editor extension, see this article : http://www.devx.com/VS_2010/Article/45058
And to understand how it works : http://msdn.microsoft.com/en-us/library/dd885240(v=VS.100).aspx
Do research about "Managed Extensibility Framework (MEF) "
You can download an exemple for the Ook langage here

What is the VS 2008 IDE Written in?

I tried to search but if this is a duplicate it is hidden by some noise. Alternate title to the question:
What skills to look for when needing integration with the Visual Studio IDE?
Visual Studio 2008 is written in both native and managed code, though the bulk is written in C++. There are several pieces of Visual Studio that have always been written in managed code (e.g. the property browser, the WinForms Designer). And of course, Visual Studio 2008 is stitched together with COM.
In Visual Studio 2010, there is an effort to move more of the IDE to managed code. The text editor and the shell (i.e., menus, toolbars, document and tool window frames, etc.) are written in C#. In addition, pieces of the C# and VB IDEs are being written in C# and VB respectively. The new language, F#, is written completely in managed code -- the compiler, the language service, the project system, etc. -- are all written in F#.
You can use C#, VB or C++ to integrate with Visual Studio 2008. However, given that Visual Studio is built on COM, a good understanding of COM/ATL will be helpful. In addition, if you choose to use a managed language, a knownledge of COM interop and mixed-mode debugging will be extremely helpful. Note that there are a few levels of VS integration:
Macros -- the simplest way to run custom code in the IDE.
Add-in -- A simple but powerful way to build custom functionality into the IDE. With an add-in, you can create custom commands, listen to events, manipulate text in the editor, etc. However, you cannot add, say, a new language or editor to the IDE with an add-in. For many purposes, an add-in works fine.
Package -- this is the same level of integration as Microsoft's features use. With a package, you can create pretty much anything in the Visual Studio IDE, including adding new languages.
You should note that these become progressively more complex to author and deploy.
In Visual Studio 2010, a new form of extensibility is being introduced in several areas of the IDE, but primarily for extending the new WPF text editor. Going forward, integration with Visual Studio will require MEF (Managed Extensibility Framework) components rather than COM. So, in VS 2010, extending the text editor will simply require authoring a MEF component in your favorite managed language.
The podcast Herding Code episode #48 features an interview with Dustin Campbell, a program manager on the Visual Studio Managed Languages Group.
In that interview he talks for several minutes about this exact issue and gets into details about why the changes in 2010 are breaking compat with 2008 and how the future looks.
If this is strictly a curiousity question the other answers are correct. But if you want to dig a little deeper, listening to the podcast would be well worth your time.
At least the following languages are used inside of Visual Studio 2008
C++
C#
VB.Net
C
C++/CLI
C++ with managed extensions
Probably a few others that I forgot about.
A mix. The core is C++/COM stuff, but a lot of the newer stuff is managed code (C# etc). Due to the core being C++/COM (with a pile of code 'borrowed' from MS Office), VS integration is a funny experience.

Resources