Bug 477990 - [quick fix] "Syntax Error, insert ; to complete block statement" should also provide a quickfix
Summary: [quick fix] "Syntax Error, insert ; to complete block statement" should also ...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.5   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday
Depends on: 481016
Blocks: 39813
  Show dependency tree
 
Reported: 2015-09-21 14:07 EDT by Mickael Istria CLA
Modified: 2017-10-08 05:33 EDT (History)
9 users (show)

See Also:
mistria: review? (noopur_gupta)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mickael Istria CLA 2015-09-21 14:07:14 EDT
This error message, that one can see by forgetting a ; actually tells what to do. So it should also be a quick-fix, adding the ";"
Comment 1 Eclipse Genie CLA 2015-09-22 04:22:53 EDT
New Gerrit change created: https://git.eclipse.org/r/56405
Comment 2 Mickael Istria CLA 2015-09-22 04:24:11 EDT
Tentatively put 4.6.M3 as target, since patch is already available, we can hope it can be reviewed/polished/merged for 4.6.M3.
Comment 3 Stephan Herrmann CLA 2015-09-22 09:22:03 EDT
Comment from JDT/Core perspective: error messages for syntax errors are heuristically generated by a clever algorithm, and may in some situations be quite off the mark. I'm not sure how best to evaluate the hit-ratio. Our syntax tests provide some hints already, but plain monkey testing may perhaps provide deeper insights.

Of course we are doing a best effort so that "good" suggestions are generated. But if the quick fix leads to more user complaints about "wrong" suggestions, we'll be in a difficult positions, since fine tuning those messages is an extremely tricky task.

Just saying.
Comment 4 Mickael Istria CLA 2015-09-22 09:23:13 EDT
@Markus: I see this change makes a test fail. The test is checking that most Parser errors don't have a quickfix. Is it fine if I rewrite it to allow quickfix on parser errors?
Comment 5 Mickael Istria CLA 2015-09-22 09:30:11 EDT
(In reply to Stephan Herrmann from comment #3)
> Of course we are doing a best effort so that "good" suggestions are
> generated. But if the quick fix leads to more user complaints about "wrong"
> suggestions, we'll be in a difficult positions, since fine tuning those
> messages is an extremely tricky task.

The suggested implementation is currently restricted to very simple cases, and seems to work fine on them. It introduces quite a lot of value compared to the current status, especially for people coming from other programming languages. In case we see a case which is very poorly handled and that introduce negative value in the quick-fix we can tweak the quick-fix to skip it.

IMHO, the ration between value and risk of false suggestion makes it worth including it.
Comment 6 Mickael Istria CLA 2015-10-06 12:00:36 EDT
@Stephan: Do you have examples of tricky cases where this suggestion would lead user to "worse" results ?
Comment 7 Markus Keller CLA 2015-10-19 08:40:24 EDT
Dup of bug 437927.

(In reply to Mickael Istria from comment #4)
> @Markus: I see this change makes a test fail. The test is checking that most
> Parser errors don't have a quickfix. Is it fine if I rewrite it to allow
> quickfix on parser errors?

Hmm, do you really think I remember each and every test we have, so that I can easily find the one you're talking about? If it's org.eclipse.jdt.ui.tests.quickfix.LocalCorrectionsQuickFixTest#testNoFixFor_ParsingErrorInsertToComplete(), then just see the reference on top and Team > Show Annotations, which all point to bug 434188.

In short: We should only add these Quick Fixes when we're reasonably sure that they do something useful in most cases. I cannot asses that off-hands. Someone would need to add the Quick Fixes locally and then work with them for a while and always apply the Quick Fixes during normal development.
Comment 8 Mickael Istria CLA 2015-10-26 07:52:47 EDT
(In reply to Markus Keller from comment #7)
> In short: We should only add these Quick Fixes when we're reasonably sure
> that they do something useful in most cases. I cannot asses that off-hands.
> Someone would need to add the Quick Fixes locally and then work with them
> for a while and always apply the Quick Fixes during normal development.

Who do you mean by someone?
I did try the submitted patch while developing Java code, and the quick-fixes it suggest are useful and worth it IMO. FYI, other popular Java IDEs have this kind of quick-fix that JDT doesn't provide yet.
It's mainly targetting new Java developers who're not very comfortable with JDT grammar. Just doing Ctrl+1 would help them to fix syntax error automatically.
Comment 9 Mickael Istria CLA 2015-10-28 17:00:11 EDT
It would be great if this feature could be considered for Neon M4. Despite the test failure (which is expected as there are now some new quickfixes that some test weren't expected), the patch submitted on Gerrit can already be evaluated to discuss the usability of this feature and the reliability of the implementation.
Comment 10 Stephan Herrmann CLA 2015-10-29 19:24:04 EDT
Bug 481016 (thanks Markus) is a perfect example of what I meant in comment 3.
Comment 11 Markus Keller CLA 2015-10-30 07:45:40 EDT
I'm doing the real-life tests and will report back.

As explained in bug 437927 and other referenced bugs, we need more infrastructure to avoid showing the light bulb in situations where we don't actually have a fix to offer. Maybe also needs better support from the compiler (separate error id for cases where the proposed token(s) can be inserted because it's a literal string and not a reference to a nonterminal of the grammar).

In the UI, we don't use terms like "token(s)". Use separate strings for singular and plural.
Comment 12 Markus Keller CLA 2015-10-30 07:48:13 EDT
Search for bugs about "recovery" and "syntax" errors to see more examples where the compiler's recovery needs work.
Comment 13 Mickael Istria CLA 2015-11-03 11:10:51 EST
This seems to be a DUP of bug 39813, but since more discussion and a patch are provided here, is it OK to mark bug 39813 as a DUP of this one?
Comment 14 Mickael Istria CLA 2015-11-19 11:59:12 EST
Since the syntax error reported in bug 97822 is actually a good one, and since the proposed patch suggests the right fix for the syntax error, I'm removing the dep on that bug.
The suggested patch + the one for 481016 seem to be everything needed to make a step forward in better quick fix of parsing error (with limitations explained in comment 5 that prevent from doing wrong suggestions).
Are you aware of any other 1-character parsing error for which parser give a bad hint?
Comment 15 Robert Roth CLA 2016-07-02 02:36:43 EDT
I would also agree that including such a quick-fix would be helpful to Java newcomers, let me know if there's anything I could do to make this happen.
Comment 16 Mickael Istria CLA 2016-07-04 03:52:21 EDT
(In reply to Robert Roth from comment #15)
> I would also agree that including such a quick-fix would be helpful to Java
> newcomers, let me know if there's anything I could do to make this happen.

Thanks Robert,
I think you can give a try to the suggested patch and compare the behavior for JDT quickfix with/without it, and report how useful it was to you (or some Java rookies) while developing, and whether you identified cases of "false-positive".
If it was helpful at least once and without perceived false-positive, then  it means that this patch is worth being included.
Comment 17 Alexander Kurtakov CLA 2017-10-06 08:13:20 EDT
What is holding on this patch?
Comment 18 Stephan Herrmann CLA 2017-10-06 16:58:50 EDT
(In reply to Alexander Kurtakov from comment #17)
> What is holding on this patch?

The review assignee no longer working for Eclipse, plus the rest of the team being heavily overbooked by Java 9 work and minimal triage of severe bugs.

Hope this explains :)
Comment 19 Lars Vogel CLA 2017-10-07 04:44:06 EDT
(In reply to Stephan Herrmann from comment #18)
> (In reply to Alexander Kurtakov from comment #17)
> > What is holding on this patch?
> 
> The review assignee no longer working for Eclipse, plus the rest of the team
> being heavily overbooked by Java 9 work and minimal triage of severe bugs.
> 
> Hope this explains :)

I changed the review assignee to Noopur.
Comment 20 Mickael Istria CLA 2017-10-08 05:33:40 EDT
(In reply to Stephan Herrmann from comment #3)
> Comment from JDT/Core perspective: error messages for syntax errors are
> heuristically generated by a clever algorithm, and may in some situations be
> quite off the mark. I'm not sure how best to evaluate the hit-ratio. Our
> syntax tests provide some hints already, but plain monkey testing may
> perhaps provide deeper insights.
> Of course we are doing a best effort so that "good" suggestions are
> generated. But if the quick fix leads to more user complaints about "wrong"
> suggestions, we'll be in a difficult positions, since fine tuning those
> messages is an extremely tricky task.
> Just saying.

Do you think it would be worth adding a note on the quick-fix label for quick-fixes derived from parsing error? So it would be something like " Insert ';' (potential fix)"