Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to find files paths/names in project running with Xtend
How to find files paths/names in project running with Xtend [message #714059] Tue, 09 August 2011 17:53 Go to next message
Carmela  is currently offline Carmela Friend
Messages: 10
Registered: July 2011
Junior Member
Hi again!

I'm using Xtend to generate some code.
But my question does not exactly concerns code generation, but some other things within an Eclipse Application running with my DSL and code generator.

My generator needs some information contained in a kind of configuration file.
I manage to access and process this file by writing its path and name in a String variable within the generator's Main.java
This works for testing, but not more than that.

So, considering there's an Eclipse running with my generator, I would like to search within the current project directory, in order to find out the file paths and names contained in it.
Since this configuration file must be anyway imported (it is pre-processed by another plugin before I use it), being able to find it in my project would be a reasonable solution.

I tried doing something in this direction http://www.java-tips.org/java-se-tips/java.io/list-the-names-of-all-files-in-a-particular-dire.html
in the Main.java or in the .xtend, but it has returned the eclipse path, not the path of the current project.

I believe that the solution should not be a big issue, but neither am I an experienced programmer...

Many thanks in advance,
Carmela
Re: How to find files paths/names in project running with Xtend [message #714110 is a reply to message #714059] Tue, 09 August 2011 20:12 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13876
Registered: July 2009
Senior Member
Hi,

i doubt this is a common usecase.

if you are restricted to usage in eclipse ui you could e.g.
- come up with a own JavaProjectBasedBuilderParticipant/IGenerator that knows the IProject the generation is done within. then you could query the projects with eclipse means
- Or you come up with an own IFileSystemAccess (subclass of ExtendedEclipseResourceFilesystemAccess) and expose the src-gen path and then downcast in your generator. you may have to add an additional interface to get clean dependencies is runtime and ui plugin.

In both cases the solution is imho dirty.
so what is the reason you want to do this.

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:A rule that consumes everything until certain char/string?
Next Topic:Registering a resource factory
Goto Forum:
  


Current Time: Sun Apr 11 08:19:26 GMT 2021

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

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

Back to the top