Exemplo n.º 1
0
 public boolean visit(ConstantDeclaration declaration) throws Exception {
   int modifiers = Modifiers.AccConstant | Modifiers.AccPublic | Modifiers.AccFinal;
   if (fCurrentParent != null) {
     modifiers = modifiers | PHPCoreConstants.AccClassField;
   }
   modifiers = markAsDeprecated(modifiers, declaration);
   ConstantReference constantName = declaration.getConstantName();
   int offset = constantName.sourceStart();
   int length = constantName.sourceEnd();
   StringBuilder metadata = new StringBuilder();
   if (fCurrentQualifier != null) {
     metadata.append(fCurrentQualifierCounts.get(fCurrentQualifier));
     metadata.append(";"); // $NON-NLS-1$
   }
   modifyDeclaration(
       declaration,
       new DeclarationInfo(
           IModelElement.FIELD,
           modifiers,
           offset,
           length,
           offset,
           length,
           ASTUtils.stripQuotes(constantName.getName()),
           metadata.length() == 0 ? null : metadata.toString(),
           encodeDocInfo(declaration),
           fCurrentQualifier,
           fCurrentParent));
   return visitGeneral(declaration);
 }
Exemplo n.º 2
0
  public boolean visit(CallExpression call) throws Exception {
    FieldDeclaration constantDecl = ASTUtils.getConstantDeclaration(call);
    if (constantDecl != null) {
      // In case we are entering a nested element
      if (!declarations.empty() && declarations.peek() instanceof MethodDeclaration) {
        deferredDeclarations.add(constantDecl);
        return visitGeneral(call);
      }

      visit((FieldDeclaration) constantDecl);

    } else {
      int argsCount = 0;
      CallArgumentsList args = call.getArgs();
      if (args != null && args.getChilds() != null) {
        argsCount = args.getChilds().size();
      }

      modifyReference(
          call,
          new ReferenceInfo(
              IModelElement.METHOD,
              call.sourceStart(),
              call.sourceEnd() - call.sourceStart(),
              call.getName(),
              Integer.toString(argsCount),
              null));
    }

    return visitGeneral(call);
  }
  public boolean visit(CallExpression call) throws Exception {
    FieldDeclaration constantDecl = ASTUtils.getConstantDeclaration(call);
    if (constantDecl != null) {
      // In case we are entering a nested element
      if (!declarations.empty() && declarations.peek() instanceof MethodDeclaration) {
        deferredDeclarations.add(constantDecl);
        return false;
      }

      visit((FieldDeclaration) constantDecl);

    } else {
      int argsCount = 0;
      CallArgumentsList args = call.getArgs();
      if (args != null && args.getChilds() != null) {
        argsCount = args.getChilds().size();
      }
      fRequestor.acceptMethodReference(
          call.getName(),
          argsCount,
          call.getCallName().sourceStart(),
          call.getCallName().sourceEnd());
    }
    return true;
  }
Exemplo n.º 4
0
 protected void handleVarComment() {
   String content = yytext();
   int start = getTokenStartPosition();
   int end = start + getTokenLength();
   VarComment varComment = ASTUtils.parseVarComment(content, start, end);
   if (varComment != null) {
     getCommentList().add(varComment);
   }
 }
  public boolean visit(ConstantDeclaration declaration) throws Exception {
    ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo();
    info.modifiers = Modifiers.AccConstant | Modifiers.AccPublic | Modifiers.AccFinal;
    ConstantReference constantName = declaration.getConstantName();
    info.name = ASTUtils.stripQuotes(constantName.getName());
    info.nameSourceEnd = constantName.sourceEnd() - 1;
    info.nameSourceStart = constantName.sourceStart();
    info.declarationStart = declaration.sourceStart();
    info.modifiers = markAsDeprecated(info.modifiers, declaration);

    fInfoStack.push(info);
    fRequestor.enterField(info);
    return true;
  }
Exemplo n.º 6
0
  public boolean visit(Include include) throws Exception {
    // special case for include statements; we need to cache this
    // information in order to access it quickly:
    if (include.getExpr() instanceof Scalar) {
      Scalar filePath = (Scalar) include.getExpr();
      modifyReference(
          include,
          new ReferenceInfo(
              IModelElement.METHOD,
              filePath.sourceStart(),
              filePath.sourceEnd() - filePath.sourceStart(),
              "include",
              Integer //$NON-NLS-1$
                  .toString(1),
              null));

      String fullPath = ASTUtils.stripQuotes(((Scalar) filePath).getValue());
      int idx = Math.max(fullPath.lastIndexOf('/'), fullPath.lastIndexOf('\\'));

      String lastSegment = fullPath;
      if (idx != -1) {
        lastSegment = lastSegment.substring(idx + 1);
      }
      modifyDeclaration(
          include,
          new DeclarationInfo(
              IModelElement.IMPORT_DECLARATION,
              0,
              include.sourceStart(),
              include.sourceEnd() - include.sourceStart(),
              filePath.sourceStart(),
              filePath.sourceEnd() - filePath.sourceStart(),
              lastSegment,
              fullPath,
              null,
              null,
              null));
    }

    return visitGeneral(include);
  }