Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Library in VS Code extension
Library in VS Code extension [message #1859786] Tue, 27 June 2023 09:58 Go to next message
Cyril Vrousos is currently offline Cyril VrousosFriend
Messages: 5
Registered: June 2023
Junior Member
Good morning,

I'm creating this topic because I couldn't find an answer for the problem I'm having.
I am currently developing a VS Code extension for my DSL developed with Xtext.

In the current architecture of my DSL, I have a plugin "org.eclipse.mydsl.lib" which is a library containing common implementations of objects in my language.

Currently, using my DSL from an Eclipse runtime, this plugin is automatically added to the MANIFEST.MF of every new project.

However, with VS Code, I no longer have access to the MANIFEST.MF. Thus, every new project using my DSL does not have access to this plug-in and the common object implementation described by this library.
Is there a way to get a reference to this library/plugin via the language server?

Let me know if it's not clear enough.

Thank you,
Cyril
Re: Library in VS Code extension [message #1859799 is a reply to message #1859786] Tue, 27 June 2023 14:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14687
Registered: July 2009
Senior Member
Hi, i dont know a ootb feature for that
you may start digging at org.eclipse.xtext.ide.server.ProjectManager.doInitialBuild(CancelIndicator) / org.eclipse.xtext.util.IFileSystemScanner



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Library in VS Code extension [message #1859811 is a reply to message #1859799] Wed, 28 June 2023 14:39 Go to previous messageGo to next message
Cyril Vrousos is currently offline Cyril VrousosFriend
Messages: 5
Registered: June 2023
Junior Member
Hi,

I followed what you suggested here about the ProjectManager: https://github.com/eclipse/xtext/issues/2566

public class CustomProjectManager extends ProjectManager {
	
	IProjectConfig projectConfig;
	
	@Override
	public void initialize(ProjectDescription description, IProjectConfig projectConfig,
			Procedure2<? super URI, ? super Iterable<Issue>> acceptor,
			IExternalContentProvider openedDocumentsContentProvider,
			Provider<Map<String, ResourceDescriptionsData>> indexProvider, CancelIndicator cancelIndicator) {
		super.initialize(description, projectConfig, acceptor, openedDocumentsContentProvider, indexProvider, cancelIndicator);
		this.projectConfig = projectConfig;
	}
	
	@Override
	public Result doInitialBuild(CancelIndicator cancelIndicator) {
		List<URI> allUris = new ArrayList<>();
		for (ISourceFolder srcFolder : super.getProjectConfig().getSourceFolders()) {
			allUris.addAll(srcFolder.getAllResources(fileSystemScanner));
		}
		var url = getClass().getResource("/org/eclipse/mydsl/lib/catalogue.mydsl");
		allUris.add(URI.createURI(url.toString()));
		return super.doBuild(allUris, Collections.emptyList(), Collections.emptyList(), cancelIndicator);
	}
}


I also created a CustomServerModule and a CustomServerLauncher, but it doesn't work.

I tested the access to the resource was valid and I verified that the creation of the URI is done (in a junit test).
Any idea what I might have forgotten?

Thank you.

[Updated on: Wed, 28 June 2023 14:45]

Report message to a moderator

Re: Library in VS Code extension [message #1859830 is a reply to message #1859811] Thu, 29 June 2023 08:45 Go to previous message
Cyril Vrousos is currently offline Cyril VrousosFriend
Messages: 5
Registered: June 2023
Junior Member
The above solution finally works. It was a Maven build problem.

My library is automatically loaded when I use my VS code extension!

Thank you
Previous Topic:Xtext 2.32.0.M0 is out
Next Topic:Calling IReferenceFinder.findAllReferences in tests
Goto Forum:
  


Current Time: Mon Jun 24 10:51:54 GMT 2024

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

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

Back to the top