Lines 25-31
Link Here
|
25 |
import org.eclipse.jdt.internal.compiler.env.INameEnvironment; |
25 |
import org.eclipse.jdt.internal.compiler.env.INameEnvironment; |
26 |
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; |
26 |
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; |
27 |
import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding; |
27 |
import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding; |
28 |
import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding; |
|
|
29 |
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; |
28 |
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; |
30 |
import org.eclipse.jdt.internal.core.NameLookup; |
29 |
import org.eclipse.jdt.internal.core.NameLookup; |
31 |
import org.eclipse.jdt.internal.core.SearchableEnvironment; |
30 |
import org.eclipse.jdt.internal.core.SearchableEnvironment; |
Lines 49-66
Link Here
|
49 |
this.resolver = resolver; |
48 |
this.resolver = resolver; |
50 |
} |
49 |
} |
51 |
|
50 |
|
52 |
public IResolvedAnnotation[] getAnnotations() { |
51 |
public IAnnotationBinding[] getAnnotations() { |
53 |
try { |
52 |
try { |
54 |
INameEnvironment nameEnvironment = this.binding.environment.nameEnvironment; |
53 |
INameEnvironment nameEnvironment = this.binding.environment.nameEnvironment; |
55 |
if (!(nameEnvironment instanceof SearchableEnvironment)) |
54 |
if (!(nameEnvironment instanceof SearchableEnvironment)) |
56 |
return ResolvedAnnotation.NoAnnotations; |
55 |
return AnnotationBinding.NoAnnotations; |
57 |
NameLookup nameLookup = ((SearchableEnvironment) nameEnvironment).nameLookup; |
56 |
NameLookup nameLookup = ((SearchableEnvironment) nameEnvironment).nameLookup; |
58 |
if (nameLookup == null) |
57 |
if (nameLookup == null) |
59 |
return ResolvedAnnotation.NoAnnotations; |
58 |
return AnnotationBinding.NoAnnotations; |
60 |
final String pkgName = getName(); |
59 |
final String pkgName = getName(); |
61 |
IPackageFragment[] pkgs = nameLookup.findPackageFragments(pkgName, false/*exact match*/); |
60 |
IPackageFragment[] pkgs = nameLookup.findPackageFragments(pkgName, false/*exact match*/); |
62 |
if (pkgs == null) |
61 |
if (pkgs == null) |
63 |
return ResolvedAnnotation.NoAnnotations; |
62 |
return AnnotationBinding.NoAnnotations; |
64 |
|
63 |
|
65 |
for (int i = 0, len = pkgs.length; i < len; i++) { |
64 |
for (int i = 0, len = pkgs.length; i < len; i++) { |
66 |
int fragType = pkgs[i].getKind(); |
65 |
int fragType = pkgs[i].getKind(); |
Lines 80-93
Link Here
|
80 |
if (pkgDecl != null) { |
79 |
if (pkgDecl != null) { |
81 |
List annos = pkgDecl.annotations(); |
80 |
List annos = pkgDecl.annotations(); |
82 |
if (annos == null || annos.isEmpty()) |
81 |
if (annos == null || annos.isEmpty()) |
83 |
return ResolvedAnnotation.NoAnnotations; |
82 |
return AnnotationBinding.NoAnnotations; |
84 |
IResolvedAnnotation[] result = new IResolvedAnnotation[annos.size()]; |
83 |
IAnnotationBinding[] result = new IAnnotationBinding[annos.size()]; |
85 |
int index=0; |
84 |
int index=0; |
86 |
for (Iterator it = annos.iterator(); it.hasNext(); index++) { |
85 |
for (Iterator it = annos.iterator(); it.hasNext(); index++) { |
87 |
result[index] = ((Annotation) it.next()).resolveAnnotation(); |
86 |
result[index] = ((Annotation) it.next()).resolveAnnotation(); |
88 |
// not resolving bindings |
87 |
// not resolving bindings |
89 |
if (result[index] == null) |
88 |
if (result[index] == null) |
90 |
return ResolvedAnnotation.NoAnnotations; |
89 |
return AnnotationBinding.NoAnnotations; |
91 |
} |
90 |
} |
92 |
return result; |
91 |
return result; |
93 |
} |
92 |
} |
Lines 99-123
Link Here
|
99 |
if (answer != null && answer.isBinaryType()) { |
98 |
if (answer != null && answer.isBinaryType()) { |
100 |
IBinaryType type = answer.getBinaryType(); |
99 |
IBinaryType type = answer.getBinaryType(); |
101 |
IBinaryAnnotation[] binaryAnnotations = type.getAnnotations(); |
100 |
IBinaryAnnotation[] binaryAnnotations = type.getAnnotations(); |
102 |
AnnotationBinding[] binaryInstances = |
101 |
org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] binaryInstances = |
103 |
BinaryTypeBinding.createAnnotations(binaryAnnotations, this.binding.environment); |
102 |
BinaryTypeBinding.createAnnotations(binaryAnnotations, this.binding.environment); |
104 |
AnnotationBinding[] allInstances = |
103 |
org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] allInstances = |
105 |
AnnotationBinding.addStandardAnnotations(binaryInstances, type.getTagBits(), this.binding.environment); |
104 |
org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding.addStandardAnnotations(binaryInstances, type.getTagBits(), this.binding.environment); |
106 |
int total = allInstances.length; |
105 |
int total = allInstances.length; |
107 |
IResolvedAnnotation[] domInstances = new ResolvedAnnotation[total]; |
106 |
IAnnotationBinding[] domInstances = new AnnotationBinding[total]; |
108 |
for (int a = 0; a < total; a++) { |
107 |
for (int a = 0; a < total; a++) { |
109 |
domInstances[a] = this.resolver.getAnnotationInstance(allInstances[a]); |
108 |
domInstances[a] = this.resolver.getAnnotationInstance(allInstances[a]); |
110 |
if (domInstances[a] == null) // not resolving binding |
109 |
if (domInstances[a] == null) // not resolving binding |
111 |
return ResolvedAnnotation.NoAnnotations; |
110 |
return AnnotationBinding.NoAnnotations; |
112 |
} |
111 |
} |
113 |
return domInstances; |
112 |
return domInstances; |
114 |
} |
113 |
} |
115 |
} |
114 |
} |
116 |
} |
115 |
} |
117 |
} catch(JavaModelException e) { |
116 |
} catch(JavaModelException e) { |
118 |
return ResolvedAnnotation.NoAnnotations; |
117 |
return AnnotationBinding.NoAnnotations; |
119 |
} |
118 |
} |
120 |
return ResolvedAnnotation.NoAnnotations; |
119 |
return AnnotationBinding.NoAnnotations; |
121 |
} |
120 |
} |
122 |
|
121 |
|
123 |
/* |
122 |
/* |