Bug 236193 - DiagnoseParser has unreachable code
Summary: DiagnoseParser has unreachable code
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: Other All
: P3 minor (vote)
Target Milestone: 3.5 M1   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-08 13:16 EDT by Stephan Herrmann CLA
Modified: 2008-08-06 13:40 EDT (History)
1 user (show)

See Also:


Attachments
Proposed fix (1.84 KB, patch)
2008-07-16 05:45 EDT, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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