Customizing and Extending Babel

The source code for Babel is provided in the VSIP Environment SDK. You can use the source code to debug through Babel or to extend Babel functionality.

Finding the Babel Package Source

After installing the Visual Studio SDK, you can find the Babel VSPackage files in the Babel folder (for example, <InstallPath>\VisualStudioIntegration\Babel\Source\LangService). You can extend the Babel VSPackage functionality by modifying the default implementation. It is recommended that you create a copy of the entire Babel folder and modify only the copy.

注意

You must provide new package GUIDs and service GUIDs for the Babel Package if you intend to modify the default implementation. Then both the modified Babel Package and your language service must be installed and registered with Visual Studio. These package and service GUIDs are defined in BabelGuids.cpp.

Customizing Babel

To extend the default Babel implementation

  1. Open the lservice.sln file in the LangService folder (for example, <InstallPath>\VisualStudioIntegration\Babel\Source\LangService\lservice.sln).

  2. Replace the existing VSPackage and service GUIDs with your own GUIDs in BabelGuids.cpp and build the solution.

    注意

    Make sure that the .dll file created does not conflict with any existing .dll files.

  3. Include your modifications to the Babel source code.

  4. Use the Visual Studio Language Service Wizard to generate a new Babel language service project.

  5. Include your modifications to the new language service project to use your modified Babel Package.

  6. Link your parser component to the new language service project to use the Babel VSPackage like the default implementation. For more information on this, see Using the Default Babel Implementation.

Extending Babel

You can alternatively extend the Babel VSPackage functionality by modifying the Babel source code and linking or binding your own parser component to the code:

To extend the Babel VSPackage

  1. Copy the files in the LangService directory into a solution.

  2. Replace the existing VSPackage and service GUIDs with your own GUIDs in BabelGuids.cpp and build the solution.

    注意

    Make sure that the .dll file created does not conflict with any existing .dll files.

  3. Include your modifications to the Babel source code.

  4. Provide code for the parser component that either links to the modified Babel source, or is tightly bound within the modified Babel source code.

Babel Files

The following Babel folders are found in the VSIP Environment SDK's Babel folder (for example, C:\Program Files\VSIP 8.0\EnvSDK\Babel):

  • \Common

    Contains the source files of common.lib, which contains default implementations of the IBabelService Interface and interfaces for the generated lexer and parser.

  • \Samples\ECMAScriptLangService

    Contains a sample ECMA script language service.

  • \Samples\MyCLangService

    Contains an example of a CLR language integrated into Visual Studio using Babel.

  • \Samples\PascalLangService

    Contains a sample Pascal language service.

  • \Samples\SchemaLangService

    Contains a sample schema language service.

  • \Source\LangService

    Contains the source files of the Babel VSPackage.

  • \Source

    Contains the babelservice.idl and the readme.txt file.

Conventions

The code in the \Common directory uses the following conventions:

  • Types and constants start with a capital letter. For example, class StdService, enum Color { ColorBlack }.

  • Variables start with a lower case letter. For example, token, g_service.

  • Global variables are prefixed with g_ and member variables are prefixed with m_. For example, g_languageName.

  • Arguments are marked as in, out or inout. For example, void increment( inout int* i ). These are empty #defines and are to make the code easier to understand.

  • Methods are either marked as virtual, override (used whenever a virtual member is redefined), or final (used for a non-virtual method). The override and final keywords are actually empty #defines and are to make the code easier to understand.

See Also

Concepts

Using the Default Babel Implementation

Babel Package Overview

Implementing the IBabelService Interface