Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Using EclipseResourceFileSystemAccess2 in test
Using EclipseResourceFileSystemAccess2 in test [message #1801610] Wed, 23 January 2019 07:16 Go to next message
Eclipse UserFriend
Hi,

in order to set a specific encoding for files generated by my language, I created my own EclipseResourceFileSystemAccess2 subclass and created a binding as shown below.

public class MyFileSystemAccess2 extends EclipseResourceFileSystemAccess2 {
	
	@Override
	protected String getEncoding(IFile file) throws CoreException {
		
		if (file.getName().endsWith(".csv")) {
			IContainer parent = file.getParent();
			if (parent != null && "export".equals(parent.getName()))
				return "ISO-8859-1";
		}
		
		return super.getEncoding(file);
	}
}


class LogDslRuntimeModule extends AbstractLogDslRuntimeModule {
...
	def Class<? extends EclipseResourceFileSystemAccess2> bindEclipseResourceFileSystemAccess2() {
		return MyFileSystemAccess2
	}
}


This works fine. However, my UnitTests now don't start anymore, as Guice is unable to inject a dependency used by EclipseResourceFileSystemAccess2.

...
	at de.myProject.mydsl.tests.MyDslInjectorProvider$1.createInjector(MyDslInjectorProvider.java:39)
	at de.myProject.mydsl.MyDslStandaloneSetupGenerated.createInjectorAndDoEMFRegistration(MyDslStandaloneSetupGenerated.java:21)
	at de.myProject.mydsl.tests.MyDslInjectorProvider.internalCreateInjector(MyDslInjectorProvider.java:41)
	at de.myProject.mydsl.tests.MyDslInjectorProvider.getInjector(MyDslInjectorProvider.java:29)
	at de.myProject.mydsl.tests.MyDslInjectorProvider.setupRegistry(MyDslInjectorProvider.java:63)
...
Caused by: java.lang.ClassNotFoundException: org.eclipse.xtext.ui.generator.trace.TraceMarkers


I figure my Standalone / Test Injector Setup is incorrect, but I am at a loss about how to fix it.
1. Do I have to use a different IFileSystemAccess2 subtype in test?
2. If so, how would I create the binding?
3. If so, how do I prevent the other binding (bindEclipseResourceFileSystemAccess2) from being used in test?

Maybe I did something else wrong. Any advice would be greatly appreciated!
Re: Using EclipseResourceFileSystemAccess2 in test [message #1801611 is a reply to message #1801610] Wed, 23 January 2019 07:23 Go to previous messageGo to next message
Eclipse UserFriend
EclipseResourceFileSystemAccess2 is an eclipse component and thus should be bound in ui module
Re: Using EclipseResourceFileSystemAccess2 in test [message #1801612 is a reply to message #1801611] Wed, 23 January 2019 07:33 Go to previous message
Eclipse UserFriend
Thanks! That solved my issue. :-)
Previous Topic:Inverse operation of ModelJvmModelInferrer
Next Topic:Building Xtext out of the box with maven fails on photon
Goto Forum:
  


Current Time: Thu Jun 19 13:12:24 EDT 2025

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

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

Back to the top