Examples of StructuralPropertyDescriptor


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

   *
   * @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

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

         */
        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

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

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

  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

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

   }

   @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

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

   *
   * @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

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

   }

   @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

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

      log("Visiting children of node " + getNodeAsString(thisNode));
      Iterator<StructuralPropertyDescriptor> it = thisNode
          .structuralPropertiesForType().iterator();
      boolean flag = true;
      while (it.hasNext()) {
        StructuralPropertyDescriptor prop = (StructuralPropertyDescriptor) it
            .next();
        if (prop.isChildListProperty()) {
          List<ASTNode> nodelist = (List<ASTNode>) thisNode
              .getStructuralProperty(prop);
          log("prop " + prop);
          for (ASTNode cnode : nodelist) {
            log("Visiting node " + getNodeAsString(cnode));
View Full Code Here

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

  protected static ASTNode findClosestParentNode(int lineNumber, ASTNode node) {
    Iterator<StructuralPropertyDescriptor> it = node
        .structuralPropertiesForType().iterator();
    // logE("Props of " + node.getClass().getName());
    while (it.hasNext()) {
      StructuralPropertyDescriptor prop = (StructuralPropertyDescriptor) it
          .next();

      if (prop.isChildProperty() || prop.isSimpleProperty()) {
        if (node.getStructuralProperty(prop) != null) {
//          System.out
//              .println(node.getStructuralProperty(prop) + " -> " + (prop));
          if (node.getStructuralProperty(prop) instanceof ASTNode) {
            ASTNode cnode = (ASTNode) node.getStructuralProperty(prop);
//            log("Looking at " + getNodeAsString(cnode)+ " for line num " + lineNumber);
            int cLineNum = ((CompilationUnit) cnode.getRoot())
                .getLineNumber(cnode.getStartPosition() + cnode.getLength());
            if (getLineNumber(cnode) <= lineNumber && lineNumber <= cLineNum) {
              return findClosestParentNode(lineNumber, cnode);
            }
          }
        }
      }

      else if (prop.isChildListProperty()) {
        List<ASTNode> nodelist = (List<ASTNode>) node
            .getStructuralProperty(prop);
        for (ASTNode cnode : nodelist) {
          int cLineNum = ((CompilationUnit) cnode.getRoot())
              .getLineNumber(cnode.getStartPosition() + cnode.getLength());
View Full Code Here

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

    Iterator<StructuralPropertyDescriptor> it = node
        .structuralPropertiesForType().iterator();
    //logE("Props of " + node.getClass().getName());
    DefaultMutableTreeNode ctnode = null;
    while (it.hasNext()) {
      StructuralPropertyDescriptor prop = (StructuralPropertyDescriptor) it
          .next();

      if (prop.isChildProperty() || prop.isSimpleProperty()) {
        if (node.getStructuralProperty(prop) != null) {
//          System.out
//              .println(node.getStructuralProperty(prop) + " -> " + (prop));
          if (node.getStructuralProperty(prop) instanceof ASTNode) {
            ASTNode cnode = (ASTNode) node.getStructuralProperty(prop);
            if (isAddableASTNode(cnode)) {
              ctnode = new DefaultMutableTreeNode(
                                                  new ASTNodeWrapper((ASTNode) node
                                                      .getStructuralProperty(prop)));
              tnode.add(ctnode);
              visitRecur(cnode, ctnode);
            }
          } else {
            tnode.add(new DefaultMutableTreeNode(node
                .getStructuralProperty(prop)));
          }
        }
      }

      else if (prop.isChildListProperty()) {
        List<ASTNode> nodelist = (List<ASTNode>) node
            .getStructuralProperty(prop);
        for (ASTNode cnode : nodelist) {
          if (isAddableASTNode(cnode)) {
            ctnode = new DefaultMutableTreeNode(new ASTNodeWrapper(cnode));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.