]> source.dussan.org Git - aspectj.git/blob
35ae2fb9bef17855baa38cbae6497e5994acadd3
[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
24  * MAP can provide aspect information at runtime.
25  * 
26  * Done:
27  *  - AspectDeclaration
28  *  - AdviceDeclaration
29  *  - PointcutDeclaration
30  *  
31  *  To Do:
32  *  - DeclareDeclaration
33  *  - Inter-Type Declaration
34  */
35 public class AddAtAspectJAnnotationsVisitor extends ASTVisitor {
36
37         private CompilationUnitDeclaration unit;
38         
39         public AddAtAspectJAnnotationsVisitor(CompilationUnitDeclaration unit) {
40                 this.unit = unit;
41         }
42         
43         public boolean visit(TypeDeclaration localTypeDeclaration, BlockScope scope) {
44                 if (localTypeDeclaration instanceof AspectDeclaration) {
45                         ((AspectDeclaration) localTypeDeclaration).addAtAspectJAnnotations();
46                 }
47                 return true;
48         }
49                 
50         public boolean visit(TypeDeclaration memberTypeDeclaration,ClassScope scope) {
51                 if (memberTypeDeclaration instanceof AspectDeclaration) {
52                         ((AspectDeclaration) memberTypeDeclaration).addAtAspectJAnnotations();
53                 }
54                 return true;
55         }
56         
57         public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) {
58                 if (typeDeclaration instanceof AspectDeclaration) {
59                         ((AspectDeclaration) typeDeclaration).addAtAspectJAnnotations();
60                 }
61                 return true;
62         }
63         public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
64                 if (methodDeclaration instanceof AdviceDeclaration) {
65                         ((AdviceDeclaration)methodDeclaration).addAtAspectJAnnotations();
66                 } else if (methodDeclaration instanceof PointcutDeclaration) {
67                         ((PointcutDeclaration)methodDeclaration).addAtAspectJAnnotations();
68                 } else if (methodDeclaration instanceof DeclareDeclaration) {
69                         ((DeclareDeclaration)methodDeclaration).addAtAspectJAnnotations();
70                 }
71                 return false;
72         }
73         
74
75 }