Skip to content

Commit

Permalink
Feat: Support for --bprint in language server. (#4206)
Browse files Browse the repository at this point in the history
I add this as a way to simplify boogie debugging, especially in cases
when VSCode is not consistent with the command-line like in #4205

I did not add any test for that as it's meant for Dafny development
only, but I tested it manually. I borrowed the code from the driver.
Should I still list it as a feature?

<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
  • Loading branch information
MikaelMayer committed Jul 10, 2023
1 parent 5c1badc commit f4b7ccd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
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 @@ public enum CommandLineArgumentsResult {
}

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 @@ DafnyOptions options

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

0 comments on commit f4b7ccd

Please sign in to comment.