Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.FindReplaceDocumentAdapter$FindReplaceOperationCode


      return (value.trim().startsWith("{") && value.trim().endsWith("}")) || (value.trim().startsWith("[") && value.trim().endsWith("]"));
    }
  }
 
  public IRegion getAttributeValueRegion(String attributeName) throws BadLocationException {
    FindReplaceDocumentAdapter findReplaceAdapter = new FindReplaceDocumentAdapter(_document);
   
    IRegion region = findReplaceAdapter.find(_documentRegion.getOffset(), attributeName + "=\"" + getAttributeValue(attributeName) + "\"", true, true, false, false);
    if (region != null) {
      String tmp = attributeName + "=\"";
      return new Region(region.getOffset() + tmp.length(), region.getLength() - tmp.length() - 1);
    } else {
      return null;
View Full Code Here


  public LabelTagReplaceHandler(IDocument doc, String labelFileName) {
    super();
    _doc = doc;
    _labelFileName = labelFileName;
    _findreplace = new FindReplaceDocumentAdapter(doc);
    IEditorPart editorPart = Plugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (editorPart != null && editorPart instanceof ITextEditor) {
      _editor = (ITextEditor) editorPart;
    }
    ITextSelection selection = ((ITextSelection) _editor.getEditorSite().getSelectionProvider().getSelection());
View Full Code Here

      if (editor instanceof TextEditor) {
        ITextEditor textEditor = (ITextEditor) editor;
        IDocument doc = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
        try {
          // search for line starting with label key
          FindReplaceDocumentAdapter finder = new FindReplaceDocumentAdapter(doc);
          IRegion keyRegion = finder.find(0, "^" + LabelFileEncodingHelper.saveConvert(labelKey,true).replaceAll("\\\\", "\\\\\\\\") + "\\s*=", true, false, false, true);
          if (keyRegion != null) {
            textEditor.getSelectionProvider().setSelection(new TextSelection(keyRegion.getOffset() + keyRegion.getLength(),0));
          }
        } catch (BadLocationException e) {
        }
View Full Code Here

      TextFileChange change = new TextFileChange("", info.getFile());
      IDocument doc = change.getCurrentDocument(new NullProgressMonitor());
      // create Textedit
   
 
      FindReplaceDocumentAdapter find = new FindReplaceDocumentAdapter(doc);
      IRegion resultStart = find.find(0, "location\\s*=\\s*\"", true, true, false, true);
      IRegion resultStop = find.find(resultStart.getOffset() + resultStart.getLength(), "\"", true, true, false, false);
 
      String linkTarget = WGADesignStructureHelper.computeDirLinkTarget(info.getFile().getParent(), computeNewLinkTarget(info));
      TextEdit edit = new ReplaceEdit(resultStart.getLength() + resultStart.getOffset(), resultStop.getOffset() - (resultStart.getLength() + resultStart.getOffset()), linkTarget);
     
      change.setEdit(edit);
View Full Code Here

            // Repace the selection with the subroutine call
            doc.replace(selection.getOffset(), selection.getLength(), result[0]);

            int offset = -1;

            FindReplaceDocumentAdapter docFind = new FindReplaceDocumentAdapter(doc);

            IRegion regionEnd =
                docFind.find(selection.getOffset(), "^__END__", true, true, false, true);
            offset = (regionEnd != null) ? regionEnd.getOffset() : doc.getLength();

            String lineSep = getLineSeparator(doc.get());

            // format and insert the new subroutine code
View Full Code Here

 
  public void setHtmlSelection(String wicketId)
  {
    final IDocument document = htmlEditor.getDocumentProvider().getDocument(htmlEditor.getEditorInput());

    final FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
   
    String[] ids = wicketId.split("/");
   
    try
    {
      IRegion region = null;
      int index = 0;
     
      for(int i=0; i<ids.length; i++)
      {
        region = frda.find(index, '"' + ids[i] + '"', true, true, false, false);
        if(region != null)
        {
          index = region.getOffset();
        }
      }
View Full Code Here

        try {
          if ("java".equals(extension))
          {
            final ITextEditor textEditor = (ITextEditor)wEditor.getJavaEditor();
            final IDocument document = ((textEditor).getDocumentProvider()).getDocument(textEditor.getEditorInput());
            final FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
            final IRegion region = frda.find(0, '"' + wicketId + '"', true, true, false, false);
            if (region != null)
            {
              textEditor.selectAndReveal(region.getOffset() + 1, wicketId.length());
              wEditor.setActiveEditor(wEditor.getJavaEditor());
            }
          }
          else if ("html".equals(extension))
          {
            final ITextEditor textEditor = (ITextEditor)wEditor.getHtmlEditor();
            final IDocument document = ((textEditor).getDocumentProvider()).getDocument(textEditor.getEditorInput());
            final FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
            final IRegion region = frda.find(0, "wicket:id=\"" + wicketId, true, true, true, false);
            if (region != null)
            {
              textEditor.selectAndReveal(region.getOffset() + 11, wicketId.length());
              wEditor.setActiveEditor(wEditor.getHtmlEditor());
            }
          }
          else if ("properties".equals(extension) && propertiesEditor != null)
          {
            final ITextEditor textEditor = (ITextEditor)propertiesEditor;
            final IDocument document = ((textEditor).getDocumentProvider()).getDocument(textEditor.getEditorInput());
            final FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
            IRegion regionBegin = frda.find(0, wicketId, true, true, true, false);
            if (regionBegin != null)
            {
              regionBegin = frda.find(regionBegin.getOffset(), "=", true, true, false, false);
              if (regionBegin != null)
              {
                final IRegion lineRegion = document.getLineInformationOfOffset(regionBegin.getOffset());
                final int selectionLength = lineRegion.getOffset() + lineRegion.getLength() - regionBegin.getOffset();
                textEditor.selectAndReveal(regionBegin.getOffset() + 1, selectionLength);
View Full Code Here

   
        if (firstPosition == document.getLength()) {
            return res;
        }

    FindReplaceDocumentAdapter searcher= new FindReplaceDocumentAdapter(document);

    // search only at word boundaries
    String searchPattern;

    // unless we are at the beginning of the document, the completion boundary
    // matches one character. It is enough to move just one character backwards
    // because the boundary pattern has the (....)+ form.
    // see HippieCompletionTest#testForwardSearch().
    if (firstPosition > 0) {
      firstPosition--;
      // empty spacing is not permitted now.
      searchPattern= NON_EMPTY_COMPLETION_BOUNDARY + asRegPattern(prefix);
    } else {
      searchPattern= COMPLETION_BOUNDARY + asRegPattern(prefix);
    }
   
    IRegion reg= searcher.find(firstPosition, searchPattern, true, CASE_SENSITIVE, false, true);
    while (reg != null) {
      // since the boundary may be of nonzero length
      int wordSearchPos= reg.getOffset() + reg.getLength() - prefix.length();
      // try to complete to a word. case is irrelevant here.
      IRegion word= searcher.find(wordSearchPos, COMPLETION_WORD_REGEX, true, true, false, true);
      if (word.getLength() > prefix.length() ) { // empty suggestion will be added later
        String wholeWord= document.get(word.getOffset(), word.getLength());
        String completion= wholeWord.substring(prefix.length());
        if (currentWordLast && reg.getOffset() == firstPosition) { // we got the word at caret as completion
          currentWordCompletion= completion; // add it as the last word.
        } else {
          res.add(completion);
        }
      }
      int nextPos= word.getOffset() + word.getLength();
      if (nextPos >= document.getLength() ) {
        break;
      }
      reg= searcher.find(nextPos, searchPattern, true, CASE_SENSITIVE, false, true);
    }
   
    // the word at caret position goes last (bug 132533).
    if (currentWordCompletion != null) {
      res.add(currentWordCompletion);
View Full Code Here

        // actual caret position, probably for compatibility with forward search.
        if (firstPosition == 0) {
            return res;
        }

    FindReplaceDocumentAdapter searcher= new FindReplaceDocumentAdapter(document);

    // search only at word boundaries
    String searchPattern= COMPLETION_BOUNDARY + asRegPattern(prefix);

    IRegion reg= searcher.find(0, searchPattern, true, CASE_SENSITIVE, false, true);
    while (reg != null) {
      // since the boundary may be of nonzero length
      int wordSearchPos= reg.getOffset() + reg.getLength() - prefix.length();
      // try to complete to a word. case is of no matter here
      IRegion word= searcher.find(wordSearchPos, COMPLETION_WORD_REGEX, true, true, false, true);
            if (word.getOffset() + word.getLength() > firstPosition) {
                break;
            }
      if (word.getLength() > prefix.length() ) { // empty suggestion will be added later
        String found= document.get(word.getOffset(), word.getLength());
        res.add(found.substring(prefix.length()));
      }
            int nextPos= word.getOffset() + word.getLength();
            if (nextPos >= firstPosition ) { // for efficiency only
                break;
            }
      reg= searcher.find(nextPos, searchPattern, true, CASE_SENSITIVE, false, true);
    }
        Collections.reverse(res);

    return res;
  }
View Full Code Here

    targetSignature = targetSignature.replaceAll("\\)", "\\\\)");
    targetSignature = ((ToolComponent)getParent()).getToolName() + "." + targetSignature;
    String startRegionRegex = "method\\s+" + targetSignature + "\\s*begin";
    String endRegionRegex = "(?s)(.+?)(?-s)end method;";
    try {
      FindReplaceDocumentAdapter frAdapter = new FindReplaceDocumentAdapter(document);
      IRegion startRegion = frAdapter.find(0, startRegionRegex, true, false, false, true);
     
      if (startRegion == null)
        return null; // no method implementation
     
      IRegion endRegion = frAdapter.find(startRegion.getOffset()+startRegion.getLength()+"begin".length(), endRegionRegex, true, false, false, true);
      IRegion sourceRegion = null;
      if (includeSignature){
        sourceRegion = new Region(startRegion.getOffset(), "begin".length()+startRegion.getLength()+endRegion.getLength());
      } else {
        sourceRegion = new Region(endRegion.getOffset(), endRegion.getLength()-"end method;".length());
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.FindReplaceDocumentAdapter$FindReplaceOperationCode

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.