Package org.eclipse.jdt.core.dom

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


  public boolean preVisit2(ASTNode node) {
    ASTNode previous = null;
   
    List properties = node.structuralPropertiesForType();
    for (int i = 0; i < properties.size(); i++) {
      StructuralPropertyDescriptor property = (StructuralPropertyDescriptor) properties.get(i);
      if (property.isChildProperty()) {
        ASTNode child = (ASTNode) node.getStructuralProperty(property);
        if (child != null) {
          boolean ok = checkChild(node, previous, child);
          if (ok) {
            previous = child;
          } else {
            return false;
          }
        }
      } else if (property.isChildListProperty()) {
        List children = (List) node.getStructuralProperty(property);
        for (int j= 0; j < children.size(); j++) {
          ASTNode child = (ASTNode) children.get(j);
          boolean ok = checkChild(node, previous, child);
          if (ok) {
View Full Code Here


  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

   }

   @SuppressWarnings("unchecked")
   public static List<Type> getInterfaces(final BodyDeclaration dec)
   {
      StructuralPropertyDescriptor desc;
      if (dec instanceof EnumDeclaration) {
         desc = EnumDeclaration.SUPER_INTERFACE_TYPES_PROPERTY;
      } else {
         desc = TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY;
      }
View Full Code Here

         */
        ASTNode orig = (ASTNode) this.clonedNodes.remove(node);
        if (orig != null) {
          List properties = node.structuralPropertiesForType();
          for (int i= 0; i < properties.size(); i++) {
            StructuralPropertyDescriptor property = (StructuralPropertyDescriptor) properties.get(i);
            Object child = node.getStructuralProperty(property);
            if (child instanceof ASTNode) {
              markAsMoveOrCopyTarget(node, (ASTNode) child);
            } else if (child instanceof List) {
              List children = (List) child;
View Full Code Here

   */
  public static List<ChildListPropertyDescriptor> getChildListPropertyDescriptors(ASTNode node) {
    List<ChildListPropertyDescriptor> childListPropertyDescriptors = new ArrayList<ChildListPropertyDescriptor>();
    List list= node.structuralPropertiesForType();
    for (int i= 0; i < list.size(); i++) {
      StructuralPropertyDescriptor curr= (StructuralPropertyDescriptor) list.get(i);
      if (!(curr instanceof ChildListPropertyDescriptor)) {
        continue;
      }
      childListPropertyDescriptors.add((ChildListPropertyDescriptor)curr);
    }
View Full Code Here

  public boolean preVisit2(ASTNode node) {
    ASTNode previous = null;
   
    List properties = node.structuralPropertiesForType();
    for (int i = 0; i < properties.size(); i++) {
      StructuralPropertyDescriptor property = (StructuralPropertyDescriptor) properties.get(i);
      if (property.isChildProperty()) {
        ASTNode child = (ASTNode) node.getStructuralProperty(property);
        if (child != null) {
          boolean ok = checkChild(node, previous, child);
          if (ok) {
            previous = child;
          } else {
            return false;
          }
        }
      } else if (property.isChildListProperty()) {
        List children = (List) node.getStructuralProperty(property);
        for (int j= 0; j < children.size(); j++) {
          ASTNode child = (ASTNode) children.get(j);
          boolean ok = checkChild(node, previous, child);
          if (ok) {
View Full Code Here

   *
   * @see #createAfter(IJavaElement)
   * @see #createBefore(IJavaElement)
   */
  protected void insertASTNode(ASTRewrite rewriter, ASTNode parent, ASTNode child) throws JavaModelException {
    StructuralPropertyDescriptor propertyDescriptor = getChildPropertyDescriptor(parent);
    if (propertyDescriptor instanceof ChildListPropertyDescriptor) {
      ChildListPropertyDescriptor childListPropertyDescriptor = (ChildListPropertyDescriptor) propertyDescriptor;
       ListRewrite rewrite = rewriter.getListRewrite(parent, childListPropertyDescriptor);
       switch (this.insertionPolicy) {
         case INSERT_BEFORE:
View Full Code Here

         */
        ASTNode orig = (ASTNode) this.clonedNodes.remove(node);
        if (orig != null) {
          List properties = node.structuralPropertiesForType();
          for (int i= 0; i < properties.size(); i++) {
            StructuralPropertyDescriptor property = (StructuralPropertyDescriptor) properties.get(i);
            Object child = node.getStructuralProperty(property);
            if (child instanceof ASTNode) {
              markAsMoveOrCopyTarget(node, (ASTNode) child);
            } else if (child instanceof List) {
              List children = (List) child;
View Full Code Here

  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

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.