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