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.
If you want to refer to Java types, use Xbase and add
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
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' importedNamespace=QualifiedName
> QualifiedName: ID ('.' ID)*;
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?