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.AddCustomConstructorOperation_description); 			fCreated.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) {				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);					MethodDeclaration stub= StubUtility2.createConstructorStub(rewrite.getCu(), rewrite.getASTRewrite(), rewrite.getImportRewrite(), binding, rewrite.getAST(), fOmitSuper ? null : fBinding, fBindings, fVisibility, fSettings);					if (stub != null) {						fCreated.addAll(Arrays.asList(fBindings));						if (insertion != null)							rewriter.insertBefore(stub, insertion, null);						else							rewriter.insertLast(stub, null);					}					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();		}	}