| Summary: | Cannot refer to a non-final variable i inside an inner class defined in a different method | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Serano Colameo <serano.colameo> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | minor | ||
| Priority: | P3 | CC: | benjamin.schwertfeger, sebastian.zarnekow |
| Version: | unspecified | Flags: | sebastian.zarnekow:
indigo+
|
| Target Milestone: | SR1 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
workaround:
def Interface toInterface(InterfaceDcl source, Model model) {
val target = model.createIcmInterface(source.name)
val inherits = source.inherits.filter(typeof(InterfaceDcl))
source.exports.filter(typeof(OpDcl)).forEach([e|e.toOperation(target)])
source.exports.filter(typeof(TypeDcl)).forEach([e|e.toTypeDef(target)])
for (i : inherits) {
if (!model.exists(i)) {
target.^extends.add(i.toInterface(model))
target.extended = true
}
}
debug("Interface created => " + target.name)
return target
}
def boolean exists(Model model, InterfaceDcl idcl) {
val ifaces = model.features.filter(typeof(Interface))
ifaces.exists(e|e.name == idcl.name)
}
I'll push the fix as soon as Xtext 2.0 final was tagged. Pushed to master. *** Bug 352642 has been marked as a duplicate of this bug. *** Closing all bugs that were set to RESOLVED before Neon.0 Closing all bugs that were set to RESOLVED before Neon.0 |
Build Identifier: Xtext 2.0.0.v201105230203 xtend2: def Interface toInterface(InterfaceDcl source, Model model) { val target = model.createIcmInterface(source.name) val inherits = source.inherits.filter(typeof(InterfaceDcl)) source.exports.filter(typeof(OpDcl)).forEach([e|e.toOperation(target)]) source.exports.filter(typeof(TypeDcl)).forEach([e|e.toTypeDef(target)]) for (i : inherits) { if (!model.features.filter(typeof(Interface)).exists(e|e.name == i.name)) { target.^extends.add(i.toInterface(model)) target.extended = true } } debug("Interface created => " + target.name) return target } generated java class: public Interface toInterface(final InterfaceDcl source, final Model model) { { String _name = source.getName(); Interface _createIcmInterface = this.createIcmInterface(model, _name); final Interface target = _createIcmInterface; EList<InterfaceDcl> _inherits = source.getInherits(); Iterable<InterfaceDcl> _filter = IterableExtensions.<InterfaceDcl>filter(_inherits, com.csg.cs.tools.mdgen.idl.idl.InterfaceDcl.class); final Iterable<InterfaceDcl> inherits = _filter; EList<Export> _exports = source.getExports(); Iterable<OpDcl> _filter_1 = IterableExtensions.<OpDcl>filter(_exports, com.csg.cs.tools.mdgen.idl.idl.OpDcl.class); final Function1<OpDcl,Operation> _function = new Function1<OpDcl,Operation>() { public Operation apply(final OpDcl e) { Operation _operation = Idl2Icm.this.toOperation(e, target); return _operation; } }; IterableExtensions.<OpDcl>forEach(_filter_1, _function); EList<Export> _exports_1 = source.getExports(); Iterable<TypeDcl> _filter_2 = IterableExtensions.<TypeDcl>filter(_exports_1, com.csg.cs.tools.mdgen.idl.idl.TypeDcl.class); final Function1<TypeDcl,TypeDef> _function_1 = new Function1<TypeDcl,TypeDef>() { public TypeDef apply(final TypeDcl e_1) { TypeDef _typeDef = Idl2Icm.this.toTypeDef(e_1, target); return _typeDef; } }; IterableExtensions.<TypeDcl>forEach(_filter_2, _function_1); for (InterfaceDcl i : inherits) { EList<StructuralFeature> _features = model.getFeatures(); Iterable<Interface> _filter_3 = IterableExtensions.<Interface>filter(_features, com.csg.cs.tools.mdgen.icm.icmDsl.Interface.class); final Function1<Interface,Boolean> _function_2 = new Function1<Interface,Boolean>() { public Boolean apply(final Interface e_2) { String _name_1 = e_2.getName(); String _name_2 = i.getName(); boolean _operator_equals = ObjectExtensions.operator_equals(_name_1, _name_2); return ((Boolean)_operator_equals); } }; boolean _exists = IterableExtensions.<Interface>exists(_filter_3, _function_2); boolean _operator_not = BooleanExtensions.operator_not(_exists); if (_operator_not) { { EList<InterfaceType> _extends = target.getExtends(); Interface _interface = this.toInterface(i, model); _extends.add(_interface); target.setExtended(true); } } } String _name_3 = target.getName(); String _operator_plus = StringExtensions.operator_plus("Interface created => ", _name_3); this.debug(_operator_plus); return target; } } Reproducible: Always Steps to Reproduce: 1. see details 2. 3.