Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 549225

Summary: Bugs contains "%"
Product: [Eclipse Project] JDT Reporter: Miaoying Wang <314miaomiao>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: stephan.herrmann
Version: 4.10   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Miaoying Wang CLA 2019-07-12 11:02:06 EDT
This situation will occur when there's an extra character '%' or a String contains a '%'.

package com.application.areca.launcher.gui.common;
import org.eclipse.swt.widgets.Composite;
/** 
 * <BR>
 * @author Olivier PETRUCCI<BR>
 */
public class ListPaneElement {
  private String key;
  private String label;
  private Composite composite;
  public ListPaneElement(  String key,  String label,  Composite composite){
    super();
    this.key=key;
    this.label=label;
    this.composite=composite;
  }
  public Composite getComposite(){
    return composite;
  }
  public String getKey(){
    return key;
  }
  public String getLabel(){
    return label;
  }%*
}
In this case , the compiler should give a suggestion on the strange marks on Line 25, however, it responds as following:

----------
1. ERROR in C:\DataG\ListPaneElement.java (at line 23)
	public String getLabel(){
	                        ^
Syntax error, insert "}" to complete MethodBody
----------
2. ERROR in C:\DataG\ListPaneElement.java (at line 23)
	public String getLabel(){
	                        ^
Syntax error, insert "}" to complete ClassBody
----------
2 problems (2 errors)

It suggests to insert a '}' which makes no help but even more mistakes. And the location of the report is also far away from where it should be without any human logic.
Comment 1 Stephan Herrmann CLA 2019-07-15 12:24:11 EDT
While it's a different example than in bug 549217, the common theme is: the heuristics implemented for giving a suitable location to syntax errors doesn't always agree with what the human reader would expect.

Due to the heuristics based approach we can impossibly add special case treatment for each of the examples where the result is currently less than perfect.

If s.o. intends to contribute a solution, having several examples is of course helpful. Otherwise there are more relevant bugs waiting to be fixed.

*** This bug has been marked as a duplicate of bug 549217 ***