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