You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DeclareAnnotationDeclaration.java 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* *******************************************************************
  2. * Copyright (c) 2005 IBM Corporation.
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Common Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/cpl-v10.html
  8. *
  9. * Contributors:
  10. * Adrian Colyer initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.ajdt.internal.compiler.ast;
  13. import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
  14. import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation;
  15. import org.aspectj.weaver.patterns.DeclareAnnotation;
  16. public class DeclareAnnotationDeclaration extends DeclareDeclaration {
  17. private Annotation annotation;
  18. public DeclareAnnotationDeclaration(CompilationResult result, DeclareAnnotation symbolicDeclare, Annotation annotation) {
  19. super(result,symbolicDeclare);
  20. this.annotation = annotation;
  21. addAnnotation(annotation);
  22. symbolicDeclare.setAnnotationString(annotation.toString());
  23. symbolicDeclare.setAnnotationMethod(new String(selector));
  24. }
  25. public Annotation getDeclaredAnnotation() {
  26. return annotation;
  27. }
  28. /* (non-Javadoc)
  29. * @see org.aspectj.ajdt.internal.compiler.ast.DeclareDeclaration#shouldDelegateCodeGeneration()
  30. */
  31. protected boolean shouldDelegateCodeGeneration() {
  32. return true; // declare annotation needs a method to be written out.
  33. }
  34. private void addAnnotation(Annotation ann) {
  35. if (this.annotations == null) {
  36. this.annotations = new Annotation[1];
  37. } else {
  38. Annotation[] old = this.annotations;
  39. this.annotations = new Annotation[old.length + 1];
  40. System.arraycopy(old,0,this.annotations,1,old.length);
  41. }
  42. this.annotations[0] = ann;
  43. }
  44. }