Search in sources :

Example 1 with GString

use of org.eclipse.xtext.parser.terminalrules.unicode.GString in project xtext-core by eclipse.

the class UnicodeTestLanguageSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == UnicodePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case UnicodePackage.GSTRING:
                sequence_GString(context, (GString) semanticObject);
                return;
            case UnicodePackage.MODEL:
                sequence_Model(context, (Model) semanticObject);
                return;
            case UnicodePackage.QUOTED_STRING:
                sequence_QuotedString(context, (QuotedString) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) Model(org.eclipse.xtext.parser.terminalrules.unicode.Model) Parameter(org.eclipse.xtext.Parameter) GString(org.eclipse.xtext.parser.terminalrules.unicode.GString) QuotedString(org.eclipse.xtext.parser.terminalrules.unicode.QuotedString) EPackage(org.eclipse.emf.ecore.EPackage)

Example 2 with GString

use of org.eclipse.xtext.parser.terminalrules.unicode.GString in project xtext-core by eclipse.

the class UnicodeTest method testWrite.

@Test
public void testWrite() throws Exception {
    XtextResource resource = getResource("", "test.mydsl");
    Model model = UnicodeFactory.eINSTANCE.createModel();
    resource.getContents().add(model);
    GString s0 = UnicodeFactory.eINSTANCE.createGString();
    s0.setName(UMLAUTS);
    model.getStrings().add(s0);
    QuotedString s1 = UnicodeFactory.eINSTANCE.createQuotedString();
    s1.setName(UMLAUTS);
    model.getStrings().add(s1);
    QuotedString s2 = UnicodeFactory.eINSTANCE.createQuotedString();
    s2.setName(QUOTED_UMLAUTS);
    model.getStrings().add(s2);
    QuotedString s3 = UnicodeFactory.eINSTANCE.createQuotedString();
    s3.setName(MIXED_UMLAUTS);
    model.getStrings().add(s3);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    resource.save(outputStream, null);
    String textualModel = new String(outputStream.toByteArray(), getCharsetForTest());
    assertEquals(doubleQuote(UMLAUTS + " \"" + UMLAUTS + "\" \"" + QUOTED_UMLAUTS + "\" \"" + MIXED_UMLAUTS + "\""), textualModel);
}
Also used : Model(org.eclipse.xtext.parser.terminalrules.unicode.Model) XtextResource(org.eclipse.xtext.resource.XtextResource) ByteArrayOutputStream(java.io.ByteArrayOutputStream) GString(org.eclipse.xtext.parser.terminalrules.unicode.GString) QuotedString(org.eclipse.xtext.parser.terminalrules.unicode.QuotedString) AbstractString(org.eclipse.xtext.parser.terminalrules.unicode.AbstractString) GString(org.eclipse.xtext.parser.terminalrules.unicode.GString) QuotedString(org.eclipse.xtext.parser.terminalrules.unicode.QuotedString) Test(org.junit.Test)

Aggregations

GString (org.eclipse.xtext.parser.terminalrules.unicode.GString)2 Model (org.eclipse.xtext.parser.terminalrules.unicode.Model)2 QuotedString (org.eclipse.xtext.parser.terminalrules.unicode.QuotedString)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 EPackage (org.eclipse.emf.ecore.EPackage)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1 AbstractString (org.eclipse.xtext.parser.terminalrules.unicode.AbstractString)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1 Test (org.junit.Test)1