Пример #1
0
  protected void printAnnotations(String label, SymbolMetadata annotations, Details details) {
    if (annotations == null) {
      printNull(label);
    } else {
      // no SUMMARY format currently available to use

      // use reflection to get at private fields
      Object DECL_NOT_STARTED = getField(null, SymbolMetadata.class, "DECL_NOT_STARTED");
      Object DECL_IN_PROGRESS = getField(null, SymbolMetadata.class, "DECL_IN_PROGRESS");
      Object attributes = getField(annotations, SymbolMetadata.class, "attributes");
      Object type_attributes = getField(annotations, SymbolMetadata.class, "type_attributes");

      if (!showEmptyItems) {
        if (attributes instanceof List
            && ((List) attributes).isEmpty()
            && attributes != DECL_NOT_STARTED
            && attributes != DECL_IN_PROGRESS
            && type_attributes instanceof List
            && ((List) type_attributes).isEmpty()) return;
      }

      printString(label, hashString(annotations));

      indent(+1);
      if (attributes == DECL_NOT_STARTED) printString("attributes", "DECL_NOT_STARTED");
      else if (attributes == DECL_IN_PROGRESS) printString("attributes", "DECL_IN_PROGRESS");
      else if (attributes instanceof List) printList("attributes", (List) attributes);
      else printObject("attributes", attributes, Details.SUMMARY);

      if (attributes instanceof List) printList("type_attributes", (List) type_attributes);
      else printObject("type_attributes", type_attributes, Details.SUMMARY);
      indent(-1);
    }
  }
Пример #2
0
 public void printName(String label, Name name) {
   if (name == null) {
     printNull(label);
   } else {
     printString(label, name.toString());
   }
 }
Пример #3
0
 public void printFileObject(String label, FileObject fo) {
   if (fo == null) {
     printNull(label);
   } else {
     printString(label, fo.getName());
   }
 }
Пример #4
0
 public void printLimitedEscapedString(String label, String text) {
   String s = Convert.quote(text);
   if (s.length() > maxSrcLength) {
     String trim = "[...]";
     int head = (maxSrcLength - trim.length()) * 2 / 3;
     int tail = maxSrcLength - trim.length() - head;
     s = s.substring(0, head) + trim + s.substring(s.length() - tail);
   }
   printString(label, s);
 }
Пример #5
0
  public void printAttribute(String label, Attribute attr) {
    if (attr == null) {
      printNull(label);
    } else {
      printString(label, attr.getClass().getSimpleName());

      indent(+1);
      attr.accept(attrVisitor);
      indent(-1);
    }
  }
Пример #6
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);
      }
    }
  }
Пример #7
0
  public void printList(String label, List<?> list) {
    if (list == null) {
      printNull(label);
    } else if (!list.isEmpty() || showEmptyItems) {
      printString(label, "[" + list.size() + "]");

      indent(+1);
      int i = 0;
      for (Object item : list) {
        printObject(String.valueOf(i++), item, Details.FULL);
      }
      indent(-1);
    }
  }
Пример #8
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);
      }
    }
  }
Пример #9
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));
   }
 }
Пример #10
0
 public void printSource(String label, JCTree tree) {
   printString(label, Pretty.toSimpleString(tree, maxSrcLength));
 }
Пример #11
0
 public void printNull(String label) {
   if (showNulls) printString(label, NULL);
 }
Пример #12
0
 public void printInt(String label, int i) {
   printString(label, String.valueOf(i));
 }
Пример #13
0
 protected <T> void printImplClass(T item, Class<? extends T> stdImplClass) {
   if (item.getClass() != stdImplClass) printString("impl", item.getClass().getName());
 }