Share via


Enable Block Commenting

To enable block commenting, you need to implement the Service::getCommentFormat method, as described in the following procedure.

This topic is based on the Visual Studio Language Package solution, which provides a basic implementation of the Babel package. For more information about creating one of these solutions, see Walkthrough: Creating a Language Service Package.

To enable block commenting

  1. Open stdservice.h and add a declaration of the getCommentFormat method:

    class Service : public CommentService
    {
    protected:
      override const CommentFormat* getCommentFormat() const; 
      override const ColorInfo*     getColorInfo()     const;
      override const TokenInfo*     getTokenInfo()     const;
    };
    
  2. The method returns a pointer to a CommentFormat structure, which is defined in stdservice.h as follows:

    struct CommentFormat
    {
      const char* lineStart;
      const char* blockStart;
      const char* blockEnd;
      bool useLineComments; 
    };
    

    The lineStart member should be set to the character sequence that starts line comments; set this value to NULL if line comments are not supported. The blockStart and blockEnd members should be set to the start and end characters for block comments. Set useLineCommentsto true if your language uses line comments. C++ comments are defined like this:

    override const CommentFormat* Service::getCommentFormat() const
    {
      static CommentFormat commentFormat =  { "//", "/*", "*/", true  };
      return &commentFormat;
    }
    

Change History

Date

History

Reason

July 2008

Rewrote and refactored project.

Content bug fix.