src/share/classes/com/sun/tools/javac/parser/EndPosParser.java

changeset 1138
7375d4979bd3
parent 1137
c1238fcc9515
child 1139
f07d6f55d39a
     1.1 --- a/src/share/classes/com/sun/tools/javac/parser/EndPosParser.java	Mon Nov 14 08:09:47 2011 -0800
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,102 +0,0 @@
     1.4 -/*
     1.5 - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
     1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 - *
     1.8 - * This code is free software; you can redistribute it and/or modify it
     1.9 - * under the terms of the GNU General Public License version 2 only, as
    1.10 - * published by the Free Software Foundation.  Oracle designates this
    1.11 - * particular file as subject to the "Classpath" exception as provided
    1.12 - * by Oracle in the LICENSE file that accompanied this code.
    1.13 - *
    1.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 - * version 2 for more details (a copy is included in the LICENSE file that
    1.18 - * accompanied this code).
    1.19 - *
    1.20 - * You should have received a copy of the GNU General Public License version
    1.21 - * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 - *
    1.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 - * or visit www.oracle.com if you need additional information or have any
    1.26 - * questions.
    1.27 - */
    1.28 -
    1.29 -package com.sun.tools.javac.parser;
    1.30 -
    1.31 -import java.util.Map;
    1.32 -import java.util.HashMap;
    1.33 -import com.sun.tools.javac.tree.JCTree;
    1.34 -import com.sun.tools.javac.tree.TreeInfo;
    1.35 -
    1.36 -import static com.sun.tools.javac.tree.JCTree.*;
    1.37 -
    1.38 -/**
    1.39 - * This class is similar to Parser except that it stores ending
    1.40 - * positions for the tree nodes.
    1.41 - *
    1.42 - * <p><b>This is NOT part of any supported API.
    1.43 - * If you write code that depends on this, you do so at your own risk.
    1.44 - * This code and its internal interfaces are subject to change or
    1.45 - * deletion without notice.</b></p>
    1.46 - */
    1.47 -public class EndPosParser extends JavacParser {
    1.48 -
    1.49 -    public EndPosParser(ParserFactory fac, Lexer S, boolean keepDocComments, boolean keepLineMap) {
    1.50 -        super(fac, S, keepDocComments, keepLineMap);
    1.51 -        this.S = S;
    1.52 -        endPositions = new HashMap<JCTree,Integer>();
    1.53 -    }
    1.54 -
    1.55 -    private Lexer S;
    1.56 -
    1.57 -    /** A hashtable to store ending positions
    1.58 -     *  of source ranges indexed by the tree nodes.
    1.59 -     *  Defined only if option flag genEndPos is set.
    1.60 -     */
    1.61 -    Map<JCTree, Integer> endPositions;
    1.62 -
    1.63 -    /** {@inheritDoc} */
    1.64 -    @Override
    1.65 -    protected void storeEnd(JCTree tree, int endpos) {
    1.66 -        int errorEndPos = getErrorEndPos();
    1.67 -        endPositions.put(tree, errorEndPos > endpos ? errorEndPos : endpos);
    1.68 -    }
    1.69 -
    1.70 -    /** {@inheritDoc} */
    1.71 -    @Override
    1.72 -    protected <T extends JCTree> T to(T t) {
    1.73 -        storeEnd(t, token.endPos);
    1.74 -        return t;
    1.75 -    }
    1.76 -
    1.77 -    /** {@inheritDoc} */
    1.78 -    @Override
    1.79 -    protected <T extends JCTree> T toP(T t) {
    1.80 -        storeEnd(t, S.prevToken().endPos);
    1.81 -        return t;
    1.82 -    }
    1.83 -
    1.84 -    @Override
    1.85 -    public JCCompilationUnit parseCompilationUnit() {
    1.86 -        JCCompilationUnit t = super.parseCompilationUnit();
    1.87 -        t.endPositions = endPositions;
    1.88 -        return t;
    1.89 -    }
    1.90 -
    1.91 -    /** {@inheritDoc} */
    1.92 -    @Override
    1.93 -    JCExpression parExpression() {
    1.94 -        int pos = token.pos;
    1.95 -        JCExpression t = super.parExpression();
    1.96 -        return toP(F.at(pos).Parens(t));
    1.97 -    }
    1.98 -
    1.99 -    /** {@inheritDoc} */
   1.100 -    @Override
   1.101 -    public int getEndPos(JCTree tree) {
   1.102 -        return TreeInfo.getEndPos(tree, endPositions);
   1.103 -    }
   1.104 -
   1.105 -}

mercurial