コード例 #1
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;
  }
コード例 #2
0
  public boolean visit(TypeDeclaration type) throws Exception {
    if (type instanceof NamespaceDeclaration) {
      NamespaceDeclaration namespaceDecl = (NamespaceDeclaration) type;
      fCurrentNamespace = namespaceDecl;
      fLastUseParts.clear();
      if (namespaceDecl.isGlobal()) {
        return visitGeneral(type);
      }
      declarations.push(type);

      int modifiers = type.getModifiers() | Modifiers.AccNameSpace;
      fCurrentQualifier = type.getName();
      Integer count = fCurrentQualifierCounts.get(fCurrentQualifier);
      count = count != null ? count + 1 : 1;
      fCurrentQualifierCounts.put(fCurrentQualifier, count);

      modifiers = markAsDeprecated(modifiers, type);
      StringBuilder metadata = new StringBuilder();
      if (fCurrentQualifier != null) {
        metadata.append(fCurrentQualifierCounts.get(fCurrentQualifier));
        metadata.append(";"); // $NON-NLS-1$
      }
      modifyDeclaration(
          type,
          new DeclarationInfo(
              IModelElement.PACKAGE_DECLARATION,
              modifiers,
              type.sourceStart(),
              type.sourceEnd() - type.sourceStart(),
              type.getNameStart(),
              type.getNameEnd() - type.getNameStart(),
              type.getName(),
              metadata.length() == 0 ? null : metadata.toString(),
              encodeDocInfo(type),
              null,
              null));
    } else {
      Declaration parentDeclaration = null;
      if (!declarations.empty()) {
        parentDeclaration = declarations.peek();
      }
      declarations.push(type);

      if (!(parentDeclaration instanceof NamespaceDeclaration)) {
        type.setModifier(Modifiers.AccGlobal);
      }

      // In case we are entering a nested element
      if (parentDeclaration instanceof MethodDeclaration) {
        if (fCurrentNamespace == null) {
          deferredDeclarations.add(type);
        } else {
          deferredNamespacedDeclarations.add(type);
        }
        return visitGeneral(type);
      }

      int modifiers = type.getModifiers();
      fCurrentParent = type.getName();

      String[] superClasses = processSuperClasses(type);
      StringBuilder metadata = new StringBuilder();
      if (fCurrentQualifier != null) {
        metadata.append(fCurrentQualifierCounts.get(fCurrentQualifier));
        metadata.append(";"); // $NON-NLS-1$
      }
      for (int i = 0; i < superClasses.length; ++i) {
        metadata.append(superClasses[i]);
        if (i < superClasses.length - 1) {
          metadata.append(","); // $NON-NLS-1$
        }
      }
      modifiers = markAsDeprecated(modifiers, type);
      modifyDeclaration(
          type,
          new DeclarationInfo(
              IModelElement.TYPE,
              modifiers,
              type.sourceStart(),
              type.sourceEnd() - type.sourceStart(),
              type.getNameStart(),
              type.getNameEnd() - type.getNameStart(),
              type.getName(),
              metadata.length() == 0 ? null : metadata.toString(),
              encodeDocInfo(type),
              fCurrentQualifier,
              null));
    }

    for (PhpIndexingVisitorExtension visitor : extensions) {
      visitor.visit(type);
    }

    return visitGeneral(type);
  }