Examples of IRegion


Examples of org.eclipse.jface.text.IRegion

      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

Examples of org.eclipse.jface.text.IRegion

        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

Examples of org.eclipse.jface.text.IRegion

                    + 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

Examples of org.eclipse.jface.text.IRegion

     * @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

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

Examples of org.eclipse.jface.text.IRegion

    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

Examples of org.eclipse.jface.text.IRegion

            parent.setBorder(BORDER_UPPER);

            if (postfix > offset) {

              text= parent.getText(range.getOffset(), range.getLength());
              final IRegion region= trimLine(text, content);

              range.move(region.getOffset());
              range.setLength(region.getLength());
            }
          }
        }
      }
    } else if (line == lines - 1) {

      offset= text.indexOf(content);
      if (offset >= 0 && text.substring(0, offset).trim().length() != 0)
        offset= -1;
      postfix= text.lastIndexOf(end);
      if (postfix >= 0 && text.substring(postfix + end.length()).trim().length() != 0)
        postfix= -1;
     
      if (offset >= 0 && offset == postfix)
        // no content on line, only the comment postfix
        range.setLength(0);
      else {
        if (offset >= 0)
          // omit the content prefix
          range.trimBegin(offset + content.length());
       
        if (postfix >= 0)
          // omit the comment postfix
          range.trimEnd(-end.length());
       
        text= parent.getText(range.getOffset(), range.getLength());
        final IRegion region= trimLine(text, content);
        if (region.getOffset() != 0 || region.getLength() != text.length()) {

          range.move(region.getOffset());
          range.setLength(region.getLength());

          parent.setBorder(BORDER_UPPER);
          parent.setBorder(BORDER_LOWER);
        }
      }
View Full Code Here

Examples of org.eclipse.jface.text.IRegion

      }
     
      StringBuffer buf= new StringBuffer();
     
      for (int i= 0; i < nLines; i++) {
        IRegion region= tracker.getLineInformation(i);
        int start= region.getOffset();
        int end= start + region.getLength();
        String line= code.substring(start, end);
       
        if (i == 0) {  // no indent for first line (contained in the formatted string)
          buf.append(line);
        } else { // no new line after last line
View Full Code Here

Examples of org.eclipse.jface.text.IRegion

      tracker.set(source);
      int nLines= tracker.getNumberOfLines();
      if (nLines == 1)
        return (ReplaceEdit[])result.toArray(new ReplaceEdit[result.size()]);
      for (int i= 1; i < nLines; i++) {
        IRegion region= tracker.getLineInformation(i);
        int offset= region.getOffset();
        String line= source.substring(offset, offset + region.getLength());
        int length= indexOfIndent(line, indentUnitsToRemove, tabWidth, indentWidth);
        if (length >= 0) {
          result.add(new ReplaceEdit(offset, length, newIndentString));
        } else {
          length= measureIndentUnits(line, tabWidth, indentWidth);
View Full Code Here

Examples of org.eclipse.jface.text.IRegion

   */
  public int getStartPosition() {
    if (this.group.isEmpty()) {
      return this.node.getStartPosition();
    }
    IRegion coverage= TextEdit.getCoverage(this.group.getTextEdits());
    if (coverage == null) {
      return this.node.getStartPosition();
    }
    return coverage.getOffset();
  }
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.