Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Validating JvmType imports
Validating JvmType imports [message #836406] Wed, 04 April 2012 12:56 Go to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
Karsten Thoms posted some code to validate Java imports in a DSL: https://kthoms.wordpress.com/2012/04/03/jvmtype-import-check/

But the code has one problem: org.eclipse.xtext.common.types.access.IJvmTypeProvider is not a public API (access is "discouraged" (?) in the access rules of the plug-in org.eclipse.xtext.common.types 2.2.1)

Since this is an extremely useful example: Is the code in the blog post wrong or should I file enhancement request to make this API public?

Re: Validating JvmType imports [message #836410 is a reply to message #836406] Wed, 04 April 2012 13:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13493
Registered: July 2009
Senior Member
Hi,

it is "not public api" cause the Xtext guys want to be able to change it. changing public api is hard in eclipse => it is not public api.
=> if you can live with having to change your stuff with a new Xtext version.
don't care about the warning.

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Validating JvmType imports [message #838021 is a reply to message #836410] Fri, 06 April 2012 12:55 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 734
Registered: July 2009
Location: Dortmund, Germany
Senior Member

You can add
@SuppressWarnings("restriction")
to your class.


Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: Validating JvmType imports [message #840798 is a reply to message #838021] Tue, 10 April 2012 14:21 Go to previous messageGo to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
Karsten Thoms wrote on Fri, 06 April 2012 14:55
You can add
@SuppressWarnings("restriction")
to your class.


Well, yes but I was rised to pay heed to warnings Wink

My main complaint is that I must add the annotation to the class (because I also get warnings for the imports), so the scope of the annotation to too broad for my liking.

Okay, I can work around this by not using imports but FQ names but, well, it would be better if Xtext would offer an official API for this.

I think that many DSLs need to interface Java code and the API to check imports and type names should be pretty stable.
Re: Validating JvmType imports [message #841552 is a reply to message #840798] Wed, 11 April 2012 13:03 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
Registered: July 2009
Senior Member
Hi Aaron,

it will become public API as soon as we have the feeling that it's
mature enough. We don't have the resources to maintain poorly designed
APIs and apply deprecation strategies thus we warn clients that the
referenced code may change.
What you consider pretty stable is not necessarily stable from our
perspective, e.g. the resource set may be a to broad context for the
lookup environment of a type (which indeed it is).

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 10.04.12 16:21, schrieb Aaron Digulla:
> Karsten Thoms wrote on Fri, 06 April 2012 14:55
>> You can add @SuppressWarnings("restriction")
>> to your class.
>
>
> Well, yes but I was rised to pay heed to warnings ;)
>
> My main complaint is that I must add the annotation to the class
> (because I also get warnings for the imports), so the scope of the
> annotation to too broad for my liking.
>
> Okay, I can work around this by not using imports but FQ names but,
> well, it would be better if Xtext would offer an official API for this.
>
> I think that many DSLs need to interface Java code and the API to check
> imports and type names should be pretty stable.
Re: Validating JvmType imports [message #843660 is a reply to message #841552] Fri, 13 April 2012 08:46 Go to previous message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
I understand. Here is the recipe for a workaround:

- Create another class which contains *only* restricted API calls (i.e. methods that simply delegate, no logic).
- Add @SuppressWarnings("restriction") to that class
- Inject this class into your code

This way, there is no risk to suppress too many warnings (or the wrong ones) and all the "risky" code is in one place.
Previous Topic:Launching rename operation in fix provider
Next Topic:dangling references on reparse of a resource
Goto Forum:
  


Current Time: Fri Jul 10 00:25:45 GMT 2020

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

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

Back to the top