Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/src/share/classes/com/sun/source/util/DocTrees.java
38899 views
/*1* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.source.util;2627import javax.annotation.processing.ProcessingEnvironment;28import javax.lang.model.element.Element;29import javax.tools.JavaCompiler.CompilationTask;3031import com.sun.source.doctree.DocCommentTree;32import javax.tools.Diagnostic;3334/**35* Provides access to syntax trees for doc comments.36*37* @since 1.838*/39@jdk.Exported40public abstract class DocTrees extends Trees {41/**42* Gets a DocTrees object for a given CompilationTask.43* @param task the compilation task for which to get the Trees object44* @throws IllegalArgumentException if the task does not support the Trees API.45*/46public static DocTrees instance(CompilationTask task) {47return (DocTrees) Trees.instance(task);48}4950/**51* Gets a DocTrees object for a given ProcessingEnvironment.52* @param env the processing environment for which to get the Trees object53* @throws IllegalArgumentException if the env does not support the Trees API.54*/55public static DocTrees instance(ProcessingEnvironment env) {56if (!env.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment"))57throw new IllegalArgumentException();58return (DocTrees) getJavacTrees(ProcessingEnvironment.class, env);59}6061/**62* Gets the doc comment tree, if any, for the Tree node identified by a given TreePath.63* Returns null if no doc comment was found.64*/65public abstract DocCommentTree getDocCommentTree(TreePath path);6667/**68* Gets the language model element referred to by the leaf node of the given69* {@link DocTreePath}, or null if unknown.70*/71public abstract Element getElement(DocTreePath path);7273public abstract DocSourcePositions getSourcePositions();7475/**76* Prints a message of the specified kind at the location of the77* tree within the provided compilation unit78*79* @param kind the kind of message80* @param msg the message, or an empty string if none81* @param t the tree to use as a position hint82* @param root the compilation unit that contains tree83*/84public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg,85com.sun.source.doctree.DocTree t,86com.sun.source.doctree.DocCommentTree c,87com.sun.source.tree.CompilationUnitTree root);88}899091