src/share/classes/com/sun/tools/javac/tree/JCTree.java

changeset 1521
71f35e4b93a5
parent 1510
7873d37f5b37
child 1615
12202e6ab78a
     1.1 --- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Wed Jan 23 20:57:40 2013 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Wed Jan 23 13:27:24 2013 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -250,11 +250,11 @@
    1.11           */
    1.12          TYPEAPPLY,
    1.13  
    1.14 -        /** Union types, of type TypeUnion
    1.15 +        /** Union types, of type TypeUnion.
    1.16           */
    1.17          TYPEUNION,
    1.18  
    1.19 -        /** Intersection types, of type TypeIntersection
    1.20 +        /** Intersection types, of type TypeIntersection.
    1.21           */
    1.22          TYPEINTERSECTION,
    1.23  
    1.24 @@ -274,10 +274,16 @@
    1.25           */
    1.26          ANNOTATION,
    1.27  
    1.28 +        /** metadata: Type annotation.
    1.29 +         */
    1.30 +        TYPE_ANNOTATION,
    1.31 +
    1.32          /** metadata: Modifiers
    1.33           */
    1.34          MODIFIERS,
    1.35  
    1.36 +        /** An annotated type tree.
    1.37 +         */
    1.38          ANNOTATED_TYPE,
    1.39  
    1.40          /** Error trees, of type Erroneous.
    1.41 @@ -725,6 +731,8 @@
    1.42          public JCExpression restype;
    1.43          /** type parameters */
    1.44          public List<JCTypeParameter> typarams;
    1.45 +        /** receiver parameter */
    1.46 +        public JCVariableDecl recvparam;
    1.47          /** value parameters */
    1.48          public List<JCVariableDecl> params;
    1.49          /** exceptions thrown by this method */
    1.50 @@ -739,6 +747,7 @@
    1.51                              Name name,
    1.52                              JCExpression restype,
    1.53                              List<JCTypeParameter> typarams,
    1.54 +                            JCVariableDecl recvparam,
    1.55                              List<JCVariableDecl> params,
    1.56                              List<JCExpression> thrown,
    1.57                              JCBlock body,
    1.58 @@ -750,6 +759,9 @@
    1.59              this.restype = restype;
    1.60              this.typarams = typarams;
    1.61              this.params = params;
    1.62 +            this.recvparam = recvparam;
    1.63 +            // TODO: do something special if the given type is null?
    1.64 +            // receiver != null ? receiver : List.<JCTypeAnnotation>nil());
    1.65              this.thrown = thrown;
    1.66              this.body = body;
    1.67              this.defaultValue = defaultValue;
    1.68 @@ -768,6 +780,7 @@
    1.69          public List<JCVariableDecl> getParameters() {
    1.70              return params;
    1.71          }
    1.72 +        public JCVariableDecl getReceiverParameter() { return recvparam; }
    1.73          public List<JCExpression> getThrows() {
    1.74              return thrown;
    1.75          }
    1.76 @@ -1505,6 +1518,10 @@
    1.77      public static class JCNewArray extends JCExpression implements NewArrayTree {
    1.78          public JCExpression elemtype;
    1.79          public List<JCExpression> dims;
    1.80 +        // type annotations on inner-most component
    1.81 +        public List<JCAnnotation> annotations;
    1.82 +        // type annotations on dimensions
    1.83 +        public List<List<JCAnnotation>> dimAnnotations;
    1.84          public List<JCExpression> elems;
    1.85          protected JCNewArray(JCExpression elemtype,
    1.86                             List<JCExpression> dims,
    1.87 @@ -1512,6 +1529,8 @@
    1.88          {
    1.89              this.elemtype = elemtype;
    1.90              this.dims = dims;
    1.91 +            this.annotations = List.nil();
    1.92 +            this.dimAnnotations = List.nil();
    1.93              this.elems = elems;
    1.94          }
    1.95          @Override
    1.96 @@ -2152,9 +2171,12 @@
    1.97          public Name name;
    1.98          /** bounds */
    1.99          public List<JCExpression> bounds;
   1.100 -        protected JCTypeParameter(Name name, List<JCExpression> bounds) {
   1.101 +        /** type annotations on type parameter */
   1.102 +        public List<JCAnnotation> annotations;
   1.103 +        protected JCTypeParameter(Name name, List<JCExpression> bounds, List<JCAnnotation> annotations) {
   1.104              this.name = name;
   1.105              this.bounds = bounds;
   1.106 +            this.annotations = annotations;
   1.107          }
   1.108          @Override
   1.109          public void accept(Visitor v) { v.visitTypeParameter(this); }
   1.110 @@ -2164,6 +2186,9 @@
   1.111          public List<JCExpression> getBounds() {
   1.112              return bounds;
   1.113          }
   1.114 +        public List<JCAnnotation> getAnnotations() {
   1.115 +            return annotations;
   1.116 +        }
   1.117          @Override
   1.118          public <R,D> R accept(TreeVisitor<R,D> v, D d) {
   1.119              return v.visitTypeParameter(this, d);
   1.120 @@ -2230,16 +2255,27 @@
   1.121      }
   1.122  
   1.123      public static class JCAnnotation extends JCExpression implements AnnotationTree {
   1.124 +        // Either Tag.ANNOTATION or Tag.TYPE_ANNOTATION
   1.125 +        private Tag tag;
   1.126 +
   1.127          public JCTree annotationType;
   1.128          public List<JCExpression> args;
   1.129 -        protected JCAnnotation(JCTree annotationType, List<JCExpression> args) {
   1.130 +
   1.131 +        // Attribute.Compound if tag is ANNOTATION
   1.132 +        // Attribute.TypeCompound if tag is TYPE_ANNOTATION
   1.133 +        public Attribute.Compound attribute;
   1.134 +
   1.135 +        protected JCAnnotation(Tag tag, JCTree annotationType, List<JCExpression> args) {
   1.136 +            this.tag = tag;
   1.137              this.annotationType = annotationType;
   1.138              this.args = args;
   1.139          }
   1.140 +
   1.141          @Override
   1.142          public void accept(Visitor v) { v.visitAnnotation(this); }
   1.143  
   1.144 -        public Kind getKind() { return Kind.ANNOTATION; }
   1.145 +        public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
   1.146 +
   1.147          public JCTree getAnnotationType() { return annotationType; }
   1.148          public List<JCExpression> getArguments() {
   1.149              return args;
   1.150 @@ -2250,7 +2286,7 @@
   1.151          }
   1.152          @Override
   1.153          public Tag getTag() {
   1.154 -            return ANNOTATION;
   1.155 +            return tag;
   1.156          }
   1.157      }
   1.158  
   1.159 @@ -2281,6 +2317,35 @@
   1.160          }
   1.161      }
   1.162  
   1.163 +    public static class JCAnnotatedType extends JCExpression implements com.sun.source.tree.AnnotatedTypeTree {
   1.164 +        // type annotations
   1.165 +        public List<JCAnnotation> annotations;
   1.166 +        public JCExpression underlyingType;
   1.167 +
   1.168 +        protected JCAnnotatedType(List<JCAnnotation> annotations, JCExpression underlyingType) {
   1.169 +            this.annotations = annotations;
   1.170 +            this.underlyingType = underlyingType;
   1.171 +        }
   1.172 +        @Override
   1.173 +        public void accept(Visitor v) { v.visitAnnotatedType(this); }
   1.174 +
   1.175 +        public Kind getKind() { return Kind.ANNOTATED_TYPE; }
   1.176 +        public List<JCAnnotation> getAnnotations() {
   1.177 +            return annotations;
   1.178 +        }
   1.179 +        public JCExpression getUnderlyingType() {
   1.180 +            return underlyingType;
   1.181 +        }
   1.182 +        @Override
   1.183 +        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
   1.184 +            return v.visitAnnotatedType(this, d);
   1.185 +        }
   1.186 +        @Override
   1.187 +        public Tag getTag() {
   1.188 +            return ANNOTATED_TYPE;
   1.189 +        }
   1.190 +    }
   1.191 +
   1.192      public static class JCErroneous extends JCExpression
   1.193              implements com.sun.source.tree.ErroneousTree {
   1.194          public List<? extends JCTree> errs;
   1.195 @@ -2347,6 +2412,7 @@
   1.196                              Name name,
   1.197                              JCExpression restype,
   1.198                              List<JCTypeParameter> typarams,
   1.199 +                            JCVariableDecl recvparam,
   1.200                              List<JCVariableDecl> params,
   1.201                              List<JCExpression> thrown,
   1.202                              JCBlock body,
   1.203 @@ -2472,6 +2538,7 @@
   1.204          public void visitTypeBoundKind(TypeBoundKind that)   { visitTree(that); }
   1.205          public void visitAnnotation(JCAnnotation that)       { visitTree(that); }
   1.206          public void visitModifiers(JCModifiers that)         { visitTree(that); }
   1.207 +        public void visitAnnotatedType(JCAnnotatedType that) { visitTree(that); }
   1.208          public void visitErroneous(JCErroneous that)         { visitTree(that); }
   1.209          public void visitLetExpr(LetExpr that)               { visitTree(that); }
   1.210  

mercurial