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