コード例 #1
0
 public void createPackageInfoType() {
   TypeDeclaration declaration = new TypeDeclaration(this.compilationResult);
   declaration.name = TypeConstants.PACKAGE_INFO_NAME;
   declaration.modifiers = ClassFileConstants.AccDefault | ClassFileConstants.AccInterface;
   declaration.javadoc = this.javadoc;
   this.types[0] = declaration; // Assumes the first slot is meant for this type
 }
コード例 #2
0
 public void resolve() {
   int startingTypeIndex = 0;
   boolean isPackageInfo = isPackageInfo();
   if (this.types != null && isPackageInfo) {
     // resolve synthetic type declaration
     final TypeDeclaration syntheticTypeDeclaration = this.types[0];
     // set empty javadoc to avoid missing warning (see bug
     // https://bugs.eclipse.org/bugs/show_bug.cgi?id=95286)
     if (syntheticTypeDeclaration.javadoc == null) {
       syntheticTypeDeclaration.javadoc =
           new Javadoc(
               syntheticTypeDeclaration.declarationSourceStart,
               syntheticTypeDeclaration.declarationSourceStart);
     }
     syntheticTypeDeclaration.resolve(this.scope);
     /*
      * resolve javadoc package if any, skip this step if we don't have a valid scope due to an earlier error (bug 252555)
      * we do it now as the javadoc in the fake type won't be resolved. The peculiar usage of MethodScope to resolve the
      * package level javadoc is because the CU level resolve method	is a NOP to mimic Javadoc's behavior and can't be used
      * as such.
      */
     if (this.javadoc != null && syntheticTypeDeclaration.staticInitializerScope != null) {
       this.javadoc.resolve(syntheticTypeDeclaration.staticInitializerScope);
     }
     startingTypeIndex = 1;
   } else {
     // resolve compilation unit javadoc package if any
     if (this.javadoc != null) {
       this.javadoc.resolve(this.scope);
     }
   }
   if (this.currentPackage != null && this.currentPackage.annotations != null && !isPackageInfo) {
     this.scope
         .problemReporter()
         .invalidFileNameForPackageAnnotations(this.currentPackage.annotations[0]);
   }
   try {
     if (this.types != null) {
       for (int i = startingTypeIndex, count = this.types.length; i < count; i++) {
         this.types[i].resolve(this.scope);
       }
     }
     if (!this.compilationResult.hasMandatoryErrors()) checkUnusedImports();
     reportNLSProblems();
   } catch (AbortCompilationUnit e) {
     this.ignoreFurtherInvestigation = true;
     return;
   }
 }
コード例 #3
0
  public void resolve() {
    int startingTypeIndex = 0;
    boolean isPackageInfo = false; // isPackageInfo();
    if (this.types != null && isPackageInfo) {
      // resolve synthetic type declaration
      final TypeDeclaration syntheticTypeDeclaration = types[0];
      // set empty javadoc to avoid missing warning (see bug
      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=95286)
      if (syntheticTypeDeclaration.javadoc == null) {
        syntheticTypeDeclaration.javadoc =
            new Javadoc(
                syntheticTypeDeclaration.declarationSourceStart,
                syntheticTypeDeclaration.declarationSourceStart);
      }
      syntheticTypeDeclaration.resolve(this.scope);
      // resolve annotations if any
      //			if (this.currentPackage!= null && this.currentPackage.annotations != null) {
      //				resolveAnnotations(syntheticTypeDeclaration.staticInitializerScope,
      // this.currentPackage.annotations, this.scope.getDefaultPackage());
      //			}
      // resolve javadoc package if any
      if (this.javadoc != null) {
        this.javadoc.resolve(syntheticTypeDeclaration.staticInitializerScope);
      }
      startingTypeIndex = 1;
    } else {
      // resolve compilation unit javadoc package if any
      if (this.javadoc != null) {
        this.javadoc.resolve(this.scope);
      }
    }

    try {
      if (types != null) {
        for (int i = startingTypeIndex, count = types.length; i < count; i++) {
          types[i].resolve(scope);
        }
      }
      if (statements != null) {
        for (int i = 0, count = statements.length; i < count; i++) {
          statements[i].resolve(scope);
        }
      }
      reportNLSProblems();
    } catch (AbortCompilationUnit e) {
      this.ignoreFurtherInvestigation = true;
      return;
    }
  }
コード例 #4
0
  protected void consumeClassHeaderName1() {
    // ClassHeaderName ::= Modifiersopt 'class' 'Identifier'
    TypeDeclaration typeDecl;
    if (this.nestedMethod[this.nestedType] == 0) {
      if (this.nestedType != 0) {
        typeDecl = new TypeDeclaration(this.compilationUnit.compilationResult);
        typeDecl.bits |= ASTNode.IsMemberTypeMASK;
      } else {
        typeDecl = new CodeSnippetTypeDeclaration(this.compilationUnit.compilationResult);
      }
    } else {
      // Record that the block has a declaration for local types
      typeDecl = new TypeDeclaration(this.compilationUnit.compilationResult);
      typeDecl.bits |= ASTNode.IsLocalTypeMASK;
      markEnclosingMemberWithLocalType();
      blockReal();
    }

    // highlight the name of the type
    long pos = this.identifierPositionStack[this.identifierPtr];
    typeDecl.sourceEnd = (int) pos;
    typeDecl.sourceStart = (int) (pos >>> 32);
    typeDecl.name = this.identifierStack[this.identifierPtr--];
    this.identifierLengthPtr--;

    // compute the declaration source too
    typeDecl.declarationSourceStart = this.intStack[this.intPtr--];
    this.intPtr--;
    // 'class' and 'interface' push an int position
    typeDecl.modifiersSourceStart = this.intStack[this.intPtr--];
    typeDecl.modifiers = this.intStack[this.intPtr--];
    if (typeDecl.modifiersSourceStart >= 0) {
      typeDecl.declarationSourceStart = typeDecl.modifiersSourceStart;
    }
    typeDecl.bodyStart = typeDecl.sourceEnd + 1;
    pushOnAstStack(typeDecl);

    this.listLength = 0; // will be updated when reading super-interfaces
    // recovery
    if (this.currentElement != null) {
      this.lastCheckPoint = typeDecl.bodyStart;
      this.currentElement = this.currentElement.add(typeDecl, 0);
      this.lastIgnoredToken = -1;
    }
    // javadoc
    typeDecl.javadoc = this.javadoc;
    this.javadoc = null;
  }