2017-01-06 1 views
0

Я переводил один dsl (A) в другой dsl (B) create в xtext.Создание файла доступа во время генерации автокодирования xtext

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

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') файл не может быть найден.

Как получить доступ к файлу 'transform.wp'.

Идея состоит в том, чтобы скопировать часть модели ЭДС модели А в модель Б после создания кода.

ответ

0

Раствор был в 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; 
Смежные вопросы