Package org.eclipse.xtext.util

Examples of org.eclipse.xtext.util.TextRegion


      //in particular for folding, the significant region would otherwise be a
      //potential type of language keyword
      return getSignificantTextRegion(obj, XturtlePackage.Literals.LITERAL__VALUE,-1);
    } else if(obj instanceof BlankObjects || obj instanceof BlankCollection){
      ICompositeNode node = NodeModelUtils.findActualNodeFor(obj);
      return new TextRegion(node.getOffset(), 1);
    }
    return super.getSignificantTextRegion(obj);
  }
View Full Code Here


   * @return the cross referenced EObject under, right or left to the cursor (in that order) or <code>null</code> if
   *         there is no cross referenced
   *         object next to the offset.
   */
  public List<IEObjectDescription> resolveCrossReferencedElementAt(XtextResource resource, int offset) {
    INode node = getCrossReferenceNode(resource, new TextRegion(offset, 0));
    if(node != null)
      return getCrossReferencedElement(node);
    return null;
  }
View Full Code Here

          else if(content.endsWith("\n"))
            length -= 1;

          Matcher matcher = getTextPatternInComment().matcher(content);
          if(matcher.find()) {
            TextRegion significant = new TextRegion(offset + matcher.start(), 0);
            foldingRegionAcceptor.accept(offset, length, significant);
          }
          else {
            foldingRegionAcceptor.accept(offset, length);
          }
View Full Code Here

        else if(content.endsWith("\n"))
          length -= 1;

        Matcher matcher = getTextPatternInComment().matcher(content);
        if(matcher.find()) {
          TextRegion significant = new TextRegion(startOffset + matcher.start(), 0);
          foldingRegionAcceptor.accept(startOffset, length, significant);
        }
        else {
          foldingRegionAcceptor.accept(startOffset, length);
        }
View Full Code Here

   */
  @Override
  public void createHyperlinksByOffset(XtextResource resource, int offset, IHyperlinkAcceptor acceptor) {
    super.createHyperlinksByOffset(resource, offset, acceptor);

    INode crossRefNode = ppObjectAtOffsetHelper.getCrossReferenceNode(resource, new TextRegion(offset, 0));
    if(crossRefNode == null)
      return;
    List<IEObjectDescription> crossLinkedObjects = ppObjectAtOffsetHelper.getCrossReferencedElement(crossRefNode);
    Region region = new Region(crossRefNode.getOffset(), crossRefNode.getLength());
    if(crossLinkedObjects != null)
View Full Code Here

    wsWritten = false;
    final StringBuilder builder = new StringBuilder();
    internalFormat(dom, regionToFormat, formattingContext, builder);
    final String text = builder.toString();
    if(regionToFormat == null)
      regionToFormat = new TextRegion(0, text.length());
    return new ReplaceRegion(regionToFormat, text);
  }
View Full Code Here

            try {
              resourceScope.enter(state);
              // EObject context = getContext(state.getContents().get(0));
              IDomNode root = getSerializer().serializeToDom(state.getContents().get(0), false);
              org.eclipse.xtext.util.ReplaceRegion r = getFormatter().format(
                root, new TextRegion(0, document.getLength()), //
                getFormattingContextFactory().create(state, FormattingOption.Format), errors);
              if(!content.equals(r.getText())) {
                document.replace(0, document.getLength(), r.getText());
                changed = true;
              }
View Full Code Here

      textString = ((StringBuilder) text).toString();
    else
      textString = new StringBuilder(text).toString();

    return new ReplaceRegion(regionToFormat == null
        ? new TextRegion(0, text.length())
        : regionToFormat, textString);
  }
View Full Code Here

    assertTrue(ws.containsAll(none));
  }

  @Test
  public void testRegionMatcher_after() {
    RegionMatch match = new RegionMatch("abc", 5, new TextRegion(3, 2));
    assertEquals("Should be AFTER", RegionMatch.IntersectionType.AFTER, match.getIntersectionType());
    Triple<CharSequence, CharSequence, CharSequence> applied = match.apply();
    assertEquals("", applied.getFirst().toString());
    assertEquals("", applied.getSecond().toString());
    assertEquals("abc", applied.getThird().toString());
View Full Code Here

    assertEquals("abc", applied.getThird().toString());
  }

  @Test
  public void testRegionMatcher_before() {
    RegionMatch match = new RegionMatch("abc", 0, new TextRegion(3, 2));
    assertEquals("Should be BEFORE", RegionMatch.IntersectionType.BEFORE, match.getIntersectionType());
    Triple<CharSequence, CharSequence, CharSequence> applied = match.apply();
    assertEquals("", applied.getFirst().toString());
    assertEquals("abc", applied.getSecond().toString());
    assertEquals("", applied.getThird().toString());
View Full Code Here

TOP

Related Classes of org.eclipse.xtext.util.TextRegion

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.