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

Bug 362981

Summary: Warning: Statement unnecessarily nested within else clause
Product: [Modeling] EMF Reporter: Eike Stepper <stepper>
Component: CoreAssignee: Ed Merks <Ed.Merks>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3    
Version: 2.8.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Fix none

Description Eike Stepper CLA 2011-11-06 03:51:29 EST
Created attachment 206495 [details]
Fix

The generator produces warnings in the generated switch classes:

  protected T doSwitch(EClass theEClass, EObject theEObject)
  {
    if (theEClass.eContainer() == modelPackage)
    {
      return doSwitch(theEClass.getClassifierID(), theEObject);
    }
    else // HERE!!!
    {
      List<EClass> eSuperTypes = theEClass.getESuperTypes();
      return eSuperTypes.isEmpty() ? defaultCase(theEObject) : doSwitch(eSuperTypes.get(0), theEObject);
    }
  }

The attached patch should fix that.
Comment 1 Eike Stepper CLA 2012-01-30 03:01:35 EST
Please consult the project settings (falling back to the workspace preferences) to determine what compiler setting is used to create problem markers for unnecessary else clauses.
Comment 2 Eike Stepper CLA 2012-01-30 03:02:06 EST
*** Bug 370091 has been marked as a duplicate of this bug. ***
Comment 3 Ed Merks CLA 2013-01-10 08:23:40 EST
The enhancement is committed to master:

http://git.eclipse.org/c/emf/org.eclipse.emf.git/commit/?id=ca5d1a30b0c5828a1df2f948771e2710d3541592
Comment 4 Ed Merks CLA 2013-07-10 11:26:09 EDT
The changes are available in Kepler.