]> source.dussan.org Git - aspectj.git/blob
7606ed4461a814bc87c0f4f07c7025c55d05f856
[aspectj.git] /
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
14 import org.aspectj.org.eclipse.jdt.internal.compiler.ASTVisitor;
15 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
16 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
17 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
18 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope;
19 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope;
20 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
21
22 /**
23  * Adds runtime visible annotations to code-style aspect declarations so that the MAP can provide aspect information at runtime.
24  * 
25  * Done: - AspectDeclaration - AdviceDeclaration - PointcutDeclaration
26  * 
27  * To Do: - DeclareDeclaration - Inter-Type Declaration
28  */
29 public class AddAtAspectJAnnotationsVisitor extends ASTVisitor {
30
31         // private CompilationUnitDeclaration unit;
32
33         public AddAtAspectJAnnotationsVisitor(CompilationUnitDeclaration unit) {
34                 // this.unit = unit;
35         }
36
37         public boolean visit(TypeDeclaration localTypeDeclaration, BlockScope scope) {
38                 if (localTypeDeclaration instanceof AspectDeclaration) {
39                         ((AspectDeclaration) localTypeDeclaration).addAtAspectJAnnotations();
40                 }
41                 return true;
42         }
43
44         public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope scope) {
45                 if (memberTypeDeclaration instanceof AspectDeclaration) {
46                         ((AspectDeclaration) memberTypeDeclaration).addAtAspectJAnnotations();
47                 }
48                 return true;
49         }
50
51         public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) {
52                 if (typeDeclaration instanceof AspectDeclaration) {
53                         ((AspectDeclaration) typeDeclaration).addAtAspectJAnnotations();
54                 }
55                 return true;
56         }
57
58         public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
59                 if (methodDeclaration instanceof AdviceDeclaration) {
60                         ((AdviceDeclaration) methodDeclaration).addAtAspectJAnnotations();
61                 } else if (methodDeclaration instanceof PointcutDeclaration) {
62                         ((PointcutDeclaration) methodDeclaration).addAtAspectJAnnotations();
63                 } else if (methodDeclaration instanceof DeclareDeclaration) {
64                         ((DeclareDeclaration) methodDeclaration).addAtAspectJAnnotations();
65                 } else if (methodDeclaration instanceof InterTypeDeclaration) {
66                         ((InterTypeDeclaration) methodDeclaration).addAtAspectJAnnotations();
67                 }
68                 return false;
69         }
70
71 }