com.sun.tools.javac.parser
Class DocCommentScanner

java.lang.Object
  extended by com.sun.tools.javac.parser.Scanner
      extended by com.sun.tools.javac.parser.DocCommentScanner
All Implemented Interfaces:
Lexer

public class DocCommentScanner
extends Scanner

An extension to the base lexical analyzer that captures and processes the contents of doc comments. It does so by translating Unicode escape sequences and by stripping the leading whitespace and starts from each line of the comment.

This is NOT part of any API supported by Sun Microsystems. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.


Nested Class Summary
static class DocCommentScanner.Factory
          A factory for creating scanners.
 
Nested classes/interfaces inherited from class com.sun.tools.javac.parser.Scanner
Scanner.CommentStyle
 
Field Summary
private  int bp
           
private  char[] buf
          The comment input buffer, index of next chacter to be read, index of one past last character in buffer.
private  int buflen
           
private  char ch
          The current character.
private  int col
          The column number position of the current character.
private  java.lang.String docComment
          Translated and stripped contents of doc comment
private  char[] docCommentBuffer
          Buffer for doc comment.
private  int docCommentCount
          Number of characters in doc comment buffer.
private  int pos
          Starting position of the comment in original source
private  int unicodeConversionBp
          The buffer index of the last converted Unicode character
 
Fields inherited from class com.sun.tools.javac.parser.Scanner
deprecatedFlag, surrogatesSupported
 
Constructor Summary
protected DocCommentScanner(DocCommentScanner.Factory fac, char[] input, int inputLength)
          Create a scanner from the input array.
protected DocCommentScanner(DocCommentScanner.Factory fac, java.nio.CharBuffer buffer)
          Create a scanner from the input buffer.
 
Method Summary
private  void convertUnicode()
          Convert Unicode escape; bp points to initial '\' character (Spec 3.3).
private  int digit(int base)
          Convert an ASCII digit from its base (8, 10, or 16) to its value.
 java.lang.String docComment()
          Returns the documentation string of the current token.
private  void expandCommentBuffer()
          Unconditionally expand the comment buffer.
 Position.LineMap getLineMap()
          Build a map for translating between line numbers and positions in the input.
 void nextToken()
          Read token.
protected  void processComment(Scanner.CommentStyle style)
          Process a doc comment and make the string content available.
private  void scanChar()
          Read next character.
private  void scanDocCommentChar()
          Read next character in doc comment, skipping over double '\' characters.
 
Methods inherited from class com.sun.tools.javac.parser.Scanner
deprecatedFlag, endPos, errPos, errPos, getRawCharacters, getRawCharacters, name, pos, prevEndPos, processLineTerminator, processWhiteSpace, radix, resetDeprecatedFlag, stringVal, token, token
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pos

private int pos
Starting position of the comment in original source


buf

private char[] buf
The comment input buffer, index of next chacter to be read, index of one past last character in buffer.


bp

private int bp

buflen

private int buflen

ch

private char ch
The current character.


col

private int col
The column number position of the current character.


unicodeConversionBp

private int unicodeConversionBp
The buffer index of the last converted Unicode character


docCommentBuffer

private char[] docCommentBuffer
Buffer for doc comment.


docCommentCount

private int docCommentCount
Number of characters in doc comment buffer.


docComment

private java.lang.String docComment
Translated and stripped contents of doc comment

Constructor Detail

DocCommentScanner

protected DocCommentScanner(DocCommentScanner.Factory fac,
                            java.nio.CharBuffer buffer)
Create a scanner from the input buffer. buffer must implement array() and compact(), and remaining() must be less than limit().


DocCommentScanner

protected DocCommentScanner(DocCommentScanner.Factory fac,
                            char[] input,
                            int inputLength)
Create a scanner from the input array. The array must have at least a single character of extra space.

Method Detail

expandCommentBuffer

private void expandCommentBuffer()
Unconditionally expand the comment buffer.


digit

private int digit(int base)
Convert an ASCII digit from its base (8, 10, or 16) to its value.


convertUnicode

private void convertUnicode()
Convert Unicode escape; bp points to initial '\' character (Spec 3.3).


scanChar

private void scanChar()
Read next character.


scanDocCommentChar

private void scanDocCommentChar()
Read next character in doc comment, skipping over double '\' characters. If a double '\' is skipped, put in the buffer and update buffer count.


nextToken

public void nextToken()
Description copied from class: Scanner
Read token.

Specified by:
nextToken in interface Lexer
Overrides:
nextToken in class Scanner

docComment

public java.lang.String docComment()
Returns the documentation string of the current token.

Specified by:
docComment in interface Lexer
Overrides:
docComment in class Scanner

processComment

protected void processComment(Scanner.CommentStyle style)
Process a doc comment and make the string content available. Strips leading whitespace and stars.

Overrides:
processComment in class Scanner

getLineMap

public Position.LineMap getLineMap()
Build a map for translating between line numbers and positions in the input.

Specified by:
getLineMap in interface Lexer
Overrides:
getLineMap in class Scanner
Returns:
a LineMap