Lines 147-156
Link Here
|
147 |
*/ |
147 |
*/ |
148 |
public void locateMatches(MatchLocator locator, ClassFile classFile, IBinaryType info) throws CoreException { |
148 |
public void locateMatches(MatchLocator locator, ClassFile classFile, IBinaryType info) throws CoreException { |
149 |
SearchPattern pattern = locator.pattern; |
149 |
SearchPattern pattern = locator.pattern; |
|
|
150 |
|
150 |
// check annotations references |
151 |
// check annotations references |
151 |
if (((InternalSearchPattern)pattern).kind == TYPE_REF_PATTERN) { |
152 |
matchAnnotations(pattern, locator, classFile, info); |
152 |
matchAnnotations((TypeReferencePattern)pattern, locator, classFile, info); |
|
|
153 |
} |
154 |
|
153 |
|
155 |
// check class definition |
154 |
// check class definition |
156 |
BinaryType binaryType = (BinaryType) classFile.getType(); |
155 |
BinaryType binaryType = (BinaryType) classFile.getType(); |
Lines 308-320
Link Here
|
308 |
/* |
307 |
/* |
309 |
* Look for annotations references |
308 |
* Look for annotations references |
310 |
*/ |
309 |
*/ |
311 |
void matchAnnotations(TypeReferencePattern pattern, MatchLocator locator, ClassFile classFile, IBinaryType binaryType) throws CoreException { |
310 |
void matchAnnotations(SearchPattern pattern, MatchLocator locator, ClassFile classFile, IBinaryType binaryType) throws CoreException { |
|
|
311 |
// Only process TypeReference patterns |
312 |
switch (((InternalSearchPattern)pattern).kind) { |
313 |
case TYPE_REF_PATTERN: |
314 |
break; |
315 |
case OR_PATTERN: |
316 |
SearchPattern[] patterns = ((OrPattern) pattern).patterns; |
317 |
for (int i = 0, length = patterns.length; i < length; i++) { |
318 |
matchAnnotations(patterns[i], locator, classFile, binaryType); |
319 |
} |
320 |
// fall through default to return |
321 |
default: |
322 |
return; |
323 |
} |
324 |
TypeReferencePattern typeReferencePattern = (TypeReferencePattern) pattern; |
312 |
|
325 |
|
313 |
// Look for references in class annotations |
326 |
// Look for references in class annotations |
314 |
IBinaryAnnotation[] annotations = binaryType.getAnnotations(); |
327 |
IBinaryAnnotation[] annotations = binaryType.getAnnotations(); |
315 |
BinaryType classFileBinaryType = (BinaryType) classFile.getType(); |
328 |
BinaryType classFileBinaryType = (BinaryType) classFile.getType(); |
316 |
BinaryTypeBinding binaryTypeBinding = null; |
329 |
BinaryTypeBinding binaryTypeBinding = null; |
317 |
if (checkAnnotations(pattern, annotations, binaryType.getTagBits())) { |
330 |
if (checkAnnotations(typeReferencePattern, annotations, binaryType.getTagBits())) { |
318 |
classFileBinaryType = new ResolvedBinaryType((JavaElement) classFileBinaryType.getParent(), classFileBinaryType.getElementName(), classFileBinaryType.getKey()); |
331 |
classFileBinaryType = new ResolvedBinaryType((JavaElement) classFileBinaryType.getParent(), classFileBinaryType.getElementName(), classFileBinaryType.getKey()); |
319 |
locator.reportBinaryMemberDeclaration(null, classFileBinaryType, null, binaryType, SearchMatch.A_ACCURATE); |
332 |
locator.reportBinaryMemberDeclaration(null, classFileBinaryType, null, binaryType, SearchMatch.A_ACCURATE); |
320 |
} |
333 |
} |
Lines 324-330
Link Here
|
324 |
if (methods != null) { |
337 |
if (methods != null) { |
325 |
for (int i = 0, max = methods.length; i < max; i++) { |
338 |
for (int i = 0, max = methods.length; i < max; i++) { |
326 |
MethodInfo method = methods[i]; |
339 |
MethodInfo method = methods[i]; |
327 |
if (checkAnnotations(pattern, method.getAnnotations(), method.getTagBits())) { |
340 |
if (checkAnnotations(typeReferencePattern, method.getAnnotations(), method.getTagBits())) { |
328 |
binaryTypeBinding = locator.cacheBinaryType(classFileBinaryType, binaryType); |
341 |
binaryTypeBinding = locator.cacheBinaryType(classFileBinaryType, binaryType); |
329 |
IMethod methodHandle = classFileBinaryType.getMethod( |
342 |
IMethod methodHandle = classFileBinaryType.getMethod( |
330 |
new String(method.isConstructor() ? binaryTypeBinding.compoundName[binaryTypeBinding.compoundName.length-1] : method.getSelector()), |
343 |
new String(method.isConstructor() ? binaryTypeBinding.compoundName[binaryTypeBinding.compoundName.length-1] : method.getSelector()), |
Lines 339-345
Link Here
|
339 |
if (fields != null) { |
352 |
if (fields != null) { |
340 |
for (int i = 0, max = fields.length; i < max; i++) { |
353 |
for (int i = 0, max = fields.length; i < max; i++) { |
341 |
FieldInfo field = fields[i]; |
354 |
FieldInfo field = fields[i]; |
342 |
if (checkAnnotations(pattern, field.getAnnotations(), field.getTagBits())) { |
355 |
if (checkAnnotations(typeReferencePattern, field.getAnnotations(), field.getTagBits())) { |
343 |
IField fieldHandle = classFileBinaryType.getField(new String(field.getName())); |
356 |
IField fieldHandle = classFileBinaryType.getField(new String(field.getName())); |
344 |
locator.reportBinaryMemberDeclaration(null, fieldHandle, null, binaryType, SearchMatch.A_ACCURATE); |
357 |
locator.reportBinaryMemberDeclaration(null, fieldHandle, null, binaryType, SearchMatch.A_ACCURATE); |
345 |
} |
358 |
} |