Buggy code:
public class ExtractFunctionRefactoring extends AbstractRefactoring { private final class FindOuterReferencesVisitor extends Visitor { final Declaration declaration ; int refs = 0 ; FindOuterReferencesVisitor ( Declaration declaration ) { } @ Override public void visit ( Tree . MemberOrTypeExpression that ) { } @ Override public void visit ( Tree . Declaration that ) { } @ Override public void visit ( Tree . Type that ) { } } private final class CheckExpressionVisitor extends Visitor { String problem = null ; @ Override public void visit ( Tree . Body that ) { } @ Override public void visit ( Tree . AssignmentOp that ) { } } private final class CheckStatementsVisitor extends Visitor { final Body scope ; final Collection < Statement > statements ; CheckStatementsVisitor ( Tree . Body scope , Collection < Statement > statements ) { } String problem = null ; @ Override public void visit ( Tree . Body that ) { } @ Override public void visit ( Tree . Declaration that ) { } @ Override public void visit ( Tree . SpecifierStatement that ) { } @ Override public void visit ( Tree . AssignmentOp that ) { } private boolean notResultRef ( Declaration d ) { } @ Override public void visit ( Tree . Directive that ) { } } private boolean hasOuterRefs ( Declaration d , Tree . Body scope , Collection < Statement > statements ) { } private final class FindResultVisitor extends Visitor { AttributeDeclaration result = null ; final Body scope ; final Collection < Statement > statements ; FindResultVisitor ( Tree . Body scope , Collection < Statement > statements ) { } @ Override public void visit ( Tree . Body that ) { } @ Override public void visit ( Tree . AttributeDeclaration that ) { } } private final class FindReturnsVisitor extends Visitor { final Collection < Return > returns ; FindReturnsVisitor ( Collection < Return > returns ) { } @ Override public void visit ( Tree . Declaration that ) { } @ Override public void visit ( Tree . Return that ) { } } private static final class FindLocalReferencesVisitor extends Visitor { List < Tree . BaseMemberExpression > localReferences = new ArrayList < Tree . BaseMemberExpression > ( ) ; private Scope scope ; private Scope targetScope ; private FindLocalReferencesVisitor ( Scope scope , Scope targetScope ) { } public List < Tree . BaseMemberExpression > getLocalReferences ( ) { } @ Override public void visit ( Tree . BaseMemberExpression that ) { } } private String newName ; private boolean explicitType ; private AttributeDeclaration result ; private List < Statement > statements ; List < Return > returns ; private ProducedType returnType ; public ExtractFunctionRefactoring ( ITextEditor editor ) { } private void init ( ITextSelection selection ) { } @ Override public boolean isEnabled ( ) { } public String getName ( ) { } public boolean forceWizardMode ( ) { } public RefactoringStatus checkInitialConditions ( IProgressMonitor pm ) throws CoreException , OperationCanceledException { } public RefactoringStatus checkFinalConditions ( IProgressMonitor pm ) throws CoreException , OperationCanceledException { } IRegion decRegion ; IRegion refRegion ; IRegion typeRegion ; public Change createChange ( IProgressMonitor pm ) throws CoreException , OperationCanceledException { } void extractInFile ( TextChange tfc ) throws CoreException { } private void extractExpressionInFile ( TextChange tfc ) throws CoreException { } private Scope getContainingScope ( Tree . Declaration decNode ) { <START_BUG> return decNode . getDeclarationModel ( ) . getContainer ( ) . getScope ( ) ; <END_BUG> } private void extractStatementsInFile ( TextChange tfc ) throws CoreException { } private List < Statement > getStatements ( Tree . Body body , ITextSelection selection ) { } private void addLocalType ( Declaration dec , ProducedType type , List < TypeDeclaration > localTypes , List < ProducedType > visited ) { } public void setNewName ( String text ) { } public String getNewName ( ) { } public void setExplicitType ( ) { } ProducedType getType ( ) { } }

Fix:
return decNode . getDeclarationModel ( ) . getContainer ( ) ;