27 |
27 |
28 import javax.lang.model.element.Element; |
28 import javax.lang.model.element.Element; |
29 import javax.lang.model.element.ElementKind; |
29 import javax.lang.model.element.ElementKind; |
30 import javax.lang.model.type.TypeKind; |
30 import javax.lang.model.type.TypeKind; |
31 |
31 |
|
32 import javax.tools.JavaFileObject; |
|
33 |
32 import com.sun.tools.javac.code.Attribute; |
34 import com.sun.tools.javac.code.Attribute; |
33 import com.sun.tools.javac.code.Attribute.TypeCompound; |
35 import com.sun.tools.javac.code.Attribute.TypeCompound; |
34 import com.sun.tools.javac.code.Flags; |
36 import com.sun.tools.javac.code.Flags; |
35 import com.sun.tools.javac.code.Kinds; |
37 import com.sun.tools.javac.code.Kinds; |
36 import com.sun.tools.javac.code.Type.AnnotatedType; |
38 import com.sun.tools.javac.code.Type.AnnotatedType; |
50 import com.sun.tools.javac.code.TypeTag; |
52 import com.sun.tools.javac.code.TypeTag; |
51 import com.sun.tools.javac.code.Symbol.VarSymbol; |
53 import com.sun.tools.javac.code.Symbol.VarSymbol; |
52 import com.sun.tools.javac.code.Symbol.MethodSymbol; |
54 import com.sun.tools.javac.code.Symbol.MethodSymbol; |
53 import com.sun.tools.javac.comp.Annotate; |
55 import com.sun.tools.javac.comp.Annotate; |
54 import com.sun.tools.javac.comp.Annotate.Annotator; |
56 import com.sun.tools.javac.comp.Annotate.Annotator; |
|
57 import com.sun.tools.javac.comp.AttrContext; |
|
58 import com.sun.tools.javac.comp.Env; |
55 import com.sun.tools.javac.tree.JCTree; |
59 import com.sun.tools.javac.tree.JCTree; |
|
60 import com.sun.tools.javac.tree.TreeInfo; |
56 import com.sun.tools.javac.tree.JCTree.JCBlock; |
61 import com.sun.tools.javac.tree.JCTree.JCBlock; |
57 import com.sun.tools.javac.tree.JCTree.JCClassDecl; |
62 import com.sun.tools.javac.tree.JCTree.JCClassDecl; |
58 import com.sun.tools.javac.tree.JCTree.JCExpression; |
63 import com.sun.tools.javac.tree.JCTree.JCExpression; |
59 import com.sun.tools.javac.tree.JCTree.JCLambda; |
64 import com.sun.tools.javac.tree.JCTree.JCLambda; |
60 import com.sun.tools.javac.tree.JCTree.JCMethodDecl; |
65 import com.sun.tools.javac.tree.JCTree.JCMethodDecl; |
|
66 import com.sun.tools.javac.tree.JCTree.JCMethodInvocation; |
61 import com.sun.tools.javac.tree.JCTree.JCNewClass; |
67 import com.sun.tools.javac.tree.JCTree.JCNewClass; |
62 import com.sun.tools.javac.tree.JCTree.JCTypeApply; |
68 import com.sun.tools.javac.tree.JCTree.JCTypeApply; |
63 import com.sun.tools.javac.tree.JCTree.JCVariableDecl; |
69 import com.sun.tools.javac.tree.JCTree.JCVariableDecl; |
64 import com.sun.tools.javac.tree.TreeScanner; |
70 import com.sun.tools.javac.tree.TreeScanner; |
65 import com.sun.tools.javac.tree.JCTree.*; |
71 import com.sun.tools.javac.tree.JCTree.*; |
88 * The method takes the Annotate object as parameter and |
94 * The method takes the Annotate object as parameter and |
89 * adds an Annotator to the correct Annotate queue for |
95 * adds an Annotator to the correct Annotate queue for |
90 * later processing. |
96 * later processing. |
91 */ |
97 */ |
92 public static void organizeTypeAnnotationsSignatures(final Symtab syms, final Names names, |
98 public static void organizeTypeAnnotationsSignatures(final Symtab syms, final Names names, |
93 final Log log, final JCClassDecl tree, Annotate annotate) { |
99 final Log log, final Env<AttrContext> env, final JCClassDecl tree, final Annotate annotate) { |
94 annotate.afterRepeated( new Annotator() { |
100 annotate.afterRepeated( new Annotator() { |
95 @Override |
101 @Override |
96 public void enterAnnotation() { |
102 public void enterAnnotation() { |
97 new TypeAnnotationPositions(syms, names, log, true).scan(tree); |
103 JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile); |
|
104 |
|
105 try { |
|
106 new TypeAnnotationPositions(syms, names, log, true).scan(tree); |
|
107 } finally { |
|
108 log.useSource(oldSource); |
|
109 } |
98 } |
110 } |
99 } ); |
111 } ); |
100 } |
112 } |
101 |
113 |
102 /** |
114 /** |
904 case METHOD_INVOCATION: { |
916 case METHOD_INVOCATION: { |
905 JCMethodInvocation invocation = (JCMethodInvocation)frame; |
917 JCMethodInvocation invocation = (JCMethodInvocation)frame; |
906 if (!invocation.typeargs.contains(tree)) { |
918 if (!invocation.typeargs.contains(tree)) { |
907 Assert.error("{" + tree + "} is not an argument in the invocation: " + invocation); |
919 Assert.error("{" + tree + "} is not an argument in the invocation: " + invocation); |
908 } |
920 } |
909 p.type = TargetType.METHOD_INVOCATION_TYPE_ARGUMENT; |
921 MethodSymbol exsym = (MethodSymbol) TreeInfo.symbol(invocation.getMethodSelect()); |
|
922 if (exsym == null) { |
|
923 Assert.error("could not determine symbol for {" + invocation + "}"); |
|
924 } else if (exsym.isConstructor()) { |
|
925 p.type = TargetType.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT; |
|
926 } else { |
|
927 p.type = TargetType.METHOD_INVOCATION_TYPE_ARGUMENT; |
|
928 } |
910 p.pos = invocation.pos; |
929 p.pos = invocation.pos; |
911 p.type_index = invocation.typeargs.indexOf(tree); |
930 p.type_index = invocation.typeargs.indexOf(tree); |
912 return; |
931 return; |
913 } |
932 } |
914 |
933 |