Package org.aspectj.org.eclipse.jdt.internal.compiler.ast

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration


       ((SourceTypeBinding) memberTypes[i]).scope.buildFieldsAndMethods();
  }
 
  // AspectJ Extension
  private void postParse() {
    TypeDeclaration typeDec = referenceContext;
    AbstractMethodDeclaration[] methods = typeDec.methods;
    if (methods == null) return;
    for (int i=0, len=methods.length; i < len; i++) {
      methods[i].postParse(typeDec);
    }
View Full Code Here


    if (referenceContext.memberTypes != null) {
      int size = referenceContext.memberTypes.length;
      memberTypeBindings = new ReferenceBinding[size];
      int count = 0;
      nextMember : for (int i = 0; i < size; i++) {
        TypeDeclaration memberContext = referenceContext.memberTypes[i];
        switch(TypeDeclaration.kind(memberContext.modifiers)) {
          case TypeDeclaration.INTERFACE_DECL :
          case TypeDeclaration.ANNOTATION_TYPE_DECL :
            problemReporter().illegalLocalTypeDeclaration(memberContext);
            continue nextMember;
View Full Code Here

    if (referenceContext.memberTypes != null) {
      int length = referenceContext.memberTypes.length;
      memberTypeBindings = new ReferenceBinding[length];
      int count = 0;
      nextMember : for (int i = 0; i < length; i++) {
        TypeDeclaration memberContext = referenceContext.memberTypes[i];
        switch(TypeDeclaration.kind(memberContext.modifiers)) {
          case TypeDeclaration.INTERFACE_DECL :
          case TypeDeclaration.ANNOTATION_TYPE_DECL :
            if (sourceType.isNestedType()
                && sourceType.isClass() // no need to check for enum, since implicitly static
                && !sourceType.isStatic()) {
              problemReporter().illegalLocalTypeDeclaration(memberContext);
              continue nextMember;
            }
          break;           
        }
        ReferenceBinding type = sourceType;
        // check that the member does not conflict with an enclosing type
        do {
          if (CharOperation.equals(type.sourceName, memberContext.name)) {
            problemReporter().typeCollidesWithEnclosingType(memberContext);
            continue nextMember;
          }
          type = type.enclosingType();
        } while (type != null);
        // check that the member type does not conflict with another sibling member type
        for (int j = 0; j < i; j++) {
          if (CharOperation.equals(referenceContext.memberTypes[j].name, memberContext.name)) {
            problemReporter().duplicateNestedType(memberContext);
            continue nextMember;
          }
        }

        ClassScope memberScope = new ClassScope(this, memberContext);
        // Aspectj change - pass in extra parameter
        memberTypeBindings[count++] = memberScope.buildType(sourceType, sourceType.fPackage, accessRestriction,memberContext.alternativeName());
      }
      if (count != length)
        System.arraycopy(memberTypeBindings, 0, memberTypeBindings = new ReferenceBinding[count], 0, count);
    }
    sourceType.memberTypes = memberTypeBindings;
View Full Code Here

            modifiers |= ClassFileConstants.AccAbstract;
            break checkAbstractEnum;
          }          
          // body of enum constant must implement any inherited abstract methods
          // enum type needs to implement abstract methods if one of its constants does not supply a body
          TypeDeclaration typeDeclaration = this.referenceContext;
          FieldDeclaration[] fields = typeDeclaration.fields;
          int fieldsLength = fields == null ? 0 : fields.length;
          if (fieldsLength == 0) break checkAbstractEnum; // has no constants so must implement the method itself
          AbstractMethodDeclaration[] methods = typeDeclaration.methods;
          int methodsLength = methods == null ? 0 : methods.length;
          // TODO (kent) cannot tell that the superinterfaces are empty or that their methods are implemented
          boolean definesAbstractMethod = typeDeclaration.superInterfaces != null;
          for (int i = 0; i < methodsLength && !definesAbstractMethod; i++)
            definesAbstractMethod = methods[i].isAbstract();
          if (!definesAbstractMethod) break checkAbstractEnum; // all methods have bodies
          boolean needAbstractBit = false;
          for (int i = 0; i < fieldsLength; i++) {
            FieldDeclaration fieldDecl = fields[i];
            if (fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
              if (fieldDecl.initialization instanceof QualifiedAllocationExpression) {
                needAbstractBit = true;
              } else {
                break checkAbstractEnum;
              }
            }
          }
          // tag this enum as abstract since an abstract method must be implemented AND all enum constants define an anonymous body
          // as a result, each of its anonymous constants will see it as abstract and must implement each inherited abstract method         
          if (needAbstractBit) {
            modifiers |= ClassFileConstants.AccAbstract;
          }
        }
        // final if no enum constant with anonymous body
        checkFinalEnum: {
          TypeDeclaration typeDeclaration = this.referenceContext;
          FieldDeclaration[] fields = typeDeclaration.fields;
          if (fields != null) {
            for (int i = 0, fieldsLength = fields.length; i < fieldsLength; i++) {
              FieldDeclaration fieldDecl = fields[i];
              if (fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
View Full Code Here

  List aliases;
  Map /* real type variable > alias letter */ usedAliases; // Used later when reconstructing the resolved member

  public InterTypeScope(Scope parent, ReferenceBinding onType) {
    super(parent, null);
    referenceContext = new TypeDeclaration(null);
    referenceContext.binding = makeSourceTypeBinding(onType);
    this.onType = onType;
  }
View Full Code Here

        if (parentRef != null) {
          TypeBinding parentBinding = parentRef.resolvedType;
          if (parentBinding instanceof SourceTypeBinding) {
            SourceTypeBinding parentSTB = (SourceTypeBinding) parentBinding;
            if (parentSTB.scope != null) {
              TypeDeclaration parentDecl = parentSTB.scope.referenceContext;
              if (isAspect(parentDecl)) {
                typeDecl.scope.problemReporter().signalError(typeDecl.sourceStart,typeDecl.sourceEnd,"a class cannot extend an aspect");
              }
            }
          }
View Full Code Here

    return CharOperation.contains(orgAspectJLangAnnotation, sig);
  }
 
  private boolean insideAspect() {
    if (typeStack.empty()) return false;
    TypeDeclaration typeDecl = (TypeDeclaration) typeStack.peek();
    return isAspect(typeDecl);
  }
View Full Code Here

    if (parentRef != null) {
      TypeBinding parentBinding = parentRef.resolvedType;
      if (parentBinding instanceof SourceTypeBinding) {
        SourceTypeBinding parentSTB = (SourceTypeBinding) parentBinding;
        if (parentSTB.scope!=null) { // scope is null if its a binarytypebinding (in AJ world, thats a subclass of SourceTypeBinding)
          TypeDeclaration parentDecl = parentSTB.scope.referenceContext;
          if (isAspect(parentDecl) && !Modifier.isAbstract(parentDecl.modifiers)) {
            typeDecl.scope.problemReporter().signalError(typeDecl.sourceStart,typeDecl.sourceEnd,"cannot extend a concrete aspect");
          }     
        }
      }
View Full Code Here

    }
    return null;
  }
 
  private void convertToPointcutDeclaration(MethodDeclaration methodDeclaration, ClassScope scope) {
    TypeDeclaration typeDecl = (TypeDeclaration) typeStack.peek();
    if (typeDecl.binding != null) {
      if (!typeDecl.binding.isClass()) {
        methodDeclaration.scope.problemReporter()
          .signalError(methodDeclaration.sourceStart,methodDeclaration.sourceEnd,"pointcuts can only be declared in a class or an aspect");
      }
    }
   
    if (methodDeclaration.thrownExceptions != null && methodDeclaration.thrownExceptions.length > 0) {
      methodDeclaration.scope.problemReporter()
        .signalError(methodDeclaration.sourceStart,methodDeclaration.sourceEnd,"pointcuts cannot throw exceptions!");
    }
   
    PointcutDeclaration pcDecl = new PointcutDeclaration(unit.compilationResult);
    copyAllFields(methodDeclaration,pcDecl);

    if (ajAnnotations.hasAdviceAnnotation) {
      methodDeclaration.scope.problemReporter().disallowedTargetForAnnotation(ajAnnotations.adviceAnnotation);     
    }
    if (ajAnnotations.hasAspectAnnotation) {
      methodDeclaration.scope.problemReporter().disallowedTargetForAnnotation(ajAnnotations.aspectAnnotation);     
    }
    if (ajAnnotations.hasAdviceNameAnnotation) {
      methodDeclaration.scope.problemReporter().disallowedTargetForAnnotation(ajAnnotations.adviceNameAnnotation);     
    }
 
    boolean containsIfPcd = false;
    int[] pcLocation = new int[2];
    String pointcutExpression = getStringLiteralFor("value",ajAnnotations.pointcutAnnotation,pcLocation);
    try {
      ISourceContext context = new EclipseSourceContext(unit.compilationResult,pcLocation[0]);
            Pointcut pc = null;//abstract
            if (pointcutExpression == null  || pointcutExpression.length() == 0) {
                ;//will have to ensure abstract ()V method
            } else {
                pc = new PatternParser(pointcutExpression,context).parsePointcut();
            }
            pcDecl.pointcutDesignator = (pc==null)?null:new PointcutDesignator(pc);
      pcDecl.setGenerateSyntheticPointcutMethod();
      TypeDeclaration onType = (TypeDeclaration) typeStack.peek();
      pcDecl.postParse(onType);
//      EclipseFactory factory = EclipseFactory.fromScopeLookupEnvironment(methodDeclaration.scope);
//      int argsLength = methodDeclaration.arguments == null ? 0 : methodDeclaration.arguments.length;
      FormalBinding[] bindings = buildFormalAdviceBindingsFrom(methodDeclaration);
//         FormalBinding[] bindings = new FormalBinding[argsLength];
View Full Code Here

  public Shadow makeShadow(ReferenceContext context) {
    return EclipseShadow.makeShadow(this, (ASTNode) context, context);
  }
 
  public void addSourceTypeBinding(SourceTypeBinding binding, CompilationUnitDeclaration unit) {
    TypeDeclaration decl = binding.scope.referenceContext;
   
    // Deal with the raw/basic type to give us an entry in the world type map
    UnresolvedType simpleTx = null;
    if (binding.isGenericType()) {
        simpleTx  = UnresolvedType.forRawTypeName(getName(binding));
View Full Code Here

TOP

Related Classes of org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration

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.