Obtainign the classpath from a XtextResource [message #1736573] |
Thu, 30 June 2016 11:51 |
|
Dear all,
I would like to obtain the classpath associated to a XtextResource in order to extract additional information from the Manifests when they are available.
Is a way to retreive the list of elements in the classpath that is used for resolving types for a specific XtextResource?
All the best.
Stéphane.
|
|
|
|
Re: Obtainign the classpath from a XtextResource [message #1736583 is a reply to message #1736576] |
Thu, 30 June 2016 12:57 |
|
Dear Christian.
Thank you for your quick reply.
I have a jar file, says "math.jar" that contains extension types for my DSL, similar to *Extensions provided by Xtext, but for mathematical primitives.
This jar file in the classpath of the currently compiled project.
The extension are currently included with an import in the code.
Now my question is related to the fact that I want to never explicit the import of the extension types. In other words, I would like to implicitly import them when the jar file is in the classpath.
I know about ImplicityImportedFeatures; and I have already one defined as:
@Singleton
public class SARLImplicitlyImportedFeatures extends ImplicitlyImportedFeatures {
/** Construct the provider.
*/
public SARLImplicitlyImportedFeatures() {
super();
}
@Override
protected List<Class<?>> getExtensionClasses() {
final List<Class<?>> xtextList = super.getExtensionClasses();
// Insert at the beginning for ensuring the SARL extension is selected before any Xtext extension.
xtextList.add(0, SARLMapExtensions.class);
xtextList.add(0, SARLTimeExtensions.class);
return xtextList;
}
}
I would like to update it in order to obtain something similar to:
@Singleton
public class SARLImplicitlyImportedFeatures extends ImplicitlyImportedFeatures {
/** Construct the provider.
*/
public SARLImplicitlyImportedFeatures() {
super();
}
@Override
protected List<Class<?>> getExtensionClasses() {
final List<Class<?>> xtextList = super.getExtensionClasses();
// Insert at the beginning for ensuring the SARL extension is selected before any Xtext extension.
xtextList.add(0, SARLMapExtensions.class);
xtextList.add(0, SARLTimeExtensions.class);
return xtextList;
}
/** {@inheritDoc}
*/
@Override
public List<JvmType> getExtensionClasses(Resource context) {
final List<JvmType> types = super.getExtensionClasses(context);
getExtensionClassesFromClasspath(types, context);
return types;
}
private void getExtensionClassesFromClasspath(List<JvmType> types, Resource context) {
// TODO
}
}
The question is: how to retreive the classpath entries from the context?
Indeed, I would like to put some information in the jar's manifest for definition the extension that are provided by the jar file.
The TypeReferences object provided by Xtext does not provide access to the classpath.
Should I access to the classpath by directly using the JDT API?
Stéphane.
[Updated on: Thu, 30 June 2016 12:59] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03599 seconds