Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.Position


    }

    Position[] positions = new Position[matches.length];
    int i = 0;
    for (int c = 0; c < matches.length; c++) {
      positions[i++] = new Position(matches[c].getOffset(),
          matches[c].getLength());
    }

    fOccurrencesFinderJob = new OccurrencesFinderJob(document, positions,
        selection, editor);
View Full Code Here


  /**
   * @see org.eclipse.wst.sse.ui.internal.projection.AbstractFoldingStrategy#calcNewFoldPosition(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)
   */
  protected Position calcNewFoldPosition(IndexedRegion indexedRegion) {
    Position retPos = null;
   
    //only want to fold regions of the valid type and with a valid range
    if(indexedRegion.getStartOffset() >= 0 && indexedRegion.getLength() >= 0) {
      IDOMNode node = (IDOMNode)indexedRegion;
      IStructuredDocumentRegion startRegion = node.getStartStructuredDocumentRegion();
View Full Code Here

        }
        parentConstraints.setAvailableLineWidth(lineWidth);

        // format all siblings (and their children) as long they
        // overlap with start/length
        Position formatRange = new Position(start, length);
        formatSiblings(edit, domRegion, parentConstraints, formatRange);
      }
    }
    return edit;
  }
View Full Code Here

   *            the offset of the document region
   * @param length
   *            the length of the document region
   */
  public ReplaceNameTemplateContext(TemplateContextType type, IDocument document, int offset, int length) {
    this(type, document, new Position(offset, length));
  }
View Full Code Here

   * @param insertOffset
   *            the offset of the document region where insert was
   *            originally requested
   */
  public ReplaceNameTemplateContext(TemplateContextType type, IDocument document, int offset, int length, int insertOffset) {
    this(type, document, new Position(offset, length));
    fInsertOffset = insertOffset;
  }
View Full Code Here

      }

      public Position getPosition(Annotation annotation) {
        EclipseAnnotationPeer peer = (EclipseAnnotationPeer) annotation;
        AnnotationFS annotationFS = peer.getAnnotationFS();
        return new Position(annotationFS.getBegin(),
            annotationFS.getEnd() - annotationFS.getBegin());
      }

      public void removeAnnotation(Annotation annotation) {
      }
View Full Code Here

                    // errorOffset = container.getOffset();
                    // errorLength = container.getLength();
                    // errorText = new StringBuffer(container.toString());
                    // }
                    Annotation annotation = new Annotation( ERROR_ANNOTATION_TYPE, true, errorText.toString() );
                    Position position = new Position( errorOffset, errorLength );
                    positionList.add( position );
                    viewer.getAnnotationModel().addAnnotation( annotation, position );
                }

            }
View Full Code Here

        }
    }

    private static void createAnnotation(IFile file, final IAnnotationModel annotationModel, final String message, final int offset, final int length) {
        Annotation annotation = new DRLProblemAnnotation(message);
        Position position = new Position(0, 1);
//        Position position = new Position(offset, length);
        annotationModel.addAnnotation(annotation, position);
    }
View Full Code Here

    protected void calculateFolding(String input) {
        // TODO replace this parsing by getting this input from the parsed rule file
        final List<Position> positions = new ArrayList<Position>();
        Matcher matcher = RULE_PATTERN.matcher(input);
        while (matcher.find()) {
            positions.add(new Position(matcher.start(1), matcher.end(1) - matcher.start(1)));
        }
        matcher = QUERY_PATTERN.matcher(input);
        while (matcher.find()) {
            positions.add(new Position(matcher.start(1), matcher.end(1) - matcher.start(1)));
        }
        matcher = TEMPLATE_PATTERN.matcher(input);
        while (matcher.find()) {
            positions.add(new Position(matcher.start(1), matcher.end(1) - matcher.start(1)));
        }
        matcher = IMPORT_PATTERN.matcher(input);
        while (matcher.find()) {
            positions.add(new Position(matcher.start(1), matcher.end(1) - matcher.start(1)));
        }
        matcher = FUNCTION_PATTERN.matcher(input);
        while (matcher.find()) {
            int start = matcher.start(1);
            // TODO also take comments, strings etc. in consideration
            // use JavaPairMatcher or similar
            int nbOpenBrackets = 1;
            for (int i = matcher.end(); i < input.length(); i++) {
                if (input.charAt(i) == '{') {
                    nbOpenBrackets++;
                } else if (input.charAt(i) == '}') {
                    if (--nbOpenBrackets == 0) {
                        positions.add(new Position(start, i - start + 1));
                        break;
                    }
                }
            }
        }
View Full Code Here

                    int stop = invalidFilters[i].getStopToken() != null ? invalidFilters[i].getStopToken().getOffset()
                        + invalidFilters[i].getStopToken().getLength() : start
                        + invalidFilters[i].getStartToken().getLength();

                    Annotation annotation = new Annotation( "DEFAULT", true, invalidFilters[i].toString() ); //$NON-NLS-1$
                    Position position = new Position( start, stop - start );
                    positionList.add( position );
                    sourceViewer.getAnnotationModel().addAnnotation( annotation, position );
                }
            }

            for ( int i = 0; i < tokens.length; i++ )
            {
                if ( tokens[i].getType() == LdapFilterToken.ERROR )
                {

                    boolean overlaps = false;
                    for ( int k = 0; k < positionList.size(); k++ )
                    {
                        Position pos = positionList.get( k );
                        if ( pos.overlapsWith( tokens[i].getOffset(), tokens[i].getLength() ) )
                        {
                            overlaps = true;
                            break;
                        }
                    }
                    if ( !overlaps )
                    {
                        Annotation annotation = new Annotation( "DEFAULT", true, tokens[i].getValue() ); //$NON-NLS-1$
                        Position position = new Position( tokens[i].getOffset(), tokens[i].getLength() );
                        sourceViewer.getAnnotationModel().addAnnotation( annotation, position );
                    }
                }
            }
        }
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.