use of org.eclipse.xtext.generator.trace.TraceRegionSerializer in project xtext-core by eclipse.
the class JavaIoFileSystemAccessTest method testTraceIsCreated.
@Test
public void testTraceIsCreated() throws Exception {
File file = null;
try {
JavaIoFileSystemAccess fileSystemAccess = new JavaIoFileSystemAccess(IResourceServiceProvider.Registry.INSTANCE, new IEncodingProvider.Runtime(), new TraceFileNameProvider(), new TraceRegionSerializer());
File tmpDir = configureFileSystemAccess(fileSystemAccess);
SourceRelativeURI uri = new SourceRelativeURI(URI.createURI("foo/bar"));
CharSequenceTraceWrapper wrapper = new CharSequenceTraceWrapper();
fileSystemAccess.generateFile("tmp/X", wrapper.wrapWithTraceData("XX", uri, 0, 10, 0, 1));
file = new File(tmpDir, "tmp/X");
assertTrue(file.exists());
assertTrue(file.isFile());
assertEquals("XX", fileSystemAccess.readTextFile("tmp/X"));
file = new File(tmpDir, "tmp/.X._trace");
assertTrue(file.exists());
assertTrue(file.isFile());
} finally {
if (file != null)
file.delete();
}
}
use of org.eclipse.xtext.generator.trace.TraceRegionSerializer in project xtext-eclipse by eclipse.
the class TraceResourceFactory method createResource.
@Override
public Resource createResource(URI uri) {
Resource result = new ResourceImpl(uri) {
@Override
protected void doLoad(InputStream inputStream, Map<?, ?> options) throws IOException {
TraceRegionSerializer serializer = new TraceRegionSerializer();
DebugTraceRegion result = serializer.doReadFrom(inputStream, new Strategy());
getContents().add(result);
}
@Override
protected void doSave(OutputStream outputStream, Map<?, ?> options) throws IOException {
TraceRegionSerializer serializer = new TraceRegionSerializer();
serializer.doWriteTo(new Strategy(), (DebugTraceRegion) getContents().get(0), outputStream);
}
};
return result;
}
Aggregations