Skip to content

Commit

Permalink
misc: fixes
Browse files Browse the repository at this point in the history
- backcompat for v2
- fixes to Rust dependencies
  • Loading branch information
andrewmd5 committed Oct 19, 2024
1 parent d686895 commit 6e01830
Show file tree
Hide file tree
Showing 21 changed files with 1,644 additions and 986 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION="3.1.2"
VERSION="3.1.3"
MAJOR=3
MINOR=1
PATCH=2
PATCH=3
6 changes: 3 additions & 3 deletions Compiler/Compiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0" />
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.19.5" />
<PackageReference Include="Spectre.Console" Version="0.48.0" />
<PackageReference Include="Spectre.Console.Json" Version="0.48.0" />
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.19.9" />
<PackageReference Include="Spectre.Console" Version="0.49.1" />
<PackageReference Include="Spectre.Console.Json" Version="0.49.1" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.23407.1" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions Compiler/LangServer/Handlers/CompletionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ namespace Compiler.LangServer
public sealed class CompletionHandler : ICompletionHandler
{
private readonly BufferManager _bufferManager;
private readonly DocumentSelector _documentSelector;
private readonly TextDocumentSelector _documentSelector;
private readonly HashSet<string> _keywords;
private readonly HashSet<string> _decorators;
private readonly HashSet<string> _constants;

public CompletionHandler(BufferManager bufferManager, CompilerHost compilerHost)
{
_bufferManager = bufferManager;
_documentSelector = new DocumentSelector(
new DocumentFilter()
_documentSelector = new TextDocumentSelector(
new TextDocumentFilter()
{
Pattern = "**/*.bop"
}
Expand Down
2 changes: 1 addition & 1 deletion Compiler/LangServer/Handlers/HoverHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public HoverHandler(BufferManager bufferManager,

public HoverRegistrationOptions GetRegistrationOptions(HoverCapability capability, ClientCapabilities clientCapabilities)
{
return new HoverRegistrationOptions() { DocumentSelector = DocumentSelector.ForLanguage("bebop") };
return new HoverRegistrationOptions() { DocumentSelector = TextDocumentSelector.ForLanguage("bebop") };
}

public Task<Hover?> Handle(HoverParams request, CancellationToken cancellationToken)
Expand Down
2 changes: 1 addition & 1 deletion Compiler/LangServer/Handlers/SemanticTokenHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected override SemanticTokensRegistrationOptions CreateRegistrationOptions(S
{
return new SemanticTokensRegistrationOptions
{
DocumentSelector = DocumentSelector.ForLanguage("bebop"),
DocumentSelector = TextDocumentSelector.ForLanguage("bebop"),
Legend = _legend,
Full = new SemanticTokensCapabilityRequestFull
{
Expand Down
6 changes: 3 additions & 3 deletions Compiler/LangServer/Handlers/TextDocumentSyncHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public sealed class TextDocumentSyncHandler : TextDocumentSyncHandlerBase
private readonly BufferManager _bufferManager;
private readonly BebopDiagnosticPublisher _publisher;
private readonly BebopLangServerLogger _logger;
private readonly DocumentSelector _documentSelector;
private readonly TextDocumentSelector _documentSelector;

public TextDocumentSyncKind Change { get; } = TextDocumentSyncKind.Full;

Expand All @@ -41,7 +41,7 @@ public TextDocumentSyncHandler(
_bufferManager = bufferManager ?? throw new ArgumentNullException(nameof(bufferManager));
_publisher = publisher ?? throw new ArgumentNullException(nameof(publisher));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_documentSelector = new DocumentSelector(new DocumentFilter()
_documentSelector = new TextDocumentSelector(new TextDocumentFilter()
{
Pattern = "**/*.bop",
});
Expand All @@ -52,7 +52,7 @@ public override TextDocumentAttributes GetTextDocumentAttributes(DocumentUri uri
return new TextDocumentAttributes(uri, "bop");
}

protected override TextDocumentSyncRegistrationOptions CreateRegistrationOptions(SynchronizationCapability capability, ClientCapabilities clientCapabilities)
protected override TextDocumentSyncRegistrationOptions CreateRegistrationOptions(TextSynchronizationCapability capability, ClientCapabilities clientCapabilities)
{
return new TextDocumentSyncRegistrationOptions()
{
Expand Down
2 changes: 1 addition & 1 deletion Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Errata" Version="0.11.0" />
<PackageReference Include="Errata" Version="0.13.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0" />
</ItemGroup>

Expand Down
2 changes: 2 additions & 0 deletions Core/Generators/TypeScript/TypeScriptGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,8 @@ public override ValueTask<string> Compile(BebopSchema schema, GeneratorConfig co
{
// We codegen "1 as 1", "2 as 2"... because TypeScript otherwise infers the type "number" for this field, whereas a literal type is necessary to discriminate unions.
builder.AppendLine($"public readonly discriminator: number = {td.DiscriminatorInParent} as {td.DiscriminatorInParent};");
// back compaq for v2 usage where discriminator is a static field
builder.AppendLine($"public static readonly discriminator: number = {td.DiscriminatorInParent} as {td.DiscriminatorInParent};");
}
for (var i = 0; i < fd.Fields.Count; i++)
{
Expand Down
11 changes: 9 additions & 2 deletions Core/Meta/JsonContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ namespace Core.Meta;
[JsonSerializable(typeof(CompilerOutput))]
[JsonSerializable(typeof(GeneratedFile))]
[JsonSerializable(typeof(AuxiliaryFile))]
[JsonSerializable(typeof(SpanException))]
[JsonSerializable(typeof(Exception))]
[JsonSerializable(typeof(SpanException))]
[JsonSerializable(typeof(DiagnosticLogger.Diagnostic))]
[JsonSerializable(typeof(Span))]
[JsonSerializable(typeof(GeneratorContext))]
Expand Down Expand Up @@ -80,7 +80,14 @@ public override void Write(Utf8JsonWriter writer, Exception value, JsonSerialize
if (value.InnerException is not null)
{
writer.WritePropertyName("innerException");
JsonSerializer.Serialize(writer, value.InnerException, options);
if (value.InnerException is SpanException spanException)
{
JsonSerializer.Serialize(writer, spanException, JsonContext.Default.SpanException);
}
else
{
JsonSerializer.Serialize(writer, value.InnerException, JsonContext.Default.Exception);
}
}
writer.WriteEndObject();
}
Expand Down
9 changes: 4 additions & 5 deletions Laboratory/Integration/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
using Bebop.Runtime;


if (args.Length == 1 && args[0] == "encode")
if (args.Length == 2 && args[0] == "encode")
{
var lib = MakeLibrary();
byte[] buffer = Library.Encode(lib);
using (var stdout = Console.OpenStandardOutput())
{
stdout.Write(buffer, 0, buffer.Length);
}
var path = Path.GetFullPath(args[1]);
Console.WriteLine($"Writing {buffer.Length} bytes to {path}");
File.WriteAllBytes(path, buffer);

return 0;
}
Expand Down
5 changes: 4 additions & 1 deletion Laboratory/Integration/run_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ if (
}

shell.echo("Generating encodings from each language...");
shell.exec("dotnet run encode 1> cs.enc");
shell.exec("dotnet run encode cs.enc");
// Print contents of cs.enc as raw data
shell.echo("Contents of cs.enc (raw data):");
shell.exec("cat cs.enc");
shell.exec("npx ts-node encode.ts > ts.enc");
if (shell.exec(`${cxx} --std=c++17 encode.cpp`).code !== 0) {
shell.echo(`Error: ${cxx} encode.cpp failed`);
Expand Down
Loading

0 comments on commit 6e01830

Please sign in to comment.