Пример #1
0
        // Called by us to update entries
        public override void UpdateFileInfo(string projectFilePath, DynamicDocumentContainer documentContainer)
        {
            if (projectFilePath == null)
            {
                throw new ArgumentNullException(nameof(projectFilePath));
            }

            if (documentContainer == null)
            {
                throw new ArgumentNullException(nameof(documentContainer));
            }

            // This endpoint is called either when:
            //  1. LSP: File is closed
            //  2. Non-LSP: File is Supressed
            // We report, diagnostics are not supported, to Roslyn in these cases
            documentContainer.SupportsDiagnostics = false;

            // There's a possible race condition here where we're processing an update
            // and the project is getting unloaded. So if we don't find an entry we can
            // just ignore it.
            var key = new Key(projectFilePath, documentContainer.FilePath);

            if (_entries.TryGetValue(key, out var entry))
            {
                lock (entry.Lock)
                {
                    entry.Current = CreateInfo(key, documentContainer);
                }

                Updated?.Invoke(this, documentContainer.FilePath);
            }
        }
Пример #2
0
        // Called by us to update LSP document entries
        public override void UpdateLSPFileInfo(Uri documentUri, DynamicDocumentContainer documentContainer)
        {
            if (documentUri is null)
            {
                throw new ArgumentNullException(nameof(documentUri));
            }

            if (documentContainer is null)
            {
                throw new ArgumentNullException(nameof(documentContainer));
            }

            // This endpoint is only called in LSP cases when the file is open(ed)
            // We report diagnostics are supported to Roslyn in this case
            documentContainer.SupportsDiagnostics = true;

            var filePath = documentUri.GetAbsoluteOrUNCPath().Replace('/', '\\');

            if (!TryGetKeyAndEntry(filePath, out var associatedKvp))
            {
                return;
            }

            var associatedKey   = associatedKvp.Value.Key;
            var associatedEntry = associatedKvp.Value.Value;

            lock (associatedEntry.Lock)
            {
                associatedEntry.Current = CreateInfo(associatedKey, documentContainer);
            }

            Updated?.Invoke(this, filePath);
        }
Пример #3
0
        private RazorDynamicFileInfo CreateInfo(Key key, DynamicDocumentContainer document)
        {
            var filename   = key.FilePath + ".g.cs";
            var textLoader = document.GetTextLoader(filename);

            return(new RazorDynamicFileInfo(filename, SourceCodeKind.Regular, textLoader, _factory.Create(document)));
        }
Пример #4
0
        // Called by us to update entries
        public override void UpdateFileInfo(string projectFilePath, DynamicDocumentContainer documentContainer)
        {
            if (projectFilePath == null)
            {
                throw new ArgumentNullException(nameof(projectFilePath));
            }

            if (documentContainer == null)
            {
                throw new ArgumentNullException(nameof(documentContainer));
            }

            // There's a possible race condition here where we're processing an update
            // and the project is getting unloaded. So if we don't find an entry we can
            // just ignore it.
            var key = new Key(projectFilePath, documentContainer.FilePath);

            if (_entries.TryGetValue(key, out var entry))
            {
                lock (entry.Lock)
                {
                    entry.Current = CreateInfo(key, documentContainer);
                }

                Updated?.Invoke(this, documentContainer.FilePath);
            }
        }
Пример #5
0
        public override IRazorDocumentServiceProvider Create(DynamicDocumentContainer documentContainer)
        {
            if (documentContainer is null)
            {
                throw new ArgumentNullException(nameof(documentContainer));
            }

            return(new RazorDocumentServiceProvider(documentContainer));
        }
Пример #6
0
        // Called by us to update LSP document entries
        public override void UpdateLSPFileInfo(Uri documentUri, DynamicDocumentContainer documentContainer)
        {
            if (documentUri is null)
            {
                throw new ArgumentNullException(nameof(documentUri));
            }

            if (documentContainer is null)
            {
                throw new ArgumentNullException(nameof(documentContainer));
            }

            // This endpoint is only called in LSP cases when the file is open(ed)
            // We report diagnostics are supported to Roslyn in this case
            documentContainer.SupportsDiagnostics = true;

            var filePath = documentUri.GetAbsoluteOrUNCPath().Replace('/', '\\');
            KeyValuePair <Key, Entry>?associatedKvp = null;

            foreach (var entry in _entries)
            {
                if (FilePathComparer.Instance.Equals(filePath, entry.Key.FilePath))
                {
                    associatedKvp = entry;
                    break;
                }
            }

            if (associatedKvp == null)
            {
                return;
            }

            var associatedKey   = associatedKvp.Value.Key;
            var associatedEntry = associatedKvp.Value.Value;

            lock (associatedEntry.Lock)
            {
                associatedEntry.Current = CreateInfo(associatedKey, documentContainer);
            }

            Updated?.Invoke(this, filePath);
        }
        // Called by us to update LSP document entries
        public override void UpdateLSPFileInfo(Uri documentUri, DynamicDocumentContainer documentContainer)
        {
            if (documentUri is null)
            {
                throw new ArgumentNullException(nameof(documentUri));
            }

            if (documentContainer is null)
            {
                throw new ArgumentNullException(nameof(documentContainer));
            }

            var filePath = documentUri.GetAbsoluteOrUNCPath().Replace('/', '\\');
            KeyValuePair <Key, Entry>?associatedKvp = null;

            foreach (var entry in _entries)
            {
                if (FilePathComparer.Instance.Equals(filePath, entry.Key.FilePath))
                {
                    associatedKvp = entry;
                    break;
                }
            }

            if (associatedKvp == null)
            {
                return;
            }

            var associatedKey   = associatedKvp.Value.Key;
            var associatedEntry = associatedKvp.Value.Value;

            lock (associatedEntry.Lock)
            {
                associatedEntry.SupportsSuppression = false;
                associatedEntry.Current             = CreateInfo(associatedKey, documentContainer);
            }

            Updated?.Invoke(this, filePath);
        }
        public RazorDocumentServiceProvider(DynamicDocumentContainer documentContainer)
        {
            _documentContainer = documentContainer;

            _lock = new object();
        }
 public abstract IRazorDocumentServiceProvider Create(DynamicDocumentContainer documentContainer);
 public abstract void UpdateLSPFileInfo(Uri documentUri, DynamicDocumentContainer documentContainer);
 public abstract void UpdateFileInfo(string projectFilePath, DynamicDocumentContainer documentContainer);