src/share/classes/com/sun/tools/javadoc/ParameterImpl.java

Mon, 27 Sep 2010 14:20:39 -0700

author
jjg
date
Mon, 27 Sep 2010 14:20:39 -0700
changeset 695
3c9b64e55c5d
parent 554
9d9f26857129
child 1357
c75be5bc5283
permissions
-rw-r--r--

6877202: Elements.getDocComment() is not getting JavaDocComments
6861094: javac -Xprint <file> does not print comments
6985205: access to tree positions and doc comments may be lost across annotation processing rounds
Reviewed-by: darcy

     1 /*
     2  * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.tools.javadoc;
    28 import com.sun.javadoc.*;
    30 import com.sun.tools.javac.code.Attribute;
    31 import com.sun.tools.javac.code.Symbol.VarSymbol;
    32 import com.sun.tools.javac.code.Type;
    34 /**
    35  * ParameterImpl information.
    36  * This includes a parameter type and parameter name.
    37  *
    38  * @author Kaiyang Liu (original)
    39  * @author Robert Field (rewrite)
    40  * @author Scott Seligman (generics, annotations)
    41  */
    42 class ParameterImpl implements Parameter {
    44     private final DocEnv env;
    45     private final VarSymbol sym;
    46     private final com.sun.javadoc.Type type;
    48     /**
    49      * Constructor of parameter info class.
    50      */
    51     ParameterImpl(DocEnv env, VarSymbol sym) {
    52         this.env = env;
    53         this.sym = sym;
    54         this.type = TypeMaker.getType(env, sym.type, false);
    55     }
    57     /**
    58      * Get the type of this parameter.
    59      */
    60     public com.sun.javadoc.Type type() {
    61         return type;
    62     }
    64     /**
    65      * Get local name of this parameter.
    66      * For example if parameter is the short 'index', returns "index".
    67      */
    68     public String name() {
    69         return sym.toString();
    70     }
    72     /**
    73      * Get type name of this parameter.
    74      * For example if parameter is the short 'index', returns "short".
    75      */
    76     public String typeName() {
    77         return (type instanceof ClassDoc || type instanceof TypeVariable)
    78                 ? type.typeName()       // omit formal type params or bounds
    79                 : type.toString();
    80     }
    82     /**
    83      * Returns a string representation of the parameter.
    84      * <p>
    85      * For example if parameter is the short 'index', returns "short index".
    86      *
    87      * @return type name and parameter name of this parameter.
    88      */
    89     public String toString() {
    90         return typeName() + " " + sym;
    91     }
    93     /**
    94      * Get the annotations of this parameter.
    95      * Return an empty array if there are none.
    96      */
    97     public AnnotationDesc[] annotations() {
    98         AnnotationDesc res[] = new AnnotationDesc[sym.getAnnotationMirrors().length()];
    99         int i = 0;
   100         for (Attribute.Compound a : sym.getAnnotationMirrors()) {
   101             res[i++] = new AnnotationDescImpl(env, a);
   102         }
   103         return res;
   104     }
   105 }

mercurial