Bug 236193

Summary: DiagnoseParser has unreachable code
Product: [Eclipse Project] JDT Reporter: Stephan Herrmann <stephan.herrmann>
Component: CoreAssignee: David Audel <david_audel>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: Olivier_Thomann
Version: 3.4   
Target Milestone: 3.5 M1   
Hardware: Other   
OS: All   
Whiteboard:
Attachments:
Description Flags
Proposed fix none

Description Stephan Herrmann CLA 2008-06-08 13:16:41 EDT
Build ID: I20080530-1730

Method DiagnoseParser#checkPrimaryDistance contains this if-structure:

  if (j > repair.distance) { 
  ...
  } else if (j == repair.distance && k > repair.misspellIndex) {
  ...
  } else if (j == repair.distance && k > repair.misspellIndex && isBetterSymbol(symbol, repair.symbol)) {
  ...
  }

The third branch can obviously never be reached.
Additionally, isBetterSymbol constantly returns false.

I was going to add specific logic to isBetterSymbol,
but this might be riding a dead horse. So my question is:
is this code unfinished or obsolete or both? ;-)
Comment 1 David Audel CLA 2008-06-09 10:03:02 EDT
This code has bug, it should be 'j == repair.distance && k == repair.misspellIndex && isBetterSymbol(symbol, repair.symbol)'.
This code is useless because isBetterSymbol() return always false.

I think that this code has been released by accident.
If my memory is good, i investigated how to replace 'interface' by 'class' in syntax error diagnosis and this code is a part of these investigation.

So we should remove this useless code or we should add the complete support to replace 'interface' by 'class' in diagnosis (we should also replace non terminal symbols like 'InterfaceHeader' by 'ClassHeader' and do the same for other constructs like the 'enum').
Comment 2 David Audel CLA 2008-07-16 05:45:35 EDT
Created attachment 107583 [details]
Proposed fix

This patch remove the useless code.
Comment 3 David Audel CLA 2008-07-16 05:47:06 EDT
Released for 3.5M1.
Comment 4 Olivier Thomann CLA 2008-08-06 13:40:30 EDT
Verified for 3.5M1 using I20080805-1307