src/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java

Mon, 21 Jan 2013 20:13:56 +0000

author
mcimadamore
date
Mon, 21 Jan 2013 20:13:56 +0000
changeset 1510
7873d37f5b37
parent 0
959103a6100f
permissions
-rw-r--r--

8005244: Implement overload resolution as per latest spec EDR
Summary: Add support for stuck expressions and provisional applicability
Reviewed-by: jjg

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 package com.sun.tools.javac.tree;
aoqi@0 27
aoqi@0 28 import com.sun.source.doctree.AttributeTree.ValueKind;
aoqi@0 29 import com.sun.source.doctree.DocTree.Kind;
aoqi@0 30
aoqi@0 31 import com.sun.tools.javac.parser.Tokens.Comment;
aoqi@0 32 import com.sun.tools.javac.tree.DCTree.*;
aoqi@0 33 import com.sun.tools.javac.util.Context;
aoqi@0 34 import com.sun.tools.javac.util.DiagnosticSource;
aoqi@0 35 import com.sun.tools.javac.util.JCDiagnostic;
aoqi@0 36 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
aoqi@0 37 import com.sun.tools.javac.util.List;
aoqi@0 38 import com.sun.tools.javac.util.Name;
aoqi@0 39 import com.sun.tools.javac.util.Position;
aoqi@0 40
aoqi@0 41 /**
aoqi@0 42 *
aoqi@0 43 * <p><b>This is NOT part of any supported API.
aoqi@0 44 * If you write code that depends on this, you do so at your own risk.
aoqi@0 45 * This code and its internal interfaces are subject to change or
aoqi@0 46 * deletion without notice.</b>
aoqi@0 47 */
aoqi@0 48 public class DocTreeMaker {
aoqi@0 49
aoqi@0 50 /** The context key for the tree factory. */
aoqi@0 51 protected static final Context.Key<DocTreeMaker> treeMakerKey =
aoqi@0 52 new Context.Key<DocTreeMaker>();
aoqi@0 53
aoqi@0 54 /** Get the TreeMaker instance. */
aoqi@0 55 public static DocTreeMaker instance(Context context) {
aoqi@0 56 DocTreeMaker instance = context.get(treeMakerKey);
aoqi@0 57 if (instance == null)
aoqi@0 58 instance = new DocTreeMaker(context);
aoqi@0 59 return instance;
aoqi@0 60 }
aoqi@0 61
aoqi@0 62 /** The position at which subsequent trees will be created.
aoqi@0 63 */
aoqi@0 64 public int pos = Position.NOPOS;
aoqi@0 65
aoqi@0 66 /** Access to diag factory for ErroneousTrees. */
aoqi@0 67 private final JCDiagnostic.Factory diags;
aoqi@0 68
aoqi@0 69 /** Create a tree maker with NOPOS as initial position.
aoqi@0 70 */
aoqi@0 71 protected DocTreeMaker(Context context) {
aoqi@0 72 context.put(treeMakerKey, this);
aoqi@0 73 diags = JCDiagnostic.Factory.instance(context);
aoqi@0 74 this.pos = Position.NOPOS;
aoqi@0 75 }
aoqi@0 76
aoqi@0 77 /** Reassign current position.
aoqi@0 78 */
aoqi@0 79 public DocTreeMaker at(int pos) {
aoqi@0 80 this.pos = pos;
aoqi@0 81 return this;
aoqi@0 82 }
aoqi@0 83
aoqi@0 84 /** Reassign current position.
aoqi@0 85 */
aoqi@0 86 public DocTreeMaker at(DiagnosticPosition pos) {
aoqi@0 87 this.pos = (pos == null ? Position.NOPOS : pos.getStartPosition());
aoqi@0 88 return this;
aoqi@0 89 }
aoqi@0 90
aoqi@0 91 public DCAttribute Attribute(Name name, ValueKind vkind, List<DCTree> value) {
aoqi@0 92 DCAttribute tree = new DCAttribute(name, vkind, value);
aoqi@0 93 tree.pos = pos;
aoqi@0 94 return tree;
aoqi@0 95 }
aoqi@0 96
aoqi@0 97 public DCAuthor Author(List<DCTree> name) {
aoqi@0 98 DCAuthor tree = new DCAuthor(name);
aoqi@0 99 tree.pos = pos;
aoqi@0 100 return tree;
aoqi@0 101 }
aoqi@0 102
aoqi@0 103 public DCLiteral Code(DCText text) {
aoqi@0 104 DCLiteral tree = new DCLiteral(Kind.CODE, text);
aoqi@0 105 tree.pos = pos;
aoqi@0 106 return tree;
aoqi@0 107 }
aoqi@0 108
aoqi@0 109 public DCComment Comment(String text) {
aoqi@0 110 DCComment tree = new DCComment(text);
aoqi@0 111 tree.pos = pos;
aoqi@0 112 return tree;
aoqi@0 113 }
aoqi@0 114
aoqi@0 115 public DCDeprecated Deprecated(List<DCTree> text) {
aoqi@0 116 DCDeprecated tree = new DCDeprecated(text);
aoqi@0 117 tree.pos = pos;
aoqi@0 118 return tree;
aoqi@0 119 }
aoqi@0 120
aoqi@0 121 public DCDocComment DocComment(Comment comment, List<DCTree> firstSentence, List<DCTree> body, List<DCTree> tags) {
aoqi@0 122 DCDocComment tree = new DCDocComment(comment, firstSentence, body, tags);
aoqi@0 123 tree.pos = pos;
aoqi@0 124 return tree;
aoqi@0 125 }
aoqi@0 126
aoqi@0 127 public DCDocRoot DocRoot() {
aoqi@0 128 DCDocRoot tree = new DCDocRoot();
aoqi@0 129 tree.pos = pos;
aoqi@0 130 return tree;
aoqi@0 131 }
aoqi@0 132
aoqi@0 133 public DCEndElement EndElement(Name name) {
aoqi@0 134 DCEndElement tree = new DCEndElement(name);
aoqi@0 135 tree.pos = pos;
aoqi@0 136 return tree;
aoqi@0 137 }
aoqi@0 138
aoqi@0 139 public DCEntity Entity(Name name) {
aoqi@0 140 DCEntity tree = new DCEntity(name);
aoqi@0 141 tree.pos = pos;
aoqi@0 142 return tree;
aoqi@0 143 }
aoqi@0 144
aoqi@0 145 public DCErroneous Erroneous(String text, DiagnosticSource diagSource, String code, Object... args) {
aoqi@0 146 DCErroneous tree = new DCErroneous(text, diags, diagSource, code, args);
aoqi@0 147 tree.pos = pos;
aoqi@0 148 return tree;
aoqi@0 149 }
aoqi@0 150
aoqi@0 151 public DCThrows Exception(DCReference name, List<DCTree> description) {
aoqi@0 152 DCThrows tree = new DCThrows(Kind.EXCEPTION, name, description);
aoqi@0 153 tree.pos = pos;
aoqi@0 154 return tree;
aoqi@0 155 }
aoqi@0 156
aoqi@0 157 public DCIdentifier Identifier(Name name) {
aoqi@0 158 DCIdentifier tree = new DCIdentifier(name);
aoqi@0 159 tree.pos = pos;
aoqi@0 160 return tree;
aoqi@0 161 }
aoqi@0 162
aoqi@0 163 public DCInheritDoc InheritDoc() {
aoqi@0 164 DCInheritDoc tree = new DCInheritDoc();
aoqi@0 165 tree.pos = pos;
aoqi@0 166 return tree;
aoqi@0 167 }
aoqi@0 168
aoqi@0 169 public DCLink Link(DCReference ref, List<DCTree> label) {
aoqi@0 170 DCLink tree = new DCLink(Kind.LINK, ref, label);
aoqi@0 171 tree.pos = pos;
aoqi@0 172 return tree;
aoqi@0 173 }
aoqi@0 174
aoqi@0 175 public DCLink LinkPlain(DCReference ref, List<DCTree> label) {
aoqi@0 176 DCLink tree = new DCLink(Kind.LINK_PLAIN, ref, label);
aoqi@0 177 tree.pos = pos;
aoqi@0 178 return tree;
aoqi@0 179 }
aoqi@0 180
aoqi@0 181 public DCLiteral Literal(DCText text) {
aoqi@0 182 DCLiteral tree = new DCLiteral(Kind.LITERAL, text);
aoqi@0 183 tree.pos = pos;
aoqi@0 184 return tree;
aoqi@0 185 }
aoqi@0 186
aoqi@0 187 public DCParam Param(boolean isTypeParameter, DCIdentifier name, List<DCTree> description) {
aoqi@0 188 DCParam tree = new DCParam(isTypeParameter, name, description);
aoqi@0 189 tree.pos = pos;
aoqi@0 190 return tree;
aoqi@0 191 }
aoqi@0 192
aoqi@0 193 public DCReference Reference(String signature,
aoqi@0 194 JCTree qualExpr, Name member, List<JCTree> paramTypes) {
aoqi@0 195 DCReference tree = new DCReference(signature, qualExpr, member, paramTypes);
aoqi@0 196 tree.pos = pos;
aoqi@0 197 return tree;
aoqi@0 198 }
aoqi@0 199
aoqi@0 200 public DCReturn Return(List<DCTree> description) {
aoqi@0 201 DCReturn tree = new DCReturn(description);
aoqi@0 202 tree.pos = pos;
aoqi@0 203 return tree;
aoqi@0 204 }
aoqi@0 205
aoqi@0 206 public DCSee See(List<DCTree> reference) {
aoqi@0 207 DCSee tree = new DCSee(reference);
aoqi@0 208 tree.pos = pos;
aoqi@0 209 return tree;
aoqi@0 210 }
aoqi@0 211
aoqi@0 212 public DCSerial Serial(List<DCTree> description) {
aoqi@0 213 DCSerial tree = new DCSerial(description);
aoqi@0 214 tree.pos = pos;
aoqi@0 215 return tree;
aoqi@0 216 }
aoqi@0 217
aoqi@0 218 public DCSerialData SerialData(List<DCTree> description) {
aoqi@0 219 DCSerialData tree = new DCSerialData(description);
aoqi@0 220 tree.pos = pos;
aoqi@0 221 return tree;
aoqi@0 222 }
aoqi@0 223
aoqi@0 224 public DCSerialField SerialField(DCIdentifier name, DCReference type, List<DCTree> description) {
aoqi@0 225 DCSerialField tree = new DCSerialField(name, type, description);
aoqi@0 226 tree.pos = pos;
aoqi@0 227 return tree;
aoqi@0 228 }
aoqi@0 229
aoqi@0 230 public DCSince Since(List<DCTree> text) {
aoqi@0 231 DCSince tree = new DCSince(text);
aoqi@0 232 tree.pos = pos;
aoqi@0 233 return tree;
aoqi@0 234 }
aoqi@0 235
aoqi@0 236 public DCStartElement StartElement(Name name, List<DCTree> attrs, boolean selfClosing) {
aoqi@0 237 DCStartElement tree = new DCStartElement(name, attrs, selfClosing);
aoqi@0 238 tree.pos = pos;
aoqi@0 239 return tree;
aoqi@0 240 }
aoqi@0 241
aoqi@0 242 public DCText Text(String text) {
aoqi@0 243 DCText tree = new DCText(text);
aoqi@0 244 tree.pos = pos;
aoqi@0 245 return tree;
aoqi@0 246 }
aoqi@0 247
aoqi@0 248 public DCThrows Throws(DCReference name, List<DCTree> description) {
aoqi@0 249 DCThrows tree = new DCThrows(Kind.THROWS, name, description);
aoqi@0 250 tree.pos = pos;
aoqi@0 251 return tree;
aoqi@0 252 }
aoqi@0 253
aoqi@0 254 public DCUnknownBlockTag UnknownBlockTag(Name name, List<DCTree> content) {
aoqi@0 255 DCUnknownBlockTag tree = new DCUnknownBlockTag(name, content);
aoqi@0 256 tree.pos = pos;
aoqi@0 257 return tree;
aoqi@0 258 }
aoqi@0 259
aoqi@0 260 public DCUnknownInlineTag UnknownInlineTag(Name name, List<DCTree> content) {
aoqi@0 261 DCUnknownInlineTag tree = new DCUnknownInlineTag(name, content);
aoqi@0 262 tree.pos = pos;
aoqi@0 263 return tree;
aoqi@0 264 }
aoqi@0 265
aoqi@0 266 public DCValue Value(DCReference ref) {
aoqi@0 267 DCValue tree = new DCValue(ref);
aoqi@0 268 tree.pos = pos;
aoqi@0 269 return tree;
aoqi@0 270 }
aoqi@0 271
aoqi@0 272 public DCVersion Version(List<DCTree> text) {
aoqi@0 273 DCVersion tree = new DCVersion(text);
aoqi@0 274 tree.pos = pos;
aoqi@0 275 return tree;
aoqi@0 276 }
aoqi@0 277 }

mercurial