com.sun.tools.javac.parser
Class EndPosParser

java.lang.Object
  extended by com.sun.tools.javac.parser.JavacParser
      extended by com.sun.tools.javac.parser.EndPosParser
All Implemented Interfaces:
Parser

public class EndPosParser
extends JavacParser

This class is similar to Parser except that it stores ending positions for the tree nodes.

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.


Field Summary
(package private)  java.util.Map<JCTree,java.lang.Integer> endPositions
          A hashtable to store ending positions of source ranges indexed by the tree nodes.
private  Lexer S
           
 
Fields inherited from class com.sun.tools.javac.parser.JavacParser
allowAnnotations, allowAsserts, allowEnums, allowForeach, allowGenerics, allowStaticImport, allowVarargs, docComments, EXPR, F, keepDocComments, keepLineMap, NOPARAMS, odStackSupply, opStackSupply, TYPE, TYPEARG
 
Constructor Summary
EndPosParser(ParserFactory fac, Lexer S, boolean keepDocComments, boolean keepLineMap)
           
 
Method Summary
 int getEndPos(JCTree tree)
          Get the end position for a tree node.
(package private)  JCTree.JCExpression parExpression()
          ParExpression = "(" Expression ")"
 JCTree.JCCompilationUnit parseCompilationUnit()
          CompilationUnit = [ { "@" Annotation } PACKAGE Qualident ";"] {ImportDeclaration} {TypeDeclaration}
protected  void storeEnd(JCTree tree, int endpos)
          Store ending position for a tree.
protected
<T extends JCTree>
T
to(T t)
          Store ending position for a tree.
protected
<T extends JCTree>
T
toP(T t)
          Store ending position for a tree.
 
Methods inherited from class com.sun.tools.javac.parser.JavacParser
accept, annotation, annotationFieldValue, annotationFieldValues, annotationFieldValuesOpt, annotationsOpt, annotationValue, arguments, arguments, argumentsOpt, arrayCreatorRest, arrayInitializer, attach, basicType, block, block, blockStatements, bracketsSuffix, catchClause, checkAnnotations, checkExprStat, checkForeach, checkGenerics, checkNoMods, checkStaticImports, checkVarargs, classCreatorRest, classDeclaration, classOrInterfaceBody, classOrInterfaceBodyDeclaration, classOrInterfaceOrEnumDeclaration, creator, enumBody, enumDeclaration, enumeratorDeclaration, foldStrings, forInit, formalParameter, formalParameters, forUpdate, getErrorEndPos, getStartPos, ident, illegal, illegal, importDeclaration, innerCreator, interfaceDeclaration, isZero, literal, methodDeclaratorRest, modifiersOpt, modifiersOpt, moreStatementExpressions, optag, optFinal, parseExpression, parseStatement, parseType, prec, qualident, qualidentList, strval, superSuffix, switchBlockStatementGroups, term, term, term1, term1Rest, term2, term2Rest, term3, termRest, typeArgument, typeArguments, typeArguments, typeArgumentsOpt, typeArgumentsOpt, typeArgumentsOpt, typeDeclaration, typeList, typeParameter, typeParametersOpt, typetag, unoptag, variableDeclarator, variableDeclaratorId, variableDeclaratorRest, variableDeclarators, variableDeclaratorsRest, variableInitializer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

S

private Lexer S

endPositions

java.util.Map<JCTree,java.lang.Integer> endPositions
A hashtable to store ending positions of source ranges indexed by the tree nodes. Defined only if option flag genEndPos is set.

Constructor Detail

EndPosParser

public EndPosParser(ParserFactory fac,
                    Lexer S,
                    boolean keepDocComments,
                    boolean keepLineMap)
Method Detail

storeEnd

protected void storeEnd(JCTree tree,
                        int endpos)
Store ending position for a tree.

Overrides:
storeEnd in class JavacParser
Parameters:
tree - The tree.
endpos - The ending position to associate with the tree.

to

protected <T extends JCTree> T to(T t)
Store ending position for a tree. The ending position should be the ending position of the current token.

Overrides:
to in class JavacParser
Parameters:
t - The tree.

toP

protected <T extends JCTree> T toP(T t)
Store ending position for a tree. The ending position should be greater of the ending position of the previous token and errorEndPos.

Overrides:
toP in class JavacParser
Parameters:
t - The tree.

parseCompilationUnit

public JCTree.JCCompilationUnit parseCompilationUnit()
Description copied from class: JavacParser
CompilationUnit = [ { "@" Annotation } PACKAGE Qualident ";"] {ImportDeclaration} {TypeDeclaration}

Specified by:
parseCompilationUnit in interface Parser
Overrides:
parseCompilationUnit in class JavacParser
Returns:
a compilation unit

parExpression

JCTree.JCExpression parExpression()
ParExpression = "(" Expression ")"

Overrides:
parExpression in class JavacParser

getEndPos

public int getEndPos(JCTree tree)
Get the end position for a tree node. The end position is defined to be the position of the last character of the last token of the node's source text. Returns Position.NOPOS if end positions are not generated or the position is otherwise not found.

Overrides:
getEndPos in class JavacParser
Parameters:
tree - The tree node