langtools/src/share/classes/com/sun/tools/javadoc/DocEnv.java
author jjg
Sun, 18 May 2014 19:59:10 -0700
changeset 24604 7f68545b5128
parent 24069 dfb8f11542fc
permissions -rw-r--r--
8041422: Split javac ClassReader into ClassReader+ClassFinder Reviewed-by: jfranck
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
22442
8fd30fc4e3a3 8029690: Move symbol creation from ClassReader to Symtab
jfranck
parents: 22163
diff changeset
     2
 * Copyright (c) 2000, 2014, 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: 5010
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: 5010
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: 5010
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5010
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5010
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.javadoc;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1264
diff changeset
    28
import java.lang.reflect.Modifier;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.util.*;
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
    30
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1264
diff changeset
    31
import javax.tools.JavaFileManager;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import com.sun.javadoc.*;
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
    34
import com.sun.source.util.JavacTask;
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
    35
import com.sun.source.util.TreePath;
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
    36
import com.sun.tools.doclint.DocLint;
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
    37
import com.sun.tools.javac.api.BasicJavacTask;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
import com.sun.tools.javac.code.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
import com.sun.tools.javac.code.Symbol.*;
24604
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
    40
import com.sun.tools.javac.code.Symbol.ClassSymbol;
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
    41
import com.sun.tools.javac.code.Symbol.CompletionFailure;
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
    42
import com.sun.tools.javac.code.Symbol.MethodSymbol;
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
    43
import com.sun.tools.javac.code.Symbol.PackageSymbol;
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
    44
import com.sun.tools.javac.code.Symbol.VarSymbol;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
import com.sun.tools.javac.code.Type.ClassType;
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
import com.sun.tools.javac.comp.Check;
24604
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
    47
import com.sun.tools.javac.comp.Enter;
21891
42435b2c96cf 8027977: javadoc dies on NumberFormat/DateFormat subclass
bpatel
parents: 21500
diff changeset
    48
import com.sun.tools.javac.file.JavacFileManager;
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
    49
import com.sun.tools.javac.tree.JCTree;
24604
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
    50
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
    51
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
    52
import com.sun.tools.javac.tree.JCTree.JCPackageDecl;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
import com.sun.tools.javac.util.Context;
1260
a772ba9ba43d 6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents: 10
diff changeset
    54
import com.sun.tools.javac.util.Names;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 * Holds the environment for a run of javadoc.
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 * Holds only the information needed throughout the
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
 * run and not the compiler info that could be GC'ed
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
 * or ported.
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 10189
diff changeset
    62
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 10189
diff changeset
    63
 *  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: 10189
diff changeset
    64
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 10189
diff changeset
    65
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 10189
diff changeset
    66
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
 * @since 1.4
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
 * @author Neal Gafter (rewrite)
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
 * @author Scott Seligman (generics)
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
public class DocEnv {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21891
diff changeset
    73
    protected static final Context.Key<DocEnv> docEnvKey = new Context.Key<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
    public static DocEnv instance(Context context) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
        DocEnv instance = context.get(docEnvKey);
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        if (instance == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
            instance = new DocEnv(context);
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
        return instance;
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    DocLocale doclocale;
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
24604
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
    84
    private final Messager messager;
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
    85
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    /** Predefined symbols known to the compiler. */
24604
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
    87
    final Symtab syms;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
    /** Referenced directly in RootDocImpl. */
24604
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
    90
    private final ClassFinder finder;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    /** Javadoc's own version of the compiler's enter phase. */
24604
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
    93
    final Enter enter;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    /** The name table. */
24604
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
    96
    private Names names;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
    /** The encoding name. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    private String encoding;
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    final Symbol externalizableSym;
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    /** Access filter (public, protected, ...).  */
10189
57268b86d4da 7059905: (javadoc) promote method visibility for netbeans usage
ksrini
parents: 7681
diff changeset
   104
    protected ModifierFilter showAccess;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    /** True if we are using a sentence BreakIterator. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
    boolean breakiterator;
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     * True if we do not want to print any notifications at all.
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    boolean quiet = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
    Check chk;
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
    Types types;
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1264
diff changeset
   116
    JavaFileManager fileManager;
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents: 14260
diff changeset
   117
    Context context;
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   118
    DocLint doclint;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21891
diff changeset
   120
    WeakHashMap<JCTree, TreePath> treePaths = new WeakHashMap<>();
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   121
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
    /** Allow documenting from class files? */
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
    boolean docClasses = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
    /** Does the doclet only expect pre-1.5 doclet API? */
10189
57268b86d4da 7059905: (javadoc) promote method visibility for netbeans usage
ksrini
parents: 7681
diff changeset
   126
    protected boolean legacyDoclet = true;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     * Set this to true if you would like to not emit any errors, warnings and
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     * notices.
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
    private boolean silent = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
    /**
19912
4b1a79163f9c 8022738: doclet should only generate functional interface text if source >= 8
bpatel
parents: 16799
diff changeset
   135
     * The source language version.
4b1a79163f9c 8022738: doclet should only generate functional interface text if source >= 8
bpatel
parents: 16799
diff changeset
   136
     */
4b1a79163f9c 8022738: doclet should only generate functional interface text if source >= 8
bpatel
parents: 16799
diff changeset
   137
    protected Source source;
4b1a79163f9c 8022738: doclet should only generate functional interface text if source >= 8
bpatel
parents: 16799
diff changeset
   138
4b1a79163f9c 8022738: doclet should only generate functional interface text if source >= 8
bpatel
parents: 16799
diff changeset
   139
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     * Constructor
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     * @param context      Context for this javadoc instance.
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
     */
10189
57268b86d4da 7059905: (javadoc) promote method visibility for netbeans usage
ksrini
parents: 7681
diff changeset
   144
    protected DocEnv(Context context) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        context.put(docEnvKey, this);
14541
36f9d11fc9aa 7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents: 14260
diff changeset
   146
        this.context = context;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
        messager = Messager.instance0(context);
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
        syms = Symtab.instance(context);
24604
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
   150
        finder = JavadocClassFinder.instance(context);
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
   151
        enter = JavadocEnter.instance(context);
1260
a772ba9ba43d 6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents: 10
diff changeset
   152
        names = Names.instance(context);
22442
8fd30fc4e3a3 8029690: Move symbol creation from ClassReader to Symtab
jfranck
parents: 22163
diff changeset
   153
        externalizableSym = syms.enterClass(names.fromString("java.io.Externalizable"));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        chk = Check.instance(context);
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        types = Types.instance(context);
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1264
diff changeset
   156
        fileManager = context.get(JavaFileManager.class);
21891
42435b2c96cf 8027977: javadoc dies on NumberFormat/DateFormat subclass
bpatel
parents: 21500
diff changeset
   157
        if (fileManager instanceof JavacFileManager) {
42435b2c96cf 8027977: javadoc dies on NumberFormat/DateFormat subclass
bpatel
parents: 21500
diff changeset
   158
            ((JavacFileManager)fileManager).setSymbolFileEnabled(false);
42435b2c96cf 8027977: javadoc dies on NumberFormat/DateFormat subclass
bpatel
parents: 21500
diff changeset
   159
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        // Default.  Should normally be reset with setLocale.
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        this.doclocale = new DocLocale(this, "", breakiterator);
19912
4b1a79163f9c 8022738: doclet should only generate functional interface text if source >= 8
bpatel
parents: 16799
diff changeset
   163
        source = Source.instance(context);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    public void setSilent(boolean silent) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
        this.silent = silent;
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
     * Look up ClassDoc by qualified name.
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
    public ClassDocImpl lookupClass(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        ClassSymbol c = getClassSymbol(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
        if (c != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
            return getClassDoc(c);
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     * Load ClassDoc by qualified name.
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
    public ClassDocImpl loadClass(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        try {
24604
7f68545b5128 8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents: 24069
diff changeset
   187
            ClassSymbol c = finder.loadClass(names.fromString(name));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
            return getClassDoc(c);
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        } catch (CompletionFailure ex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
            chk.completionError(null, ex);
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
            return null;
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
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
     * Look up PackageDoc by qualified name.
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
    public PackageDocImpl lookupPackage(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
        //### Jing alleges that class check is needed
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
        //### to avoid a compiler bug.  Most likely
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
        //### instead a dummy created for error recovery.
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        //### Should investigate this.
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        PackageSymbol p = syms.packages.get(names.fromString(name));
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
        ClassSymbol c = getClassSymbol(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
        if (p != null && c == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
            return getPackageDoc(p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
        // where
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
        /** Retrieve class symbol by fully-qualified name.
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
        ClassSymbol getClassSymbol(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
            // Name may contain nested class qualification.
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
            // Generate candidate flatnames with successively shorter
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
            // package qualifiers and longer nested class qualifiers.
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
            int nameLen = name.length();
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
            char[] nameChars = name.toCharArray();
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
            int idx = name.length();
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
            for (;;) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
                ClassSymbol s = syms.classes.get(names.fromChars(nameChars, 0, nameLen));
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
                if (s != null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
                    return s; // found it!
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
                idx = name.substring(0, idx).lastIndexOf('.');
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
                if (idx < 0) break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
                nameChars[idx] = '$';
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
     * Set the locale.
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
    public void setLocale(String localeName) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
        // create locale specifics
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
        doclocale = new DocLocale(this, localeName, breakiterator);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents: 14541
diff changeset
   238
        // update Messager if locale has changed.
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents: 14541
diff changeset
   239
        messager.setLocale(doclocale.locale);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
    /** Check whether this member should be documented. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
    public boolean shouldDocument(VarSymbol sym) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
        long mod = sym.flags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
        if ((mod & Flags.SYNTHETIC) != 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
        return showAccess.checkModifier(translateModifiers(mod));
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
    /** Check whether this member should be documented. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
    public boolean shouldDocument(MethodSymbol sym) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
        long mod = sym.flags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
        if ((mod & Flags.SYNTHETIC) != 0) {
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
        return showAccess.checkModifier(translateModifiers(mod));
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
    /** check whether this class should be documented. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
    public boolean shouldDocument(ClassSymbol sym) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
        return
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
            (sym.flags_field&Flags.SYNTHETIC) == 0 && // no synthetics
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
            (docClasses || getClassDoc(sym).tree != null) &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
            isVisible(sym);
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
    //### Comment below is inaccurate wrt modifier filter testing
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
     * Check the visibility if this is an nested class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
     * if this is not a nested class, return true.
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
     * if this is an static visible nested class,
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
     *    return true.
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
     * if this is an visible nested class
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     *    if the outer class is visible return true.
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
     *    else return false.
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
     * IMPORTANT: This also allows, static nested classes
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
     * to be defined inside an nested class, which is not
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
     * allowed by the compiler. So such an test case will
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
     * not reach upto this method itself, but if compiler
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
     * allows it, then that will go through.
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
    protected boolean isVisible(ClassSymbol sym) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
        long mod = sym.flags_field;
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
        if (!showAccess.checkModifier(translateModifiers(mod))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
        ClassSymbol encl = sym.owner.enclClass();
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
        return (encl == null || (mod & Flags.STATIC) != 0 || isVisible(encl));
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
    //---------------- print forwarders ----------------//
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
     * Print error message, increment error count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
     * @param msg message to print.
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
    public void printError(String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
        if (silent)
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
        messager.printError(msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
     * Print error message, increment error count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
     * @param key selects message from resource
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
    public void error(DocImpl doc, String key) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
        if (silent)
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
        messager.error(doc==null ? null : doc.position(), key);
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
     * Print error message, increment error count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
     * @param key selects message from resource
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
    public void error(SourcePosition pos, String key) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
        if (silent)
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
        messager.error(pos, key);
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
     * Print error message, increment error count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
     * @param msg message to print.
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
    public void printError(SourcePosition pos, String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
        if (silent)
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
        messager.printError(pos, msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
     * Print error message, increment error count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
     * @param key selects message from resource
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
     * @param a1 first argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
    public void error(DocImpl doc, String key, String a1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
        if (silent)
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
        messager.error(doc==null ? null : doc.position(), key, a1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
     * Print error message, increment error count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
     * @param key selects message from resource
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
     * @param a1 first argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
     * @param a2 second argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
    public void error(DocImpl doc, String key, String a1, String a2) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
        if (silent)
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
        messager.error(doc==null ? null : doc.position(), key, a1, a2);
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
     * Print error message, increment error count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
     * @param key selects message from resource
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
     * @param a1 first argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
     * @param a2 second argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
     * @param a3 third argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
    public void error(DocImpl doc, String key, String a1, String a2, String a3) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
        if (silent)
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
        messager.error(doc==null ? null : doc.position(), key, a1, a2, a3);
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
     * Print warning message, increment warning count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
     * @param msg message to print.
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
    public void printWarning(String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
        if (silent)
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
        messager.printWarning(msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
     * Print warning message, increment warning count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
     * @param key selects message from resource
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
    public void warning(DocImpl doc, String key) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
        if (silent)
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
        messager.warning(doc==null ? null : doc.position(), key);
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
     * Print warning message, increment warning count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
     * @param msg message to print.
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
    public void printWarning(SourcePosition pos, String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
        if (silent)
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
        messager.printWarning(pos, msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
     * Print warning message, increment warning count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
     * @param key selects message from resource
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
     * @param a1 first argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   419
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
    public void warning(DocImpl doc, String key, String a1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
        if (silent)
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
            return;
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   423
        // suppress messages that have (probably) been covered by doclint
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   424
        if (doclint != null && doc != null && key.startsWith("tag"))
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   425
            return;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   426
        messager.warning(doc==null ? null : doc.position(), key, a1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   427
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   428
06bc494ca11e Initial load
duke
parents:
diff changeset
   429
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   430
     * Print warning message, increment warning count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   431
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   432
     * @param key selects message from resource
06bc494ca11e Initial load
duke
parents:
diff changeset
   433
     * @param a1 first argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   434
     * @param a2 second argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   436
    public void warning(DocImpl doc, String key, String a1, String a2) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
        if (silent)
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
        messager.warning(doc==null ? null : doc.position(), key, a1, a2);
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
     * Print warning message, increment warning count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
     * @param key selects message from resource
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
     * @param a1 first argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
     * @param a2 second argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
     * @param a3 third argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
    public void warning(DocImpl doc, String key, String a1, String a2, String a3) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   451
        if (silent)
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
        messager.warning(doc==null ? null : doc.position(), key, a1, a2, a3);
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   455
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
     * Print warning message, increment warning count.
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
     * @param key selects message from resource
06bc494ca11e Initial load
duke
parents:
diff changeset
   460
     * @param a1 first argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   461
     * @param a2 second argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   462
     * @param a3 third argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   463
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   464
    public void warning(DocImpl doc, String key, String a1, String a2, String a3,
06bc494ca11e Initial load
duke
parents:
diff changeset
   465
                        String a4) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   466
        if (silent)
06bc494ca11e Initial load
duke
parents:
diff changeset
   467
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   468
        messager.warning(doc==null ? null : doc.position(), key, a1, a2, a3, a4);
06bc494ca11e Initial load
duke
parents:
diff changeset
   469
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   470
06bc494ca11e Initial load
duke
parents:
diff changeset
   471
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   472
     * Print a message.
06bc494ca11e Initial load
duke
parents:
diff changeset
   473
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   474
     * @param msg message to print.
06bc494ca11e Initial load
duke
parents:
diff changeset
   475
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   476
    public void printNotice(String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   477
        if (silent || quiet)
06bc494ca11e Initial load
duke
parents:
diff changeset
   478
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   479
        messager.printNotice(msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   480
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   481
06bc494ca11e Initial load
duke
parents:
diff changeset
   482
06bc494ca11e Initial load
duke
parents:
diff changeset
   483
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   484
     * Print a message.
06bc494ca11e Initial load
duke
parents:
diff changeset
   485
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   486
     * @param key selects message from resource
06bc494ca11e Initial load
duke
parents:
diff changeset
   487
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   488
    public void notice(String key) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   489
        if (silent || quiet)
06bc494ca11e Initial load
duke
parents:
diff changeset
   490
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   491
        messager.notice(key);
06bc494ca11e Initial load
duke
parents:
diff changeset
   492
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   493
06bc494ca11e Initial load
duke
parents:
diff changeset
   494
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   495
     * Print a message.
06bc494ca11e Initial load
duke
parents:
diff changeset
   496
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   497
     * @param msg message to print.
06bc494ca11e Initial load
duke
parents:
diff changeset
   498
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   499
    public void printNotice(SourcePosition pos, String msg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   500
        if (silent || quiet)
06bc494ca11e Initial load
duke
parents:
diff changeset
   501
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   502
        messager.printNotice(pos, msg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   503
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   504
06bc494ca11e Initial load
duke
parents:
diff changeset
   505
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   506
     * Print a message.
06bc494ca11e Initial load
duke
parents:
diff changeset
   507
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   508
     * @param key selects message from resource
06bc494ca11e Initial load
duke
parents:
diff changeset
   509
     * @param a1 first argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   510
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   511
    public void notice(String key, String a1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   512
        if (silent || quiet)
06bc494ca11e Initial load
duke
parents:
diff changeset
   513
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   514
        messager.notice(key, a1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   515
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   516
06bc494ca11e Initial load
duke
parents:
diff changeset
   517
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   518
     * Print a message.
06bc494ca11e Initial load
duke
parents:
diff changeset
   519
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   520
     * @param key selects message from resource
06bc494ca11e Initial load
duke
parents:
diff changeset
   521
     * @param a1 first argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   522
     * @param a2 second argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   523
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   524
    public void notice(String key, String a1, String a2) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   525
        if (silent || quiet)
06bc494ca11e Initial load
duke
parents:
diff changeset
   526
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   527
        messager.notice(key, a1, a2);
06bc494ca11e Initial load
duke
parents:
diff changeset
   528
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   529
06bc494ca11e Initial load
duke
parents:
diff changeset
   530
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   531
     * Print a message.
06bc494ca11e Initial load
duke
parents:
diff changeset
   532
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   533
     * @param key selects message from resource
06bc494ca11e Initial load
duke
parents:
diff changeset
   534
     * @param a1 first argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   535
     * @param a2 second argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   536
     * @param a3 third argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   537
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   538
    public void notice(String key, String a1, String a2, String a3) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   539
        if (silent || quiet)
06bc494ca11e Initial load
duke
parents:
diff changeset
   540
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   541
        messager.notice(key, a1, a2, a3);
06bc494ca11e Initial load
duke
parents:
diff changeset
   542
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   543
06bc494ca11e Initial load
duke
parents:
diff changeset
   544
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   545
     * Exit, reporting errors and warnings.
06bc494ca11e Initial load
duke
parents:
diff changeset
   546
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   547
    public void exit() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   548
        // Messager should be replaced by a more general
06bc494ca11e Initial load
duke
parents:
diff changeset
   549
        // compilation environment.  This can probably
06bc494ca11e Initial load
duke
parents:
diff changeset
   550
        // subsume DocEnv as well.
06bc494ca11e Initial load
duke
parents:
diff changeset
   551
        messager.exit();
06bc494ca11e Initial load
duke
parents:
diff changeset
   552
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   553
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21891
diff changeset
   554
    protected Map<PackageSymbol, PackageDocImpl> packageMap = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   555
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   556
     * Return the PackageDoc of this package symbol.
06bc494ca11e Initial load
duke
parents:
diff changeset
   557
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   558
    public PackageDocImpl getPackageDoc(PackageSymbol pack) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   559
        PackageDocImpl result = packageMap.get(pack);
06bc494ca11e Initial load
duke
parents:
diff changeset
   560
        if (result != null) return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   561
        result = new PackageDocImpl(this, pack);
06bc494ca11e Initial load
duke
parents:
diff changeset
   562
        packageMap.put(pack, result);
06bc494ca11e Initial load
duke
parents:
diff changeset
   563
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   564
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   565
06bc494ca11e Initial load
duke
parents:
diff changeset
   566
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   567
     * Create the PackageDoc (or a subtype) for a package symbol.
06bc494ca11e Initial load
duke
parents:
diff changeset
   568
     */
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   569
    void makePackageDoc(PackageSymbol pack, TreePath treePath) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   570
        PackageDocImpl result = packageMap.get(pack);
06bc494ca11e Initial load
duke
parents:
diff changeset
   571
        if (result != null) {
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   572
            if (treePath != null) result.setTreePath(treePath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   573
        } else {
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   574
            result = new PackageDocImpl(this, pack, treePath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   575
            packageMap.put(pack, result);
06bc494ca11e Initial load
duke
parents:
diff changeset
   576
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   577
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   578
06bc494ca11e Initial load
duke
parents:
diff changeset
   579
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21891
diff changeset
   580
    protected Map<ClassSymbol, ClassDocImpl> classMap = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   581
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   582
     * Return the ClassDoc (or a subtype) of this class symbol.
06bc494ca11e Initial load
duke
parents:
diff changeset
   583
     */
10189
57268b86d4da 7059905: (javadoc) promote method visibility for netbeans usage
ksrini
parents: 7681
diff changeset
   584
    public ClassDocImpl getClassDoc(ClassSymbol clazz) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   585
        ClassDocImpl result = classMap.get(clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   586
        if (result != null) return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   587
        if (isAnnotationType(clazz)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   588
            result = new AnnotationTypeDocImpl(this, clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   589
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   590
            result = new ClassDocImpl(this, clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   591
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   592
        classMap.put(clazz, result);
06bc494ca11e Initial load
duke
parents:
diff changeset
   593
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   594
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   595
06bc494ca11e Initial load
duke
parents:
diff changeset
   596
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   597
     * Create the ClassDoc (or a subtype) for a class symbol.
06bc494ca11e Initial load
duke
parents:
diff changeset
   598
     */
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   599
    protected void makeClassDoc(ClassSymbol clazz, TreePath treePath) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   600
        ClassDocImpl result = classMap.get(clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   601
        if (result != null) {
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   602
            if (treePath != null) result.setTreePath(treePath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   603
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   604
        }
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   605
        if (isAnnotationType((JCClassDecl) treePath.getLeaf())) {   // flags of clazz may not yet be set
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   606
            result = new AnnotationTypeDocImpl(this, clazz, treePath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   607
        } else {
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   608
            result = new ClassDocImpl(this, clazz, treePath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   609
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   610
        classMap.put(clazz, result);
06bc494ca11e Initial load
duke
parents:
diff changeset
   611
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   612
10189
57268b86d4da 7059905: (javadoc) promote method visibility for netbeans usage
ksrini
parents: 7681
diff changeset
   613
    protected static boolean isAnnotationType(ClassSymbol clazz) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   614
        return ClassDocImpl.isAnnotationType(clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   615
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   616
10189
57268b86d4da 7059905: (javadoc) promote method visibility for netbeans usage
ksrini
parents: 7681
diff changeset
   617
    protected static boolean isAnnotationType(JCClassDecl tree) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   618
        return (tree.mods.flags & Flags.ANNOTATION) != 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   619
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   620
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21891
diff changeset
   621
    protected Map<VarSymbol, FieldDocImpl> fieldMap = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   622
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   623
     * Return the FieldDoc of this var symbol.
06bc494ca11e Initial load
duke
parents:
diff changeset
   624
     */
10189
57268b86d4da 7059905: (javadoc) promote method visibility for netbeans usage
ksrini
parents: 7681
diff changeset
   625
    public FieldDocImpl getFieldDoc(VarSymbol var) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   626
        FieldDocImpl result = fieldMap.get(var);
06bc494ca11e Initial load
duke
parents:
diff changeset
   627
        if (result != null) return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   628
        result = new FieldDocImpl(this, var);
06bc494ca11e Initial load
duke
parents:
diff changeset
   629
        fieldMap.put(var, result);
06bc494ca11e Initial load
duke
parents:
diff changeset
   630
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   631
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   632
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   633
     * Create a FieldDoc for a var symbol.
06bc494ca11e Initial load
duke
parents:
diff changeset
   634
     */
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   635
    protected void makeFieldDoc(VarSymbol var, TreePath treePath) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   636
        FieldDocImpl result = fieldMap.get(var);
06bc494ca11e Initial load
duke
parents:
diff changeset
   637
        if (result != null) {
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   638
            if (treePath != null) result.setTreePath(treePath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   639
        } else {
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   640
            result = new FieldDocImpl(this, var, treePath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   641
            fieldMap.put(var, result);
06bc494ca11e Initial load
duke
parents:
diff changeset
   642
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   643
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   644
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21891
diff changeset
   645
    protected Map<MethodSymbol, ExecutableMemberDocImpl> methodMap = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   646
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   647
     * Create a MethodDoc for this MethodSymbol.
06bc494ca11e Initial load
duke
parents:
diff changeset
   648
     * Should be called only on symbols representing methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   649
     */
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   650
    protected void makeMethodDoc(MethodSymbol meth, TreePath treePath) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   651
        MethodDocImpl result = (MethodDocImpl)methodMap.get(meth);
06bc494ca11e Initial load
duke
parents:
diff changeset
   652
        if (result != null) {
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   653
            if (treePath != null) result.setTreePath(treePath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   654
        } else {
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   655
            result = new MethodDocImpl(this, meth, treePath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   656
            methodMap.put(meth, result);
06bc494ca11e Initial load
duke
parents:
diff changeset
   657
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   658
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   659
06bc494ca11e Initial load
duke
parents:
diff changeset
   660
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   661
     * Return the MethodDoc for a MethodSymbol.
06bc494ca11e Initial load
duke
parents:
diff changeset
   662
     * Should be called only on symbols representing methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   663
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   664
    public MethodDocImpl getMethodDoc(MethodSymbol meth) {
7071
8bcda461a06a 6551367: javadoc throws ClassCastException when an @link tries to reference constructor.
sundar
parents: 5520
diff changeset
   665
        assert !meth.isConstructor() : "not expecting a constructor symbol";
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   666
        MethodDocImpl result = (MethodDocImpl)methodMap.get(meth);
06bc494ca11e Initial load
duke
parents:
diff changeset
   667
        if (result != null) return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   668
        result = new MethodDocImpl(this, meth);
06bc494ca11e Initial load
duke
parents:
diff changeset
   669
        methodMap.put(meth, result);
06bc494ca11e Initial load
duke
parents:
diff changeset
   670
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   671
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   672
06bc494ca11e Initial load
duke
parents:
diff changeset
   673
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   674
     * Create the ConstructorDoc for a MethodSymbol.
06bc494ca11e Initial load
duke
parents:
diff changeset
   675
     * Should be called only on symbols representing constructors.
06bc494ca11e Initial load
duke
parents:
diff changeset
   676
     */
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   677
    protected void makeConstructorDoc(MethodSymbol meth, TreePath treePath) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   678
        ConstructorDocImpl result = (ConstructorDocImpl)methodMap.get(meth);
06bc494ca11e Initial load
duke
parents:
diff changeset
   679
        if (result != null) {
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   680
            if (treePath != null) result.setTreePath(treePath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   681
        } else {
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   682
            result = new ConstructorDocImpl(this, meth, treePath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   683
            methodMap.put(meth, result);
06bc494ca11e Initial load
duke
parents:
diff changeset
   684
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   685
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   686
06bc494ca11e Initial load
duke
parents:
diff changeset
   687
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   688
     * Return the ConstructorDoc for a MethodSymbol.
06bc494ca11e Initial load
duke
parents:
diff changeset
   689
     * Should be called only on symbols representing constructors.
06bc494ca11e Initial load
duke
parents:
diff changeset
   690
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   691
    public ConstructorDocImpl getConstructorDoc(MethodSymbol meth) {
7071
8bcda461a06a 6551367: javadoc throws ClassCastException when an @link tries to reference constructor.
sundar
parents: 5520
diff changeset
   692
        assert meth.isConstructor() : "expecting a constructor symbol";
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   693
        ConstructorDocImpl result = (ConstructorDocImpl)methodMap.get(meth);
06bc494ca11e Initial load
duke
parents:
diff changeset
   694
        if (result != null) return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   695
        result = new ConstructorDocImpl(this, meth);
06bc494ca11e Initial load
duke
parents:
diff changeset
   696
        methodMap.put(meth, result);
06bc494ca11e Initial load
duke
parents:
diff changeset
   697
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   698
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   699
06bc494ca11e Initial load
duke
parents:
diff changeset
   700
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   701
     * Create the AnnotationTypeElementDoc for a MethodSymbol.
06bc494ca11e Initial load
duke
parents:
diff changeset
   702
     * Should be called only on symbols representing annotation type elements.
06bc494ca11e Initial load
duke
parents:
diff changeset
   703
     */
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   704
    protected void makeAnnotationTypeElementDoc(MethodSymbol meth, TreePath treePath) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   705
        AnnotationTypeElementDocImpl result =
06bc494ca11e Initial load
duke
parents:
diff changeset
   706
            (AnnotationTypeElementDocImpl)methodMap.get(meth);
06bc494ca11e Initial load
duke
parents:
diff changeset
   707
        if (result != null) {
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   708
            if (treePath != null) result.setTreePath(treePath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   709
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   710
            result =
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   711
                new AnnotationTypeElementDocImpl(this, meth, treePath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   712
            methodMap.put(meth, result);
06bc494ca11e Initial load
duke
parents:
diff changeset
   713
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   714
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   715
06bc494ca11e Initial load
duke
parents:
diff changeset
   716
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   717
     * Return the AnnotationTypeElementDoc for a MethodSymbol.
06bc494ca11e Initial load
duke
parents:
diff changeset
   718
     * Should be called only on symbols representing annotation type elements.
06bc494ca11e Initial load
duke
parents:
diff changeset
   719
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   720
    public AnnotationTypeElementDocImpl getAnnotationTypeElementDoc(
06bc494ca11e Initial load
duke
parents:
diff changeset
   721
            MethodSymbol meth) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   722
06bc494ca11e Initial load
duke
parents:
diff changeset
   723
        AnnotationTypeElementDocImpl result =
06bc494ca11e Initial load
duke
parents:
diff changeset
   724
            (AnnotationTypeElementDocImpl)methodMap.get(meth);
06bc494ca11e Initial load
duke
parents:
diff changeset
   725
        if (result != null) return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   726
        result = new AnnotationTypeElementDocImpl(this, meth);
06bc494ca11e Initial load
duke
parents:
diff changeset
   727
        methodMap.put(meth, result);
06bc494ca11e Initial load
duke
parents:
diff changeset
   728
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   729
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   730
06bc494ca11e Initial load
duke
parents:
diff changeset
   731
//  private Map<ClassType, ParameterizedTypeImpl> parameterizedTypeMap =
06bc494ca11e Initial load
duke
parents:
diff changeset
   732
//          new HashMap<ClassType, ParameterizedTypeImpl>();
06bc494ca11e Initial load
duke
parents:
diff changeset
   733
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   734
     * Return the ParameterizedType of this instantiation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   735
//   * ### Could use Type.sameTypeAs() instead of equality matching in hashmap
06bc494ca11e Initial load
duke
parents:
diff changeset
   736
//   * ### to avoid some duplication.
06bc494ca11e Initial load
duke
parents:
diff changeset
   737
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   738
    ParameterizedTypeImpl getParameterizedType(ClassType t) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   739
        return new ParameterizedTypeImpl(this, t);
06bc494ca11e Initial load
duke
parents:
diff changeset
   740
//      ParameterizedTypeImpl result = parameterizedTypeMap.get(t);
06bc494ca11e Initial load
duke
parents:
diff changeset
   741
//      if (result != null) return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   742
//      result = new ParameterizedTypeImpl(this, t);
06bc494ca11e Initial load
duke
parents:
diff changeset
   743
//      parameterizedTypeMap.put(t, result);
06bc494ca11e Initial load
duke
parents:
diff changeset
   744
//      return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   745
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   746
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   747
    TreePath getTreePath(JCCompilationUnit tree) {
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   748
        TreePath p = treePaths.get(tree);
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   749
        if (p == null)
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   750
            treePaths.put(tree, p = new TreePath(tree));
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   751
        return p;
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   752
    }
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   753
24069
dfb8f11542fc 8034245: Refactor TopLevel tree node.
pgovereau
parents: 22442
diff changeset
   754
    TreePath getTreePath(JCCompilationUnit toplevel, JCPackageDecl tree) {
dfb8f11542fc 8034245: Refactor TopLevel tree node.
pgovereau
parents: 22442
diff changeset
   755
        TreePath p = treePaths.get(tree);
dfb8f11542fc 8034245: Refactor TopLevel tree node.
pgovereau
parents: 22442
diff changeset
   756
        if (p == null)
dfb8f11542fc 8034245: Refactor TopLevel tree node.
pgovereau
parents: 22442
diff changeset
   757
            treePaths.put(tree, p = new TreePath(getTreePath(toplevel), tree));
dfb8f11542fc 8034245: Refactor TopLevel tree node.
pgovereau
parents: 22442
diff changeset
   758
        return p;
dfb8f11542fc 8034245: Refactor TopLevel tree node.
pgovereau
parents: 22442
diff changeset
   759
    }
dfb8f11542fc 8034245: Refactor TopLevel tree node.
pgovereau
parents: 22442
diff changeset
   760
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   761
    TreePath getTreePath(JCCompilationUnit toplevel, JCClassDecl tree) {
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   762
        TreePath p = treePaths.get(tree);
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   763
        if (p == null)
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   764
            treePaths.put(tree, p = new TreePath(getTreePath(toplevel), tree));
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   765
        return p;
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   766
    }
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   767
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   768
    TreePath getTreePath(JCCompilationUnit toplevel, JCClassDecl cdecl, JCTree tree) {
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   769
        return new TreePath(getTreePath(toplevel, cdecl), tree);
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   770
    }
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14543
diff changeset
   771
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   772
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   773
     * Set the encoding.
06bc494ca11e Initial load
duke
parents:
diff changeset
   774
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   775
    public void setEncoding(String encoding) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   776
        this.encoding = encoding;
06bc494ca11e Initial load
duke
parents:
diff changeset
   777
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   778
06bc494ca11e Initial load
duke
parents:
diff changeset
   779
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   780
     * Get the encoding.
06bc494ca11e Initial load
duke
parents:
diff changeset
   781
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   782
    public String getEncoding() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   783
        return encoding;
06bc494ca11e Initial load
duke
parents:
diff changeset
   784
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   785
06bc494ca11e Initial load
duke
parents:
diff changeset
   786
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   787
     * Convert modifier bits from private coding used by
06bc494ca11e Initial load
duke
parents:
diff changeset
   788
     * the compiler to that of java.lang.reflect.Modifier.
06bc494ca11e Initial load
duke
parents:
diff changeset
   789
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   790
    static int translateModifiers(long flags) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   791
        int result = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   792
        if ((flags & Flags.ABSTRACT) != 0)
06bc494ca11e Initial load
duke
parents:
diff changeset
   793
            result |= Modifier.ABSTRACT;
06bc494ca11e Initial load
duke
parents:
diff changeset
   794
        if ((flags & Flags.FINAL) != 0)
06bc494ca11e Initial load
duke
parents:
diff changeset
   795
            result |= Modifier.FINAL;
06bc494ca11e Initial load
duke
parents:
diff changeset
   796
        if ((flags & Flags.INTERFACE) != 0)
06bc494ca11e Initial load
duke
parents:
diff changeset
   797
            result |= Modifier.INTERFACE;
06bc494ca11e Initial load
duke
parents:
diff changeset
   798
        if ((flags & Flags.NATIVE) != 0)
06bc494ca11e Initial load
duke
parents:
diff changeset
   799
            result |= Modifier.NATIVE;
06bc494ca11e Initial load
duke
parents:
diff changeset
   800
        if ((flags & Flags.PRIVATE) != 0)
06bc494ca11e Initial load
duke
parents:
diff changeset
   801
            result |= Modifier.PRIVATE;
06bc494ca11e Initial load
duke
parents:
diff changeset
   802
        if ((flags & Flags.PROTECTED) != 0)
06bc494ca11e Initial load
duke
parents:
diff changeset
   803
            result |= Modifier.PROTECTED;
06bc494ca11e Initial load
duke
parents:
diff changeset
   804
        if ((flags & Flags.PUBLIC) != 0)
06bc494ca11e Initial load
duke
parents:
diff changeset
   805
            result |= Modifier.PUBLIC;
06bc494ca11e Initial load
duke
parents:
diff changeset
   806
        if ((flags & Flags.STATIC) != 0)
06bc494ca11e Initial load
duke
parents:
diff changeset
   807
            result |= Modifier.STATIC;
06bc494ca11e Initial load
duke
parents:
diff changeset
   808
        if ((flags & Flags.SYNCHRONIZED) != 0)
06bc494ca11e Initial load
duke
parents:
diff changeset
   809
            result |= Modifier.SYNCHRONIZED;
06bc494ca11e Initial load
duke
parents:
diff changeset
   810
        if ((flags & Flags.TRANSIENT) != 0)
06bc494ca11e Initial load
duke
parents:
diff changeset
   811
            result |= Modifier.TRANSIENT;
06bc494ca11e Initial load
duke
parents:
diff changeset
   812
        if ((flags & Flags.VOLATILE) != 0)
06bc494ca11e Initial load
duke
parents:
diff changeset
   813
            result |= Modifier.VOLATILE;
06bc494ca11e Initial load
duke
parents:
diff changeset
   814
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   815
    }
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   816
21500
475e59d3b40c 8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents: 19912
diff changeset
   817
    void initDoclint(Collection<String> opts, Collection<String> customTagNames) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21891
diff changeset
   818
        ArrayList<String> doclintOpts = new ArrayList<>();
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   819
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   820
        for (String opt: opts) {
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   821
            doclintOpts.add(opt == null ? DocLint.XMSGS_OPTION : DocLint.XMSGS_CUSTOM_PREFIX + opt);
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   822
        }
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   823
15713
55f55d4f5f9f 8007610: javadoc doclint does not work with -private
jjg
parents: 15354
diff changeset
   824
        if (doclintOpts.isEmpty()) {
55f55d4f5f9f 8007610: javadoc doclint does not work with -private
jjg
parents: 15354
diff changeset
   825
            doclintOpts.add(DocLint.XMSGS_OPTION);
55f55d4f5f9f 8007610: javadoc doclint does not work with -private
jjg
parents: 15354
diff changeset
   826
        } else if (doclintOpts.size() == 1
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   827
                && doclintOpts.get(0).equals(DocLint.XMSGS_CUSTOM_PREFIX + "none")) {
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   828
            return;
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   829
        }
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   830
21500
475e59d3b40c 8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents: 19912
diff changeset
   831
        String sep = "";
475e59d3b40c 8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents: 19912
diff changeset
   832
        StringBuilder customTags = new StringBuilder();
475e59d3b40c 8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents: 19912
diff changeset
   833
        for (String customTag : customTagNames) {
475e59d3b40c 8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents: 19912
diff changeset
   834
            customTags.append(sep);
475e59d3b40c 8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents: 19912
diff changeset
   835
            customTags.append(customTag);
475e59d3b40c 8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents: 19912
diff changeset
   836
            sep = DocLint.TAGS_SEPARATOR;
475e59d3b40c 8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents: 19912
diff changeset
   837
        }
475e59d3b40c 8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents: 19912
diff changeset
   838
        doclintOpts.add(DocLint.XCUSTOM_TAGS_PREFIX + customTags.toString());
475e59d3b40c 8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents: 19912
diff changeset
   839
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   840
        JavacTask t = BasicJavacTask.instance(context);
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   841
        doclint = new DocLint();
16799
fbe4d27b8791 8006346: doclint should make allowance for headers generated by standard doclet
jjg
parents: 15713
diff changeset
   842
        // standard doclet normally generates H1, H2
fbe4d27b8791 8006346: doclint should make allowance for headers generated by standard doclet
jjg
parents: 15713
diff changeset
   843
        doclintOpts.add(DocLint.XIMPLICIT_HEADERS + "2");
15354
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   844
        doclint.init(t, doclintOpts.toArray(new String[doclintOpts.size()]), false);
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   845
    }
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   846
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   847
    boolean showTagMessages() {
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   848
        return (doclint == null);
52a04c670c05 8004834: Add doclint support into javadoc
jjg
parents: 14802
diff changeset
   849
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   850
}