01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package org.terracotta.dso;
05:
06: import org.eclipse.jdt.core.IMethod;
07: import org.eclipse.jdt.core.JavaModelException;
08: import org.eclipse.jdt.core.dom.Annotation;
09: import org.eclipse.jdt.core.dom.IAnnotationBinding;
10:
11: import com.tc.backport175.bytecode.AnnotationElement;
12: import com.tc.object.bytecode.aspectwerkz.AsmMethodInfo;
13: import com.tc.object.bytecode.aspectwerkz.ClassInfoFactory;
14:
15: import java.util.ArrayList;
16: import java.util.List;
17:
18: public class JavaModelMethodInfo extends AsmMethodInfo {
19: private List<AnnotationElement.Annotation> fAnnotations = new ArrayList<AnnotationElement.Annotation>();
20:
21: public JavaModelMethodInfo(ClassInfoFactory classInfoFactory,
22: IMethod method) throws JavaModelException {
23: this (classInfoFactory, method.getFlags(), PatternHelper
24: .getFullyQualifiedName(method.getDeclaringType()),
25: method.isConstructor() ? "__INIT__" : method
26: .getElementName(), PatternHelper
27: .getSignature(method), method
28: .getExceptionTypes());
29: }
30:
31: public JavaModelMethodInfo(ClassInfoFactory classInfoFactory,
32: int modifiers, String className, String methodName,
33: String desc, String[] exceptions) {
34: super (classInfoFactory, modifiers, className, methodName, desc,
35: exceptions);
36: }
37:
38: public void clearAnnotations() {
39: fAnnotations.clear();
40: }
41:
42: public void addAnnotation(Annotation annotation) {
43: IAnnotationBinding binding = annotation
44: .resolveAnnotationBinding();
45: String name = binding.getAnnotationType().getQualifiedName();
46: fAnnotations.add(new AnnotationElement.Annotation(name));
47: }
48:
49: public AnnotationElement.Annotation[] getAnnotations() {
50: return fAnnotations
51: .toArray(new AnnotationElement.Annotation[0]);
52: }
53: }
|