if (session != null)
if (session != null && result != null)
	public final IDocument getPreviewDocument(IProgressMonitor monitor) throws CoreException {		if (monitor == null)			monitor= new NullProgressMonitor();		IDocument result= null;		IDocument document= null;		DocumentRewriteSession session= null;		try {			document= acquireDocument(new SubProgressMonitor(monitor, 1));			if (document != null) {				result= new Document(document.get());				if (result instanceof IDocumentExtension4)					session= ((IDocumentExtension4) result).startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED);				performChanges(result, null, true);			}		} catch (BadLocationException exception) {			throw Changes.asCoreException(exception);		} finally {			if (document != null) {				try {					if (session != null)						((IDocumentExtension4) result).stopRewriteSession(session);				} finally {					releaseDocument(document, new SubProgressMonitor(monitor, 1));				}			}			monitor.done();		}		if (result == null)			result= new Document();		return result;	}