|
|
|
|
|
Re: Embedding Comments in Custom DSL Files [message #1867179 is a reply to message #1867134] |
Tue, 18 June 2024 15:16 |
Alex Oli Messages: 19 Registered: May 2024 |
Junior Member |
|
|
So I followed the blog explanation and it generated the wizard package in the UI project of my language, but when i created a new file in runtime it didn't generate the content in .xtend class.
This is mwe2 file
language = StandardLanguage {
name = "org.xtext.example.cicd.CICD"
fileExtensions = "cicd"
referencedResource = "platform:/resource/CICD_metamodel/model/cICD_metamodel.genmodel"
fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment2 auto-inject {}
formatter = {
generateStub = true
generateXtendStub = true
}
serializer = {
generateStub = false
}
validator = {
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
// Generates checks for @Deprecated grammar annotations, an IssueProvider and a corresponding PropertyPage
generateDeprecationValidation = true
}
generator = {
generateXtendStub = true
}
junitSupport = {
junitVersion = "5"
}
fileWizard = {
generate = true
}
}
and this is the xtend class automatically generated when invoking Run As -> MWE2 Workflow
/*
* generated by Xtext 2.34.0
*/
package org.xtext.example.cicd.ui.wizard
import org.eclipse.xtext.ui.wizard.template.FileTemplate
import org.eclipse.xtext.ui.wizard.template.IFileGenerator
import org.eclipse.xtext.ui.wizard.template.IFileTemplateProvider
/**
* Create a list with all file templates to be shown in the template new file wizard.
*
* Each template is able to generate one or more files.
*/
class CICDFileTemplateProvider implements IFileTemplateProvider {
override getFileTemplates() {
#[new HelloWorldFile]
}
}
@FileTemplate(label="Hello World", icon="file_template.png", description="Create a hello world for CICD.")
final class HelloWorldFile {
val helloName = combo("Hello Name:", #["Xtext", "World", "Foo", "Bar"], "The name to say 'Hello' to")
override generateFiles(IFileGenerator generator) {
generator.generate('''«folder»/«name».cicd''', '''
/*
* This is an example model
*/
Hello «helloName»!
''')
}
}
|
|
|
|
Powered by
FUDForum. Page generated in 0.25291 seconds