src/share/classes/com/sun/tools/javac/code/Type.java

changeset 904
4baab658f357
parent 880
0c24826853b2
child 988
7ae6c0fd479b
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java	Wed Mar 02 21:06:17 2011 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Wed Mar 02 21:13:55 2011 -0800
     1.3 @@ -93,6 +93,22 @@
     1.4          return null;
     1.5      }
     1.6  
     1.7 +    /**
     1.8 +     * Get the representation of this type used for modelling purposes.
     1.9 +     * By default, this is itself. For ErrorType, a different value
    1.10 +     * may be provided,
    1.11 +     */
    1.12 +    public Type getModelType() {
    1.13 +        return this;
    1.14 +    }
    1.15 +
    1.16 +    public static List<Type> getModelTypes(List<Type> ts) {
    1.17 +        ListBuffer<Type> lb = new ListBuffer<Type>();
    1.18 +        for (Type t: ts)
    1.19 +            lb.append(t.getModelType());
    1.20 +        return lb.toList();
    1.21 +    }
    1.22 +
    1.23      public <R,S> R accept(Type.Visitor<R,S> v, S s) { return v.visitType(this, s); }
    1.24  
    1.25      /** Define a type given its tag and type symbol
    1.26 @@ -190,7 +206,7 @@
    1.27          if (ts.isEmpty()) {
    1.28              return "";
    1.29          } else {
    1.30 -            StringBuffer buf = new StringBuffer();
    1.31 +            StringBuilder buf = new StringBuilder();
    1.32              buf.append(ts.head.toString());
    1.33              for (List<Type> l = ts.tail; l.nonEmpty(); l = l.tail)
    1.34                  buf.append(",").append(l.head.toString());
    1.35 @@ -464,7 +480,7 @@
    1.36  
    1.37          boolean isPrintingBound = false;
    1.38          public String toString() {
    1.39 -            StringBuffer s = new StringBuffer();
    1.40 +            StringBuilder s = new StringBuilder();
    1.41              s.append(kind.toString());
    1.42              if (kind != UNBOUND)
    1.43                  s.append(type);
    1.44 @@ -538,6 +554,10 @@
    1.45           */
    1.46          public List<Type> interfaces_field;
    1.47  
    1.48 +        /** All the interfaces of this class, including missing ones.
    1.49 +         */
    1.50 +        public List<Type> all_interfaces_field;
    1.51 +
    1.52          public ClassType(Type outer, List<Type> typarams, TypeSymbol tsym) {
    1.53              super(CLASS, tsym);
    1.54              this.outer_field = outer;
    1.55 @@ -578,7 +598,7 @@
    1.56          /** The Java source which this type represents.
    1.57           */
    1.58          public String toString() {
    1.59 -            StringBuffer buf = new StringBuffer();
    1.60 +            StringBuilder buf = new StringBuilder();
    1.61              if (getEnclosingType().tag == CLASS && tsym.owner.kind == TYP) {
    1.62                  buf.append(getEnclosingType().toString());
    1.63                  buf.append(".");
    1.64 @@ -596,7 +616,7 @@
    1.65  //where
    1.66              private String className(Symbol sym, boolean longform) {
    1.67                  if (sym.name.isEmpty() && (sym.flags() & COMPOUND) != 0) {
    1.68 -                    StringBuffer s = new StringBuffer(supertype_field.toString());
    1.69 +                    StringBuilder s = new StringBuilder(supertype_field.toString());
    1.70                      for (List<Type> is=interfaces_field; is.nonEmpty(); is = is.tail) {
    1.71                          s.append("&");
    1.72                          s.append(is.head.toString());

mercurial