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

Tue, 25 May 2010 15:54:51 -0700

author
ohair
date
Tue, 25 May 2010 15:54:51 -0700
changeset 554
9d9f26857129
parent 117
24a47c3062fe
child 893
8f0dcb9499db
permissions
-rw-r--r--

6943119: Rebrand source copyright notices
Reviewed-by: darcy

     1 /*
     2  * Copyright (c) 2003, 2008, 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.tools.javac.util.Context;
    29 import com.sun.tools.javac.util.Position;
    30 import com.sun.tools.javac.code.Flags;
    31 import com.sun.tools.javac.code.Kinds;
    32 import com.sun.tools.javac.code.Symbol.*;
    33 import com.sun.tools.javac.comp.MemberEnter;
    34 import com.sun.tools.javac.tree.JCTree.*;
    36 /**
    37  *  Javadoc's own memberEnter phase does a few things above and beyond that
    38  *  done by javac.
    39  *  @author Neal Gafter
    40  */
    41 class JavadocMemberEnter extends MemberEnter {
    42     public static JavadocMemberEnter instance0(Context context) {
    43         MemberEnter instance = context.get(memberEnterKey);
    44         if (instance == null)
    45             instance = new JavadocMemberEnter(context);
    46         return (JavadocMemberEnter)instance;
    47     }
    49     public static void preRegister(final Context context) {
    50         context.put(memberEnterKey, new Context.Factory<MemberEnter>() {
    51                public MemberEnter make() {
    52                    return new JavadocMemberEnter(context);
    53                }
    54         });
    55     }
    57     final DocEnv docenv;
    59     protected JavadocMemberEnter(Context context) {
    60         super(context);
    61         docenv = DocEnv.instance(context);
    62     }
    64     public void visitMethodDef(JCMethodDecl tree) {
    65         super.visitMethodDef(tree);
    66         MethodSymbol meth = tree.sym;
    67         if (meth == null || meth.kind != Kinds.MTH) return;
    68         String docComment = env.toplevel.docComments.get(tree);
    69         Position.LineMap lineMap = env.toplevel.lineMap;
    70         if (meth.isConstructor())
    71             docenv.makeConstructorDoc(meth, docComment, tree, lineMap);
    72         else if (isAnnotationTypeElement(meth))
    73             docenv.makeAnnotationTypeElementDoc(meth, docComment, tree, lineMap);
    74         else
    75             docenv.makeMethodDoc(meth, docComment, tree, lineMap);
    76     }
    78     public void visitVarDef(JCVariableDecl tree) {
    79         super.visitVarDef(tree);
    80         if (tree.sym != null &&
    81                 tree.sym.kind == Kinds.VAR &&
    82                 !isParameter(tree.sym)) {
    83             String docComment = env.toplevel.docComments.get(tree);
    84             Position.LineMap lineMap = env.toplevel.lineMap;
    85             docenv.makeFieldDoc(tree.sym, docComment, tree, lineMap);
    86         }
    87     }
    89     private static boolean isAnnotationTypeElement(MethodSymbol meth) {
    90         return ClassDocImpl.isAnnotationType(meth.enclClass());
    91     }
    93     private static boolean isParameter(VarSymbol var) {
    94         return (var.flags() & Flags.PARAMETER) != 0;
    95     }
    96 }

mercurial