36 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
36 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
37 import com.sun.tools.javac.util.List; |
37 import com.sun.tools.javac.util.List; |
38 |
38 |
39 import com.sun.tools.javac.code.Type.*; |
39 import com.sun.tools.javac.code.Type.*; |
40 import com.sun.tools.javac.code.Symbol.*; |
40 import com.sun.tools.javac.code.Symbol.*; |
|
41 import com.sun.tools.javac.main.RecognizedOptions.PkgInfo; |
41 import com.sun.tools.javac.tree.JCTree.*; |
42 import com.sun.tools.javac.tree.JCTree.*; |
42 |
43 |
43 import static com.sun.tools.javac.code.Flags.*; |
44 import static com.sun.tools.javac.code.Flags.*; |
44 import static com.sun.tools.javac.code.Kinds.*; |
45 import static com.sun.tools.javac.code.Kinds.*; |
45 |
46 |
100 MemberEnter memberEnter; |
101 MemberEnter memberEnter; |
101 Types types; |
102 Types types; |
102 Lint lint; |
103 Lint lint; |
103 Names names; |
104 Names names; |
104 JavaFileManager fileManager; |
105 JavaFileManager fileManager; |
|
106 PkgInfo pkginfoOpt; |
105 |
107 |
106 private final Todo todo; |
108 private final Todo todo; |
107 |
109 |
108 public static Enter instance(Context context) { |
110 public static Enter instance(Context context) { |
109 Enter instance = context.get(enterKey); |
111 Enter instance = context.get(enterKey); |
130 make.Modifiers(PUBLIC), |
132 make.Modifiers(PUBLIC), |
131 syms.predefClass.name, null, null, null, null); |
133 syms.predefClass.name, null, null, null, null); |
132 predefClassDef.sym = syms.predefClass; |
134 predefClassDef.sym = syms.predefClass; |
133 todo = Todo.instance(context); |
135 todo = Todo.instance(context); |
134 fileManager = context.get(JavaFileManager.class); |
136 fileManager = context.get(JavaFileManager.class); |
|
137 |
|
138 Options options = Options.instance(context); |
|
139 pkginfoOpt = PkgInfo.get(options); |
135 } |
140 } |
136 |
141 |
137 /** A hashtable mapping classes and packages to the environments current |
142 /** A hashtable mapping classes and packages to the environments current |
138 * at the points of their definitions. |
143 * at the points of their definitions. |
139 */ |
144 */ |
276 boolean addEnv = false; |
281 boolean addEnv = false; |
277 boolean isPkgInfo = tree.sourcefile.isNameCompatible("package-info", |
282 boolean isPkgInfo = tree.sourcefile.isNameCompatible("package-info", |
278 JavaFileObject.Kind.SOURCE); |
283 JavaFileObject.Kind.SOURCE); |
279 if (tree.pid != null) { |
284 if (tree.pid != null) { |
280 tree.packge = reader.enterPackage(TreeInfo.fullName(tree.pid)); |
285 tree.packge = reader.enterPackage(TreeInfo.fullName(tree.pid)); |
281 if (tree.packageAnnotations.nonEmpty()) { |
286 if (tree.packageAnnotations.nonEmpty() || pkginfoOpt == PkgInfo.ALWAYS) { |
282 if (isPkgInfo) { |
287 if (isPkgInfo) { |
283 addEnv = true; |
288 addEnv = true; |
284 } else { |
289 } else { |
285 log.error(tree.packageAnnotations.head.pos(), |
290 log.error(tree.packageAnnotations.head.pos(), |
286 "pkg.annotations.sb.in.package-info.java"); |
291 "pkg.annotations.sb.in.package-info.java"); |