コード例 #1
0
        public override IVsSimpleObjectList2 DoSearch(VSOBSEARCHCRITERIA2 criteria)
        {
            var node = _hierarchy as PythonFileNode;

            if (node != null)
            {
                var analysis = node.TryGetAnalysisEntry();

                if (analysis != null)
                {
                    string expr         = criteria.szName.Substring(criteria.szName.LastIndexOf(':') + 1);
                    var    exprAnalysis = analysis.Analyzer.WaitForRequest(analysis.Analyzer.AnalyzeExpressionAsync(
                                                                               analysis,
                                                                               criteria.szName.Substring(criteria.szName.LastIndexOf(':') + 1),
                                                                               new SourceLocation(1, 1)
                                                                               ), "PythonFileLibraryNode.DoSearch");

                    if (exprAnalysis != null)
                    {
                        return(EditFilter.GetFindRefLocations(analysis.Analyzer, _hierarchy.ProjectMgr.Site, expr, exprAnalysis.Variables));
                    }
                }
            }

            return(null);
        }
コード例 #2
0
        /// <summary>
        /// Perform the search using the given criteria
        /// </summary>
        /// <param name="listType">The list type to return (classes or members)</param>
        /// <param name="criteria">The criteria to use for the search</param>
        /// <returns>An enumerable list of <see cref="SearchResult"/> instances that contain information about
        /// each potential match.</returns>
        private IEnumerable <SearchResult> PerformSearch(_LIB_LISTTYPE listType, VSOBSEARCHCRITERIA2 criteria)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            IVsObjectList2 list;
            uint           count;
            int            pfOK;

            int result = library.GetList2((uint)listType, (uint)_LIB_LISTFLAGS.LLF_USESEARCHFILTER,
                                          new[] { criteria }, out list);

            if (result == VSConstants.S_OK && list != null)
            {
                result = list.GetItemCount(out count);

                if (result == VSConstants.S_OK && count != 0)
                {
                    for (uint idx = 0; idx < count; idx++)
                    {
                        result = list.CanGoToSource(idx, VSOBJGOTOSRCTYPE.GS_DEFINITION, out pfOK);

                        // Ignore anything for which we can't go to the source
                        if (result == VSConstants.S_OK && pfOK == 1)
                        {
                            yield return(new SearchResult(list, idx));
                        }
                    }
                }
            }
        }
コード例 #3
0
        protected virtual void HandleFindReferences()
        {
            int line, col;

            // Get the caret position
            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(TextView.GetCaretPos(out line, out col));

            //get selected text (text of selected token)
            TokenInfo info         = Source.GetTokenInfo(line, col);
            string    selectedText = Source.GetText(line, info.StartIndex, line, info.EndIndex + 1);

            //set the search-criteria
            VSOBSEARCHCRITERIA2 criteria = new VSOBSEARCHCRITERIA2();

            criteria.szName   = String.Format("{0}/{1}", Source.GetFilePath(), selectedText);
            criteria.dwCustom = Library.Library.DWCUSTOM_FINDREFSEARCH; //indicate that we want to find also references

            //perform the search
            IVsFindSymbol findSymbol = Source.LanguageService.GetService(typeof(SVsObjectSearch)) as IVsFindSymbol;

            Guid guidCocoLibrary = new Guid(GuidList.guidLibraryString);

            VSOBSEARCHCRITERIA2[] searchCriterias = new VSOBSEARCHCRITERIA2[] { criteria };

            //the search will be handled by the Library-object
            findSymbol.DoSearch(ref guidCocoLibrary, searchCriterias);
        }
コード例 #4
0
ファイル: Library.cs プロジェクト: qnsoftware/visualsquirrel
        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);
        }
コード例 #5
0
ファイル: Library.cs プロジェクト: vestild/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;
        }
コード例 #6
0
        public override IVsSimpleObjectList2 DoSearch(VSOBSEARCHCRITERIA2 criteria)
        {
            var node = _hierarchy as PythonFileNode;

            if (node != null)
            {
                var analysis = node.GetProjectEntry() as IPythonProjectEntry;

                if (analysis != null)
                {
                    var exprAnalysis = new ExpressionAnalysis(
                        ((PythonProjectNode)node.ProjectMgr).GetAnalyzer(),
                        criteria.szName.Substring(criteria.szName.LastIndexOf(':') + 1),
                        analysis.Analysis,
                        0,
                        null,
                        null
                        );

                    return(EditFilter.GetFindRefLocations(_hierarchy.ProjectMgr.Site, exprAnalysis));
                }
            }

            return(null);
        }
コード例 #7
0
        /// <summary>
        /// Opens the find symbols dialog with a list of results.  This is done by requesting
        /// that VS does a search against our library GUID.  Our library then responds to
        /// that request by extracting the prvoided symbol list out and using that for the
        /// search results.
        /// </summary>
        private static void ShowFindSymbolsDialog(ExpressionAnalysis provider, IVsNavInfo symbols)
        {
            // ensure our library is loaded so find all references will go to our library
            //VSGeneroPackage.GetGlobalService(typeof(IGeneroLibraryManager));
            // For some reason, using the GetGlobalService call was calling resulting in a call to an external package function, if it existed.
            // We want to keep the call to within this package.
            VSGeneroPackage.Instance.LoadLibraryManager();

            if (provider != null && provider.Expression != "")
            {
                var findSym = (IVsFindSymbol)VSGeneroPackage.GetGlobalService(typeof(SVsObjectSearch));
                VSOBSEARCHCRITERIA2 searchCriteria = new VSOBSEARCHCRITERIA2();
                searchCriteria.eSrchType   = VSOBSEARCHTYPE.SO_ENTIREWORD;
                searchCriteria.pIVsNavInfo = symbols;
                searchCriteria.grfOptions  = (uint)_VSOBSEARCHOPTIONS2.VSOBSO_LISTREFERENCES;
                searchCriteria.szName      = provider.Expression;

                Guid guid = Guid.Empty;
                //  new Guid("{a5a527ea-cf0a-4abf-b501-eafe6b3ba5c6}")
                int hResult = findSym.DoSearch(new Guid(CommonConstants.LibraryGuid), new VSOBSEARCHCRITERIA2[] { searchCriteria });
                ErrorHandler.ThrowOnFailure(hResult);
            }
            else
            {
                var statusBar = (IVsStatusbar)VSGeneroPackage.GetGlobalService(typeof(SVsStatusbar));
                statusBar.SetText("The caret must be on valid expression to find all references.");
            }
        }
コード例 #8
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;
        }
コード例 #9
0
ファイル: Library.cs プロジェクト: vestild/nemerle
 public int GetList2(
     uint					 ListType,
     uint					 flags,
     VSOBSEARCHCRITERIA2[]	pobSrch,
     out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
 {
     ppIVsSimpleObjectList2 = _root;
     return VSConstants.S_OK;
 }
コード例 #10
0
 public static void DoSearch(this IVsFindSymbol findSymbol, Guid symbolScope, VSOBSEARCHCRITERIA2 criteria)
 {
     if (findSymbol == null)
     {
         throw new ArgumentNullException("findSymbol");
     }
     VSOBSEARCHCRITERIA2[] criteriaArray = { criteria };
     ErrorHandler.ThrowOnFailure(findSymbol.DoSearch(ref symbolScope, criteriaArray));
 }
コード例 #11
0
ファイル: LibraryManager.cs プロジェクト: Rickinio/roslyn
 private bool IsSymbolObjectList(_LIB_LISTFLAGS flags, VSOBSEARCHCRITERIA2[] pobSrch)
 {
     return
         (flags & _LIB_LISTFLAGS.LLF_USESEARCHFILTER) != 0 &&
         pobSrch != null &&
         pobSrch.Length == 1 &&
         (pobSrch[0].grfOptions & (uint)_VSOBSEARCHOPTIONS2.VSOBSO_LISTREFERENCES) != 0 &&
         pobSrch[0].pIVsNavInfo is NavInfo;
 }
コード例 #12
0
ファイル: Library.cs プロジェクト: vairam-svs/poshtools
        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;
        }
コード例 #13
0
        public static IVsObjectList2 SearchIVsLibrary(IVsLibrary2 library, string keyword, VSOBSEARCHTYPE searchType)
        {
            VSOBSEARCHCRITERIA2[] searchCriteria = new VSOBSEARCHCRITERIA2[1];
            searchCriteria[0].eSrchType = searchType;
            searchCriteria[0].szName    = keyword;

            IVsObjectList2 objectList = null;

            library.GetList2((uint)_LIB_LISTTYPE.LLT_CLASSES, (uint)_LIB_LISTFLAGS.LLF_USESEARCHFILTER, searchCriteria, out objectList);
            return(objectList);
        }
コード例 #14
0
        private static SimpleObjectList <LibraryNode> SearchNodes(VSOBSEARCHCRITERIA2 srch, SimpleObjectList <LibraryNode> list, LibraryNode curNode)
        {
            foreach (var child in curNode.Children)
            {
                if (child.Name.IndexOf(srch.szName, StringComparison.OrdinalIgnoreCase) != -1)
                {
                    list.Children.Add(child.Clone(child.Name));
                }

                SearchNodes(srch, list, child);
            }
            return(list);
        }
コード例 #15
0
ファイル: LibraryManager.cs プロジェクト: Rickinio/roslyn
        protected override IVsSimpleObjectList2 GetList(uint listType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch)
        {
            switch (listType)
            {
                case (uint)_LIB_LISTTYPE.LLT_HIERARCHY:
                    if (IsSymbolObjectList((_LIB_LISTFLAGS)flags, pobSrch))
                    {
                        return ((NavInfo)pobSrch[0].pIVsNavInfo).CreateObjectList();
                    }

                    break;
            }

            return null;
        }
コード例 #16
0
ファイル: Library.cs プロジェクト: JetBrains/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;
        }
コード例 #17
0
        /// <summary>
        /// Opens the find symbols dialog with a list of results.  This is done by requesting
        /// that VS does a search against our library GUID.  Our library then responds to
        /// that request by extracting the prvoided symbol list out and using that for the
        /// search results.
        /// </summary>
        private static void ShowFindSymbolsDialog(ExpressionAnalysis provider, SymbolList symbols)
        {
            // ensure our library is loaded so find all references will go to our library
            Package.GetGlobalService(typeof(IRubyLibraryManager));

            var findSym = (IVsFindSymbol)IronRubyToolsPackage.GetGlobalService(typeof(SVsObjectSearch));
            VSOBSEARCHCRITERIA2 searchCriteria = new VSOBSEARCHCRITERIA2();

            searchCriteria.eSrchType   = VSOBSEARCHTYPE.SO_ENTIREWORD;
            searchCriteria.pIVsNavInfo = symbols;
            searchCriteria.grfOptions  = (uint)_VSOBSEARCHOPTIONS2.VSOBSO_LISTREFERENCES;
            searchCriteria.szName      = provider.Expression;

            Guid guid = Guid.Empty;

            ErrorHandler.ThrowOnFailure(findSym.DoSearch(new Guid(CommonConstants.LibraryGuid), new VSOBSEARCHCRITERIA2[] { searchCriteria }));
        }
コード例 #18
0
ファイル: LibraryManager.cs プロジェクト: GloryChou/roslyn
        private void PresentObjectList(string title, ObjectList objectList)
        {
            var navInfo = new NavInfo(objectList);
            var findSymbol = (IVsFindSymbol)this.ServiceProvider.GetService(typeof(SVsObjectSearch));
            var searchCriteria = new VSOBSEARCHCRITERIA2()
            {
                dwCustom = 0,
                eSrchType = VSOBSEARCHTYPE.SO_ENTIREWORD,
                grfOptions = (uint)_VSOBSEARCHOPTIONS2.VSOBSO_LISTREFERENCES | (uint)_VSOBSEARCHOPTIONS.VSOBSO_CASESENSITIVE,
                pIVsNavInfo = navInfo,
                szName = title,
            };

            var criteria = new[] { searchCriteria };
            var hresult = findSymbol.DoSearch(Guids.RoslynLibraryId, criteria);

            ErrorHandler.ThrowOnFailure(hresult);
        }
コード例 #19
0
        private static string GetSearchText(VSOBSEARCHCRITERIA2[] pobSrch)
        {
            if (pobSrch.Length == 0 ||
                pobSrch[0].szName == null)
            {
                return null;
            }

            var searchText = pobSrch[0].szName;

            var openParenIndex = searchText.IndexOf('(');
            if (openParenIndex != -1)
            {
                searchText = searchText.Substring(openParenIndex);
            }

            return searchText;
        }
コード例 #20
0
        private void PresentObjectList(string title, ObjectList objectList)
        {
            var navInfo        = new NavInfo(objectList);
            var findSymbol     = (IVsFindSymbol)this.ServiceProvider.GetService(typeof(SVsObjectSearch));
            var searchCriteria = new VSOBSEARCHCRITERIA2()
            {
                dwCustom    = 0,
                eSrchType   = VSOBSEARCHTYPE.SO_ENTIREWORD,
                grfOptions  = (uint)_VSOBSEARCHOPTIONS2.VSOBSO_LISTREFERENCES | (uint)_VSOBSEARCHOPTIONS.VSOBSO_CASESENSITIVE,
                pIVsNavInfo = navInfo,
                szName      = title,
            };

            var criteria = new[] { searchCriteria };
            var hresult  = findSymbol.DoSearch(Guids.RoslynLibraryId, criteria);

            ErrorHandler.ThrowOnFailure(hresult);
        }
コード例 #21
0
ファイル: EditFilter.cs プロジェクト: krus/PTVS
        /// <summary>
        /// Opens the find symbols dialog with a list of results.  This is done by requesting
        /// that VS does a search against our library GUID.  Our library then responds to
        /// that request by extracting the prvoided symbol list out and using that for the
        /// search results.
        /// </summary>
        private void ShowFindSymbolsDialog(ExpressionAnalysis provider, IVsNavInfo symbols) {
            // ensure our library is loaded so find all references will go to our library
            _serviceProvider.GetService(typeof(IPythonLibraryManager));

            if (!string.IsNullOrEmpty(provider.Expression)) {
                var findSym = (IVsFindSymbol)_serviceProvider.GetService(typeof(SVsObjectSearch));
                VSOBSEARCHCRITERIA2 searchCriteria = new VSOBSEARCHCRITERIA2();
                searchCriteria.eSrchType = VSOBSEARCHTYPE.SO_ENTIREWORD;
                searchCriteria.pIVsNavInfo = symbols;
                searchCriteria.grfOptions = (uint)_VSOBSEARCHOPTIONS2.VSOBSO_LISTREFERENCES;
                searchCriteria.szName = provider.Expression;

                Guid guid = Guid.Empty;
                //  new Guid("{a5a527ea-cf0a-4abf-b501-eafe6b3ba5c6}")
                ErrorHandler.ThrowOnFailure(findSym.DoSearch(new Guid(CommonConstants.LibraryGuid), new VSOBSEARCHCRITERIA2[] { searchCriteria }));
            } else {
                var statusBar = (IVsStatusbar)_serviceProvider.GetService(typeof(SVsStatusbar));
                statusBar.SetText("The caret must be on valid expression to find all references.");
            }
        }
コード例 #22
0
        public override IVsSimpleObjectList2 DoSearch(VSOBSEARCHCRITERIA2 criteria) {
            var node = _hierarchy as PythonFileNode;
            if(node != null) {
                var analysis = node.GetProjectEntry() as IPythonProjectEntry;

                if (analysis != null) {
                    var exprAnalysis = new ExpressionAnalysis(
                        ((PythonProjectNode)node.ProjectMgr).GetAnalyzer(),
                        criteria.szName.Substring(criteria.szName.LastIndexOf(':') + 1),
                        analysis.Analysis,
                        0,
                        null,
                        null
                    );

                    return EditFilter.GetFindRefLocations(_hierarchy.ProjectMgr.Site, exprAnalysis);
                }
            }
            
            return null;
        }
コード例 #23
0
        public override IVsSimpleObjectList2 DoSearch(VSOBSEARCHCRITERIA2 criteria)
        {
/*
 *          var node = _hierarchy as LuaFileNode;
 *          if(node != null) {
 *              var analysis = node.GetAnalysis() as ILuaProjectEntry;
 *
 *              if (analysis != null) {
 *                  var exprAnalysis = new ExpressionAnalysis(
 *                      ((LuaProjectNode)node.ProjectMgr).GetAnalyzer(),
 *                      criteria.szName.Substring(criteria.szName.LastIndexOf(':') + 1),
 *                      analysis.Analysis,
 *                      0,
 *                      null,
 *                      null
 *                  );
 *
 *                  return EditFilter.GetFindRefLocations(exprAnalysis);
 *              }
 *          }
 */
            return(null);
        }
コード例 #24
0
        /// <summary>
        /// Opens the find symbols dialog with a list of results.  This is done by requesting
        /// that VS does a search against our library GUID.  Our library then responds to
        /// that request by extracting the prvoided symbol list out and using that for the
        /// search results.
        /// </summary>
        private static void ShowFindSymbolsDialog(ExpressionAnalysis provider, params SymbolList[] symbols)
        {
            // ensure our library is loaded so find all references will go to our library
            Package.GetGlobalService(typeof(IPythonLibraryManager));

            if (provider.Expression != "")
            {
                var findSym = (IVsFindSymbol)IronPythonToolsPackage.GetGlobalService(typeof(SVsObjectSearch));
                VSOBSEARCHCRITERIA2 searchCriteria = new VSOBSEARCHCRITERIA2();
                searchCriteria.eSrchType   = VSOBSEARCHTYPE.SO_ENTIREWORD;
                searchCriteria.pIVsNavInfo = symbols.Length == 1 ? (IVsNavInfo)symbols[0] : (IVsNavInfo) new LocationCategory("Test", symbols);
                searchCriteria.grfOptions  = (uint)_VSOBSEARCHOPTIONS2.VSOBSO_LISTREFERENCES;
                searchCriteria.szName      = provider.Expression;

                Guid guid = Guid.Empty;
                //  new Guid("{a5a527ea-cf0a-4abf-b501-eafe6b3ba5c6}")
                ErrorHandler.ThrowOnFailure(findSym.DoSearch(new Guid(CommonConstants.LibraryGuid), new VSOBSEARCHCRITERIA2[] { searchCriteria }));
            }
            else
            {
                var statusBar = (IVsStatusbar)CommonPackage.GetGlobalService(typeof(SVsStatusbar));
                statusBar.SetText("The caret must be on valid expression to find all references.");
            }
        }
コード例 #25
0
 int IVsLibrary2.GetList2(uint listType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsObjectList2 ppIVsObjectList2)
 {
     ppIVsObjectList2 = null;
     return VSConstants.E_NOTIMPL;
 }
コード例 #26
0
 public virtual IVsSimpleObjectList2 DoSearch(VSOBSEARCHCRITERIA2 criteria)
 {
     return(null);
 }
コード例 #27
0
ファイル: SymbolNode.cs プロジェクト: klewin/NDjango
        internal IVsSimpleObjectList2 FilterView(LibraryNodeType filterType, VSOBSEARCHCRITERIA2[] pobSrch)
        {
            SymbolNode
                filtered = null,
                temp = null;

            if (!filteredView.TryGetValue(filterType, out temp))
            {   // Filling filtered view
                filtered = this.Clone();
                for (int i = 0; i < filtered.children.Count; )
                    if (0 == (filtered.children[i].nodeListType & filterType))
                        filtered.children.RemoveAt(i);
                    else
                        i += 1;
                filteredView.Add(filterType, filtered.Clone());
            }
            else
                filtered = temp.Clone(); // making sure we filter a new node

            // Checking if we need to perform search
            if (pobSrch != null)
            {
                Regex reg;
                switch (pobSrch[0].eSrchType)
                {
                    case VSOBSEARCHTYPE.SO_ENTIREWORD:
                        reg = new Regex(string.Format("^{0}$", pobSrch[0].szName.ToLower()));
                        break;
                    case VSOBSEARCHTYPE.SO_PRESTRING:
                        reg = new Regex(string.Format("^{0}.*", pobSrch[0].szName.ToLower()));
                        break;
                    case VSOBSEARCHTYPE.SO_SUBSTRING:
                        reg = new Regex(string.Format(".*{0}.*", pobSrch[0].szName.ToLower()));
                        break;
                    default:
                        throw new NotImplementedException();
                }

                for (int i = 0; i < filtered.children.Count; )
                    if (!reg.Match(filtered.children[i].UniqueName.ToLower()).Success)
                        filtered.children.RemoveAt(i);
                    else
                        i += 1;
            }

            return filtered as IVsSimpleObjectList2;
        }
コード例 #28
0
ファイル: Library.cs プロジェクト: IntranetFactory/ndjango
        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;
            //}
        }
コード例 #29
0
        //=====================================================================

        /// <summary>
        /// Search for and go to the definition of the given member ID
        /// </summary>
        /// <param name="memberId">The member ID for which to search</param>
        /// <returns>True if successful, false if not</returns>
        /// <remarks>We cannot guarantee any particular order for the search results so it will go to the first
        /// match it finds which may or may not be the one you are expecting.  Results are more exact when the
        /// member ID is more fully qualified.  For example, if using <c>ToString</c> you may not end up in the
        /// class you were expecting.  Using a more qualified ID such as <c>MyClass.ToString</c> will get a
        /// better result unless you have two classes by the same name in different namespaces or if the member
        /// is overloaded.</remarks>
        public bool GotoDefinitionFor(string memberId)
        {
            try
            {
                if(String.IsNullOrWhiteSpace(memberId) || !this.DetermineSearchCriteria(memberId))
                    return false;

                if(objectManager == null)
                {
                    objectManager = serviceProvider.GetService(typeof(SVsObjectManager)) as IVsObjectManager2;

                    if(objectManager == null)
                        return false;
                }

                // As noted, we only support the C# library
                if(library == null)
                    if(objectManager.FindLibrary(new Guid(BrowseLibraryGuids80.CSharp), out library) != VSConstants.S_OK)
                        return false;

                var criteria = new VSOBSEARCHCRITERIA2
                {
                    eSrchType = VSOBSEARCHTYPE.SO_SUBSTRING,
                    grfOptions = (uint)_VSOBSEARCHOPTIONS.VSOBSO_NONE
                };

                // Give precedence to classes by searching for them first if wanted
                if((searchFlags & _LIB_LISTTYPE.LLT_CLASSES) != 0)
                    foreach(string searchText in searchClassCandidates)
                    {
                        criteria.szName = searchText;

                        foreach(var r in this.PerformSearch(_LIB_LISTTYPE.LLT_CLASSES, criteria))
                            if(this.IsMatch(searchText, r, false))
                                return r.GoToSource();
                    }

                // Search for members if wanted
                if((searchFlags & _LIB_LISTTYPE.LLT_MEMBERS) != 0)
                    foreach(string searchText in searchMemberCandidates)
                    {
                        criteria.szName = searchText;

                        var results = new List<SearchResult>(this.PerformSearch(_LIB_LISTTYPE.LLT_MEMBERS, criteria));

                        // Try for a match including parameters first
                        foreach(var r in results)
                            if(this.IsMatch(searchText, r, true))
                                return r.GoToSource();

                        // Try for a match without parameters if nothing was found
                        foreach(var r in results)
                            if(this.IsMatch(searchText, r, false))
                                return r.GoToSource();
                    }
            }
            catch(Exception ex)
            {
                // Ignore exceptions, we'll just fail the search
                System.Diagnostics.Debug.WriteLine(ex);
            }

            return false;
        }
コード例 #30
0
ファイル: SymbolNode.cs プロジェクト: klewin/NDjango
        /// <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;
        }
コード例 #31
0
 protected abstract IVsSimpleObjectList2 GetList(uint listType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch);
コード例 #32
0
        /// <summary>
        /// Perform the search using the given criteria
        /// </summary>
        /// <param name="listType">The list type to return (classes or members)</param>
        /// <param name="criteria">The criteria to use for the search</param>
        /// <returns>An enumerable list of <see cref="SearchResult"/> instances that contain information about
        /// each potential match.</returns>
        private IEnumerable<SearchResult> PerformSearch(_LIB_LISTTYPE listType, VSOBSEARCHCRITERIA2 criteria)
        {
            IVsObjectList2 list;
            uint count;
            int pfOK;

            int result = library.GetList2((uint)listType, (uint)_LIB_LISTFLAGS.LLF_USESEARCHFILTER,
                new[] { criteria }, out list);

            if(result == VSConstants.S_OK && list != null)
            {
                result = list.GetItemCount(out count);

                if(result == VSConstants.S_OK && count != 0)
                    for(uint idx = 0; idx < count; idx++)
                    {
                        result = list.CanGoToSource(idx, VSOBJGOTOSRCTYPE.GS_DEFINITION, out pfOK);

                        // Ignore anything for which we can't go to the source
                        if(result == VSConstants.S_OK && pfOK == 1)
                            yield return new SearchResult(list, idx);
                    }
            }
        }
コード例 #33
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);
        }
コード例 #34
0
ファイル: Library.cs プロジェクト: vairam-svs/poshtools
        private static SimpleObjectList<LibraryNode> SearchNodes(VSOBSEARCHCRITERIA2 srch, SimpleObjectList<LibraryNode> list, LibraryNode curNode) {
            foreach (var child in curNode.Children) {
                if (child.Name.IndexOf(srch.szName, StringComparison.OrdinalIgnoreCase) != -1) {
                    list.Children.Add(child.Clone(child.Name));
                }

                SearchNodes(srch, list, child);
            }
            return list;
        }
コード例 #35
0
        public IVsSimpleObjectList2 GetSearchList(
            ObjectListKind listKind,
            uint flags,
            VSOBSEARCHCRITERIA2[] pobSrch,
            ImmutableHashSet<Tuple<ProjectId, IAssemblySymbol>> projectAndAssemblySet)
        {
            var searchText = GetSearchText(pobSrch);
            if (searchText == null)
            {
                return null;
            }

            // TODO: Support wildcards (e.g. *xyz, *xyz* and xyz*) like the old language service did.

            switch (listKind)
            {
                case ObjectListKind.Namespaces:
                    {
                        var builder = ImmutableArray.CreateBuilder<ObjectListItem>();

                        foreach (var projectIdAndAssembly in projectAndAssemblySet)
                        {
                            var projectId = projectIdAndAssembly.Item1;
                            var assemblySymbol = projectIdAndAssembly.Item2;

                            CollectNamespaceListItems(assemblySymbol, projectId, builder, searchText);
                        }

                        return new ObjectList(ObjectListKind.Namespaces, flags, this, builder.ToImmutable());
                    }

                case ObjectListKind.Types:
                    {
                        var builder = ImmutableArray.CreateBuilder<ObjectListItem>();

                        foreach (var projectIdAndAssembly in projectAndAssemblySet)
                        {
                            var projectId = projectIdAndAssembly.Item1;
                            var assemblySymbol = projectIdAndAssembly.Item2;

                            var compilation = this.GetCompilation(projectId);
                            if (compilation == null)
                            {
                                return null;
                            }

                            CollectTypeListItems(assemblySymbol, compilation, projectId, builder, searchText);
                        }

                        return new ObjectList(ObjectListKind.Types, flags, this, builder.ToImmutable());
                    }

                case ObjectListKind.Members:
                    {
                        var builder = ImmutableArray.CreateBuilder<ObjectListItem>();

                        foreach (var projectIdAndAssembly in projectAndAssemblySet)
                        {
                            var projectId = projectIdAndAssembly.Item1;
                            var assemblySymbol = projectIdAndAssembly.Item2;

                            var compilation = this.GetCompilation(projectId);
                            if (compilation == null)
                            {
                                return null;
                            }

                            CollectMemberListItems(assemblySymbol, compilation, projectId, builder, searchText);
                        }

                        return new ObjectList(ObjectListKind.Types, flags, this, builder.ToImmutable());
                    }

                default:
                    return null;
            }
        }
コード例 #36
0
        //=====================================================================

        /// <summary>
        /// Search for and go to the definition of the given member ID
        /// </summary>
        /// <param name="memberId">The member ID for which to search</param>
        /// <returns>True if successful, false if not</returns>
        /// <remarks>We cannot guarantee any particular order for the search results so it will go to the first
        /// match it finds which may or may not be the one you are expecting.  Results are more exact when the
        /// member ID is more fully qualified.  For example, if using <c>ToString</c> you may not end up in the
        /// class you were expecting.  Using a more qualified ID such as <c>MyClass.ToString</c> will get a
        /// better result unless you have two classes by the same name in different namespaces or if the member
        /// is overloaded.</remarks>
        public bool GotoDefinitionFor(string memberId)
        {
            try
            {
                ThreadHelper.ThrowIfNotOnUIThread();

                if (String.IsNullOrWhiteSpace(memberId) || !this.DetermineSearchCriteria(memberId))
                {
                    return(false);
                }

                if (objectManager == null)
                {
                    objectManager = serviceProvider.GetService(typeof(SVsObjectManager)) as IVsObjectManager2;

                    if (objectManager == null)
                    {
                        return(false);
                    }
                }

                // As noted, we only support the C# library
                if (library == null)
                {
                    if (objectManager.FindLibrary(new Guid(BrowseLibraryGuids80.CSharp), out library) != VSConstants.S_OK)
                    {
                        return(false);
                    }
                }

                var criteria = new VSOBSEARCHCRITERIA2
                {
                    eSrchType  = VSOBSEARCHTYPE.SO_SUBSTRING,
                    grfOptions = (uint)_VSOBSEARCHOPTIONS.VSOBSO_NONE
                };

                // Give precedence to classes by searching for them first if wanted
                if ((searchFlags & _LIB_LISTTYPE.LLT_CLASSES) != 0)
                {
                    foreach (string searchText in searchClassCandidates)
                    {
                        criteria.szName = searchText;

                        foreach (var r in this.PerformSearch(_LIB_LISTTYPE.LLT_CLASSES, criteria))
                        {
                            if (this.IsMatch(searchText, r, false))
                            {
                                return(r.GoToSource());
                            }
                        }
                    }
                }

                // Search for members if wanted
                if ((searchFlags & _LIB_LISTTYPE.LLT_MEMBERS) != 0)
                {
                    foreach (string searchText in searchMemberCandidates)
                    {
                        criteria.szName = searchText;

                        var results = new List <SearchResult>(this.PerformSearch(_LIB_LISTTYPE.LLT_MEMBERS, criteria));

                        // Try for a match including parameters first
                        foreach (var r in results)
                        {
                            if (this.IsMatch(searchText, r, true))
                            {
                                return(r.GoToSource());
                            }
                        }

                        // Try for a match without parameters if nothing was found
                        foreach (var r in results)
                        {
                            if (this.IsMatch(searchText, r, false))
                            {
                                return(r.GoToSource());
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // Ignore exceptions, we'll just fail the search
                System.Diagnostics.Debug.WriteLine(ex);
            }

            return(false);
        }
コード例 #37
0
 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;
 }
コード例 #38
0
        protected override IVsSimpleObjectList2 GetList(uint listType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch)
        {
            var listKind = Helpers.ListTypeToObjectListKind(listType);

            if (Helpers.IsFindSymbol(flags))
            {
                var projectAndAssemblySet = this.GetAssemblySet(this.Workspace.CurrentSolution, _languageName, CancellationToken.None);
                return GetSearchList(listKind, flags, pobSrch, projectAndAssemblySet);
            }

            if (listKind == ObjectListKind.Hierarchy)
            {
                return null;
            }

            Debug.Assert(listKind == ObjectListKind.Projects);

            return new ObjectList(ObjectListKind.Projects, flags, this, this.GetProjectListItems(this.Workspace.CurrentSolution, _languageName, flags, CancellationToken.None));
        }
コード例 #39
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;
 }