示例#1
0
文件: Library.cs 项目: ugurak/nemerle
        /// <summary>
        /// Этот метод один для целой кучи функциональности: Find All References, Calls From, Calls To, и других
        /// </summary>
        public int GetList2(
            uint ListType,
            uint flags,
            VSOBSEARCHCRITERIA2[]   pobSrch,
            out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            if ((_findResults != null) && (pobSrch != null) && (pobSrch.Length == 1) && (pobSrch[0].dwCustom == FindAllReferencesMagicNum))
            {            //если _findResults заполнены, то возвращаем их
                ppIVsSimpleObjectList2 = _findResults;
                _findResults           = null;
                return(VSConstants.S_OK);
            }

            //TODO: (hi_octane) хочу подключить CallBrowser
            //TODO: for CallBrowser (Calls From, Calls To), we need to follow these article:
            // По реализации CallBrowser что-то есть здесь:
            // http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/8bc7d011-57c5-4aef-813a-a5a38170ae68/
            // и более подробно здесь:
            // http://msdn.microsoft.com/en-us/library/bb164614(v=VS.90).aspx - VS2008, работает и в 2010
            // http://msdn.microsoft.com/en-us/library/bb164724.aspx - VS2010
            // про работу с CallBrowser через CodeModel посылают сюда:
            // http://msdn.microsoft.com/en-us/library/ms228770.aspx

            ppIVsSimpleObjectList2 = _root;
            return(VSConstants.S_OK);
        }
        int IVsSimpleLibrary2.GetList2(uint listType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            ppIVsSimpleObjectList2 = GetList(listType, flags, pobSrch);

            return ppIVsSimpleObjectList2 != null
                ? VSConstants.S_OK
                : VSConstants.E_FAIL;
        }
示例#3
0
 public int GetList2(
     uint					 ListType,
     uint					 flags,
     VSOBSEARCHCRITERIA2[]	pobSrch,
     out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
 {
     ppIVsSimpleObjectList2 = _root;
     return VSConstants.S_OK;
 }
示例#4
0
文件: Library.cs 项目: ugurak/nemerle
 public int GetList2(
     uint ListType,
     uint flags,
     VSOBSEARCHCRITERIA2[]   pobSrch,
     out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
 {
     ppIVsSimpleObjectList2 = _root;
     return(VSConstants.S_OK);
 }
示例#5
0
        public int GetList2(uint ListType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2) {
            if ((flags & (uint)_LIB_LISTFLAGS.LLF_RESOURCEVIEW) != 0) {
                ppIVsSimpleObjectList2 = null;
                return VSConstants.E_NOTIMPL;
            }

            ICustomSearchListProvider listProvider;
            if(pobSrch != null && 
                pobSrch.Length > 0) {
                if ((listProvider = pobSrch[0].pIVsNavInfo as ICustomSearchListProvider) != null) {
                    switch ((_LIB_LISTTYPE)ListType) {
                        case _LIB_LISTTYPE.LLT_NAMESPACES:
                            ppIVsSimpleObjectList2 = listProvider.GetSearchList();
                            break;
                        default:
                            ppIVsSimpleObjectList2 = null;
                            return VSConstants.E_FAIL;
                    }
                } else {
                    if (pobSrch[0].eSrchType == VSOBSEARCHTYPE.SO_ENTIREWORD && ListType == (uint)_LIB_LISTTYPE.LLT_MEMBERS) {
                        string srchText = pobSrch[0].szName;
                        int colonIndex;
                        if ((colonIndex = srchText.LastIndexOf(':')) != -1) {
                            string filename = srchText.Substring(0, srchText.LastIndexOf(':'));
                            foreach (ProjectLibraryNode project in _root.Children) {
                                foreach (var item in project.Children) {
                                    if (item.FullName == filename) {
                                        ppIVsSimpleObjectList2 = item.DoSearch(pobSrch[0]);
                                        if (ppIVsSimpleObjectList2 != null) {
                                            return VSConstants.S_OK;
                                        }
                                    }
                                }
                            }
                        }

                        ppIVsSimpleObjectList2 = null;
                        return VSConstants.E_FAIL;
                    } else if (pobSrch[0].eSrchType == VSOBSEARCHTYPE.SO_SUBSTRING && ListType == (uint)_LIB_LISTTYPE.LLT_NAMESPACES) {
                        var lib = new LibraryNode(null, "Search results " + pobSrch[0].szName, "Search results " + pobSrch[0].szName, LibraryNodeType.Package);
                        foreach (var item in SearchNodes(pobSrch[0], new SimpleObjectList<LibraryNode>(), _root).Children) {
                            lib.Children.Add(item);
                        }
                        ppIVsSimpleObjectList2 = lib;
                        return VSConstants.S_OK;
                    } else {
                        ppIVsSimpleObjectList2 = null;
                        return VSConstants.E_FAIL;
                    }
                }
            } else {
                ppIVsSimpleObjectList2 = _root as IVsSimpleObjectList2;
            }
            return VSConstants.S_OK;
        }
示例#6
0
        int IVsSimpleLibrary2.GetList2(
            uint listType,
            uint flags,
            VSOBSEARCHCRITERIA2[] pobSrch,
            out IVsSimpleObjectList2 ppIVsSimpleObjectList2
            )
        {
            ppIVsSimpleObjectList2 = GetList(listType, flags, pobSrch);

            return(ppIVsSimpleObjectList2 != null ? VSConstants.S_OK : VSConstants.E_FAIL);
        }
示例#7
0
        /// <summary>
        /// Этот метод один для целой кучи функциональности: Find All References, Calls From, Calls To, и других
        /// </summary>
        public int GetList2(
            uint ListType,
            uint flags,
            VSOBSEARCHCRITERIA2[] pobSrch,
            out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            if ((_findResults != null) && (pobSrch != null) && (pobSrch.Length == 1) && (pobSrch[0].dwCustom == FindAllReferencesMagicNum))
              {//если _findResults заполнены, то возвращаем их
            ppIVsSimpleObjectList2 = _findResults;
            _findResults = null;
            return VSConstants.S_OK;
              }

              ppIVsSimpleObjectList2 = null;
              return VSConstants.E_NOTIMPL;
        }
示例#8
0
文件: Library.cs 项目: rsdn/nitra
        /// <summary>
        /// Этот метод один для целой кучи функциональности: Find All References, Calls From, Calls To, и других
        /// </summary>
        public int GetList2(
            uint ListType,
            uint flags,
            VSOBSEARCHCRITERIA2[] pobSrch,
            out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            if ((_findResults != null) && (pobSrch != null) && (pobSrch.Length == 1) && (pobSrch[0].dwCustom == FindAllReferencesMagicNum))
            {//если _findResults заполнены, то возвращаем их
                ppIVsSimpleObjectList2 = _findResults;
                _findResults           = null;
                return(VSConstants.S_OK);
            }

            ppIVsSimpleObjectList2 = null;
            return(VSConstants.E_NOTIMPL);
        }
示例#9
0
        public int GetList2(uint ListType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            ppIVsSimpleObjectList2 = null;
            int    ret = VSConstants.S_OK;
            string strSearchCriteria = null;

            if (pobSrch != null)
            {
                strSearchCriteria = pobSrch[0].szName;
            }
            //
            IVsSimpleObjectList2 result = null;

            ThreadHelper.JoinableTaskFactory.Run(async delegate
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                switch (ListType)
                {
                case (uint)_LIB_LISTTYPE.LLT_PHYSICALCONTAINERS:
                    result = root as IVsSimpleObjectList2;
                    break;

                case (uint)_LIB_LISTTYPE.LLT_HIERARCHY:
                    // Search in Projects
                    result = SearchNodes(ListType, strSearchCriteria);
                    //ppIVsSimpleObjectList2 = root as IVsSimpleObjectList2;
                    break;

                case (uint)_LIB_LISTTYPE.LLT_NAMESPACES:
                    // Search NameSpaces with the searchCriteria
                    //ppIVsSimpleObjectList2 = root as IVsSimpleObjectList2;
                    result = SearchNodes(ListType, strSearchCriteria);
                    break;

                case (uint)_LIB_LISTTYPE.LLT_MEMBERS:
                    // Search in Members : Classes / Enums / ...
                    //ppIVsSimpleObjectList2 = root as IVsSimpleObjectList2;
                    result = SearchNodes(ListType, strSearchCriteria);
                    break;
                }
            });
            ppIVsSimpleObjectList2 = result;
            return(ret);
        }
 int IVsSimpleObjectList2.GetList2(uint index, uint ListType, uint flagsArg, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
 {
     // TODO: Use the flags and list type to actually filter the result.
     if (index >= (uint)children.Count)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     ppIVsSimpleObjectList2 = children[(int)index].FilterView((LibraryNodeType)ListType);
     return(VSConstants.S_OK);
 }
示例#11
0
        public int GetList2(uint ListType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            #region ...

            /*
             * string strSearchCriteria = pobSrch[0].szName;
             * uint grfOptions = pobSrch[0].grfOptions;
             * IVsNavInfo NavInfo = pobSrch[0].pIVsNavInfo;
             *
             * // Return generated list of symbols to the object manager.
             * ResultList resultsList = new RootMethodsList(this, grfOptions);
             * ppIVsSimpleObjectList2 = (Microsoft.VisualStudio.Shell.Interop.IVsSimpleObjectList2)(resultsList);
             * string strFullNameFromNavInfo;
             *
             * if (((uint)(grfOptions & (uint)Microsoft.VisualStudio.Shell.Interop._VSOBSEARCHOPTIONS2.VSOBSO_CALLSFROM) > 0) &&
             *  ((uint)(grfOptions & (uint)Microsoft.VisualStudio.Shell.Interop._VSOBSEARCHOPTIONS2.VSOBSO_CALLSTO) > 0))
             * {
             *  // Initial view with VSOBSO_CALLSFROM and VSOBSO_CALLSTO flags set simultaneously.
             *  // Generate list of all methods in the container.
             *
             *  foreach (CallInstance call in m_CallGraph)
             *  {
             *      resultsList.AddMethod(call.m_Source);
             *      resultsList.AddMethod(call.m_Target);
             *  }
             *
             * }
             * // Generate CALLFROM list for Call graph.
             * else if ((uint)(grfOptions & (uint)Microsoft.VisualStudio.Shell.Interop._VSOBSEARCHOPTIONS2.VSOBSO_CALLSFROM) > 0)
             * {
             *  System.Collections.Generic.List<CallInstance> Calls = null;
             *
             *  if (NavInfo != null)
             *  {
             *      strFullNameFromNavInfo = CallBrowserNavInfo.GetFullNameFromNavInfo(NavInfo);
             *      Calls = m_CallGraph.GetCallGraph(strFullNameFromNavInfo);
             *  }
             *  else if (strSearchCriteria.Length > 0)
             *  {
             *      Calls = m_CallGraph.GetCallGraph(strSearchCriteria);
             *  }
             *
             *  for (int i = 0; i < Calls.Count; i++)
             *  {
             *      Method method = Calls[i].m_Source;
             *      resultsList.AddMethod(method);
             *  }
             * }
             * // Generate CALLTO list for Callers graph.
             *
             * else if ((uint)(grfOptions & (uint)Microsoft.VisualStudio.Shell.Interop._VSOBSEARCHOPTIONS2.VSOBSO_CALLSTO) > 0)
             * {
             *  System.Collections.Generic.List<CallInstance> Callers = null; // = new System.Collections.Generic.List<CallInstance>();
             *
             *  if (NavInfo != null)
             *  {
             *      strFullNameFromNavInfo = CallBrowserNavInfo.GetFullNameFromNavInfo(NavInfo);
             *      Callers = m_CallGraph.GetCallersGraph(strFullNameFromNavInfo);
             *  }
             *  else if (strSearchCriteria.Length > 0)
             *  {
             *      Callers = m_CallGraph.GetCallersGraph(strSearchCriteria);
             *  }
             *
             *  for (int i = 0; i < Callers.Count; i++)
             *  {
             *      Method method = Callers[i].m_Target;
             *      resultsList.AddMethod(method);
             *  }
             * }
             *
             * return VSConstants.S_OK;
             */

            #endregion

            var listTypeName = Enum.GetName(typeof(_LIB_LISTTYPE), ListType);
            if (listTypeName == "")
            {
                listTypeName = Enum.GetName(typeof(_LIB_LISTTYPE2), ListType);
            }

            Logger.Log(string.Format("GetList2 : Library ListType:{0}({1}) flags: {2}",
                                     Enum.GetName(typeof(_LIB_LISTTYPE2), ListType),
                                     Enum.GetName(typeof(_LIB_LISTTYPE), ListType),
                                     Enum.GetName(typeof(_LIB_LISTFLAGS), flags)));
            if (pobSrch != null)
            {
                ppIVsSimpleObjectList2 = root.FilterView((SymbolNode.LibraryNodeType)ListType, pobSrch);
            }
            else
            {
                ppIVsSimpleObjectList2 = objRoot;
            }
            return(VSConstants.S_OK);


            #region ...
            //for (var i = 0; i < root.Children.Count; i++) {
            //    if (root.Children[i].NodeType == (ResultList.LibraryNodeType)ListType)
            //      root.GetList2(i, ListType, flags, pobSrch, out ppIVsSimpleObjectList2);
            //}


            //if (pobSrch != null)
            //{
            //    /*
            //    if (pobSrch != null)
            //    {
            //    //var txt = pobSrch[0].szName;
            //    //string temp = string.Empty;

            //    //root.GetTextWithOwnership(0, VSTREETEXTOPTIONS.TTO_DEFAULT, out temp);
            //    //if (string.Compare(temp, txt, true) == 0)
            //    //    ppIVsSimpleObjectList2 = root;
            //    //else
            //    //{
            //    //    namespaceNode.GetTextWithOwnership(0, VSTREETEXTOPTIONS.TTO_DEFAULT, out temp);
            //    //    if (string.Compare(temp, txt, true) == 0)
            //    //        ppIVsSimpleObjectList2 = namespaceNode;
            //    //    else
            //    //    {
            //    //        classNode.GetTextWithOwnership(0, VSTREETEXTOPTIONS.TTO_DEFAULT, out temp);
            //    //        if (string.Compare(temp, txt, true) == 0)
            //    //            ppIVsSimpleObjectList2 = classNode;
            //    //        else
            //    //        {
            //    //            ppIVsSimpleObjectList2 = null;
            //    //            return VSConstants.E_FAIL;
            //    //        }
            //    //    }
            //    //}
            //    for (uint i = 0; i < (uint)root.Children.Count; i++)
            //    {
            //        if (string.Compare(root.Children[(int)i].SymbolText, pobSrch[0].szName, true) == 0)
            //        {
            //            IVsSimpleObjectList2 list;
            //            root.GetList2(i, ListType, flags, null, out list);
            //            ppIVsSimpleObjectList2 = list;
            //            return VSConstants.S_OK;
            //        }
            //    }

            //    ppIVsSimpleObjectList2 = null;
            //    return VSConstants.E_FAIL;
            //}
            //     * */
            //    var txt = pobSrch[0].szName;
            //    string temp = string.Empty;

            //    root.GetTextWithOwnership(0, VSTREETEXTOPTIONS.TTO_DEFAULT, out temp);
            //    if (string.Compare(temp, txt, true) == 0)
            //        ppIVsSimpleObjectList2 = root;
            //    else
            //    {
            //        namespaceNode.GetTextWithOwnership(0, VSTREETEXTOPTIONS.TTO_DEFAULT, out temp);
            //        if (string.Compare(temp, txt, true) == 0)
            //            ppIVsSimpleObjectList2 = namespaceNode;
            //        else
            //        {
            //            classNode.GetTextWithOwnership(0, VSTREETEXTOPTIONS.TTO_DEFAULT, out temp);
            //            if (string.Compare(temp, txt, true) == 0)
            //                ppIVsSimpleObjectList2 = classNode;
            //            else
            //            {
            //                ppIVsSimpleObjectList2 = null;
            //                return VSConstants.E_FAIL;
            //            }
            //        }
            //    }

            //    return VSConstants.S_OK;
            //}
            //else
            //{
            //    ppIVsSimpleObjectList2 = root;
            //    return VSConstants.S_OK;
            //}

            //switch (ListType)
            //{
            //    case (uint)_LIB_LISTTYPE.LLT_PHYSICALCONTAINERS: //16
            //        ppIVsSimpleObjectList2 = root;
            //        return VSConstants.S_OK;
            //    case (uint)_LIB_LISTTYPE.LLT_NAMESPACES: //2
            //        ppIVsSimpleObjectList2 = null;
            //        return VSConstants.S_OK;
            //    case (uint)_LIB_LISTTYPE.LLT_CLASSES: //??
            //        ppIVsSimpleObjectList2 = null;
            //        return VSConstants.S_OK;
            //    case (uint)_LIB_LISTTYPE.LLT_MEMBERS: //8
            //        ppIVsSimpleObjectList2 = null;
            //        return VSConstants.E_FAIL;
            //    case (uint)_LIB_LISTTYPE.LLT_REFERENCES: //8192
            //        ppIVsSimpleObjectList2 = null;
            //        return VSConstants.E_FAIL;

            //    default:
            //        ppIVsSimpleObjectList2 = null;
            //        return VSConstants.E_FAIL;
            //}
            #endregion
        }
示例#12
0
        /// <summary>
        /// Returns a child IVsSimpleObjectList2 for the specified category.
        /// </summary>
        /// <param name="index"></param>
        /// <param name="ListType"></param>
        /// <param name="flags"></param>
        /// <param name="pobSrch"></param>
        /// <param name="ppIVsSimpleObjectList2"></param>
        /// <returns></returns>
        public int GetList2(uint index, uint ListType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            //Logger.Log(string.Format(
            //    "ResultList.GetList2 index:{0} ListType: {1}",
            //    index,
            //    Enum.GetName(typeof(_LIB_LISTTYPE), ListType)));

            ppIVsSimpleObjectList2 = children[(int)index].FilterView((LibraryNodeType)ListType, pobSrch);

            return(VSConstants.S_OK);
        }
示例#13
0
 public TypeListItem(IVsSimpleObjectList2 list, uint dwIndex, string sName)
 {
     this.list    = list;
     this.dwIndex = dwIndex;
     this.sName   = sName;
 }             // ctor
示例#14
0
        /// <summary>
        /// Этот метод один для целой кучи функциональности: Find All References, Calls From, Calls To, и других
        /// </summary>
        public int GetList2(
            uint					 ListType,
            uint					 flags,
            VSOBSEARCHCRITERIA2[]	pobSrch,
            out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            if((_findResults != null) && (pobSrch != null) && (pobSrch.Length == 1) && (pobSrch[0].dwCustom == FindAllReferencesMagicNum))
            {//если _findResults заполнены, то возвращаем их
                ppIVsSimpleObjectList2 = _findResults;
                _findResults = null;
                return VSConstants.S_OK;
            }

            //TODO: (hi_octane) хочу подключить CallBrowser
            //TODO: for CallBrowser (Calls From, Calls To), we need to follow these article:
            // По реализации CallBrowser что-то есть здесь:
            // http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/8bc7d011-57c5-4aef-813a-a5a38170ae68/
            // и более подробно здесь:
            // http://msdn.microsoft.com/en-us/library/bb164614(v=VS.90).aspx - VS2008, работает и в 2010
            // http://msdn.microsoft.com/en-us/library/bb164724.aspx - VS2010
            // про работу с CallBrowser через CodeModel посылают сюда:
            // http://msdn.microsoft.com/en-us/library/ms228770.aspx

            ppIVsSimpleObjectList2 = _root;
            return VSConstants.S_OK;
        }
示例#15
0
 /// <summary>
 /// Stores existing "Find All References" results in the _findResults field.
 /// Сохраняет уже готовые результаты поиска "Find All References" в поле _findResults.
 /// </summary>
 public void OnFindAllReferencesDone(IVsSimpleObjectList2 findResults)
 {
     _findResults = findResults;
 }
示例#16
0
        public int GetList2(uint ListType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            ICustomSearchListProvider listProvider;

            if (pobSrch != null &&
                pobSrch.Length > 0)
            {
                if ((listProvider = pobSrch[0].pIVsNavInfo as ICustomSearchListProvider) != null)
                {
                    switch ((_LIB_LISTTYPE)ListType)
                    {
                    case _LIB_LISTTYPE.LLT_NAMESPACES:
                        ppIVsSimpleObjectList2 = listProvider.GetSearchList();
                        break;

                    default:
                        ppIVsSimpleObjectList2 = null;
                        return(VSConstants.E_FAIL);
                    }
                }
                else
                {
                    if (pobSrch[0].eSrchType == VSOBSEARCHTYPE.SO_ENTIREWORD && ListType == (uint)_LIB_LISTTYPE.LLT_MEMBERS)
                    {
                        string srchText = pobSrch[0].szName;
                        int    colonIndex;
                        if ((colonIndex = srchText.LastIndexOf(':')) != -1)
                        {
                            string filename = srchText.Substring(0, srchText.LastIndexOf(':'));

                            foreach (var item in _root.Children)
                            {
                                if (item.FullName == filename)
                                {
                                    ppIVsSimpleObjectList2 = item.DoSearch(pobSrch[0]);
                                    if (ppIVsSimpleObjectList2 != null)
                                    {
                                        return(VSConstants.S_OK);
                                    }
                                }
                            }
                        }

                        ppIVsSimpleObjectList2 = null;
                        return(VSConstants.E_FAIL);
                    }
                    else if (pobSrch[0].eSrchType == VSOBSEARCHTYPE.SO_SUBSTRING && ListType == (uint)_LIB_LISTTYPE.LLT_NAMESPACES)
                    {
                        var lib = new LibraryNode("Search results " + pobSrch[0].szName, "Search results " + pobSrch[0].szName, LibraryNodeType.Package);
                        foreach (var item in SearchNodes(pobSrch[0], new SimpleObjectList <LibraryNode>(), _root).Children)
                        {
                            lib.Children.Add(item);
                        }
                        ppIVsSimpleObjectList2 = lib;
                        return(VSConstants.S_OK);
                    }
                    else
                    {
                        ppIVsSimpleObjectList2 = null;
                        return(VSConstants.E_FAIL);
                    }
                }
            }
            else
            {
                ppIVsSimpleObjectList2 = _root as IVsSimpleObjectList2;
            }
            return(VSConstants.S_OK);
        }
示例#17
0
        public int GetList2(uint ListType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            if ((flags & (uint)_LIB_LISTFLAGS.LLF_RESOURCEVIEW) != 0)
            {
                ppIVsSimpleObjectList2 = null;
                return(VSConstants.E_NOTIMPL);
            }

            ICustomSearchListProvider listProvider;

            if (pobSrch != null &&
                pobSrch.Length > 0)
            {
                if ((listProvider = pobSrch[0].pIVsNavInfo as ICustomSearchListProvider) != null)
                {
                    switch ((_LIB_LISTTYPE)ListType)
                    {
                    case _LIB_LISTTYPE.LLT_NAMESPACES:
                        ppIVsSimpleObjectList2 = listProvider.GetSearchList();
                        break;

                    default:
                        ppIVsSimpleObjectList2 = null;
                        return(VSConstants.E_FAIL);
                    }
                }
                else
                {
                    if (pobSrch[0].eSrchType == VSOBSEARCHTYPE.SO_ENTIREWORD && ListType == (uint)_LIB_LISTTYPE.LLT_MEMBERS)
                    {
                        string srchText = pobSrch[0].szName;
                        int    colonIndex;
                        if ((colonIndex = srchText.LastIndexOf(':')) != -1)
                        {
                            string filename = srchText.Substring(0, srchText.LastIndexOf(':'));
                            foreach (ProjectLibraryNode project in _root.Children)
                            {
                                foreach (var item in project.Children)
                                {
                                    if (item.FullName == filename)
                                    {
                                        ppIVsSimpleObjectList2 = item.DoSearch(pobSrch[0]);
                                        if (ppIVsSimpleObjectList2 != null)
                                        {
                                            return(VSConstants.S_OK);
                                        }
                                    }
                                }
                            }
                        }

                        ppIVsSimpleObjectList2 = null;
                        return(VSConstants.E_FAIL);
                    }
                    else if (pobSrch[0].eSrchType == VSOBSEARCHTYPE.SO_SUBSTRING && ListType == (uint)_LIB_LISTTYPE.LLT_NAMESPACES)
                    {
                        var lib = new LibraryNode(null, "Search results " + pobSrch[0].szName, "Search results " + pobSrch[0].szName, LibraryNodeType.Package);
                        foreach (var item in SearchNodes(pobSrch[0], new SimpleObjectList <LibraryNode>(), _root).Children)
                        {
                            lib.Children.Add(item);
                        }
                        ppIVsSimpleObjectList2 = lib;
                        return(VSConstants.S_OK);
                    }
                    else if ((pobSrch[0].grfOptions & (uint)_VSOBSEARCHOPTIONS.VSOBSO_LOOKINREFS) != 0 &&
                             ListType == (uint)_LIB_LISTTYPE.LLT_HIERARCHY)
                    {
                        LibraryNode node = pobSrch[0].pIVsNavInfo as LibraryNode;
                        if (node != null)
                        {
                            var refs = node.FindReferences();
                            if (refs != null)
                            {
                                ppIVsSimpleObjectList2 = refs;
                                return(VSConstants.S_OK);
                            }
                        }
                    }
                    ppIVsSimpleObjectList2 = null;
                    return(VSConstants.E_FAIL);
                }
            }
            else
            {
                ppIVsSimpleObjectList2 = _root as IVsSimpleObjectList2;
            }
            return(VSConstants.S_OK);
        }
示例#18
0
        public int GetList2(uint ListType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            ppIVsSimpleObjectList2 = null;
            int    ret = VSConstants.S_OK;
            string strSearchCriteria = null;

            if (pobSrch != null)
            {
                strSearchCriteria = pobSrch[0].szName;
            }
            //
            switch (ListType)
            {
            case (uint)_LIB_LISTTYPE.LLT_PHYSICALCONTAINERS:
                ppIVsSimpleObjectList2 = root as IVsSimpleObjectList2;
                break;

            case (uint)_LIB_LISTTYPE.LLT_HIERARCHY:
                // Search in Projects
                ppIVsSimpleObjectList2 = SearchNodes(ListType, strSearchCriteria);
                //ppIVsSimpleObjectList2 = root as IVsSimpleObjectList2;
                break;

            case (uint)_LIB_LISTTYPE.LLT_NAMESPACES:
                // Search NameSpaces with the searchCriteria
                //ppIVsSimpleObjectList2 = root as IVsSimpleObjectList2;
                ppIVsSimpleObjectList2 = SearchNodes(ListType, strSearchCriteria);
                break;

            case (uint)_LIB_LISTTYPE.LLT_MEMBERS:
                // Search in Members : Classes / Enums / ...
                //ppIVsSimpleObjectList2 = root as IVsSimpleObjectList2;
                ppIVsSimpleObjectList2 = SearchNodes(ListType, strSearchCriteria);
                break;
            }
            return(ret);
        }
示例#19
0
 /// <summary>
 /// Hack. Based on the fact that we have only one fixed root _library. FindAllReferences
 /// search results are stored in the _library just before VS environment ask the _library
 /// for them.
 ///
 /// Hack. Используем то что у нас одна фиксированна¤ _library, сохран¤ем в нем
 /// уже найденные результаты для FindAllReferences непосредственно перед тем как
 /// среда VS попросит у _library эти результаты поиска.
 /// </summary>
 public void OnFindAllReferencesDone(IVsSimpleObjectList2 findResults)
 {
     _library.OnFindAllReferencesDone(findResults);
 }
示例#20
0
        public int GetList2(uint ListType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            /*
            string strSearchCriteria = pobSrch[0].szName;
            uint grfOptions = pobSrch[0].grfOptions;
            IVsNavInfo NavInfo = pobSrch[0].pIVsNavInfo;

            // Return generated list of symbols to the object manager.
            ResultList resultsList = new RootMethodsList(this, grfOptions);
            ppIVsSimpleObjectList2 = (Microsoft.VisualStudio.Shell.Interop.IVsSimpleObjectList2)(resultsList);
            string strFullNameFromNavInfo;

            if (((uint)(grfOptions & (uint)Microsoft.VisualStudio.Shell.Interop._VSOBSEARCHOPTIONS2.VSOBSO_CALLSFROM) > 0) &&
                ((uint)(grfOptions & (uint)Microsoft.VisualStudio.Shell.Interop._VSOBSEARCHOPTIONS2.VSOBSO_CALLSTO) > 0))
            {
                // Initial view with VSOBSO_CALLSFROM and VSOBSO_CALLSTO flags set simultaneously.
                // Generate list of all methods in the container.

                foreach (CallInstance call in m_CallGraph)
                {
                    resultsList.AddMethod(call.m_Source);
                    resultsList.AddMethod(call.m_Target);
                }

            }
            // Generate CALLFROM list for Call graph.
            else if ((uint)(grfOptions & (uint)Microsoft.VisualStudio.Shell.Interop._VSOBSEARCHOPTIONS2.VSOBSO_CALLSFROM) > 0)
            {
                System.Collections.Generic.List<CallInstance> Calls = null;

                if (NavInfo != null)
                {
                    strFullNameFromNavInfo = CallBrowserNavInfo.GetFullNameFromNavInfo(NavInfo);
                    Calls = m_CallGraph.GetCallGraph(strFullNameFromNavInfo);
                }
                else if (strSearchCriteria.Length > 0)
                {
                    Calls = m_CallGraph.GetCallGraph(strSearchCriteria);
                }

                for (int i = 0; i < Calls.Count; i++)
                {
                    Method method = Calls[i].m_Source;
                    resultsList.AddMethod(method);
                }
            }
            // Generate CALLTO list for Callers graph.

            else if ((uint)(grfOptions & (uint)Microsoft.VisualStudio.Shell.Interop._VSOBSEARCHOPTIONS2.VSOBSO_CALLSTO) > 0)
            {
                System.Collections.Generic.List<CallInstance> Callers = null; // = new System.Collections.Generic.List<CallInstance>();

                if (NavInfo != null)
                {
                    strFullNameFromNavInfo = CallBrowserNavInfo.GetFullNameFromNavInfo(NavInfo);
                    Callers = m_CallGraph.GetCallersGraph(strFullNameFromNavInfo);
                }
                else if (strSearchCriteria.Length > 0)
                {
                    Callers = m_CallGraph.GetCallersGraph(strSearchCriteria);
                }

                for (int i = 0; i < Callers.Count; i++)
                {
                    Method method = Callers[i].m_Target;
                    resultsList.AddMethod(method);
                }
            }

            return VSConstants.S_OK;
            */

            Logger.Log(string.Format("GetList2 : Library ListType:{0}({1}) flags: {2}",
                Enum.GetName(typeof(_LIB_LISTTYPE2), ListType),
                Enum.GetName(typeof(_LIB_LISTTYPE), ListType),
                Enum.GetName(typeof(_LIB_LISTFLAGS), flags)));
            if (pobSrch != null)
                ppIVsSimpleObjectList2 = root.FilterView((ResultList.LibraryNodeType)ListType, pobSrch);
            else
                ppIVsSimpleObjectList2 = objRoot;
            return VSConstants.S_OK;

            //for (var i = 0; i < root.Children.Count; i++) {
            //    if (root.Children[i].NodeType == (ResultList.LibraryNodeType)ListType)
            //      root.GetList2(i, ListType, flags, pobSrch, out ppIVsSimpleObjectList2);
            //}

            //if (pobSrch != null)
            //{
            //    /*
            //    if (pobSrch != null)
            //    {
            //    //var txt = pobSrch[0].szName;
            //    //string temp = string.Empty;

            //    //root.GetTextWithOwnership(0, VSTREETEXTOPTIONS.TTO_DEFAULT, out temp);
            //    //if (string.Compare(temp, txt, true) == 0)
            //    //    ppIVsSimpleObjectList2 = root;
            //    //else
            //    //{
            //    //    namespaceNode.GetTextWithOwnership(0, VSTREETEXTOPTIONS.TTO_DEFAULT, out temp);
            //    //    if (string.Compare(temp, txt, true) == 0)
            //    //        ppIVsSimpleObjectList2 = namespaceNode;
            //    //    else
            //    //    {
            //    //        classNode.GetTextWithOwnership(0, VSTREETEXTOPTIONS.TTO_DEFAULT, out temp);
            //    //        if (string.Compare(temp, txt, true) == 0)
            //    //            ppIVsSimpleObjectList2 = classNode;
            //    //        else
            //    //        {
            //    //            ppIVsSimpleObjectList2 = null;
            //    //            return VSConstants.E_FAIL;
            //    //        }
            //    //    }
            //    //}
            //    for (uint i = 0; i < (uint)root.Children.Count; i++)
            //    {
            //        if (string.Compare(root.Children[(int)i].SymbolText, pobSrch[0].szName, true) == 0)
            //        {
            //            IVsSimpleObjectList2 list;
            //            root.GetList2(i, ListType, flags, null, out list);
            //            ppIVsSimpleObjectList2 = list;
            //            return VSConstants.S_OK;
            //        }
            //    }

            //    ppIVsSimpleObjectList2 = null;
            //    return VSConstants.E_FAIL;
            //}
            //     * */
            //    var txt = pobSrch[0].szName;
            //    string temp = string.Empty;

            //    root.GetTextWithOwnership(0, VSTREETEXTOPTIONS.TTO_DEFAULT, out temp);
            //    if (string.Compare(temp, txt, true) == 0)
            //        ppIVsSimpleObjectList2 = root;
            //    else
            //    {
            //        namespaceNode.GetTextWithOwnership(0, VSTREETEXTOPTIONS.TTO_DEFAULT, out temp);
            //        if (string.Compare(temp, txt, true) == 0)
            //            ppIVsSimpleObjectList2 = namespaceNode;
            //        else
            //        {
            //            classNode.GetTextWithOwnership(0, VSTREETEXTOPTIONS.TTO_DEFAULT, out temp);
            //            if (string.Compare(temp, txt, true) == 0)
            //                ppIVsSimpleObjectList2 = classNode;
            //            else
            //            {
            //                ppIVsSimpleObjectList2 = null;
            //                return VSConstants.E_FAIL;
            //            }
            //        }
            //    }

            //    return VSConstants.S_OK;
            //}
            //else
            //{
            //    ppIVsSimpleObjectList2 = root;
            //    return VSConstants.S_OK;
            //}

            //switch (ListType)
            //{
            //    case (uint)_LIB_LISTTYPE.LLT_PHYSICALCONTAINERS: //16
            //        ppIVsSimpleObjectList2 = root;
            //        return VSConstants.S_OK;
            //    case (uint)_LIB_LISTTYPE.LLT_NAMESPACES: //2
            //        ppIVsSimpleObjectList2 = null;
            //        return VSConstants.S_OK;
            //    case (uint)_LIB_LISTTYPE.LLT_CLASSES: //??
            //        ppIVsSimpleObjectList2 = null;
            //        return VSConstants.S_OK;
            //    case (uint)_LIB_LISTTYPE.LLT_MEMBERS: //8
            //        ppIVsSimpleObjectList2 = null;
            //        return VSConstants.E_FAIL;
            //    case (uint)_LIB_LISTTYPE.LLT_REFERENCES: //8192
            //        ppIVsSimpleObjectList2 = null;
            //        return VSConstants.E_FAIL;

            //    default:
            //        ppIVsSimpleObjectList2 = null;
            //        return VSConstants.E_FAIL;
            //}
        }
示例#21
0
        public int GetList2(uint ListType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            ppIVsSimpleObjectList2 = null;

            if (pobSrch != null)
            {
                if (ListType != (uint)_LIB_LISTFLAGS.LLF_USESEARCHFILTER)
                {
                    return(VSConstants.E_NOTIMPL);
                }
                VSOBSEARCHCRITERIA2 sp = pobSrch[0];

                LibraryNode results = new LibraryNode("results", LibraryNode.LibraryNodeType.PhysicalContainer);

                // partial key matching
                foreach (LibraryNode node in root.Children)
                {
                    SearchNodePartialKey(sp.szName, "", node, ref results);
                }

                ppIVsSimpleObjectList2 = results as IVsSimpleObjectList2;
            }
            else
            {
                ppIVsSimpleObjectList2 = root as IVsSimpleObjectList2;
            }

            return(VSConstants.S_OK);
        }
示例#22
0
 int IVsSimpleObjectList2.GetList2(uint index, uint listType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
 {
     ppIVsSimpleObjectList2 = GetList(index, listType, flags, pobSrch);
     return(VSConstants.S_OK);
 }
示例#23
0
        public int GetList2(uint ListType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            //the find-references command is implemented in this method
            //because it is not documented what exactly has to be implemented, we perform the search on our own (see CocoViewFilter - the request is initialized in there)
            if (((_LIB_LISTFLAGS)flags & _LIB_LISTFLAGS.LLF_USESEARCHFILTER) != 0 && pobSrch != null && pobSrch.Length > 0)
            {
                //when not filtering for members, the same list will be displayed three times (this is the same in the IrconPython sample of VS SDK 2008), so we handled it in the way to only support filtering for members (no namespaces, no hierarchys)
                if ((_LIB_LISTTYPE)ListType != _LIB_LISTTYPE.LLT_MEMBERS)
                {
                    //we just provide filter for members (not for namespaces, hierarchies, etc.)
                    ppIVsSimpleObjectList2 = null;
                    return(VSConstants.S_OK);
                }
                //we only look at one search-criteria
                VSOBSEARCHCRITERIA2 criteria = pobSrch[0];

                //get the name and check if this search was initalized by us (the manually initialized 'find-references' search)
                string searchString     = criteria.szName;
                bool   isFindReferences = criteria.dwCustom == DWCUSTOM_FINDREFSEARCH;

                if (string.IsNullOrEmpty(searchString))
                {
                    ppIVsSimpleObjectList2 = root as IVsSimpleObjectList2; //don't do anything, no filter
                    return(VSConstants.S_OK);
                }

                searchString = searchString.ToUpperInvariant();

                //references will be found by the next searchstring because references start with the same uniquename as the definition followed by a whitespace
                string searchStringWithSpace = searchString + " ";

                //copy will be returned
                LibraryNode classLevelCopy = new LibraryNode(classLevelNode);

                for (int i = 0; i < classLevelCopy.children.Count; i++)
                {
                    //copy the node, because we have to modify it
                    CocoLibraryNode fileCopy = new CocoLibraryNode(classLevelCopy.children[i] as CocoLibraryNode);

                    for (int j = 0; j < fileCopy.children.Count; j++)
                    {
                        if (isFindReferences)   //search for exact member name and for references
                        {
                            if ((fileCopy.children[j].NodeType == LibraryNode.LibraryNodeType.Members && fileCopy.children[j].UniqueName.ToUpperInvariant() == searchString) ||
                                fileCopy.children[j].NodeType == LibraryNode.LibraryNodeType.References && fileCopy.children[j].UniqueName.ToUpperInvariant().StartsWith(searchStringWithSpace))
                            {
                                fileCopy.children[j]         = new CocoLibraryNode(fileCopy.children[j] as CocoLibraryNode); //make a copy and make that visible
                                fileCopy.children[j].Visible = true;
                            }
                            else
                            {
                                fileCopy.RemoveNode(fileCopy.children[j]);
                                j--;
                            }
                        }
                        else   //don't search for references, jsut for members which contain the search string
                        {
                            if (fileCopy.children[j].NodeType == LibraryNode.LibraryNodeType.Members && fileCopy.children[j].UniqueName.ToUpperInvariant().Contains(searchString))
                            {
                                fileCopy.children[j]         = new CocoLibraryNode(fileCopy.children[j] as CocoLibraryNode); //make a copy and make that visible
                                fileCopy.children[j].Visible = true;
                            }
                            else
                            {
                                fileCopy.RemoveNode(fileCopy.children[j]);
                                j--;
                            }
                        }
                    }

                    //if the current file doesn't contain and result, remove it
                    if (fileCopy.children.Count <= 0)
                    {
                        classLevelCopy.RemoveNode(classLevelCopy.children[i]);
                        i--;
                    }
                    else
                    {
                        classLevelCopy.children[i] = fileCopy; //assign the modified copy
                    }
                }

                //move search results to top-level (now they are on file-level, but search results have to be displayed at very top level)
                System.Collections.Generic.List <LibraryNode> children;

                if (classLevelCopy.children.Count > 0)
                {
                    if (classLevelCopy.children.Count == 1)
                    {
                        children = classLevelCopy.children[0].children; //this is the normal path (and the very fast one), because normally there is only one atg-file in a project
                    }
                    else                                                //more than one
                    {
                        children = new System.Collections.Generic.List <LibraryNode>();
                        for (int i = 0; i < classLevelCopy.children.Count; i++)
                        {
                            children.AddRange(classLevelCopy.children[i].children);
                        }
                    }
                    classLevelCopy.children = children;
                }

                //return the modifed copy as result
                ppIVsSimpleObjectList2 = classLevelCopy as IVsSimpleObjectList2;
                return(VSConstants.S_OK);
            }

            ppIVsSimpleObjectList2 = root as IVsSimpleObjectList2;
            return(VSConstants.S_OK);
        }
        int IVsSimpleObjectList2.GetList2(uint index, uint ListType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            SQObjectLibraryNode node;

            if (GetChild(index, out node) && node._declaration != null)
            {
                ppIVsSimpleObjectList2 = node.FilterView((LibraryNodeType)ListType);
                return(VSConstants.S_OK);
            }
            else
            {
                ppIVsSimpleObjectList2 = null;
                return(VSConstants.S_FALSE);
            }
        }
示例#25
0
        /// <summary>
        /// Returns a child IVsSimpleObjectList2 for the specified category.
        /// </summary>
        /// <param name="index"></param>
        /// <param name="ListType"></param>
        /// <param name="flags"></param>
        /// <param name="pobSrch"></param>
        /// <param name="ppIVsSimpleObjectList2"></param>
        /// <returns></returns>
        public int GetList2(uint index, uint ListType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            //Logger.Log(string.Format(
                //"ResultList.GetList2 index:{0} ListType: {1}",
                //index,
                //Enum.GetName(typeof(_LIB_LISTTYPE), ListType)));

            ppIVsSimpleObjectList2 = children[(int)index].FilterView((LibraryNodeType)ListType, pobSrch);

            return VSConstants.S_OK;
        }
示例#26
0
        public int GetList2(uint ListType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
        {
            ICustomSearchListProvider listProvider;

            if (pobSrch != null &&
                pobSrch.Length > 0 &&
                (listProvider = pobSrch[0].pIVsNavInfo as ICustomSearchListProvider) != null)
            {
                switch ((_LIB_LISTTYPE)ListType)
                {
                case _LIB_LISTTYPE.LLT_NAMESPACES:
                    ppIVsSimpleObjectList2 = listProvider.GetSearchList();
                    break;

                default:
                    ppIVsSimpleObjectList2 = null;
                    return(VSConstants.E_FAIL);
                }
            }
            else
            {
                ppIVsSimpleObjectList2 = _root as IVsSimpleObjectList2;
            }
            return(VSConstants.S_OK);
        }
示例#27
0
文件: Library.cs 项目: rsdn/nitra
 /// <summary>
 /// Stores existing "Find All References" results in the _findResults field.
 /// Сохраняет уже готовые результаты поиска "Find All References" в поле _findResults.
 /// </summary>
 public void OnFindAllReferencesDone(IVsSimpleObjectList2 findResults)
 {
     _findResults = findResults;
 }
 int IVsSimpleObjectList2.GetList2(uint index, uint ListType, uint flagsArg, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
 {
     // TODO: Use the flags and list type to actually filter the result.
     if (index >= (uint)children.Count) {
         throw new ArgumentOutOfRangeException("index");
     }
     ppIVsSimpleObjectList2 = children[(int)index].FilterView((LibraryNodeType)ListType);
     return VSConstants.S_OK;
 }
示例#29
0
 public void SetFindResult(IVsSimpleObjectList2 findResults)
 {
     _library.OnFindAllReferencesDone(findResults);
 }
示例#30
0
文件: Library.cs 项目: TerabyteX/main
 public int GetList2(uint ListType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
 {
     ICustomSearchListProvider listProvider;
     if(pobSrch != null &&
         pobSrch.Length > 0 &&
         (listProvider = pobSrch[0].pIVsNavInfo as ICustomSearchListProvider) != null) {
         switch ((_LIB_LISTTYPE)ListType) {
             case _LIB_LISTTYPE.LLT_NAMESPACES:
                 ppIVsSimpleObjectList2 = listProvider.GetSearchList();
                 break;
             default:
                 ppIVsSimpleObjectList2 = null;
                 return VSConstants.E_FAIL;
         }
     } else {
         ppIVsSimpleObjectList2 = _root as IVsSimpleObjectList2;
     }
     return VSConstants.S_OK;
 }