|
|
|
|
|
|
|
Re: How to Integrate Xtext into other projects [message #1772117 is a reply to message #1772057] |
Tue, 05 September 2017 17:03 |
Robert Klinger Messages: 10 Registered: July 2017 |
Junior Member |
|
|
The file extension should be correct.
I am not exporting anything manually yet. Should I?
I am not sure If I really understood on how to import the language the right way.
I ve used Properties - Java Build Path and added under project the org.xtext.toolLanguage and under libraries the 5 .jars mentioned in the other post. Am I missing something?
The platform resource: I am working in one Eclipse workspace with the Xtext-Project and another Java-Project. Should this work or am I missing here something? :)
___________________________________________________
I have another question though and don´t want to make a new topic out of it: Is the xtext-File written Xtext? So is there a grammar for the file extension "xtext" and if so, is it public?
___________________________________________________
EDIT: I somehow fixed it, I am not sure how, but it works. Maybe the file could not get parsed properly with the grammar, I am not sure though. Sadly I was not really able to understand the exceptions I got :)
The code now:
//imports
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.xtext.ToolLanguageStandaloneSetup;
import org.xtext.toolLanguage.Model;
import org.xtext.toolLanguage.ToolLanguagePackage;
//these would be the imports for the default dsl
//import org.xtext.example.mydsl.MyDslStandaloneSetup;
//import org.xtext.example.mydsl.myDsl.Model;
//import org.xtext.toolLanguage.Model;
import com.google.inject.Injector;
//main-Code
Injector injector = new ToolLanguageStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
Resource resource = resourceSet.getResource(URI.createFileURI("./example.toolLanguage"), true);
Model model = (Model) resource.getContents().get(0);
System.out.println(model.getRules());
I manually added under properties - Java Build Path:
Projects: The xtext Project needed
Libraries:
com.google.inject_3.0.0...
org.eclipse.emf.common_2.12.0...
org.eclipse.emf.ecore_2.12.0...
org.eclipse.xtext_2.11.0...
You should find some of these jars referenced in the Xtext-Project too :)
Though you might want to consider using some build-tool or something :D
___________________________________
Again thank you very much for your help, specially thank you Christian Dietrich, you helped me a lot so far :)
[Updated on: Tue, 05 September 2017 17:30] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05025 seconds