예제 #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));
            }

            // 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.SupportsSuppression = true;
                    entry.Current             = CreateInfo(key, documentContainer);
                }

                Updated?.Invoke(this, documentContainer.FilePath);
            }
        }
예제 #2
0
        private DynamicFileInfo CreateInfo(Key key, DynamicDocumentContainer document)
        {
            var filename   = key.FilePath + ".g.cs";
            var textLoader = document.GetTextLoader(filename);

            return(new DynamicFileInfo(filename, SourceCodeKind.Regular, textLoader, _factory.Create(document)));
        }
예제 #3
0
        public override IDocumentServiceProvider Create(DynamicDocumentContainer documentContainer)
        {
            if (documentContainer == null)
            {
                throw new ArgumentNullException(nameof(documentContainer));
            }

            return(new RazorDocumentServiceProvider(documentContainer));
        }
예제 #4
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));
            }

            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 abstract IDocumentServiceProvider Create(DynamicDocumentContainer documentContainer);
 public override void UpdateLSPFileInfo(Uri documentUri, DynamicDocumentContainer documentContainer)
 {
     _dynamicDocuments[documentContainer.FilePath] = documentContainer;
 }
 public override void UpdateFileInfo(string projectFilePath, DynamicDocumentContainer documentContainer)
 {
     _dynamicDocuments[documentContainer.FilePath] = documentContainer;
 }
예제 #8
0
        public RazorDocumentServiceProvider(DynamicDocumentContainer documentContainer)
        {
            _documentContainer = documentContainer;

            _lock = new object();
        }
예제 #9
0
 public override void UpdateLSPFileInfo(Uri documentUri, DynamicDocumentContainer documentContainer) => throw new NotImplementedException();