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