Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8193711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:34:35+00:00 2026-06-07T04:34:35+00:00

I have implemented a simple little DSL that generates classes from input files, by

  • 0

I have implemented a simple little DSL that generates classes from input files, by using the JvmModelInferrer approach. I am trying to figure out how I can invoke the parser and the code genarator within the code of a regular java project. So at some point in the main class of my non-Xtext project I can just create a file, pass it to the Xtext parser/codeGenerator for my DSL, and the result will be that class files are generated to a folder of my choice (within my java project).
This case is not covered in the documentation, so any help would be much appreciated, Thanks!

UPDATE: My code so far looks like this:

    private  static IGenerator generator;

    /**
     * @param args
     */
    public static void main(String[] args) {

        // this line registers the EMF for our DSL
        Injector injector = new HyRuleStandaloneSetup().createInjectorAndDoEMFRegistration();
        ResourceSet rs = new ResourceSetImpl();
        File file = new File(
                "C:/Documents and Settings/chmamat2/runtime-EclipseXtext/hyrule.project/src/hyrule/project/main.hrule");
        Resource resource = rs.getResource(URI.createURI(file.toURI().toString()), true);

        //setup the generator
        generator = injector.getInstance(IGenerator.class);

        //setup the file system access
        final EclipseResourceFileSystemAccess2 fsa = new EclipseResourceFileSystemAccess2();


        generator.doGenerate(resource, fsa);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:34:37+00:00Added an answer on June 7, 2026 at 4:34 am

    Basically, you can open your DSL as an EMF model: you create an EMF ResourceSet, then use the ResourceSet API to open your file (by creating either a file or platform uri representing the file), and open its contents.

    However, this only works if you do not use Xbase. If you use Xbase, you have to use the Guice injector the Xtext API provides to instantiate the ResourceSet. If the ResourceSet is initialized, it works the same way as before.

    To use the injector, either instantiate it using the StandaloneSetup class – do not do this, if you plan to use the code in the Eclipse IDE together with your own editor, or by registering an eclipse extension with an Xtext-based execution factory. For example on this see the registered editor in my Xtext Reflective Tree editor project.

    To also call the code generator, you have several possibilities:

    1. You can use an Eclipse project with the Xtext project nature. If it is set up, you simply create/modify your DSL file, and the builder magically finishes everything I mentioned before – nothing to do anymore.
    2. You can also inject the IGenerator in your code (when having an injected class), so you can programmatically call it after opening the original EMF-based Xtext model.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the simple class using auto-implemented properies: Public Class foo { public foo()
I have a little proof-of-concept distributed transaction application that is doing a simple insert
I have a relatively simple DSL that I would like to handle more robustly
I have implemented a simple linux shell in c. Now, I am adding some
I have implemented a simple RSS reader in Java. I hit a URL and
I am creating a simple messaging system in WCF and have implemented a minimal
Very simple Qt GUI application: On the scene I have multiple circles implemented as
I have a partial view (UserControl) that implements a simple pager in my Asp.Net
I have the following class (from a simple Spring tutorial) public class CarValidator implements
I have implemented a very simple method: private String getProfileName(String path) { String testPath

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.