author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 55756 | d48ffad997b1 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
55756 | 2 |
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.javac.api; |
|
27 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
28 |
import java.io.FileNotFoundException; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
29 |
import java.io.IOException; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
30 |
import java.text.BreakIterator; |
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
31 |
import java.util.HashMap; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
32 |
import java.util.HashSet; |
49197
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
33 |
import java.util.Map; |
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
34 |
import java.util.Map.Entry; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
35 |
import java.util.Set; |
49197
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
36 |
import java.util.WeakHashMap; |
12016 | 37 |
|
10 | 38 |
import javax.annotation.processing.ProcessingEnvironment; |
39 |
import javax.lang.model.element.AnnotationMirror; |
|
40 |
import javax.lang.model.element.AnnotationValue; |
|
41 |
import javax.lang.model.element.Element; |
|
17549
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
42 |
import javax.lang.model.element.ElementKind; |
10 | 43 |
import javax.lang.model.element.ExecutableElement; |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
44 |
import javax.lang.model.element.Modifier; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
45 |
import javax.lang.model.element.NestingKind; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
46 |
import javax.lang.model.element.PackageElement; |
10 | 47 |
import javax.lang.model.element.TypeElement; |
48 |
import javax.lang.model.type.DeclaredType; |
|
9599
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
49 |
import javax.lang.model.type.TypeKind; |
10 | 50 |
import javax.lang.model.type.TypeMirror; |
3149 | 51 |
import javax.tools.Diagnostic; |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
52 |
import javax.tools.FileObject; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
53 |
import javax.tools.ForwardingFileObject; |
10 | 54 |
import javax.tools.JavaCompiler; |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
55 |
import javax.tools.JavaFileManager; |
10 | 56 |
import javax.tools.JavaFileObject; |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
57 |
import javax.tools.JavaFileObject.Kind; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
58 |
import javax.tools.StandardLocation; |
10 | 59 |
|
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
60 |
import com.sun.source.doctree.DocCommentTree; |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
61 |
import com.sun.source.doctree.DocTree; |
9599
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
62 |
import com.sun.source.tree.CatchTree; |
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
63 |
import com.sun.source.tree.ClassTree; |
10 | 64 |
import com.sun.source.tree.CompilationUnitTree; |
65 |
import com.sun.source.tree.Scope; |
|
66 |
import com.sun.source.tree.Tree; |
|
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
67 |
import com.sun.source.util.DocSourcePositions; |
17549
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
68 |
import com.sun.source.util.DocTreePath; |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
69 |
import com.sun.source.util.DocTreeScanner; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
70 |
import com.sun.source.util.DocTrees; |
12016 | 71 |
import com.sun.source.util.JavacTask; |
10 | 72 |
import com.sun.source.util.TreePath; |
6590
f745e683da2c
6930507: Symbols for anonymous and local classes made too late for use by java tree API
jjg
parents:
5847
diff
changeset
|
73 |
import com.sun.tools.javac.code.Flags; |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
74 |
import com.sun.tools.javac.code.Scope.NamedImportScope; |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
75 |
import com.sun.tools.javac.code.Scope.StarImportScope; |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
76 |
import com.sun.tools.javac.code.Scope.WriteableScope; |
10 | 77 |
import com.sun.tools.javac.code.Symbol.ClassSymbol; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
78 |
import com.sun.tools.javac.code.Symbol.MethodSymbol; |
36526 | 79 |
import com.sun.tools.javac.code.Symbol.ModuleSymbol; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
80 |
import com.sun.tools.javac.code.Symbol.PackageSymbol; |
10 | 81 |
import com.sun.tools.javac.code.Symbol.TypeSymbol; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
82 |
import com.sun.tools.javac.code.Symbol.VarSymbol; |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
83 |
import com.sun.tools.javac.code.Symtab; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
84 |
import com.sun.tools.javac.code.Type; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
85 |
import com.sun.tools.javac.code.Type.ArrayType; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
86 |
import com.sun.tools.javac.code.Type.ClassType; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
87 |
import com.sun.tools.javac.code.Type.ErrorType; |
9599
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
88 |
import com.sun.tools.javac.code.Type.UnionClassType; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
89 |
import com.sun.tools.javac.code.Types; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
90 |
import com.sun.tools.javac.code.Types.TypeRelation; |
10 | 91 |
import com.sun.tools.javac.comp.Attr; |
92 |
import com.sun.tools.javac.comp.AttrContext; |
|
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
93 |
import com.sun.tools.javac.comp.Check; |
10 | 94 |
import com.sun.tools.javac.comp.Enter; |
95 |
import com.sun.tools.javac.comp.Env; |
|
96 |
import com.sun.tools.javac.comp.MemberEnter; |
|
36526 | 97 |
import com.sun.tools.javac.comp.Modules; |
10 | 98 |
import com.sun.tools.javac.comp.Resolve; |
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
99 |
import com.sun.tools.javac.code.Symbol; |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
100 |
import com.sun.tools.javac.file.BaseFileManager; |
10 | 101 |
import com.sun.tools.javac.model.JavacElements; |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
102 |
import com.sun.tools.javac.parser.DocCommentParser; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
103 |
import com.sun.tools.javac.parser.ParserFactory; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
104 |
import com.sun.tools.javac.parser.Tokens.Comment; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
105 |
import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; |
14258 | 106 |
import com.sun.tools.javac.processing.JavacProcessingEnvironment; |
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
43879
diff
changeset
|
107 |
import com.sun.tools.javac.resources.CompilerProperties.Errors; |
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
43879
diff
changeset
|
108 |
import com.sun.tools.javac.resources.CompilerProperties.Notes; |
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
43879
diff
changeset
|
109 |
import com.sun.tools.javac.resources.CompilerProperties.Warnings; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
110 |
import com.sun.tools.javac.tree.DCTree; |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
111 |
import com.sun.tools.javac.tree.DCTree.DCBlockTag; |
55756 | 112 |
import com.sun.tools.javac.tree.DCTree.DCComment; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
113 |
import com.sun.tools.javac.tree.DCTree.DCDocComment; |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
114 |
import com.sun.tools.javac.tree.DCTree.DCEndPosTree; |
55756 | 115 |
import com.sun.tools.javac.tree.DCTree.DCEntity; |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
116 |
import com.sun.tools.javac.tree.DCTree.DCErroneous; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
117 |
import com.sun.tools.javac.tree.DCTree.DCIdentifier; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
118 |
import com.sun.tools.javac.tree.DCTree.DCParam; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
119 |
import com.sun.tools.javac.tree.DCTree.DCReference; |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
120 |
import com.sun.tools.javac.tree.DCTree.DCText; |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
121 |
import com.sun.tools.javac.tree.DocCommentTable; |
33360 | 122 |
import com.sun.tools.javac.tree.DocTreeMaker; |
13077 | 123 |
import com.sun.tools.javac.tree.EndPosTable; |
12016 | 124 |
import com.sun.tools.javac.tree.JCTree; |
33360 | 125 |
import com.sun.tools.javac.tree.JCTree.JCBlock; |
126 |
import com.sun.tools.javac.tree.JCTree.JCCatch; |
|
127 |
import com.sun.tools.javac.tree.JCTree.JCClassDecl; |
|
128 |
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; |
|
129 |
import com.sun.tools.javac.tree.JCTree.JCExpression; |
|
130 |
import com.sun.tools.javac.tree.JCTree.JCIdent; |
|
131 |
import com.sun.tools.javac.tree.JCTree.JCMethodDecl; |
|
132 |
import com.sun.tools.javac.tree.JCTree.JCVariableDecl; |
|
10 | 133 |
import com.sun.tools.javac.tree.TreeCopier; |
134 |
import com.sun.tools.javac.tree.TreeInfo; |
|
135 |
import com.sun.tools.javac.tree.TreeMaker; |
|
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
136 |
import com.sun.tools.javac.tree.TreeScanner; |
14952 | 137 |
import com.sun.tools.javac.util.Abort; |
10631
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
138 |
import com.sun.tools.javac.util.Assert; |
10 | 139 |
import com.sun.tools.javac.util.Context; |
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
26264
diff
changeset
|
140 |
import com.sun.tools.javac.util.DefinedBy; |
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
26264
diff
changeset
|
141 |
import com.sun.tools.javac.util.DefinedBy.Api; |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
142 |
import com.sun.tools.javac.util.DiagnosticSource; |
3149 | 143 |
import com.sun.tools.javac.util.JCDiagnostic; |
28455
41245007c074
8066843: Messager.printMessage cannot print multiple errors for same source position
jlahoda
parents:
27224
diff
changeset
|
144 |
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; |
10 | 145 |
import com.sun.tools.javac.util.List; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
146 |
import com.sun.tools.javac.util.ListBuffer; |
10 | 147 |
import com.sun.tools.javac.util.Log; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
148 |
import com.sun.tools.javac.util.Name; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
149 |
import com.sun.tools.javac.util.Names; |
10 | 150 |
import com.sun.tools.javac.util.Pair; |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
151 |
import com.sun.tools.javac.util.Position; |
33360 | 152 |
|
27224
228abfa87080
8054457: Refactor Symbol kinds from small ints to an enum
emc
parents:
26266
diff
changeset
|
153 |
import static com.sun.tools.javac.code.Kinds.Kind.*; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
154 |
import static com.sun.tools.javac.code.TypeTag.*; |
10 | 155 |
|
156 |
/** |
|
157 |
* Provides an implementation of Trees. |
|
158 |
* |
|
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
159 |
* <p><b>This is NOT part of any supported API. |
10 | 160 |
* If you write code that depends on this, you do so at your own |
161 |
* risk. This code and its internal interfaces are subject to change |
|
162 |
* or deletion without notice.</b></p> |
|
163 |
* |
|
164 |
* @author Peter von der Ahé |
|
165 |
*/ |
|
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
166 |
public class JavacTrees extends DocTrees { |
10 | 167 |
|
6717 | 168 |
// in a world of a single context per compilation, these would all be final |
36526 | 169 |
private Modules modules; |
6717 | 170 |
private Resolve resolve; |
171 |
private Enter enter; |
|
172 |
private Log log; |
|
173 |
private MemberEnter memberEnter; |
|
174 |
private Attr attr; |
|
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
175 |
private Check chk; |
6717 | 176 |
private TreeMaker treeMaker; |
177 |
private JavacElements elements; |
|
178 |
private JavacTaskImpl javacTaskImpl; |
|
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
179 |
private Names names; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
180 |
private Types types; |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
181 |
private DocTreeMaker docTreeMaker; |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
182 |
private BreakIterator breakIterator; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
183 |
private JavaFileManager fileManager; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
184 |
private ParserFactory parser; |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
185 |
private Symtab syms; |
10 | 186 |
|
49197
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
187 |
private final Map<Type, Type> extraType2OriginalMap = new WeakHashMap<>(); |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
188 |
|
12016 | 189 |
// called reflectively from Trees.instance(CompilationTask task) |
10 | 190 |
public static JavacTrees instance(JavaCompiler.CompilationTask task) { |
14548
aa687b312c97
8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents:
14541
diff
changeset
|
191 |
if (!(task instanceof BasicJavacTask)) |
10 | 192 |
throw new IllegalArgumentException(); |
14548
aa687b312c97
8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents:
14541
diff
changeset
|
193 |
return instance(((BasicJavacTask)task).getContext()); |
10 | 194 |
} |
195 |
||
12016 | 196 |
// called reflectively from Trees.instance(ProcessingEnvironment env) |
10 | 197 |
public static JavacTrees instance(ProcessingEnvironment env) { |
198 |
if (!(env instanceof JavacProcessingEnvironment)) |
|
199 |
throw new IllegalArgumentException(); |
|
200 |
return instance(((JavacProcessingEnvironment)env).getContext()); |
|
201 |
} |
|
202 |
||
203 |
public static JavacTrees instance(Context context) { |
|
204 |
JavacTrees instance = context.get(JavacTrees.class); |
|
205 |
if (instance == null) |
|
206 |
instance = new JavacTrees(context); |
|
207 |
return instance; |
|
208 |
} |
|
209 |
||
13845
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13077
diff
changeset
|
210 |
protected JavacTrees(Context context) { |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
211 |
this.breakIterator = null; |
10 | 212 |
context.put(JavacTrees.class, this); |
6717 | 213 |
init(context); |
214 |
} |
|
215 |
||
216 |
public void updateContext(Context context) { |
|
217 |
init(context); |
|
218 |
} |
|
219 |
||
220 |
private void init(Context context) { |
|
36526 | 221 |
modules = Modules.instance(context); |
10 | 222 |
attr = Attr.instance(context); |
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
223 |
chk = Check.instance(context); |
10 | 224 |
enter = Enter.instance(context); |
225 |
elements = JavacElements.instance(context); |
|
226 |
log = Log.instance(context); |
|
227 |
resolve = Resolve.instance(context); |
|
228 |
treeMaker = TreeMaker.instance(context); |
|
229 |
memberEnter = MemberEnter.instance(context); |
|
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
230 |
names = Names.instance(context); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
231 |
types = Types.instance(context); |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
232 |
docTreeMaker = DocTreeMaker.instance(context); |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
233 |
parser = ParserFactory.instance(context); |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
234 |
syms = Symtab.instance(context); |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
235 |
fileManager = context.get(JavaFileManager.class); |
12016 | 236 |
JavacTask t = context.get(JavacTask.class); |
237 |
if (t instanceof JavacTaskImpl) |
|
238 |
javacTaskImpl = (JavacTaskImpl) t; |
|
10 | 239 |
} |
240 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
241 |
@Override @DefinedBy(Api.COMPILER_TREE) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
242 |
public BreakIterator getBreakIterator() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
243 |
return breakIterator; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
244 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
245 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
246 |
@Override @DefinedBy(Api.COMPILER_TREE) |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
247 |
public DocSourcePositions getSourcePositions() { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
248 |
return new DocSourcePositions() { |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
249 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 250 |
public long getStartPosition(CompilationUnitTree file, Tree tree) { |
251 |
return TreeInfo.getStartPos((JCTree) tree); |
|
252 |
} |
|
253 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
254 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 255 |
public long getEndPosition(CompilationUnitTree file, Tree tree) { |
11055 | 256 |
EndPosTable endPosTable = ((JCCompilationUnit) file).endPositions; |
257 |
return TreeInfo.getEndPos((JCTree) tree, endPosTable); |
|
10 | 258 |
} |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
259 |
|
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
260 |
@Override @DefinedBy(Api.COMPILER_TREE) |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
261 |
public long getStartPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree) { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
262 |
return ((DCTree) tree).getSourcePosition((DCDocComment) comment); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
263 |
} |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
264 |
@Override @DefinedBy(Api.COMPILER_TREE) @SuppressWarnings("fallthrough") |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
265 |
public long getEndPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree) { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
266 |
DCDocComment dcComment = (DCDocComment) comment; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
267 |
if (tree instanceof DCEndPosTree) { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
268 |
int endPos = ((DCEndPosTree) tree).getEndPos(dcComment); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
269 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
270 |
if (endPos != Position.NOPOS) { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
271 |
return endPos; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
272 |
} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
273 |
} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
274 |
int correction = 0; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
275 |
switch (tree.getKind()) { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
276 |
case TEXT: |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
277 |
DCText text = (DCText) tree; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
278 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
279 |
return dcComment.comment.getSourcePos(text.pos + text.text.length()); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
280 |
case ERRONEOUS: |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
281 |
DCErroneous err = (DCErroneous) tree; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
282 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
283 |
return dcComment.comment.getSourcePos(err.pos + err.body.length()); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
284 |
case IDENTIFIER: |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
285 |
DCIdentifier ident = (DCIdentifier) tree; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
286 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
287 |
return dcComment.comment.getSourcePos(ident.pos + (ident.name != names.error ? ident.name.length() : 0)); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
288 |
case PARAM: |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
289 |
DCParam param = (DCParam) tree; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
290 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
291 |
if (param.isTypeParameter && param.getDescription().isEmpty()) { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
292 |
correction = 1; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
293 |
} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
294 |
case AUTHOR: case DEPRECATED: case RETURN: case SEE: |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
295 |
case SERIAL: case SERIAL_DATA: case SERIAL_FIELD: case SINCE: |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
296 |
case THROWS: case UNKNOWN_BLOCK_TAG: case VERSION: { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
297 |
DocTree last = getLastChild(tree); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
298 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
299 |
if (last != null) { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
300 |
return getEndPosition(file, comment, last) + correction; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
301 |
} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
302 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
303 |
DCBlockTag block = (DCBlockTag) tree; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
304 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
305 |
return dcComment.comment.getSourcePos(block.pos + block.getTagName().length() + 1); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
306 |
} |
55756 | 307 |
case ENTITY: { |
308 |
DCEntity endEl = (DCEntity) tree; |
|
309 |
return dcComment.comment.getSourcePos(endEl.pos + (endEl.name != names.error ? endEl.name.length() : 0) + 2); |
|
310 |
} |
|
311 |
case COMMENT: { |
|
312 |
DCComment endEl = (DCComment) tree; |
|
313 |
return dcComment.comment.getSourcePos(endEl.pos + endEl.body.length()); |
|
314 |
} |
|
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
315 |
default: |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
316 |
DocTree last = getLastChild(tree); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
317 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
318 |
if (last != null) { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
319 |
return getEndPosition(file, comment, last); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
320 |
} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
321 |
break; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
322 |
} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
323 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
324 |
return Position.NOPOS; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
325 |
} |
10 | 326 |
}; |
327 |
} |
|
328 |
||
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
329 |
@Override @DefinedBy(Api.COMPILER_TREE) |
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
330 |
public DocTreeMaker getDocTreeFactory() { |
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
331 |
return docTreeMaker; |
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
332 |
} |
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
333 |
|
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
334 |
private DocTree getLastChild(DocTree tree) { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
335 |
final DocTree[] last = new DocTree[] {null}; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
336 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
337 |
tree.accept(new DocTreeScanner<Void, Void>() { |
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
26264
diff
changeset
|
338 |
@Override @DefinedBy(Api.COMPILER_TREE) |
33360 | 339 |
public Void scan(DocTree node, Void p) { |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
340 |
if (node != null) last[0] = node; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
341 |
return null; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
342 |
} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
343 |
}, null); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
344 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
345 |
return last[0]; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
346 |
} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
347 |
|
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
348 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 349 |
public JCClassDecl getTree(TypeElement element) { |
350 |
return (JCClassDecl) getTree((Element) element); |
|
351 |
} |
|
352 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
353 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 354 |
public JCMethodDecl getTree(ExecutableElement method) { |
355 |
return (JCMethodDecl) getTree((Element) method); |
|
356 |
} |
|
357 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
358 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 359 |
public JCTree getTree(Element element) { |
23122
02c931d49ad2
6411385: Trees.getPath does not work for constructors
jlahoda
parents:
22165
diff
changeset
|
360 |
return getTree(element, null); |
10 | 361 |
} |
362 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
363 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 364 |
public JCTree getTree(Element e, AnnotationMirror a) { |
365 |
return getTree(e, a, null); |
|
366 |
} |
|
367 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
368 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 369 |
public JCTree getTree(Element e, AnnotationMirror a, AnnotationValue v) { |
370 |
Pair<JCTree, JCCompilationUnit> treeTopLevel = elements.getTreeAndTopLevel(e, a, v); |
|
371 |
if (treeTopLevel == null) |
|
372 |
return null; |
|
373 |
return treeTopLevel.fst; |
|
374 |
} |
|
375 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
376 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 377 |
public TreePath getPath(CompilationUnitTree unit, Tree node) { |
378 |
return TreePath.getPath(unit, node); |
|
379 |
} |
|
380 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
381 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 382 |
public TreePath getPath(Element e) { |
383 |
return getPath(e, null, null); |
|
384 |
} |
|
385 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
386 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 387 |
public TreePath getPath(Element e, AnnotationMirror a) { |
388 |
return getPath(e, a, null); |
|
389 |
} |
|
390 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
391 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 392 |
public TreePath getPath(Element e, AnnotationMirror a, AnnotationValue v) { |
393 |
final Pair<JCTree, JCCompilationUnit> treeTopLevel = elements.getTreeAndTopLevel(e, a, v); |
|
394 |
if (treeTopLevel == null) |
|
395 |
return null; |
|
396 |
return TreePath.getPath(treeTopLevel.snd, treeTopLevel.fst); |
|
397 |
} |
|
398 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
399 |
@Override @DefinedBy(Api.COMPILER_TREE) |
17549
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
400 |
public Symbol getElement(TreePath path) { |
6590
f745e683da2c
6930507: Symbols for anonymous and local classes made too late for use by java tree API
jjg
parents:
5847
diff
changeset
|
401 |
JCTree tree = (JCTree) path.getLeaf(); |
f745e683da2c
6930507: Symbols for anonymous and local classes made too late for use by java tree API
jjg
parents:
5847
diff
changeset
|
402 |
Symbol sym = TreeInfo.symbolFor(tree); |
14952 | 403 |
if (sym == null) { |
41160
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
404 |
for (TreePath p = path; p != null; p = p.getParentPath()) { |
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
405 |
JCTree t = (JCTree) p.getLeaf(); |
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
406 |
if (t.hasTag(JCTree.Tag.CLASSDEF)) { |
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
407 |
JCClassDecl ct = (JCClassDecl) t; |
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
408 |
if (ct.sym != null) { |
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
409 |
if ((ct.sym.flags_field & Flags.UNATTRIBUTED) != 0) { |
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
410 |
attr.attribClass(ct.pos(), ct.sym); |
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
411 |
sym = TreeInfo.symbolFor(tree); |
6590
f745e683da2c
6930507: Symbols for anonymous and local classes made too late for use by java tree API
jjg
parents:
5847
diff
changeset
|
412 |
} |
41160
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
413 |
break; |
6590
f745e683da2c
6930507: Symbols for anonymous and local classes made too late for use by java tree API
jjg
parents:
5847
diff
changeset
|
414 |
} |
f745e683da2c
6930507: Symbols for anonymous and local classes made too late for use by java tree API
jjg
parents:
5847
diff
changeset
|
415 |
} |
f745e683da2c
6930507: Symbols for anonymous and local classes made too late for use by java tree API
jjg
parents:
5847
diff
changeset
|
416 |
} |
f745e683da2c
6930507: Symbols for anonymous and local classes made too late for use by java tree API
jjg
parents:
5847
diff
changeset
|
417 |
} |
f745e683da2c
6930507: Symbols for anonymous and local classes made too late for use by java tree API
jjg
parents:
5847
diff
changeset
|
418 |
return sym; |
10 | 419 |
} |
420 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
26264
diff
changeset
|
421 |
@Override @DefinedBy(Api.COMPILER_TREE) |
17549
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
422 |
public Element getElement(DocTreePath path) { |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
423 |
DocTree forTree = path.getLeaf(); |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
424 |
if (forTree instanceof DCReference) |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
425 |
return attributeDocReference(path.getTreePath(), ((DCReference) forTree)); |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
426 |
if (forTree instanceof DCIdentifier) { |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
427 |
if (path.getParentPath().getLeaf() instanceof DCParam) { |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
428 |
return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf()); |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
429 |
} |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
430 |
} |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
431 |
return null; |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
432 |
} |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
433 |
|
33360 | 434 |
@Override @DefinedBy(Api.COMPILER_TREE) |
435 |
public java.util.List<DocTree> getFirstSentence(java.util.List<? extends DocTree> list) { |
|
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
436 |
return docTreeMaker.getFirstSentence(list); |
33360 | 437 |
} |
438 |
||
17549
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
439 |
private Symbol attributeDocReference(TreePath path, DCReference ref) { |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
440 |
Env<AttrContext> env = getAttrContext(path); |
43760 | 441 |
if (env == null) return null; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
442 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
443 |
Log.DeferredDiagnosticHandler deferredDiagnosticHandler = |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
444 |
new Log.DeferredDiagnosticHandler(log); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
445 |
try { |
19125
db8cab0ecbd9
8020556: doclint does not check type variables for @throws
jjg
parents:
18646
diff
changeset
|
446 |
final TypeSymbol tsym; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
447 |
final Name memberName; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
448 |
if (ref.qualifierExpression == null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
449 |
tsym = env.enclClass.sym; |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
450 |
memberName = (Name) ref.memberName; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
451 |
} else { |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
452 |
// newSeeTree if the qualifierExpression is a type or package name. |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
453 |
// javac does not provide the exact method required, so |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
454 |
// we first check if qualifierExpression identifies a type, |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
455 |
// and if not, then we check to see if it identifies a package. |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
456 |
Type t = attr.attribType(ref.qualifierExpression, env); |
52871
c09bff7928e8
8214571: -Xdoclint of array serialField gives "error: array type not allowed here"
hannesw
parents:
52664
diff
changeset
|
457 |
if (t.isErroneous()) { |
36526 | 458 |
JCCompilationUnit toplevel = |
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
41160
diff
changeset
|
459 |
treeMaker.TopLevel(List.nil()); |
36526 | 460 |
final ModuleSymbol msym = modules.getDefaultModule(); |
461 |
toplevel.modle = msym; |
|
462 |
toplevel.packge = msym.unnamedPackage; |
|
463 |
Symbol sym = attr.attribIdent(ref.qualifierExpression, toplevel); |
|
464 |
||
52664
15fc92f4ae9a
8200432: javadoc fails with ClassCastException on {@link byte[]}
hannesw
parents:
50287
diff
changeset
|
465 |
if (sym == null) |
15fc92f4ae9a
8200432: javadoc fails with ClassCastException on {@link byte[]}
hannesw
parents:
50287
diff
changeset
|
466 |
return null; |
15fc92f4ae9a
8200432: javadoc fails with ClassCastException on {@link byte[]}
hannesw
parents:
50287
diff
changeset
|
467 |
|
36526 | 468 |
sym.complete(); |
469 |
||
470 |
if ((sym.kind == PCK || sym.kind == TYP) && sym.exists()) { |
|
471 |
tsym = (TypeSymbol) sym; |
|
472 |
memberName = (Name) ref.memberName; |
|
473 |
if (sym.kind == PCK && memberName != null) { |
|
474 |
//cannot refer to a package "member" |
|
475 |
return null; |
|
476 |
} |
|
477 |
} else { |
|
478 |
if (ref.qualifierExpression.hasTag(JCTree.Tag.IDENT)) { |
|
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
479 |
// fixup: allow "identifier" instead of "#identifier" |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
480 |
// for compatibility with javadoc |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
481 |
tsym = env.enclClass.sym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
482 |
memberName = ((JCIdent) ref.qualifierExpression).name; |
36526 | 483 |
} else { |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
484 |
return null; |
36526 | 485 |
} |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
486 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
487 |
} else { |
52871
c09bff7928e8
8214571: -Xdoclint of array serialField gives "error: array type not allowed here"
hannesw
parents:
52664
diff
changeset
|
488 |
Type e = t; |
c09bff7928e8
8214571: -Xdoclint of array serialField gives "error: array type not allowed here"
hannesw
parents:
52664
diff
changeset
|
489 |
// If this is an array type convert to element type |
c09bff7928e8
8214571: -Xdoclint of array serialField gives "error: array type not allowed here"
hannesw
parents:
52664
diff
changeset
|
490 |
while (e instanceof ArrayType) |
c09bff7928e8
8214571: -Xdoclint of array serialField gives "error: array type not allowed here"
hannesw
parents:
52664
diff
changeset
|
491 |
e = ((ArrayType)e).elemtype; |
c09bff7928e8
8214571: -Xdoclint of array serialField gives "error: array type not allowed here"
hannesw
parents:
52664
diff
changeset
|
492 |
tsym = e.tsym; |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
493 |
memberName = (Name) ref.memberName; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
494 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
495 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
496 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
497 |
if (memberName == null) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
498 |
return tsym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
499 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
500 |
final List<Type> paramTypes; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
501 |
if (ref.paramTypes == null) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
502 |
paramTypes = null; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
503 |
else { |
22163 | 504 |
ListBuffer<Type> lb = new ListBuffer<>(); |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
505 |
for (List<JCTree> l = (List<JCTree>) ref.paramTypes; l.nonEmpty(); l = l.tail) { |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
506 |
JCTree tree = l.head; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
507 |
Type t = attr.attribType(tree, env); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
508 |
lb.add(t); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
509 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
510 |
paramTypes = lb.toList(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
511 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
512 |
|
43879
a6dc784b18a8
8174805: JavacTrees should use Types.skipTypeVars() to get the upper bound of type variables
vromero
parents:
43760
diff
changeset
|
513 |
ClassSymbol sym = (ClassSymbol) types.skipTypeVars(tsym.type, false).tsym; |
19125
db8cab0ecbd9
8020556: doclint does not check type variables for @throws
jjg
parents:
18646
diff
changeset
|
514 |
|
db8cab0ecbd9
8020556: doclint does not check type variables for @throws
jjg
parents:
18646
diff
changeset
|
515 |
Symbol msym = (memberName == sym.name) |
db8cab0ecbd9
8020556: doclint does not check type variables for @throws
jjg
parents:
18646
diff
changeset
|
516 |
? findConstructor(sym, paramTypes) |
db8cab0ecbd9
8020556: doclint does not check type variables for @throws
jjg
parents:
18646
diff
changeset
|
517 |
: findMethod(sym, memberName, paramTypes); |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
518 |
if (paramTypes != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
519 |
// explicit (possibly empty) arg list given, so cannot be a field |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
520 |
return msym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
521 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
522 |
|
19125
db8cab0ecbd9
8020556: doclint does not check type variables for @throws
jjg
parents:
18646
diff
changeset
|
523 |
VarSymbol vsym = (ref.paramTypes != null) ? null : findField(sym, memberName); |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
524 |
// prefer a field over a method with no parameters |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
525 |
if (vsym != null && |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
526 |
(msym == null || |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
527 |
types.isSubtypeUnchecked(vsym.enclClass().asType(), msym.enclClass().asType()))) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
528 |
return vsym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
529 |
} else { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
530 |
return msym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
531 |
} |
14952 | 532 |
} catch (Abort e) { // may be thrown by Check.completionError in case of bad class file |
533 |
return null; |
|
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
534 |
} finally { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
535 |
log.popDiagnosticHandler(deferredDiagnosticHandler); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
536 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
537 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
538 |
|
17549
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
539 |
private Symbol attributeParamIdentifier(TreePath path, DCParam ptag) { |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
540 |
Symbol javadocSymbol = getElement(path); |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
541 |
if (javadocSymbol == null) |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
542 |
return null; |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
543 |
ElementKind kind = javadocSymbol.getKind(); |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
544 |
List<? extends Symbol> params = List.nil(); |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
545 |
if (kind == ElementKind.METHOD || kind == ElementKind.CONSTRUCTOR) { |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
546 |
MethodSymbol ee = (MethodSymbol) javadocSymbol; |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
547 |
params = ptag.isTypeParameter() |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
548 |
? ee.getTypeParameters() |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
549 |
: ee.getParameters(); |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
550 |
} else if (kind.isClass() || kind.isInterface()) { |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
551 |
ClassSymbol te = (ClassSymbol) javadocSymbol; |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
552 |
params = te.getTypeParameters(); |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
553 |
} |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
554 |
|
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
555 |
for (Symbol param : params) { |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
556 |
if (param.getSimpleName() == ptag.getName().getName()) { |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
557 |
return param; |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
558 |
} |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
559 |
} |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
560 |
return null; |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
561 |
} |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
562 |
|
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
563 |
/** @see com.sun.tools.javadoc.ClassDocImpl#findField */ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
564 |
private VarSymbol findField(ClassSymbol tsym, Name fieldName) { |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
565 |
return searchField(tsym, fieldName, new HashSet<>()); |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
566 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
567 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
568 |
/** @see com.sun.tools.javadoc.ClassDocImpl#searchField */ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
569 |
private VarSymbol searchField(ClassSymbol tsym, Name fieldName, Set<ClassSymbol> searched) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
570 |
if (searched.contains(tsym)) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
571 |
return null; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
572 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
573 |
searched.add(tsym); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
574 |
|
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
575 |
for (Symbol sym : tsym.members().getSymbolsByName(fieldName)) { |
27224
228abfa87080
8054457: Refactor Symbol kinds from small ints to an enum
emc
parents:
26266
diff
changeset
|
576 |
if (sym.kind == VAR) { |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
577 |
return (VarSymbol)sym; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
578 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
579 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
580 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
581 |
//### If we found a VarSymbol above, but which did not pass |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
582 |
//### the modifier filter, we should return failure here! |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
583 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
584 |
ClassSymbol encl = tsym.owner.enclClass(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
585 |
if (encl != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
586 |
VarSymbol vsym = searchField(encl, fieldName, searched); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
587 |
if (vsym != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
588 |
return vsym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
589 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
590 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
591 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
592 |
// search superclass |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
593 |
Type superclass = tsym.getSuperclass(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
594 |
if (superclass.tsym != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
595 |
VarSymbol vsym = searchField((ClassSymbol) superclass.tsym, fieldName, searched); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
596 |
if (vsym != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
597 |
return vsym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
598 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
599 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
600 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
601 |
// search interfaces |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
602 |
List<Type> intfs = tsym.getInterfaces(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
603 |
for (List<Type> l = intfs; l.nonEmpty(); l = l.tail) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
604 |
Type intf = l.head; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
605 |
if (intf.isErroneous()) continue; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
606 |
VarSymbol vsym = searchField((ClassSymbol) intf.tsym, fieldName, searched); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
607 |
if (vsym != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
608 |
return vsym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
609 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
610 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
611 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
612 |
return null; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
613 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
614 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
615 |
/** @see com.sun.tools.javadoc.ClassDocImpl#findConstructor */ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
616 |
MethodSymbol findConstructor(ClassSymbol tsym, List<Type> paramTypes) { |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
617 |
for (Symbol sym : tsym.members().getSymbolsByName(names.init)) { |
27224
228abfa87080
8054457: Refactor Symbol kinds from small ints to an enum
emc
parents:
26266
diff
changeset
|
618 |
if (sym.kind == MTH) { |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
619 |
if (hasParameterTypes((MethodSymbol) sym, paramTypes)) { |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
620 |
return (MethodSymbol) sym; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
621 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
622 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
623 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
624 |
return null; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
625 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
626 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
627 |
/** @see com.sun.tools.javadoc.ClassDocImpl#findMethod */ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
628 |
private MethodSymbol findMethod(ClassSymbol tsym, Name methodName, List<Type> paramTypes) { |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
629 |
return searchMethod(tsym, methodName, paramTypes, new HashSet<>()); |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
630 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
631 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
632 |
/** @see com.sun.tools.javadoc.ClassDocImpl#searchMethod */ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
633 |
private MethodSymbol searchMethod(ClassSymbol tsym, Name methodName, |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
634 |
List<Type> paramTypes, Set<ClassSymbol> searched) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
635 |
//### Note that this search is not necessarily what the compiler would do! |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
636 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
637 |
// do not match constructors |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
638 |
if (methodName == names.init) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
639 |
return null; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
640 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
641 |
if (searched.contains(tsym)) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
642 |
return null; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
643 |
searched.add(tsym); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
644 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
645 |
// search current class |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
646 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
647 |
//### Using modifier filter here isn't really correct, |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
648 |
//### but emulates the old behavior. Instead, we should |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
649 |
//### apply the normal rules of visibility and inheritance. |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
650 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
651 |
if (paramTypes == null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
652 |
// If no parameters specified, we are allowed to return |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
653 |
// any method with a matching name. In practice, the old |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
654 |
// code returned the first method, which is now the last! |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
655 |
// In order to provide textually identical results, we |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
656 |
// attempt to emulate the old behavior. |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
657 |
MethodSymbol lastFound = null; |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
658 |
for (Symbol sym : tsym.members().getSymbolsByName(methodName)) { |
27224
228abfa87080
8054457: Refactor Symbol kinds from small ints to an enum
emc
parents:
26266
diff
changeset
|
659 |
if (sym.kind == MTH) { |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
660 |
if (sym.name == methodName) { |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
661 |
lastFound = (MethodSymbol)sym; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
662 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
663 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
664 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
665 |
if (lastFound != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
666 |
return lastFound; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
667 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
668 |
} else { |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
669 |
for (Symbol sym : tsym.members().getSymbolsByName(methodName)) { |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
670 |
if (sym != null && |
27224
228abfa87080
8054457: Refactor Symbol kinds from small ints to an enum
emc
parents:
26266
diff
changeset
|
671 |
sym.kind == MTH) { |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
672 |
if (hasParameterTypes((MethodSymbol) sym, paramTypes)) { |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
673 |
return (MethodSymbol) sym; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
674 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
675 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
676 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
677 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
678 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
679 |
//### If we found a MethodSymbol above, but which did not pass |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
680 |
//### the modifier filter, we should return failure here! |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
681 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
682 |
// search superclass |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
683 |
Type superclass = tsym.getSuperclass(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
684 |
if (superclass.tsym != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
685 |
MethodSymbol msym = searchMethod((ClassSymbol) superclass.tsym, methodName, paramTypes, searched); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
686 |
if (msym != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
687 |
return msym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
688 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
689 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
690 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
691 |
// search interfaces |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
692 |
List<Type> intfs = tsym.getInterfaces(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
693 |
for (List<Type> l = intfs; l.nonEmpty(); l = l.tail) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
694 |
Type intf = l.head; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
695 |
if (intf.isErroneous()) continue; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
696 |
MethodSymbol msym = searchMethod((ClassSymbol) intf.tsym, methodName, paramTypes, searched); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
697 |
if (msym != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
698 |
return msym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
699 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
700 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
701 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
702 |
// search enclosing class |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
703 |
ClassSymbol encl = tsym.owner.enclClass(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
704 |
if (encl != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
705 |
MethodSymbol msym = searchMethod(encl, methodName, paramTypes, searched); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
706 |
if (msym != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
707 |
return msym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
708 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
709 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
710 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
711 |
return null; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
712 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
713 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
714 |
/** @see com.sun.tools.javadoc.ClassDocImpl */ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
715 |
private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
716 |
if (paramTypes == null) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
717 |
return true; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
718 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
719 |
if (method.params().size() != paramTypes.size()) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
720 |
return false; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
721 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
722 |
List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
723 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
724 |
return (Type.isErroneous(paramTypes)) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
725 |
? fuzzyMatch(paramTypes, methodParamTypes) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
726 |
: types.isSameTypes(paramTypes, methodParamTypes); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
727 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
728 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
729 |
boolean fuzzyMatch(List<Type> paramTypes, List<Type> methodParamTypes) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
730 |
List<Type> l1 = paramTypes; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
731 |
List<Type> l2 = methodParamTypes; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
732 |
while (l1.nonEmpty()) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
733 |
if (!fuzzyMatch(l1.head, l2.head)) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
734 |
return false; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
735 |
l1 = l1.tail; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
736 |
l2 = l2.tail; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
737 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
738 |
return true; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
739 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
740 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
741 |
boolean fuzzyMatch(Type paramType, Type methodParamType) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
742 |
Boolean b = fuzzyMatcher.visit(paramType, methodParamType); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
743 |
return (b == Boolean.TRUE); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
744 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
745 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
746 |
TypeRelation fuzzyMatcher = new TypeRelation() { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
747 |
@Override |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
748 |
public Boolean visitType(Type t, Type s) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
749 |
if (t == s) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
750 |
return true; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
751 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
752 |
if (s.isPartial()) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
753 |
return visit(s, t); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
754 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
755 |
switch (t.getTag()) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
756 |
case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT: |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
757 |
case DOUBLE: case BOOLEAN: case VOID: case BOT: case NONE: |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
17557
diff
changeset
|
758 |
return t.hasTag(s.getTag()); |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
759 |
default: |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
760 |
throw new AssertionError("fuzzyMatcher " + t.getTag()); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
761 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
762 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
763 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
764 |
@Override |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
765 |
public Boolean visitArrayType(ArrayType t, Type s) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
766 |
if (t == s) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
767 |
return true; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
768 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
769 |
if (s.isPartial()) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
770 |
return visit(s, t); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
771 |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
17557
diff
changeset
|
772 |
return s.hasTag(ARRAY) |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
773 |
&& visit(t.elemtype, types.elemtype(s)); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
774 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
775 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
776 |
@Override |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
777 |
public Boolean visitClassType(ClassType t, Type s) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
778 |
if (t == s) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
779 |
return true; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
780 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
781 |
if (s.isPartial()) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
782 |
return visit(s, t); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
783 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
784 |
return t.tsym == s.tsym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
785 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
786 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
787 |
@Override |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
788 |
public Boolean visitErrorType(ErrorType t, Type s) { |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
17557
diff
changeset
|
789 |
return s.hasTag(CLASS) |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
790 |
&& t.tsym.name == ((ClassType) s).tsym.name; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
791 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
792 |
}; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
793 |
|
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
794 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 795 |
public TypeMirror getTypeMirror(TreePath path) { |
796 |
Tree t = path.getLeaf(); |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
28455
diff
changeset
|
797 |
Type ty = ((JCTree)t).type; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
28455
diff
changeset
|
798 |
return ty == null ? null : ty.stripMetadataIfNeeded(); |
10 | 799 |
} |
800 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
801 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 802 |
public JavacScope getScope(TreePath path) { |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
803 |
return JavacScope.create(getAttrContext(path)); |
10 | 804 |
} |
805 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
806 |
@Override @DefinedBy(Api.COMPILER_TREE) |
7631 | 807 |
public String getDocComment(TreePath path) { |
808 |
CompilationUnitTree t = path.getCompilationUnit(); |
|
13077 | 809 |
Tree leaf = path.getLeaf(); |
810 |
if (t instanceof JCTree.JCCompilationUnit && leaf instanceof JCTree) { |
|
7631 | 811 |
JCCompilationUnit cu = (JCCompilationUnit) t; |
812 |
if (cu.docComments != null) { |
|
13077 | 813 |
return cu.docComments.getCommentText((JCTree) leaf); |
7631 | 814 |
} |
815 |
} |
|
816 |
return null; |
|
817 |
} |
|
818 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
819 |
@Override @DefinedBy(Api.COMPILER_TREE) |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
820 |
public DocCommentTree getDocCommentTree(TreePath path) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
821 |
CompilationUnitTree t = path.getCompilationUnit(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
822 |
Tree leaf = path.getLeaf(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
823 |
if (t instanceof JCTree.JCCompilationUnit && leaf instanceof JCTree) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
824 |
JCCompilationUnit cu = (JCCompilationUnit) t; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
825 |
if (cu.docComments != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
826 |
return cu.docComments.getCommentTree((JCTree) leaf); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
827 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
828 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
829 |
return null; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
830 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
831 |
|
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
832 |
@Override @DefinedBy(Api.COMPILER_TREE) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
833 |
public DocCommentTree getDocCommentTree(Element e) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
834 |
TreePath path = getPath(e); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
835 |
if (path == null) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
836 |
return null; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
837 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
838 |
return getDocCommentTree(path); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
839 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
840 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
841 |
@Override @DefinedBy(Api.COMPILER_TREE) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
842 |
public DocCommentTree getDocCommentTree(Element e, String relativeFileName) throws IOException { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
843 |
PackageElement pkg = elements.getPackageOf(e); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
844 |
FileObject fileForInput = fileManager.getFileForInput(StandardLocation.SOURCE_PATH, |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
845 |
pkg.getQualifiedName().toString(), relativeFileName); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
846 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
847 |
if (fileForInput == null) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
848 |
throw new FileNotFoundException(relativeFileName); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
849 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
850 |
return getDocCommentTree(fileForInput); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
851 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
852 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
853 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 854 |
public boolean isAccessible(Scope scope, TypeElement type) { |
855 |
if (scope instanceof JavacScope && type instanceof ClassSymbol) { |
|
856 |
Env<AttrContext> env = ((JavacScope) scope).env; |
|
7209
889e80aa1d2e
6598108: com.sun.source.util.Trees.isAccessible incorrect
mcimadamore
parents:
7077
diff
changeset
|
857 |
return resolve.isAccessible(env, (ClassSymbol)type, true); |
10 | 858 |
} else |
859 |
return false; |
|
860 |
} |
|
861 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
862 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 863 |
public boolean isAccessible(Scope scope, Element member, DeclaredType type) { |
864 |
if (scope instanceof JavacScope |
|
865 |
&& member instanceof Symbol |
|
866 |
&& type instanceof com.sun.tools.javac.code.Type) { |
|
867 |
Env<AttrContext> env = ((JavacScope) scope).env; |
|
7209
889e80aa1d2e
6598108: com.sun.source.util.Trees.isAccessible incorrect
mcimadamore
parents:
7077
diff
changeset
|
868 |
return resolve.isAccessible(env, (com.sun.tools.javac.code.Type)type, (Symbol)member, true); |
10 | 869 |
} else |
870 |
return false; |
|
871 |
} |
|
872 |
||
873 |
private Env<AttrContext> getAttrContext(TreePath path) { |
|
874 |
if (!(path.getLeaf() instanceof JCTree)) // implicit null-check |
|
875 |
throw new IllegalArgumentException(); |
|
876 |
||
10631
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
877 |
// if we're being invoked from a Tree API client via parse/enter/analyze, |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
878 |
// we need to make sure all the classes have been entered; |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
879 |
// if we're being invoked from JSR 199 or JSR 269, then the classes |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
880 |
// will already have been entered. |
10 | 881 |
if (javacTaskImpl != null) { |
26264
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
25874
diff
changeset
|
882 |
javacTaskImpl.enter(null); |
10 | 883 |
} |
884 |
||
885 |
JCCompilationUnit unit = (JCCompilationUnit) path.getCompilationUnit(); |
|
13845
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13077
diff
changeset
|
886 |
Copier copier = createCopier(treeMaker.forToplevel(unit)); |
10 | 887 |
|
888 |
Env<AttrContext> env = null; |
|
889 |
JCMethodDecl method = null; |
|
890 |
JCVariableDecl field = null; |
|
891 |
||
892 |
List<Tree> l = List.nil(); |
|
893 |
TreePath p = path; |
|
894 |
while (p != null) { |
|
895 |
l = l.prepend(p.getLeaf()); |
|
896 |
p = p.getParentPath(); |
|
897 |
} |
|
898 |
||
899 |
for ( ; l.nonEmpty(); l = l.tail) { |
|
900 |
Tree tree = l.head; |
|
901 |
switch (tree.getKind()) { |
|
902 |
case COMPILATION_UNIT: |
|
903 |
// System.err.println("COMP: " + ((JCCompilationUnit)tree).sourcefile); |
|
904 |
env = enter.getTopLevelEnv((JCCompilationUnit)tree); |
|
905 |
break; |
|
7077
55689b828dc5
6993304: JavacTrees.getAttrContext not updated to Tree.Kind.{ANNOTATION_TYPE,ENUM,INTERFACE}
jjg
parents:
6717
diff
changeset
|
906 |
case ANNOTATION_TYPE: |
10 | 907 |
case CLASS: |
7077
55689b828dc5
6993304: JavacTrees.getAttrContext not updated to Tree.Kind.{ANNOTATION_TYPE,ENUM,INTERFACE}
jjg
parents:
6717
diff
changeset
|
908 |
case ENUM: |
6600 | 909 |
case INTERFACE: |
10 | 910 |
// System.err.println("CLASS: " + ((JCClassDecl)tree).sym.getSimpleName()); |
911 |
env = enter.getClassEnv(((JCClassDecl)tree).sym); |
|
43760 | 912 |
if (env == null) return null; |
10 | 913 |
break; |
914 |
case METHOD: |
|
915 |
// System.err.println("METHOD: " + ((JCMethodDecl)tree).sym.getSimpleName()); |
|
916 |
method = (JCMethodDecl)tree; |
|
19125
db8cab0ecbd9
8020556: doclint does not check type variables for @throws
jjg
parents:
18646
diff
changeset
|
917 |
env = memberEnter.getMethodEnv(method, env); |
10 | 918 |
break; |
919 |
case VARIABLE: |
|
920 |
// System.err.println("FIELD: " + ((JCVariableDecl)tree).sym.getSimpleName()); |
|
921 |
field = (JCVariableDecl)tree; |
|
922 |
break; |
|
923 |
case BLOCK: { |
|
924 |
// System.err.println("BLOCK: "); |
|
10631
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
925 |
if (method != null) { |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
926 |
try { |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
927 |
Assert.check(method.body == tree); |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
928 |
method.body = copier.copy((JCBlock)tree, (JCTree) path.getLeaf()); |
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
929 |
env = attribStatToTree(method.body, env, copier.leafCopy, copier.copiedClasses); |
10631
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
930 |
} finally { |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
931 |
method.body = (JCBlock) tree; |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
932 |
} |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
933 |
} else { |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
934 |
JCBlock body = copier.copy((JCBlock)tree, (JCTree) path.getLeaf()); |
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
935 |
env = attribStatToTree(body, env, copier.leafCopy, copier.copiedClasses); |
10631
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
936 |
} |
10 | 937 |
return env; |
938 |
} |
|
939 |
default: |
|
940 |
// System.err.println("DEFAULT: " + tree.getKind()); |
|
941 |
if (field != null && field.getInitializer() == tree) { |
|
942 |
env = memberEnter.getInitEnv(field, env); |
|
943 |
JCExpression expr = copier.copy((JCExpression)tree, (JCTree) path.getLeaf()); |
|
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
944 |
env = attribExprToTree(expr, env, copier.leafCopy, copier.copiedClasses); |
10 | 945 |
return env; |
946 |
} |
|
947 |
} |
|
948 |
} |
|
10631
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
949 |
return (field != null) ? memberEnter.getInitEnv(field, env) : env; |
10 | 950 |
} |
951 |
||
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
952 |
private Env<AttrContext> attribStatToTree(JCTree stat, Env<AttrContext>env, |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
953 |
JCTree tree, Map<JCClassDecl, JCClassDecl> copiedClasses) { |
10 | 954 |
JavaFileObject prev = log.useSource(env.toplevel.sourcefile); |
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
955 |
Log.DiagnosticHandler diagHandler = new Log.DiscardDiagnosticHandler(log); |
10 | 956 |
try { |
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
957 |
Env<AttrContext> result = attr.attribStatToTree(stat, env, tree); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
958 |
|
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
959 |
enter.unenter(env.toplevel, stat); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
960 |
fixLocalClassNames(copiedClasses, env); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
961 |
return result; |
10 | 962 |
} finally { |
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
963 |
log.popDiagnosticHandler(diagHandler); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
964 |
log.useSource(prev); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
965 |
} |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
966 |
} |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
967 |
|
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
968 |
private Env<AttrContext> attribExprToTree(JCExpression expr, Env<AttrContext>env, |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
969 |
JCTree tree, Map<JCClassDecl, JCClassDecl> copiedClasses) { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
970 |
JavaFileObject prev = log.useSource(env.toplevel.sourcefile); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
971 |
Log.DiagnosticHandler diagHandler = new Log.DiscardDiagnosticHandler(log); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
972 |
try { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
973 |
Env<AttrContext> result = attr.attribExprToTree(expr, env, tree); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
974 |
|
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
975 |
enter.unenter(env.toplevel, expr); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
976 |
fixLocalClassNames(copiedClasses, env); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
977 |
return result; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
978 |
} finally { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
979 |
log.popDiagnosticHandler(diagHandler); |
10 | 980 |
log.useSource(prev); |
981 |
} |
|
982 |
} |
|
983 |
||
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
984 |
/* Change the flatnames of the local and anonymous classes in the Scope to |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
985 |
* the names they would have if the whole file was attributed normally. |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
986 |
*/ |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
987 |
private void fixLocalClassNames(Map<JCClassDecl, JCClassDecl> copiedClasses, |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
988 |
Env<AttrContext> lastEnv) { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
989 |
Map<JCClassDecl, Name> flatnameForClass = null; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
990 |
|
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
991 |
for (Entry<JCClassDecl, JCClassDecl> e : copiedClasses.entrySet()) { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
992 |
if (e.getKey().sym != null) { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
993 |
Name origName; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
994 |
if (e.getValue().sym != null) { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
995 |
//if the source tree was already attributed, use the flatname |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
996 |
//from the source tree's Symbol: |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
997 |
origName = e.getValue().sym.flatname; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
998 |
} else { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
999 |
//otherwise, compute the flatnames (for source trees) as |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1000 |
//if the full source code would be attributed: |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1001 |
if (flatnameForClass == null) { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1002 |
flatnameForClass = prepareFlatnameForClass(lastEnv); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1003 |
} |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1004 |
origName = flatnameForClass.get(e.getValue()); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1005 |
} |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1006 |
if (origName != null) { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1007 |
e.getKey().sym.flatname = origName; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1008 |
} |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1009 |
} |
10 | 1010 |
} |
1011 |
} |
|
1012 |
||
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1013 |
/* This method computes and assigns flatnames to trees, as if they would be |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1014 |
* normally assigned during attribution of the full source code. |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1015 |
*/ |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1016 |
private Map<JCTree.JCClassDecl, Name> prepareFlatnameForClass(Env<AttrContext> env) { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1017 |
Map<JCClassDecl, Name> flatNameForClass = new HashMap<>(); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1018 |
Symbol enclClass = env.enclClass.sym; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1019 |
|
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1020 |
if (enclClass != null && (enclClass.flags_field & Flags.UNATTRIBUTED) != 0) { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1021 |
ListBuffer<ClassSymbol> toClear = new ListBuffer<>(); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1022 |
new TreeScanner() { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1023 |
Symbol owner; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1024 |
boolean localContext; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1025 |
@Override |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1026 |
public void visitClassDef(JCClassDecl tree) { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1027 |
//compute the name (and ClassSymbol) which would be used |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1028 |
//for this class for full attribution |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1029 |
Symbol prevOwner = owner; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1030 |
try { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1031 |
ClassSymbol c; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1032 |
if (tree.sym != null) { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1033 |
//already entered: |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1034 |
c = tree.sym; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1035 |
} else { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1036 |
c = syms.defineClass(tree.name, owner); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1037 |
if (owner.kind != TYP) { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1038 |
//for local classes, assign the flatname |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1039 |
c.flatname = chk.localClassName(c); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1040 |
chk.putCompiled(c); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1041 |
toClear.add(c); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1042 |
} |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1043 |
flatNameForClass.put(tree, c.flatname); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1044 |
} |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1045 |
owner = c; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1046 |
super.visitClassDef(tree); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1047 |
} finally { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1048 |
owner = prevOwner; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1049 |
} |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1050 |
} |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1051 |
|
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1052 |
@Override |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1053 |
public void visitBlock(JCBlock tree) { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1054 |
Symbol prevOwner = owner; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1055 |
try { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1056 |
owner = new MethodSymbol(0, names.empty, Type.noType, owner); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1057 |
super.visitBlock(tree); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1058 |
} finally { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1059 |
owner = prevOwner; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1060 |
} |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1061 |
} |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1062 |
@Override |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1063 |
public void visitVarDef(JCVariableDecl tree) { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1064 |
Symbol prevOwner = owner; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1065 |
try { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1066 |
owner = new MethodSymbol(0, names.empty, Type.noType, owner); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1067 |
super.visitVarDef(tree); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1068 |
} finally { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1069 |
owner = prevOwner; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1070 |
} |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1071 |
} |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1072 |
}.scan(env.enclClass); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1073 |
//revert changes done by the visitor: |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1074 |
toClear.stream().forEach(c -> { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1075 |
chk.clearLocalClassNameIndexes(c); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1076 |
chk.removeCompiled(c); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1077 |
}); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1078 |
} |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1079 |
|
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1080 |
return flatNameForClass; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1081 |
} |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1082 |
|
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
1083 |
static JavaFileObject asJavaFileObject(FileObject fileObject) { |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1084 |
JavaFileObject jfo = null; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1085 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1086 |
if (fileObject instanceof JavaFileObject) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1087 |
jfo = (JavaFileObject) fileObject; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1088 |
checkHtmlKind(fileObject, Kind.HTML); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1089 |
return jfo; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1090 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1091 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1092 |
checkHtmlKind(fileObject); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1093 |
jfo = new HtmlFileObject(fileObject); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1094 |
return jfo; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1095 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1096 |
|
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
1097 |
private static void checkHtmlKind(FileObject fileObject) { |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1098 |
checkHtmlKind(fileObject, BaseFileManager.getKind(fileObject.getName())); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1099 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1100 |
|
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
1101 |
private static void checkHtmlKind(FileObject fileObject, JavaFileObject.Kind kind) { |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1102 |
if (kind != JavaFileObject.Kind.HTML) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1103 |
throw new IllegalArgumentException("HTML file expected:" + fileObject.getName()); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1104 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1105 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1106 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1107 |
private static class HtmlFileObject extends ForwardingFileObject<FileObject> |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1108 |
implements JavaFileObject { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1109 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1110 |
public HtmlFileObject(FileObject fileObject) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1111 |
super(fileObject); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1112 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1113 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1114 |
@Override @DefinedBy(Api.COMPILER) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1115 |
public Kind getKind() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1116 |
return BaseFileManager.getKind(fileObject.getName()); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1117 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1118 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1119 |
@Override @DefinedBy(Api.COMPILER) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1120 |
public boolean isNameCompatible(String simpleName, Kind kind) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1121 |
return false; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1122 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1123 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1124 |
@Override @DefinedBy(Api.COMPILER) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1125 |
public NestingKind getNestingKind() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1126 |
return null; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1127 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1128 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1129 |
@Override @DefinedBy(Api.COMPILER) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1130 |
public Modifier getAccessLevel() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1131 |
return null; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1132 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1133 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1134 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1135 |
@Override @DefinedBy(Api.COMPILER_TREE) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1136 |
public DocCommentTree getDocCommentTree(FileObject fileObject) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1137 |
JavaFileObject jfo = asJavaFileObject(fileObject); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1138 |
DiagnosticSource diagSource = new DiagnosticSource(jfo, log); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1139 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1140 |
final Comment comment = new Comment() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1141 |
int offset = 0; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1142 |
@Override |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1143 |
public String getText() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1144 |
try { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1145 |
CharSequence rawDoc = fileObject.getCharContent(true); |
48028
9e022f580a9d
8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents:
47216
diff
changeset
|
1146 |
return rawDoc.toString(); |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1147 |
} catch (IOException ignore) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1148 |
// do nothing |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1149 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1150 |
return ""; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1151 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1152 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1153 |
@Override |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1154 |
public int getSourcePos(int index) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1155 |
return offset + index; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1156 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1157 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1158 |
@Override |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1159 |
public CommentStyle getStyle() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1160 |
throw new UnsupportedOperationException(); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1161 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1162 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1163 |
@Override |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1164 |
public boolean isDeprecated() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1165 |
throw new UnsupportedOperationException(); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1166 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1167 |
}; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1168 |
|
48028
9e022f580a9d
8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents:
47216
diff
changeset
|
1169 |
return new DocCommentParser(parser, diagSource, comment, true).parse(); |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1170 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1171 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1172 |
@Override @DefinedBy(Api.COMPILER_TREE) |
43265
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
42828
diff
changeset
|
1173 |
public DocTreePath getDocTreePath(FileObject fileObject, PackageElement packageElement) { |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
1174 |
JavaFileObject jfo = asJavaFileObject(fileObject); |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1175 |
DocCommentTree docCommentTree = getDocCommentTree(jfo); |
48028
9e022f580a9d
8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents:
47216
diff
changeset
|
1176 |
if (docCommentTree == null) |
9e022f580a9d
8190552: Augment the Compiler API tree with APIs to represent HTML content
ksrini
parents:
47216
diff
changeset
|
1177 |
return null; |
43265
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
42828
diff
changeset
|
1178 |
TreePath treePath = makeTreePath((PackageSymbol)packageElement, jfo, docCommentTree); |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
42828
diff
changeset
|
1179 |
return new DocTreePath(treePath, docCommentTree); |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
1180 |
} |
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
1181 |
|
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
1182 |
@Override @DefinedBy(Api.COMPILER_TREE) |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1183 |
public void setBreakIterator(BreakIterator breakiterator) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1184 |
this.breakIterator = breakiterator; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1185 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1186 |
|
10 | 1187 |
/** |
1188 |
* Makes a copy of a tree, noting the value resulting from copying a particular leaf. |
|
1189 |
**/ |
|
13845
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13077
diff
changeset
|
1190 |
protected static class Copier extends TreeCopier<JCTree> { |
10 | 1191 |
JCTree leafCopy = null; |
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1192 |
private Map<JCClassDecl, JCClassDecl> copiedClasses = new HashMap<>(); |
10 | 1193 |
|
13845
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13077
diff
changeset
|
1194 |
protected Copier(TreeMaker M) { |
10 | 1195 |
super(M); |
1196 |
} |
|
1197 |
||
6717 | 1198 |
@Override |
10 | 1199 |
public <T extends JCTree> T copy(T t, JCTree leaf) { |
1200 |
T t2 = super.copy(t, leaf); |
|
1201 |
if (t == leaf) |
|
1202 |
leafCopy = t2; |
|
1203 |
return t2; |
|
1204 |
} |
|
55622
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1205 |
|
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1206 |
@Override |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1207 |
public JCTree visitClass(ClassTree node, JCTree p) { |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1208 |
JCTree nue = super.visitClass(node, p); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1209 |
copiedClasses.put((JCClassDecl) nue, (JCClassDecl) node); |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1210 |
return nue; |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1211 |
} |
0b470386f5f7
8223443: Calling Trees.getScope early changes names of local/anonymous classes
jlahoda
parents:
53773
diff
changeset
|
1212 |
|
10 | 1213 |
} |
1257
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
10
diff
changeset
|
1214 |
|
13845
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13077
diff
changeset
|
1215 |
protected Copier createCopier(TreeMaker maker) { |
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13077
diff
changeset
|
1216 |
return new Copier(maker); |
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13077
diff
changeset
|
1217 |
} |
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13077
diff
changeset
|
1218 |
|
1257
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
10
diff
changeset
|
1219 |
/** |
25287 | 1220 |
* Returns the original type from the ErrorType object. |
1257
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
10
diff
changeset
|
1221 |
* @param errorType The errorType for which we want to get the original type. |
31751 | 1222 |
* @return TypeMirror corresponding to the original type, replaced by the ErrorType. |
1223 |
* noType (type.tag == NONE) is returned if there is no original type. |
|
1257
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
10
diff
changeset
|
1224 |
*/ |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1225 |
@Override @DefinedBy(Api.COMPILER_TREE) |
1257
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
10
diff
changeset
|
1226 |
public TypeMirror getOriginalType(javax.lang.model.type.ErrorType errorType) { |
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
10
diff
changeset
|
1227 |
if (errorType instanceof com.sun.tools.javac.code.Type.ErrorType) { |
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
10
diff
changeset
|
1228 |
return ((com.sun.tools.javac.code.Type.ErrorType)errorType).getOriginalType(); |
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
10
diff
changeset
|
1229 |
} |
49197
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
1230 |
if (errorType instanceof com.sun.tools.javac.code.Type.ClassType && |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
1231 |
errorType.getKind() == TypeKind.ERROR) { |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
1232 |
ClassType ct = (ClassType) errorType; |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
1233 |
return extraType2OriginalMap.computeIfAbsent(ct, tt -> |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
1234 |
new ClassType(ct.getEnclosingType(), ct.typarams_field, |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
1235 |
ct.tsym, ct.getMetadata()) { |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
1236 |
@Override |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
1237 |
public Type baseType() { return ct; } |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
1238 |
@Override |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
1239 |
public TypeKind getKind() { |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
1240 |
return TypeKind.DECLARED; |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
1241 |
} |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
1242 |
}); |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48028
diff
changeset
|
1243 |
} |
1257
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
10
diff
changeset
|
1244 |
|
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
10
diff
changeset
|
1245 |
return com.sun.tools.javac.code.Type.noType; |
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
10
diff
changeset
|
1246 |
} |
3149 | 1247 |
|
1248 |
/** |
|
1249 |
* Prints a message of the specified kind at the location of the |
|
1250 |
* tree within the provided compilation unit |
|
1251 |
* |
|
1252 |
* @param kind the kind of message |
|
1253 |
* @param msg the message, or an empty string if none |
|
1254 |
* @param t the tree to use as a position hint |
|
1255 |
* @param root the compilation unit that contains tree |
|
1256 |
*/ |
|
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1257 |
@Override @DefinedBy(Api.COMPILER_TREE) |
3149 | 1258 |
public void printMessage(Diagnostic.Kind kind, CharSequence msg, |
1259 |
com.sun.source.tree.Tree t, |
|
1260 |
com.sun.source.tree.CompilationUnitTree root) { |
|
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1261 |
printMessage(kind, msg, ((JCTree) t).pos(), root); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1262 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1263 |
|
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1264 |
@Override @DefinedBy(Api.COMPILER_TREE) |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1265 |
public void printMessage(Diagnostic.Kind kind, CharSequence msg, |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1266 |
com.sun.source.doctree.DocTree t, |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1267 |
com.sun.source.doctree.DocCommentTree c, |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1268 |
com.sun.source.tree.CompilationUnitTree root) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1269 |
printMessage(kind, msg, ((DCTree) t).pos((DCDocComment) c), root); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1270 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1271 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1272 |
private void printMessage(Diagnostic.Kind kind, CharSequence msg, |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1273 |
JCDiagnostic.DiagnosticPosition pos, |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1274 |
com.sun.source.tree.CompilationUnitTree root) { |
3149 | 1275 |
JavaFileObject oldSource = null; |
1276 |
JavaFileObject newSource = null; |
|
1277 |
||
1278 |
newSource = root.getSourceFile(); |
|
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1279 |
if (newSource == null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1280 |
pos = null; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1281 |
} else { |
3149 | 1282 |
oldSource = log.useSource(newSource); |
1283 |
} |
|
1284 |
||
1285 |
try { |
|
1286 |
switch (kind) { |
|
1287 |
case ERROR: |
|
53773
454d54d8af1c
8217381: Incovenient errors reported when annotation processor generates source file and errors in the same round
jlahoda
parents:
52871
diff
changeset
|
1288 |
log.error(DiagnosticFlag.API, pos, Errors.ProcMessager(msg.toString())); |
3149 | 1289 |
break; |
1290 |
||
1291 |
case WARNING: |
|
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
43879
diff
changeset
|
1292 |
log.warning(pos, Warnings.ProcMessager(msg.toString())); |
3149 | 1293 |
break; |
1294 |
||
1295 |
case MANDATORY_WARNING: |
|
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
43879
diff
changeset
|
1296 |
log.mandatoryWarning(pos, Warnings.ProcMessager(msg.toString())); |
3149 | 1297 |
break; |
1298 |
||
1299 |
default: |
|
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
43879
diff
changeset
|
1300 |
log.note(pos, Notes.ProcMessager(msg.toString())); |
3149 | 1301 |
} |
1302 |
} finally { |
|
1303 |
if (oldSource != null) |
|
1304 |
log.useSource(oldSource); |
|
1305 |
} |
|
1306 |
} |
|
9599
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
1307 |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
26264
diff
changeset
|
1308 |
@Override @DefinedBy(Api.COMPILER_TREE) |
9599
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
1309 |
public TypeMirror getLub(CatchTree tree) { |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
1310 |
JCCatch ct = (JCCatch) tree; |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
1311 |
JCVariableDecl v = ct.param; |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
1312 |
if (v.type != null && v.type.getKind() == TypeKind.UNION) { |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
1313 |
UnionClassType ut = (UnionClassType) v.type; |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
1314 |
return ut.getLub(); |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
1315 |
} else { |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
1316 |
return v.type; |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
1317 |
} |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
1318 |
} |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1319 |
|
43265
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
42828
diff
changeset
|
1320 |
private TreePath makeTreePath(final PackageSymbol psym, final JavaFileObject jfo, |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
42828
diff
changeset
|
1321 |
DocCommentTree dcTree) { |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1322 |
JCCompilationUnit jcCompilationUnit = new JCCompilationUnit(List.nil()) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1323 |
public int getPos() { |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
1324 |
return Position.FIRSTPOS; |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1325 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1326 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1327 |
public JavaFileObject getSourcefile() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1328 |
return jfo; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1329 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1330 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1331 |
@Override @DefinedBy(Api.COMPILER_TREE) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1332 |
public Position.LineMap getLineMap() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1333 |
try { |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
1334 |
CharSequence content = jfo.getCharContent(true); |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1335 |
String s = content.toString(); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1336 |
return Position.makeLineMap(s.toCharArray(), s.length(), true); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1337 |
} catch (IOException ignore) {} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1338 |
return null; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1339 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1340 |
}; |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1341 |
|
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1342 |
jcCompilationUnit.docComments = new DocCommentTable() { |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1343 |
@Override |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1344 |
public boolean hasComment(JCTree tree) { |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1345 |
return false; |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1346 |
} |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1347 |
|
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1348 |
@Override |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1349 |
public Comment getComment(JCTree tree) { |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1350 |
throw new UnsupportedOperationException(); |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1351 |
} |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1352 |
|
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1353 |
@Override |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1354 |
public String getCommentText(JCTree tree) { |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1355 |
throw new UnsupportedOperationException(); |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1356 |
} |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1357 |
|
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1358 |
@Override |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1359 |
public DCDocComment getCommentTree(JCTree tree) { |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1360 |
return (DCDocComment)dcTree; |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1361 |
} |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1362 |
|
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1363 |
@Override |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1364 |
public void putComment(JCTree tree, Comment c) { |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1365 |
throw new UnsupportedOperationException(); |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1366 |
} |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1367 |
|
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1368 |
}; |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1369 |
jcCompilationUnit.lineMap = jcCompilationUnit.getLineMap(); |
36526 | 1370 |
jcCompilationUnit.modle = psym.modle; |
1371 |
jcCompilationUnit.sourcefile = jfo; |
|
50287
64c880300d9b
8193717: Import resolution performance regression in JDK 9
jlahoda
parents:
49197
diff
changeset
|
1372 |
jcCompilationUnit.namedImportScope = new NamedImportScope(psym); |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1373 |
jcCompilationUnit.packge = psym; |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1374 |
jcCompilationUnit.starImportScope = new StarImportScope(psym); |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1375 |
jcCompilationUnit.toplevelScope = WriteableScope.create(psym); |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1376 |
return new TreePath(jcCompilationUnit); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1377 |
} |
10 | 1378 |
} |