Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Suppress 'default' modifier on interface method?(Need help to tailor inferrer to supporess 'default' on generated java Interface)
Suppress 'default' modifier on interface method? [message #1809194] Thu, 11 July 2019 08:52 Go to next message
Paul Bandler is currently offline Paul BandlerFriend
Messages: 2
Registered: July 2019
Junior Member
I'm quite new to XText, having just breathed life into my first XText/XBase generator. I'm attempting to generate a Java interface, and it _nearly_ works - great! However it's generating all methods with the 'default' modifier, despite attempting to suppress this by setting the 'default' property to false in the inferrer. I'm doing something like (code annonymised )

acceptor.accept(someType.toInterface("my.package." + someType.name, [])) [
//...
val type = typeRef(String)
val propertyName = "somePropertyName"
val getter = someType.toGetter(propertyName, type)
getter.removeExistingBody()
val setter = someType.toSetter(propertyName, type)
setter.removeExistingBody()
getter.^default = false
setter.^default = false
members += getter
members += setter
System.err.println("members: " + members)
]
]

It appears to set the default property successfully:

members: [JvmOperation: my.package.SomeType.getSomePropertyName() (visibility: PUBLIC, simpleName: getSomePropertyName, identifier: my.package.SomeType.getSomePropertyName(), deprecated: <unset>) (varArgs: false) (static: false, final: false, abstract: false, synchronized: false, default: false, native: false, strictFloatingPoint: false),...

Yet the generated code results in a method with the default modifier:
public default String getSomeProperty();

Can anyone suggest what I'm doing wrong? Thanks in advance for any assistance.
Re: Suppress 'default' modifier on interface method? [message #1809263 is a reply to message #1809194] Fri, 12 July 2019 15:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13071
Registered: July 2009
Senior Member
you should debug JvmModelGenerator to see what is happening

		if (!isAbstract && !isStatic && config.getJavaSourceVersion.isAtLeast(JAVA8)
				&& eContainer instanceof JvmGenericType && (eContainer as JvmGenericType).isInterface)
			appendable.append("default ")


=> i assume the abstract is the problem in your case


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Suppress 'default' modifier on interface method? [message #1809366 is a reply to message #1809263] Mon, 15 July 2019 06:13 Go to previous message
Paul Bandler is currently offline Paul BandlerFriend
Messages: 2
Registered: July 2019
Junior Member
Thank you for the diagnosis and pointer to how to investigate such issues in future.
Previous Topic:Xtext grammar autocompletion
Next Topic:Package URI is not properly generating
Goto Forum:
  


Current Time: Sat Aug 24 07:35:46 GMT 2019

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

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

Back to the top