xtext

How to get name (uri) of all model files in project


In validator I would like to get uri of all model files.

I can get name only of current file (e.g myDsl1.mydsl) but I would like to get uri of other files too (e.g myDsl2.mydsl, myDsl3.mydsl).

Can this be done in validator or I should create new classes/methods for seeing this files?


Solution

  • You can access the Xtext index IResourceDescriptions via IResourceDescriptionsProvider. You can ask IResourceDescriptions for getAllResourceDescriptions which you may have to filter for project. to use std visibility meachinsm check out IContainer.Manager with getVisibleContainers/getContainer and IContainer.getResourceDescriptions´. Check out DefaultGlobalScopeProvider` for sample usage.