1 24 25 package org.aspectj.compiler.crosscuts; 26 27 import org.aspectj.compiler.crosscuts.ast.*; 28 import org.aspectj.compiler.crosscuts.joinpoints.*; 29 30 import org.aspectj.compiler.base.ast.*; 31 import org.aspectj.compiler.base.*; 32 import org.aspectj.util.CollectionUtil; 33 34 import java.util.*; 35 36 public class BuildAdvicePlannersPass extends AbstractCompilerPass { 37 38 public BuildAdvicePlannersPass(JavaCompiler compiler) { 39 super(compiler); 40 } 41 42 public String getDisplayName() { 43 return "building advice planners"; 44 } 45 46 public void transform(TypeDec td) { 47 if (td instanceof AspectDec) { 48 initializeAspect((AspectDec)td); 49 } 50 51 final int N = td.getBody().size(); 53 for (int i = 0; i < N; i++) { 54 Dec dec = td.getBody().get(i); 55 if (dec instanceof TypeDec) transform( (TypeDec)dec ); 56 } 57 } 58 59 public void initializeAspect(final AspectDec aspectDec) { 60 if (aspectDec.isAbstract()) return; 62 63 getCompiler().enterNode(aspectDec); 64 65 PerClause perClause = aspectDec.getPerClause(); 66 if (perClause != null) { 67 JpPlanner planner = perClause.makeInitializerPlanner( 68 new PlanData(aspectDec, null)); 69 if (planner != null) getWorld().addJpPlanner(planner); 70 } 71 72 Collection jpPlannerMakerList = aspectDec.getJpPlannerMakers(); 73 74 getCompiler().showMessage(" initializing advice in " + 75 aspectDec.toShortString()); 76 77 for(Iterator i = jpPlannerMakerList.iterator(); i.hasNext(); ) { 78 JpPlannerMaker jpPlannerMaker = (JpPlannerMaker)i.next(); 79 JpPlanner planner = 80 jpPlannerMaker.makePlanner(new PlanData(aspectDec, jpPlannerMaker)); 81 if (planner != null) { 82 getWorld().addJpPlanner(planner); 83 getCompiler().showMessage(" " + jpPlannerMaker.toShortString()); 84 } 85 } 86 87 for (Iterator i = aspectDec.getExtraPlanners().values().iterator(); 88 i.hasNext(); ) 89 { 90 getWorld().addJpPlanner((JpPlanner)i.next()); 91 } 92 93 getCompiler().exitNode(aspectDec); 95 } 96 97 } 98 99 | Popular Tags |