insertion= (MethodDeclaration) ASTNodes.getParent(NodeFinder.perform(rewrite.getRoot(), ((IMethod) fInsert).getNameRange()), MethodDeclaration.class);
insertion= ASTNodes.getParent(NodeFinder.perform(rewrite.getRoot(), ((IMethod) fInsert).getNameRange()), MethodDeclaration.class);
	public final void run(IProgressMonitor monitor) throws CoreException {		if (monitor == null)			monitor= new NullProgressMonitor();		try {			monitor.beginTask("", 1); //$NON-NLS-1$			monitor.setTaskName(CodeGenerationMessages.AddUnimplementedMethodsOperation_description); 			fCreatedMethods.clear();			final ICompilationUnit unit= fType.getCompilationUnit();			final CompilationUnitRewrite rewrite= new CompilationUnitRewrite(unit, fUnit);			ITypeBinding binding= null;			ListRewrite rewriter= null;			if (fType.isAnonymous()) {				final ClassInstanceCreation creation= (ClassInstanceCreation) ASTNodes.getParent(NodeFinder.perform(rewrite.getRoot(), fType.getNameRange()), ClassInstanceCreation.class);				if (creation != null) {					binding= creation.resolveTypeBinding();					final AnonymousClassDeclaration declaration= creation.getAnonymousClassDeclaration();					if (declaration != null)						rewriter= rewrite.getASTRewrite().getListRewrite(declaration, AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY);				}			} else {				final AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) ASTNodes.getParent(NodeFinder.perform(rewrite.getRoot(), fType.getNameRange()), AbstractTypeDeclaration.class);				if (declaration != null) {					binding= declaration.resolveBinding();					rewriter= rewrite.getASTRewrite().getListRewrite(declaration, declaration.getBodyDeclarationsProperty());				}			}			if (binding != null && rewriter != null) {				final IMethodBinding[] bindings= StubUtility2.getVisibleConstructors(binding, false, true);				if (bindings != null && bindings.length > 0) {					ITextFileBuffer buffer= null;					IDocument document= null;					try {						if (!JavaModelUtil.isPrimary(unit))							document= new Document(unit.getBuffer().getContents());						else {							buffer= RefactoringFileBuffers.acquire(unit);							document= buffer.getDocument();						}						ASTNode insertion= null;						if (fInsert instanceof IMethod)							insertion= (MethodDeclaration) ASTNodes.getParent(NodeFinder.perform(rewrite.getRoot(), ((IMethod) fInsert).getNameRange()), MethodDeclaration.class);						ImportRewrite imports= rewrite.getImportRewrite();						String key= null;						MethodDeclaration stub= null;						for (int index= 0; index < fKeys.length; index++) {							key= fKeys[index];							if (monitor.isCanceled())								break;							for (int offset= 0; offset < bindings.length; offset++) {								if (bindings[offset].getKey().equals(key)) {									stub= StubUtility2.createConstructorStub(rewrite.getCu(), rewrite.getASTRewrite(), imports, bindings[offset], binding.getName(), fVisibility, fOmitSuper, fSettings);									if (stub != null) {										fCreatedMethods.add(key);										if (insertion != null)											rewriter.insertBefore(stub, insertion, null);										else											rewriter.insertLast(stub, null);									}									break;								}							}						}						imports.createEdit(document, new SubProgressMonitor(monitor, 1));						if (!fImports)							rewrite.clearImportRewrites();						fCreatedImports= imports.getCreatedImports();						final Change result= rewrite.createChange();						if (result instanceof CompilationUnitChange) {							final CompilationUnitChange change= (CompilationUnitChange) result;							final TextEdit edit= change.getEdit();							if (edit != null) {								try {									fEdit= edit;									if (fApply)										edit.apply(document, TextEdit.UPDATE_REGIONS);									if (fSave) {										if (buffer != null)											buffer.commit(new SubProgressMonitor(monitor, 1), true);										else											unit.getBuffer().setContents(document.get());									}								} catch (Exception exception) {									throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, exception.getLocalizedMessage(), exception));								}							}						}					} finally {						if (buffer != null)							RefactoringFileBuffers.release(unit);					}				}			}		} finally {			monitor.done();		}	}