Example #1
0
        public async Task <IEnumerable <VsExpansion> > GetAvailableSnippetsAsync()
        {
            if (_expansionMgr == null)
            {
                return(Enumerable.Empty <VsExpansion>());
            }

            try {
                var enumerator = await _expansionMgr.EnumerateExpansionsAsync(CommonGuidList.guidPythonLanguageServiceGuid, 1, null, 0, 0, 0);

                if (enumerator == null)
                {
                    return(null);
                }

                var res = new List <VsExpansion>();
                foreach (var e in COMEnumerable.ToList <VsExpansion>(enumerator.Next))
                {
                    res.Add(e);
                }

                return(res);
            } catch (Exception ex) {
                Debug.Fail(ex.ToUnhandledExceptionMessage(GetType()));
                return(Enumerable.Empty <VsExpansion>());
            }
        }
Example #2
0
        private async Task <IEnumerable <CompletionResult> > GetAvailableSnippets()
        {
            var textMgr = _serviceProvider.GetService(typeof(SVsTextManager)) as IVsTextManager2;
            IVsExpansionManager vsmgr;
            IExpansionManager   mgr;

            if (textMgr == null || ErrorHandler.Failed(textMgr.GetExpansionManager(out vsmgr)) ||
                (mgr = vsmgr as IExpansionManager) == null)
            {
                return(null);
            }

            try {
                var enumerator = await mgr.EnumerateExpansionsAsync(CommonGuidList.guidPythonLanguageServiceGuid, 1, null, 0, 0, 0);

                if (enumerator == null)
                {
                    return(null);
                }

                var res = new List <CompletionResult>();

                foreach (var e in COMEnumerable.ToList <VsExpansion>(enumerator.Next))
                {
                    res.Add(new CompletionResult(
                                e.shortcut,
                                e.shortcut,
                                e.shortcut,
                                e.description,
                                PythonMemberType.CodeSnippet,
                                null
                                ));
                }

                return(res);
            } catch (Exception ex) {
                Debug.Fail(ex.ToUnhandledExceptionMessage(GetType()));
                return(null);
            }
        }