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

Enable check model command from model checking panel #222

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

klinvill
Copy link
Contributor

@klinvill klinvill commented Jun 4, 2021

Addresses #215, replaces #216.

This PR extends the tlaplus.model.check.run command to be enabled whenever tlaplus.tlc.canRunAgain is true. This has the effect of showing the check model command when the model checking pane is active. When no TLA+ file is active, the command falls back on using the last checked spec. The flow of the checkModel function roughly follows:

  1. If given a file URI , read the spec from the file.
  2. If the active file is a TLA+ file, read the spec from that file.
  3. If lastCheckFiles is populated, use that spec.
  4. Error, no spec to check

This PR also refactors the helper functions called by checkModel to return Result types. Returning a Result allows the error messages to be ignored in the case where a TLA+ file is not active but the last checked spec is known and can be used.

As part of the refactoring, I also extracted the canRunTlc() checks from functions that get the editor and moved them to the functions that run the TLC tool (doCheckModel() and doEvaluateExpression()).

@sonarcloud
Copy link

sonarcloud bot commented Jun 4, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

When the model pane is active, the last checked model is used as the model
to check. This is needed since the spec to check is otherwise retrieved
using the active file. Since there is no active file if the model pane
is active, we need to supply another file to check.

This commit also refactors several checkModel helper functions to return
Result types. This allows for errors to be propagated back and
potentially ignored rather than immediately resulting in an error
message.
Instead the canRunTlc check is now performed just before TLC is
executed. This avoids code duplication while only sacrificing a bit of
early warning.
The match statement works well, but makes the code a little hard to
read. Refactoring in favor of longer conditional statements makes the
code more readable
@klinvill klinvill force-pushed the klinvill/enable-check-model-from-panel branch from f3b3541 to 6582c3e Compare November 14, 2021 21:42
@sonarcloud
Copy link

sonarcloud bot commented Nov 14, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@klinvill
Copy link
Contributor Author

@lemmy I rebased this onto the latest changes and think it didn't break anything, but I'd love some extra assurance I didn't break #233

@lemmy
Copy link
Member

lemmy commented Nov 15, 2021

The work as part of #242 identified/created the problem that the code can check another specification than what the HTML page shows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants