Файл доступа создается во время автоматической генерации кода xtext

Перевожу одну dsl(A) на другую dsl(B) создаю в xtext.

Генерация кода A выглядит так

override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {
    fsa.generateFile('transformed.wp', resource.allContents.filter(typeof(ActionSystem)).map [
        compile
    ].join(', '))

    val rs = new ResourceSetImpl();
    val r = rs.getResource(URI.createPlatformResourceURI('transformed.wp'), true);
    val List<EObject> contentOfYourFile = r.getContents();
    }

ошибка тогда я вызываю URI.createPlatformResourceURI('transformed.wp') файл не может быть найден.

Как мне получить доступ к файлу «transformed.wp».

Идея будет заключаться в том, чтобы скопировать часть модели ЭДС A в модель B после того, как код был сгенерирован.


person Johan    schedule 06.01.2017    source источник


Ответы (1)


Решение было в IFileSystemAccess2

//create the file name
var fileuri = fsa.getURI('transformed.wp');
//get the name of the resource
var resource_name = fileuri.toString();
//get eh name of the resource
var file = fileuri.lastSegment;
person Johan    schedule 09.01.2017