XText ValueConverter And Generated Editor Issue [message #1049266] |
Thu, 25 April 2013 11:44  |
Eclipse User |
|
|
|
Hi,
I have written an IValueConverter which allows me to generate RegExs without the default XText backslash escaping. This seems to work fine as my ATL generator runs nicely. However, when I open the generated file using the XText generated editor I see red marks all over the RegExs where backslashes are. Did I miss something?
Perhaps it has something todo with the toValue method in IValueConverter? I don't know what that does. I placed custom backslash replace code in the toString method to handle a special case at serialization time.
My code is as follows:
public class RegExConverter extends DefaultTerminalConverters {
@ValueConverter(rule = "RegEx")
public IValueConverter<String> RegEx() {
return new IValueConverter<String>() {
@Override
//TODO:Not sure what this method is really doing
public String toValue(String string, INode node) throws ValueConverterException {
if (string == null)
return null;
else
//return this.toString(string);
return string;
}
@Override
public String toString(String value) throws ValueConverterException {
if (value == null)
return null;
else
//YANG/XSD gets upset with double backslash so we replace it with triple
return '"' + value.replace("\\\\", "\\\\\\") + '"';
}
};
}
Thanks,
Ronan
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05565 seconds