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

implement error/warning squiggles in stan editor #100

Merged
merged 4 commits into from
Jun 27, 2024
Merged

Conversation

magland
Copy link
Collaborator

@magland magland commented Jun 27, 2024

Fixes #76

@magland magland requested a review from WardBrian June 27, 2024 17:49
@WardBrian
Copy link
Collaborator

I think it makes sense to do some munging on the error messages so they look nicer on the hover-over, e.g. removing the 'preview' stanc gives you. See:

https://github.com/WardBrian/vscode-stan-extension/blob/main/src/linter.ts#L38
https://github.com/WardBrian/vscode-stan-extension/blob/main/src/linter.ts#L48

Additionally, with this implemented, do we still see value in the "pop-up" error window?

@magland
Copy link
Collaborator Author

magland commented Jun 27, 2024

Additionally, with this implemented, do we still see value in the "pop-up" error window?

Not sure about that. But can we keep it in there for the time being? Not ready to say goodbye :)

@WardBrian
Copy link
Collaborator

Sure, no need to delete it in the same PR -- just speculating for the future!

@magland
Copy link
Collaborator Author

magland commented Jun 27, 2024

I think it makes sense to do some munging on the error messages so they look nicer on the hover-over, e.g. removing the 'preview' stanc gives you. See:

https://github.com/WardBrian/vscode-stan-extension/blob/main/src/linter.ts#L38 https://github.com/WardBrian/vscode-stan-extension/blob/main/src/linter.ts#L48

I was about to use that code, but saw that it's GPL. Do I have your permission?

@WardBrian
Copy link
Collaborator

Ah, yes. The project I forked from is GPL, but I am the sole author of that file, and I happily grant permission.

@magland
Copy link
Collaborator Author

magland commented Jun 27, 2024

Okay, the messages are now reformatted and they look nice!

Another comment about the syntax window... I think it's nice to not just rely on seeing a slight yellow squiggle... so even if we do remove that window, we'll want to be able to display something prominently that there are issues (and at that point, I'd like to click on that notification and get the details)

Copy link
Collaborator

@WardBrian WardBrian left a comment

Choose a reason for hiding this comment

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

Two style comments but otherwise I think this looks great!

}

if ((lineNumber !== undefined) && (startColumn !== undefined) && (endColumn !== undefined)) {
const isWarning = x.toLowerCase().startsWith('warning')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thoughts on having a loop over warnings and a loop over errors to avoid needing to back this information out again? I think if the above logic to find the start/end was its own function the two loops wouldn't need to share too much duplicate code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines 81 to 88
const toSeverity = (s: 'error' | 'warning' | 'hint' | 'info'): monaco.MarkerSeverity => {
switch (s) {
case 'error': return monaco.MarkerSeverity.Error
case 'warning': return monaco.MarkerSeverity.Warning
case 'hint': return monaco.MarkerSeverity.Hint
case 'info': return monaco.MarkerSeverity.Info
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mind moving this helper function out of the hook?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@magland magland merged commit 245839a into main Jun 27, 2024
2 checks passed
@WardBrian WardBrian mentioned this pull request Jun 28, 2024
@WardBrian WardBrian deleted the stan-editor-squiggles branch July 1, 2024 16:27
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.

Improve integration into monaco editor
2 participants