Search in sources :

Example 36 with RichString

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

the class RichStringProcessorTest method richStringWithError.

protected RichString richStringWithError(String string) throws Exception {
    XtextResourceSet set = getResourceSet();
    String fileName = getFileName(string);
    Resource resource = set.createResource(URI.createURI(fileName + ".xtend"));
    resource.load(new StringInputStream(getPrefix() + string + "}"), null);
    XtendFile file = (XtendFile) resource.getContents().get(0);
    XtendClass clazz = (XtendClass) file.getXtendTypes().get(0);
    XtendFunction function = (XtendFunction) clazz.getMembers().get(0);
    return (RichString) function.getExpression();
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) StringInputStream(org.eclipse.xtext.util.StringInputStream) RichString(org.eclipse.xtend.core.xtend.RichString) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) Resource(org.eclipse.emf.ecore.resource.Resource) RichString(org.eclipse.xtend.core.xtend.RichString)

Example 37 with RichString

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

the class RichStringValidationTest method assertValidRichString.

protected void assertValidRichString(String input) throws Exception {
    RichString richString = richString(input);
    validationTestHelper.assertNoIssues(richString);
}
Also used : RichString(org.eclipse.xtend.core.xtend.RichString)

Example 38 with RichString

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

the class RichStringValidationTest method testRichStringValidation_04.

@Test
public void testRichStringValidation_04() throws Exception {
    String input = "'''  \n" + "\t\tindentedLine\n" + "  \tindentedLine\n" + "  '''";
    RichString richString = richString(input);
    validationTestHelper.assertWarning(richString, XtendPackage.Literals.RICH_STRING_LITERAL, IssueCodes.INCONSISTENT_INDENTATION, "inconsistent", "indentation");
}
Also used : RichString(org.eclipse.xtend.core.xtend.RichString) RichString(org.eclipse.xtend.core.xtend.RichString) AbstractRichStringTest(org.eclipse.xtend.core.tests.richstring.AbstractRichStringTest) Test(org.junit.Test)

Aggregations

RichString (org.eclipse.xtend.core.xtend.RichString)38 Test (org.junit.Test)18 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)15 RichStringLiteral (org.eclipse.xtend.core.xtend.RichStringLiteral)11 XExpression (org.eclipse.xtext.xbase.XExpression)11 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)8 XtendField (org.eclipse.xtend.core.xtend.XtendField)6 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)6 XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)5 XBinaryOperation (org.eclipse.xtext.xbase.XBinaryOperation)4 DefaultIndentationHandler (org.eclipse.xtend.core.richstring.DefaultIndentationHandler)3 RichStringForLoop (org.eclipse.xtend.core.xtend.RichStringForLoop)3 XBooleanLiteral (org.eclipse.xtext.xbase.XBooleanLiteral)3 XStringLiteral (org.eclipse.xtext.xbase.XStringLiteral)3 EObject (org.eclipse.emf.ecore.EObject)2 RichStringProcessor (org.eclipse.xtend.core.richstring.RichStringProcessor)2 AbstractRichStringTest (org.eclipse.xtend.core.tests.richstring.AbstractRichStringTest)2 RichStringIf (org.eclipse.xtend.core.xtend.RichStringIf)2 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)2 XtendInterface (org.eclipse.xtend.core.xtend.XtendInterface)2