langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java
changeset 45504 ea7475564d07
parent 43760 bdbe9f1571f0
equal deleted inserted replaced
45503:d23ae2d67a5d 45504:ea7475564d07
    37 import com.sun.tools.javac.code.Scope.*;
    37 import com.sun.tools.javac.code.Scope.*;
    38 import com.sun.tools.javac.code.Symbol.*;
    38 import com.sun.tools.javac.code.Symbol.*;
    39 import com.sun.tools.javac.code.Type.*;
    39 import com.sun.tools.javac.code.Type.*;
    40 import com.sun.tools.javac.main.Option.PkgInfo;
    40 import com.sun.tools.javac.main.Option.PkgInfo;
    41 import com.sun.tools.javac.resources.CompilerProperties.Errors;
    41 import com.sun.tools.javac.resources.CompilerProperties.Errors;
       
    42 import com.sun.tools.javac.resources.CompilerProperties.Warnings;
    42 import com.sun.tools.javac.tree.*;
    43 import com.sun.tools.javac.tree.*;
    43 import com.sun.tools.javac.tree.JCTree.*;
    44 import com.sun.tools.javac.tree.JCTree.*;
    44 import com.sun.tools.javac.util.*;
    45 import com.sun.tools.javac.util.*;
    45 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
    46 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
    46 import com.sun.tools.javac.util.List;
    47 import com.sun.tools.javac.util.List;
   330                     || tree.docComments != null) {
   331                     || tree.docComments != null) {
   331                     if (isPkgInfo) {
   332                     if (isPkgInfo) {
   332                         addEnv = true;
   333                         addEnv = true;
   333                     } else if (pd.annotations.nonEmpty()) {
   334                     } else if (pd.annotations.nonEmpty()) {
   334                         log.error(pd.annotations.head.pos(),
   335                         log.error(pd.annotations.head.pos(),
   335                                   "pkg.annotations.sb.in.package-info.java");
   336                                   Errors.PkgAnnotationsSbInPackageInfoJava);
   336                     }
   337                     }
   337                 }
   338                 }
   338             } else {
   339             } else {
   339                 tree.packge = tree.modle.unnamedPackage;
   340                 tree.packge = tree.modle.unnamedPackage;
   340             }
   341             }
   361                 Env<AttrContext> env0 = typeEnvs.get(tree.packge);
   362                 Env<AttrContext> env0 = typeEnvs.get(tree.packge);
   362                 if (env0 != null) {
   363                 if (env0 != null) {
   363                     JCCompilationUnit tree0 = env0.toplevel;
   364                     JCCompilationUnit tree0 = env0.toplevel;
   364                     if (!fileManager.isSameFile(tree.sourcefile, tree0.sourcefile)) {
   365                     if (!fileManager.isSameFile(tree.sourcefile, tree0.sourcefile)) {
   365                         log.warning(pd != null ? pd.pid.pos() : null,
   366                         log.warning(pd != null ? pd.pid.pos() : null,
   366                                     "pkg-info.already.seen",
   367                                     Warnings.PkgInfoAlreadySeen(tree.packge));
   367                                     tree.packge);
       
   368                     }
   368                     }
   369                 }
   369                 }
   370                 typeEnvs.put(tree.packge, packageEnv);
   370                 typeEnvs.put(tree.packge, packageEnv);
   371 
   371 
   372                 for (Symbol q = tree.packge; q != null && q.kind == PCK; q = q.owner)
   372                 for (Symbol q = tree.packge; q != null && q.kind == PCK; q = q.owner)
   407                     topElement = KindName.ENUM;
   407                     topElement = KindName.ENUM;
   408                 } else if ((tree.mods.flags & INTERFACE) != 0) {
   408                 } else if ((tree.mods.flags & INTERFACE) != 0) {
   409                     topElement = KindName.INTERFACE;
   409                     topElement = KindName.INTERFACE;
   410                 }
   410                 }
   411                 log.error(tree.pos(),
   411                 log.error(tree.pos(),
   412                           "class.public.should.be.in.file", topElement, tree.name);
   412                           Errors.ClassPublicShouldBeInFile(topElement, tree.name));
   413             }
   413             }
   414         } else {
   414         } else {
   415             if (!tree.name.isEmpty() &&
   415             if (!tree.name.isEmpty() &&
   416                 !chk.checkUniqueClassName(tree.pos(), tree.name, enclScope)) {
   416                 !chk.checkUniqueClassName(tree.pos(), tree.name, enclScope)) {
   417                 result = null;
   417                 result = null;
   510                                                             JavaFileObject.Kind.SOURCE);
   510                                                             JavaFileObject.Kind.SOURCE);
   511         }
   511         }
   512 
   512 
   513     /** Complain about a duplicate class. */
   513     /** Complain about a duplicate class. */
   514     protected void duplicateClass(DiagnosticPosition pos, ClassSymbol c) {
   514     protected void duplicateClass(DiagnosticPosition pos, ClassSymbol c) {
   515         log.error(pos, "duplicate.class", c.fullname);
   515         log.error(pos, Errors.DuplicateClass(c.fullname));
   516     }
   516     }
   517 
   517 
   518     /** Class enter visitor method for type parameters.
   518     /** Class enter visitor method for type parameters.
   519      *  Enter a symbol for type parameter in local scope, after checking that it
   519      *  Enter a symbol for type parameter in local scope, after checking that it
   520      *  is unique.
   520      *  is unique.