Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java
38899 views
/*1* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.tools.javadoc;2627import javax.tools.JavaFileObject;2829import com.sun.tools.javac.code.Kinds;30import com.sun.tools.javac.code.Symbol.*;31import com.sun.tools.javac.comp.Enter;32import com.sun.tools.javac.tree.JCTree.*;33import com.sun.tools.javac.util.Context;34import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;35import com.sun.tools.javac.util.List;3637/**38* Javadoc's own enter phase does a few things above and beyond that39* done by javac.40*41* <p><b>This is NOT part of any supported API.42* If you write code that depends on this, you do so at your own risk.43* This code and its internal interfaces are subject to change or44* deletion without notice.</b>45*46* @author Neal Gafter47*/48public class JavadocEnter extends Enter {49public static JavadocEnter instance0(Context context) {50Enter instance = context.get(enterKey);51if (instance == null)52instance = new JavadocEnter(context);53return (JavadocEnter)instance;54}5556public static void preRegister(Context context) {57context.put(enterKey, new Context.Factory<Enter>() {58public Enter make(Context c) {59return new JavadocEnter(c);60}61});62}6364protected JavadocEnter(Context context) {65super(context);66messager = Messager.instance0(context);67docenv = DocEnv.instance(context);68}6970final Messager messager;71final DocEnv docenv;7273@Override74public void main(List<JCCompilationUnit> trees) {75// count all Enter errors as warnings.76int nerrors = messager.nerrors;77super.main(trees);78messager.nwarnings += (messager.nerrors - nerrors);79messager.nerrors = nerrors;80}8182@Override83public void visitTopLevel(JCCompilationUnit tree) {84super.visitTopLevel(tree);85if (tree.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {86docenv.makePackageDoc(tree.packge, docenv.getTreePath(tree));87}88}8990@Override91public void visitClassDef(JCClassDecl tree) {92super.visitClassDef(tree);93if (tree.sym == null) return;94if (tree.sym.kind == Kinds.TYP || tree.sym.kind == Kinds.ERR) {95ClassSymbol c = tree.sym;96docenv.makeClassDoc(c, docenv.getTreePath(env.toplevel, tree));97}98}99100/** Don't complain about a duplicate class. */101@Override102protected void duplicateClass(DiagnosticPosition pos, ClassSymbol c) {}103104}105106107