Package org.aspectj.bridge.context

Examples of org.aspectj.bridge.context.ContextToken


//        return wovenClassNames;
//    }
   
    // variation of "weave" that sources class files from an external source.
    public Collection weave(IClassFileProvider input) throws IOException {
      ContextToken weaveToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING, "");
      Collection wovenClassNames = new ArrayList();
      IWeaveRequestor requestor = input.getRequestor();

        // special case for AtAspectJMungerOnly - see #113587
        if (input.isApplyAtAspectJMungersOnly()) {
            ContextToken atAspectJMungersOnly = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_ATASPECTJTYPE_MUNGERS_ONLY, "");
            requestor.weavingAspects();
            ContextToken aspectToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_ASPECTS, "");
            for (Iterator i = input.getClassFileIterator(); i.hasNext(); ) {
                UnwovenClassFile classFile = (UnwovenClassFile)i.next();
                String className = classFile.getClassName();
                ResolvedType theType = world.resolve(className);
                if (theType.isAnnotationStyleAspect()) {
                    BcelObjectType classType = BcelWorld.getBcelObjectType(theType);
                    if (classType==null) {
                       throw new BCException("Can't find bcel delegate for "+className+" type="+theType.getClass());
                    }
                    LazyClassGen clazz = classType.getLazyClassGen();
                    BcelPerClauseAspectAdder selfMunger = new BcelPerClauseAspectAdder(theType, theType.getPerClause().getKind());
                    selfMunger.forceMunge(clazz, true);
                    classType.finishedWith();
                    UnwovenClassFile[] newClasses = getClassFilesFor(clazz);
                    for (int news = 0; news < newClasses.length; news++) {
                        requestor.acceptResult(newClasses[news]);
                    }
                    wovenClassNames.add(classFile.getClassName());
                }
            }
            requestor.weaveCompleted();
            CompilationAndWeavingContext.leavingPhase(atAspectJMungersOnly);
            return wovenClassNames;
        }

        requestor.processingReweavableState();
      ContextToken reweaveToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_REWEAVABLE_STATE,"");
    prepareToProcessReweavableState();
    // clear all state from files we'll be reweaving
    for (Iterator i = input.getClassFileIterator(); i.hasNext(); ) {
        UnwovenClassFile classFile = (UnwovenClassFile)i.next();
      String className = classFile.getClassName();
        BcelObjectType classType = getClassType(className);
       
        // null return from getClassType() means the delegate is an eclipse source type - so
        // there *cant* be any reweavable state... (he bravely claimed...)
        if (classType !=null) {
          ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_REWEAVABLE_STATE, className);
          processReweavableStateIfPresent(className, classType);
          CompilationAndWeavingContext.leavingPhase(tok);
        }
    }

    CompilationAndWeavingContext.leavingPhase(reweaveToken);
   
    ContextToken typeMungingToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_TYPE_MUNGERS,"");
    requestor.addingTypeMungers();
       
        // We process type mungers in two groups, first mungers that change the type
        // hierarchy, then 'normal' ITD type mungers.
       
       
        // Process the types in a predictable order (rather than the order encountered).
        // For class A, the order is superclasses of A then superinterfaces of A
        // (and this mechanism is applied recursively)
        List typesToProcess = new ArrayList();
        for (Iterator iter = input.getClassFileIterator(); iter.hasNext();) {
      UnwovenClassFile clf = (UnwovenClassFile) iter.next();
            typesToProcess.add(clf.getClassName());
        }
        while (typesToProcess.size()>0) {
            weaveParentsFor(typesToProcess,(String)typesToProcess.get(0));
       
       
        for (Iterator i = input.getClassFileIterator(); i.hasNext(); ) {
            UnwovenClassFile classFile = (UnwovenClassFile)i.next();
            String className = classFile.getClassName();
            addNormalTypeMungers(className);
        }

        CompilationAndWeavingContext.leavingPhase(typeMungingToken);
       
    requestor.weavingAspects();
    ContextToken aspectToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_ASPECTS, "");
    // first weave into aspects
    for (Iterator i = input.getClassFileIterator(); i.hasNext(); ) {
        UnwovenClassFile classFile = (UnwovenClassFile)i.next();
      String className = classFile.getClassName();
      ResolvedType theType = world.resolve(className);
      if (theType.isAspect()) {
         BcelObjectType classType = BcelWorld.getBcelObjectType(theType);
        if (classType==null) {
         
          // Sometimes.. if the Bcel Delegate couldn't be found then a problem occurred at compile time - on
          // a previous compiler run.  In this case I assert the delegate will still be an EclipseSourceType
          // and we can ignore the problem here (the original compile error will be reported again from
          // the eclipse source type) - pr113531
          ReferenceTypeDelegate theDelegate = ((ReferenceType)theType).getDelegate();
          if (theDelegate.getClass().getName().endsWith("EclipseSourceType")) continue;

          throw new BCException("Can't find bcel delegate for "+className+" type="+theType.getClass());
        }
            weaveAndNotify(classFile, classType,requestor);
            wovenClassNames.add(className);
        }
    }
   
    CompilationAndWeavingContext.leavingPhase(aspectToken);

    requestor.weavingClasses();
    ContextToken classToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_CLASSES, "");
    // then weave into non-aspects
    for (Iterator i = input.getClassFileIterator(); i.hasNext(); ) {
        UnwovenClassFile classFile = (UnwovenClassFile)i.next();
      String className = classFile.getClassName();
      ResolvedType theType = world.resolve(className);
View Full Code Here


         ResolvedType rtxI = interfaceTypes[i];
         if (typesForWeaving.contains(rtxI.getName())) {
           weaveParentsFor(typesForWeaving,rtxI.getName());
         }
       }
       ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_DECLARE_PARENTS,rtx.getName());
           weaveParentTypeMungers(rtx); // Now do this type
           CompilationAndWeavingContext.leavingPhase(tok);
           typesForWeaving.remove(typeToWeave); // and remove it from the list of those to process
    }
View Full Code Here

    }
  }

    private void weaveAndNotify(UnwovenClassFile classFile, BcelObjectType classType,
                            IWeaveRequestor requestor) throws IOException {
      ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_TYPE, classType.getResolvedTypeX().getName());
      LazyClassGen clazz = weaveWithoutDump(classFile,classType);
      classType.finishedWith();
    //clazz is null if the classfile was unchanged by weaving...
    if (clazz != null) {
      UnwovenClassFile[] newClasses = getClassFilesFor(clazz);
View Full Code Here

    }
    return didSomething;
  }
   
    public void weaveNormalTypeMungers(ResolvedType onType) {
      ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_TYPE_MUNGERS, onType.getName());
      if (onType.isRawType() || onType.isParameterizedType()) onType = onType.getGenericType();
    for (Iterator i = typeMungerList.iterator(); i.hasNext(); ) {
      ConcreteTypeMunger m = (ConcreteTypeMunger)i.next();
      if (!m.isLateMunger() && m.matches(onType)) {
        onType.addInterTypeMunger(m);
View Full Code Here

        boolean batch) throws IOException, AbortException {
        boolean ret = true;
      batchCompile = batch;
     
      int phase = batch ? CompilationAndWeavingContext.BATCH_BUILD : CompilationAndWeavingContext.INCREMENTAL_BUILD;
      ContextToken ct = CompilationAndWeavingContext.enteringPhase(phase ,buildConfig);
        try {
          if (batch) {
            this.state = new AjState(this);
          }
         
View Full Code Here

    fixSuperCallsInBody();
  }

  private void fixSuperCallsForInterfaceContext(ClassScope scope) {
    if (onTypeBinding.isInterface()) {
      ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.FIXING_SUPER_CALLS, selector);
      InterSuperFixerVisitor v =
        new InterSuperFixerVisitor(this,
            EclipseFactory.fromScopeLookupEnvironment(scope), scope);
      this.traverse(v, scope);
      CompilationAndWeavingContext.leavingPhase(tok);
View Full Code Here

   * Called from AspectDeclarations.buildInterTypeAndPerClause
   */
  public abstract EclipseTypeMunger build(ClassScope classScope);

  public void fixSuperCallsInBody() {
    ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.FIXING_SUPER_CALLS_IN_ITDS, selector);
    SuperFixerVisitor v = new SuperFixerVisitor(this, onTypeBinding);
    this.traverse(v, (ClassScope)null);
    munger.setSuperMethodsCalled(v.superMethodsCalled);
    CompilationAndWeavingContext.leavingPhase(tok);
  }
View Full Code Here

  //        }

  boolean inBlockThatCantRun = false;

  public boolean visit(MessageSend call, BlockScope scope) {
    ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.OPTIMIZING_THIS_JOIN_POINT_CALLS, call.selector);
    Expression receiver = call.receiver;
    if (isRef(receiver, thisJoinPointDec)) {
      if (canTreatAsStatic(new String(call.selector))) {
        if (replaceEffectivelyStaticRefs) {
          replaceEffectivelyStaticRef(call);
View Full Code Here

  public void endVisit(TypeDeclaration typeDeclaration,CompilationUnitScope scope) {
    typeStack.pop();
  }
 
  private void checkTypeDeclaration(TypeDeclaration typeDecl) {
    ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.VALIDATING_AT_ASPECTJ_ANNOTATIONS, typeDecl.name);
    if (!(typeDecl instanceof AspectDeclaration)) {
      if (ajAnnotations.hasAspectAnnotation) {
        validateAspectDeclaration(typeDecl);
      } else {
        // check that class doesn't extend aspect
View Full Code Here

    }
    CompilationAndWeavingContext.leavingPhase(tok);
  }
 
  public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
    ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.VALIDATING_AT_ASPECTJ_ANNOTATIONS, methodDeclaration.selector);
    ajAnnotations = new AspectJAnnotations(methodDeclaration.annotations);
    if (!methodDeclaration.getClass().equals(AjMethodDeclaration.class)) {
      // simply test for innapropriate use of annotations on code-style members
      if (methodDeclaration instanceof PointcutDeclaration) {
        if (ajAnnotations.hasMultiplePointcutAnnotations ||
View Full Code Here

TOP

Related Classes of org.aspectj.bridge.context.ContextToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.