コード例 #1
0
ファイル: DocItem.java プロジェクト: cfeclipse/cfeclipse
  /**
   * Adds a child to this item's child node list. It first asks the new item whether it's allowed to
   * belong to this item, for example <cfelse> tags must only be a child of an <cfif>
   * tag.
   *
   * @param newItem The new document item to add.
   * @return true - child added, false - error with child.
   */
  public boolean addChild(DocItem newItem) {
    boolean addOkay = true;

    if (!newItem.validChildAddition(this)) {
      parseMessages.addMessage(
          new ParseError(
              newItem.getLineNumber(),
              newItem.getStartPosition(),
              newItem.getEndPosition(),
              newItem.getItemData(),
              "Invalid child "
                  + newItem.getClass().getName()
                  + ":\'"
                  + newItem.getName()
                  + "\' for parent \'"
                  + getName()
                  + "\'"));
      addOkay = false;
    }
    //
    // Set the item's parent & sibling
    newItem.setParent(this);
    if (docNodes.size() == 0) newItem.setPrevSibling(null);
    else newItem.setPrevSibling((DocItem) docNodes.get(docNodes.size() - 1));

    docNodes.add(newItem);

    return addOkay;
  }
コード例 #2
0
  private MethodViewItem[] getMethods(CFNodeList nodes) {
    if (sortItems) {
      CFCMethodsComparator comparator = new CFCMethodsComparator();
      Collections.sort(nodes, comparator);
    }
    Iterator i = nodes.iterator();
    MethodViewItem[] methods = new MethodViewItem[nodes.size()];
    int index = 0;
    while (i.hasNext()) {
      try {
        Object itemThing = i.next();
        DocItem thisTag = (DocItem) itemThing;
        MethodViewItem item;
        if (itemThing instanceof FunctionInfo) {
          item = new CFCMethodViewScriptItem((FunctionInfo) itemThing);

        } else {
          item = new CFCMethodViewItem((TagItem) thisTag);
        }

        boolean addItem = true;

        if (item.getAccess().toLowerCase().equals("remote") && !this.showRemote) {
          addItem = false;
        }

        if (item.getAccess().toLowerCase().equals("public") && !this.showPublic) {
          addItem = false;
        }

        if (item.getAccess().toLowerCase().equals("package") && !this.showPackage) {
          addItem = false;
        }

        if (item.getAccess().toLowerCase().equals("private") && !this.showPrivate) {
          addItem = false;
        }

        if (addItem) {
          methods[index] = item;
          index++;
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    MethodViewItem[] finalMethods = new MethodViewItem[index];

    for (int x = 0; x < finalMethods.length; x++) {
      finalMethods[x] = methods[x];
    }
    return finalMethods;
  }
コード例 #3
0
ファイル: DocItem.java プロジェクト: cfeclipse/cfeclipse
  /**
   * Inserts the node newChild before existing node refChild. If refChild is null, insert newChild
   * at end of the list of children.
   *
   * @param newChild The new child node to insert
   * @param refChild The reference node, i.e. the node before which the new node must be inserted.
   * @throws InvalidChildItemException Raised if <code>newChild</code> being added is not valid for
   *     this node type.
   * @throws NodeNotFound Raised if the <code>refChild</code> node is not found in the node's
   *     children.
   */
  public void insertBefore(DocItem newChild, DocItem refChild)
      throws InvalidChildItemException, NodeNotFound {
    if (!newChild.validChildAddition(this))
      throw new InvalidChildItemException(
          "Child item of type \'"
              + newChild.getName()
              + "\' says it is not allowed to belong to this (\'"
              + itemName
              + "\') doc item");

    int insertPos = docNodes.size();

    //
    // Does the refChild exist and exists in this node's children?
    if (refChild != null && docNodes.contains(refChild)) insertPos = docNodes.indexOf(refChild);
    else if (refChild != null) // Isn't null & doesn't belong to this node. Argh!
    throw new NodeNotFound("Cannot find node \'" + refChild.getName() + "\'");

    docNodes.add(insertPos, newChild);
  }
コード例 #4
0
  public Object[] getElements(Object parent) {

    try {
      CFDocument doc = document.getCFDocument();
      if (doc == null) { // OBT: Added to handle when the parse fatally fails.
        return EMPTY_ARRAY;
      }
      DocItem rootItem = doc.getDocumentRoot();

      // nodes = rootItem.selectNodes("//function[#startpos>=0 and #endpos < 200]");
      nodes = rootItem.selectNodes("//cffunction");
      if (nodes.size() == 0) {
        nodes = rootItem.selectNodes("//ASTFunctionDeclaration");
      }
      return getMethods(nodes);
    } catch (Exception e) {
      System.err.println("CFCMethodsContentProvider has no elements");
      e.printStackTrace();
      return EMPTY_ARRAY;
    }
  }
コード例 #5
0
ファイル: DocItem.java プロジェクト: cfeclipse/cfeclipse
  private CFNodeList selectNodes(XPathSearch search) {
    CFNodeList result = new CFNodeList();

    if (docNodes == null) {
      docNodes = new CFNodeList();
    }

    for (int i = 0; i < docNodes.size(); i++) {
      DocItem currItem = (DocItem) docNodes.get(i);
      DocItem endItem = null;
      if (search.searchForEndTag && currItem.getMatchingItem() != null) {
        endItem = currItem.getMatchingItem();
      }

      int matches = 0;
      int endMatches = 0;

      if (search.doChildNodes) result.addAll(currItem.selectNodes(search));

      // r2 added simple * node selection
      if (search.searchForTag
          && (currItem.getName().compareToIgnoreCase(search.tagName) == 0
              || search.tagName.equals("*"))) {
        matches++;
      }
      if (endItem != null
          && search.searchForTag
          && (endItem.getName().compareToIgnoreCase(search.tagName) == 0
              || search.tagName.equals("*"))) {
        endMatches++;
      }

      // System.out.print("DocItem::selectNodes() - Testing \'" + currItem.getName() + "\'");
      if (search.attrSearch.containsKey(XPathSearch.ATTR_STARTPOS)) {
        ComparisonType comp = (ComparisonType) search.attrSearch.get(XPathSearch.ATTR_STARTPOS);
        // System.out.println(XPathSearch.ATTR_STARTPOS + ": ");
        if (comp.performComparison(currItem.startPosition)) {
          matches++;
          // System.out.print(" success ");
        }
        if (endItem != null && comp.performComparison(endItem.startPosition)) {
          endMatches++;
        }
      }
      if (search.attrSearch.containsKey(XPathSearch.ATTR_ENDPOS)) {
        // System.out.print(XPathSearch.ATTR_ENDPOS + ":");
        ComparisonType comp = (ComparisonType) search.attrSearch.get(XPathSearch.ATTR_ENDPOS);
        if (comp.performComparison(currItem.endPosition)) {
          matches++;
          // System.out.print(" success ");
        }
        if (endItem != null && comp.performComparison(endItem.endPosition)) {
          endMatches++;
          // System.out.println(" failed ");
        }
      }

      if (matches == search.getMatchesRequired()) {
        // System.out.println("DocItem::selectNodes(XPathSearch) - Got match for " +
        // currItem.itemName);
        result.add(currItem);
        // System.out.print(" name match success");
      } else if (endItem != null && endMatches == search.getMatchesRequired()) {
        result.add(currItem);
        // System.out.println(" End matched " + endItem.getMatchingItem());
        // System.out.print(" name match failed with ");
      }

      // System.out.println("");
    }

    return result;
  }
コード例 #6
0
ファイル: DocItem.java プロジェクト: cfeclipse/cfeclipse
 public DocItem getLastChild() {
   return (DocItem) docNodes.get(docNodes.size() - 1);
 }
コード例 #7
0
ファイル: DocItem.java プロジェクト: cfeclipse/cfeclipse
 public boolean hasChildren() {
   return docNodes.size() > 0;
 }