use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-core by eclipse.
the class ChangeSerializerWithEmfTest method testChangeInDSL.
@Test
public void testChangeInDSL() {
final InMemoryURIHandler fs = new InMemoryURIHandler();
StringConcatenation _builder = new StringConcatenation();
_builder.append("#20 DslEClass");
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=\"inmemory:/file1.pstl#//@clazz.0\"/>");
_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 Model model = this._changeSerializerTestHelper.<Model>contents(rs, "inmemory:/file1.pstl", Model.class);
final ChangeSerializer serializer = this.serializerProvider.get();
final IChangeSerializer.IModification<Resource> _function = (Resource it) -> {
EClass _get = model.getClazz().get(0);
_get.setName("ChangedName");
EList<EClass> _clazz = model.getClazz();
EClass _createEClass = EcoreFactory.eINSTANCE.createEClass();
final Procedure1<EClass> _function_1 = (EClass it_1) -> {
it_1.setName("NewName");
};
EClass _doubleArrow = ObjectExtensions.<EClass>operator_doubleArrow(_createEClass, _function_1);
_clazz.add(0, _doubleArrow);
Assert.assertEquals(1, model.eResource().getResourceSet().getResources().size());
};
serializer.<Resource>addModification(model.eResource(), _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("#20 <4:0|NewName ><4:9| ChangedName>");
_builder_2.newLine();
_builder_2.append("--------------------------------------------------------------------------------");
_builder_2.newLine();
_builder_2.append("4 0 \"\" -> \"NewName \"");
_builder_2.newLine();
_builder_2.append("4 9 \"DslEClass\" -> \" ChangedName\"");
_builder_2.newLine();
_builder_2.append("---------------------------- inmemory:/file2.ecore -----------------------------");
_builder_2.newLine();
_builder_2.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
_builder_2.newLine();
_builder_2.append("<ecore:EPackage xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
_builder_2.newLine();
_builder_2.append(" ");
_builder_2.append("xmlns:ecore=\"http://www.eclipse.org/emf/2002/Ecore\" name=\"MyPackage\">");
_builder_2.newLine();
_builder_2.append(" ");
_builder_2.append("<eClassifiers xsi:type=\"ecore:EClass\" name=\"MyClass1\" eSuperTypes=\"file1.pstl#//@clazz.1\"/>");
_builder_2.newLine();
_builder_2.append("</ecore:EPackage>");
_builder_2.newLine();
_builder_2.append("--------------------------------------------------------------------------------");
_builder_2.newLine();
this._changeSerializerTestHelper.operator_tripleEquals(_endRecordChangesToTextDocuments, _builder_2);
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-core by eclipse.
the class ChangeSerializerWithImports method testRenameGlobal1.
@Test
public void testRenameGlobal1() {
final InMemoryURIHandler fs = new InMemoryURIHandler();
StringConcatenation _builder = new StringConcatenation();
_builder.append("#1 root1 { child1; }");
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("#1 import root1.child1 refs child1;");
Pair<String, String> _mappedTo_1 = Pair.<String, String>of("inmemory:/file2.pstl", _builder_1.toString());
this._changeSerializerTestHelper.operator_add(fs, _mappedTo_1);
final ResourceSet rs = this._changeSerializerTestHelper.createResourceSet(fs);
final Node model = this._changeSerializerTestHelper.<Node>contents(rs, "inmemory:/file1.pstl", Node.class);
final ChangeSerializer serializer = this.serializerProvider.get();
final IChangeSerializer.IModification<Resource> _function = (Resource it) -> {
Node _get = model.getChildren().get(0);
_get.setName("newchild");
Assert.assertEquals(1, model.eResource().getResourceSet().getResources().size());
};
serializer.<Resource>addModification(model.eResource(), _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("#1 root1 { <11:6|newchild>; }");
_builder_2.newLine();
_builder_2.append("--------------------------------------------------------------------------------");
_builder_2.newLine();
_builder_2.append("11 6 \"child1\" -> \"newchild\"");
_builder_2.newLine();
_builder_2.append("----------------- inmemory:/file2.pstl (syntax: <offset|text>) -----------------");
_builder_2.newLine();
_builder_2.append("#1 import <10:12|root1.newchild> refs <28:6|newchild>;");
_builder_2.newLine();
_builder_2.append("--------------------------------------------------------------------------------");
_builder_2.newLine();
_builder_2.append("10 12 \"root1.child1\" -> \"root1.newchild\"");
_builder_2.newLine();
_builder_2.append("28 6 \"child1\" -> \"newchild\"");
_builder_2.newLine();
this._changeSerializerTestHelper.operator_tripleEquals(_endRecordChangesToTextDocuments, _builder_2);
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-core by eclipse.
the class ConcurrentAccessTest method testMultiThreadedSynchronized.
@Test
public void testMultiThreadedSynchronized() throws InterruptedException {
ResourceSet resourceSet = new SynchronizedXtextResourceSet();
resourceSet.getResources().add(resource);
boolean wasOk = resolveAllReferencesMultithreaded((EPackage) resource.getContents().get(0));
assertEquals(101, resourceSet.getResources().size());
assertTrue("unresolvedProxy", wasOk);
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-core by eclipse.
the class ConcurrentAccessTest method testMultiThreadedSynchronizedUnitOfWork.
@Test
public void testMultiThreadedSynchronizedUnitOfWork() throws InterruptedException {
ResourceSet resourceSet = new SynchronizedXtextResourceSet();
resourceSet.getResources().add(resource);
boolean wasOk = resolveAllReferencesStateAccess((EPackage) resource.getContents().get(0));
assertEquals(101, resourceSet.getResources().size());
assertTrue("unresolvedProxy or concurrent modification or no such element", wasOk);
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-core by eclipse.
the class ConcurrentAccessTest method testResolveSingleThreaded.
@Test
public void testResolveSingleThreaded() {
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResources().add(resource);
assertEquals(1, resourceSet.getResources().size());
EPackage pack = (EPackage) resource.getContents().get(0);
doResolveAllReferences(pack);
assertEquals(101, resourceSet.getResources().size());
}
Aggregations