Package org.aspectj.bridge.context

Examples of org.aspectj.bridge.context.ContextToken


    // the list than outer shadows. That's fine. This order is preserved if:

    // A preceeds B iff B.getStart() is LATER THAN A.getStart().

    for (BcelShadow shadow : shadows) {
      ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.IMPLEMENTING_ON_SHADOW,
          shadow);
      shadow.implement();
      CompilationAndWeavingContext.leavingPhase(tok);
    }
    // int ii =
View Full Code Here


    if (baseHandler instanceof ILifecycleAware) {
      ((ILifecycleAware) baseHandler).buildStarting(!isFullBuild);
    }
    CompilationAndWeavingContext.reset();
    int phase = isFullBuild ? CompilationAndWeavingContext.BATCH_BUILD : CompilationAndWeavingContext.INCREMENTAL_BUILD;
    ContextToken ct = CompilationAndWeavingContext.enteringPhase(phase, buildConfig);
    try {
      if (isFullBuild) {
        this.state = new AjState(this);
      }
View Full Code Here

  }

  private void doPendingWeaves() {
    for (Iterator i = pendingTypesToWeave.iterator(); i.hasNext();) {
      SourceTypeBinding t = (SourceTypeBinding) i.next();
      ContextToken tok = CompilationAndWeavingContext.enteringPhase(
          CompilationAndWeavingContext.WEAVING_INTERTYPE_DECLARATIONS, t.sourceName);
      weaveInterTypeDeclarations(t);
      CompilationAndWeavingContext.leavingPhase(tok);
    }
    pendingTypesToWeave.clear();
View Full Code Here

   * @param mode 0=do everything, 1=do declare parents, 2=do ITDs
   */
  private void weaveInterTypeDeclarations(SourceTypeBinding sourceType, List<ConcreteTypeMunger> typeMungers,
      List<DeclareParents> declareParents, List<DeclareAnnotation> declareAnnotationOnTypes, boolean skipInners, int mode) {

    ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_INTERTYPE_DECLARATIONS,
        sourceType.sourceName);

    ResolvedType onType = factory.fromEclipse(sourceType);

    // AMC we shouldn't need this when generic sigs are fixed??
View Full Code Here

    }
  }

  private boolean doDeclareParents(DeclareParents declareParents, SourceTypeBinding sourceType) {
    ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_DECLARE_PARENTS,
        sourceType.sourceName);
    ResolvedType resolvedSourceType = factory.fromEclipse(sourceType);
    List newParents = declareParents.findMatchingNewParents(resolvedSourceType, false);
    if (!newParents.isEmpty()) {
      for (Iterator i = newParents.iterator(); i.hasNext();) {
View Full Code Here

    }
    if (!rtx.isExposedToWeaver()) {
      return false;
    }

    ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_DECLARE_ANNOTATIONS,
        sourceType.sourceName);

    // Get the annotation specified in the declare
    UnresolvedType aspectType = decA.getAspect();
    if (aspectType instanceof ReferenceType) {
View Full Code Here

  }

  // ??? duplicates some of super's code
  public void completeTypeBindings() {
    AsmManager.setCompletingTypeBindings(true);
    ContextToken completeTypeBindingsToken = CompilationAndWeavingContext.enteringPhase(
        CompilationAndWeavingContext.COMPLETING_TYPE_BINDINGS, "");
    // builtInterTypesAndPerClauses = false;
    // pendingTypesToWeave = new ArrayList();
    stepCompleted = BUILD_TYPE_HIERARCHY;

    for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
      ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CHECK_AND_SET_IMPORTS,
          units[i].compilationResult.fileName);
      units[i].scope.checkAndSetImports();
      CompilationAndWeavingContext.leavingPhase(tok);
    }
    stepCompleted = CHECK_AND_SET_IMPORTS;

    for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
      ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CONNECTING_TYPE_HIERARCHY,
          units[i].compilationResult.fileName);
      units[i].scope.connectTypeHierarchy();
      CompilationAndWeavingContext.leavingPhase(tok);
    }
    stepCompleted = CONNECT_TYPE_HIERARCHY;

    for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
      ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.BUILDING_FIELDS_AND_METHODS,
          units[i].compilationResult.fileName);
      // units[i].scope.checkParameterizedTypes(); do this check a little
      // later, after ITDs applied to stbs
      units[i].scope.buildFieldsAndMethods();
      CompilationAndWeavingContext.leavingPhase(tok);
    }

    // would like to gather up all TypeDeclarations at this point and put
    // them in the factory
    for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
      SourceTypeBinding[] b = units[i].scope.topLevelTypes;
      for (int j = 0; j < b.length; j++) {
        factory.addSourceTypeBinding(b[j], units[i]);
      }
    }

    // We won't find out about anonymous types until later though, so
    // register to be
    // told about them when they turn up.
    AnonymousClassPublisher.aspectOf().setAnonymousClassCreationListener(this);

    // need to build inter-type declarations for all AspectDeclarations at
    // this point
    // this MUST be done in order from super-types to subtypes
    List<SourceTypeBinding> typesToProcess = new ArrayList<SourceTypeBinding>();
    List<SourceTypeBinding> aspectsToProcess = new ArrayList<SourceTypeBinding>();
    for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
      CompilationUnitScope cus = units[i].scope;
      SourceTypeBinding[] stbs = cus.topLevelTypes;
      for (int j = 0; j < stbs.length; j++) {
        SourceTypeBinding stb = stbs[j];
        typesToProcess.add(stb);
        TypeDeclaration typeDeclaration = stb.scope.referenceContext;
        if (typeDeclaration instanceof AspectDeclaration) {
          aspectsToProcess.add(stb);
        }
      }
    }
    factory.getWorld().getCrosscuttingMembersSet().reset();

    // Need to do these before the other ITDs
    for (SourceTypeBinding aspectToProcess : aspectsToProcess) {
      processInterTypeMemberTypes(aspectToProcess.scope);
    }

    while (typesToProcess.size() > 0) {
      // removes types from the list as they are processed...
      collectAllITDsAndDeclares(typesToProcess.get(0), typesToProcess);
    }

    factory.finishTypeMungers();

    // now do weaving
    List<ConcreteTypeMunger> typeMungers = factory.getTypeMungers();

    List<DeclareParents> declareParents = factory.getDeclareParents();
    List<DeclareAnnotation> declareAnnotationOnTypes = factory.getDeclareAnnotationOnTypes();

    doPendingWeaves();

    // We now have some list of types to process, and we are about to apply
    // the type mungers.
    // There can be situations where the order of types passed to the
    // compiler causes the
    // output from the compiler to vary - THIS IS BAD. For example, if we
    // have class A
    // and class B extends A. Also, an aspect that 'declare parents: A+
    // implements Serializable'
    // then depending on whether we see A first, we may or may not make B
    // serializable.

    // The fix is to process them in the right order, ensuring that for a
    // type we process its
    // supertypes and superinterfaces first. This algorithm may have
    // problems with:
    // - partial hierarchies (e.g. suppose types A,B,C are in a hierarchy
    // and A and C are to be woven but not B)
    // - weaving that brings new types in for processing (see
    // pendingTypesToWeave.add() calls) after we thought
    // we had the full list.
    //
    // but these aren't common cases (he bravely said...)
    boolean typeProcessingOrderIsImportant = declareParents.size() > 0 || declareAnnotationOnTypes.size() > 0; // DECAT

    if (typeProcessingOrderIsImportant) {
      typesToProcess = new ArrayList<SourceTypeBinding>();
      for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
        CompilationUnitScope cus = units[i].scope;
        SourceTypeBinding[] stbs = cus.topLevelTypes;
        for (int j = 0; j < stbs.length; j++) {
          SourceTypeBinding stb = stbs[j];
          typesToProcess.add(stb);
        }
      }

      List<SourceTypeBinding> stb2 = new ArrayList<SourceTypeBinding>();
      stb2.addAll(typesToProcess);

      while (typesToProcess.size() > 0) {
        // A side effect of weaveIntertypes() is that the processed type is removed from the collection
        weaveIntertypes(typesToProcess, typesToProcess.get(0), typeMungers, declareParents, declareAnnotationOnTypes, 1);
      }

      while (stb2.size() > 0) {
        // A side effect of weaveIntertypes() is that the processed type is removed from the collection
        weaveIntertypes(stb2, stb2.get(0), typeMungers, declareParents, declareAnnotationOnTypes, 2);
      }

    } else {
      // Order isn't important
      for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
        weaveInterTypeDeclarations(units[i].scope, typeMungers, declareParents, declareAnnotationOnTypes);
      }
    }

    for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
      units[i].scope.checkParameterizedTypes();
    }

    for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
      SourceTypeBinding[] b = units[i].scope.topLevelTypes;
      for (int j = 0; j < b.length; j++) {
        ContextToken tok = CompilationAndWeavingContext.enteringPhase(
            CompilationAndWeavingContext.RESOLVING_POINTCUT_DECLARATIONS, b[j].sourceName);
        resolvePointcutDeclarations(b[j].scope);
        CompilationAndWeavingContext.leavingPhase(tok);
      }
    }

    for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
      SourceTypeBinding[] b = units[i].scope.topLevelTypes;
      for (int j = 0; j < b.length; j++) {
        ContextToken tok = CompilationAndWeavingContext.enteringPhase(
            CompilationAndWeavingContext.ADDING_DECLARE_WARNINGS_AND_ERRORS, b[j].sourceName);
        addAdviceLikeDeclares(b[j].scope);
        CompilationAndWeavingContext.leavingPhase(tok);
      }
    }
View Full Code Here

   * @param sourceType
   * @param yetToProcess
   */
  private void collectAllITDsAndDeclares(SourceTypeBinding sourceType, Collection yetToProcess) {
    // Look at the supertype first
    ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.COLLECTING_ITDS_AND_DECLARES,
        sourceType.sourceName);

    yetToProcess.remove(sourceType);
    // look out our direct supertype
    doSupertypesFirst(sourceType.superclass(), yetToProcess);
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) {
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 {
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.