예제 #1
0
 public void ClearDiagnotics(Uri documentUri)
 {
     _languageServer.TextDocument.PublishDiagnostics(new PublishDiagnosticsParams()
     {
         Uri         = documentUri,
         Diagnostics = Array.Empty <OmniSharp.Extensions.LanguageServer.Protocol.Models.Diagnostic>()
     });
 }
예제 #2
0
        internal async Task <SyntaxTree> ParseTextDocumentAsync(Uri docUri, CancellationToken cancellationToken)
        {
            var source = new List <string>(1)
            {
                docUri.GetFileSystemPath()
            };

            var syntaxTrees = await _server.Parse(source, cancellationToken);

            return(syntaxTrees.FirstOrDefault());
        }
예제 #3
0
        internal void DidCloseTextDocument(TextDocumentItem document)
        {
            _logger.LogInformation($"Document closed {document.Uri.GetFileSystemPath()} ({document.Version})");

            Uri docUri = document.Uri;

            if (Documents.ContainsKey(docUri))
            {
                Documents.Remove(docUri);
            }
        }
예제 #4
0
        internal async Task <Compilation?> ValidateTextDocumentAsync(Uri docUri, CancellationToken cancellationToken)
        {
            if (!Documents.ContainsKey(docUri))
            {
                _logger.LogError("File is not open for validation.");
                return(null);
            }

            var doc = Documents[docUri];

            doc.Compilation = await _server.Validate(doc.Document.Text, doc.Document.Uri.GetFileSystemPath(), cancellationToken);

            return(doc.Compilation);
        }
예제 #5
0
        internal void DidChangeTextDocument(VersionedTextDocumentIdentifier document, Container <TextDocumentContentChangeEvent> changes)
        {
            _logger.LogInformation($"Document changed {document.Uri.GetFileSystemPath()} ({document.Version})");

            Uri docUri = document.Uri;

            if (!Documents.ContainsKey(docUri))
            {
                return;
            }

            var doc = Documents[docUri];

            // We only handle a full document update right now
            doc.Document.Version = document.Version;
            doc.Document.Text    = changes.First().Text;
        }
예제 #6
0
        public static DocumentUri ToDefinition(this Uri uri)
        {
            string enc = uri.LocalPath.Replace('\\', '/').Replace(" ", "%20").Replace(":", "%3A");

            return(DocumentUri.File(uri.LocalPath));
        }