Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/src/share/classes/com/sun/source/util/DocTrees.java
38899 views
1
/*
2
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package com.sun.source.util;
27
28
import javax.annotation.processing.ProcessingEnvironment;
29
import javax.lang.model.element.Element;
30
import javax.tools.JavaCompiler.CompilationTask;
31
32
import com.sun.source.doctree.DocCommentTree;
33
import javax.tools.Diagnostic;
34
35
/**
36
* Provides access to syntax trees for doc comments.
37
*
38
* @since 1.8
39
*/
40
@jdk.Exported
41
public abstract class DocTrees extends Trees {
42
/**
43
* Gets a DocTrees object for a given CompilationTask.
44
* @param task the compilation task for which to get the Trees object
45
* @throws IllegalArgumentException if the task does not support the Trees API.
46
*/
47
public static DocTrees instance(CompilationTask task) {
48
return (DocTrees) Trees.instance(task);
49
}
50
51
/**
52
* Gets a DocTrees object for a given ProcessingEnvironment.
53
* @param env the processing environment for which to get the Trees object
54
* @throws IllegalArgumentException if the env does not support the Trees API.
55
*/
56
public static DocTrees instance(ProcessingEnvironment env) {
57
if (!env.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment"))
58
throw new IllegalArgumentException();
59
return (DocTrees) getJavacTrees(ProcessingEnvironment.class, env);
60
}
61
62
/**
63
* Gets the doc comment tree, if any, for the Tree node identified by a given TreePath.
64
* Returns null if no doc comment was found.
65
*/
66
public abstract DocCommentTree getDocCommentTree(TreePath path);
67
68
/**
69
* Gets the language model element referred to by the leaf node of the given
70
* {@link DocTreePath}, or null if unknown.
71
*/
72
public abstract Element getElement(DocTreePath path);
73
74
public abstract DocSourcePositions getSourcePositions();
75
76
/**
77
* Prints a message of the specified kind at the location of the
78
* tree within the provided compilation unit
79
*
80
* @param kind the kind of message
81
* @param msg the message, or an empty string if none
82
* @param t the tree to use as a position hint
83
* @param root the compilation unit that contains tree
84
*/
85
public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg,
86
com.sun.source.doctree.DocTree t,
87
com.sun.source.doctree.DocCommentTree c,
88
com.sun.source.tree.CompilationUnitTree root);
89
}
90
91