Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.IRegion


   * @return the line end offset for the given offset
   * @exception BadLocationException if offset is invalid in the current document
   */
  protected int endOfLineOf(int offset) throws BadLocationException {

    IRegion info = fDocument.getLineInformationOfOffset(offset);
    if (offset <= info.getOffset() + info.getLength())
      return info.getOffset() + info.getLength();

    int line = fDocument.getLineOfOffset(offset);
    try {
      info = fDocument.getLineInformation(line + 1);
      return info.getOffset() + info.getLength();
    } catch (BadLocationException x) {
      return fDocument.getLength();
    }
  }
View Full Code Here


    DocumentEvent event,
    boolean documentPartitioningChanged) {
    if (!documentPartitioningChanged) {
      try {

        IRegion info =
          fDocument.getLineInformationOfOffset(event.getOffset());
        int start = Math.max(partition.getOffset(), info.getOffset());

        int end =
          event.getOffset()
            + (event.getText() == null
              ? event.getLength()
              : event.getText().length());

        if (info.getOffset() <= end
          && end <= info.getOffset() + info.getLength()) {
          // optimize the case of the same line
          end = info.getOffset() + info.getLength();
        } else
          end = endOfLineOf(end);

        end =
          Math.min(
View Full Code Here

                }
            }
        }

        // compute user input
        IRegion lineRegion = _document.getLineInformationOfOffset(_cursorInDocument);
       
        if (lineRegion.getOffset() < _region.getOffset()) {
            // stay in parsion region
            lineRegion = _region;
        }
       
        // read backwards until open bracket / line start or control character
        int numClosedBrackets = 0;
        int pos =_cursorInDocument -1;
        while (pos >= lineRegion.getOffset()) {
            char c = _document.getChar(pos);
            if (c == ')') {
                numClosedBrackets++;
            }
            if (c =='(') {
View Full Code Here

        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) {
        }
      }
    } catch (PartInitException e) {
View Full Code Here

                }
               
                if (invalidCharsFound) {
                  // create marker
                  try {
                    IRegion lineInfo = document.getLineInformation(read.getLineNumber() - 1);
                    String lineContent = document.get(lineInfo.getOffset(), lineInfo.getLength());
                    int beginningSpaces = 0;
                    for (int i = 0; i < lineContent.length(); i++) {
                      char c = lineContent.charAt(i);
                      if (Character.isWhitespace(c)) {
                        beginningSpaces++;
                      } else {
                        break;
                      }
                    }
                    int trailingSpaces = 0;
                    for (int i = lineContent.length() - 1; i >= 0; i--) {
                      char c = lineContent.charAt(i);
                      if (Character.isWhitespace(c)) {
                        trailingSpaces++;
                      } else {
                        break;
                      }
                    }
              int charStart = lineInfo.getOffset() + beginningSpaces;             
              int charEnd = charStart + lineInfo.getLength() - beginningSpaces - trailingSpaces;

              Map<String,Object> map = new HashMap<String,Object>();

              MarkerUtilities.setLineNumber(map, read.getLineNumber()-1);
             
View Full Code Here

      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);
      return change;
      }else if (info.getArguments() instanceof DeleteArguments) {
        // check if resource to delete will still exists after parent deletion is performed - otherwise we can skip any change here
View Full Code Here

        try {
            if (startSourceLine > 0) {
                IDocument document = javaEditor.getDocumentProvider()
                    .getDocument(javaEditor.getEditorInput());
                try {
                    IRegion lineInfo = document
                        .getLineInformation(startSourceLine - 1);

                    int startOffset = lineInfo.getOffset();
                    int length = lineInfo.getLength();
                    if(endSourceLine > 0){
                        IRegion region = document.getLineInformation(endSourceLine - 1);
                        length = region.getLength() + (region.getOffset() - startOffset);
                    }
                    EclipseUtils.selectInEditor(javaEditor, startOffset, length);
                } catch (BadLocationException e) {
                    // do nothing. This could happens e.g. if editor does not contain
                    // full source code etc, so that line info is not exist in editor
View Full Code Here

                    + getSourceMapper().getDecompiledLine(
                        (IMember) reference, getClassFile());
                if(decompLine < 0){
                    return;
                }
                IRegion region = ((BytecodeDocumentProvider) getDocumentProvider())
                    .getDecompiledLineInfo(getEditorInput(), decompLine);
                if (region == null) {
                    return;
                }
                offset = region.getOffset();
                length = region.getLength();
            } else if (!isDecompiled()) {
                range = reference.getSourceRange();
                if (range == null) {
                    return;
                }
View Full Code Here

     * @param parent expected parent class file
     * @return The region in the inner class (if inner class could be found), or an empty
     * zero-based region.
     */
    public static IRegion checkForInnerClass(int sourceLine, IClassFile parent) {
        IRegion region = new Region(0, 0);

        // get the editor with given class file, if any
        BytecodeClassFileEditor editor = getBytecodeEditor(parent);
        if (editor == null) {
            return region;
View Full Code Here

   * @return the line end offset for the given offset
   * @exception BadLocationException if offset is invalid in the current document
   */
  protected int endOfLineOf(int offset) throws BadLocationException {

    IRegion info = fDocument.getLineInformationOfOffset(offset);
    if (offset <= info.getOffset() + info.getLength())
      return info.getOffset() + info.getLength();

    int line = fDocument.getLineOfOffset(offset);
    try {
      info = fDocument.getLineInformation(line + 1);
      return info.getOffset() + info.getLength();
    } catch (BadLocationException x) {
      return fDocument.getLength();
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.IRegion

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.