Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.Region


  public void documentChanged(DocumentEvent event) {
    if (fRememberedPosition != null) {
      if (!fRememberedPosition.isDeleted()) {
       
        event.getDocument().removePosition(fRememberedPosition);
        activeRegion= new Region(fRememberedPosition.getOffset(), fRememberedPosition.getLength());
        fRememberedPosition= null;
       
        ISourceViewer viewer= editor.getViewer();
        if (viewer != null) {
          StyledText widget= viewer.getTextWidget();
View Full Code Here


    // adjust offset to end of normalized selection
    if (selection.getOffset() == offset)
      offset= selection.getOffset() + selection.getLength();

    String prefix= extractPrefix(viewer, offset);
    Region region= new Region(offset - prefix.length(), prefix.length());
    TemplateContext context= createContext(viewer, region);
    if (context == null)
      return new ICompletionProposal[0];

    context.setVariable("selection", selection.getText()); // name of the selection variables {line, word}_selection //$NON-NLS-1$
View Full Code Here

        char c = text.charAt(offset);
        if(isEndBlock(c)){
          int place = getPrevPlace(text, c, offset-1);
          if(place >= 0){
            fAnchor = ICharacterPairMatcher.LEFT;
            return new Region(place, 1);
          }
        }
        if(isQuoteCharacter(c)){
          String substr = text.substring(0, offset);
          int stoffset = substr.lastIndexOf(c);
          int eqoffset = substr.lastIndexOf(delimiter);
          if(stoffset > eqoffset){
            int place = substr.lastIndexOf(c, offset - 1);
            if(place >= 0){
              fAnchor = ICharacterPairMatcher.LEFT;
              return new Region(place, 1);
            }
          }
        }
      }
      if(offset > 0){
        char c = text.charAt(offset - 1);
        if(isStartBlock(c)){
          int place = getNextPlace(text, c, offset+1);
          if(place >= 0){
            fAnchor = ICharacterPairMatcher.RIGHT;
            return new Region(place, 1);
          }
        }
        if(isQuoteCharacter(c)){
          String substr = text.substring(0, offset - 1);
          int stoffset = substr.lastIndexOf(c);
          int eqoffset = substr.lastIndexOf(delimiter);
          if(stoffset < eqoffset){
            int place = text.indexOf(c, offset);
            if(place >= 0){
              fAnchor = ICharacterPairMatcher.RIGHT;
              return new Region(place, 1);
            }
          }
        }
      }
    } catch(Exception ex){
View Full Code Here

   */
  public IRegion getSubject(ITextViewer textViewer, int offset) {
    Point selection = textViewer.getTextWidget().getSelection();

    int length = selection.y - selection.x;
    return new Region(offset, length);
  }
View Full Code Here

          end = info.getOffset() + info.getLength();
        } else
          end = endOfLineOf(end);

        end = Math.min(partition.getOffset() + partition.getLength(), end);
        return new Region(start, end - start);

      } catch (BadLocationException x) {
      }
    }
View Full Code Here

        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());
      }
      return sourceRegion;
    } catch (BadLocationException e) {
      ToolPlugin.showError("Error finding method source region.", e);
    }
View Full Code Here

    Matcher sig = ToolEvent.pattern.matcher(source);
   
    while (sig.find()){
      String wholeMatch = sig.group(0);
      ToolEvent eh = new ToolEvent(this, wholeMatch);
      eh.setRegion(new Region(sig.start(0), sig.end(0)));
      if (events == null)
        events = new HashMap<String, ToolEvent>();
      events.put(eh.getLabelText(), eh);
      eh.setDirty(false);
     
View Full Code Here

   
    while (sig.find()){
      //process signature
      String wholeMatch = sig.group(0);
      ToolEventHandler eh = new ToolEventHandler(this, wholeMatch);
      eh.setRegion(new Region(sig.start(0), sig.end(0)));
      eh.setFile(this.implementationFile);
      if (eventHandlers == null)
        eventHandlers = new HashMap<String, ToolEventHandler>();
      eventHandlers.put(eh.getLabelText(), eh);
      eh.setDirty(false);
View Full Code Here

   
    while (sig.find()){
      //process method signature
      String wholeMatch = sig.group(0);
      ToolMethod method = new ToolMethod(this, wholeMatch);
      method.setRegion(new Region(sig.start(0), sig.end(0)));
      method.setFile(this.implementationFile);
      if (methods == null)
        methods = new HashMap<String, ToolMethod>();
      methods.put(method.getLabelText(), method);
     
View Full Code Here

    //Constants
    Matcher matcher = ToolConstant.pattern.matcher(source);
    while (matcher.find()){
      String wholeMatch = matcher.group(0);
      ToolConstant con = new ToolConstant(this, wholeMatch);
      con.setRegion(new Region(matcher.start(0), matcher.end(0)));
      if (constants == null)
        constants = new HashMap<String, ToolConstant>();
      constants.put(con.getName(), con);
      con.setDirty(false);
    }
View Full Code Here

TOP

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

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.