Exemplo n.º 1
0
            public OpenSourceGeneratedFile(SourceGeneratedFileManager fileManager, ITextBuffer textBuffer, Workspace workspace, ProjectId projectId, string generatorTypeName, string generatorAssemblyName, string generatedSourceHintName, IThreadingContext threadingContext)
                : base(threadingContext, assertIsForeground: true)
            {
                _fileManager             = fileManager;
                _textBuffer              = textBuffer;
                _workspace               = workspace;
                _projectId               = projectId;
                _generatorTypeName       = generatorTypeName;
                _generatorAssemblyName   = generatorAssemblyName;
                _generatedSourceHintName = generatedSourceHintName;

                // We'll create a read-only region for the file, but it'll be a dynamic region we can temporarily suspend
                // while we're doing edits.
                using (var readOnlyRegionEdit = _textBuffer.CreateReadOnlyRegionEdit())
                {
                    _readOnlyRegion = readOnlyRegionEdit.CreateDynamicReadOnlyRegion(
                        _textBuffer.CurrentSnapshot.GetFullSpan(),
                        SpanTrackingMode.EdgeInclusive,
                        EdgeInsertionMode.Deny,
                        callback: _ => !_updatingBuffer);

                    readOnlyRegionEdit.Apply();
                }

                _workspace.WorkspaceChanged += OnWorkspaceChanged;

                _batchingWorkQueue = new AsyncBatchingDelay(
                    TimeSpan.FromSeconds(1),
                    UpdateBufferContentsAsync,
                    asyncListener: _fileManager._listener,
                    _cancellationTokenSource.Token);
            }
        public VisualStudioSymbolNavigationService(
            SVsServiceProvider serviceProvider,
            VisualStudio14StructureTaggerProvider outliningTaggerProvider)
            : base(outliningTaggerProvider.ThreadingContext)
        {
            _serviceProvider = serviceProvider;

            var componentModel = _serviceProvider.GetService <SComponentModel, IComponentModel>();

            _editorAdaptersFactory       = componentModel.GetService <IVsEditorAdaptersFactoryService>();
            _metadataAsSourceFileService = componentModel.GetService <IMetadataAsSourceFileService>();
            _sourceGeneratedFileManager  = componentModel.GetService <SourceGeneratedFileManager>();
        }