Wes, put some votes into <https://xojo.com/issue/50560> if you want to give Norman more work fix the problem you mentioned (which was introduced in 2017r1)
Fixed an edge case with unicode literals, you can now have:
a = &u41
or
a = "&u41"
which are different but it was a bit tricky as they were both tokenised as string tokens.
Thanks Julian, I’ve added case 50560 to the “My Top Cases” category in the Feedback application. Is that how you ‘put some votes into’ it?
I get that the Select Case/End Select is a bit odd in that it has an opening (Select Case) and a closing (End Select) but the Case clauses only have an opening (there’s no End Case.) But still, the Case clauses are children of the Select Case and should be indented. I really wish the IDE would allow a little latitude when it comes to indenting in this particular situation.
Spot on
Select certainly is an odd one (trying to tactfully keep this thread on track :D)
I read a comment on here (I can’t remember where or who) that mentioned their project can take a number of minutes to compile when something as trivial as a mismatched parenthesis ( ) could cause a compilation failure and a waste of time,
I’m thinking about putting in mismatched parenthesis detection into the script. As I’m not able to do anything fancy like highlight the line or place a warning symbol in the gutter from the script (feature request?) I’m thinking about adding a comment to the end of the line that looks something like:
if a = ( a + 1 then // MISMATCHED PARENTHESIS
It would insert itself before any other comment on the line so you’d have the most change of seeing it if you had a long line, or I could insert it at the start of the line and comment the whole line out to make it more obvious?
Good idea? Bad Idea? Want is displayed differently? Thoughts?
Good idea!
As long as it doesn’t flag the mismatch in real time. I have an editor that does that, and it’s maddening - every time I enter a left parenthesis it throws up a startling warning, and I’m like, “jeez, let me finish!”
Heh, doh! No it’ll only happen when you move off the line.
The reformatting stuff doesn’t thrill me much, but the macro facility - heck yes!!! Must check it out asap, thanks!
So it’s not currently possible to do multi-line macros? That is heartbreaking. Is there a feature request in Feedback I can vote for?
Quite impressive.
I just had a look at the script and have a few questions about it out of pure curiousity:
What makes this script work, i.e. what are the conditions under which it gets invoked? I could not find code that “inits” it, i.e. tell the IDE to invoke “CleanBlock” whenever the editor leaves a code line. Also, where does the tokenizer come from? Is there a doc on all this behavior by the IDE?
Nope
I just noticed that its visible to only me and Xojo, I’ve asked for it to be made public.
<https://xojo.com/issue/51365> all my comments in there are marked as private due to a bug in feedback so the ticket looks one sided and Norman is talking to himself
Norman/Xojo is aware of it and a little birdy tells me that they hope to get it into 2018r2 so fingers crossed.
Thanks for posting the link Jurg, let me know if anyone has any further questions.
Well its done but I’ve just found out that it will trigger mismatched parenthesis when a line is split using a continuation _ so you end up with:
a = (1 + _//MISMATCHED PARENTHESIS
a)//MISMATCHED PARENTHESIS
and as I can’t navigate around the code in the script and I’m not able to work back and count the parenthesis. I can’t even check if the current line is a portion of a continuation and ignore the check.
This would mean that your code would end up with //MISMATCHED PARENTHESIS around the place when you split a line that contains parenthesis.
Not ideal but do you think its still worth doing?
New Feature
Checks the line for mismatched parentheses and notifies you
Example
a = ((1+2)/3
becomes
a = ((1+2)/3'MISMATCHED PARENTHESES
when you move the cursor off the line.
Additional preferences
CheckMismatchedPar (true)
If you set this value to true it will check if there are matching parentheses on the line. If not it will add a comment to the end of the line notifying you of the fact.
MismatchedParComment (')
This is the comment type used for the mismatched parentheses notification.
MismatchedParMessage ("MISMATCHED PARENTHESES")
This is the message that is shown to notify you if there are mismatched parentheses on the line.
Download
Get the latest update here
Julian, thanks for this fantastic tool, works like a charm.
As always there are edge cases such as this:
Dim a, b As String
a = "hhah"
b = mid(a, 3 ' MISMATCHED PARENTHESES
b = mid a, 3)(
The last line should IMHO been marked as MISMATCHED PERENTHESES and the line before that one should show “MISSING CLOSING PARENTHESE”.
But that, i think, is very hard to implement.
Something along these lines could maybe useable for single / double quotes especially in JS code blocks.
Add to the wishlist???
After all i think the tool makes the code in the editor much and MUCH better readable.
Again MANY THANKS !!!
Great idea Andre, checking single quotes is a little harder as they are considered comments if they are outside of quotes and I don’t really want to get into parsing javascript inside comments. If you want to have a go at this please do, the source is on the git and I’ll happily merge it in.
I’ve just added this and tweaked some of the settings. Let me know if you find any problems with this update.
Updates
An error checking feature that will notify you if the line has:
- mismatched parentheses
- missing opening parenthesis
- missing closing parenthesis
- mismatched quotes
Settings
These error messages will automatically be removed when you move off the line if the error is corrected without altering the format or spacing of the error message.
MessageComment (')
This is the comment type used for error message notifications. This setting can either be '
, //
or Rem
.
MessageParMismatched (MISMATCHED PARENTHESES)
This is the message that is shown to notify you if there are mismatched parentheses on the line. Setting this to _
(underscore) will turn off checks for this setting and the error message will not be shown.
MessageParOpening (MISSING OPENING PARENTHESIS)
This is the message that is shown to notify you if there is a missing opening parenthesis on the line. Setting this to _
(underscore) will turn off checks for this setting and the error message will not be shown.
MessageParClosing (MISSING CLOSING PARENTHESIS)
This is the message that is shown to notify you if there is a missing closing parenthesis on the line. Setting this to _
(underscore) will turn off checks for this setting and the error message will not be shown.
MessageQuoteMismatched (MISMATCHED QUOTES)
This is the message that is shown to notify you if there are mismatched quotes on the line. Setting this to _
(underscore) will turn off checks for this setting and the error message will not be shown.
Download
Get the latest update here
Julian, you are a miracle, in a short test the new version works just fine, even the opening and closing error message for parenthesis work as i meant. Great job!
Thinking further about the single quote balancing i think indead that that is realy hard to implement, think about one single quote within a quoted text, how should you decide if that single quote is meant as such and no balancing should take place. IMHO that is almost impossible.
Oh, and i like the automatic removal of the error message after correcting the bug. A real masterpiece you made!
Glad you like it Andre.
Yes the single quotes thing is a bit tricky and I don’t really feel like writing a javascript parser at the moment but I can think of a way of doing it if someone has a javascript validator/parser.
I get an error when I try to copy in some obfuscated code on MISSING CLOSING PARENTHESIS on a continuation line:
Return DecodeBase64(c(97) + c(23) + c(61) + c(66) + c(119) + _'MISSING CLOSING PARENTHESIS
c(116) + c(37) + c(69) + c(79) + c(65) + _
c(9) + c(114) + c(58) + c(27) + c(100) + _
c(34) + c(3) + c(72) + c(2) + c(56) + _
c(77) + c(90) + c(83) + c(86) + c(91) + _
c(5) + c(76) + c(113) + c(45) + c(107) + _
c(17) + c(70) + c(38) + c(7) + c(31) + _
c(36) + c(10) + c(39) + c(73) + c(51) + _
c(50) + c(25) + c(11) + c(42) + c(117) + _
c(21) + c(81) + c(46) + c(57) + c(99) + _
c(32) + c(103) + c(40) + c(41) + c(22) + _
c(71) + c(68) + c(16) + c(35) + c(80) + _
c(1) + c(19) + c(96) + c(18) + c(8) + _
c(28) + c(20) + c(88) + c(98) + c(12) + _
c(78) + c(4) + c(59) + c(84) + c(24) + _
c(54) + c(33) + c(85) + c(63) + c(95) + _
c(111) + c(67) + c(94) + c(29) + c(101) + _
c(0) + c(110) + c(44) + c(52) + c(62) + _
c(105) + c(6) + c(75) + c(104) + c(49) + _
c(106) + c(118) + c(89) + c(64) + c(43) + _
c(92) + c(48) + c(74) + c(14) + c(13) + _
c(47) + c(15) + c(26) + c(115) + c(87) + _
c(93) + c(102) + c(53) + c(108) + c(55) + _
c(112) + c(82) + c(60) + c(30) + c(109))'MISSING OPENING PARENTHESIS