Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Organise imports in my DSL
Organise imports in my DSL [message #1062311] Fri, 07 June 2013 07:18 Go to next message
Alfredo Capozucca is currently offline Alfredo CapozuccaFriend
Messages: 12
Registered: November 2011
Junior Member
Hi,

I want to implement an import organizer for my DSL in the same manner that exists in Eclipse development environment (i.e. when you hit Shift + Crtl + O). I'm wondering what's the best (i.e. simplest) way to implement such a functionality using Xtext. Any advice is more than welcome.

Regards.
Re: Organise imports in my DSL [message #1062314 is a reply to message #1062311] Fri, 07 June 2013 07:21 Go to previous messageGo to next message
Alfredo Capozucca is currently offline Alfredo CapozuccaFriend
Messages: 12
Registered: November 2011
Junior Member
It might be worth adding that in my DSL imports are represented according to the following grammar rule

Import:
'import' importedNamespace=QualifiedName
;

QualifiedName: ID ('.' ID)*;
Re: Organise imports in my DSL [message #1062325 is a reply to message #1062314] Fri, 07 June 2013 08:25 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
If you want to refer to Java types, use Xbase and add

importSection=XImportSection

in your grammar. You will get extensive tooling - organize imports,
content assist, validation - for free.

If not, you have to build it your own. Have a look at the classes around
org.eclipse.xtext.xbase.imports.ImportOrganizer
org.eclipse.xtext.xbase.imports.RewritableImportSection
to get the idea. But be warned: It's a lot of work.


Am 07.06.13 09:21, schrieb Alfredo Capozucca:
> It might be worth adding that in my DSL imports are represented
> according to the following grammar rule
>
> Import:
> 'import' importedNamespace=QualifiedName
> ;
>
> QualifiedName: ID ('.' ID)*;


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


---
Get professional support from the Xtext committers at www.typefox.io
Re: Organise imports in my DSL [message #1062339 is a reply to message #1062325] Fri, 07 June 2013 09:37 Go to previous messageGo to next message
Alfredo Capozucca is currently offline Alfredo CapozuccaFriend
Messages: 12
Registered: November 2011
Junior Member
Dear Jan,

Thanks for the tip. Wouldn't you consider refactoring as a choice to implement this functionality?

Regards.
Re: Organise imports in my DSL [message #1062345 is a reply to message #1062339] Fri, 07 June 2013 10:13 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
That's of course your choice. The current implementation relies on the
Xbase/Xtype and the JvmModel, i.e. on Java types (inferred or native).
Depends on your target if it's worthwhile to refactor.

A complete solution involves a lot of services, e.g. content assist
(proposing a type automatically adds an import), validation (find unused
imports), UI (a dialog for choosing from ambiguous candidates),
refactoring, quickfix etc. That's what makes it complicated.

Am 07.06.13 11:37, schrieb Alfredo Capozucca:
> Dear Jan,
>
> Thanks for the tip. Wouldn't you consider refactoring as a choice to
> implement this functionality?
>
> Regards.


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


---
Get professional support from the Xtext committers at www.typefox.io
Previous Topic:How to set working directory for import URIs
Next Topic:Xtext unordered group
Goto Forum:
  


Current Time: Thu Apr 18 09:01:49 GMT 2024

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

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

Back to the top