bool Visit(BlockBase b, Node n, int offset) { n.BlockBase = b; // Check if we are not inside the right node if (!(n.StartOffset < offset && n.EndOffset >= offset)) { return(false); } NodePath.Add(n); // Add metaproperties from lambda draw. var metaProperties = new List <MetaProperty>(); foreach (var i in b.Members) { if (i.Type == BlockMemberType.Apply) { var applyItem = i as Apply; if (applyItem.Block.Parent == b) { foreach (var c in applyItem.Block.Members) { if (c.Type == BlockMemberType.MetaProperty) { metaProperties.Add(c as MetaProperty); } } } } } if (n.Children != null) { foreach (var c in n.Children) { foreach (var db in b.EnumerateNestedScopes()) { if (Visit(db, c, offset)) { return(true); } } if (c.Type == NodeType.MetaProperty) { foreach (var m in metaProperties) { if (m.Name == c.Name) { if (Visit(m, c, offset)) { return(true); } } } } foreach (var i in b.Members) { if (i.Type == BlockMemberType.Apply && c.Type == NodeType.Apply) { c.ApplyItem = i as Apply; continue; } if (i.Type == BlockMemberType.MetaProperty && c.Type == NodeType.MetaProperty) { var mp = i as MetaProperty; if (mp.Name == c.Name) { if (Visit(mp, c, offset)) { return(true); } } } } if (Visit(b, c, offset)) { return(true); } } } return(true); }