Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Using the DSL and MWE in a non Java Project
Using the DSL and MWE in a non Java Project [message #730439] Wed, 28 September 2011 12:18 Go to next message
Daniel Missing name is currently offline Daniel Missing nameFriend
Messages: 101
Registered: July 2011
Senior Member
Hi Developers.

My DSL Model files will be added to a C/C++ project in Eclipse. No problem so far: Eclipse asks for the Xtext nature and everything works fine.

But when I added the MWE2 files for my compiler the problem starts: The MWE2 DSL file tries to resolve references to java classes which are (of course) not referenced to the project.

My compliler will be placed in a tools directory which contains the all-in-one Jars and also contains an ant-script for triggering the compilation.

Is there a way I can setup a "mwe-buildpath" since no "java-buildpath" is available on C/C++ projects? I even can't simply use another file extension to prevent project errors because Xtext recognizes resources according to their file extension.

Any ideas how to fix this problem?

Cheers
Daniel
Re: Using the DSL and MWE in a non Java Project [message #730477 is a reply to message #730439] Wed, 28 September 2011 13:29 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7670
Registered: July 2009
Senior Member
Hi Daniel

A C/C++ project is a project with the C/C++ nature; it can also have the
Java nature.

Edit the .project file to cut and paste the Java nature (probably don't
need the buildCommand) from a Java project. Then make sure that the
..classpath defines the appropriate src folder. Sometimes it is necessary
to have a dummy Java file to silence some warnings.

Regards

Ed Willink

On 28/09/2011 13:19, Daniel wrote:
> Hi Developers.
> My DSL Model files will be added to a C/C++ project in Eclipse. No
> problem so far: Eclipse asks for the Xtext nature and everything works
> fine.
> But when I added the MWE2 files for my compiler the problem starts:
> The MWE2 DSL file tries to resolve references to java classes which
> are (of course) not referenced to the project.
> My compliler will be placed in a tools directory which contains the
> all-in-one Jars and also contains an ant-script for triggering the
> compilation.
> Is there a way I can setup a "mwe-buildpath" since no "java-buildpath"
> is available on C/C++ projects? I even can't simply use another file
> extension to prevent project errors because Xtext recognizes resources
> according to their file extension.
> Any ideas how to fix this problem?
>
> Cheers
> Daniel
Re: Using the DSL and MWE in a non Java Project [message #730481 is a reply to message #730477] Wed, 28 September 2011 13:57 Go to previous messageGo to next message
Daniel Missing name is currently offline Daniel Missing nameFriend
Messages: 101
Registered: July 2011
Senior Member
It's quite a bad practice to make a C/C++ Project also a Java Project if there are no real Java Elements within the project. I don't think the developers of the C/C++ department will like the idea of adding Java stuff to their system projects.

It definitly should be possible to have mwe2 files within a project without the need of Java.
Re: Using the DSL and MWE in a non Java Project [message #730486 is a reply to message #730481] Wed, 28 September 2011 14:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi,

why do you want to use mwe2 at all if you want to hide this from the user? why don't you write an action/command+handler

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Using the DSL and MWE in a non Java Project [message #730494 is a reply to message #730486] Wed, 28 September 2011 14:17 Go to previous messageGo to next message
Daniel Missing name is currently offline Daniel Missing nameFriend
Messages: 101
Registered: July 2011
Senior Member
My compiler is a MWE2 workflow component. For the C/C++ developers I want to provide a standalone compiler package which they can place into their tools folder and run it from there using ANT (that's the way the want it). If you open the MWE2 files or any file of my DSL the xtext-natures get added to the project and there the error starts: the classes in the MWE2 files (compiler descriptors) are not found.

The compiler package also runs on the build server where no eclipse instance is running. Therefore the compiler package includes all required Jars within it.

My compiler should be a simple standalone commandline/ant tool for the C/C++ developers. They don't want to mess around with Java Specific stuff.
Re: Using the DSL and MWE in a non Java Project [message #730497 is a reply to message #730494] Wed, 28 September 2011 14:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi,

why do you load the mwe2 file from the project and dont bundle it with the jars?
otherwise i dont know any way to work arround this besides turning the porject into to a java project as Ed suggested.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Using the DSL and MWE in a non Java Project [message #730522 is a reply to message #730497] Wed, 28 September 2011 14:45 Go to previous messageGo to next message
Daniel Missing name is currently offline Daniel Missing nameFriend
Messages: 101
Registered: July 2011
Senior Member
The MWE2 file is quite dynamic and compiler independent. The compiler contains multiple targets like Java and C. You use the MWE2 file to specify which template needs to get loaded, where to find the model files and where to put the output files (+ some general and target specific settings). For my DSL the MWE2 are some kind of build-files which tell the compiler framework what to do.

I don't really need the option to have IDE support for MWE2 files, but xtext automatically adds the required nature for MWE2 files. I still like the idea of a MWE2 specific Build-Path for non Java Projects for the future.

To prevent errors I registered the MWE2 IResourceFactory and IResourceServiceProvider to a custom "mydslbuild" file extension. This way I can prevent errors within the C/C++ project.

Currently everything in Xtext is strictly bound to the Eclipse environment. My standalone compiler needs about 70 dependency jars. For the future of Xtext I hope it will become easier to create standalone products with less dependencies. The best scenario is: Integrating the DSL into a build server is a painful task because of all the dependencies to maintain.
Re: Using the DSL and MWE in a non Java Project [message #730586 is a reply to message #730497] Wed, 28 September 2011 16:15 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7670
Registered: July 2009
Senior Member
Hi

Perhaps you want to take the approach I took with
org.eclipse.ocl.examples.build which contains the MWE scripts for 5
Xtext editors for which I wanted to avoid unnecessary builder
dependencies. Getting the classpath right is a bit exciting but it works.

Regards

Ed Willink



On 28/09/2011 15:21, Christian Dietrich wrote:
> Hi,
>
> why do you load the mwe2 file from the project and dont bundle it with
> the jars?
> otherwise i dont know any way to work arround this besides turning the
> porject into to a java project as Ed suggested.
>
> ~Christian
Re: Using the DSL and MWE in a non Java Project [message #730784 is a reply to message #730586] Thu, 29 September 2011 07:28 Go to previous messageGo to next message
Daniel Missing name is currently offline Daniel Missing nameFriend
Messages: 101
Registered: July 2011
Senior Member
Good morning.

I don't think this approach works for me. It would end up in an additional compiler project again instead of having the project lying in a tools-subfolder of the C/C++ project. I also don't want to edit any .classpath or .project files manually to prevent check of mwe2 because it's too dangerous that any plugin updates will mess up the files and add some stuff again. And I refuse the task to add a Java nature to the C/C++ projects because I'm only using a standalone java program placed in a tools folder.


The approach I want to achieve is quite simple: I want to provide an eclipse plugin to edit my DSL. Additionally a copy of the runtime project including all dependencies is placed within a tools folder. And last but not least: place MWE2 files + ant script beside the compiler to trigger the standalone compiler jar.

But the last point simply causes project errors as the Java depencencies cannot be resolved. This is caused by the JVM bindings of the language. A simple flag within the project settings would help too: "disable JVM type inference in MWE2 files". Okay that would cut off some really cool features but that would still be better than errors.

Or another solution could be the way Visual Studio handles it: If you have a C# project opened, place a C++ file within it and open it, the file only gets syntactically validated no semantic checks are applied. You could do that in your JVM inferrence too: If the MWE2 file containing project has the Java Nature a JVM inferrence is done and you get the full featured IDE support. But if you open in a project without the Java Nature you disable the JVM inferrence and only provide the non-java stuff (keyword completion, syntax highlighting, syntactic checks, outline, ...).

Cheers
Daniel


Re: Using the DSL and MWE in a non Java Project [message #731898 is a reply to message #730784] Mon, 03 October 2011 12:38 Go to previous messageGo to next message
Daniel Missing name is currently offline Daniel Missing nameFriend
Messages: 101
Registered: July 2011
Senior Member
Hi again.

One more question: What is the default behavior for searching for DSL files within a project? If I make references between files the references can not be resolved by the linker. Is the default behavior that xtext searches for model files within the java build path? This would explain that references between model files cannot be done.

Is it possible to make xtext search in all or specific directories for models? That would be similar to the behavior I expected for MWE2 files. I want to specify my own "model class path" because I'm not working with a Java Project.

Greetings
Daniel
Re: Using the DSL and MWE in a non Java Project [message #731902 is a reply to message #731898] Mon, 03 October 2011 12:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi,

this depends on your language setup and if you are using runtime or ui.

At runtime (standalone) it is all resources in the resourceset (all files you give the reader as input) (in the mwe file guess you can configue the classpath to be used too by setting UseJavaClassPath=true)

In UI it is default the project and the references projects and if java project the classpath is used too.

read the docs on Containers/ContainerState http://www.eclipse.org/Xtext/documentation/2_0_0/080-scoping.php#global_scopes

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 03 October 2011 12:52]

Report message to a moderator

Re: Using the DSL and MWE in a non Java Project [message #731906 is a reply to message #731902] Mon, 03 October 2011 12:56 Go to previous messageGo to next message
Daniel Missing name is currently offline Daniel Missing nameFriend
Messages: 101
Registered: July 2011
Senior Member
Thanks to this fast answer. I just was reading this section of the documentation. But I don't understand all aspects yet. For my standalone setup everything works fine but I have problems within my Eclipse environment.

The easiest way would be to create my own IAllContainersState implementation. To keep the stuff simple I want to achive this behavior: If the Java Nature is available use the Java Classpath, otherwise look for model files in all files of the current project.

As the lookup isn't relative to a model file this would be the easiest way (otherwise I'd preffer to look for model files in the same directory).

Is there already an implementation which searches for all files within a project I could adapt for my needs?

- Daniel
Re: Using the DSL and MWE in a non Java Project [message #731907 is a reply to message #731906] Mon, 03 October 2011 13:00 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi,

as i said before: this is done by default.
org.eclipse.xtext.ui.containers.JavaProjectsState /
org.eclipse.xtext.ui.containers.WorkspaceProjectsState does this,
but it includes additionally references projects.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 03 October 2011 13:10]

Report message to a moderator

Previous Topic:Problem with datatype rule - mismatched input
Next Topic:backtracking problem while generate grammar
Goto Forum:
  


Current Time: Thu Sep 26 03:15:05 GMT 2024

Powered by FUDForum. Page generated in 0.05104 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top