Examples of TypeDeclaration


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

  // }

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

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

        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

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

    }
    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 noValueSupplied = true;
    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) {
        noValueSupplied = true; // matches nothing pointcut
      } else {
        noValueSupplied = false;
        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 :
View Full Code Here

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

    if (packageName.length > 0) {
      compilationUnit.currentPackage = new ImportReference(packageName, new long[]{0}, false, ClassFileConstants.AccDefault);
    }
 
    /* convert type */
    TypeDeclaration typeDeclaration = convert(type, null, null, compilationResult);
   
    IType alreadyComputedMember = type;
    IType parent = type.getDeclaringType();
    TypeDeclaration previousDeclaration = typeDeclaration;
    while(parent != null) {
      TypeDeclaration declaration = convert(parent, alreadyComputedMember, previousDeclaration, compilationResult);
     
      alreadyComputedMember = parent;
      previousDeclaration = declaration;
      parent = parent.getDeclaringType();
    }
View Full Code Here

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

    return methodDeclaration;
  }
 
  private static TypeDeclaration convert(IType type, IType alreadyComputedMember,TypeDeclaration alreadyComputedMemberDeclaration, CompilationResult compilationResult) throws JavaModelException {
    /* create type declaration - can be member type */
    TypeDeclaration typeDeclaration = new TypeDeclaration(compilationResult);

    if (type.getDeclaringType() != null) {
      typeDeclaration.bits |= ASTNode.IsMemberType;
    }
    typeDeclaration.name = type.getElementName().toCharArray();
    typeDeclaration.modifiers = type.getFlags();


    /* set superclass and superinterfaces */
    if (type.getSuperclassName() != null) {
      typeDeclaration.superclass = createTypeReference(type.getSuperclassName().toCharArray());
      typeDeclaration.superclass.bits |= ASTNode.IsSuperType;
    }
    String[] interfaceNames = type.getSuperInterfaceNames();
    int interfaceCount = interfaceNames == null ? 0 : interfaceNames.length;
    typeDeclaration.superInterfaces = new TypeReference[interfaceCount];
    for (int i = 0; i < interfaceCount; i++) {
      typeDeclaration.superInterfaces[i] = createTypeReference(interfaceNames[i].toCharArray());
      typeDeclaration.superInterfaces[i].bits |= ASTNode.IsSuperType;
    }
   
    /* convert member types */
    IType[] memberTypes = type.getTypes();
    int memberTypeCount =  memberTypes == null ? 0 : memberTypes.length;
    typeDeclaration.memberTypes = new TypeDeclaration[memberTypeCount];
    for (int i = 0; i < memberTypeCount; i++) {
      if(alreadyComputedMember != null && alreadyComputedMember.getFullyQualifiedName().equals(memberTypes[i].getFullyQualifiedName())) {
        typeDeclaration.memberTypes[i] = alreadyComputedMemberDeclaration;
      } else {
        typeDeclaration.memberTypes[i] = convert(memberTypes[i], null, null, compilationResult);
      }
    }

    /* convert fields */
    IField[] fields = type.getFields();
    int fieldCount = fields == null ? 0 : fields.length;
    typeDeclaration.fields = new FieldDeclaration[fieldCount];
    for (int i = 0; i < fieldCount; i++) {
      typeDeclaration.fields[i] = convert(fields[i], type);
    }

    /* convert methods - need to add default constructor if necessary */
    IMethod[] methods = type.getMethods();
    int methodCount = methods == null ? 0 : methods.length;

    /* source type has a constructor ?           */
    /* by default, we assume that one is needed. */
    int neededCount = 1;
    for (int i = 0; i < methodCount; i++) {
      if (methods[i].isConstructor()) {
        neededCount = 0;
        // Does not need the extra constructor since one constructor already exists.
        break;
      }
    }
    boolean isInterface = type.isInterface();
    neededCount = isInterface ? 0 : neededCount;
    typeDeclaration.methods = new AbstractMethodDeclaration[methodCount + neededCount];
    if (neededCount != 0) { // add default constructor in first position
      typeDeclaration.methods[0] = typeDeclaration.createDefaultConstructor(false, false);
    }
    boolean hasAbstractMethods = false;
    for (int i = 0; i < methodCount; i++) {
      AbstractMethodDeclaration method =convert(methods[i], type, compilationResult);
      boolean isAbstract;
View Full Code Here

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

        this.typeDeclaration == null ?
          (this.parsedUnit == null ? null : this.parsedUnit.types) :
          this.typeDeclaration.memberTypes;
      if (typeDeclarations == null) return null;
      for (int i = 0, length = typeDeclarations.length; i < length; i++) {
        TypeDeclaration declaration = typeDeclarations[i];
        if (CharOperation.equals(simpleTypeName, declaration.name)) {
          this.typeDeclaration = declaration;
          return declaration.binding;
        }
      }
View Full Code Here

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

  /*
   * Finds the FieldDeclaration in the given ast corresponding to the given field handle.
   * Returns null if not found.
   */
  public FieldDeclaration findField(IField fieldHandle) {
    TypeDeclaration typeDecl = findType((IType)fieldHandle.getParent());
    if (typeDecl == null) return null;
    FieldDeclaration[] fields = typeDecl.fields;
    if (fields != null) {
      char[] fieldName = fieldHandle.getElementName().toCharArray();
      for (int i = 0, length = fields.length; i < length; i++) {
View Full Code Here

Examples of org.drools.core.rule.TypeDeclaration

    public void finalize( TypeDeclaration type, AbstractClassTypeDeclarationDescr typeDescr, PackageRegistry pkgRegistry, Map<String, PackageRegistry> pkgRegistryMap, ClassHierarchyManager hierarchyManager ) {
        // prefer definitions where possible
        if ( type.getNature() == TypeDeclaration.Nature.DEFINITION ) {
            hierarchyManager.addDeclarationToPackagePreservingOrder( type, typeDescr, pkgRegistry.getPackage(), pkgRegistryMap );
        } else {
            TypeDeclaration oldType = pkgRegistry.getPackage().getTypeDeclaration( type.getTypeName() );
            if ( oldType == null ) {
                pkgRegistry.getPackage().addTypeDeclaration( type );
            } else {
                if (type.getRole() == TypeDeclaration.Role.EVENT) {
                    oldType.setRole(TypeDeclaration.Role.EVENT);
                    if ( type.getDurationAttribute() != null ) {
                        oldType.setDurationAttribute( type.getDurationAttribute() );
                        oldType.setDurationExtractor( type.getDurationExtractor() );
                    }
                    if ( type.getTimestampAttribute() != null ) {
                        oldType.setTimestampAttribute( type.getTimestampAttribute() );
                        oldType.setTimestampExtractor( type.getTimestampExtractor() );
                    }
                    if ( type.getExpirationOffset() >= 0 ) {
                        oldType.setExpirationOffset( type.getExpirationOffset() );
                    }
                }
                if (type.isPropertyReactive()) {
                    oldType.setPropertyReactive(true);
                }
            }
        }
    }
View Full Code Here

Examples of org.drools.rule.TypeDeclaration

        }
        pkg.getClassFieldAccessorStore().merge( newPkg.getClassFieldAccessorStore() );
        pkg.getDialectRuntimeRegistry().onBeforeExecute();

        // we have to do this before the merging, as it does some classloader resolving
        TypeDeclaration lastType = null;
        try {
            // Resolve the class for the type declaation
            if ( newPkg.getTypeDeclarations() != null ) {
                // add type declarations
                for ( TypeDeclaration type : newPkg.getTypeDeclarations().values() ) {
                    lastType = type;
                    type.setTypeClass( this.rootClassLoader.loadClass( type.getTypeClassName() ) );
                }
            }
        } catch ( ClassNotFoundException e ) {
            throw new RuntimeDroolsException( "unable to resolve Type Declaration class '" + lastType.getTypeName() + "'" );
        }

        // now merge the new package into the existing one
        mergePackage( pkg,
                      newPkg );
View Full Code Here

Examples of org.eclipse.dltk.ast.declarations.TypeDeclaration

        return;
      }
      if (nde.sourceStart() <= node.sourceStart() && node.sourceEnd() <= nde.sourceEnd()) {
        if (element instanceof IParent) {
          if (nde instanceof TypeDeclaration) {
            TypeDeclaration type = (TypeDeclaration) nde;
            String typeName = getNodeChildName(type);
            IModelElement e = findChildrenByName(typeName, element);
            if (e == null && type.getName().startsWith("::")) {
              try {
                e = (IModelElement) findTypeFrom(sourceModule.getChildren(), "", type.getName()
                        .replaceAll("::", "\\$"), '$');
              } catch (ModelException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.