Kunal Khaware's Profile

GitHub User: nandkunal

Site: kunalkhaware.com

Comments by Kunal Khaware

Avatar

Below is the MWE code I am using:

module org.xtext.example.mydsl.GenerateMyDsl

import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.generator.*
import org.eclipse.xtext.ui.generator.*

var grammarURI = "classpath:/org/xtext/example/mydsl/MyDsl.xtext"
var file.extensions = "mydsl"
var projectName = "org.xtext.example.mydsl"
var runtimeProject = "../${projectName}"

Workflow {
    bean = StandaloneSetup {
        scanClassPath = true
        platformUri = "${runtimeProject}/.."
    }

    component = DirectoryCleaner {
        directory = "${runtimeProject}/src-gen"
    }

    component = DirectoryCleaner {
        directory = "${runtimeProject}.ui/src-gen"
    }

  component = org.eclipse.xtext.generator.GeneratorComponent {
    outlet = { // Custom output configuration
    path = "read-src"
    outletName = "XML-FILES"
  }
}

  component = Generator {
        pathRtProject = runtimeProject
        pathUiProject = "${runtimeProject}.ui"
        pathTestProject = "${runtimeProject}.tests"
        projectNameRt = projectName
        projectNameUi = "${projectName}.ui"
        language = {
            uri = grammarURI
            fileExtensions = file.extensions

            // Java API to access grammar elements (required by several other fragments)
            fragment = grammarAccess.GrammarAccessFragment {}

            // generates Java API for the generated EPackages
            fragment = ecore.EcoreGeneratorFragment {
            // referencedGenModels = "
            //  platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel,
            //  platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel
            // "
            }

            // Serializer 2.0
            fragment = serializer.SerializerFragment {}
            
            // the serialization component (1.0)
            // fragment = parseTreeConstructor.ParseTreeConstructorFragment {}

            // a custom ResourceFactory for use with EMF
            fragment = resourceFactory.ResourceFactoryFragment {
                fileExtensions = file.extensions
            }

            // The antlr parser generator fragment.
            fragment = parser.antlr.XtextAntlrGeneratorFragment {
            //  options = {
            //      backtrack = true
            //  }
            }

            // java-based API for validation
            fragment = validation.JavaValidatorFragment {
                composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
                composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
            }

            // scoping and exporting API
            // fragment = scoping.ImportURIScopingFragment {}
            // fragment = exporting.SimpleNamesFragment {}

            // scoping and exporting API
            fragment = scoping.ImportNamespacesScopingFragment {}
            fragment = exporting.QualifiedNamesFragment {}
            fragment = builder.BuilderIntegrationFragment {}

            // generator API
            fragment = generator.GeneratorFragment {
                generateMwe = true
                generateJavaMain = true
            }

            // formatter API
            fragment = formatting.FormatterFragment {}

            // labeling API
            fragment = labeling.LabelProviderFragment {}

            // outline API
            fragment = outline.OutlineTreeProviderFragment {}
            fragment = outline.QuickOutlineFragment {}

            // quickfix API
            fragment = quickfix.QuickfixProviderFragment {}

            // content assist API
            fragment = contentAssist.JavaBasedContentAssistFragment {}

            // generates a more lightweight Antlr parser and lexer tailored for content assist
            fragment = parser.antlr.XtextAntlrUiGeneratorFragment {}

            // generates junit test support classes into Generator#pathTestProject
            fragment = junit.Junit4Fragment {}

            // project wizard (optional)
            // fragment = projectWizard.SimpleProjectWizardFragment {
            //      generatorProjectName = "${projectName}"
            //      modelFileExtension = file.extensions
            // }

            // provides the necessary bindings for java types integration
            fragment = types.TypesGeneratorFragment {}

            // generates the required bindings only if the grammar inherits from Xbase
            fragment = xbase.XbaseGeneratorFragment {}

            // provides a preference page for template proposals
            fragment = templates.CodetemplatesGeneratorFragment {}

            // rename refactoring
            fragment = refactoring.RefactorElementNameFragment {}

            // provides a compare view
            fragment = compare.CompareFragment {
                 fileExtensions = file.extensions
            }

        }
    }
}
Avatar

Hi Boris,

Thanks for the reply, I am new to xtext and when I added above block I got below Runtime Exception :

0 [main] INFO lipse.emf.mwe.utils.StandaloneSetup - Registering platform uri 'C:\xtext-eclipse-3.7'
1218 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher - Problems running workflow org.xtext.example.mydsl.GenerateMyDsl: no 'slot' has been configured.
java.lang.RuntimeException: Problems running workflow org.xtext.example.mydsl.GenerateMyDsl: no 'slot' has been configured.

Appreciate your help

Cheers

Avatar

I am using Xtext version 2.0.1. If I try to upgrade the version, I am getting compatibility error.

Avatar

Hi, OutputConfigurationProviderClass is not being generated in Eclipse version 3.7 . Any idea to get this class in this version.
Thanks