Example #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;
                    }
                }
Example #2
0
        int IVsSimpleObjectList2.LocateNavInfoNode(IVsNavInfoNode pNavInfoNode, out uint pulIndex)
        {
            if (null == pNavInfoNode)
            {
                throw new ArgumentNullException("pNavInfoNode");
            }
            pulIndex = NullIndex;
            string nodeName = null;

            ThreadHelper.JoinableTaskFactory.Run(async delegate
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                ErrorHandler.ThrowOnFailure(pNavInfoNode.get_Name(out nodeName));
            });
            try
            {
                for (int i = 0; i < children.Count; i++)
                {
                    if (0 == string.Compare(children[i].UniqueName, nodeName, StringComparison.OrdinalIgnoreCase))
                    {
                        pulIndex = (uint)i;
                        return(VSConstants.S_OK);
                    }
                }
            }
            catch (Exception)
            {
            }
            return(VSConstants.S_FALSE);
        }
Example #3
0
        int IVsSimpleObjectList2.LocateNavInfoNode(IVsNavInfoNode pNavInfoNode, out uint pulIndex)
        {
            if (null == pNavInfoNode)
            {
                throw new ArgumentNullException("pNavInfoNode");
            }
            pulIndex = NullIndex;
            string nodeName;

            ErrorHandler.ThrowOnFailure(pNavInfoNode.get_Name(out nodeName));
            try
            {
                for (int i = 0; i < children.Count; i++)
                {
                    if (0 == string.Compare(children[i].UniqueName, nodeName, StringComparison.OrdinalIgnoreCase))
                    {
                        pulIndex = (uint)i;
                        return(VSConstants.S_OK);
                    }
                }
            }
            catch (Exception)
            {
            }
            return(VSConstants.S_FALSE);
        }
Example #4
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);
        }
Example #5
0
        int IVsSimpleObjectList2.GetNavInfoNode(uint index, out IVsNavInfoNode ppNavInfoNode)
        {
            ppNavInfoNode = GetNavInfoNode(index);

            return(ppNavInfoNode != null
                ? VSConstants.S_OK
                : VSConstants.E_NOTIMPL);
        }
Example #6
0
        /// <summary>
        ///     Reserved for future use.
        /// </summary>
        /// <param name="index"></param>
        /// <param name="ppNavInfoNode"></param>
        /// <returns></returns>
        public int GetNavInfoNode(uint index, out IVsNavInfoNode ppNavInfoNode)
        {
            //Logger.Log("ResultList.GetNavInfoNode");
            ppNavInfoNode = children[(int)index];
            return(VSConstants.S_OK);

            throw new NotImplementedException();
        }
 int IVsSimpleObjectList2.GetNavInfoNode(uint index, out IVsNavInfoNode ppNavInfoNode)
 {
     if (index >= (uint)children.Count)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     ppNavInfoNode = children[(int)index] as IVsNavInfoNode;
     return(VSConstants.S_OK);
 }
Example #8
0
        int IVsSimpleObjectList2.LocateNavInfoNode(IVsNavInfoNode pNavInfoNode, out uint pulIndex)
        {
            if (!SupportsNavInfo)
            {
                pulIndex = 0;
                return(VSConstants.E_NOTIMPL);
            }

            return(TryLocateNavInfoNode(pNavInfoNode, out pulIndex)
                ? VSConstants.S_OK
                : VSConstants.E_FAIL);
        }
Example #9
0
        public int Next(uint celt, IVsNavInfoNode[] rgelt, out uint pceltFetched)
        {
            var i = 0;
            for (; i < celt && _index < _nodes.Length; i++, _index++)
            {
                rgelt[i] = _nodes[_index];
            }

            pceltFetched = (uint)i;

            return i < celt
                ? VSConstants.S_FALSE
                : VSConstants.S_OK;
        }
        int IVsSimpleObjectList2.GetNavInfoNode(uint index, out IVsNavInfoNode ppNavInfoNode)
        {
            SQObjectLibraryNode node;

            if (GetChild(index, out node))
            {
                ppNavInfoNode = node;
                return(VSConstants.S_OK);
            }
            else
            {
                ppNavInfoNode = null;
                return(VSConstants.S_FALSE);
            }
        }
        int IVsSimpleObjectList2.LocateNavInfoNode(IVsNavInfoNode pNavInfoNode, out uint pulIndex)
        {
            int id = Children.IndexOf((SQObjectLibraryNode)pNavInfoNode);

            if (id == -1)
            {
                pulIndex = NullIndex;
                return(VSConstants.S_FALSE);
            }
            else
            {
                pulIndex = (uint)id;
                return(VSConstants.S_OK);
            }
        }
Example #12
0
        int IVsSimpleObjectList2.LocateNavInfoNode(IVsNavInfoNode pNavInfoNode, out uint pulIndex)
        {
            Utilities.ArgumentNotNull(nameof(pNavInfoNode), pNavInfoNode);

            pulIndex = NullIndex;
            ErrorHandler.ThrowOnFailure(pNavInfoNode.get_Name(out var nodeName));
            for (var i = 0; i < this.children.Count; i++)
            {
                if (StringComparer.OrdinalIgnoreCase.Equals(this.children[i].UniqueName, nodeName))
                {
                    pulIndex = (uint)i;
                    return(VSConstants.S_OK);
                }
            }
            return(VSConstants.S_FALSE);
        }
Example #13
0
        int IVsSimpleObjectList2.LocateNavInfoNode(IVsNavInfoNode pNavInfoNode, out uint pulIndex)
        {
            Utilities.ArgumentNotNull("pNavInfoNode", pNavInfoNode);

            pulIndex = NullIndex;
            string nodeName;

            ErrorHandler.ThrowOnFailure(pNavInfoNode.get_Name(out nodeName));
            for (int i = 0; i < _children.Count; i++)
            {
                if (0 == string.Compare(_children[i].UniqueName, nodeName, StringComparison.OrdinalIgnoreCase))
                {
                    pulIndex = (uint)i;
                    return(VSConstants.S_OK);
                }
            }
            return(VSConstants.S_FALSE);
        }
Example #14
0
 int IVsSimpleObjectList2.GetNavInfoNode(uint index, out IVsNavInfoNode ppNavInfoNode)
 {
     ppNavInfoNode = null;
     if (!XSolution.IsClosing)
     {
         if (index >= (uint)children.Count)
         {
             throw new ArgumentOutOfRangeException("index");
         }
         IVsNavInfoNode navinfo = null;
         ThreadHelper.JoinableTaskFactory.Run(async delegate
         {
             await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
             navinfo = children[(int)index] as IVsNavInfoNode;
         });
         ppNavInfoNode = navinfo;
     }
     return(VSConstants.S_OK);
 }
Example #15
0
        /// <summary>
        /// Reserved for future use.
        /// </summary>
        /// <param name="pNavInfoNode"></param>
        /// <param name="pulIndex"></param>
        /// <returns></returns>
        public int LocateNavInfoNode(IVsNavInfoNode pNavInfoNode, out uint pulIndex)
        {
            //Logger.Log("ResultList.LocateNavInfoNode   ");

            string needleName = string.Empty;

            pNavInfoNode.get_Name(out needleName);
            var index = 0;

            foreach (var c in children)
            {
                string nodeName = string.Empty;
                ((IVsNavInfoNode)c).get_Name(out nodeName);
                if (string.Compare(needleName, nodeName) == 0)
                {
                    pulIndex = (uint)index;
                    return(VSConstants.S_OK);
                }
                index++;
            }
            pulIndex = 0;
            return(VSConstants.E_FAIL);
        }
Example #16
0
 protected virtual bool TryLocateNavInfoNode(IVsNavInfoNode pNavInfoNode, out uint index)
 {
     index = 0;
     return(false);
 }
 int IVsSimpleObjectList2.LocateNavInfoNode(IVsNavInfoNode pNavInfoNode, out uint pulIndex)
 {
     if (null == pNavInfoNode) {
         throw new ArgumentNullException("pNavInfoNode");
     }
     pulIndex = NullIndex;
     string nodeName;
     ErrorHandler.ThrowOnFailure(pNavInfoNode.get_Name(out nodeName));
     for (int i = 0; i < children.Count; i++ ) {
         if (0 == string.Compare(children[i].UniqueName, nodeName, StringComparison.OrdinalIgnoreCase)) {
             pulIndex = (uint)i;
             return VSConstants.S_OK;
         }
     }
     return VSConstants.S_FALSE;
 }
 int IVsSimpleObjectList2.GetNavInfoNode(uint index, out IVsNavInfoNode ppNavInfoNode)
 {
     if (index >= (uint)children.Count) {
         throw new ArgumentOutOfRangeException("index");
     }
     ppNavInfoNode = children[(int)index] as IVsNavInfoNode;
     return VSConstants.S_OK;
 }
Example #19
0
 /// <summary>
 /// 	Reserved for future use.
 /// </summary>
 /// <param name="index"></param>
 /// <param name="ppNavInfoNode"></param>
 /// <returns></returns>
 public int GetNavInfoNode(uint index, out IVsNavInfoNode ppNavInfoNode)
 {
     //Logger.Log("ResultList.GetNavInfoNode");
     ppNavInfoNode = children[(int)index];
     return VSConstants.S_OK;
 }
Example #20
0
 /// <summary>
 /// 	Reserved for future use.
 /// </summary>
 /// <param name="index"></param>
 /// <param name="ppNavInfoNode"></param>
 /// <returns></returns>
 public int GetNavInfoNode(uint index, out IVsNavInfoNode ppNavInfoNode)
 {
     //Logger.Log("ResultList.GetNavInfoNode");
     ppNavInfoNode = children[(int)index];
     return VSConstants.S_OK;
     throw new NotImplementedException();
 }
Example #21
0
        private void AddLibraryContent(TreeViewItem libRoot, TreeViewItem expander, IVsCombinedBrowseComponentSet extras, IVsLibrary2 lib)
        {
            if (lib == null)
                return;

            if (libRoot.Items.Count != 1 || libRoot.Items[0] != expander)
                return;
            libRoot.Items.Clear();

            var simpleLib = lib as IVsSimpleLibrary2;

            uint libFlags;
            ErrorHandler.Succeeded(lib.GetLibFlags2(out libFlags));

            var flags = "";
            if ((libFlags & (uint)_LIB_FLAGS.LF_EXPANDABLE) != 0)
                flags += "|LF_EXPANDABLE";
            if ((libFlags & (uint)_LIB_FLAGS.LF_GLOBAL) != 0)
                flags += "|LF_GLOBAL";
            if ((libFlags & (uint)_LIB_FLAGS.LF_HIDEINLIBPICKER) != 0)
                flags += "|LF_HIDEINLIBPICKER";
            if ((libFlags & (uint)_LIB_FLAGS.LF_PROJECT) != 0)
                flags += "|LF_PROJECT";
            if ((libFlags & (uint)_LIB_FLAGS2.LF_SUPPORTSBASETYPES) != 0)
                flags += "|LF_SUPPORTSBASETYPES";
            if ((libFlags & (uint)_LIB_FLAGS2.LF_SUPPORTSCALLBROWSER) != 0)
                flags += "|LF_SUPPORTSCALLBROWSER";
            if ((libFlags & (uint)_LIB_FLAGS2.LF_SUPPORTSCLASSDESIGNER) != 0)
                flags += "|LF_SUPPORTSCLASSDESIGNER";
            if ((libFlags & (uint)_LIB_FLAGS2.LF_SUPPORTSDERIVEDTYPES) != 0)
                flags += "|LF_SUPPORTSDERIVEDTYPES";
            if ((libFlags & (uint)_LIB_FLAGS2.LF_SUPPORTSFILTERING) != 0)
                flags += "|LF_SUPPORTSFILTERING";
            if ((libFlags & (uint)_LIB_FLAGS2.LF_SUPPORTSFILTERINGWITHEXPANSION) != 0)
                flags += "|LF_SUPPORTSFILTERINGWITHEXPANSION";
            if ((libFlags & (uint)_LIB_FLAGS2.LF_SUPPORTSINHERITEDMEMBERS) != 0)
                flags += "|LF_SUPPORTSINHERITEDMEMBERS";
            if ((libFlags & (uint)_LIB_FLAGS2.LF_SUPPORTSLISTREFERENCES) != 0)
                flags += "|LF_SUPPORTSLISTREFERENCES";
            if ((libFlags & (uint)_LIB_FLAGS2.LF_SUPPORTSPRIVATEMEMBERS) != 0)
                flags += "|LF_SUPPORTSPRIVATEMEMBERS";
            if ((libFlags & (uint)_LIB_FLAGS2.LF_SUPPORTSPROJECTREFERENCES) != 0)
                flags += "|LF_SUPPORTSPROJECTREFERENCES";
            flags = flags.Substring(1);

            Guid libGuid;
            ErrorHandler.Succeeded(simpleLib.GetGuid(out libGuid));

            IVsNavInfo navInfo = null;

            var rc = VSConstants.E_NOTIMPL;
            //for (var i = (uint)0; navInfo==null && i<32 && rc != VSConstants.S_OK; i++)
            //{
            //    //rc = extras.CreateNavInfo(
            //    //    libGuid,
            //    //    new[]
            //    //        {
            //    //            new SYMBOL_DESCRIPTION_NODE {dwType = (uint)(0), pszName = "ClassLibrary12"},
            //    //        },
            //    //    1,
            //    //    out navInfo
            //    //    );
            //    //if (rc == VSConstants.S_OK)
            //    //    break;
            rc = extras.CreateNavInfo(
                libGuid,
                new[]
                        {
                            new SYMBOL_DESCRIPTION_NODE {dwType = (uint)_LIB_LISTTYPE.LLT_NAMESPACES, pszName = "ClassLibrary3"},
                        },
                1,
                out navInfo
                );
            //}

            var navInfoRoot = new TreeViewItem { Header = "NavInfo (rc=" + rc + ")" };
            if (rc == VSConstants.S_OK)
            {
                Guid symbolGuid;
                ErrorHandler.Succeeded(navInfo.GetLibGuid(out symbolGuid));
                navInfoRoot.Items.Add("Guid=" + symbolGuid);
                uint symbolType;
                ErrorHandler.Succeeded(navInfo.GetSymbolType(out symbolType));
                var symbolTypeString = Enum.GetName(typeof(_LIB_LISTTYPE), symbolType);
                if (symbolTypeString != null)
                {
                    navInfoRoot.Items.Add("Type = _LIB_LISTTYPE." + symbolTypeString);
                }
                else
                {
                    symbolTypeString = Enum.GetName(typeof(_LIB_LISTTYPE2), symbolType);
                    if (symbolTypeString != null)
                    {
                        navInfoRoot.Items.Add("Type = _LIB_LISTTYPE2." + symbolTypeString);
                    }
                    else
                    {
                        navInfoRoot.Items.Add("Type = " + symbolType);
                    }
                }

                IVsEnumNavInfoNodes infoNodes;
                ErrorHandler.Succeeded(navInfo.EnumCanonicalNodes(out infoNodes));
                var navInfoNodesArray = new IVsNavInfoNode[20];
                uint fetched;
                ErrorHandler.Succeeded(infoNodes.Next((uint)navInfoNodesArray.Length, navInfoNodesArray, out fetched));
                if (fetched > 0)
                {
                    var navNodes = new TreeViewItem { Header = "Nodes" };
                    foreach (var node in navInfoNodesArray)
                    {
                        if (node == null)
                            continue;
                        string nodeName;
                        ErrorHandler.Succeeded(node.get_Name(out nodeName));
                        uint nodeType;
                        ErrorHandler.Succeeded(node.get_Type(out nodeType));
                        var nodeTypeString = Enum.GetName(typeof(_LIB_LISTTYPE), nodeType);
                        if (nodeTypeString != null)
                        {
                            navNodes.Items.Add(nodeName + "(_LIB_LISTTYPE." + nodeTypeString + ")");
                        }
                        else
                        {
                            nodeTypeString = Enum.GetName(typeof(_LIB_LISTTYPE2), symbolType);
                            if (symbolTypeString != null)
                            {
                                navNodes.Items.Add(nodeName + "(_LIB_LISTTYPE." + nodeTypeString + ")");
                            }
                            else
                            {
                                navNodes.Items.Add(nodeName + "(" + symbolType + ")");
                            }
                        }
                    }
                }

            }
            libRoot.Items.Add(navInfoRoot);

            libRoot.Items.Add("Flags=" + flags);

            IVsLiteTreeList globalLibs;
            ErrorHandler.Succeeded(lib.GetLibList(LIB_PERSISTTYPE.LPT_GLOBAL, out globalLibs));
            AddLibList(libRoot, "Global", globalLibs);

            IVsLiteTreeList projectLibs;
            ErrorHandler.Succeeded(lib.GetLibList(LIB_PERSISTTYPE.LPT_PROJECT, out projectLibs));
            AddLibList(libRoot, "Project", globalLibs);

            AddNested(lib, libRoot, _LIB_LISTTYPE.LLT_NAMESPACES);

            AddNested(lib, libRoot, _LIB_LISTTYPE.LLT_CLASSES);

            AddNested(lib, libRoot, _LIB_LISTTYPE.LLT_MEMBERS);

            AddNested(lib, libRoot, _LIB_LISTTYPE.LLT_REFERENCES);
            //expander.Items.Add(libRoot);
        }
Example #22
0
        /// <summary>
        /// Reserved for future use.
        /// </summary>
        /// <param name="pNavInfoNode"></param>
        /// <param name="pulIndex"></param>
        /// <returns></returns>
        public int LocateNavInfoNode(IVsNavInfoNode pNavInfoNode, out uint pulIndex)
        {
            //Logger.Log("ResultList.LocateNavInfoNode   ");

            string needleName = string.Empty;
            pNavInfoNode.get_Name(out needleName);
            var index = 0;
            foreach(var c in children)
            {
                string nodeName = string.Empty;
                ((IVsNavInfoNode)c).get_Name(out nodeName);
                if (string.Compare(needleName, nodeName) == 0)
                {
                    pulIndex = (uint)index;
                    return VSConstants.S_OK;
                }
                index++;
            }
            pulIndex = 0;
            return VSConstants.E_FAIL;
        }
Example #23
0
        private IEnumerable <SelectedItem> GetCurrentSelections()
        {
            var navTools = this.GetService(typeof(SVsObjBrowser)) as IVsNavigationTool;

            if (navTools == null)
            {
                yield break;
            }

            IVsSelectedSymbols symbols;
            int hresult = navTools.GetSelectedSymbols(out symbols);

            Marshal.ThrowExceptionForHR(hresult);

            uint count;

            hresult = symbols.GetCount(out count);
            Marshal.ThrowExceptionForHR(hresult);

            for (uint i = 0; i < count; ++i)
            {
                IVsSelectedSymbol symbol;
                hresult = symbols.GetItem(i, out symbol);
                Marshal.ThrowExceptionForHR(hresult);

                string name;
                hresult = symbol.GetName(out name);
                Marshal.ThrowExceptionForHR(hresult);

                IVsNavInfo navInfo;
                hresult = symbol.GetNavInfo(out navInfo);
                Marshal.ThrowExceptionForHR(hresult);

                uint symType;
                hresult = navInfo.GetSymbolType(out symType);
                Marshal.ThrowExceptionForHR(hresult);

                switch ((_LIB_LISTTYPE)symType)
                {
                case _LIB_LISTTYPE.LLT_CLASSES:     // type
                    IVsEnumNavInfoNodes enin;
                    hresult = navInfo.EnumCanonicalNodes(out enin);
                    Marshal.ThrowExceptionForHR(hresult);

                    IVsNavInfoNode[] nodes = new IVsNavInfoNode[1];
                    uint             fetched;

                    while (enin.Next(1, nodes, out fetched) >= 0 && fetched == 1)
                    {
                        var node = nodes[0];

                        uint type2;

                        hresult = node.get_Type(out type2);
                        Marshal.ThrowExceptionForHR(hresult);

                        if (type2 != (uint)_LIB_LISTTYPE.LLT_PHYSICALCONTAINERS)
                        {
                            continue;
                        }

                        string name2;
                        hresult = node.get_Name(out name2);
                        Marshal.ThrowExceptionForHR(hresult);

                        var    asmName  = AssemblyName.GetAssemblyName(name2);
                        string typeName = Assembly.CreateQualifiedName(asmName.FullName, name);

                        yield return(new SelectedItem
                        {
                            Name = typeName,
                            Type = ItemType.Type
                        });
                    }

                    break;

                case _LIB_LISTTYPE.LLT_PHYSICALCONTAINERS:     // assembly
                    var asmName2 = AssemblyName.GetAssemblyName(name);

                    yield return(new SelectedItem
                    {
                        Name = asmName2.FullName,
                        Type = ItemType.Type
                    });

                    break;

                default:
                    break;
                }
            }
        }