Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » JvmTypeReference to new Type being created.
JvmTypeReference to new Type being created. [message #1681424] Tue, 17 March 2015 09:57 Go to next message
Ma DeWael is currently offline Ma DeWaelFriend
Messages: 6
Registered: March 2015
Junior Member
Dear All

In my grammar I use JvmTypeReference to refer to the types defined in my plain Java program.

My language allows to define an entity which compiles down to a plain old Java class. When the program in my language contains a (small) error, because I'm still programming, the generated java-class-file is removed from the src-gen director, and subsequently if I correct my program, the reference to my newly created type can not be resolved.

class Matrix combines A, B, C { // <- this compiles to a .java file with:class Matrix { .... }

...
Matrix m = new Matrix(); // <- this JvmTypeReference only resolves if the compilation has succeeded.
...
}


How should I change my project to be able to always refer at to types being created?
Re: JvmTypeReference to new Type being created. [message #1681462 is a reply to message #1681424] Tue, 17 March 2015 10:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
HI,

do you use JvmModelInferrer? how does it look like?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: JvmTypeReference to new Type being created. [message #1689728 is a reply to message #1681462] Tue, 24 March 2015 07:45 Go to previous messageGo to next message
Ma DeWael is currently offline Ma DeWaelFriend
Messages: 6
Registered: March 2015
Junior Member
No,
I use
class MyDslGenerator implements IGenerator
because I need Java as a base language instead of XBase-expressions.

def generate(Domainmodel dm, IFileSystemAccess fsa){
		val jit = dm.jitclass
		var name = ""
		if(dm.package != null) name = '''«dm.package.name».«jit.fullyQualifiedName»'''
		else name = '''«jit.fullyQualifiedName»'''
		
		fsa.generateFile(name.replaceAll("\\.","/") + ".java",'''
			«IF dm.package != null»
			package «dm.package.name»;
			«ENDIF»
			public class «jit.name» { ... }


The problem is, every time I mistype something in my .mydsl file (eg. parser problem) the generated .java file is removed, making my .mydsl file un-processable even after correcting the mistakes,
because the generated .java contained a type which I need to reference in .mydsl.

Eg.
Matrix.mydsl compiles to Matrix.java with a Matrix-class defined, which allows me to refer to Matrix in Matrix.mydsl .... if Matrix.java exists.
Re: JvmTypeReference to new Type being created. [message #1689813 is a reply to message #1689728] Tue, 24 March 2015 11:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
The way to go is to use tje jvmmodelinferrer

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: JvmTypeReference to new Type being created. [message #1689951 is a reply to message #1689813] Tue, 24 March 2015 18:01 Go to previous messageGo to next message
Ma DeWael is currently offline Ma DeWaelFriend
Messages: 6
Registered: March 2015
Junior Member
but the JvmModelInferrer does not allow me to define aspects (aspectJ) and only accepts XBlockExpression as method bodies, whereas I want to have "normal" Java.
Re: JvmTypeReference to new Type being created. [message #1689954 is a reply to message #1689951] Tue, 24 March 2015 18:08 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Body = '''yourcodegoeshere''' should work as well

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Maven "exec-maven-plugin" --> Could not load class: org.eclipse.core.runtime.OperationC
Next Topic:Oomph setup broken?
Goto Forum:
  


Current Time: Thu Apr 25 20:56:22 GMT 2024

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

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

Back to the top