Adding a language library to a non java project [message #872243] |
Tue, 15 May 2012 14:43  |
Eclipse User |
|
|
|
Hi,
I've created an xtext based language which should be used in cdt based
projects. That language should come with a language library (similar to
the xbase lib or the java.lang classes). The user should be able to
refer to elements of that library without further action. Therefore I've
added implicit imports to the scope provider and I've created a jar
containg all models of that library.
In java based projects I can put the library on the classpath and
referring to elements of the library works out of the box (cool :).
But how do I add the library content to a CDT project? Do I have to
create my own IAllContainersState implementation? I think of an approach
where I load the library from a configured path and add it to the scope
"somehow".
I would like to have a solution which works without any additional user
action. If I add a file of my language to the CDT project, the library
should be automatically available. In the best case the user should not
notice that such a library exists.
Note that the language library itself should *not* be added as it's own
project to the eclipse workspace which contains the CDT project (I could
use the WorkspaceProjectsState then and just add a project reference
from the cdt project to the library project).
Any ideas?
Christoph
|
|
|
|
|
|
Re: Adding a language library to a non java project [message #891757 is a reply to message #879026] |
Mon, 25 June 2012 15:33  |
Eclipse User |
|
|
|
Hi Sebastian,
thanks for your suggestion. I had no luck so far. I've added an
container for my library as you suggested. Unfortunately the resources
of the library never show up in the library's scope. When the scope for
the library is calculated it is always empty.
What do I have to do to load the resources from initContainedURIs?
What I did so far is:
public class MyWorkspaceProjectsStateHelper extends
WorkspaceProjectsStateHelper {
public static final String LIBRARY = "library";
@Override
public List<String> initVisibleHandles(String handle) {
List<String> handles = super.initVisibleHandles(handle);
handles.add (LIBRARY);
return handles;
}
@Override
public Collection<URI> initContainedURIs(String containerHandle) {
if (containerHandle.equals (LIBRARY)) {
ArrayList<URI> result = new ArrayList<URI>();
result.add
(URI.createFileURI("/Users/ckulla/dev/eclipse/workspaces/cdtxtext/mydsl.lib/src/Lib.mydsl"));
// result.add (URI.createPlatformPluginURI("/mydsl.lib/src/Lib.mydsl",
true));
return result;
} else {
return super.initContainedURIs(containerHandle);
}
}
}
I've spent some time with debugging, but no progress so far. I did not
figure out where the URI's returned by initContainedURIs() are actually
loaded. I must have missed something...
Cheers,
Christoph
On 5/30/12 1:32 PM, Sebastian Zarnekow wrote:
> Am 30.05.12 11:13, schrieb Christoph Kulla:
>> Hi,
>>
>> I still haven't found a solution for this, any comment is appreciated.
>>
>> Christoph
>>
>> On 5/15/12 8:43 PM, Christoph Kulla wrote:
>>> Hi,
>>>
>>> I've created an xtext based language which should be used in cdt based
>>> projects. That language should come with a language library (similar to
>>> the xbase lib or the java.lang classes). The user should be able to
>>> refer to elements of that library without further action. Therefore I've
>>> added implicit imports to the scope provider and I've created a jar
>>> containg all models of that library.
>>>
>>> In java based projects I can put the library on the classpath and
>>> referring to elements of the library works out of the box (cool :).
>>>
>>> But how do I add the library content to a CDT project? Do I have to
>>> create my own IAllContainersState implementation? I think of an approach
>>> where I load the library from a configured path and add it to the scope
>>> "somehow".
>>>
>>> I would like to have a solution which works without any additional user
>>> action. If I add a file of my language to the CDT project, the library
>>> should be automatically available. In the best case the user should not
>>> notice that such a library exists.
>>>
>>> Note that the language library itself should *not* be added as it's own
>>> project to the eclipse workspace which contains the CDT project (I could
>>> use the WorkspaceProjectsState then and just add a project reference
>>> from the cdt project to the library project).
>>>
>>> Any ideas?
>>>
>>> Christoph
>>
>
> Hi Christoph,
>
> you may want to add an IContainer to the set of visible containers and
> use platform:/plugin to load them
>
> Regards,
> Sebastian
|
|
|
Powered by
FUDForum. Page generated in 0.04146 seconds