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

Thu, 02 Oct 2008 19:58:40 -0700

author
xdono
date
Thu, 02 Oct 2008 19:58:40 -0700
changeset 117
24a47c3062fe
parent 74
5a9172b251dd
child 554
9d9f26857129
permissions
-rw-r--r--

6754988: Update copyright year
Summary: Update for files that have been modified starting July 2008
Reviewed-by: ohair, tbell

     1 /*
     2  * Copyright 2001-2008 Sun Microsystems, Inc.  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.  Sun designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
    23  * have any questions.
    24  */
    26 package com.sun.tools.javadoc;
    28 import com.sun.tools.javac.util.Context;
    29 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
    30 import com.sun.tools.javac.util.List;
    31 import com.sun.tools.javac.code.Kinds;
    32 import com.sun.tools.javac.code.Symbol.*;
    33 import com.sun.tools.javac.comp.Enter;
    34 import com.sun.tools.javac.tree.JCTree;
    35 import com.sun.tools.javac.tree.JCTree.*;
    36 import javax.tools.JavaFileObject;
    38 /**
    39  *  Javadoc's own enter phase does a few things above and beyond that
    40  *  done by javac.
    41  *  @author Neal Gafter
    42  */
    43 public class JavadocEnter extends Enter {
    44     public static JavadocEnter instance0(Context context) {
    45         Enter instance = context.get(enterKey);
    46         if (instance == null)
    47             instance = new JavadocEnter(context);
    48         return (JavadocEnter)instance;
    49     }
    51     public static void preRegister(final Context context) {
    52         context.put(enterKey, new Context.Factory<Enter>() {
    53                public Enter make() {
    54                    return new JavadocEnter(context);
    55                }
    56         });
    57     }
    59     protected JavadocEnter(Context context) {
    60         super(context);
    61         messager = Messager.instance0(context);
    62         docenv = DocEnv.instance(context);
    63     }
    65     final Messager messager;
    66     final DocEnv docenv;
    68     public void main(List<JCCompilationUnit> trees) {
    69         // count all Enter errors as warnings.
    70         int nerrors = messager.nerrors;
    71         super.main(trees);
    72         messager.nwarnings += (messager.nerrors - nerrors);
    73         messager.nerrors = nerrors;
    74     }
    76     public void visitTopLevel(JCCompilationUnit tree) {
    77         super.visitTopLevel(tree);
    78         if (tree.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {
    79             String comment = tree.docComments.get(tree);
    80             docenv.makePackageDoc(tree.packge, comment, tree);
    81         }
    82     }
    84     public void visitClassDef(JCClassDecl tree) {
    85         super.visitClassDef(tree);
    86         if (tree.sym != null && tree.sym.kind == Kinds.TYP) {
    87             if (tree.sym == null) return;
    88             String comment = env.toplevel.docComments.get(tree);
    89             ClassSymbol c = tree.sym;
    90             docenv.makeClassDoc(c, comment, tree, env.toplevel.lineMap);
    91         }
    92     }
    94     /** Don't complain about a duplicate class. */
    95     protected void duplicateClass(DiagnosticPosition pos, ClassSymbol c) {}
    97 }

mercurial