langtools/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java
changeset 10203 cca843a7d258
parent 8614 06e42328ddab
child 13077 16fb753bb5dc
equal deleted inserted replaced
10202:f32c7f2c2219 10203:cca843a7d258
    29 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
    29 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
    30 import com.sun.tools.javac.util.List;
    30 import com.sun.tools.javac.util.List;
    31 import com.sun.tools.javac.code.Kinds;
    31 import com.sun.tools.javac.code.Kinds;
    32 import com.sun.tools.javac.code.Symbol.*;
    32 import com.sun.tools.javac.code.Symbol.*;
    33 import com.sun.tools.javac.comp.Enter;
    33 import com.sun.tools.javac.comp.Enter;
    34 import com.sun.tools.javac.tree.JCTree;
       
    35 import com.sun.tools.javac.tree.JCTree.*;
    34 import com.sun.tools.javac.tree.JCTree.*;
    36 import javax.tools.JavaFileObject;
    35 import javax.tools.JavaFileObject;
    37 
    36 
    38 /**
    37 /**
    39  *  Javadoc's own enter phase does a few things above and beyond that
    38  *  Javadoc's own enter phase does a few things above and beyond that
    63     }
    62     }
    64 
    63 
    65     final Messager messager;
    64     final Messager messager;
    66     final DocEnv docenv;
    65     final DocEnv docenv;
    67 
    66 
       
    67     @Override
    68     public void main(List<JCCompilationUnit> trees) {
    68     public void main(List<JCCompilationUnit> trees) {
    69         // count all Enter errors as warnings.
    69         // count all Enter errors as warnings.
    70         int nerrors = messager.nerrors;
    70         int nerrors = messager.nerrors;
    71         super.main(trees);
    71         super.main(trees);
    72         messager.nwarnings += (messager.nerrors - nerrors);
    72         messager.nwarnings += (messager.nerrors - nerrors);
    73         messager.nerrors = nerrors;
    73         messager.nerrors = nerrors;
    74     }
    74     }
    75 
    75 
       
    76     @Override
    76     public void visitTopLevel(JCCompilationUnit tree) {
    77     public void visitTopLevel(JCCompilationUnit tree) {
    77         super.visitTopLevel(tree);
    78         super.visitTopLevel(tree);
    78         if (tree.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {
    79         if (tree.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {
    79             String comment = tree.docComments.get(tree);
    80             String comment = tree.docComments.get(tree);
    80             docenv.makePackageDoc(tree.packge, comment, tree);
    81             docenv.makePackageDoc(tree.packge, comment, tree);
    81         }
    82         }
    82     }
    83     }
    83 
    84 
       
    85     @Override
    84     public void visitClassDef(JCClassDecl tree) {
    86     public void visitClassDef(JCClassDecl tree) {
    85         super.visitClassDef(tree);
    87         super.visitClassDef(tree);
    86         if (tree.sym != null && tree.sym.kind == Kinds.TYP) {
    88         if (tree.sym == null) return;
    87             if (tree.sym == null) return;
    89         if (tree.sym.kind == Kinds.TYP || tree.sym.kind == Kinds.ERR) {
    88             String comment = env.toplevel.docComments.get(tree);
    90             String comment = env.toplevel.docComments.get(tree);
    89             ClassSymbol c = tree.sym;
    91             ClassSymbol c = tree.sym;
    90             docenv.makeClassDoc(c, comment, tree, env.toplevel.lineMap);
    92             docenv.makeClassDoc(c, comment, tree, env.toplevel.lineMap);
    91         }
    93         }
    92     }
    94     }
    93 
    95 
    94     /** Don't complain about a duplicate class. */
    96     /** Don't complain about a duplicate class. */
       
    97     @Override
    95     protected void duplicateClass(DiagnosticPosition pos, ClassSymbol c) {}
    98     protected void duplicateClass(DiagnosticPosition pos, ClassSymbol c) {}
    96 
    99 
    97 }
   100 }