Package org.eclipse.dltk.ast.references

Examples of org.eclipse.dltk.ast.references.SimpleReference


    return true;
  }

  public boolean visit(ForEachStatement foreachStatement) throws Exception {
    if (foreachStatement.getKey() instanceof VariableReference) {
      SimpleReference var = (SimpleReference) foreachStatement.getKey();
      ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo();
      info.modifiers = Modifiers.AccPublic;
      info.name = var.getName();
      info.nameSourceEnd = var.sourceEnd() - 1;
      info.nameSourceStart = var.sourceStart();
      info.declarationStart = var.sourceStart();
      fRequestor.enterField(info);
      fRequestor.exitField(var.sourceEnd() - 1);
    }
    if (foreachStatement.getValue() instanceof VariableReference) {
      SimpleReference var = (SimpleReference) foreachStatement.getValue();
      ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo();
      info.modifiers = Modifiers.AccPublic;
      info.name = var.getName();
      info.nameSourceEnd = var.sourceEnd() - 1;
      info.nameSourceStart = var.sourceStart();
      info.declarationStart = var.sourceStart();
      fRequestor.enterField(info);
      fRequestor.exitField(var.sourceEnd() - 1);
    }
    return true;
  }
View Full Code Here


      Expression dispatcher = fieldAccess.getDispatcher();
      if (dispatcher instanceof VariableReference
          && "$this".equals(((VariableReference) dispatcher).getName())) { //$NON-NLS-1$
        Expression field = fieldAccess.getField();
        if (field instanceof SimpleReference) {
          SimpleReference ref = (SimpleReference) field;
          ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo();
          info.modifiers = Modifiers.AccPublic;
          info.name = '$' + ref.getName();
          info.nameSourceEnd = ref.sourceEnd() - 1;
          info.nameSourceStart = ref.sourceStart();
          info.declarationStart = assignment.sourceStart();
          fRequestor.enterField(info);
          fNodes.push(assignment);
        }
      }
View Full Code Here

      Expression dispatcher = fieldAccess.getDispatcher();
      if (dispatcher instanceof VariableReference
          && "$this".equals(((VariableReference) dispatcher).getName())) { //$NON-NLS-1$
        Expression field = fieldAccess.getField();
        if (field instanceof SimpleReference) {
          SimpleReference var = (SimpleReference) field;
          int modifiers = Modifiers.AccPublic;
          int offset = var.sourceStart();
          int length = var.sourceEnd() - offset;
          modifyDeclaration(assignment, new DeclarationInfo(
              IModelElement.FIELD, modifiers, offset, length,
              offset, length, '$' + var.getName(), null, null,
              fCurrentQualifier, fCurrentParent));
        }
      }
    } else if (left instanceof VariableReference) {
      int modifiers = Modifiers.AccPublic | Modifiers.AccGlobal;
View Full Code Here

  }

  public boolean visit(FieldAccess access) throws Exception {
    // This is variable field access:
    if (access.getField() instanceof SimpleReference) {
      SimpleReference simpleReference = (SimpleReference) access
          .getField();

      String name = simpleReference.getName();
      if (!name.startsWith(DOLOR)) {
        name = DOLOR + name;
      }
      modifyReference(access, new ReferenceInfo(IModelElement.FIELD,
          simpleReference.sourceStart(), simpleReference.sourceEnd()
              - simpleReference.sourceStart(), name, null, null));
    }

    return visitGeneral(access);
  }
View Full Code Here

  public IGoal[] init() {
    ExpressionTypeGoal typedGoal = (ExpressionTypeGoal) goal;
    CatchClause catchClause = (CatchClause) typedGoal.getExpression();

    SimpleReference type = catchClause.getClassName();
    if (type != null) {
      result = PHPClassType.fromSimpleReference(type);
    }
    return IGoal.NO_GOALS;
  }
View Full Code Here

      decl.setModifiers(Modifiers.AccConstant);
      locator.match(decl, getNodeSet());
    } else if (node instanceof FieldAccess) {
      Expression field = ((FieldAccess) node).getField();
      if (field instanceof SimpleReference) {
        SimpleReference ref = (SimpleReference) field;
        SimpleReferenceLocation refLoc = new SimpleReferenceLocation(
            ref.sourceStart(), ref.sourceEnd(), '$' + ref.getName());
        locator.match(refLoc, getNodeSet());
      }
    } else if (node instanceof StaticFieldAccess) {
      Expression field = ((StaticFieldAccess) node).getField();
      if (field instanceof SimpleReference) {
        SimpleReference ref = (SimpleReference) field;
        SimpleReferenceLocation refLoc = new SimpleReferenceLocation(
            ref.sourceStart(), ref.sourceEnd(), '$' + ref.getName());
        locator.match(refLoc, getNodeSet());
      }
    } else if (node instanceof StaticConstantAccess) {
      ConstantReference constantRef = ((StaticConstantAccess) node)
          .getConstant();
      locator.match(constantRef, getNodeSet());
    }
    /*
     * else if (node instanceof ConstantReference) {
     * locator.match((ConstantReference)node, getNodeSet()); }
     */
    else if (node instanceof Assignment) {
      Expression left = ((Assignment) node).getVariable();
      if (left instanceof FieldAccess) { // class variable ($this->a = .)
        FieldAccess fieldAccess = (FieldAccess) left;
        Expression dispatcher = fieldAccess.getDispatcher();
        if (dispatcher instanceof VariableReference) { // && "$this".equals(((VariableReference) dispatcher).getName())) { //$NON-NLS-1$
          Expression field = fieldAccess.getField();
          if (field instanceof SimpleReference) {
            SimpleReference ref = (SimpleReference) field;
            FieldDeclaration decl = new FieldDeclarationLocation(
                '$' + ref.getName(), ref.sourceStart(), ref
                    .sourceEnd(), node.sourceStart(), node
                    .sourceEnd());
            locator.match(decl, getNodeSet());
          }
        }
      } else if (left instanceof VariableReference) {
        FieldDeclaration decl = new FieldDeclarationLocation(
            ((VariableReference) left).getName(), left
                .sourceStart(), left.sourceEnd(), node
                .sourceStart(), node.sourceEnd());
        locator.match(decl, getNodeSet());
      }
    } else if (node instanceof ListVariable) {
      recursiveListMatch(node, locator);
    } else if (node instanceof TypeReference) {
      locator.match((TypeReference) node, getNodeSet());
    } else if (node instanceof VariableReference) {
      locator.match((VariableReference) node, getNodeSet());
    } else if (node instanceof CallExpression) {
      FieldDeclaration constantDecl = ASTUtils
          .getConstantDeclaration((CallExpression) node);
      if (constantDecl != null) {
        locator.match(constantDecl, getNodeSet());
      } else {
        locator.match((CallExpression) node, getNodeSet());
      }
    } else if (node instanceof Include) {
      Include include = (Include) node;
      if (include.getExpr() instanceof Scalar) {
        Scalar filePath = (Scalar) include.getExpr();
        CallExpression callExpression = new CallExpressionLocation(
            filePath.sourceStart(), filePath.sourceEnd(), null,
            "include", new CallArgumentsList()); //$NON-NLS-1$
        locator.match(callExpression, getNodeSet());
      }
    } else if (node instanceof Argument) {
      SimpleReference ref = ((Argument) node).getRef();
      FieldDeclaration decl = new FieldDeclarationLocation(ref.getName(),
          ref.sourceStart(), ref.sourceEnd(), node.sourceStart(),
          node.sourceEnd());
      locator.match(decl, getNodeSet());
    } else if (node instanceof ForEachStatement) {
      Expression key = ((ForEachStatement) node).getKey();
      Expression value = ((ForEachStatement) node).getValue();
      if (key instanceof SimpleReference) {
        SimpleReference ref = (SimpleReference) key;
        FieldDeclaration decl = new FieldDeclarationLocation(ref
            .getName(), ref.sourceStart(), ref.sourceEnd(), node
            .sourceStart(), node.sourceEnd());
        locator.match(decl, getNodeSet());
      }
      if (value instanceof SimpleReference) {
        SimpleReference ref = (SimpleReference) value;
        FieldDeclaration decl = new FieldDeclarationLocation(ref
            .getName(), ref.sourceStart(), ref.sourceEnd(), ref
            .sourceStart(), ref.sourceEnd());
        locator.match(decl, getNodeSet());
      }
    } else if (node instanceof CatchClause) {
      VariableReference ref = ((CatchClause) node).getVariable();
      FieldDeclaration decl = new FieldDeclarationLocation(ref.getName(),
          ref.sourceStart(), ref.sourceEnd(), node.sourceStart(),
          node.sourceEnd());
      locator.match(decl, getNodeSet());
    }
  }
View Full Code Here

  private final boolean isMandatory;

  private FormalParameter(int start, int end, SimpleReference type, final VariableReference parameterName, Expression defaultValue, boolean isMandatory) {
    super(parameterName, start, end, defaultValue, 0);
   
    SimpleReference ref = getRef();
    if (ref != null) {
      ref.setStart(parameterName.sourceStart());
      ref.setEnd(parameterName.sourceEnd());
    }

    assert parameterName != null;

    this.parameterType = type;
View Full Code Here

        }
      } catch (ModelException e1) {
        Logger.logException(e1);
      }

      SimpleReference ref = new SimpleReference(sourcePosition,
          sourceEndPosition, methodName);
      IMethod[] methods = findMethods(methodName, argCount,
          sourcePosition);
      fSearchResults.put(ref, methods);
    }
View Full Code Here

      if (match.getElement() != null
          && match.getElement() instanceof IModelElement) {
        IModelElement member = (IModelElement) match.getElement();

        SimpleReference ref = new SimpleReference(match.getOffset(),
            match.getOffset() + match.getLength(), EMPTY_STRING);
        result.put(ref, member);
      }
    }
View Full Code Here

                List childs = superClasses.getChilds();
                for (Iterator iterator = childs.iterator(); iterator
                    .hasNext();) {
                  ASTNode node = (ASTNode) iterator.next();
                  NamespaceReference namespace = null;
                  SimpleReference reference = null;
                  if (node instanceof SimpleReference) {
                    reference = (SimpleReference) node;
                    String typeName = reference.getName();
                    if (reference instanceof FullyQualifiedReference) {
                      FullyQualifiedReference ref = (FullyQualifiedReference) node;
                      namespace = ref.getNamespace();
                    }
                    if (namespace != null
                        && !namespace.getName().equals(
                            "")) { //$NON-NLS-1$
                      String nsName = namespace.getName();
                      if (nsName.equals("\\")) { //$NON-NLS-1$
                        typeName = nsName + typeName;
                      } else {
                        if (nsName
                            .startsWith("namespace\\")) { //$NON-NLS-1$
                          nsName = nsName.replace(
                              "namespace\\", ""); //$NON-NLS-1$ //$NON-NLS-2$
                        }
                        typeName = nsName
                            + NamespaceReference.NAMESPACE_SEPARATOR
                            + typeName;
                      }
                    }
                    if (typeName
                        .indexOf(NamespaceReference.NAMESPACE_SEPARATOR) > 0) {
                      // check if the first part
                      // is an
                      // alias,then get the full
                      // name
                      String prefix = typeName.substring(
                          0,
                          typeName.indexOf(NamespaceReference.NAMESPACE_SEPARATOR));
                      final Map<String, UsePart> result = PHPModelUtils
                          .getAliasToNSMap(
                              prefix,
                              moduleDeclaration,
                              reference
                                  .sourceStart(),
                              currentNamespace,
                              true);
                      if (result.containsKey(prefix)) {
                        String fullName = result
                            .get(prefix)
                            .getNamespace()
                            .getFullyQualifiedName();
                        typeName = typeName.replace(
                            prefix, fullName);
                      }
                    } else if (typeName
                        .indexOf(NamespaceReference.NAMESPACE_SEPARATOR) < 0) {

                      String prefix = typeName;
                      final Map<String, UsePart> result = PHPModelUtils
                          .getAliasToNSMap(
                              prefix,
                              moduleDeclaration,
                              reference
                                  .sourceStart(),
                              currentNamespace,
                              true);
                      if (result.containsKey(prefix)) {
                        String fullName = result
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.ast.references.SimpleReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.