Examples of IRegion


Examples of org.eclipse.jface.text.IRegion

        return text;

      try {
        // find start of line
        int p= (offset == document.getLength() ? offset  - 1 : offset);
        IRegion info= document.getLineInformationOfOffset(p);
        int start= info.getOffset();

        // find white spaces
        int end= findEndOfWhiteSpace(document, start, offset);

        StringBuffer buf= new StringBuffer(text);
View Full Code Here

Examples of org.eclipse.jface.text.IRegion

  }
 
  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;
    }
    /*
    IRegion end = findReplaceAdapter.find(start.getOffset() + start.getLength(), "\"", true, true, false, false);
View Full Code Here

Examples of org.eclipse.jface.text.IRegion

  public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {   
    setErrorMessage(null);
    IDocument document = viewer.getDocument();
           
        try {
            IRegion region = document.getPartition(offset);
           
            // search backwards to document start or partition of type TML - this is neccessary bc. our current script may contain TMLscript comments
            ITypedRegion prevPartition = null;
            int previousOffset = region.getOffset() - 1;
            while (previousOffset > 0) {
                prevPartition = document.getPartition(previousOffset);
                if (prevPartition.getType().equals(TMLPartitionScanner.TML_TAG_START)) {
                    break;
                }
                previousOffset = prevPartition.getOffset() - 1;
            }
           
            if (prevPartition != null) {
                region = new Region(previousOffset+1, region.getOffset() - previousOffset + region.getLength() - 1);
            }
           
            VersionCompliance versionCompliance = WGADesignStructureHelper.getWGAVersionCompliance(Plugin.getDefault().getActiveFile());
            TMLScriptRegion tmlScriptRegion = TMLScriptRegion.parse(region, document, offset, versionCompliance);
            System.out.println(tmlScriptRegion.toString());
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

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

                }
            }
        }

        // 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

Examples of org.eclipse.jface.text.IRegion

        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

Examples of org.eclipse.jface.text.IRegion

                }
               
                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
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.