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));
}
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);
}
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());
}
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());
}
Aggregations