Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.Position


        IRegion region = frAdapter.find(0, ToolMethod.CEX_SIGNATURE_REGEX, true, false, false, true);
        String methodSignature = null;
        while (region != null){
          int offset = region.getOffset();
          int length = region.getLength();
          Position p = new Position(offset, length);
          document.addPosition(SEGMENTS, p);
          methodSignature = document.get(region.getOffset(), region.getLength());
          Matcher sig = ToolMethod.cexSignaturePattern.matcher(methodSignature);
          if (sig.find()){
            methodSignature = sig.group(1);
            methodSignature = methodSignature.replaceAll("\\s","");
            methodSignature = methodSignature.substring(methodSignature.indexOf(".")+1);
            fContent.add(new Segment(methodSignature, p, "icons/private_method.gif"));
          }
          region = frAdapter.find(offset+length, ToolMethod.CEX_SIGNATURE_REGEX, true, false, false, true);
        }
        // do the event handlers
        region = frAdapter.find(0, ToolEventHandler.CEX_SIGNATURE_REGEX, true, false, false, true);
        String ehSignature = null;
        while (region != null){
          int offset = region.getOffset();
          int length = region.getLength();
          Position p = new Position(offset, length);
          document.addPosition(SEGMENTS, p);
          ehSignature = document.get(region.getOffset(), region.getLength());
          Matcher sig = ToolEventHandler.cexSignaturePattern.matcher(ehSignature);
          if (sig.find()){
            ehSignature = sig.group(1);
            ehSignature = ehSignature.replaceAll("\\s","");
            ehSignature = ehSignature.substring(ehSignature.indexOf(".")+1);
            fContent.add(new Segment(ehSignature, p, "icons/private_event_handler.gif"));
          }
          region = frAdapter.find(offset+length, ToolEventHandler.CEX_SIGNATURE_REGEX, true, false, false, true);
        }
        // do constants
        region = frAdapter.find(0, ToolConstant.PLAN_REGEX, true, false, false, true);
        String constText = null;
        while (region != null){
          int offset = region.getOffset();
          int length = region.getLength();
          Position p = new Position(offset, length);
          document.addPosition(SEGMENTS, p);
          constText = document.get(region.getOffset(), region.getLength());
          fContent.add(new Segment(constText, p, "icons/private_constant.gif"));
          region = frAdapter.find(offset+length, ToolConstant.PLAN_REGEX, true, false, false, true);
        }
        // do classes
        region = frAdapter.find(0, ToolClass.CLASS_REGEX, true, false, false, true);
        String classText = null;
        while (region != null){
          int offset = region.getOffset();
          int length = region.getLength();
          Position p = new Position(offset, length);
          document.addPosition(SEGMENTS, p);
          classText = document.get(region.getOffset(), region.getLength());
          fContent.add(new Segment(classText, p, "icons/class.gif"));
          region = frAdapter.find(offset+length, ToolClass.CLASS_REGEX, true, false, false, true);
        }
View Full Code Here


    SearchRequestor requestor = new SearchRequestor() {
      @Override
      public void acceptSearchMatch(final SearchMatch match) {
        IAnnotationModel model = textEditor.getDocumentProvider().getAnnotationModel(textEditor.getEditorInput());
        Annotation annotation = new Annotation("org.eclipse.jdt.ui.occurrences", false, "wicket id constant");
        model.addAnnotation(annotation, new Position(match.getOffset(), match.getLength()));
      }
    };

    SearchEngine searchEngine = new SearchEngine();
    try {
View Full Code Here

   * org.eclipse.imp.parser.IMessageHandler#handleSimpleMessage(java.lang.
   * String, int, int, int, int, int, int)
   */
  public void handleSimpleMessage(String message, int startOffset,
      int endOffset, int startCol, int endCol, int startLine, int endLine) {
    Position pos = new Position(startOffset, endOffset - startOffset + 1);
    fMessages.add(new PositionedMessage(message, pos));
  }
View Full Code Here

                }
            }

            ContributionAnnotation annotation = new ContributionAnnotation(
                source, model);
            addContributionAnnotation(annotation, new Position(offset, length));
        }
    }
View Full Code Here

            .hasNext();) {
            Annotation annotation = it.next();

            if (annotation instanceof ContributionAnnotation) {

                Position pos = model.getPosition(annotation);

                if (pos == null) {
                    /*
                     * FIXME This error occurs when search/replacing lots of
                     * small stuff as client
                     */
                    log.warn("Annotation could not be found: " + annotation);
                    return;
                }

                if ((offset > pos.offset) && (offset < pos.offset + pos.length)) {
                    Position beforeOffset = new Position(pos.offset, offset
                        - pos.offset);
                    Position afterOffset = new Position(offset, pos.length
                        - (offset - pos.offset));

                    ContributionAnnotation oldAnnotation = (ContributionAnnotation) annotation;

                    removeFromHistory(oldAnnotation);
View Full Code Here

                    }
                }
            }

            setSelectionAnnotation(source, model, new SelectionAnnotation(
                source, isCursor), new Position(offset, length));
        }
    }
View Full Code Here

                throw new BadLocationException("Start line -1");
            int end = document.getLineOffset(bottom);
            if (end == -1 || end < start)
                throw new BadLocationException("End line -1 or less than start");
            SarosAnnotation annotation = new ViewportAnnotation(source);
            Position position = new Position(start, end - start);
            model.addAnnotation(annotation, position);
        } catch (BadLocationException e) {
            log.warn("Internal Error:", e);
        }
    }
View Full Code Here

   * @return the corresponding Java offset for a give JSP offset
   */
  public int getJavaOffset(int jspOffset) {
    int result = -1;
    int offsetInRange = 0;
    Position jspPos, javaPos = null;

    // iterate all mapped jsp ranges
    Iterator it = fJsp2JavaMap.keySet().iterator();
    while (it.hasNext()) {
      jspPos = (Position) it.next();
      // need to count the last position as included
      if (!jspPos.includes(jspOffset) && !(jspPos.offset+jspPos.length == jspOffset))
        continue;

      offsetInRange = jspOffset - jspPos.offset;
      javaPos = (Position) fJsp2JavaMap.get(jspPos);
      if(javaPos != null)
View Full Code Here

   * @return the corresponding JSP offset for a give Java offset
   */
  public int getJspOffset(int javaOffset) {
    int result = -1;
    int offsetInRange = 0;
    Position jspPos, javaPos = null;

    // iterate all mapped java ranges
    Iterator it = fJava2JspMap.keySet().iterator();
    while (it.hasNext()) {
      javaPos = (Position) it.next();
View Full Code Here

   */
  public boolean javaSpansMultipleJspPartitions(int javaOffset, int javaLength) {
    HashMap java2jsp = getJava2JspMap();
    int count = 0;
    Iterator it = java2jsp.keySet().iterator();
    Position javaRange = null;
    while(it.hasNext()) {
      javaRange = (Position)it.next();
      if(javaRange.overlapsWith(javaOffset, javaLength))
        count++;
      if(count > 1)
        return true;
    }
    return false;
View Full Code Here

TOP

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

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.