Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 324964

Summary: Allow derived properties
Product: [Modeling] EMFT Reporter: Moritz Eysholdt <moritz.eysholdt>
Component: MWEAssignee: Project Inbox <emft-mwe-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: sven.efftinge
Version: 1.0   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Moritz Eysholdt CLA 2010-09-10 09:17:52 EDT
In the forum, an interesting problem has come up:
1. in an MWE workflow, a property containing backslashes (\) was declared.
2. This property was handed on to a component which evaluates an Xtend expression.

Example:

------
var src_gen = "c:\\var\\foo"

org.eclipse.xtend.typesystem.xsd.XMLWriter {
	uriExpression = {
		expression = "\'${src_gen}\' + extension::getFileName()"
	}
}
------
http://www.openarchitectureware.org/forum/viewtopic.php?showtopic=15205

This can not work because either MWE needs to be able to escape the backshashes or Xtend need to have a string-token that can contain unescaped backslashes.

If the propertie's original value is seen as untouchable, one solution might be to allow derived attributes:

------
var src_gen = "c:\\var\\foo"
var src_gen_esacepd = replaceBacksashWithForwarndSlash(src_gen)

org.eclipse.xtend.typesystem.xsd.XMLWriter {
	uriExpression = {
		expression = "\'${src_gen_esacepd}\' + extension::getFileName()"
	}
}
------

with replaceBacksashWithForwarndSlash() being a Java method.
Comment 1 Sven Efftinge CLA 2010-09-11 05:15:37 EDT
If you have four backslashes it should work.
In case you want to reuse the information and only make it xtend compatible for the one situation (i.e. you can't use four backslashes), you should create a small subclass of the component, where you do the escaping.

For instance :

org.eclipse.xtend.typesystem.xsd.XMLWriter {
    uriExpression = MyEscapingUriExpression {
        expression = "\'${src_gen_esacepd}\' + extension::getFileName()"
    }
}


Where MyEscapingUriExpression replaces single backslashes by double backslashes.
Also as suggested simple forward slashes should also solve the issue.

I think such rare situations are solvable with this approach. Therefore I wouldn't want to add the proposed feature. Did I miss something?