Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Obtainign the classpath from a XtextResource
Obtainign the classpath from a XtextResource [message #1736573] Thu, 30 June 2016 11:51 Go to next message
Stéphane Galland is currently offline Stéphane GallandFriend
Messages: 123
Registered: July 2014
Location: Belfort, France
Senior Member
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 #1736576 is a reply to message #1736573] Thu, 30 June 2016 12:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Xtext uses jdt to do this. Can you give some hints what exactly want to do

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Obtainign the classpath from a XtextResource [message #1736583 is a reply to message #1736576] Thu, 30 June 2016 12:57 Go to previous messageGo to next message
Stéphane Galland is currently offline Stéphane GallandFriend
Messages: 123
Registered: July 2014
Location: Belfort, France
Senior Member
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

Re: Obtainign the classpath from a XtextResource [message #1736588 is a reply to message #1736583] Thu, 30 June 2016 13:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

you may start digging around org.eclipse.xtext.ui.resource.Storage2UriMapperJavaImpl
if you can look the information up inside its data


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Obtainign the classpath from a XtextResource [message #1736590 is a reply to message #1736588] Thu, 30 June 2016 13:36 Go to previous message
Stéphane Galland is currently offline Stéphane GallandFriend
Messages: 123
Registered: July 2014
Location: Belfort, France
Senior Member
Thank you, Christian. I will explore on this direction.
Previous Topic:Log4J problems in xtext plugins
Next Topic:Using ImportURIScopingFragment instead of ImportNamespacesScopingFragment with the new MWE2
Goto Forum:
  


Current Time: Thu Apr 25 12:10:37 GMT 2024

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

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

Back to the top