Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » File extension conflict(Problem when other plugins register a file extension for xtext that is also used in my plugin.)
File extension conflict [message #1695667] Mon, 18 May 2015 12:30 Go to next message
Mario Prieto is currently offline Mario PrietoFriend
Messages: 9
Registered: January 2013
Junior Member
I have following situation:

I have a plugin with an Xtext grammar that when run will generate (between others) a file with extension .cfg

In another plugin there is a Xtext grammar that registers the .cfg extension as extension for that grammar's files.

When running my application, Xtext is complaining in my project that the .cfg file in my project cannot be parsed.

How can I avoid Xtext trying to parse the .cfg file in my project?

- My project cannot have that grammar's .cfg file, only the generated one.
- I cannot change the .cfg file extension to be other extension (compatibility)

Thanks for any advice!
Re: File extension conflict [message #1695685 is a reply to message #1695667] Mon, 18 May 2015 13:17 Go to previous messageGo to next message
Mario Prieto is currently offline Mario PrietoFriend
Messages: 9
Registered: January 2013
Junior Member
I'm not sure if this is the way to go, but I found myself what seems to be a solution.

I created a class inheriting from DefaultResourceServiceProvider which implements IResourceServiceProvider. In that class I overrided the canHandle method to only accept file extensions which are valid for the grammar applying in my type of project. Then I registered that new ResourceServiceProvider in the *RuntimeModule class of my grammar, as the class to be injected when IResourceServiceProvider is required, so that only files with valid file extensions will be processed by Xtext in my project.

BR.
Re: File extension conflict [message #1695719 is a reply to message #1695685] Mon, 18 May 2015 15:03 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Yes, that sounds ok to me, though it will still use the Xtext editor for
your not-quite-cfg-files cfgf-files.
Did you try to use Eclipse's content type mechanism?

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Find help at http://xtext.itemis.com or xtext(@)itemis.com
Blog: zarnekow.blogspot.com
Twitter: @szarnekow
Google+: https://www.google.com/+SebastianZarnekow
Re: File extension conflict [message #1696620 is a reply to message #1695719] Wed, 27 May 2015 13:58 Go to previous messageGo to next message
Mario Prieto is currently offline Mario PrietoFriend
Messages: 9
Registered: January 2013
Junior Member
First of all thanks for your answer and sorry my late one. I didn't get an email notification for your answer...

My "solution" did not really work, I just thought so Sad

I've tried to define a content type with the cfg extension but the problem remains. This would also not really solve the potential problem of other file extensions that may conflict in the future. I wouldn't like to keep updating my plugin as more Xtext-Languages are added to my software.

Xtext still tries to parse the cfg file and places an error marker on it.

[Updated on: Wed, 27 May 2015 14:00]

Report message to a moderator

Re: File extension conflict [message #1696726 is a reply to message #1696620] Thu, 28 May 2015 08:52 Go to previous messageGo to next message
Mario Prieto is currently offline Mario PrietoFriend
Messages: 9
Registered: January 2013
Junior Member
Hi again,

I'm trying to solve the issue using the contribution IToBeBuiltComputerContribution where I would reject the cfg files to be processed if they are in a project with a given nature. The problem with this approach seems to be that the contribution mechanism doesn't work properly.

When ToBeBuiltComputer loads, it checks for extensions of type IToBeBuiltComputerContribution and only finds JdtToBeBuiltComputer as my plugins get loaded, and thus add the contributions later. The extensions don't get checked ever again and have thus no effect.

There must be a way to keep the wrong Xtext-Builders away from my project :s!

Thanks for any advice...
Re: File extension conflict [message #1859927 is a reply to message #1695667] Wed, 05 July 2023 18:30 Go to previous message
Eclipse UserFriend
AI Spam removed

[Updated on: Wed, 04 October 2023 13:24] by Moderator

Report message to a moderator

Previous Topic:[SOLVED] A (very stupid?) beginner problem
Next Topic:How to remove the '\' before each single quote in a string added by the formatter ?
Goto Forum:
  


Current Time: Sat Apr 20 02:49:29 GMT 2024

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

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

Back to the top