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

Bug 549224

Summary: Bugs next to comments
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 10:59:59 EDT
If there's an obvious bugs appears at the start of the line which is just next to a comment, just like the code showing below, the compiler should prompt user to check the bug instead of check the comment.

package com.application.areca.impl.tools;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.myJava.file.FileList.FileListIterator;
/** 
 * <BR>
 * @author Olivier PETRUCCI<BR>
 */
publRecoveryFilterMap {
  private Map content=new HashMap();
  public void add(  File archive,  String entry) throws IOException {
    com.application.areca.metadata.FileList entries=(com.application.areca.metadata.FileList)get(archive);
    if (entries == null) {
      entries=new com.application.areca.metadata.FileList();
      content.put(archive,entries);
    }
    entries.add(entry);
  }
  public com.application.areca.metadata.FileList get(  File archive){
    return (com.application.areca.metadata.FileList)content.get(archive);
  }

It is clear that something goes wrong with the Line 14, which might be corrected as "public class RecoveryFilterMap {". But the result of the compiler is shown below:
----------
1. ERROR in C:\DataG\RecoveryFilterMap.java (at line 9)
	import com.myJava.file.FileList.FileListIterator;
	                                                ^
Syntax error on token ";", interface expected after this token
----------
1 problem (1 error)

Under the impact of the comment, the compiler provides a bug report on the line step over the whole comment which causes the location far away from where the bug should be fixed.
Comment 1 Stephan Herrmann CLA 2019-07-15 12:23:21 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 ***