Search in sources :

Example 11 with RichStringLiteral

use of org.eclipse.xtend.core.xtend.RichStringLiteral in project xtext-xtend by eclipse.

the class LiteralImpl method setLiteral.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setLiteral(RichStringLiteral newLiteral) {
    RichStringLiteral oldLiteral = literal;
    literal = newLiteral;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ProcessedRichStringPackage.LITERAL__LITERAL, oldLiteral, literal));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) RichStringLiteral(org.eclipse.xtend.core.xtend.RichStringLiteral)

Example 12 with RichStringLiteral

use of org.eclipse.xtend.core.xtend.RichStringLiteral in project xtext-xtend by eclipse.

the class XtendExpressionUtil method getRichStringPartTextRegion.

protected ITextRegion getRichStringPartTextRegion(EObject element) {
    if (element instanceof RichStringLiteral) {
        return locationInFileProvider.getSignificantTextRegion(element);
    }
    ICompositeNode elementNode = NodeModelUtils.getNode(element);
    ITextRegion totalTextRegion = elementNode.getTotalTextRegion();
    int offset = totalTextRegion.getOffset() - 1;
    int length = totalTextRegion.getLength() + 2;
    ILeafNode nextNode = NodeModelUtils.findLeafNodeAtOffset(elementNode.getRootNode(), elementNode.getEndOffset());
    while (nextNode != null && nextNode.isHidden()) {
        length += nextNode.getLength();
        INode nextSibling = nextNode.getNextSibling();
        if (nextSibling instanceof ILeafNode) {
            nextNode = (ILeafNode) nextSibling;
        } else {
            nextNode = null;
        }
    }
    return new TextRegion(offset, length);
}
Also used : INode(org.eclipse.xtext.nodemodel.INode) ILeafNode(org.eclipse.xtext.nodemodel.ILeafNode) TextRegion(org.eclipse.xtext.util.TextRegion) ITextRegion(org.eclipse.xtext.util.ITextRegion) ITextRegion(org.eclipse.xtext.util.ITextRegion) RichStringLiteral(org.eclipse.xtend.core.xtend.RichStringLiteral) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode)

Example 13 with RichStringLiteral

use of org.eclipse.xtend.core.xtend.RichStringLiteral in project xtext-xtend by eclipse.

the class ParserTest method testRichString_00.

@Test
public void testRichString_00() throws Exception {
    XtendFunction function = function("def foo() ''' foo '''");
    assertTrue(function.getExpression() instanceof RichString);
    RichString richString = (RichString) function.getExpression();
    assertEquals(1, richString.getExpressions().size());
    RichStringLiteral stringLiteral = (RichStringLiteral) richString.getExpressions().get(0);
    assertEquals(" foo ", stringLiteral.getValue());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) RichString(org.eclipse.xtend.core.xtend.RichString) RichStringLiteral(org.eclipse.xtend.core.xtend.RichStringLiteral) Test(org.junit.Test)

Example 14 with RichStringLiteral

use of org.eclipse.xtend.core.xtend.RichStringLiteral in project xtext-xtend by eclipse.

the class ParserTest method testRichStringWithComment_03.

@Test
public void testRichStringWithComment_03() throws Exception {
    XtendFunction function = function("def foo() '''first��� comment \nsecond� /* ml comment */ �third'''");
    assertTrue(function.getExpression() instanceof RichString);
    RichString richString = (RichString) function.getExpression();
    assertEquals(3, richString.getExpressions().size());
    RichStringLiteral first = (RichStringLiteral) richString.getExpressions().get(0);
    assertEquals("first", first.getValue());
    RichStringLiteral second = (RichStringLiteral) richString.getExpressions().get(1);
    assertEquals("second", second.getValue());
    RichStringLiteral third = (RichStringLiteral) richString.getExpressions().get(2);
    assertEquals("third", third.getValue());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) RichString(org.eclipse.xtend.core.xtend.RichString) RichStringLiteral(org.eclipse.xtend.core.xtend.RichStringLiteral) Test(org.junit.Test)

Aggregations

RichStringLiteral (org.eclipse.xtend.core.xtend.RichStringLiteral)14 RichString (org.eclipse.xtend.core.xtend.RichString)11 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)9 Test (org.junit.Test)8 XBooleanLiteral (org.eclipse.xtext.xbase.XBooleanLiteral)3 EObject (org.eclipse.emf.ecore.EObject)2 RichStringIf (org.eclipse.xtend.core.xtend.RichStringIf)2 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)2 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)2 INode (org.eclipse.xtext.nodemodel.INode)2 ITextRegion (org.eclipse.xtext.util.ITextRegion)2 XBinaryOperation (org.eclipse.xtext.xbase.XBinaryOperation)2 XExpression (org.eclipse.xtext.xbase.XExpression)2 XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)2 XStringLiteral (org.eclipse.xtext.xbase.XStringLiteral)2 EPackage (org.eclipse.emf.ecore.EPackage)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 RichStringElseIf (org.eclipse.xtend.core.xtend.RichStringElseIf)1 RichStringForLoop (org.eclipse.xtend.core.xtend.RichStringForLoop)1 XtendAnnotationType (org.eclipse.xtend.core.xtend.XtendAnnotationType)1