Exemplo n.º 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>());
            }
        }
Exemplo n.º 2
0
        private async Task PopulateSnippetCacheAsync(IExpansionManager expansionManager)
        {
            AssertIsBackground();

            var expansionEnumerator = await expansionManager.EnumerateExpansionsAsync(
                _languageGuidForSnippets,
                0,                      // shortCutOnly
                Array.Empty <string>(), // types
                0,                      // countTypes
                1,                      // includeNULLTypes
                1                       // includeDulicates: Allows snippets with the same title but different shortcuts
                ).ConfigureAwait(false);

            // The rest of the process requires being on the UI thread, see the explanation on
            // PopulateSnippetCacheFromExpansionEnumeration for details
            await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync();

            PopulateSnippetCacheFromExpansionEnumeration(expansionEnumerator);
        }
Exemplo n.º 3
0
        private async Task PopulateSnippetCacheAsync(IExpansionManager expansionManager)
        {
            AssertIsBackground();

            var expansionEnumerator = await expansionManager.EnumerateExpansionsAsync(
                _languageGuidForSnippets,
                0,                      // shortCutOnly
                Array.Empty <string>(), // types
                0,                      // countTypes
                1,                      // includeNULLTypes
                1                       // includeDulicates: Allows snippets with the same title but different shortcuts
                ).ConfigureAwait(false);

            // The rest of the process requires being on the UI thread, see the explanation on
            // PopulateSnippetCacheFromExpansionEnumeration for details
            await Task.Factory.StartNew(() => PopulateSnippetCacheFromExpansionEnumeration(expansionEnumerator),
                                        CancellationToken.None,
                                        TaskCreationOptions.None,
                                        ForegroundTaskScheduler).ConfigureAwait(false);
        }
Exemplo n.º 4
0
        private async Task PopulateSnippetCacheAsync(IExpansionManager expansionManager)
        {
            AssertIsBackground();

            var expansionEnumerator = await expansionManager.EnumerateExpansionsAsync(
                _languageGuidForSnippets,
                0, // shortCutOnly
                Array.Empty<string>(), // types
                0, // countTypes
                1, // includeNULLTypes
                1 // includeDulicates: Allows snippets with the same title but different shortcuts
                ).ConfigureAwait(false);

            // The rest of the process requires being on the UI thread, see the explanation on
            // PopulateSnippetCacheFromExpansionEnumeration for details
            await Task.Factory.StartNew(() => PopulateSnippetCacheFromExpansionEnumeration(expansionEnumerator),
                CancellationToken.None,
                TaskCreationOptions.None,
                ForegroundTaskScheduler).ConfigureAwait(false);
        }