void UpdateOutlineSelection(object sender, Mono.TextEditor.DocumentLocationEventArgs e) { if (clickedOnOutlineItem || SyntaxTree == null || TreeStore == null) { return; } IStatement stmt = null; var caretLocation = Document.Editor.Caret.Location; var caretLocationD = new CodeLocation(caretLocation.Column, caretLocation.Line); var currentblock = DResolver.SearchBlockAt(SyntaxTree, caretLocationD, out stmt); INode selectedASTNode = null; if (currentblock == null) { return; } foreach (var n in currentblock) { if (caretLocationD >= n.Location && caretLocationD <= n.EndLocation) { selectedASTNode = n; break; } } if (selectedASTNode == null) { selectedASTNode = stmt != null ? stmt.ParentNode : currentblock; } if (selectedASTNode == null) { return; } if (lastExpanded != null) { if (TreeView.GetRowExpanded(lastExpanded)) { TreeView.CollapseRow(lastExpanded); } } TreeStore.Foreach((TreeModel model, TreePath path, TreeIter iter) => { var n = model.GetValue(iter, 0); if (n == selectedASTNode) { dontJumpToDeclaration = true; TreePath parentPath = path.Copy(); parentPath.Up(); if (!TreeView.GetRowExpanded(parentPath)) { lastExpanded = parentPath.Copy(); } TreeView.ExpandToPath(path); TreeView.Selection.SelectIter(iter); dontJumpToDeclaration = false; return(true); } return(false); }); }