Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.StructuralPropertyDescriptor


  public final void remove(ASTNode node, TextEditGroup editGroup) {
    if (node == null) {
      throw new IllegalArgumentException();
    }

    StructuralPropertyDescriptor property;
    ASTNode parent;
    if (RewriteEventStore.isNewNode(node)) { // remove a new node, bug 164862
      PropertyLocation location= this.eventStore.getPropertyLocation(node, RewriteEventStore.NEW);
      if (location != null) {
        property= location.getProperty();
        parent= location.getParent();
      } else {
        throw new IllegalArgumentException("Node is not part of the rewriter's AST"); //$NON-NLS-1$
      }
    } else {
      property= node.getLocationInParent();
      parent= node.getParent();
    }

    if (property.isChildListProperty()) {
      getListRewrite(parent, (ChildListPropertyDescriptor) property).remove(node, editGroup);
    } else {
      set(parent, property, null, editGroup);
    }
  }
View Full Code Here


  public final void replace(ASTNode node, ASTNode replacement, TextEditGroup editGroup) {
    if (node == null) {
      throw new IllegalArgumentException();
    }

    StructuralPropertyDescriptor property;
    ASTNode parent;
    if (RewriteEventStore.isNewNode(node)) { // replace a new node, bug 164862
      PropertyLocation location= this.eventStore.getPropertyLocation(node, RewriteEventStore.NEW);
      if (location != null) {
        property= location.getProperty();
        parent= location.getParent();
      } else {
        throw new IllegalArgumentException("Node is not part of the rewriter's AST"); //$NON-NLS-1$
      }
    } else {
      property= node.getLocationInParent();
      parent= node.getParent();
    }

    if (property.isChildListProperty()) {
      getListRewrite(parent, (ChildListPropertyDescriptor) property).replace(node, replacement, editGroup);
    } else {
      set(parent, property, replacement, editGroup);
    }
  }
View Full Code Here

     *
     *  @param node The node to be removed.
     */
    public static void removeNode(ASTNode node) {
        ASTNode parent = node.getParent();
        StructuralPropertyDescriptor location = node.getLocationInParent();

        if (location.isChildProperty()) {
            parent.setStructuralProperty(location, null);
        } else {
            List<ASTNode> properties = (List<ASTNode>) parent
                    .getStructuralProperty(location);
            int position = properties.indexOf(node);
View Full Code Here

     @param node The node to be replace.
     *  @param newNode The new node.
     */
    public static void replaceNode(ASTNode node, ASTNode newNode) {
        ASTNode parent = node.getParent();
        StructuralPropertyDescriptor location = node.getLocationInParent();

        if (location.isChildProperty()) {
            parent.setStructuralProperty(location, newNode);
        } else {
            List<ASTNode> properties = (List<ASTNode>) parent
                    .getStructuralProperty(location);
            int position = properties.indexOf(node);
View Full Code Here

     * @param parent the parent node
     * @return <code>true</code> if the nodes may be the sub nodes of a type node, false otherwise
     */
    private boolean isTypePath(ASTNode child, ASTNode parent) {
      if (parent instanceof Type) {
        StructuralPropertyDescriptor location= child.getLocationInParent();
        return location == ParameterizedType.TYPE_PROPERTY || location == SimpleType.NAME_PROPERTY;
      } else if (parent instanceof QualifiedName) {
        StructuralPropertyDescriptor location= child.getLocationInParent();
        return location == QualifiedName.NAME_PROPERTY;
      }
      return false;
    }
View Full Code Here

        return true;
      // special cases: the autoboxing conversions happens at a
      // location that is not mapped directly to a simple name
      // or a literal, but can still be mapped somehow
      // A) expressions
      StructuralPropertyDescriptor desc= node.getLocationInParent();
      if (desc == ArrayAccess.ARRAY_PROPERTY
          || desc == InfixExpression.LEFT_OPERAND_PROPERTY
          || desc == InfixExpression.RIGHT_OPERAND_PROPERTY
          || desc == ConditionalExpression.THEN_EXPRESSION_PROPERTY
          || desc == PrefixExpression.OPERAND_PROPERTY
View Full Code Here

    /*
     * @see org.eclipse.jdt.internal.ui.javaeditor.ISemanticHighlighting#isMatched(org.eclipse.jdt.core.dom.ASTNode)
     */
    public boolean consumes(SemanticToken token) {
      StructuralPropertyDescriptor location= token.getNode().getLocationInParent();
      return location == MethodDeclaration.NAME_PROPERTY || location == AnnotationTypeMemberDeclaration.NAME_PROPERTY;
    }
View Full Code Here

     * @param parent the parent node
     * @return <code>true</code> if the nodes may be the sub nodes of a type node, false otherwise
     */
    private boolean isTypePath(ASTNode child, ASTNode parent) {
      if (parent instanceof Type) {
        StructuralPropertyDescriptor location= child.getLocationInParent();
        return location == ParameterizedType.TYPE_PROPERTY || location == SimpleType.NAME_PROPERTY;
      } else if (parent instanceof QualifiedName) {
        StructuralPropertyDescriptor location= child.getLocationInParent();
        return location == QualifiedName.NAME_PROPERTY;
      }
      return false;
    }
View Full Code Here

    /*
     * @see org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlighting#consumes(org.eclipse.jdt.internal.ui.javaeditor.SemanticToken)
     */
    public boolean consumes(SemanticToken token) {
      SimpleName node= token.getNode();
      StructuralPropertyDescriptor location= node.getLocationInParent();
      if (location == VariableDeclarationFragment.NAME_PROPERTY || location == SingleVariableDeclaration.NAME_PROPERTY) {
        ASTNode parent= node.getParent();
        if (parent instanceof VariableDeclaration) {
          parent= parent.getParent();
          return parent == null || !(parent instanceof FieldDeclaration);
View Full Code Here

      int nodeType= node.getNodeType();
      if (nodeType != ASTNode.SIMPLE_TYPE && nodeType != ASTNode.QUALIFIED_TYPE)
        return false;

      // 2: match type arguments
      StructuralPropertyDescriptor locationInParent= node.getLocationInParent();
      if (locationInParent == ParameterizedType.TYPE_ARGUMENTS_PROPERTY)
        return true;

      return false;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.StructuralPropertyDescriptor

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.