Пример #1
0
 void printFullScopeImpl(Scope scope) {
   indent();
   out.println(scope.getClass().getName());
   printSymbol("owner", scope.owner, Details.SUMMARY);
   if (SCOPE_IMPL_CLASS.equals(scope.getClass().getName())) {
     printScope("next", (Scope) getField(scope, scope.getClass(), "next"), Details.SUMMARY);
     printObject("shared", getField(scope, scope.getClass(), "shared"), Details.SUMMARY);
     Object[] table = (Object[]) getField(scope, scope.getClass(), "table");
     for (int i = 0; i < table.length; i++) {
       if (i > 0) out.print(", ");
       else indent();
       out.print(i + ":" + entryToString(table[i], table, false));
     }
     out.println();
   } else if (FILTER_SCOPE_CLASS.equals(scope.getClass().getName())) {
     printScope("origin", (Scope) getField(scope, scope.getClass(), "origin"), Details.FULL);
   } else if (scope instanceof CompoundScope) {
     printList("delegates", (List<?>) getField(scope, CompoundScope.class, "subScopes"));
   } else {
     for (Symbol sym : scope.getSymbols()) {
       printSymbol(sym.name.toString(), sym, Details.SUMMARY);
     }
   }
 }
Пример #2
0
  protected void printSymbol(String label, Symbol sym, Details details) {
    if (sym == null) {
      printNull(label);
    } else {
      switch (details) {
        case SUMMARY:
          printString(label, toString(sym));
          break;

        case FULL:
          indent();
          out.print(label);
          out.println(
              ": "
                  + info(
                      sym.getClass(),
                      String.format("0x%x--%s", sym.kind.ordinal(), Kinds.kindName(sym)),
                      sym.getKind())
                  + " "
                  + sym.name
                  + " "
                  + hashString(sym));

          indent(+1);
          if (showSrc) {
            JCTree tree = (JCTree) trees.getTree(sym);
            if (tree != null) printSource("src", tree);
          }
          printString(
              "flags", String.format("0x%x--%s", sym.flags_field, Flags.toString(sym.flags_field)));
          printObject("completer", sym.completer, Details.SUMMARY); // what if too long?
          printSymbol("owner", sym.owner, Details.SUMMARY);
          printType("type", sym.type, Details.SUMMARY);
          printType("erasure", sym.erasure_field, Details.SUMMARY);
          sym.accept(symVisitor, null);
          printAnnotations("annotations", sym.getMetadata(), Details.SUMMARY);
          indent(-1);
      }
    }
  }
Пример #3
0
  protected void printType(String label, Type type, Details details) {
    if (type == null) printNull(label);
    else {
      switch (details) {
        case SUMMARY:
          printString(label, toString(type));
          break;

        case FULL:
          indent();
          out.print(label);
          out.println(
              ": " + info(type.getClass(), type.getTag(), type.getKind()) + " " + hashString(type));

          indent(+1);
          printSymbol("tsym", type.tsym, Details.SUMMARY);
          printObject("constValue", type.constValue(), Details.SUMMARY);
          printObject("annotations", type.getAnnotationMirrors(), Details.SUMMARY);
          type.accept(typeVisitor, null);
          indent(-1);
      }
    }
  }
Пример #4
0
 protected void printObject(String label, Object item, Details details) {
   if (item == null) {
     printNull(label);
   } else if (item instanceof Attribute) {
     printAttribute(label, (Attribute) item);
   } else if (item instanceof Symbol) {
     printSymbol(label, (Symbol) item, details);
   } else if (item instanceof Type) {
     printType(label, (Type) item, details);
   } else if (item instanceof JCTree) {
     printTree(label, (JCTree) item);
   } else if (item instanceof DocTree) {
     printDocTree(label, (DocTree) item);
   } else if (item instanceof List) {
     printList(label, (List) item);
   } else if (item instanceof Name) {
     printName(label, (Name) item);
   } else if (item instanceof Scope) {
     printScope(label, (Scope) item);
   } else {
     printString(label, String.valueOf(item));
   }
 }
Пример #5
0
 public void printSymbol(String label, Symbol symbol) {
   printSymbol(label, symbol, Details.FULL);
 }