author | jlahoda |
Fri, 23 Sep 2016 15:35:32 +0200 | |
changeset 41160 | 61082a97bbf0 |
parent 36526 | 3b41f1c69604 |
child 42828 | cce89649f958 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
2 |
* Copyright (c) 2005, 2016, 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; |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
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; |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
33 |
import java.util.Map; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
34 |
import java.util.Set; |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
35 |
import java.util.regex.Matcher; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
36 |
import java.util.regex.Pattern; |
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; |
10 | 63 |
import com.sun.source.tree.CompilationUnitTree; |
64 |
import com.sun.source.tree.Scope; |
|
65 |
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
|
66 |
import com.sun.source.util.DocSourcePositions; |
17549
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
67 |
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
|
68 |
import com.sun.source.util.DocTreeScanner; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
69 |
import com.sun.source.util.DocTrees; |
12016 | 70 |
import com.sun.source.util.JavacTask; |
10 | 71 |
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
|
72 |
import com.sun.tools.javac.code.Flags; |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
73 |
import com.sun.tools.javac.code.Scope.NamedImportScope; |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
74 |
import com.sun.tools.javac.code.Scope.StarImportScope; |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
75 |
import com.sun.tools.javac.code.Scope.WriteableScope; |
12016 | 76 |
import com.sun.tools.javac.code.Symbol; |
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; |
|
93 |
import com.sun.tools.javac.comp.Enter; |
|
94 |
import com.sun.tools.javac.comp.Env; |
|
95 |
import com.sun.tools.javac.comp.MemberEnter; |
|
36526 | 96 |
import com.sun.tools.javac.comp.Modules; |
10 | 97 |
import com.sun.tools.javac.comp.Resolve; |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
98 |
import com.sun.tools.javac.file.BaseFileManager; |
10 | 99 |
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
|
100 |
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
|
101 |
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
|
102 |
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
|
103 |
import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; |
14258 | 104 |
import com.sun.tools.javac.processing.JavacProcessingEnvironment; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
105 |
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
|
106 |
import com.sun.tools.javac.tree.DCTree.DCBlockTag; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
107 |
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
|
108 |
import com.sun.tools.javac.tree.DCTree.DCEndPosTree; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
109 |
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
|
110 |
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
|
111 |
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
|
112 |
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
|
113 |
import com.sun.tools.javac.tree.DCTree.DCText; |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
114 |
import com.sun.tools.javac.tree.DocCommentTable; |
33360 | 115 |
import com.sun.tools.javac.tree.DocTreeMaker; |
13077 | 116 |
import com.sun.tools.javac.tree.EndPosTable; |
12016 | 117 |
import com.sun.tools.javac.tree.JCTree; |
33360 | 118 |
import com.sun.tools.javac.tree.JCTree.JCBlock; |
119 |
import com.sun.tools.javac.tree.JCTree.JCCatch; |
|
120 |
import com.sun.tools.javac.tree.JCTree.JCClassDecl; |
|
121 |
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; |
|
122 |
import com.sun.tools.javac.tree.JCTree.JCExpression; |
|
123 |
import com.sun.tools.javac.tree.JCTree.JCIdent; |
|
124 |
import com.sun.tools.javac.tree.JCTree.JCMethodDecl; |
|
125 |
import com.sun.tools.javac.tree.JCTree.JCVariableDecl; |
|
10 | 126 |
import com.sun.tools.javac.tree.TreeCopier; |
127 |
import com.sun.tools.javac.tree.TreeInfo; |
|
128 |
import com.sun.tools.javac.tree.TreeMaker; |
|
14952 | 129 |
import com.sun.tools.javac.util.Abort; |
10631
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
130 |
import com.sun.tools.javac.util.Assert; |
10 | 131 |
import com.sun.tools.javac.util.Context; |
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
26264
diff
changeset
|
132 |
import com.sun.tools.javac.util.DefinedBy; |
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
26264
diff
changeset
|
133 |
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
|
134 |
import com.sun.tools.javac.util.DiagnosticSource; |
3149 | 135 |
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
|
136 |
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; |
10 | 137 |
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
|
138 |
import com.sun.tools.javac.util.ListBuffer; |
10 | 139 |
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
|
140 |
import com.sun.tools.javac.util.Name; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
141 |
import com.sun.tools.javac.util.Names; |
10 | 142 |
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
|
143 |
import com.sun.tools.javac.util.Position; |
33360 | 144 |
|
27224
228abfa87080
8054457: Refactor Symbol kinds from small ints to an enum
emc
parents:
26266
diff
changeset
|
145 |
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
|
146 |
import static com.sun.tools.javac.code.TypeTag.*; |
10 | 147 |
|
148 |
/** |
|
149 |
* Provides an implementation of Trees. |
|
150 |
* |
|
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
151 |
* <p><b>This is NOT part of any supported API. |
10 | 152 |
* If you write code that depends on this, you do so at your own |
153 |
* risk. This code and its internal interfaces are subject to change |
|
154 |
* or deletion without notice.</b></p> |
|
155 |
* |
|
156 |
* @author Peter von der Ahé |
|
157 |
*/ |
|
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
158 |
public class JavacTrees extends DocTrees { |
10 | 159 |
|
6717 | 160 |
// in a world of a single context per compilation, these would all be final |
36526 | 161 |
private Modules modules; |
6717 | 162 |
private Resolve resolve; |
163 |
private Enter enter; |
|
164 |
private Log log; |
|
165 |
private MemberEnter memberEnter; |
|
166 |
private Attr attr; |
|
167 |
private TreeMaker treeMaker; |
|
168 |
private JavacElements elements; |
|
169 |
private JavacTaskImpl javacTaskImpl; |
|
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
170 |
private Names names; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
171 |
private Types types; |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
172 |
private DocTreeMaker docTreeMaker; |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
173 |
private BreakIterator breakIterator; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
174 |
private JavaFileManager fileManager; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
175 |
private ParserFactory parser; |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
176 |
private Symtab syms; |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
177 |
private Map<JavaFileObject, PackageSymbol> javaFileObjectToPackageMap; |
10 | 178 |
|
12016 | 179 |
// called reflectively from Trees.instance(CompilationTask task) |
10 | 180 |
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
|
181 |
if (!(task instanceof BasicJavacTask)) |
10 | 182 |
throw new IllegalArgumentException(); |
14548
aa687b312c97
8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents:
14541
diff
changeset
|
183 |
return instance(((BasicJavacTask)task).getContext()); |
10 | 184 |
} |
185 |
||
12016 | 186 |
// called reflectively from Trees.instance(ProcessingEnvironment env) |
10 | 187 |
public static JavacTrees instance(ProcessingEnvironment env) { |
188 |
if (!(env instanceof JavacProcessingEnvironment)) |
|
189 |
throw new IllegalArgumentException(); |
|
190 |
return instance(((JavacProcessingEnvironment)env).getContext()); |
|
191 |
} |
|
192 |
||
193 |
public static JavacTrees instance(Context context) { |
|
194 |
JavacTrees instance = context.get(JavacTrees.class); |
|
195 |
if (instance == null) |
|
196 |
instance = new JavacTrees(context); |
|
197 |
return instance; |
|
198 |
} |
|
199 |
||
13845
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13077
diff
changeset
|
200 |
protected JavacTrees(Context context) { |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
201 |
javaFileObjectToPackageMap = new HashMap<>(); |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
202 |
this.breakIterator = null; |
10 | 203 |
context.put(JavacTrees.class, this); |
6717 | 204 |
init(context); |
205 |
} |
|
206 |
||
207 |
public void updateContext(Context context) { |
|
208 |
init(context); |
|
209 |
} |
|
210 |
||
211 |
private void init(Context context) { |
|
36526 | 212 |
modules = Modules.instance(context); |
10 | 213 |
attr = Attr.instance(context); |
214 |
enter = Enter.instance(context); |
|
215 |
elements = JavacElements.instance(context); |
|
216 |
log = Log.instance(context); |
|
217 |
resolve = Resolve.instance(context); |
|
218 |
treeMaker = TreeMaker.instance(context); |
|
219 |
memberEnter = MemberEnter.instance(context); |
|
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
220 |
names = Names.instance(context); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
221 |
types = Types.instance(context); |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
222 |
docTreeMaker = DocTreeMaker.instance(context); |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
223 |
parser = ParserFactory.instance(context); |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
224 |
syms = Symtab.instance(context); |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
225 |
fileManager = context.get(JavaFileManager.class); |
12016 | 226 |
JavacTask t = context.get(JavacTask.class); |
227 |
if (t instanceof JavacTaskImpl) |
|
228 |
javacTaskImpl = (JavacTaskImpl) t; |
|
10 | 229 |
} |
230 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
231 |
@Override @DefinedBy(Api.COMPILER_TREE) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
232 |
public BreakIterator getBreakIterator() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
233 |
return breakIterator; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
234 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
235 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
236 |
@Override @DefinedBy(Api.COMPILER_TREE) |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
237 |
public DocSourcePositions getSourcePositions() { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
238 |
return new DocSourcePositions() { |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
239 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 240 |
public long getStartPosition(CompilationUnitTree file, Tree tree) { |
241 |
return TreeInfo.getStartPos((JCTree) tree); |
|
242 |
} |
|
243 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
244 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 245 |
public long getEndPosition(CompilationUnitTree file, Tree tree) { |
11055 | 246 |
EndPosTable endPosTable = ((JCCompilationUnit) file).endPositions; |
247 |
return TreeInfo.getEndPos((JCTree) tree, endPosTable); |
|
10 | 248 |
} |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
249 |
|
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
250 |
@Override @DefinedBy(Api.COMPILER_TREE) |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
251 |
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
|
252 |
return ((DCTree) tree).getSourcePosition((DCDocComment) comment); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
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) @SuppressWarnings("fallthrough") |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
255 |
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
|
256 |
DCDocComment dcComment = (DCDocComment) comment; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
257 |
if (tree instanceof DCEndPosTree) { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
258 |
int endPos = ((DCEndPosTree) tree).getEndPos(dcComment); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
259 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
260 |
if (endPos != Position.NOPOS) { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
261 |
return endPos; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
262 |
} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
263 |
} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
264 |
int correction = 0; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
265 |
switch (tree.getKind()) { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
266 |
case TEXT: |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
267 |
DCText text = (DCText) tree; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
268 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
269 |
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
|
270 |
case ERRONEOUS: |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
271 |
DCErroneous err = (DCErroneous) tree; |
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 |
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
|
274 |
case IDENTIFIER: |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
275 |
DCIdentifier ident = (DCIdentifier) tree; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
276 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
277 |
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
|
278 |
case PARAM: |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
279 |
DCParam param = (DCParam) tree; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
280 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
281 |
if (param.isTypeParameter && param.getDescription().isEmpty()) { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
282 |
correction = 1; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
283 |
} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
284 |
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
|
285 |
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
|
286 |
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
|
287 |
DocTree last = getLastChild(tree); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
288 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
289 |
if (last != null) { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
290 |
return getEndPosition(file, comment, last) + correction; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
291 |
} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
292 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
293 |
DCBlockTag block = (DCBlockTag) tree; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
294 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
295 |
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
|
296 |
} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
297 |
default: |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
298 |
DocTree last = getLastChild(tree); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
299 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
300 |
if (last != null) { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
301 |
return getEndPosition(file, comment, last); |
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 |
break; |
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 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
306 |
return Position.NOPOS; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
307 |
} |
10 | 308 |
}; |
309 |
} |
|
310 |
||
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
311 |
@Override @DefinedBy(Api.COMPILER_TREE) |
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
312 |
public DocTreeMaker getDocTreeFactory() { |
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
313 |
return docTreeMaker; |
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
314 |
} |
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
315 |
|
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
316 |
private DocTree getLastChild(DocTree tree) { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
317 |
final DocTree[] last = new DocTree[] {null}; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
318 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
319 |
tree.accept(new DocTreeScanner<Void, Void>() { |
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
26264
diff
changeset
|
320 |
@Override @DefinedBy(Api.COMPILER_TREE) |
33360 | 321 |
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
|
322 |
if (node != null) last[0] = node; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
323 |
return null; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
324 |
} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
325 |
}, null); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
326 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
327 |
return last[0]; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
328 |
} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
14952
diff
changeset
|
329 |
|
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
330 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 331 |
public JCClassDecl getTree(TypeElement element) { |
332 |
return (JCClassDecl) getTree((Element) element); |
|
333 |
} |
|
334 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
335 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 336 |
public JCMethodDecl getTree(ExecutableElement method) { |
337 |
return (JCMethodDecl) getTree((Element) method); |
|
338 |
} |
|
339 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
340 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 341 |
public JCTree getTree(Element element) { |
23122
02c931d49ad2
6411385: Trees.getPath does not work for constructors
jlahoda
parents:
22165
diff
changeset
|
342 |
return getTree(element, null); |
10 | 343 |
} |
344 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
345 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 346 |
public JCTree getTree(Element e, AnnotationMirror a) { |
347 |
return getTree(e, a, null); |
|
348 |
} |
|
349 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
350 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 351 |
public JCTree getTree(Element e, AnnotationMirror a, AnnotationValue v) { |
352 |
Pair<JCTree, JCCompilationUnit> treeTopLevel = elements.getTreeAndTopLevel(e, a, v); |
|
353 |
if (treeTopLevel == null) |
|
354 |
return null; |
|
355 |
return treeTopLevel.fst; |
|
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 TreePath getPath(CompilationUnitTree unit, Tree node) { |
360 |
return TreePath.getPath(unit, node); |
|
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 TreePath getPath(Element e) { |
365 |
return getPath(e, null, 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 TreePath getPath(Element e, AnnotationMirror a) { |
370 |
return getPath(e, a, null); |
|
371 |
} |
|
372 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
373 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 374 |
public TreePath getPath(Element e, AnnotationMirror a, AnnotationValue v) { |
375 |
final Pair<JCTree, JCCompilationUnit> treeTopLevel = elements.getTreeAndTopLevel(e, a, v); |
|
376 |
if (treeTopLevel == null) |
|
377 |
return null; |
|
378 |
return TreePath.getPath(treeTopLevel.snd, treeTopLevel.fst); |
|
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) |
17549
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
382 |
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
|
383 |
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
|
384 |
Symbol sym = TreeInfo.symbolFor(tree); |
14952 | 385 |
if (sym == null) { |
41160
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
386 |
for (TreePath p = path; p != null; p = p.getParentPath()) { |
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
387 |
JCTree t = (JCTree) p.getLeaf(); |
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
388 |
if (t.hasTag(JCTree.Tag.CLASSDEF)) { |
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
389 |
JCClassDecl ct = (JCClassDecl) t; |
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
390 |
if (ct.sym != null) { |
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
391 |
if ((ct.sym.flags_field & Flags.UNATTRIBUTED) != 0) { |
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
392 |
attr.attribClass(ct.pos(), ct.sym); |
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
393 |
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
|
394 |
} |
41160
61082a97bbf0
8047347: com.sun.source.util.Trees breaks the compiler.
jlahoda
parents:
36526
diff
changeset
|
395 |
break; |
6590
f745e683da2c
6930507: Symbols for anonymous and local classes made too late for use by java tree API
jjg
parents:
5847
diff
changeset
|
396 |
} |
f745e683da2c
6930507: Symbols for anonymous and local classes made too late for use by java tree API
jjg
parents:
5847
diff
changeset
|
397 |
} |
f745e683da2c
6930507: Symbols for anonymous and local classes made too late for use by java tree API
jjg
parents:
5847
diff
changeset
|
398 |
} |
f745e683da2c
6930507: Symbols for anonymous and local classes made too late for use by java tree API
jjg
parents:
5847
diff
changeset
|
399 |
} |
f745e683da2c
6930507: Symbols for anonymous and local classes made too late for use by java tree API
jjg
parents:
5847
diff
changeset
|
400 |
return sym; |
10 | 401 |
} |
402 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
26264
diff
changeset
|
403 |
@Override @DefinedBy(Api.COMPILER_TREE) |
17549
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
404 |
public Element getElement(DocTreePath path) { |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
405 |
DocTree forTree = path.getLeaf(); |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
406 |
if (forTree instanceof DCReference) |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
407 |
return attributeDocReference(path.getTreePath(), ((DCReference) forTree)); |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
408 |
if (forTree instanceof DCIdentifier) { |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
409 |
if (path.getParentPath().getLeaf() instanceof DCParam) { |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
410 |
return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf()); |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
411 |
} |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
412 |
} |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
413 |
return null; |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
414 |
} |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
415 |
|
33360 | 416 |
@Override @DefinedBy(Api.COMPILER_TREE) |
417 |
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
|
418 |
return docTreeMaker.getFirstSentence(list); |
33360 | 419 |
} |
420 |
||
17549
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
421 |
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
|
422 |
Env<AttrContext> env = getAttrContext(path); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
423 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
424 |
Log.DeferredDiagnosticHandler deferredDiagnosticHandler = |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
425 |
new Log.DeferredDiagnosticHandler(log); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
426 |
try { |
19125
db8cab0ecbd9
8020556: doclint does not check type variables for @throws
jjg
parents:
18646
diff
changeset
|
427 |
final TypeSymbol tsym; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
428 |
final Name memberName; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
429 |
if (ref.qualifierExpression == null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
430 |
tsym = env.enclClass.sym; |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
431 |
memberName = (Name) ref.memberName; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
432 |
} else { |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
433 |
// 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
|
434 |
// 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
|
435 |
// 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
|
436 |
// 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
|
437 |
Type t = attr.attribType(ref.qualifierExpression, env); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
438 |
if (t.isErroneous()) { |
36526 | 439 |
JCCompilationUnit toplevel = |
440 |
treeMaker.TopLevel(List.<JCTree>nil()); |
|
441 |
final ModuleSymbol msym = modules.getDefaultModule(); |
|
442 |
toplevel.modle = msym; |
|
443 |
toplevel.packge = msym.unnamedPackage; |
|
444 |
Symbol sym = attr.attribIdent(ref.qualifierExpression, toplevel); |
|
445 |
||
446 |
sym.complete(); |
|
447 |
||
448 |
if ((sym.kind == PCK || sym.kind == TYP) && sym.exists()) { |
|
449 |
tsym = (TypeSymbol) sym; |
|
450 |
memberName = (Name) ref.memberName; |
|
451 |
if (sym.kind == PCK && memberName != null) { |
|
452 |
//cannot refer to a package "member" |
|
453 |
return null; |
|
454 |
} |
|
455 |
} else { |
|
456 |
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
|
457 |
// fixup: allow "identifier" instead of "#identifier" |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
458 |
// for compatibility with javadoc |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
459 |
tsym = env.enclClass.sym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
460 |
memberName = ((JCIdent) ref.qualifierExpression).name; |
36526 | 461 |
} else { |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
462 |
return null; |
36526 | 463 |
} |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
464 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
465 |
} else { |
19125
db8cab0ecbd9
8020556: doclint does not check type variables for @throws
jjg
parents:
18646
diff
changeset
|
466 |
tsym = t.tsym; |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
467 |
memberName = (Name) ref.memberName; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
468 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
469 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
470 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
471 |
if (memberName == null) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
472 |
return tsym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
473 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
474 |
final List<Type> paramTypes; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
475 |
if (ref.paramTypes == null) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
476 |
paramTypes = null; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
477 |
else { |
22163 | 478 |
ListBuffer<Type> lb = new ListBuffer<>(); |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
479 |
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
|
480 |
JCTree tree = l.head; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
481 |
Type t = attr.attribType(tree, env); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
482 |
lb.add(t); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
483 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
484 |
paramTypes = lb.toList(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
485 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
486 |
|
24612
75dc732b45af
8042338: Refactor Types.upperBound to treat wildcards and variables separately
dlsmith
parents:
23122
diff
changeset
|
487 |
ClassSymbol sym = (ClassSymbol) types.cvarUpperBound(tsym.type).tsym; |
19125
db8cab0ecbd9
8020556: doclint does not check type variables for @throws
jjg
parents:
18646
diff
changeset
|
488 |
|
db8cab0ecbd9
8020556: doclint does not check type variables for @throws
jjg
parents:
18646
diff
changeset
|
489 |
Symbol msym = (memberName == sym.name) |
db8cab0ecbd9
8020556: doclint does not check type variables for @throws
jjg
parents:
18646
diff
changeset
|
490 |
? findConstructor(sym, paramTypes) |
db8cab0ecbd9
8020556: doclint does not check type variables for @throws
jjg
parents:
18646
diff
changeset
|
491 |
: findMethod(sym, memberName, paramTypes); |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
492 |
if (paramTypes != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
493 |
// 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
|
494 |
return msym; |
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 |
|
19125
db8cab0ecbd9
8020556: doclint does not check type variables for @throws
jjg
parents:
18646
diff
changeset
|
497 |
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
|
498 |
// 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
|
499 |
if (vsym != null && |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
500 |
(msym == null || |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
501 |
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
|
502 |
return vsym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
503 |
} else { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
504 |
return msym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
505 |
} |
14952 | 506 |
} catch (Abort e) { // may be thrown by Check.completionError in case of bad class file |
507 |
return null; |
|
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
508 |
} finally { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
509 |
log.popDiagnosticHandler(deferredDiagnosticHandler); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
510 |
} |
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 |
|
17549
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
513 |
private Symbol attributeParamIdentifier(TreePath path, DCParam ptag) { |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
514 |
Symbol javadocSymbol = getElement(path); |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
515 |
if (javadocSymbol == null) |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
516 |
return null; |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
517 |
ElementKind kind = javadocSymbol.getKind(); |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
518 |
List<? extends Symbol> params = List.nil(); |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
519 |
if (kind == ElementKind.METHOD || kind == ElementKind.CONSTRUCTOR) { |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
520 |
MethodSymbol ee = (MethodSymbol) javadocSymbol; |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
521 |
params = ptag.isTypeParameter() |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
522 |
? ee.getTypeParameters() |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
523 |
: ee.getParameters(); |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
524 |
} else if (kind.isClass() || kind.isInterface()) { |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
525 |
ClassSymbol te = (ClassSymbol) javadocSymbol; |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
526 |
params = te.getTypeParameters(); |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
527 |
} |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
528 |
|
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
529 |
for (Symbol param : params) { |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
530 |
if (param.getSimpleName() == ptag.getName().getName()) { |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
531 |
return param; |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
532 |
} |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
533 |
} |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
534 |
return null; |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
535 |
} |
65ea6f3b72d9
8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
17273
diff
changeset
|
536 |
|
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
537 |
/** @see com.sun.tools.javadoc.ClassDocImpl#findField */ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
538 |
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
|
539 |
return searchField(tsym, fieldName, new HashSet<>()); |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
540 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
541 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
542 |
/** @see com.sun.tools.javadoc.ClassDocImpl#searchField */ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
543 |
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
|
544 |
if (searched.contains(tsym)) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
545 |
return null; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
546 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
547 |
searched.add(tsym); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
548 |
|
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
549 |
for (Symbol sym : tsym.members().getSymbolsByName(fieldName)) { |
27224
228abfa87080
8054457: Refactor Symbol kinds from small ints to an enum
emc
parents:
26266
diff
changeset
|
550 |
if (sym.kind == VAR) { |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
551 |
return (VarSymbol)sym; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
552 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
553 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
554 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
555 |
//### 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
|
556 |
//### 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
|
557 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
558 |
ClassSymbol encl = tsym.owner.enclClass(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
559 |
if (encl != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
560 |
VarSymbol vsym = searchField(encl, fieldName, searched); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
561 |
if (vsym != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
562 |
return vsym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
563 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
564 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
565 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
566 |
// search superclass |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
567 |
Type superclass = tsym.getSuperclass(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
568 |
if (superclass.tsym != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
569 |
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
|
570 |
if (vsym != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
571 |
return vsym; |
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 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
574 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
575 |
// search interfaces |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
576 |
List<Type> intfs = tsym.getInterfaces(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
577 |
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
|
578 |
Type intf = l.head; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
579 |
if (intf.isErroneous()) continue; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
580 |
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
|
581 |
if (vsym != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
582 |
return vsym; |
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 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
585 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
586 |
return null; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
587 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
588 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
589 |
/** @see com.sun.tools.javadoc.ClassDocImpl#findConstructor */ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
590 |
MethodSymbol findConstructor(ClassSymbol tsym, List<Type> paramTypes) { |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
591 |
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
|
592 |
if (sym.kind == MTH) { |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
593 |
if (hasParameterTypes((MethodSymbol) sym, paramTypes)) { |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
594 |
return (MethodSymbol) sym; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
595 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
596 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
597 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
598 |
return null; |
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 |
/** @see com.sun.tools.javadoc.ClassDocImpl#findMethod */ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
602 |
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
|
603 |
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
|
604 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
605 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
606 |
/** @see com.sun.tools.javadoc.ClassDocImpl#searchMethod */ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
607 |
private MethodSymbol searchMethod(ClassSymbol tsym, Name methodName, |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
608 |
List<Type> paramTypes, Set<ClassSymbol> searched) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
609 |
//### 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
|
610 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
611 |
// do not match constructors |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
612 |
if (methodName == names.init) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
613 |
return null; |
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 |
if (searched.contains(tsym)) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
616 |
return null; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
617 |
searched.add(tsym); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
618 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
619 |
// search current class |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
620 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
621 |
//### 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
|
622 |
//### 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
|
623 |
//### 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
|
624 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
625 |
if (paramTypes == null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
626 |
// 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
|
627 |
// 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
|
628 |
// 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
|
629 |
// 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
|
630 |
// attempt to emulate the old behavior. |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
631 |
MethodSymbol lastFound = null; |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
632 |
for (Symbol sym : tsym.members().getSymbolsByName(methodName)) { |
27224
228abfa87080
8054457: Refactor Symbol kinds from small ints to an enum
emc
parents:
26266
diff
changeset
|
633 |
if (sym.kind == MTH) { |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
634 |
if (sym.name == methodName) { |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
635 |
lastFound = (MethodSymbol)sym; |
14541
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 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
638 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
639 |
if (lastFound != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
640 |
return lastFound; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
641 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
642 |
} else { |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
643 |
for (Symbol sym : tsym.members().getSymbolsByName(methodName)) { |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
644 |
if (sym != null && |
27224
228abfa87080
8054457: Refactor Symbol kinds from small ints to an enum
emc
parents:
26266
diff
changeset
|
645 |
sym.kind == MTH) { |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
646 |
if (hasParameterTypes((MethodSymbol) sym, paramTypes)) { |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
647 |
return (MethodSymbol) sym; |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
648 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
649 |
} |
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 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
652 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
653 |
//### 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
|
654 |
//### 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
|
655 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
656 |
// search superclass |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
657 |
Type superclass = tsym.getSuperclass(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
658 |
if (superclass.tsym != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
659 |
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
|
660 |
if (msym != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
661 |
return msym; |
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 |
// search interfaces |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
666 |
List<Type> intfs = tsym.getInterfaces(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
667 |
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
|
668 |
Type intf = l.head; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
669 |
if (intf.isErroneous()) continue; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
670 |
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
|
671 |
if (msym != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
672 |
return msym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
673 |
} |
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 |
// search enclosing class |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
677 |
ClassSymbol encl = tsym.owner.enclClass(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
678 |
if (encl != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
679 |
MethodSymbol msym = searchMethod(encl, methodName, paramTypes, searched); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
680 |
if (msym != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
681 |
return msym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
682 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
683 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
684 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
685 |
return null; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
686 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
687 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
688 |
/** @see com.sun.tools.javadoc.ClassDocImpl */ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
689 |
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
|
690 |
if (paramTypes == null) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
691 |
return true; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
692 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
693 |
if (method.params().size() != paramTypes.size()) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
694 |
return false; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
695 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
696 |
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
|
697 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
698 |
return (Type.isErroneous(paramTypes)) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
699 |
? fuzzyMatch(paramTypes, methodParamTypes) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
700 |
: types.isSameTypes(paramTypes, methodParamTypes); |
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 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
703 |
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
|
704 |
List<Type> l1 = paramTypes; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
705 |
List<Type> l2 = methodParamTypes; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
706 |
while (l1.nonEmpty()) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
707 |
if (!fuzzyMatch(l1.head, l2.head)) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
708 |
return false; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
709 |
l1 = l1.tail; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
710 |
l2 = l2.tail; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
711 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
712 |
return true; |
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 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
715 |
boolean fuzzyMatch(Type paramType, Type methodParamType) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
716 |
Boolean b = fuzzyMatcher.visit(paramType, methodParamType); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
717 |
return (b == Boolean.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 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
720 |
TypeRelation fuzzyMatcher = new TypeRelation() { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
721 |
@Override |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
722 |
public Boolean visitType(Type t, Type s) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
723 |
if (t == s) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
724 |
return true; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
725 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
726 |
if (s.isPartial()) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
727 |
return visit(s, t); |
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 |
switch (t.getTag()) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
730 |
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
|
731 |
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
|
732 |
return t.hasTag(s.getTag()); |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
733 |
default: |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
734 |
throw new AssertionError("fuzzyMatcher " + t.getTag()); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
735 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
736 |
} |
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 |
@Override |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
739 |
public Boolean visitArrayType(ArrayType t, Type s) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
740 |
if (t == s) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
741 |
return true; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
742 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
743 |
if (s.isPartial()) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
744 |
return visit(s, t); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
745 |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
17557
diff
changeset
|
746 |
return s.hasTag(ARRAY) |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
747 |
&& visit(t.elemtype, types.elemtype(s)); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
748 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
749 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
750 |
@Override |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
751 |
public Boolean visitClassType(ClassType t, Type s) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
752 |
if (t == s) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
753 |
return true; |
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 |
if (s.isPartial()) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
756 |
return visit(s, t); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
757 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
758 |
return t.tsym == s.tsym; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
759 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
760 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
761 |
@Override |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
762 |
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
|
763 |
return s.hasTag(CLASS) |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
764 |
&& t.tsym.name == ((ClassType) s).tsym.name; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
765 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
766 |
}; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
767 |
|
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
768 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 769 |
public TypeMirror getTypeMirror(TreePath path) { |
770 |
Tree t = path.getLeaf(); |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
28455
diff
changeset
|
771 |
Type ty = ((JCTree)t).type; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
28455
diff
changeset
|
772 |
return ty == null ? null : ty.stripMetadataIfNeeded(); |
10 | 773 |
} |
774 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
775 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 776 |
public JavacScope getScope(TreePath path) { |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25287
diff
changeset
|
777 |
return JavacScope.create(getAttrContext(path)); |
10 | 778 |
} |
779 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
780 |
@Override @DefinedBy(Api.COMPILER_TREE) |
7631 | 781 |
public String getDocComment(TreePath path) { |
782 |
CompilationUnitTree t = path.getCompilationUnit(); |
|
13077 | 783 |
Tree leaf = path.getLeaf(); |
784 |
if (t instanceof JCTree.JCCompilationUnit && leaf instanceof JCTree) { |
|
7631 | 785 |
JCCompilationUnit cu = (JCCompilationUnit) t; |
786 |
if (cu.docComments != null) { |
|
13077 | 787 |
return cu.docComments.getCommentText((JCTree) leaf); |
7631 | 788 |
} |
789 |
} |
|
790 |
return null; |
|
791 |
} |
|
792 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
793 |
@Override @DefinedBy(Api.COMPILER_TREE) |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
794 |
public DocCommentTree getDocCommentTree(TreePath path) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
795 |
CompilationUnitTree t = path.getCompilationUnit(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
796 |
Tree leaf = path.getLeaf(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
797 |
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
|
798 |
JCCompilationUnit cu = (JCCompilationUnit) t; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
799 |
if (cu.docComments != null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
800 |
return cu.docComments.getCommentTree((JCTree) leaf); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
801 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
802 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
803 |
return null; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
804 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
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) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
807 |
public DocCommentTree getDocCommentTree(Element e) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
808 |
TreePath path = getPath(e); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
809 |
if (path == null) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
810 |
return null; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
811 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
812 |
return getDocCommentTree(path); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
813 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
814 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
815 |
@Override @DefinedBy(Api.COMPILER_TREE) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
816 |
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
|
817 |
PackageElement pkg = elements.getPackageOf(e); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
818 |
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
|
819 |
pkg.getQualifiedName().toString(), relativeFileName); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
820 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
821 |
if (fileForInput == null) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
822 |
throw new FileNotFoundException(relativeFileName); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
823 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
824 |
return getDocCommentTree(fileForInput); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
825 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
826 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
827 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 828 |
public boolean isAccessible(Scope scope, TypeElement type) { |
829 |
if (scope instanceof JavacScope && type instanceof ClassSymbol) { |
|
830 |
Env<AttrContext> env = ((JavacScope) scope).env; |
|
7209
889e80aa1d2e
6598108: com.sun.source.util.Trees.isAccessible incorrect
mcimadamore
parents:
7077
diff
changeset
|
831 |
return resolve.isAccessible(env, (ClassSymbol)type, true); |
10 | 832 |
} else |
833 |
return false; |
|
834 |
} |
|
835 |
||
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
836 |
@Override @DefinedBy(Api.COMPILER_TREE) |
10 | 837 |
public boolean isAccessible(Scope scope, Element member, DeclaredType type) { |
838 |
if (scope instanceof JavacScope |
|
839 |
&& member instanceof Symbol |
|
840 |
&& type instanceof com.sun.tools.javac.code.Type) { |
|
841 |
Env<AttrContext> env = ((JavacScope) scope).env; |
|
7209
889e80aa1d2e
6598108: com.sun.source.util.Trees.isAccessible incorrect
mcimadamore
parents:
7077
diff
changeset
|
842 |
return resolve.isAccessible(env, (com.sun.tools.javac.code.Type)type, (Symbol)member, true); |
10 | 843 |
} else |
844 |
return false; |
|
845 |
} |
|
846 |
||
847 |
private Env<AttrContext> getAttrContext(TreePath path) { |
|
848 |
if (!(path.getLeaf() instanceof JCTree)) // implicit null-check |
|
849 |
throw new IllegalArgumentException(); |
|
850 |
||
10631
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
851 |
// 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
|
852 |
// 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
|
853 |
// 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
|
854 |
// will already have been entered. |
10 | 855 |
if (javacTaskImpl != null) { |
26264
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
25874
diff
changeset
|
856 |
javacTaskImpl.enter(null); |
10 | 857 |
} |
858 |
||
859 |
JCCompilationUnit unit = (JCCompilationUnit) path.getCompilationUnit(); |
|
13845
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13077
diff
changeset
|
860 |
Copier copier = createCopier(treeMaker.forToplevel(unit)); |
10 | 861 |
|
862 |
Env<AttrContext> env = null; |
|
863 |
JCMethodDecl method = null; |
|
864 |
JCVariableDecl field = null; |
|
865 |
||
866 |
List<Tree> l = List.nil(); |
|
867 |
TreePath p = path; |
|
868 |
while (p != null) { |
|
869 |
l = l.prepend(p.getLeaf()); |
|
870 |
p = p.getParentPath(); |
|
871 |
} |
|
872 |
||
873 |
for ( ; l.nonEmpty(); l = l.tail) { |
|
874 |
Tree tree = l.head; |
|
875 |
switch (tree.getKind()) { |
|
876 |
case COMPILATION_UNIT: |
|
877 |
// System.err.println("COMP: " + ((JCCompilationUnit)tree).sourcefile); |
|
878 |
env = enter.getTopLevelEnv((JCCompilationUnit)tree); |
|
879 |
break; |
|
7077
55689b828dc5
6993304: JavacTrees.getAttrContext not updated to Tree.Kind.{ANNOTATION_TYPE,ENUM,INTERFACE}
jjg
parents:
6717
diff
changeset
|
880 |
case ANNOTATION_TYPE: |
10 | 881 |
case CLASS: |
7077
55689b828dc5
6993304: JavacTrees.getAttrContext not updated to Tree.Kind.{ANNOTATION_TYPE,ENUM,INTERFACE}
jjg
parents:
6717
diff
changeset
|
882 |
case ENUM: |
6600 | 883 |
case INTERFACE: |
10 | 884 |
// System.err.println("CLASS: " + ((JCClassDecl)tree).sym.getSimpleName()); |
885 |
env = enter.getClassEnv(((JCClassDecl)tree).sym); |
|
886 |
break; |
|
887 |
case METHOD: |
|
888 |
// System.err.println("METHOD: " + ((JCMethodDecl)tree).sym.getSimpleName()); |
|
889 |
method = (JCMethodDecl)tree; |
|
19125
db8cab0ecbd9
8020556: doclint does not check type variables for @throws
jjg
parents:
18646
diff
changeset
|
890 |
env = memberEnter.getMethodEnv(method, env); |
10 | 891 |
break; |
892 |
case VARIABLE: |
|
893 |
// System.err.println("FIELD: " + ((JCVariableDecl)tree).sym.getSimpleName()); |
|
894 |
field = (JCVariableDecl)tree; |
|
895 |
break; |
|
896 |
case BLOCK: { |
|
897 |
// System.err.println("BLOCK: "); |
|
10631
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
898 |
if (method != null) { |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
899 |
try { |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
900 |
Assert.check(method.body == tree); |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
901 |
method.body = copier.copy((JCBlock)tree, (JCTree) path.getLeaf()); |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
902 |
env = attribStatToTree(method.body, env, copier.leafCopy); |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
903 |
} finally { |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
904 |
method.body = (JCBlock) tree; |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
905 |
} |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
906 |
} else { |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
907 |
JCBlock body = copier.copy((JCBlock)tree, (JCTree) path.getLeaf()); |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
908 |
env = attribStatToTree(body, env, copier.leafCopy); |
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
909 |
} |
10 | 910 |
return env; |
911 |
} |
|
912 |
default: |
|
913 |
// System.err.println("DEFAULT: " + tree.getKind()); |
|
914 |
if (field != null && field.getInitializer() == tree) { |
|
915 |
env = memberEnter.getInitEnv(field, env); |
|
916 |
JCExpression expr = copier.copy((JCExpression)tree, (JCTree) path.getLeaf()); |
|
917 |
env = attribExprToTree(expr, env, copier.leafCopy); |
|
918 |
return env; |
|
919 |
} |
|
920 |
} |
|
921 |
} |
|
10631
d9914010b902
7090249: IllegalStateException from Trees.getScope when called from JSR 199
jjg
parents:
9599
diff
changeset
|
922 |
return (field != null) ? memberEnter.getInitEnv(field, env) : env; |
10 | 923 |
} |
924 |
||
925 |
private Env<AttrContext> attribStatToTree(JCTree stat, Env<AttrContext>env, JCTree tree) { |
|
926 |
JavaFileObject prev = log.useSource(env.toplevel.sourcefile); |
|
927 |
try { |
|
928 |
return attr.attribStatToTree(stat, env, tree); |
|
929 |
} finally { |
|
930 |
log.useSource(prev); |
|
931 |
} |
|
932 |
} |
|
933 |
||
934 |
private Env<AttrContext> attribExprToTree(JCExpression expr, Env<AttrContext>env, JCTree tree) { |
|
935 |
JavaFileObject prev = log.useSource(env.toplevel.sourcefile); |
|
936 |
try { |
|
937 |
return attr.attribExprToTree(expr, env, tree); |
|
938 |
} finally { |
|
939 |
log.useSource(prev); |
|
940 |
} |
|
941 |
} |
|
942 |
||
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
943 |
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
|
944 |
JavaFileObject jfo = null; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
945 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
946 |
if (fileObject instanceof JavaFileObject) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
947 |
jfo = (JavaFileObject) fileObject; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
948 |
checkHtmlKind(fileObject, Kind.HTML); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
949 |
return jfo; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
950 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
951 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
952 |
checkHtmlKind(fileObject); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
953 |
jfo = new HtmlFileObject(fileObject); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
954 |
return jfo; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
955 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
956 |
|
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
957 |
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
|
958 |
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
|
959 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
960 |
|
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
961 |
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
|
962 |
if (kind != JavaFileObject.Kind.HTML) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
963 |
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
|
964 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
965 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
966 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
967 |
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
|
968 |
implements JavaFileObject { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
969 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
970 |
public HtmlFileObject(FileObject fileObject) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
971 |
super(fileObject); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
972 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
973 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
974 |
@Override @DefinedBy(Api.COMPILER) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
975 |
public Kind getKind() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
976 |
return BaseFileManager.getKind(fileObject.getName()); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
977 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
978 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
979 |
@Override @DefinedBy(Api.COMPILER) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
980 |
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
|
981 |
return false; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
982 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
983 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
984 |
@Override @DefinedBy(Api.COMPILER) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
985 |
public NestingKind getNestingKind() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
986 |
return null; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
987 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
988 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
989 |
@Override @DefinedBy(Api.COMPILER) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
990 |
public Modifier getAccessLevel() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
991 |
return null; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
992 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
993 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
994 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
995 |
@Override @DefinedBy(Api.COMPILER_TREE) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
996 |
public DocCommentTree getDocCommentTree(FileObject fileObject) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
997 |
JavaFileObject jfo = asJavaFileObject(fileObject); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
998 |
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
|
999 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1000 |
final Comment comment = new Comment() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1001 |
int offset = 0; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1002 |
@Override |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1003 |
public String getText() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1004 |
try { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1005 |
CharSequence rawDoc = fileObject.getCharContent(true); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1006 |
Pattern bodyPat = |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1007 |
Pattern.compile("(?is).*?<body\\b[^>]*>(.*)</body\\b.*"); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1008 |
Matcher m = bodyPat.matcher(rawDoc); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1009 |
if (m.matches()) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1010 |
offset = m.end(1); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1011 |
return m.group(1); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1012 |
} else { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1013 |
// Assume doclint will do the right thing. |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1014 |
return ""; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1015 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1016 |
} catch (IOException ignore) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1017 |
// do nothing |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1018 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1019 |
return ""; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1020 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1021 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1022 |
@Override |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1023 |
public int getSourcePos(int index) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1024 |
return offset + index; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1025 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1026 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1027 |
@Override |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1028 |
public CommentStyle getStyle() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1029 |
throw new UnsupportedOperationException(); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1030 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1031 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1032 |
@Override |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1033 |
public boolean isDeprecated() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1034 |
throw new UnsupportedOperationException(); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1035 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1036 |
}; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1037 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1038 |
return new DocCommentParser(parser, diagSource, comment).parse(); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1039 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1040 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1041 |
@Override @DefinedBy(Api.COMPILER_TREE) |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
1042 |
public DocTreePath getDocTreePath(FileObject fileObject) { |
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
1043 |
JavaFileObject jfo = asJavaFileObject(fileObject); |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1044 |
DocCommentTree docCommentTree = getDocCommentTree(jfo); |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1045 |
return new DocTreePath(makeTreePath(jfo, docCommentTree), docCommentTree); |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
1046 |
} |
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
1047 |
|
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
1048 |
@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
|
1049 |
public void setBreakIterator(BreakIterator breakiterator) { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1050 |
this.breakIterator = breakiterator; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1051 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1052 |
|
10 | 1053 |
/** |
1054 |
* Makes a copy of a tree, noting the value resulting from copying a particular leaf. |
|
1055 |
**/ |
|
13845
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13077
diff
changeset
|
1056 |
protected static class Copier extends TreeCopier<JCTree> { |
10 | 1057 |
JCTree leafCopy = null; |
1058 |
||
13845
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13077
diff
changeset
|
1059 |
protected Copier(TreeMaker M) { |
10 | 1060 |
super(M); |
1061 |
} |
|
1062 |
||
6717 | 1063 |
@Override |
10 | 1064 |
public <T extends JCTree> T copy(T t, JCTree leaf) { |
1065 |
T t2 = super.copy(t, leaf); |
|
1066 |
if (t == leaf) |
|
1067 |
leafCopy = t2; |
|
1068 |
return t2; |
|
1069 |
} |
|
1070 |
} |
|
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
|
1071 |
|
13845
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13077
diff
changeset
|
1072 |
protected Copier createCopier(TreeMaker maker) { |
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13077
diff
changeset
|
1073 |
return new Copier(maker); |
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13077
diff
changeset
|
1074 |
} |
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13077
diff
changeset
|
1075 |
|
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
|
1076 |
/** |
25287 | 1077 |
* 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
|
1078 |
* @param errorType The errorType for which we want to get the original type. |
31751 | 1079 |
* @return TypeMirror corresponding to the original type, replaced by the ErrorType. |
1080 |
* 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
|
1081 |
*/ |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1082 |
@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
|
1083 |
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
|
1084 |
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
|
1085 |
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
|
1086 |
} |
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
10
diff
changeset
|
1087 |
|
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
10
diff
changeset
|
1088 |
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
|
1089 |
} |
3149 | 1090 |
|
1091 |
/** |
|
1092 |
* Prints a message of the specified kind at the location of the |
|
1093 |
* tree within the provided compilation unit |
|
1094 |
* |
|
1095 |
* @param kind the kind of message |
|
1096 |
* @param msg the message, or an empty string if none |
|
1097 |
* @param t the tree to use as a position hint |
|
1098 |
* @param root the compilation unit that contains tree |
|
1099 |
*/ |
|
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1100 |
@Override @DefinedBy(Api.COMPILER_TREE) |
3149 | 1101 |
public void printMessage(Diagnostic.Kind kind, CharSequence msg, |
1102 |
com.sun.source.tree.Tree t, |
|
1103 |
com.sun.source.tree.CompilationUnitTree root) { |
|
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1104 |
printMessage(kind, msg, ((JCTree) t).pos(), root); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1105 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1106 |
|
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1107 |
@Override @DefinedBy(Api.COMPILER_TREE) |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1108 |
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
|
1109 |
com.sun.source.doctree.DocTree t, |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1110 |
com.sun.source.doctree.DocCommentTree c, |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1111 |
com.sun.source.tree.CompilationUnitTree root) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1112 |
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
|
1113 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1114 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1115 |
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
|
1116 |
JCDiagnostic.DiagnosticPosition pos, |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1117 |
com.sun.source.tree.CompilationUnitTree root) { |
3149 | 1118 |
JavaFileObject oldSource = null; |
1119 |
JavaFileObject newSource = null; |
|
1120 |
||
1121 |
newSource = root.getSourceFile(); |
|
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1122 |
if (newSource == null) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1123 |
pos = null; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
14258
diff
changeset
|
1124 |
} else { |
3149 | 1125 |
oldSource = log.useSource(newSource); |
1126 |
} |
|
1127 |
||
1128 |
try { |
|
1129 |
switch (kind) { |
|
1130 |
case ERROR: |
|
28455
41245007c074
8066843: Messager.printMessage cannot print multiple errors for same source position
jlahoda
parents:
27224
diff
changeset
|
1131 |
log.error(DiagnosticFlag.MULTIPLE, pos, "proc.messager", msg.toString()); |
3149 | 1132 |
break; |
1133 |
||
1134 |
case WARNING: |
|
1135 |
log.warning(pos, "proc.messager", msg.toString()); |
|
1136 |
break; |
|
1137 |
||
1138 |
case MANDATORY_WARNING: |
|
1139 |
log.mandatoryWarning(pos, "proc.messager", msg.toString()); |
|
1140 |
break; |
|
1141 |
||
1142 |
default: |
|
1143 |
log.note(pos, "proc.messager", msg.toString()); |
|
1144 |
} |
|
1145 |
} finally { |
|
1146 |
if (oldSource != null) |
|
1147 |
log.useSource(oldSource); |
|
1148 |
} |
|
1149 |
} |
|
9599
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
1150 |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
26264
diff
changeset
|
1151 |
@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
|
1152 |
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
|
1153 |
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
|
1154 |
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
|
1155 |
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
|
1156 |
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
|
1157 |
return ut.getLub(); |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
1158 |
} else { |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
1159 |
return v.type; |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
1160 |
} |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
7631
diff
changeset
|
1161 |
} |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1162 |
|
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1163 |
/** |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1164 |
* Register a file object, such as for a package.html, that provides |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1165 |
* doc comments for a package. |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1166 |
* @param psym the PackageSymbol representing the package. |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1167 |
* @param jfo the JavaFileObject for the given package. |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1168 |
*/ |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1169 |
public void putJavaFileObject(PackageSymbol psym, JavaFileObject jfo) { |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1170 |
javaFileObjectToPackageMap.putIfAbsent(jfo, psym); |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1171 |
} |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1172 |
|
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1173 |
private TreePath makeTreePath(final JavaFileObject jfo, DocCommentTree dcTree) { |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1174 |
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
|
1175 |
public int getPos() { |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
1176 |
return Position.FIRSTPOS; |
33424
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1177 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1178 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1179 |
public JavaFileObject getSourcefile() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1180 |
return jfo; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1181 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1182 |
|
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1183 |
@Override @DefinedBy(Api.COMPILER_TREE) |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1184 |
public Position.LineMap getLineMap() { |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1185 |
try { |
35346
c0614a805fad
8146208: Add a public DocTreeFactory to the Compiler Tree API
jjg
parents:
33424
diff
changeset
|
1186 |
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
|
1187 |
String s = content.toString(); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1188 |
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
|
1189 |
} catch (IOException ignore) {} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1190 |
return null; |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1191 |
} |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1192 |
}; |
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1193 |
|
36526 | 1194 |
PackageSymbol psym = javaFileObjectToPackageMap.getOrDefault(jfo, |
1195 |
syms.unnamedModule.unnamedPackage); |
|
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1196 |
|
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1197 |
jcCompilationUnit.docComments = new DocCommentTable() { |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1198 |
@Override |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1199 |
public boolean hasComment(JCTree tree) { |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1200 |
return false; |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1201 |
} |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1202 |
|
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1203 |
@Override |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1204 |
public Comment getComment(JCTree tree) { |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1205 |
throw new UnsupportedOperationException(); |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1206 |
} |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1207 |
|
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1208 |
@Override |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1209 |
public String getCommentText(JCTree tree) { |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1210 |
throw new UnsupportedOperationException(); |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1211 |
} |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1212 |
|
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1213 |
@Override |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1214 |
public DCDocComment getCommentTree(JCTree tree) { |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1215 |
return (DCDocComment)dcTree; |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1216 |
} |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1217 |
|
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1218 |
@Override |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1219 |
public void putComment(JCTree tree, Comment c) { |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1220 |
throw new UnsupportedOperationException(); |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1221 |
} |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1222 |
|
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1223 |
}; |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1224 |
jcCompilationUnit.lineMap = jcCompilationUnit.getLineMap(); |
36526 | 1225 |
jcCompilationUnit.modle = psym.modle; |
1226 |
jcCompilationUnit.sourcefile = jfo; |
|
36045
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1227 |
jcCompilationUnit.namedImportScope = new NamedImportScope(psym, jcCompilationUnit.toplevelScope); |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1228 |
jcCompilationUnit.packge = psym; |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1229 |
jcCompilationUnit.starImportScope = new StarImportScope(psym); |
9643bffe2105
8150096: Cleanup synthetic JCCompilationUnit for html files
ksrini
parents:
35346
diff
changeset
|
1230 |
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
|
1231 |
return new TreePath(jcCompilationUnit); |
e6bd5406e2cf
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents:
33360
diff
changeset
|
1232 |
} |
10 | 1233 |
} |