Package org.cfeclipse.cfml.editors.partitioner

Examples of org.cfeclipse.cfml.editors.partitioner.CFEPartition


        .getSelection();
    int startpos = sel.getOffset();
    int len = Math.max(sel.getLength(),1);
    CFEPartitioner partitioner = (CFEPartitioner)cfd.getDocumentPartitioner();
   
    CFEPartition part = partitioner.findClosestPartition(startpos);
    return part;
  }
View Full Code Here


          int startpos = sel.getOffset();
          int len = Math.max(sel.getLength(),1);
          CFEPartitioner partitioner = (CFEPartitioner)cfd.getDocumentPartitioner();
          CFEPartition[] partitioning = partitioner.getCFEPartitions(startpos,startpos+len);
            String info = "Partitioning info from offset " + startpos + " to " + Integer.toString(startpos + len) + "\n\n";
            CFEPartition part = partitioner.findClosestPartition(startpos);
            info += "(Closest partition: " + part.getType() + " = " + part.getTagName() + ")\n";
          for (int i=0;i<partitioning.length;i++) {
              info += partitioning[i].getType();
              info += " starting at ";
              info += partitioning[i].getOffset();
              info += " ending at ";
              info += Integer.toString(partitioning[i].getOffset() + partitioning[i].getLength());
              if (partitioning[i].getTagName() != null) {
                  info += " (";
                  info += partitioning[i].getTagName();
                  info += ") ";
              }
              info += "\n";
          }
           
            String[] labels = new String[1];
          labels[0] = "OK";
            MessageDialog msg = new MessageDialog(
              Display.getCurrent().getActiveShell(),
              "Partition info",
              null,
              info,
              MessageDialog.WARNING,
              labels,
              0);
            msg.open();
        }
      };
      menu.add(act);

     
      /*
       * TODO: re-write this so the edit this tag action can be called from different places
       * Edit this tag action start
       */
      act = new Action("Edit this tag", null){
        public void run() {
       
            EditTagAction eta = new EditTagAction();
            eta.run();
          
        }
      };
     
      //Only display if you are at the start tag
      int startpos = sel.getOffset();
      CFEPartitioner partitioner = (CFEPartitioner)cfd.getDocumentPartitioner();
      CFEPartition part = partitioner.findClosestPartition(startpos);
//      ITypedRegion part = cfd.getDocumentPartitioner(CFDocumentSetupParticipant.CFML_PARTITIONING).getPartition(startpos);
     
      if(part != null && EditableTags.isEditable(part.getType())){
        menu.add(act);
      }
     
     
      //This is not only for
View Full Code Here

    if (doc instanceof ICFDocument
        && this.isUseSmartIndent()) {
      ICFDocument cfd = (ICFDocument) doc;
      CFEPartitioner partitioner = (CFEPartitioner) cfd
          .getDocumentPartitioner();
      CFEPartition prevPartition = partitioner
          .getPreviousPartition(docCommand.offset);
      CFEPartition nextPartition = null;
      if (prevPartition != null) {
        nextPartition = partitioner
            .getNextPartition(prevPartition.offset);
      }
      //System.out.println("Command at offset: " + docCommand.offset);
      //System.out.println(prevPartition);
      //System.out.println(nextPartition);
      if (nextPartition != null
          && prevPartition != null) {
        if (prevPartition.getType().endsWith("start_tag_end")) {
          try {
            boolean doIndent = true;
            if (nextPartition.getType().endsWith("end_tag")
                && nextPartition.offset == docCommand.offset) {
              doIndent = false;
            }
            if (doc.getLineOfOffset(prevPartition.offset) != doc
                .getLineOfOffset(docCommand.offset)) {
              doIndent = false;
            }
            if (doIndent) {
              CFEPartition closer = partitioner
                  .getCloser(prevPartition);
              if (closer != null) {

                String prevLineWhitespace = getPrevLineWhiteSpace(
                    doc, docCommand.offset);
                docCommand.text += indentString
                    + guessNewIndentWhitespace(prevLineWhitespace);
                return;

              }
            }
          } catch (BadLocationException e) {
            //
          }
        }
       
        if (nextPartition.getType().endsWith("end_tag")
            && nextPartition.offset == docCommand.offset) {
         
          try {
            CFEPartition opener = partitioner
                .getOpener(nextPartition);

           
            if (opener == null) {
              return;
View Full Code Here

    boolean doIndent = true;
    if (doc instanceof ICFDocument && this.isUseSmartIndent()) {
      ICFDocument cfd = (ICFDocument) doc;
      CFEPartitioner partitioner = (CFEPartitioner) cfd.getDocumentPartitioner();
      CFEPartition prevPartition = partitioner.getPreviousPartition(docCommand.offset);
      CFEPartition nextPartition = null;
      if (prevPartition != null) {
        nextPartition = partitioner.getNextPartition(prevPartition.offset);
      }
      // System.out.println("Command at offset: " + docCommand.offset);
      // System.out.println(prevPartition);
View Full Code Here

    } catch (Exception e) {
      System.err.println(cti.getName());
      e.printStackTrace();
    }     
    CFEPartitioner partitioner = (CFEPartitioner)cfd.getDocumentPartitioner();   
    CFEPartition part = partitioner.findClosestPartition(startPos);
    if(part == null) {
      return;
    }
    startPos = part.offset;
    if (cti != null) {
View Full Code Here

     *            the offset for which to search the closest position
     * @return the closest position in the partitioner's category
     */
    private Position findMatchingTag(int offset) {
   
        CFEPartition currentPartition =  this.partitioner.findClosestPartition(offset);
       
        if (currentPartition == null) {
            return null;
        }
       
        CFEPartition[] fullStartTagPartitions = this.partitioner.getStartTagPartitions(currentPartition.getOffset());
       
        if (currentPartition.isMidPartition() || currentPartition.isEndPartition()) {
           
            //System.out.println("Clicked in tag attributes or by closing chevron; finding start tag");
           
            // CFEPartition prevPartition = (CFEPartition) category[--index];
            CFEPartition prevPartition = this.partitioner.getPreviousPartition(currentPartition.getOffset());
            //System.out.println("Checked previous partition: " + prevPartition.getType() + "(" + prevPartition.getTagName());
            while (prevPartition != null && (!prevPartition.isStartPartition())) {
                // prevPartition = (CFEPartition) category[--index];
                prevPartition = this.partitioner.getPreviousPartition(prevPartition.getOffset());
                //System.out.println("Checked previous partition: " + prevPartition.getType() + "(" + prevPartition.getTagName());
            }
            //System.out.println("Found start tag!");
            currentPartition = prevPartition;
        }
       
        // By this point, we have either returned null or we have the correct start or end CF Tag partition
       
        String tagName = currentPartition.getTagName();
        //System.out.println("Current tag name: " + tagName);
        int stackDepth = 0;
   
        if (currentPartition.isStartPartition()) {
            //System.out.println("In start tag; looking for matching end tag");
           
            int lastPartitionIndex =  fullStartTagPartitions.length - 1;
            int closingPartitionLength = fullStartTagPartitions[lastPartitionIndex].getLength();
           
            if (closingPartitionLength == 2) {
                // Self-closing tag
                //System.out.println("This is a self-closing tag.");
                IStatusLineManager statusLM = editor.getEditorSite().getActionBars().getStatusLineManager();
                statusLM.setMessage("This is a self-closing tag.");
                return null;
            }
           
            // Start after the closing chevron
            CFEPartition checkMatchPartition = this.partitioner.getNextPartition(fullStartTagPartitions[lastPartitionIndex].getOffset());
            while (checkMatchPartition != null) {
                // System.out.println("Checked partition tag name: " + checkMatchPartition.getTagName() + " & type: " + checkMatchPartition.getType());
                if (checkMatchPartition.isStartPartition() && currentPartition.getTagName().equalsIgnoreCase(checkMatchPartition.getTagName())) {
                    //System.out.println("Encountered nested start tag before end tag");
                    stackDepth++;
                    checkMatchPartition = this.partitioner.getNextPartition(checkMatchPartition.getOffset());
                    continue;
                }
                if (!checkMatchPartition.isCloser() || !tagName.equalsIgnoreCase(checkMatchPartition.getTagName())) {
                    //System.out.println("Partition at offset " + checkMatchPartition.getOffset() + " is not a closer or is a different tag");
                    checkMatchPartition = this.partitioner.getNextPartition(checkMatchPartition.getOffset());
                    continue;
                }
                // If we've reached this point, we should be at a closing tag with the same name
                if (stackDepth > 0) {
                    //System.out.println("Found match for nested tag; removing from stack");
                    stackDepth--;
                    checkMatchPartition = this.partitioner.getNextPartition(checkMatchPartition.getOffset());
                    continue;
                }
                //System.out.println("Found match! Is it a start partition: " + checkMatchPartition.isStartPartition());
                IStatusLineManager statusLM = editor.getEditorSite().getActionBars().getStatusLineManager();
                statusLM.setMessage(null);
                return checkMatchPartition;
            }
            //System.out.println("Looks like there's no match.");
        }
        else { // Trying to find the matching start tag for an end tag
            CFEPartition checkMatchPartition = this.partitioner.getPreviousPartition(currentPartition.getOffset());
            int start = 0;
            int end = 0;
            boolean matchFound = false;
            while (checkMatchPartition != null) {
                if (checkMatchPartition.isCloser() && currentPartition.getTagName().equalsIgnoreCase(checkMatchPartition.getTagName())) {
                    //System.out.println("Encountered nested end tag before start tag");
                    stackDepth++;
                    checkMatchPartition = this.partitioner.getPreviousPartition(checkMatchPartition.getOffset());
                    continue;
                }
                if (!tagName.equalsIgnoreCase(checkMatchPartition.getTagName()) || (checkMatchPartition.isMidPartition())) {
                    //System.out.println("Partition at offset " + checkMatchPartition.getOffset() + " doesn't match");
                    checkMatchPartition = this.partitioner.getPreviousPartition(checkMatchPartition.getOffset());
                    continue;
                }
                if (checkMatchPartition.isStartPartition() && currentPartition.getTagName().equals(checkMatchPartition.getTagName())) {
                    if (stackDepth == 0) {
                        //System.out.println("Found match at offset " + checkMatchPartition.getOffset());
                        // return checkMatchPartition;
                        matchFound = true;
                        break;
                    }
                    else {
                        //System.out.println("Found match for nested tag; removing from stack");
                        stackDepth--;
                    }
                }
                checkMatchPartition = this.partitioner.getPreviousPartition(checkMatchPartition.getOffset());
            }
            if (!matchFound) {
                IStatusLineManager statusLM = editor.getEditorSite().getActionBars().getStatusLineManager();
                statusLM.setMessage("No matching tag found.");
                return null;
            }
           
            if (checkMatchPartition == null ) {
                return null;
            }
           
            CFEPartition[] startPartitions = this.partitioner.getStartTagPartitions(checkMatchPartition.getOffset());
            if (startPartitions == null || startPartitions.length < 2) {
                return null;
            }
            start = startPartitions[0].getOffset();
            end = startPartitions[startPartitions.length - 1].getOffset() + startPartitions[startPartitions.length - 1].getLength();
View Full Code Here

TOP

Related Classes of org.cfeclipse.cfml.editors.partitioner.CFEPartition

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.