src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ExecutableMemberDocImpl.java
author ksrini
Fri, 09 Feb 2018 13:58:17 -0800
changeset 48840 5e2d2067da48
parent 47216 71c04702a3d5
permissions -rw-r--r--
8194651: javadoc: mark the com.sun.javadoc API for removal Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
48840
5e2d2067da48 8194651: javadoc: mark the com.sun.javadoc API for removal
ksrini
parents: 47216
diff changeset
     2
 * Copyright (c) 1997, 2018, 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: 2212
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: 2212
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: 2212
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
37938
42baa89d2156 8075703: jdk.javadoc module exports com.sun.tools.javadoc package which contains a lot of internal API.
jjg
parents: 25874
diff changeset
    26
package com.sun.tools.javadoc.main;
10
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
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14260
diff changeset
    33
import com.sun.source.util.TreePath;
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1264
diff changeset
    34
import com.sun.tools.javac.code.Flags;
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1264
diff changeset
    35
import com.sun.tools.javac.code.Symbol.*;
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1264
diff changeset
    36
import com.sun.tools.javac.code.Type;
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
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * Represents a method or constructor of a java class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 8631
diff changeset
    43
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 8631
diff changeset
    44
 *  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: 8631
diff changeset
    45
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 8631
diff changeset
    46
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 8631
diff changeset
    47
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * @since 1.2
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 * @author Neal Gafter (rewrite)
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 * @author Scott Seligman (generics, annotations)
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
48840
5e2d2067da48 8194651: javadoc: mark the com.sun.javadoc API for removal
ksrini
parents: 47216
diff changeset
    54
@Deprecated(since="9", forRemoval=true)
5e2d2067da48 8194651: javadoc: mark the com.sun.javadoc API for removal
ksrini
parents: 47216
diff changeset
    55
@SuppressWarnings("removal")
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
public abstract class ExecutableMemberDocImpl
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
        extends MemberDocImpl implements ExecutableMemberDoc {
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    protected final MethodSymbol sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     * Constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     */
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14260
diff changeset
    64
    public ExecutableMemberDocImpl(DocEnv env, MethodSymbol sym, TreePath treePath) {
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14260
diff changeset
    65
        super(env, sym, treePath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
        this.sym = sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     * Constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    public ExecutableMemberDocImpl(DocEnv env, MethodSymbol sym) {
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14260
diff changeset
    73
        this(env, sym, null);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     * Returns the flags in terms of javac's flags
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
    protected long getFlags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
        return sym.flags();
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     * Identify the containing class
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    protected ClassSymbol getContainingClass() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
        return sym.enclClass();
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * Return true if this method is native
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    public boolean isNative() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
        return Modifier.isNative(getModifiers());
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     * Return true if this method is synchronized
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    public boolean isSynchronized() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        return Modifier.isSynchronized(getModifiers());
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     * Return true if this method was declared to take a variable number
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     * of arguments.
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    public boolean isVarArgs() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        return ((sym.flags() & Flags.VARARGS) != 0
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
                && !env.legacyDoclet);
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     * Returns true if this field was synthesized by the compiler.
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
    public boolean isSynthetic() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
        return ((sym.flags() & Flags.SYNTHETIC) != 0);
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
    public boolean isIncluded() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        return containingClass().isIncluded() && env.shouldDocument(sym);
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
     * Return the throws tags in this method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     * @return an array of ThrowTagImpl containing all {@code @exception}
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     * and {@code @throws} tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    public ThrowsTag[] throwsTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        return comment().throwsTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     * Return the param tags in this method, excluding the type
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     * parameter tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     * @return an array of ParamTagImpl containing all {@code @param} tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    public ParamTag[] paramTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        return comment().paramTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
     * Return the type parameter tags in this method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
    public ParamTag[] typeParamTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
        return env.legacyDoclet
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
            ? new ParamTag[0]
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
            : comment().typeParamTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
     * Return exceptions this method or constructor throws.
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     * @return an array of ClassDoc[] representing the exceptions
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
     * thrown by this method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
    public ClassDoc[] thrownExceptions() {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 17578
diff changeset
   160
        ListBuffer<ClassDocImpl> l = new ListBuffer<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        for (Type ex : sym.type.getThrownTypes()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
            ex = env.types.erasure(ex);
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
            //### Will these casts succeed in the face of static semantic
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
            //### errors in the documented code?
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
            ClassDocImpl cdi = env.getClassDoc((ClassSymbol)ex.tsym);
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
            if (cdi != null) l.append(cdi);
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        return l.toArray(new ClassDocImpl[l.length()]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
     * Return exceptions this method or constructor throws.
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
     * Each array element is either a <code>ClassDoc</code> or a
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
     * <code>TypeVariable</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
    public com.sun.javadoc.Type[] thrownExceptionTypes() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
        return TypeMaker.getTypes(env, sym.type.getThrownTypes());
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
     * Get argument information.
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     * @see ParameterImpl
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
     * @return an array of ParameterImpl, one element per argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
     * in the order the arguments are present.
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
    public Parameter[] parameters() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        // generate the parameters on the fly:  they're not cached
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
        List<VarSymbol> params = sym.params();
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
        Parameter result[] = new Parameter[params.length()];
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
        int i = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
        for (VarSymbol param : params) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
            result[i++] = new ParameterImpl(env, param);
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
16964
096de5815398 8005091: javadoc should be able to return the receiver type
bpatel
parents: 16556
diff changeset
   200
    /**
096de5815398 8005091: javadoc should be able to return the receiver type
bpatel
parents: 16556
diff changeset
   201
     * Get the receiver type of this executable element.
096de5815398 8005091: javadoc should be able to return the receiver type
bpatel
parents: 16556
diff changeset
   202
     *
096de5815398 8005091: javadoc should be able to return the receiver type
bpatel
parents: 16556
diff changeset
   203
     * @return the receiver type of this executable element.
096de5815398 8005091: javadoc should be able to return the receiver type
bpatel
parents: 16556
diff changeset
   204
     * @since 1.8
096de5815398 8005091: javadoc should be able to return the receiver type
bpatel
parents: 16556
diff changeset
   205
     */
096de5815398 8005091: javadoc should be able to return the receiver type
bpatel
parents: 16556
diff changeset
   206
    public com.sun.javadoc.Type receiverType() {
096de5815398 8005091: javadoc should be able to return the receiver type
bpatel
parents: 16556
diff changeset
   207
        Type recvtype = sym.type.asMethodType().recvtype;
096de5815398 8005091: javadoc should be able to return the receiver type
bpatel
parents: 16556
diff changeset
   208
        return (recvtype != null) ? TypeMaker.getType(env, recvtype, false, true) : null;
096de5815398 8005091: javadoc should be able to return the receiver type
bpatel
parents: 16556
diff changeset
   209
    }
096de5815398 8005091: javadoc should be able to return the receiver type
bpatel
parents: 16556
diff changeset
   210
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
     * Return the formal type parameters of this method or constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
     * Return an empty array if there are none.
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
    public TypeVariable[] typeParameters() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
        if (env.legacyDoclet) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
            return new TypeVariable[0];
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        TypeVariable res[] = new TypeVariable[sym.type.getTypeArguments().length()];
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
        TypeMaker.getTypes(env, sym.type.getTypeArguments(), res);
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
        return res;
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
     * Get the signature. It is the parameter list, type is qualified.
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
     * For instance, for a method <code>mymethod(String x, int y)</code>,
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
     * it will return <code>(java.lang.String,int)</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
    public String signature() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
        return makeSignature(true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
     * Get flat signature.  All types are not qualified.
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
     * Return a String, which is the flat signiture of this member.
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
     * It is the parameter list, type is not qualified.
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
     * For instance, for a method <code>mymethod(String x, int y)</code>,
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
     * it will return <code>(String, int)</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
    public String flatSignature() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
        return makeSignature(false);
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
    private String makeSignature(boolean full) {
8631
664f84942e74 6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents: 5520
diff changeset
   245
        StringBuilder result = new StringBuilder();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
        result.append("(");
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
        for (List<Type> types = sym.type.getParameterTypes(); types.nonEmpty(); ) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   248
            Type t = types.head;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
            result.append(TypeMaker.getTypeString(env, t, full));
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
            types = types.tail;
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
            if (types.nonEmpty()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
                result.append(", ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
        if (isVarArgs()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
            int len = result.length();
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
            result.replace(len - 2, len, "...");
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
        result.append(")");
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
        return result.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
    protected String typeParametersString() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
        return TypeMaker.typeParametersString(env, sym, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
     * Generate a key for sorting.
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
     */
8631
664f84942e74 6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents: 5520
diff changeset
   270
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
    CollationKey generateKey() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
        String k = name() + flatSignature() + typeParametersString();
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
        // ',' and '&' are between '$' and 'a':  normalize to spaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
        k = k.replace(',', ' ').replace('&', ' ');
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
        // System.out.println("COLLATION KEY FOR " + this + " is \"" + k + "\"");
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
        return env.doclocale.collator.getCollationKey(k);
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
     * Return the source position of the entity, or null if
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
     * no position is available.
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
     */
8631
664f84942e74 6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents: 5520
diff changeset
   283
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
    public SourcePosition position() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
        if (sym.enclClass().sourcefile == null) return null;
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1264
diff changeset
   286
        return SourcePositionImpl.make(sym.enclClass().sourcefile,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
                                       (tree==null) ? 0 : tree.pos,
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
                                       lineMap);
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
}