-
Notifications
You must be signed in to change notification settings - Fork 42
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
Syntax checker in the model editor. #1875
Conversation
Replaced QTextEdit with a nicer editor, with line number printout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good step forward and nearly there, but the code could use more documentation and I've made a few inline comments that could use addressing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. So I built and ran the branch. But I don't actually see any functionality to check a model! What am I missing?
Fitting -> Edit Custom Model -> Load plugin... Once a plugin is loaded, modify it with wrong syntax and try saving. Saving triggers the initial syntax check and if not successful, shows similar visual cues as with the simple Plugin Definition check. The Log Explorer shows more of the trace, including the line number of the first error encountered. This is now meaningful, with the editor displaying line numbers. |
Oh I see... Ok, then the functionality as described above does indeed work. However, the 'complaint' I would have is that if you load a plugin with errors already in it, as I did because I had an actual Users example to hand, then the Save button is disabled, so you sit there asking yourself 'ok, now what?'! :-) Could we have a 'Check model' button instead of replying on 'Save'? |
Ah! Great use case! |
I just pulled and built the branch again, but I can't run it because of the version string problem (#1874)!
|
Thanks @rozyczko . That did the trick. Ok, so now when I run the Model Editor and load a plugin with (known) errors this happens: The highlighting line 1 and not line 70 is a bit confusing: and clicking Save at this point doesn't change the view, but the red border is good and the log explorer is clear about the problem. It seems the highlighting is just where the input focus is (top of the file initially)? I notice that if I hover the mouse pointer in the window a popup appears: but it takes a while to appear (too long I think) and the absence of the line number in the popup is a pity. Can anything be done about both of these? If I then change define in line 70 to def and try Save it correctly picks up that there is a second error: So that's good. If I add in the missing ] and Save again the red border vanishes and the Log Explorer confirms the fix: |
Setting the cursor on the 1st error line has been implemented. Changing the tooltip activation time seems really difficult, requiring custom widget signalling and non-trivial code changes. Adding line number to the tooltip - is it required, given that the cursor moves to the failing location automatically and on each "Save"? |
The cursor does not move to the failing location on each Save in what I am testing... |
@smk78 : what does the error message say? Does it point to the correct line? The parser is just taking the line mentioned in the error and putting the cursor on it. |
Yes, the Log Explorer (and cmd window since I'm running a build) show the correct line number as shown in the screen shots above (you may have skipped over them: they're under the editor windows). Here's the model I've been using: |
oh.. OHH... I see now. Some of the lines are too wide and they just wrap. I need to find a fix for that. |
on error is impossible. Added border colour reset on loading a new model.
Fixed. |
Yes! That's working now! Good to merge as far as I'm concerned! |
Build system is fixed now (we were waiting for it). It should be ok to merge now. |
Also, replaced QTextEdit with a nicer editor, with line number printout and current row highlight
Addresses issue #1800