C# Class Rhino.Ast.Comment

Node representing comments.
Node representing comments. Node type is Rhino.Token.COMMENT .

JavaScript effectively has five comment types:

  1. // line comments
  2. /* block comments *\/
  3. /** jsdoc comments *\/
  4. <!-- html-open line comments
  5. ^\\s*--> html-close line comments

The first three should be familiar to Java programmers. JsDoc comments are really just block comments with some conventions about the formatting within the comment delimiters. Line and block comments are described in the Ecma-262 specification.

SpiderMonkey and Rhino also support HTML comment syntax, but somewhat counterintuitively, the syntax does not produce a block comment. Instead, everything from the string <!-- through the end of the line is considered a comment, and if the token --> is the first non-whitespace on the line, then the line is considered a line comment. This is to support parsing JavaScript in <script> HTML tags that has been "hidden" from very old browsers by surrounding it with HTML comment delimiters.

Note the node start position for Comment nodes is still relative to the parent, but Comments are always stored directly in the AstRoot node, so they are also effectively absolute offsets.

Inheritance: AstNode
Show file Open project: hazzik/Rhino.Net

Public Methods

Method Description
Comment ( int pos, int len, Token type, string value ) : System.Text

Constructs a new Comment

GetCommentType ( ) : Token.CommentType

Returns the comment style

GetValue ( ) : string

Returns a string of the comment value.

Returns a string of the comment value.

SetCommentType ( Token type ) : void

Sets the comment style

ToSource ( int depth ) : string
Visit ( NodeVisitor v ) : void

Comment nodes are not visited during normal visitor traversals, but comply with the AstNode.Visit(NodeVisitor) interface.

Method Details

Comment() public method

Constructs a new Comment
public Comment ( int pos, int len, Token type, string value ) : System.Text
pos int the start position
len int the length including delimiter(s)
type Rhino.Token the comment type
value string the value of the comment, as a string
return System.Text

GetCommentType() public method

Returns the comment style
public GetCommentType ( ) : Token.CommentType
return Token.CommentType

GetValue() public method

Returns a string of the comment value.
Returns a string of the comment value.
public GetValue ( ) : string
return string

SetCommentType() public method

Sets the comment style
public SetCommentType ( Token type ) : void
type Rhino.Token /// the comment style, a /// Rhino.Token.CommentType ///
return void

ToSource() public method

public ToSource ( int depth ) : string
depth int
return string

Visit() public method

Comment nodes are not visited during normal visitor traversals, but comply with the AstNode.Visit(NodeVisitor) interface.
public Visit ( NodeVisitor v ) : void
v NodeVisitor
return void