Package org.cfeclipse.cfml.parser.docitems

Examples of org.cfeclipse.cfml.parser.docitems.DocItem


  {
    boolean addOkay = true;
   
    if(docNodes.size() != 0)
    {
      DocItem mostRecentItem = (DocItem)docNodes.get(docNodes.size()-1);
      boolean lastIsElseIf =   mostRecentItem.getName().compareToIgnoreCase("elseif") == 0;
      boolean lastIsElse =   mostRecentItem.getName().compareToIgnoreCase("else") == 0;
      boolean itemIsElse =   newItem.getName().compareToIgnoreCase("else") == 0;
      boolean itemIsElseIf =   newItem.getName().compareToIgnoreCase("elseif") == 0;
      //
      // Tests to make sure that the user isn't trying to do something stupid.
      //if(newItem.getName().compareToIgnoreCase("else") == 0 && lastIsElse)
      if(itemIsElse && lastIsElse)
      {
        parseMessages.addMessage(new ParseMessage(newItem.getLineNumber(), newItem.getStartPosition(), newItem.getEndPosition(), newItem.getItemData(),
                     "<cfif> already has a <cfelse>"));
        addOkay = false;
      }       
      //else if(newItem.getName().compareToIgnoreCase("elseif") == 0 && lastIsElse)
      else if(itemIsElseIf && lastIsElse)
      {
         parseMessages.addMessage(new ParseMessage(newItem.getLineNumber(), newItem.getStartPosition(), newItem.getEndPosition(), newItem.getItemData(),
         "<cfelseif> after <cfelse>"));
        addOkay = false;
      }
      else if((lastIsElseIf || lastIsElse) && !(itemIsElse || itemIsElseIf) )  // Is the previous item an else/elseif and the current item isn't one?    
        mostRecentItem.addChild(newItem);  
      else
        addOkay = addOkay & super.addChild(newItem)// No elses if elseifs, so we add it to the if's children.
    }
    else
      addOkay = addOkay & super.addChild(newItem);
View Full Code Here


    Stack tempStack = new Stack();
    tempStack.copyInto(matchStack.toArray());
   
    while(tempStack.size() > 0)
    {
      DocItem tempItem = (DocItem)tempStack.pop();
      if(tempItem.getName().compareTo(itemName) == 0)
        break;
    }
    return startSize - popCount;
 
View Full Code Here

   */
  static protected void dumpStack(Stack inStack)
  {
    for(int i = 0; i < inStack.size(); i++)
    {
      DocItem tempItem = (DocItem)inStack.get(i);
    //System.out.println("Parser: Stack at "+ i+ " is \', " + tempItem.itemName + "\' + match data was : " + tempItem.getItemData());
    }
   
  }
View Full Code Here

      Function function = new Function(funcName, funcReturn, Byte.parseByte("8"));
      // System.out.println(currItem.getItemData());
      if (currItem.hasChildren() && currItem.getFirstChild().getName().equals("cfargument")) {
        Iterator childNodes = currItem.getChildNodes().iterator();
        DocItem childNode;
        while (childNodes.hasNext()) {
          childNode = (DocItem) childNodes.next();
          if (childNode.getName().equals("cfargument")) {
            matcher = pattern.matcher(childNode.getItemData());
            while (matcher.find()) {
              String value = matcher.group(2).replaceAll("'", "").replaceAll("\"", "");
              if (matcher.group(1).toLowerCase().equals("name")) {
                name = value;
              }
View Full Code Here

    try {

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

      CFNodeList nodes = rootItem.selectNodes("//cffunction");
     
      Iterator i = nodes.iterator();
      CFCMethodViewItem[] methods = new CFCMethodViewItem[nodes.size()];
      int index = 0;
      while(i.hasNext())
View Full Code Here

    {
      // CF tag
        closerName = closerName.substring(2, closerName.length()-1);
     
       
        DocItem topItem = (DocItem)matchStack.peek();
       
      //System.out.println("Top item on stack is " + topItem.getName());
     
      if(topItem instanceof TagItem)
      { 
          // Look for hybrids at the top of the stack
          // and remove them if there is an opener below them.
          try {
        boolean foundCloser = false;
          ArrayList removals = new ArrayList();
          Object[] items = matchStack.toArray();
          //System.out.println("Looking on stack for opening " + closerName + ". Closer found on line: " + this.getLineNumber(match.getStartPos()));
          for (int i=items.length-1;i>0;i--) {
              if (items[i] instanceof TagItem) {
                  TagItem item = (TagItem)items[i];
                  //System.out.println("Checking " + item.getName());
               
                if (item.getName().equalsIgnoreCase(closerName)) {
                    //System.out.println("Found opener. Exiting loop.");
                    foundCloser = true;
                    break;
                } else if (item.isHybrid()) {
                    removals.add(item);
                }
              }
          }
          // If we found a closer, we want to remove any unclosed hybrids.
          if (foundCloser) {
     
              items = removals.toArray();
                DocItem parent = (DocItem)matchStack.get(items.length);
              for (int i=0;i<items.length;i++) {
                  TagItem item = (TagItem)items[i];
                  //System.out.println(item.getChildNodes().size() + " children need to be moved to " + parent.getName());
                  Object[] orphans = item.getChildNodes().toArray();
                  if (item instanceof CfmlCustomTag) {
                    ((CfmlCustomTag)item).hasCloser = false;
                    parent.addChild(item);
                    item.setParent(parent);
                  }
                  for (int j=0;j<orphans.length;j++) {
                      DocItem orphan = (DocItem)orphans[j];
                      //System.out.println("Moving " + orphan.getName() + " under " + parent.getName());
                      parent.addChild(orphan);
                      item.removeChild(orphan);
                  }
                  //System.out.println("Removing " + ((TagItem)items[i]).getName() + " from the stack." + " Current parent is " + parent.getName());
                  matchStack.remove(items[i]);
              }
             
              Iterator iter = parent.getChildNodes().iterator();
              while (iter.hasNext()) {
                DocItem di = (DocItem)iter.next();
                //System.out.println("Child: " + di.getName());
              }
          }
          else {
              //System.out.println("Opener not found on stack for " + closerName);
              //System.out.println(" ");
          }
         
          }
          catch (Exception e) {
              e.printStackTrace();
          }
         
        try {
          TagItem tempItem = new TagItem(match.lineNumber, match.startPos, match.endPos+1, match.match);
          ((TagItem)topItem).setMatchingItem(tempItem);
          } catch(Exception e){
          System.err.println("Caught exception: " + e.getMessage());
          e.printStackTrace();
        }
      }
     
      // Take the top item off the stack.
      topItem = (DocItem)matchStack.pop()// Should be the opening item for this closer
      //System.out..println("CFParser::handleClosingTag() - " + Util.GetTabs(matchStack) + "Parser: Does \'" + closerName + "\' match \'" + topItem.itemName + "\'");             
     
      //SPIKE: Made this case insensitive
      if(topItem.getName().compareToIgnoreCase(closerName) == 0)
      {
          //System.out.println("Found matcher at top of stack!!!");
        DocItem parentItem = (DocItem)matchStack.pop();
        try {
          parentItem.addChild(topItem);
        }
        catch(Exception excep)
        {
          //
          // Tell the user there was a problem and then rethrow the exception.
View Full Code Here

    newItem.addAttributes(attrList);
    addTagItemToTree(match, matchStack, isACloser, newItem);
  }

  private void addDocItemToTree(DocItem item) {
    DocItem topItem = (DocItem) matchStack.pop();
    topItem.addChild(item);
    matchStack.push(topItem);
  }
View Full Code Here

      // Not a closing item, it's an opener so on the stack it goes.
        matchStack.push(newItem);
      }
      else
      {   // It's a closing item, so we get the parent item and add this item to it's children.
        DocItem top = (DocItem)matchStack.pop();

        top.addChild(newItem);
        matchStack.push(top);
     
    } catch(Exception anExcep) {
      parserState.addMessage(new ParseError(getLineNumber(match.startPos), match.startPos, match.endPos, match.match, "An unknown error occurred during parsing."));
      System.err.println("CFParser::handleCFTag() - Caught an exception during item popping. Exception was " + anExcep.getLocalizedMessage());
View Full Code Here

                }

                break;
              case MATCHER_CFMLCOMMENT:
                //System.out.println("CFParser::createDocTree() - Got a CFML comment!");
                DocItem newComment = new CfmlComment(
                    match.getLineNumber(),
                    match.getStartPos(),
                    match.getEndPos(),
                    match.getMatch()
                );
               
                newComment.setItemData(match.getMatch());
              addDocItemToTree(match, newComment);
               
                break;
              case MATCHER_CFSCRIPT:
                tagName = tagName.substring(1, tagName.length());
View Full Code Here

            // Mark them as being self closers.
            if (tagName.toLowerCase().startsWith("cf_") || tagName.toLowerCase().startsWith("cfx_")) {
              ((CfmlCustomTag)t).hasCloser= false;
            }
            // Get the current parent of the tag.
            DocItem parent = t.getParent();
            if (parent == null) {
              parent = defaultParent;
            }
            // Don't make the thing a child of itself.
            if (!parent.equals(t)) {
              parent.addChild(t);
 
              CFNodeList childNodes = t.getChildNodes();
              Iterator iter = childNodes.iterator();
              ArrayList deletedChildren = new ArrayList();
              while (iter.hasNext()) {
                Object o = iter.next();
                if (o instanceof DocItem) {
                  DocItem d = (DocItem)o;
                  d.setParent(parent);
                  parent.addChild(d);
                  deletedChildren.add(d);
                  System.out.println("Added " + d.getClass().getName() + " as child of " + parent.getName() + ". Was child of " + tagName);
                }
              }
              iter = deletedChildren.iterator();
              while(iter.hasNext()) {
                t.removeChild((DocItem)iter.next());
View Full Code Here

TOP

Related Classes of org.cfeclipse.cfml.parser.docitems.DocItem

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.