Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Support for --bprint in language server. #4206

Merged
merged 13 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Source/DafnyDriver/DafnyDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -607,16 +607,16 @@ private static string BoogieProgramSuffix(string printFile, string suffix) {
}

public static IEnumerable<Tuple<string, Bpl.Program>> Translate(ExecutionEngineOptions options, Program dafnyProgram) {
var nmodules = Translator.VerifiableModules(dafnyProgram).Count();
var modulesCount = Translator.VerifiableModules(dafnyProgram).Count();


foreach (var prog in Translator.Translate(dafnyProgram, dafnyProgram.Reporter)) {

if (options.PrintFile != null) {

var nm = nmodules > 1 ? Dafny.DafnyMain.BoogieProgramSuffix(options.PrintFile, prog.Item1) : options.PrintFile;
var fileName = modulesCount > 1 ? Dafny.DafnyMain.BoogieProgramSuffix(options.PrintFile, prog.Item1) : options.PrintFile;

ExecutionEngine.PrintBplFile(options, nm, prog.Item2, false, false, options.PrettyPrint);
ExecutionEngine.PrintBplFile(options, fileName, prog.Item2, false, false, options.PrettyPrint);
}

yield return prog;
Expand Down
11 changes: 9 additions & 2 deletions Source/DafnyLanguageServer/Language/DafnyProgramVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,17 @@ public async Task<IReadOnlyList<IImplementationTask>> GetVerificationTasksAsync(

cancellationToken.ThrowIfCancellationRequested();

if (engine.Options.PrintFile != null) {
var moduleCount = Translator.VerifiableModules(program).Count();
foreach (var (suffix, boogieProgram) in translated) {
var fileName = moduleCount > 1 ? DafnyMain.BoogieProgramSuffix(engine.Options.PrintFile, suffix) : engine.Options.PrintFile;
ExecutionEngine.PrintBplFile(engine.Options, fileName, boogieProgram, false, false, engine.Options.PrettyPrint);
}
}

return translated.SelectMany(t => {
var (_, boogieProgram) = t;
var results = engine.GetImplementationTasks(boogieProgram);
return results;
return engine.GetImplementationTasks(boogieProgram);
}).ToList();
}

Expand Down
1 change: 1 addition & 0 deletions Source/DafnyLanguageServer/ServerCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ related locations
GhostIndicators,
LineVerificationStatus,
VerifySnapshots,
DeveloperOptionBag.BoogiePrint,
CommonOptionBag.EnforceDeterminism,
CommonOptionBag.UseJavadocLikeDocstringRewriterOption
}.Concat(ICommandSpec.VerificationOptions).
Expand Down
1 change: 1 addition & 0 deletions docs/dev/news/bprint-option-in language-server.feat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support for the `--bprint` option for language server arguments