Search in sources :

Example 1 with EClassRef

use of org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.EClassRef in project xtext-core by eclipse.

the class ChangeSerializerWithEmfTest method testChangeRefToXML.

@Test
public void testChangeRefToXML() {
    final InMemoryURIHandler fs = new InMemoryURIHandler();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("#21 MyPackage.MyClass1");
    Pair<String, String> _mappedTo = Pair.<String, String>of("inmemory:/file1.pstl", _builder.toString());
    this._changeSerializerTestHelper.operator_add(fs, _mappedTo);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    _builder_1.newLine();
    _builder_1.append("<ecore:EPackage xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("xmlns:ecore=\"http://www.eclipse.org/emf/2002/Ecore\" name=\"MyPackage\">");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("<eClassifiers xsi:type=\"ecore:EClass\" name=\"MyClass1\" eSuperTypes=\"#//MyClass2\"/>");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("<eClassifiers xsi:type=\"ecore:EClass\" name=\"MyClass2\"/>");
    _builder_1.newLine();
    _builder_1.append("</ecore:EPackage>");
    _builder_1.newLine();
    Pair<String, String> _mappedTo_1 = Pair.<String, String>of("inmemory:/file2.ecore", _builder_1.toString());
    this._changeSerializerTestHelper.operator_add(fs, _mappedTo_1);
    final ResourceSet rs = this._changeSerializerTestHelper.createResourceSet(fs);
    final EClassRef model = this._changeSerializerTestHelper.<EClassRef>contents(rs, "inmemory:/file1.pstl", EClassRef.class);
    final ChangeSerializer serializer = this.serializerProvider.get();
    final IChangeSerializer.IModification<EClassRef> _function = (EClassRef it) -> {
        EClassifier _get = model.getRef().getEPackage().getEClassifiers().get(1);
        model.setRef(((EClass) _get));
    };
    serializer.<EClassRef>addModification(model, _function);
    Collection<IEmfResourceChange> _endRecordChangesToTextDocuments = this._changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("----------------- inmemory:/file1.pstl (syntax: <offset|text>) -----------------");
    _builder_2.newLine();
    _builder_2.append("#21 <4:18|MyPackage.MyClass2>");
    _builder_2.newLine();
    _builder_2.append("--------------------------------------------------------------------------------");
    _builder_2.newLine();
    _builder_2.append("4 18 \"MyPackage.MyClass1\" -> \"MyPackage.MyClass2\"");
    _builder_2.newLine();
    this._changeSerializerTestHelper.operator_tripleEquals(_endRecordChangesToTextDocuments, _builder_2);
}
Also used : EClassRef(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.EClassRef) IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) ChangeSerializer(org.eclipse.xtext.ide.serializer.impl.ChangeSerializer) InMemoryURIHandler(org.eclipse.xtext.testing.util.InMemoryURIHandler) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) EClassifier(org.eclipse.emf.ecore.EClassifier) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IEmfResourceChange(org.eclipse.xtext.ide.serializer.IEmfResourceChange) Test(org.junit.Test)

Aggregations

EClassifier (org.eclipse.emf.ecore.EClassifier)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 IChangeSerializer (org.eclipse.xtext.ide.serializer.IChangeSerializer)1 IEmfResourceChange (org.eclipse.xtext.ide.serializer.IEmfResourceChange)1 ChangeSerializer (org.eclipse.xtext.ide.serializer.impl.ChangeSerializer)1 EClassRef (org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.EClassRef)1 InMemoryURIHandler (org.eclipse.xtext.testing.util.InMemoryURIHandler)1 Test (org.junit.Test)1