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

changeset 2136
7f6481e5fe3a
parent 2134
b0c086cd4520
child 2149
e5d3cd43c85e
equal deleted inserted replaced
2135:d7e155f874a7 2136:7f6481e5fe3a
95 final Log log; 95 final Log log;
96 final Names names; 96 final Names names;
97 final Symtab syms; 97 final Symtab syms;
98 final Annotate annotate; 98 final Annotate annotate;
99 final Attr attr; 99 final Attr attr;
100 private final boolean typeAnnoAsserts;
101 100
102 protected TypeAnnotations(Context context) { 101 protected TypeAnnotations(Context context) {
103 context.put(typeAnnosKey, this); 102 context.put(typeAnnosKey, this);
104 names = Names.instance(context); 103 names = Names.instance(context);
105 log = Log.instance(context); 104 log = Log.instance(context);
106 syms = Symtab.instance(context); 105 syms = Symtab.instance(context);
107 annotate = Annotate.instance(context); 106 annotate = Annotate.instance(context);
108 attr = Attr.instance(context); 107 attr = Attr.instance(context);
109 Options options = Options.instance(context); 108 Options options = Options.instance(context);
110 typeAnnoAsserts = options.isSet("TypeAnnotationAsserts");
111 } 109 }
112 110
113 /** 111 /**
114 * Separate type annotations from declaration annotations and 112 * Separate type annotations from declaration annotations and
115 * determine the correct positions for type annotations. 113 * determine the correct positions for type annotations.
1040 * then determine the positions. 1038 * then determine the positions.
1041 */ 1039 */
1042 @Override 1040 @Override
1043 public void visitMethodDef(final JCMethodDecl tree) { 1041 public void visitMethodDef(final JCMethodDecl tree) {
1044 if (tree.sym == null) { 1042 if (tree.sym == null) {
1045 if (typeAnnoAsserts) { 1043 Assert.error("Visiting tree node before memberEnter");
1046 Assert.error("Visiting tree node before memberEnter");
1047 } else {
1048 return;
1049 }
1050 } 1044 }
1051 if (sigOnly) { 1045 if (sigOnly) {
1052 if (!tree.mods.annotations.isEmpty()) { 1046 if (!tree.mods.annotations.isEmpty()) {
1053 // Nothing to do for separateAnnotationsKinds if 1047 // Nothing to do for separateAnnotationsKinds if
1054 // there are no annotations of either kind. 1048 // there are no annotations of either kind.
1148 public void visitVarDef(final JCVariableDecl tree) { 1142 public void visitVarDef(final JCVariableDecl tree) {
1149 if (tree.mods.annotations.isEmpty()) { 1143 if (tree.mods.annotations.isEmpty()) {
1150 // Nothing to do for separateAnnotationsKinds if 1144 // Nothing to do for separateAnnotationsKinds if
1151 // there are no annotations of either kind. 1145 // there are no annotations of either kind.
1152 } else if (tree.sym == null) { 1146 } else if (tree.sym == null) {
1153 if (typeAnnoAsserts) { 1147 Assert.error("Visiting tree node before memberEnter");
1154 Assert.error("Visiting tree node before memberEnter");
1155 }
1156 // Something is wrong already. Quietly ignore.
1157 } else if (tree.sym.getKind() == ElementKind.PARAMETER) { 1148 } else if (tree.sym.getKind() == ElementKind.PARAMETER) {
1158 // Parameters are handled in visitMethodDef or visitLambda. 1149 // Parameters are handled in visitMethodDef or visitLambda.
1159 } else if (tree.sym.getKind() == ElementKind.FIELD) { 1150 } else if (tree.sym.getKind() == ElementKind.FIELD) {
1160 if (sigOnly) { 1151 if (sigOnly) {
1161 TypeAnnotationPosition pos = new TypeAnnotationPosition(); 1152 TypeAnnotationPosition pos = new TypeAnnotationPosition();

mercurial