Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » getting the file path and accessing project files
getting the file path and accessing project files [message #1734941] Tue, 14 June 2016 00:04 Go to next message
Mansour Al is currently offline Mansour AlFriend
Messages: 44
Registered: June 2016
Member
I am trying to validate the existence of a file in the project:

@Check
def checkConfigFile(ConfigFile configFile) {

val suitePath = configFile.eResource.URI.toPlatformString(true)
val config = Paths.get(suitePath).resolveSibling(configFile.file)
val msg = "File does not exist"
println("checking the path " + config )

if (!config.toFile.exists) {
println("not found " + config)
error(msg, MyDslPackage.Literals.CONFIG_FILE__FILE, "some issue")
}
}

I have seen a similar post http://stackoverflow.com/questions/7242403/a-better-way-to-get-files-within-a-project-using-eclipse-and-xtext

and
http://stackoverflow.com/questions/23630118/xtext-get-the-absolute-path-of-the-generated-files

and
http://stackoverflow.com/questions/22377592/xtext-get-project-root-directory-from-validator


but was not able to figure out how to add org.eclipse.core.resources to plugin.xml
or inject an instance of IFileSystemAccess into the validator.

Is there a detailed documentation showing how to achieve this?
An advice of the best approach is highly appreciated.

Thank you
Re: getting the file path and accessing project files [message #1734943 is a reply to message #1734941] Tue, 14 June 2016 03:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14651
Registered: July 2009
Senior Member
Is this Code targeting standalone or eclipse.

Using resources plugin works in eclipse only.

You can add org.eclipse.core.resources to the manifest


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: getting the file path and accessing project files [message #1735048 is a reply to message #1734943] Tue, 14 June 2016 23:09 Go to previous message
Mansour Al is currently offline Mansour AlFriend
Messages: 44
Registered: June 2016
Member
Christian,
Adding org.eclipse.core.resources as an OSGI import did the trick.
I will need a more generic solution if possible, as I would like to make it available for the interrupter. For now eclipse support is enough to keep me going.
If you have a more generic solution (eclipse and standalone) then please do let me know.

Thank you a lot
Previous Topic:Bundle Exception - Error when launching Eclipse Application
Next Topic:The seven languages text
Goto Forum:
  


Current Time: Thu Feb 22 16:45:28 GMT 2024

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

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

Back to the top