static String parameterizedTypeToString(DocEnv env, ClassType cl, boolean full) {
   if (env.legacyDoclet) {
     return TypeMaker.getTypeName(cl, full);
   }
   StringBuffer s = new StringBuffer();
   if (cl.getEnclosingType().tag != CLASS) { // if not an inner class...
     s.append(TypeMaker.getTypeName(cl, full));
   } else {
     ClassType encl = (ClassType) cl.getEnclosingType();
     s.append(parameterizedTypeToString(env, encl, full))
         .append('.')
         .append(cl.tsym.name.toString());
   }
   s.append(TypeMaker.typeArgumentsString(env, cl, full));
   return s.toString();
 }
 @Override
 public String visitClassType(ClassType t, Locale locale) {
   if (t.isCompound() && getConfiguration().isEnabled(RichFormatterFeature.WHERE_CLAUSES)) {
     return localize(
         locale, "compiler.misc.intersection.type", indexOf(t, WhereClauseKind.INTERSECTION));
   } else return super.visitClassType(t, locale);
 }
Beispiel #3
0
 @Override
 public String visitClassType(ClassType t, Locale locale) {
   StringBuilder buf = new StringBuilder();
   if (t.getEnclosingType().tag == CLASS && t.tsym.owner.kind == Kinds.TYP) {
     buf.append(visit(t.getEnclosingType(), locale));
     buf.append('.');
     buf.append(className(t, false, locale));
   } else {
     buf.append(className(t, true, locale));
   }
   if (t.getTypeArguments().nonEmpty()) {
     buf.append('<');
     buf.append(visitTypes(t.getTypeArguments(), locale));
     buf.append('>');
   }
   return buf.toString();
 }
 public Void visitClassType(ClassType type, Void ignore) {
   printType("outer", type.getEnclosingType(), Details.SUMMARY);
   printList("typarams", type.typarams_field);
   printList("allparams", type.allparams_field);
   printType("supertype", type.supertype_field, Details.SUMMARY);
   printList("interfaces", type.interfaces_field);
   printList("allinterfaces", type.all_interfaces_field);
   return visitType(type, null);
 }
 @Override
 public Void visitClassType(ClassType t, Void ignored) {
   if (t.isCompound()) {
     if (indexOf(t, WhereClauseKind.INTERSECTION) == -1) {
       Type supertype = types.supertype(t);
       List<Type> interfaces = types.interfaces(t);
       JCDiagnostic d =
           diags.fragment("where.intersection", t, interfaces.prepend(supertype));
       whereClauses.get(WhereClauseKind.INTERSECTION).put(t, d);
       visit(supertype);
       visit(interfaces);
     }
   }
   nameSimplifier.addUsage(t.tsym);
   visit(t.getTypeArguments());
   if (t.getEnclosingType() != Type.noType) visit(t.getEnclosingType());
   return null;
 }
Beispiel #6
0
  public void visitClassDef(JCClassDecl tree) {
    Symbol owner = env.info.scope.owner;
    Scope enclScope = enterScope(env);
    ClassSymbol c;
    if (owner.kind == PCK) {
      // We are seeing a toplevel class.
      PackageSymbol packge = (PackageSymbol) owner;
      for (Symbol q = packge; q != null && q.kind == PCK; q = q.owner) q.flags_field |= EXISTS;
      c = reader.enterClass(tree.name, packge);
      packge.members().enterIfAbsent(c);
      if ((tree.mods.flags & PUBLIC) != 0 && !classNameMatchesFileName(c, env)) {
        log.error(tree.pos(), "class.public.should.be.in.file", tree.name);
      }
    } else {
      if (!tree.name.isEmpty() && !chk.checkUniqueClassName(tree.pos(), tree.name, enclScope)) {
        result = null;
        return;
      }
      if (owner.kind == TYP) {
        // We are seeing a member class.
        c = reader.enterClass(tree.name, (TypeSymbol) owner);
        if ((owner.flags_field & INTERFACE) != 0) {
          tree.mods.flags |= PUBLIC | STATIC;
        }
      } else {
        // We are seeing a local class.
        c = reader.defineClass(tree.name, owner);
        c.flatname = chk.localClassName(c);
        if (!c.name.isEmpty()) chk.checkTransparentClass(tree.pos(), c, env.info.scope);
      }
    }
    tree.sym = c;

    // Enter class into `compiled' table and enclosing scope.
    if (chk.compiled.get(c.flatname) != null) {
      duplicateClass(tree.pos(), c);
      result = types.createErrorType(tree.name, (TypeSymbol) owner, Type.noType);
      tree.sym = (ClassSymbol) result.tsym;
      return;
    }
    chk.compiled.put(c.flatname, c);
    enclScope.enter(c);

    // Set up an environment for class block and store in `typeEnvs'
    // table, to be retrieved later in memberEnter and attribution.
    Env<AttrContext> localEnv = classEnv(tree, env);
    typeEnvs.put(c, localEnv);

    // Fill out class fields.
    c.completer = memberEnter;
    c.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, c, tree);
    c.sourcefile = env.toplevel.sourcefile;
    c.members_field = new Scope(c);

    ClassType ct = (ClassType) c.type;
    if (owner.kind != PCK && (c.flags_field & STATIC) == 0) {
      // We are seeing a local or inner class.
      // Set outer_field of this class to closest enclosing class
      // which contains this class in a non-static context
      // (its "enclosing instance class"), provided such a class exists.
      Symbol owner1 = owner;
      while ((owner1.kind & (VAR | MTH)) != 0 && (owner1.flags_field & STATIC) == 0) {
        owner1 = owner1.owner;
      }
      if (owner1.kind == TYP) {
        ct.setEnclosingType(owner1.type);
      }
    }

    // Enter type parameters.
    ct.typarams_field = classEnter(tree.typarams, localEnv);

    // Add non-local class to uncompleted, to make sure it will be
    // completed later.
    if (!c.isLocal() && uncompleted != null) uncompleted.append(c);
    //      System.err.println("entering " + c.fullname + " in " + c.owner);//DEBUG

    // Recursively enter all member classes.
    classEnter(tree.defs, localEnv);

    result = c.type;
  }