Пример #1
0
        void UpdateOutlineSelection(object sender, Mono.TextEditor.DocumentLocationEventArgs e)
        {
            if (clickedOnOutlineItem || SyntaxTree == null || TreeStore == null)
            {
                return;
            }

            var caretLocation  = Document.Editor.Caret.Location;
            var caretLocationD = new CodeLocation(caretLocation.Column, caretLocation.Line);

            var currentblock = DResolver.SearchBlockAt(SyntaxTree, caretLocationD);

            INode selectedASTNode = null;

            if (currentblock == null)
            {
                return;
            }

            foreach (var n in currentblock)
            {
                if (caretLocationD >= n.Location && caretLocationD <= n.EndLocation)
                {
                    selectedASTNode = n;
                    break;
                }
            }

            // Select parameter node if needed
            if (selectedASTNode == null && currentblock is DMethod)
            {
                foreach (var n in (currentblock as DMethod).Parameters)
                {
                    if (caretLocationD >= n.Location && caretLocationD <= n.EndLocation)
                    {
                        selectedASTNode = n;
                        break;
                    }
                }
            }

            if (selectedASTNode == null)
            {
                selectedASTNode = currentblock;
            }

            if (selectedASTNode == null)
            {
                return;
            }

            TreeStore.Foreach((TreeModel model, TreePath path, TreeIter iter) =>
            {
                var n = model.GetValue(iter, 0);
                if (n == selectedASTNode)
                {
                    dontJumpToDeclaration = true;
                    //var parentPath = path.Copy().Up();

                    TreeView.ExpandToPath(path);
                    TreeView.Selection.SelectIter(iter);
                    dontJumpToDeclaration = false;

                    return(true);
                }

                return(false);
            });
        }
Пример #2
0
        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);
            });
        }