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

Standard lib support in dafny server #4770

Merged
merged 27 commits into from
Nov 17, 2023

Conversation

keyboardDrummer
Copy link
Member

@keyboardDrummer keyboardDrummer commented Nov 10, 2023

Description

  • Add support for the Dafny standard library to dafny server
  • Add support for library = [..] in dfyconfig.toml to dafny server
  • Refactor error handling for errors in dfyconfig.toml, so it is consistent between dafny server and other commands.
  • Ensure dafny server only publishes notifications for Uris owned by a particular project. A project owns a Uri if it is the closest project to that Uri and it includes it.
  • Moves code in new Dafny to DafnyFile.CreateAndValidate, so it's more clear that it contains logic.
  • Refactor the logic in DafnyFile so it reports errors using an ErrorReporter instead of stdio, which makes it reusable for the language server.
  • Stop using the exception IllegalDafnyFile to handle common scenarios.
  • Replace obsolete usage of Lazy<IdeState> in ProjectManager with IdeState

How has this been tested?

  • Add a test for using the standard library with dafny server
  • Add a test for using an unfound library file with dafny server
  • Add a test for using a library file with dafny server

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@keyboardDrummer keyboardDrummer enabled auto-merge (squash) November 10, 2023 23:14
Copy link
Member

@MikaelMayer MikaelMayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I'm looking forward having these libraries in VSCode.

RootFiles = DetermineRootFiles();
var diagnosticsCopy = staticDiagnostics.ToImmutableDictionary(k => k.Key,
kv => kv.Value.Select(d => d.ToLspDiagnostic()).ToImmutableList());
updates.OnNext(new FoundFiles(Project, RootFiles!, diagnosticsCopy));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain me in a few sentences why these lines? Or add a comment?

Source/DafnyLanguageServer/Workspace/FoundFiles.cs Outdated Show resolved Hide resolved
Source/DafnyLanguageServer/Workspace/IdeState.cs Outdated Show resolved Hide resolved
Source/DafnyLanguageServer/Workspace/ProjectManager.cs Outdated Show resolved Hide resolved
Source/DafnyDriver/Commands/DafnyCli.cs Show resolved Hide resolved
@@ -4,7 +4,9 @@ Dafny program verifier finished with 1 verified, 0 errors
Dafny program verifier finished with 1 verified, 0 errors
StandardLibraries_Errors.dfy(20,29): Error: module DafnyStdLibs does not exist (position 0 in path DafnyStdLibs.Wrappers)
1 resolution/type errors detected in StandardLibraries_Errors.dfy
*** Error: Cannot load DafnyStandardLibraries-notarget.doo: --unicode-char is set locally to False, but the library was built with True
CLI: Error: cannot load DafnyStandardLibraries-notarget.doo: --unicode-char is set locally to False, but the library was built with True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any way to remove the ":" between "CLI" and "Error" to avoid colon repetition?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an existing method:

public string ErrorToString(ErrorLevel header, IToken tok, string msg) {
    return $"{tok.TokenToString(Options)}: {header.ToString()}: {msg}";
  }

that creates the double colon. We could remove the first one.

@keyboardDrummer keyboardDrummer merged commit dd7a142 into dafny-lang:master Nov 17, 2023
20 checks passed
@keyboardDrummer keyboardDrummer deleted the standardLibServer branch November 17, 2023 19:06
@keyboardDrummer keyboardDrummer restored the standardLibServer branch November 17, 2023 19:10
@keyboardDrummer keyboardDrummer deleted the standardLibServer branch November 17, 2023 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants