Project: JDT
Bug 82950 Extract local fails on switch statement [refactor]
Reported: 2005-01-17 04:54:06 | Status: resolved fixed

I20050112-1200 case IJavaElement.METHOD: { final IMethod methodReferenced= (IMethod) referenced; final ICompilationUnit referencedUnit= methodReferenced.getCompilationUnit(); switch (referencingType) { case IJavaElement.COMPILATION_UNIT: final ICompilationUnit unit= (ICompilationUnit) referencing; if (referencedUnit != null && referencedUnit.equals(unit)) keyword= ModifierKeyword.PRIVATE_KEYWORD; else if (referencedUnit != null && referencedUnit.getParent().equals(unit.getParent())) keyword= null; break; case IJavaElement.TYPE: final IType type= (IType) referencing; if (methodReferenced.getDeclaringType().equals(type)) keyword= ModifierKeyword.PRIVATE_KEYWORD; else { final ITypeHierarchy hierarchy= getTypeHierarchy(type, new SubProgressMonitor (monitor, 1)); final IType[] types= hierarchy.getSupertypes(type); IType superType= null; for (int index= 0; index < types.length; index++) { superType= types[index]; if (superType.equals(methodReferenced.getDeclaringType())) { keyword= ModifierKeyword.PROTECTED_KEYWORD; return keyword; } } } if (referencedUnit != null && referencedUnit.equals(type.getCompilationUnit())) { if (methodReferenced.getDeclaringType().getDeclaringType() != null) keyword= null; else keyword= ModifierKeyword.PRIVATE_KEYWORD; } else if (referencedUnit != null && referencedUnit.getParent().equals (type.getCompilationUnit().getParent())) keyword= null; break; case IJavaElement.PACKAGE_FRAGMENT: final IPackageFragment fragment= (IPackageFragment) referencing; if (methodReferenced.getDeclaringType().getPackageFragment().equals(fragment)) keyword= null; break; default: Assert.isTrue(false); } break; - Extract "type.getCompilationUnit()"

Files changed in fix:
org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractTempRefactoring.java