langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/RootDocImpl.java
author jjg
Fri, 27 May 2016 13:06:58 -0700
changeset 38617 d93a7f64e231
parent 37938 42baa89d2156
child 43261 d377e97291d8
permissions -rw-r--r--
8157606: deprecate com.sun.javadoc API Reviewed-by: ksrini
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
29150
ef280223e694 8041628: Javadoc cross-compilation problem
jjg
parents: 25874
diff changeset
     2
 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
37938
42baa89d2156 8075703: jdk.javadoc module exports com.sun.tools.javadoc package which contains a lot of internal API.
jjg
parents: 29957
diff changeset
    26
package com.sun.tools.javadoc.main;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import java.io.IOException;
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
    29
import java.util.Collection;
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
    30
import java.util.Locale;
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
    31
14544
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14260
diff changeset
    32
import javax.tools.JavaFileManager;
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
    33
import javax.tools.JavaFileObject;
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
    34
import javax.tools.StandardJavaFileManager;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
import com.sun.tools.javac.util.List;
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
import com.sun.tools.javac.util.ListBuffer;
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
import com.sun.tools.javac.util.Position;
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * This class holds the information from one run of javadoc.
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * Particularly the packages, classes and options specified
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 8633
diff changeset
    45
 * by the user.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 8633
diff changeset
    46
 *
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 8633
diff changeset
    47
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 8633
diff changeset
    48
 *  If you write code that depends on this, you do so at your own risk.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 8633
diff changeset
    49
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 8633
diff changeset
    50
 *  deletion without notice.</b>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 * @since 1.2
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 * @author Neal Gafter (rewrite)
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 */
38617
d93a7f64e231 8157606: deprecate com.sun.javadoc API
jjg
parents: 37938
diff changeset
    57
@Deprecated
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
public class RootDocImpl extends DocImpl implements RootDoc {
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * list of classes specified on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    private List<ClassDocImpl> cmdLineClasses;
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     * list of packages specified on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    private List<PackageDocImpl> cmdLinePackages;
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     * a collection of all options.
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    private List<String[]> options;
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     * Constructor used when reading source files.
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     * @param env the documentation environment, state for this javadoc run
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * @param classes list of classes specified on the commandline
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     * @param packages list of package names specified on the commandline
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     * @param options list of options
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    public RootDocImpl(DocEnv env, List<JCClassDecl> classes, List<String> packages, List<String[]> options) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
        super(env, null);
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
        this.options = options;
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
        setPackages(env, packages);
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
        setClasses(env, classes);
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * Constructor used when reading class files.
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     * @param env the documentation environment, state for this javadoc run
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     * @param classes list of class names specified on the commandline
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     * @param options list of options
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
    public RootDocImpl(DocEnv env, List<String> classes, List<String[]> options) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
        super(env, null);
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        this.options = options;
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
        cmdLinePackages = List.nil();
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21500
diff changeset
   101
        ListBuffer<ClassDocImpl> classList = new ListBuffer<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
        for (String className : classes) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
            ClassDocImpl c = env.loadClass(className);
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
            if (c == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
                env.error(null, "javadoc.class_not_found", className);
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
            else
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
                classList = classList.append(c);
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        cmdLineClasses = classList.toList();
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     * Initialize classes information. Those classes are input from
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     * command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     * @param env the compilation environment
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     * @param classes a list of ClassDeclaration
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    private void setClasses(DocEnv env, List<JCClassDecl> classes) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21500
diff changeset
   120
        ListBuffer<ClassDocImpl> result = new ListBuffer<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        for (JCClassDecl def : classes) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
            //### Do we want modifier check here?
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
            if (env.shouldDocument(def.sym)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
                ClassDocImpl cd = env.getClassDoc(def.sym);
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
                if (cd != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
                    cd.isIncluded = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
                    result.append(cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
                } //else System.out.println(" (classdoc is null)");//DEBUG
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
            } //else System.out.println(" (env.shouldDocument() returned false)");//DEBUG
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        cmdLineClasses = result.toList();
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     * Initialize packages information.
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     * @param env the compilation environment
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     * @param packages a list of package names (String)
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    private void setPackages(DocEnv env, List<String> packages) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21500
diff changeset
   141
        ListBuffer<PackageDocImpl> packlist = new ListBuffer<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
        for (String name : packages) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
            PackageDocImpl pkg = env.lookupPackage(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
            if (pkg != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
                pkg.isIncluded = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
                packlist.append(pkg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
                env.warning(null, "main.no_source_files_for_package", name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        cmdLinePackages = packlist.toList();
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
     * Command line options.
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
     * <pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
     * For example, given:
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
     *     javadoc -foo this that -bar other ...
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     * This method will return:
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
     *      options()[0][0] = "-foo"
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
     *      options()[0][1] = "this"
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
     *      options()[0][2] = "that"
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     *      options()[1][0] = "-bar"
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
     *      options()[1][1] = "other"
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     * </pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     * @return an array of arrays of String.
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    public String[][] options() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
        return options.toArray(new String[options.length()][]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
     * Packages specified on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
    public PackageDoc[] specifiedPackages() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
        return (PackageDoc[])cmdLinePackages
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
            .toArray(new PackageDocImpl[cmdLinePackages.length()]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
     * Classes and interfaces specified on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
    public ClassDoc[] specifiedClasses() {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21500
diff changeset
   187
        ListBuffer<ClassDocImpl> classesToDocument = new ListBuffer<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
        for (ClassDocImpl cd : cmdLineClasses) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
            cd.addAllClasses(classesToDocument, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
        return (ClassDoc[])classesToDocument.toArray(new ClassDocImpl[classesToDocument.length()]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
     * Return all classes and interfaces (including those inside
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
     * packages) to be documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
    public ClassDoc[] classes() {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21500
diff changeset
   199
        ListBuffer<ClassDocImpl> classesToDocument = new ListBuffer<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
        for (ClassDocImpl cd : cmdLineClasses) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
            cd.addAllClasses(classesToDocument, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        for (PackageDocImpl pd : cmdLinePackages) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
            pd.addAllClassesTo(classesToDocument);
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
        return classesToDocument.toArray(new ClassDocImpl[classesToDocument.length()]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
     * Return a ClassDoc for the specified class/interface name
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
     * @param qualifiedName qualified class name
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
     *                        (i.e. includes package name).
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
     * @return a ClassDocImpl holding the specified class, null if
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
     * this class is not referenced.
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
    public ClassDoc classNamed(String qualifiedName) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        return env.lookupClass(qualifiedName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
     * Return a PackageDoc for the specified package name
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
     * @param name package name
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
     * @return a PackageDoc holding the specified package, null if
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
     * this package is not referenced.
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
    public PackageDoc packageNamed(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
        return env.lookupPackage(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
     * Return the name of this Doc item.
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
     * @return the string <code>"*RootDocImpl*"</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
    public String name() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
        return "*RootDocImpl*";
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
     * Return the name of this Doc item.
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
     * @return the string <code>"*RootDocImpl*"</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
    public String qualifiedName() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
        return "*RootDocImpl*";
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
     * Return true if this Doc is include in the active set.
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
     * RootDocImpl isn't even a program entity so it is always false.
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
    public boolean isIncluded() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
     * Print error message, increment error count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
     * @param msg message to print
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
    public void printError(String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
        env.printError(msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
     * Print error message, increment error count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
     * @param msg message to print
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
    public void printError(SourcePosition pos, String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
        env.printError(pos, msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     * Print warning message, increment warning count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
     * @param msg message to print
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
    public void printWarning(String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
        env.printWarning(msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
     * Print warning message, increment warning count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
     * @param msg message to print
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
    public void printWarning(SourcePosition pos, String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
        env.printWarning(pos, msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
     * Print a message.
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
     * @param msg message to print
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
    public void printNotice(String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
        env.printNotice(msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
     * Print a message.
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
     * @param msg message to print
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
    public void printNotice(SourcePosition pos, String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
        env.printNotice(pos, msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
     * Return the path of the overview file and null if it does not exist.
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
     * @return the path of the overview file and null if it does not exist.
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
     */
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   318
    private JavaFileObject getOverviewPath() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
        for (String[] opt : options) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
            if (opt[0].equals("-overview")) {
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   321
                if (env.fileManager instanceof StandardJavaFileManager) {
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   322
                    StandardJavaFileManager fm = (StandardJavaFileManager) env.fileManager;
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   323
                    return fm.getJavaFileObjects(opt[1]).iterator().next();
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   324
                }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
     * Do lazy initialization of "documentation" string.
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
     */
8633
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents: 5520
diff changeset
   333
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
    protected String documentation() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
        if (documentation == null) {
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   336
            JavaFileObject overviewPath = getOverviewPath();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
            if (overviewPath == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
                // no doc file to be had
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
                documentation = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
                // read from file
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
                try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
                    documentation = readHTMLDocumentation(
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   344
                        overviewPath.openInputStream(),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
                        overviewPath);
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
                } catch (IOException exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
                    documentation = "";
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   348
                    env.error(null, "javadoc.File_Read_Error", overviewPath.getName());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
        return documentation;
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
     * Return the source position of the entity, or null if
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
     * no position is available.
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
     */
8633
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents: 5520
diff changeset
   359
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
    public SourcePosition position() {
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   361
        JavaFileObject path;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
        return ((path = getOverviewPath()) == null) ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
            null :
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
            SourcePositionImpl.make(path, Position.NOPOS, null);
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
    }
1863
e5de9abc0eb1 6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents: 10
diff changeset
   366
e5de9abc0eb1 6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents: 10
diff changeset
   367
    /**
e5de9abc0eb1 6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents: 10
diff changeset
   368
     * Return the locale provided by the user or the default locale value.
e5de9abc0eb1 6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents: 10
diff changeset
   369
     */
e5de9abc0eb1 6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents: 10
diff changeset
   370
    public Locale getLocale() {
e5de9abc0eb1 6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents: 10
diff changeset
   371
        return env.doclocale.locale;
e5de9abc0eb1 6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents: 10
diff changeset
   372
    }
14544
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14260
diff changeset
   373
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14260
diff changeset
   374
    /**
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14260
diff changeset
   375
     * Return the current file manager.
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14260
diff changeset
   376
     */
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14260
diff changeset
   377
    public JavaFileManager getFileManager() {
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14260
diff changeset
   378
        return env.fileManager;
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14260
diff changeset
   379
    }
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   380
29957
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 29150
diff changeset
   381
    public void initDocLint(Collection<String> opts, Collection<String> customTagNames,
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 29150
diff changeset
   382
            String htmlVersion) {
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 29150
diff changeset
   383
        env.initDoclint(opts, customTagNames, htmlVersion);
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   384
    }
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   385
23799
daa645653200 8029143: javadoc standard doclet should add Functional Interface blurb when @FunctionalInterface annotation is present
bpatel
parents: 22163
diff changeset
   386
    public boolean isFunctionalInterface(AnnotationDesc annotationDesc) {
29150
ef280223e694 8041628: Javadoc cross-compilation problem
jjg
parents: 25874
diff changeset
   387
        return env.source.allowLambda()
ef280223e694 8041628: Javadoc cross-compilation problem
jjg
parents: 25874
diff changeset
   388
            && annotationDesc.annotationType().qualifiedName().equals(
ef280223e694 8041628: Javadoc cross-compilation problem
jjg
parents: 25874
diff changeset
   389
                env.syms.functionalInterfaceType.toString());
23799
daa645653200 8029143: javadoc standard doclet should add Functional Interface blurb when @FunctionalInterface annotation is present
bpatel
parents: 22163
diff changeset
   390
    }
daa645653200 8029143: javadoc standard doclet should add Functional Interface blurb when @FunctionalInterface annotation is present
bpatel
parents: 22163
diff changeset
   391
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   392
    public boolean showTagMessages() {
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   393
        return env.showTagMessages();
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   394
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
}