How to set file encoding of generated file from my dsl file [message #818388] |
Sun, 11 March 2012 10:42  |
Eclipse User |
|
|
|
Hi there,
E.g: In xtext StateMachine flower dsl example, it transform file of a state machine dsl to a java file, I want to set this java file to encoding "UTF-8" when transforming. In default this file's encoding is inherit from java workspace.
In the xtext documentation there have some encoding presentations,but it seems not hit my requirement, I want to set the generated java file from a state machine dsl file, not the generate file of "src-gen","xtend-gen" in the xtext project.
Is there anyone knows how to solve this problem?
Thanks in advance!
|
|
|
|
Re: How to set file encoding of generated file from my dsl file [message #819158 is a reply to message #818477] |
Mon, 12 March 2012 11:15   |
Eclipse User |
|
|
|
Hi Christian,
Thank you for your quick response, I tried as you suggested, but with no success, it seems the binding doesn't success, for method getInputStream, it always use from EclipseResourceFileSystemAccess2, not MyFileSystemAccess, can you help to check where the problem is, what I have done is as follow, thank you very much.
1. I created a class MyFileSystemAccess inherited from EclipseResourceFileSystemAccess2 in package org.eclipse.xtext.example.fowlerdsl like:
public class MyFileSystemAccess extends EclipseResourceFileSystemAccess2 {
@Override
protected StringInputStream getInputStream(String contentsAsString,
String encoding) {
return super.getInputStream(contentsAsString, "UTF-16");
}
}
2.I bind MyFileSystemAccess to IFileSystemAccess in file StatemachineRuntimeModule:
public class StatemachineRuntimeModule extends org.eclipse.xtext.example.fowlerdsl.AbstractStatemachineRuntimeModule {
@Override
public void configure(Binder binder) {
binder.bind(IFileSystemAccess.class).to(MyFileSystemAccess.class);
super.configure(binder);
}
}
[Updated on: Mon, 12 March 2012 11:18] by Moderator
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04403 seconds