예제 #1
0
  public boolean visit(PHPFieldDeclaration decl) throws Exception {
    // This is variable declaration:
    int modifiers = markAsDeprecated(decl.getModifiers(), decl);

    StringBuilder metadata = new StringBuilder();
    if (fCurrentQualifier != null) {
      metadata.append(fCurrentQualifierCounts.get(fCurrentQualifier));
      metadata.append(";"); // $NON-NLS-1$
    }

    modifyDeclaration(
        decl,
        new DeclarationInfo(
            IModelElement.FIELD,
            modifiers,
            decl.sourceStart(),
            decl.sourceEnd() - decl.sourceStart(),
            decl.getNameStart(),
            decl.getNameEnd() - decl.getNameStart(),
            decl.getName(),
            metadata.length() == 0 ? null : metadata.toString(),
            encodeDocInfo(decl),
            fCurrentQualifier,
            fCurrentParent));

    return visitGeneral(decl);
  }
  public boolean visit(PHPFieldDeclaration declaration) throws Exception {
    // This is variable declaration:
    ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo();
    info.modifiers = declaration.getModifiers();
    info.name = declaration.getName();
    SimpleReference var = declaration.getRef();
    info.nameSourceEnd = var.sourceEnd() - 1;
    info.nameSourceStart = var.sourceStart();
    info.declarationStart = declaration.getDeclarationStart();
    info.modifiers = markAsDeprecated(info.modifiers, declaration);
    PHPDocBlock doc = declaration.getPHPDoc();
    if (doc != null) {
      for (PHPDocTag tag : doc.getTags(PHPDocTag.VAR)) {
        // do it like for
        // PHPDocumentationContentAccess#handleBlockTags(List tags):
        // variable name can be optional, but if present keep only
        // the good ones
        if (tag.getVariableReference() != null
            && !tag.getVariableReference().getName().equals(declaration.getName())) {
          continue;
        }

        if (tag.getTypeReferences().size() > 0) {
          info.type = PHPModelUtils.appendTypeReferenceNames(tag.getTypeReferences());
          break;
        }
      }
    }
    fInfoStack.push(info);
    fRequestor.enterField(info);
    return true;
  }