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.

AddAtAspectJAnnotationsVisitor.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* *******************************************************************
  2. * Copyright (c) 2005 IBM Corporation Ltd
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/epl-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.ASTVisitor;
  14. import org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
  15. import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
  16. import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
  17. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope;
  18. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope;
  19. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
  20. /**
  21. * Adds runtime visible annotations to code-style aspect declarations so that the MAP can provide aspect information at runtime.
  22. *
  23. * Done: - AspectDeclaration - AdviceDeclaration - PointcutDeclaration
  24. *
  25. * To Do: - DeclareDeclaration - Inter-Type Declaration
  26. */
  27. public class AddAtAspectJAnnotationsVisitor extends ASTVisitor {
  28. private boolean makeReflectable;
  29. // private CompilationUnitDeclaration unit;
  30. public AddAtAspectJAnnotationsVisitor(CompilationUnitDeclaration unit, boolean makeReflectable) {
  31. // this.unit = unit;
  32. this.makeReflectable= makeReflectable;
  33. }
  34. public boolean visit(TypeDeclaration localTypeDeclaration, BlockScope scope) {
  35. if (localTypeDeclaration instanceof AspectDeclaration) {
  36. ((AspectDeclaration) localTypeDeclaration).addAtAspectJAnnotations();
  37. }
  38. return true;
  39. }
  40. public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope scope) {
  41. if (memberTypeDeclaration instanceof AspectDeclaration) {
  42. ((AspectDeclaration) memberTypeDeclaration).addAtAspectJAnnotations();
  43. }
  44. return true;
  45. }
  46. public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) {
  47. if (typeDeclaration instanceof AspectDeclaration) {
  48. ((AspectDeclaration) typeDeclaration).addAtAspectJAnnotations();
  49. }
  50. return true;
  51. }
  52. public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
  53. if (methodDeclaration instanceof AdviceDeclaration) {
  54. ((AdviceDeclaration) methodDeclaration).addAtAspectJAnnotations();
  55. } else if (methodDeclaration instanceof PointcutDeclaration) {
  56. ((PointcutDeclaration) methodDeclaration).addAtAspectJAnnotations();
  57. } else if (methodDeclaration instanceof DeclareDeclaration) {
  58. ((DeclareDeclaration) methodDeclaration).addAtAspectJAnnotations();
  59. } else if (methodDeclaration instanceof InterTypeDeclaration) {
  60. if (makeReflectable) {
  61. ((InterTypeDeclaration) methodDeclaration).addAtAspectJAnnotations();
  62. }
  63. }
  64. return false;
  65. }
  66. }