1/*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package jdk.javadoc.internal.tool;
27
28import java.util.Set;
29
30import javax.lang.model.SourceVersion;
31import javax.lang.model.element.Element;
32import javax.lang.model.element.TypeElement;
33import javax.lang.model.util.Elements;
34import javax.lang.model.util.Types;
35import javax.tools.JavaFileManager;
36import javax.tools.JavaFileObject.Kind;
37
38import com.sun.source.util.DocTrees;
39import com.sun.tools.javac.code.Source;
40import jdk.javadoc.doclet.DocletEnvironment;
41
42/**
43 * This class holds the information from one run of javadoc.
44 * Particularly the packages, classes and options specified
45 * by the user.
46 *
47 *  <p><b>This is NOT part of any supported API.
48 *  If you write code that depends on this, you do so at your own risk.
49 *  This code and its internal interfaces are subject to change or
50 *  deletion without notice.</b>
51 *
52 * @author Robert Field
53 * @author Atul M Dambalkar
54 * @author Neal Gafter (rewrite)
55 */
56public class DocEnvImpl implements DocletEnvironment {
57
58    public final ElementsTable etable;
59
60    public final ToolEnvironment toolEnv;
61
62    /**
63     * Construct a doclet environment.
64     *
65     * @param toolEnv the tool environment
66     * @param etable the includes table, providing all the information
67     * with respect to specified, included/selected elements.
68     */
69    public DocEnvImpl(ToolEnvironment toolEnv, ElementsTable etable) {
70        this.toolEnv = toolEnv;
71        this.etable = etable;
72    }
73   @Override
74    public Set<? extends Element> getSpecifiedElements() {
75        return etable.getSpecifiedElements();
76    }
77
78    @Override
79    public Set<? extends Element> getIncludedElements() {
80        return etable.getIncludedElements();
81    }
82
83    @Override
84    public boolean isIncluded(Element e) {
85        return etable.isIncluded(e);
86    }
87
88    @Override
89    public DocTrees getDocTrees() {
90        return toolEnv.docTrees;
91    }
92
93    @Override
94    public Elements getElementUtils() {
95        return toolEnv.elements;
96    }
97
98    @Override
99    public Types getTypeUtils() {
100        return toolEnv.typeutils;
101    }
102
103    @Override
104    public JavaFileManager getJavaFileManager() {
105        return toolEnv.fileManager;
106    }
107
108    @Override
109    public SourceVersion getSourceVersion() {
110        return Source.toSourceVersion(toolEnv.source);
111    }
112
113    @Override
114    public ModuleMode getModuleMode() {
115        return etable.getModuleMode();
116    }
117
118    @Override
119    public Kind getFileKind(TypeElement type) {
120        return toolEnv.getFileKind(type);
121    }
122
123    @Override
124    public boolean isSelected(Element e) {
125        return etable.isSelected(e);
126    }
127}
128