Examples of FindReplaceDocumentAdapter


Examples of org.eclipse.jface.text.FindReplaceDocumentAdapter

      //this is because when they hit > it often moves them into
      //another partiton type - so get the last partition
      if(invoker.equals(">")) {
        start = document.getPartition(documentOffset - 1).getOffset();
      } else if (invoker.equals(".")) {
        FindReplaceDocumentAdapter finder = new FindReplaceDocumentAdapter(document);
        IRegion region = finder.find(documentOffset-2,"[^a-z.]",false,false,false,true);
       
        if (region != null) {
          start = region.getOffset()+1;
        }
      } else {
View Full Code Here

Examples of org.eclipse.jface.text.FindReplaceDocumentAdapter


      int cursorOffset = ((ITextSelection) sel).getOffset();
      int lastSpaceOffset = -1;
      // int nextSpaceOffset = -1;
      FindReplaceDocumentAdapter finder = new FindReplaceDocumentAdapter(doc);

      try {
        IRegion lastSpace = finder.find(cursorOffset - 1, "[^\\*0-9a-zA-Z_-]", false, false, false, true);

        if (lastSpace == null) {
          lastSpaceOffset = 0;
        } else {
          lastSpaceOffset = lastSpace.getOffset() + 1;
        }

        // System.out.println("Last Space at" + lastSpaceOffset);
        // System.out.println("Cursot at" + cursorOffset);

        if (cursorOffset > lastSpaceOffset) {
          // ok, it could be valid, but we need to check what comes
          // after the cursor.
          if (cursorOffset != doc.getLength()) {
            //System.out.println("yep");
            IRegion nextSpace = finder
                .find(cursorOffset - 1, "[^\\*0-9a-zA-Z_-]", true, false, false, true);
            if (nextSpace != null && nextSpace.getOffset() == cursorOffset) {
              // System.out.println("Next space bit");
              sequence = doc.get().substring(lastSpaceOffset, cursorOffset);
            }
View Full Code Here

Examples of org.eclipse.jface.text.FindReplaceDocumentAdapter

    ITextSelection sel = (ITextSelection) editor.getSelectionProvider().getSelection();
    editor.getSelectionProvider().setSelection(CFDocUtils.selectWord(doc, sel.getOffset()));
    sel = (ITextSelection) editor.getSelectionProvider().getSelection();
    String functionName = sel.getText();
    int startOffset = sel.getOffset();
    FindReplaceDocumentAdapter search = new FindReplaceDocumentAdapter(doc);
    try {
      IRegion startPos = search.find(sel.getOffset() + functionName.length(), "name\\s?=\\s?[\"']" + functionName + "[\"']", true, false,
          false, true);
      if (startPos == null) {
        startPos = search.find(sel.getOffset() + functionName.length(), "name\\s?=\\s?[\"']" + functionName + "[\"']", false, false, false,
            true);
      }
      if (startPos == null) {
        startPos = search.find(sel.getOffset() + functionName.length(), "function\\s" + functionName + "[(\\s]", false, false, false,
            true);
      }
      if (startPos == null) {
        startPos = search.find(sel.getOffset() + functionName.length(), "function\\s" + functionName + "[(\\s]", true, false, false,
            true);
      }
      // search for assignment, backwards first
      if (startPos == null) {
        startPos = search.find(sel.getOffset() + functionName.length(), functionName + "[\\s]?=[^=]", false, false, false, true);
      }
      if (startPos == null) {
        startPos = search.find(sel.getOffset() + functionName.length(), functionName + "[\\s]?=[^=]", true, false, false, true);
      }
      if (startPos == null) {
        if (doc.getChar(startOffset - 1) == '.') {
          String cfcInstance = CFDocUtils.selectWord(doc, sel.getOffset() - 2).getText();
          IRegion assignmentPos = search.find(sel.getOffset() + cfcInstance.length(), cfcInstance + "[\\s]?=[\\s]?new\\s", false,
              false, false, true);
          if (assignmentPos == null) {
            assignmentPos = search.find(sel.getOffset() + cfcInstance.length(), cfcInstance + "[\\s]?=[\\s]?createObject",
                false, false, false, true);
          }
          if (assignmentPos == null) {
            assignmentPos = search.find(sel.getOffset() + cfcInstance.length(), cfcInstance + "[\\s]?=[\\s]?entityNew", false,
                false, false, true);
          }
          if (assignmentPos != null) {
            //MappingManager mappingManager = new MappingManager();
            CFDocument cfdoc = ((ICFDocument) doc).getCFDocument();
            String CFCName = AssistUtils.getCFCName(cfcInstance, cfdoc);
            IFile foundCFC = AssistUtils.findCFC(CFCName);
            if (foundCFC == null) {
              foundCFC = AssistUtils.findCFC(functionName);
            }
            if (foundCFC != null) {
              OpenAtMethodAction openAction = new OpenAtMethodAction(foundCFC, "");
              openAction.run();
            }

          }

        }
        startPos = search.find(sel.getOffset() + functionName.length(), functionName + "[\\s]?=[^=]", true, false, false, true);
      }
      if (startPos != null) {
        startPos = search.find(startPos.getOffset(), functionName, true, true, false, true);
        editor.getSelectionProvider().setSelection(CFDocUtils.selectWord(doc, startPos.getOffset()));
      }
      if (startPos == null || sel.getOffset() == startPos.getOffset()) {
        DocItem st = ((CFMLEditor) editor).getSelectionCursorListener().getSelectedTag();
        if (st.getName().equals("ASTComponent") || st.getName().equals("FunctionCall")) {
View Full Code Here

Examples of org.eclipse.jface.text.FindReplaceDocumentAdapter

      ISelection sel = editor.getSelectionProvider().getSelection();
     
      int cursorOffset = ((ITextSelection)sel).getOffset();
      int lastSpaceOffset = -1;
      //int nextSpaceOffset = -1;
      FindReplaceDocumentAdapter finder = new FindReplaceDocumentAdapter(doc);
     
     
      try {
          IRegion lastSpace = finder.find(cursorOffset-1,"[^\\*0-9a-zA-Z_-]",false,false,false,true);
         
          if (lastSpace == null) {
              lastSpaceOffset = 0;
          }
          else {
              lastSpaceOffset = lastSpace.getOffset()+1;
          }
         
         // System.out.println("Last Space at" + lastSpaceOffset);
         // System.out.println("Cursot at" + cursorOffset);
         
          if (cursorOffset > lastSpaceOffset) {
              // ok, it could be valid, but we need to check what comes after the cursor.
              if (cursorOffset != doc.getLength()) {
                  System.out.println("yep");
                  IRegion nextSpace = finder.find(cursorOffset-1,"[^\\*0-9a-zA-Z_-]",true,false,false,true);
                  if (nextSpace != null
                          && nextSpace.getOffset() == cursorOffset) {
                      //System.out.println("Next space bit");
                      sequence = doc.get().substring(lastSpaceOffset,cursorOffset);
                  }
View Full Code Here

Examples of org.eclipse.jface.text.FindReplaceDocumentAdapter

          // Check to see if the open has a newline but the close doesn't
          if (selectioner.getText().endsWith(lineEnding) && selectioner.getText().startsWith(openComment + lineEnding)) {
            openComment = openComment.substring(lineEnding.length() - 1, openComment.length() - lineEnding.length());
          }
         
          FindReplaceDocumentAdapter finder = new FindReplaceDocumentAdapter(doc);
         
          // Find and replace the closing comment first so that it doesn't get messed up with positions
          finder.find(closeCommentStart, closeComment, true, false, false, false);
          finder.replace("", false);
         
          // Find and replace the opening comment so that it doesn't affect the closing comment replace
          finder.find(openCommentStart, openComment, true, false, false, false);
          finder.replace("", false);
          selectionLength = selection.length() - openComment.length() - closeComment.length() + 1;
        } else {
          if(selectioner.getText().endsWith("\n") && !selectioner.getText().startsWith("\n")){           
            // add newlines if this looks like a newline-to-newline comment, to be pretty
            openComment = openComment.concat("\n");
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.