Esempio n. 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(Statement e) throws Exception {
   if (typeDeclaration.sourceStart() < e.sourceStart()
       && typeDeclaration.sourceEnd() > e.sourceEnd()) {
     if (e instanceof PHPFieldDeclaration) {
       PHPFieldDeclaration phpFieldDecl = (PHPFieldDeclaration) e;
       if (phpFieldDecl.getDeclarationStart() == offset
           && phpFieldDecl.sourceEnd() - phpFieldDecl.getDeclarationStart() == length) {
         result = ((PHPFieldDeclaration) e).getVariableValue();
         if (result instanceof Scalar) {
           Scalar scalar = (Scalar) result;
           if (scalar.getScalarType() == Scalar.TYPE_STRING
               && scalar.getValue().toLowerCase().equals(NULL)) {
             result = null;
           }
         }
         context = contextStack.peek();
       }
     }
   }
   return visitGeneral(e);
 }
  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;
  }
 public boolean endvisit(PHPFieldDeclaration declaration) throws Exception {
   fRequestor.exitField(declaration.sourceEnd() - 1);
   fInfoStack.pop();
   return true;
 }