X Tutup
The Wayback Machine - https://web.archive.org/web/20250813044043/https://github.com/processing/processing/pull/5152
Skip to content

Handle curly quotes well #5152

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

Merged
merged 10 commits into from
Sep 24, 2017
Merged

Handle curly quotes well #5152

merged 10 commits into from
Sep 24, 2017

Conversation

GKFX
Copy link
Contributor

@GKFX GKFX commented Jun 24, 2017

Fix #5133.
The autoformatter now automatically corrects curly quotes when they're used to wrap string or character literals, provided this is safe to do. It is also now less upset by unterminated strings.
On compiling and editing, errors relating to them are reworded.
I've also started prioritising the errors spat out by ECJ since occasionally the first one on the line is not the most relevant one.

GKFX added 3 commits June 22, 2017 12:37
Also it now doesn't destroy the rest of the file if a string is left
unterminated. Will never fix "content” since curly quotes are valid
string content.
There's a special message for curly quotes.
Also now prioritizes error messages on a single line for display to the
user, since ECJ doesn't always get that right, reported mismatched
argument lists when there's a syntax error and so on.
@GKFX
Copy link
Contributor Author

GKFX commented Jun 24, 2017

Also I've forced preproc.substitute_unicode to false when previously it was the default. Is that likely to be an issue? If not, can you delete the preference?

@JakubValtar
Copy link
Contributor

Looks good. However I think we need to give these priority treatment in the error checker (the same as missing curly braces), otherwise ECJ is going to spit out bunch of nonsense like this:

image

Would you mind if I clone your branch, commit some changes to rectify this, and send you a message so you can merge them back before we accept this PR?

@GKFX
Copy link
Contributor Author

GKFX commented Jul 20, 2017

@JakubValtar I don't mind at all. Please could you submit it as a PR to my branch when you're done? Also I feel that that makes my prioritization code a bit redundant, so you could delete that if you think that's best?

@GKFX
Copy link
Contributor Author

GKFX commented Jul 20, 2017

Ignore that merge commit, it's got an extra 8. Will fix shortly.

@benfry
Copy link
Contributor

benfry commented Aug 22, 2017

@JakubValtar did you make any progress with your plan to clone and clean this up? Or is that merged back in here?

@JakubValtar
Copy link
Contributor

JakubValtar commented Aug 22, 2017 via email

@benfry
Copy link
Contributor

benfry commented Aug 22, 2017

Got it; thanks!

@JakubValtar
Copy link
Contributor

@GKFX I sent the pull request, sorry it took me a while :/

Thanks for the original PR, good stuff! I just moved stuff around a bit to make it ready for more custom errors and new build system.

All error checking is now done in PDEX.ErrorChecker and problems are prioritized manually so that user sees only the most severe problems (curly quotes > curly braces > rest), showing other stuff when program structure is messed up does not make much sense and gives lots of false alarms.

I removed the prioritozation code, becasue it was not doing much right now, but if we need to fine tune the priorities in the future we can revive it.

@GKFX
Copy link
Contributor Author

GKFX commented Sep 20, 2017

@JakubValtar Looks awesome, thank you!

@benfry
Copy link
Contributor

benfry commented Sep 22, 2017

Does that mean this is ready to merge @JakubValtar?

@JakubValtar
Copy link
Contributor

@benfry I think it is ready.

Check the error messages whether you like them.

One thing which surfaced is that autoformat might break strings which
contain curly quotes.

For sure it does not format well this:

String s = “te“xt”;

Not sure if also:

String s = "te“xt";

@GKFX
Copy link
Contributor Author

GKFX commented Sep 23, 2017

@JakubValtar

String s = "te“xt";

definitely should be unharmed; I tested strings like that. If the opening quote is straight, the autoformatter doesn't give curly quotes any special meaning. If the user has managed to type

String s = “text”;

then I think that all quotes will be straightened (I'm not at my development machine right now and can't check what happens.) But it would be quite hard to distinguish that from something like

String s = “te“.xt(“”);

so straightening all quotes that aren't in a real string seems like a reasonable thing to do.

@JakubValtar
Copy link
Contributor

@GKFX Thanks, I just tested it and it's fine. Well-formed strings are not affected and in others quotes are straightened. Yesterday I somehow I managed to get a curly quoted string shredded onto multiple lines, but can't reproduce, so it's probably some obscure scenario which will happen to some unlucky soul once in a decade.

@benfry Merge time?

@benfry benfry merged commit ebd5557 into processing:master Sep 24, 2017
@benfry
Copy link
Contributor

benfry commented Sep 24, 2017

Thanks to you both. Now merged.

@JakubValtar
Copy link
Contributor

Great! All credit goes to @GKFX for diving into it.

@benfry
Copy link
Contributor

benfry commented Mar 13, 2018

This appears to be breaking unicode characters: #5413

Presumably because of this change in PdePreprocessor.java:

    // Removing all the Unicode characters makes detecting and reporting their
//    if (Preferences.getBoolean("preproc.substitute_unicode")) {
//      program = substituteUnicode(program);
//    }

Can you two look into a fix? (This is holding up the next release.)

@JakubValtar
Copy link
Contributor

Sure, I think I already started on that issue before but didn't finish it yet

@benfry
Copy link
Contributor

benfry commented Mar 13, 2018

Just confirmed that it's due to that change; not a problem on macOS, but affects Windows. Haven't checked Linux.

@benfry
Copy link
Contributor

benfry commented Mar 13, 2018

(Let's continue discussion over at #5413)

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detect errors involving curved quotation marks
3 participants
X Tutup