langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java
author xdono
Mon, 09 Mar 2009 13:29:06 -0700
changeset 2212 1d3dc0e0ba0c
parent 1869 0e193a8f3520
child 5520 86e4b9a9da40
permissions -rw-r--r--
6814575: Update copyright year Summary: Update copyright for files that have been modified in 2009, up to 03/09 Reviewed-by: katleman, tbell, ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
2212
1d3dc0e0ba0c 6814575: Update copyright year
xdono
parents: 1869
diff changeset
     2
 * Copyright 1997-2009 Sun Microsystems, Inc.  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
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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;
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1264
diff changeset
    29
import java.text.CollationKey;
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1264
diff changeset
    30
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1264
diff changeset
    33
import com.sun.tools.javac.code.Flags;
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1264
diff changeset
    34
import com.sun.tools.javac.code.Symbol.*;
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1264
diff changeset
    35
import com.sun.tools.javac.code.Type;
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1264
diff changeset
    36
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
import com.sun.tools.javac.util.List;
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
import com.sun.tools.javac.util.ListBuffer;
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
import com.sun.tools.javac.util.Position;
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * Represents a method or constructor of a java class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * @since 1.2
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * @author Neal Gafter (rewrite)
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * @author Scott Seligman (generics, annotations)
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
public abstract class ExecutableMemberDocImpl
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
        extends MemberDocImpl implements ExecutableMemberDoc {
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    protected final MethodSymbol sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     * Constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    public ExecutableMemberDocImpl(DocEnv env, MethodSymbol sym,
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
                                   String rawDocs, JCMethodDecl tree, Position.LineMap lineMap) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
        super(env, sym, rawDocs, tree, lineMap);
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
        this.sym = sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     * Constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    public ExecutableMemberDocImpl(DocEnv env, MethodSymbol sym) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
        this(env, sym, null, null, null);
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     * Returns the flags in terms of javac's flags
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    protected long getFlags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        return sym.flags();
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * Identify the containing class
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    protected ClassSymbol getContainingClass() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
        return sym.enclClass();
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     * Return true if this method is native
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    public boolean isNative() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
        return Modifier.isNative(getModifiers());
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     * Return true if this method is synchronized
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    public boolean isSynchronized() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
        return Modifier.isSynchronized(getModifiers());
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     * Return true if this method was declared to take a variable number
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     * of arguments.
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    public boolean isVarArgs() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
        return ((sym.flags() & Flags.VARARGS) != 0
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
                && !env.legacyDoclet);
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     * Returns true if this field was synthesized by the compiler.
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
    public boolean isSynthetic() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
        return ((sym.flags() & Flags.SYNTHETIC) != 0);
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
    public boolean isIncluded() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
        return containingClass().isIncluded() && env.shouldDocument(sym);
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     * Return the throws tags in this method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     * @return an array of ThrowTagImpl containing all {@code @exception}
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     * and {@code @throws} tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
    public ThrowsTag[] throwsTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        return comment().throwsTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     * Return the param tags in this method, excluding the type
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     * parameter tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * @return an array of ParamTagImpl containing all {@code @param} tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    public ParamTag[] paramTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
        return comment().paramTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     * Return the type parameter tags in this method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    public ParamTag[] typeParamTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        return env.legacyDoclet
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
            ? new ParamTag[0]
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
            : comment().typeParamTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
     * Return exceptions this method or constructor throws.
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     * @return an array of ClassDoc[] representing the exceptions
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     * thrown by this method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
    public ClassDoc[] thrownExceptions() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        ListBuffer<ClassDocImpl> l = new ListBuffer<ClassDocImpl>();
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        for (Type ex : sym.type.getThrownTypes()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
            ex = env.types.erasure(ex);
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
            //### Will these casts succeed in the face of static semantic
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
            //### errors in the documented code?
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
            ClassDocImpl cdi = env.getClassDoc((ClassSymbol)ex.tsym);
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
            if (cdi != null) l.append(cdi);
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        return l.toArray(new ClassDocImpl[l.length()]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     * Return exceptions this method or constructor throws.
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     * Each array element is either a <code>ClassDoc</code> or a
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     * <code>TypeVariable</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    public com.sun.javadoc.Type[] thrownExceptionTypes() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
        return TypeMaker.getTypes(env, sym.type.getThrownTypes());
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
     * Get argument information.
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
     * @see ParameterImpl
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
     * @return an array of ParameterImpl, one element per argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
     * in the order the arguments are present.
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
    public Parameter[] parameters() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
        // generate the parameters on the fly:  they're not cached
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
        List<VarSymbol> params = sym.params();
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        Parameter result[] = new Parameter[params.length()];
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
        int i = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        for (VarSymbol param : params) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
            result[i++] = new ParameterImpl(env, param);
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
     * Return the formal type parameters of this method or constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     * Return an empty array if there are none.
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
    public TypeVariable[] typeParameters() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
        if (env.legacyDoclet) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
            return new TypeVariable[0];
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        TypeVariable res[] = new TypeVariable[sym.type.getTypeArguments().length()];
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
        TypeMaker.getTypes(env, sym.type.getTypeArguments(), res);
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
        return res;
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
     * Get the signature. It is the parameter list, type is qualified.
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
     * For instance, for a method <code>mymethod(String x, int y)</code>,
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
     * it will return <code>(java.lang.String,int)</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
    public String signature() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
        return makeSignature(true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
     * Get flat signature.  All types are not qualified.
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
     * Return a String, which is the flat signiture of this member.
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
     * It is the parameter list, type is not qualified.
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
     * For instance, for a method <code>mymethod(String x, int y)</code>,
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
     * it will return <code>(String, int)</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
    public String flatSignature() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
        return makeSignature(false);
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
    private String makeSignature(boolean full) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
        StringBuffer result = new StringBuffer();
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
        result.append("(");
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
        for (List<Type> types = sym.type.getParameterTypes(); types.nonEmpty(); ) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   232
            Type t = types.head;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
            result.append(TypeMaker.getTypeString(env, t, full));
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
            types = types.tail;
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
            if (types.nonEmpty()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
                result.append(", ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
        if (isVarArgs()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
            int len = result.length();
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
            result.replace(len - 2, len, "...");
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
        result.append(")");
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
        return result.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
    protected String typeParametersString() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
        return TypeMaker.typeParametersString(env, sym, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
     * Generate a key for sorting.
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
    CollationKey generateKey() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
        String k = name() + flatSignature() + typeParametersString();
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
        // ',' and '&' are between '$' and 'a':  normalize to spaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
        k = k.replace(',', ' ').replace('&', ' ');
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
        // System.out.println("COLLATION KEY FOR " + this + " is \"" + k + "\"");
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
        return env.doclocale.collator.getCollationKey(k);
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
     * Return the source position of the entity, or null if
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
     * no position is available.
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
    public SourcePosition position() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
        if (sym.enclClass().sourcefile == null) return null;
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1264
diff changeset
   268
        return SourcePositionImpl.make(sym.enclClass().sourcefile,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
                                       (tree==null) ? 0 : tree.pos,
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
                                       lineMap);
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
}