Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Get src path inside the plugin
Get src path inside the plugin [message #824347] Mon, 19 March 2012 15:07 Go to next message
Heinz Huber is currently offline Heinz HuberFriend
Messages: 45
Registered: February 2012
Member
Hi,

i am nearly finished creating my eclipse plugin.
The last bug which is on my list is the following one:

In my language it is possible to make imports at the top of the file. These imports are loaded in some hoover effects to show the information which is inside these files. This works well, but the problem is, that the path to these files couldn't be resolved right.

After exporting my plugin the imported filename is searched inside my eclipse installation folder. That's not the way i had planned that! I want him to search at the position of the file which is opened in the editor (in the normal case this is 'workspace/projectname/src').

Is there any way to get the path to the src folder of the project?

Hope someone got an idea!
Thanks in advance Smile

[Updated on: Mon, 19 March 2012 15:08]

Report message to a moderator

Re: Get src path inside the plugin [message #824641 is a reply to message #824347] Mon, 19 March 2012 22:29 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Are the imports explicitly loaded or by EMF's on demand mechanism?
You should always try to go for the latter.
Please provide more details on what kind of imports you use and how you
load them.

Am 19.03.12 16:07, schrieb Heinz Huber:
> Hi,
>
> i am nearly finished creating my eclipse plugin.
> The last bug which is on my list is the following one:
>
> In my language it is possible to make imports at the top of the file.
> These imports are loaded in some hoover effects to show the information
> which is inside these files. This works well, but the problem is, that
> the path to these files couldn't be resolved right.
>
> After exporting my plugin the imported filename is searched inside my
> eclipse installation folder. That's not the way i had planned that! I
> want him to search at the position of the file which is opened in the
> editor (in the normal case this is 'workspace/projectname/src').
>
> Is there any way to get the path to the src folder of the project?
>
> Hope someone got an idea!


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


---
Get professional support from the Xtext committers at www.typefox.io
Re: Get src path inside the plugin [message #824880 is a reply to message #824641] Tue, 20 March 2012 07:25 Go to previous messageGo to next message
Heinz Huber is currently offline Heinz HuberFriend
Messages: 45
Registered: February 2012
Member
Hi Jan,

after finishing the work on my language, validations ... -> I exported the plugin
After that, i installed it into a new eclipse installation -> That works fine!

The import in my language is done via */path/to/file.cfg at the top of the file which is created inside the new eclipse environment.
I am accessing this file via the normal file access classes of Java (BufferedReader). There is no problem getting the filename and the path which is given in the include. The whole function to access the file and extract the information is written too and works. The only problem i got is, that i couldn't get the path to the project (to access the src folder and get the Reader for the file).
So that i can build my complete filepath.
path/to/sourcefolder + includepath <- The first part is missing ...

Could you understand what i mean? ^^
I just need a way to get the src folder while the plugin is exported in a eclipse installation ...

Hope you got an idea! Smile

[Updated on: Tue, 20 March 2012 07:52]

Report message to a moderator

Re: Get src path inside the plugin [message #825462 is a reply to message #824880] Tue, 20 March 2012 21:31 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Sorry, I don't get it. Does the imported file reside in the workspace or
inside the installed plug-in?

What is the import path relative to?

Am 20.03.12 08:25, schrieb Heinz Huber:
> Hi Jan,
>
> after finishing the work on my language, validations ... -> I exported
> the plugin
> After that i installed it into a new eclipse installation -> That works
> fine!
>
> The import in my language is done via */path/to/file.cfg at the top of
> the file which is created inside the new eclipse environment.
> I am accessing this file via the normal file access classses of Java
> (BufferedReader). The whole function to access the file and extract the
> information is written and works. The only problem i got is, that i
> couldn't get the path to the project (to access the src folder and get
> the Reader for the file) ...
>
> Could you understand what i mean? ^^
> I just need a way to get the src folder while the plugin is exported in
> a eclipse installation ...
>
> Hope you got an idea! :)
>


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


---
Get professional support from the Xtext committers at www.typefox.io
Re: Get src path inside the plugin [message #825743 is a reply to message #825462] Wed, 21 March 2012 07:53 Go to previous messageGo to next message
Heinz Huber is currently offline Heinz HuberFriend
Messages: 45
Registered: February 2012
Member
Hi Jan,

no problem! I will try to explain it in another way ...

I got my xtext project. Inside a class of this project, i want to access a file (to read information into the plugin).
The filename is declared in the file which is later been created inside the eclipse environment (with the installed plugin)!
The file which i am going to open will be inside the workspace/projectname/src/ folder -> I need to get the path to the src folder.

The problem is, that the normal "tricks" to get the path do not really work because after exporting the xtext project all tricks end in the installation path of eclipse.

What do you mean with "what is the import path relative to"?
The file which is imported in the eclipse eclipse environment is saved in the workspace/project/src folder. I want to get this file to get information out of that file, while the user is editing inside the editor. Is this the answer to your question? ...

Hope that explanation is a bit better than the ones before. Smile
Re: Get src path inside the plugin [message #826706 is a reply to message #825743] Thu, 22 March 2012 12:00 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
If everything is in the workspace, why not use the Eclipse Resource API,
i.e. IProject, IFile etc?

Am 21.03.12 08:53, schrieb Heinz Huber:
> Hi Jan,
>
> no problem! I will try to explain it in another way ...
>
> I got my xtext project. Inside a class of this project, i want to access
> a file (to read information into the plugin).
> The filename is declared in the file which is later been created inside
> the eclipse environment (with the installed plugin)!
> The file which i am going to open will be inside the
> workspace/projectname/src/ folder -> I need to get the path to the src
> folder.
>
> The problem is, that the normal "tricks" to get the path do not really
> work because after exporting the xtext project all tricks end in the
> installation path of eclipse.
> What do you mean with "what is the import path relative to"? The file
> which is imported in the eclipse eclipse environment is saved in the
> workspace/project/src folder. I want to get this file to get information
> out of that file, while the user is editing inside the editor. Is this
> the answer to your question? ...
>
> Hope that explanation is a bit better than the ones before. :)


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


---
Get professional support from the Xtext committers at www.typefox.io
Re: Get src path inside the plugin [message #826772 is a reply to message #826706] Thu, 22 March 2012 13:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

as an additional hint to jans advice: http://wiki.eclipse.org/index.php/EMF-FAQ#How_do_I_map_between_an_EMF_Resource_and_an_Eclipse_IFile.3F

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Get src path inside the plugin [message #827418 is a reply to message #826772] Fri, 23 March 2012 09:56 Go to previous message
Heinz Huber is currently offline Heinz HuberFriend
Messages: 45
Registered: February 2012
Member
I got the solution now.
I don't really know why i didn't find this way before but now i've got it!

Thanks for your help! Smile
Previous Topic:Resolve Non-LL(*) decisions
Next Topic:Editor and Console
Goto Forum:
  


Current Time: Thu Apr 18 05:41:28 GMT 2024

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

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

Back to the top