src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/RootDocImpl.java
author mcimadamore
Mon, 04 Dec 2017 17:54:49 +0000
changeset 48054 702043a4cdeb
parent 47216 71c04702a3d5
child 48840 5e2d2067da48
permissions -rw-r--r--
8189749: Devise strategy for making source level checks more uniform Summary: Create a 'feature' enum which is responsible for handling source version checks and related diagnostic generation Reviewed-by: jjg, jlahoda
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
43261
d377e97291d8 8138725: Add options for Javadoc generation
jjg
parents: 38617
diff changeset
     2
 * Copyright (c) 1997, 2016, 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.*;
48054
702043a4cdeb 8189749: Devise strategy for making source level checks more uniform
mcimadamore
parents: 47216
diff changeset
    37
import com.sun.tools.javac.code.Source.Feature;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
import com.sun.tools.javac.util.List;
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
import com.sun.tools.javac.util.ListBuffer;
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
import com.sun.tools.javac.util.Position;
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * This class holds the information from one run of javadoc.
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * Particularly the packages, classes and options specified
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 8633
diff changeset
    46
 * by the user.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 8633
diff changeset
    47
 *
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 8633
diff changeset
    48
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 8633
diff changeset
    49
 *  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
    50
 *  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
    51
 *  deletion without notice.</b>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 * @since 1.2
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 * @author Neal Gafter (rewrite)
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 */
38617
d93a7f64e231 8157606: deprecate com.sun.javadoc API
jjg
parents: 37938
diff changeset
    58
@Deprecated
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
public class RootDocImpl extends DocImpl implements RootDoc {
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     * list of classes specified on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    private List<ClassDocImpl> cmdLineClasses;
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     * list of packages specified on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    private List<PackageDocImpl> cmdLinePackages;
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     * a collection of all options.
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    private List<String[]> options;
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     * Constructor used when reading source files.
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * @param env the documentation environment, state for this javadoc run
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     * @param classes list of classes specified on the commandline
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     * @param packages list of package names specified on the commandline
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     * @param options list of options
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    public RootDocImpl(DocEnv env, List<JCClassDecl> classes, List<String> packages, List<String[]> options) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
        super(env, null);
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
        this.options = options;
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
        setPackages(env, packages);
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
        setClasses(env, classes);
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     * Constructor used when reading class files.
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     * @param env the documentation environment, state for this javadoc run
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     * @param classes list of class names specified on the commandline
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     * @param options list of options
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
    public RootDocImpl(DocEnv env, List<String> classes, List<String[]> options) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        super(env, null);
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
        this.options = options;
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        cmdLinePackages = List.nil();
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21500
diff changeset
   102
        ListBuffer<ClassDocImpl> classList = new ListBuffer<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
        for (String className : classes) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
            ClassDocImpl c = env.loadClass(className);
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
            if (c == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
                env.error(null, "javadoc.class_not_found", className);
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
            else
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
                classList = classList.append(c);
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
        cmdLineClasses = classList.toList();
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     * Initialize classes information. Those classes are input from
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     * command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     * @param env the compilation environment
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     * @param classes a list of ClassDeclaration
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
    private void setClasses(DocEnv env, List<JCClassDecl> classes) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21500
diff changeset
   121
        ListBuffer<ClassDocImpl> result = new ListBuffer<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        for (JCClassDecl def : classes) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
            //### Do we want modifier check here?
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
            if (env.shouldDocument(def.sym)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
                ClassDocImpl cd = env.getClassDoc(def.sym);
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
                if (cd != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
                    cd.isIncluded = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
                    result.append(cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
                } //else System.out.println(" (classdoc is null)");//DEBUG
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
            } //else System.out.println(" (env.shouldDocument() returned false)");//DEBUG
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        cmdLineClasses = result.toList();
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     * Initialize packages information.
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     * @param env the compilation environment
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     * @param packages a list of package names (String)
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
    private void setPackages(DocEnv env, List<String> packages) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21500
diff changeset
   142
        ListBuffer<PackageDocImpl> packlist = new ListBuffer<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        for (String name : packages) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
            PackageDocImpl pkg = env.lookupPackage(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
            if (pkg != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
                pkg.isIncluded = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
                packlist.append(pkg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
                env.warning(null, "main.no_source_files_for_package", name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        cmdLinePackages = packlist.toList();
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     * Command line options.
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
     * <pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
     * For example, given:
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     *     javadoc -foo this that -bar other ...
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
     * This method will return:
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
     *      options()[0][0] = "-foo"
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
     *      options()[0][1] = "this"
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     *      options()[0][2] = "that"
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
     *      options()[1][0] = "-bar"
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     *      options()[1][1] = "other"
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     * </pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     * @return an array of arrays of String.
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
    public String[][] options() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
        return options.toArray(new String[options.length()][]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
     * Packages specified on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
    public PackageDoc[] specifiedPackages() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        return (PackageDoc[])cmdLinePackages
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
            .toArray(new PackageDocImpl[cmdLinePackages.length()]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
     * Classes and interfaces specified on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
    public ClassDoc[] specifiedClasses() {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21500
diff changeset
   188
        ListBuffer<ClassDocImpl> classesToDocument = new ListBuffer<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        for (ClassDocImpl cd : cmdLineClasses) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
            cd.addAllClasses(classesToDocument, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
        return (ClassDoc[])classesToDocument.toArray(new ClassDocImpl[classesToDocument.length()]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
     * Return all classes and interfaces (including those inside
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     * packages) to be documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
    public ClassDoc[] classes() {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21500
diff changeset
   200
        ListBuffer<ClassDocImpl> classesToDocument = new ListBuffer<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
        for (ClassDocImpl cd : cmdLineClasses) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
            cd.addAllClasses(classesToDocument, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
        for (PackageDocImpl pd : cmdLinePackages) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
            pd.addAllClassesTo(classesToDocument);
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        return classesToDocument.toArray(new ClassDocImpl[classesToDocument.length()]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
     * Return a ClassDoc for the specified class/interface name
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
     * @param qualifiedName qualified class name
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
     *                        (i.e. includes package name).
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
     * @return a ClassDocImpl holding the specified class, null if
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
     * this class is not referenced.
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
    public ClassDoc classNamed(String qualifiedName) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
        return env.lookupClass(qualifiedName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
     * Return a PackageDoc for the specified package name
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
     * @param name package name
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
     * @return a PackageDoc holding the specified package, null if
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
     * this package is not referenced.
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
    public PackageDoc packageNamed(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
        return env.lookupPackage(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
     * Return the name of this Doc item.
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
     * @return the string <code>"*RootDocImpl*"</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
    public String name() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
        return "*RootDocImpl*";
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
     * Return the name of this Doc item.
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
     * @return the string <code>"*RootDocImpl*"</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
    public String qualifiedName() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
        return "*RootDocImpl*";
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
     * Return true if this Doc is include in the active set.
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
     * RootDocImpl isn't even a program entity so it is always false.
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
    public boolean isIncluded() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
     * Print error message, increment error count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
     * @param msg message to print
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
    public void printError(String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
        env.printError(msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
     * Print error message, increment error count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
     * @param msg message to print
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
    public void printError(SourcePosition pos, String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
        env.printError(pos, msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
     * Print warning message, increment warning count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
     * @param msg message to print
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
    public void printWarning(String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
        env.printWarning(msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
     * Print warning message, increment warning count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
     * @param msg message to print
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
    public void printWarning(SourcePosition pos, String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
        env.printWarning(pos, msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
     * Print a message.
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
     * @param msg message to print
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
    public void printNotice(String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
        env.printNotice(msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
     * Print a message.
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
     * @param msg message to print
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
    public void printNotice(SourcePosition pos, String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
        env.printNotice(pos, msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
    /**
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
     * @return the path of the overview file and null if it does not exist.
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
     */
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   319
    private JavaFileObject getOverviewPath() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
        for (String[] opt : options) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
            if (opt[0].equals("-overview")) {
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   322
                if (env.fileManager instanceof StandardJavaFileManager) {
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   323
                    StandardJavaFileManager fm = (StandardJavaFileManager) env.fileManager;
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   324
                    return fm.getJavaFileObjects(opt[1]).iterator().next();
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   325
                }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
     * Do lazy initialization of "documentation" string.
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
     */
8633
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents: 5520
diff changeset
   334
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
    protected String documentation() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
        if (documentation == null) {
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   337
            JavaFileObject overviewPath = getOverviewPath();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
            if (overviewPath == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
                // no doc file to be had
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
                documentation = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
                // read from file
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
                try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
                    documentation = readHTMLDocumentation(
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   345
                        overviewPath.openInputStream(),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
                        overviewPath);
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
                } catch (IOException exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
                    documentation = "";
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   349
                    env.error(null, "javadoc.File_Read_Error", overviewPath.getName());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
        return documentation;
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
     * Return the source position of the entity, or null if
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
     * no position is available.
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
     */
8633
41311e88ffb7 6964914: javadoc does not output number of warnings using user written doclet
jjg
parents: 5520
diff changeset
   360
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
    public SourcePosition position() {
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1863
diff changeset
   362
        JavaFileObject path;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
        return ((path = getOverviewPath()) == null) ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
            null :
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
            SourcePositionImpl.make(path, Position.NOPOS, null);
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
    }
1863
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
    /**
e5de9abc0eb1 6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents: 10
diff changeset
   369
     * 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
   370
     */
e5de9abc0eb1 6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents: 10
diff changeset
   371
    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
   372
        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
   373
    }
14544
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
    /**
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14260
diff changeset
   376
     * Return the current file manager.
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14260
diff changeset
   377
     */
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14260
diff changeset
   378
    public JavaFileManager getFileManager() {
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14260
diff changeset
   379
        return env.fileManager;
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14260
diff changeset
   380
    }
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   381
29957
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 29150
diff changeset
   382
    public void initDocLint(Collection<String> opts, Collection<String> customTagNames,
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 29150
diff changeset
   383
            String htmlVersion) {
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 29150
diff changeset
   384
        env.initDoclint(opts, customTagNames, htmlVersion);
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   385
    }
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   386
43261
d377e97291d8 8138725: Add options for Javadoc generation
jjg
parents: 38617
diff changeset
   387
    public JavaScriptScanner initJavaScriptScanner(boolean allowScriptInComments) {
d377e97291d8 8138725: Add options for Javadoc generation
jjg
parents: 38617
diff changeset
   388
        return env.initJavaScriptScanner(allowScriptInComments);
d377e97291d8 8138725: Add options for Javadoc generation
jjg
parents: 38617
diff changeset
   389
    }
d377e97291d8 8138725: Add options for Javadoc generation
jjg
parents: 38617
diff changeset
   390
23799
daa645653200 8029143: javadoc standard doclet should add Functional Interface blurb when @FunctionalInterface annotation is present
bpatel
parents: 22163
diff changeset
   391
    public boolean isFunctionalInterface(AnnotationDesc annotationDesc) {
48054
702043a4cdeb 8189749: Devise strategy for making source level checks more uniform
mcimadamore
parents: 47216
diff changeset
   392
        return Feature.LAMBDA.allowedInSource(env.source)
29150
ef280223e694 8041628: Javadoc cross-compilation problem
jjg
parents: 25874
diff changeset
   393
            && annotationDesc.annotationType().qualifiedName().equals(
ef280223e694 8041628: Javadoc cross-compilation problem
jjg
parents: 25874
diff changeset
   394
                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
   395
    }
daa645653200 8029143: javadoc standard doclet should add Functional Interface blurb when @FunctionalInterface annotation is present
bpatel
parents: 22163
diff changeset
   396
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   397
    public boolean showTagMessages() {
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   398
        return env.showTagMessages();
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   399
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
}