Bug 563247 - Parsing issues when a method has not semicolon at the end
Summary: Parsing issues when a method has not semicolon at the end
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.16   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-16 05:10 EDT by Gayan Perera CLA
Modified: 2024-04-27 17:25 EDT (History)
1 user (show)

See Also:


Attachments
Eclipse (12.89 KB, image/png)
2020-05-16 05:11 EDT, Gayan Perera CLA
no flags Details
IJ (9.47 KB, image/png)
2020-05-16 05:12 EDT, Gayan Perera CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gayan Perera CLA 2020-05-16 05:10:18 EDT
Take the following code example

public class Application {
	public static void main(String[] args) {
		Mockito.mock(Application.class, )
	}
}

When we have this code there is error at line
		Mockito.mock(Application.class, )

underlining the .class and saying "Syntax error, insert ";" to complete BlockStatements", this causes any AST parsing to fail and therefore will not be able to figure out the current method invocation to inspect the parameter type at the current caret position for example.

I this the error must be shown at the end of ) of that line. This how other IDEs such as IJ handles this situation.
Comment 1 Gayan Perera CLA 2020-05-16 05:11:39 EDT
Created attachment 282889 [details]
Eclipse
Comment 2 Gayan Perera CLA 2020-05-16 05:12:18 EDT
Created attachment 282890 [details]
IJ
Comment 3 Stephan Herrmann CLA 2020-05-16 08:52:55 EDT
Is this problem specific to Foo.class expressions as invocation argument?

Is the dangling ',' part of the problem?

Note, that syntax errors are not individually implemented, but reported through sophisticated heuristics, see class DiagnoseParser for details. The key notion here is to compute the minimal repair to go from the current input to a legal one. It seems, the correct repair was found (insert ';') but the location is not optimal, likely caused by the fact that we have 2 syntax errors in the input.
Comment 4 Gayan Perera CLA 2020-05-16 14:15:58 EDT
Yes as soon as we have dangling , the AST tree stops working, basically I cannot find this invocation until i add a something to fill that parameter location.
Comment 5 Eclipse Genie CLA 2022-05-07 04:11:58 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 6 Eclipse Genie CLA 2024-04-27 17:25:08 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.