예제 #1
0
        private async Task <(HierarchyId itemid, IVsHierarchy hierarchy, IVsContainedLanguageFactory containedLanguageFactory)> GetContainedLanguageFactoryForFileAsync(string filePath)
        {
            await _languageServiceHost.InitializeAsync();

            await _projectVsServices.ThreadingService.SwitchToUIThread();

            var     priority = new VSDOCUMENTPRIORITY[1];
            HResult result   = _projectVsServices.VsProject.IsDocumentInProject(filePath, out int isFound, priority, out uint itemid);

            if (result.Failed || isFound == 0)
            {
                return(HierarchyId.Nil, null, null);
            }

            Assumes.False(itemid == HierarchyId.Nil);

            IVsContainedLanguageFactory containedLanguageFactory = await _containedLanguageFactory.GetValueAsync();

            if (containedLanguageFactory == null)
            {
                return(HierarchyId.Nil, null, null);
            }

            var hierarchy = (IVsHierarchy)_projectHostProvider.UnconfiguredProjectHostObject.ActiveIntellisenseProjectHostObject;

            if (hierarchy == null)
            {
                return(HierarchyId.Nil, null, null);
            }

            return(itemid, hierarchy, containedLanguageFactory);
        }
예제 #2
0
 protected override async Task InitializeCoreAsync(CancellationToken cancellationToken)
 {
     await _languageServiceHost.InitializeAsync(cancellationToken).ConfigureAwait(false);
 }