Ejemplo n.º 1
0
        protected override bool TryLocateNavInfoNode(IVsNavInfoNode pNavInfoNode, out uint index)
        {
            var itemCount = GetItemCount();

            index = 0xffffffffu;
            if (ErrorHandler.Failed(pNavInfoNode.get_Name(out var matchName)))
            {
                return(false);
            }

            if (ErrorHandler.Failed(pNavInfoNode.get_Type(out _)))
            {
                return(false);
            }

            var longestMatchedName = string.Empty;

            for (uint i = 0; i < itemCount; i++)
            {
                var name = GetText(i, VSTREETEXTOPTIONS.TTO_DISPLAYTEXT);

                if (_kind is ObjectListKind.Types or
                    ObjectListKind.Namespaces or
                    ObjectListKind.Members)
                {
                    if (string.Equals(matchName, name, StringComparison.Ordinal))
                    {
                        index = i;
                        break;
                    }
                }
Ejemplo n.º 2
0
        protected override bool TryLocateNavInfoNode(IVsNavInfoNode pNavInfoNode, out uint index)
        {
            var itemCount = GetItemCount();

            index = 0xffffffffu;

            string matchName;

            if (ErrorHandler.Failed(pNavInfoNode.get_Name(out matchName)))
            {
                return(false);
            }

            uint type;

            if (ErrorHandler.Failed(pNavInfoNode.get_Type(out type)))
            {
                return(false);
            }

            var longestMatchedName = string.Empty;

            for (uint i = 0; i < itemCount; i++)
            {
                var name = GetText(i, VSTREETEXTOPTIONS.TTO_DISPLAYTEXT);

                if (_kind == ObjectListKind.Types ||
                    _kind == ObjectListKind.Namespaces ||
                    _kind == ObjectListKind.Members)
                {
                    if (string.Equals(matchName, name, StringComparison.Ordinal))
                    {
                        index = i;
                        break;
                    }
                }
                else
                {
                    if (string.Equals(matchName, name, StringComparison.Ordinal))
                    {
                        index = i;
                        break;
                    }
                    else if (_kind == ObjectListKind.Projects)
                    {
                        if (matchName.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            if (longestMatchedName.Length < name.Length)
                            {
                                longestMatchedName = name;
                                index = i;
                            }
                        }
                    }
                }
            }

            return(index != 0xffffffffu);
        }