Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Using EclipseResourceFileSystemAccess2 in test
Using EclipseResourceFileSystemAccess2 in test [message #1801610] Wed, 23 January 2019 12:16 Go to next message
Konrad Jünemann is currently offline Konrad JünemannFriend
Messages: 31
Registered: December 2018
Member
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 12:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13071
Registered: July 2009
Senior Member
EclipseResourceFileSystemAccess2 is an eclipse component and thus should be bound in ui module

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Using EclipseResourceFileSystemAccess2 in test [message #1801612 is a reply to message #1801611] Wed, 23 January 2019 12:33 Go to previous message
Konrad Jünemann is currently offline Konrad JünemannFriend
Messages: 31
Registered: December 2018
Member
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: Fri Aug 23 06:20:32 GMT 2019

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

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

Back to the top