private async Task ParseAsync(Uri documentUri, string text)
        {
            var diagnostics = new List <Diagnostic>();

            ServiceInfo service;
            IReadOnlyList <ServiceDefinitionError> errors;

            if (!m_parser.TryParseDefinition(new ServiceDefinitionText(documentUri.AbsoluteUri, text), out service, out errors))
            {
                diagnostics.AddRange(errors.Select(ToDiagnostic));
            }

            if (service != null && !HttpServiceInfo.TryCreate(service, out _, out errors))
            {
                diagnostics.AddRange(errors.Select(ToDiagnostic));
            }

            SetService(documentUri, service);

            Router.PublishDiagnostics(new PublishDiagnosticsParams
            {
                Uri         = documentUri,
                Diagnostics = diagnostics
            });
        }
Пример #2
0
 protected static ServiceDefinitionError ParseInvalidHttpApi(string text)
 {
     HttpServiceInfo.TryCreate(TestUtility.ParseTestApi(text), out _, out var errors);
     if (errors.Count == 0)
     {
         throw new InvalidOperationException("Parse did not fail.");
     }
     return(errors[0]);
 }
Пример #3
0
 public void MultipleErrors()
 {
     HttpServiceInfo.TryCreate(TestUtility.ParseTestApi("[http(xyzzy: true)] service TestApi { [http] data Hey {} }"), out _, out var errors);
     errors.Count.Should().Be(2);
 }