Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Creating Xtext project based on file name not file extension
Creating Xtext project based on file name not file extension [message #714117] Tue, 09 August 2011 20:38 Go to next message
Alex Ruiz is currently offline Alex RuizFriend
Messages: 103
Registered: March 2011
Senior Member
Greetings,

Given the success we had by using Xtext for the protocol buffer editor, I'm using Xtext again for an editor for an internal DSL.

The problem is that this is an existing DSL, and the files of this type should be recognized by file name, instead of file extension (the way Xtext works.) For example, a file of type MyDSL won't have any extension, but its name should be MYDSL.

It is easy to change the plugin.xml created by Xtext to work with file names, but resource factories work with extensions only:

(from my plugin.xml)
	<extension
		point="org.eclipse.emf.ecore.extension_parser">
		<parser class="com.google.eclipse.mydsleditor.ui.MyDslExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceFactory"
			type="MYDSL">
		</parser>
	</extension>
	<extension point="org.eclipse.xtext.extension_resourceServiceProvider">
        <resourceServiceProvider
            class="com.google.eclipse.mydsleditor.ui.MyDslExecutableExtensionFactory:org.eclipse.xtext.ui.resource.IResourceUIServiceProvider"
            uriExtension="MYDSL">
        </resourceServiceProvider>
    </extension>


Is there a way to accomplish what I'm trying to do? Smile

Many thanks in advance,
-Alex
Re: Creating Xtext project based on file name not file extension [message #714118 is a reply to message #714117] Tue, 09 August 2011 20:40 Go to previous messageGo to next message
Alex Ruiz is currently offline Alex RuizFriend
Messages: 103
Registered: March 2011
Senior Member
Sorry I meant that it is easy to associate an editor to a file type using file names instead of file extensions. But I haven't found a way to make resource factories work the same way.
Re: Creating Xtext project based on file name not file extension [message #714153 is a reply to message #714118] Tue, 09 August 2011 22:29 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Alex,

you may want to register a org.eclipse.emf.ecore.resource.ContentHandler
for your sort of URI and provide the resource factory for a special
content type that is returned by your content handler. I think this
could work.

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

On 09.08.11 22:40, Alex Ruiz wrote:
> Sorry I meant that it is easy to associate an editor to a file type
> using file names instead of file extensions. But I haven't found a way
> to make resource factories work the same way.
Re: Creating Xtext project based on file name not file extension [message #714553 is a reply to message #714153] Wed, 10 August 2011 20:26 Go to previous message
Alex Ruiz is currently offline Alex RuizFriend
Messages: 103
Registered: March 2011
Senior Member
Thanks Sebastian. I'm trying that now. Not done yet but I can already see the light at the end of the tunnel.

I'm thinking about blogging about it.

Cheers,
-Alex
Previous Topic:Enumeration type between ""
Next Topic:How can I define a rule which is each line must have just one type date?
Goto Forum:
  


Current Time: Tue Sep 24 15:52:26 GMT 2024

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

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

Back to the top