IDocumentExtension extension= null; IDocumentExtension2 extension2= null;  if (document instanceof IDocumentExtension) {  extension= (IDocumentExtension)document;  extension.startSequentialRewrite(false); extension.stopPostNotificationProcessing(); }  if (document instanceof IDocumentExtension2) {  extension2= (IDocumentExtension2)document; extension2.stopListenerNotification(); }
	public void format(String indentation) {		final IDocument document= getDocument();		final Map preferences= getStrategy().getPreferences();		int margin= 80;		try {			margin= Integer.parseInt(preferences.get(PreferenceConstants.FORMATTER_COMMENT_LINELENGTH).toString());		} catch (Exception exception) {			// Do nothing		}		margin= Math.max(COMMENT_PREFIX_LENGTH + 1, margin - stringToLength(indentation) - COMMENT_PREFIX_LENGTH);		IDocumentExtension extension= null;		IDocumentExtension2 extension2= null;		if (document instanceof IDocumentExtension) {			extension= (IDocumentExtension)document;			extension.startSequentialRewrite(false);			extension.stopPostNotificationProcessing();		}		if (document instanceof IDocumentExtension2) {			extension2= (IDocumentExtension2)document;			extension2.stopListenerNotification();		}		document.addPositionCategory(COMMENT_POSITION_CATEGORY);		final IPositionUpdater positioner= new DefaultPositionUpdater(COMMENT_POSITION_CATEGORY);		document.addPositionUpdater(positioner);		try {			initializeRegion();			markRegion();			wrapRegion(margin);			applyRegion(indentation, margin);			finalizeRegion(indentation);		} finally {			if (fGraphics != null && !fGraphics.isDisposed())				fGraphics.dispose();			try {				document.removePositionCategory(COMMENT_POSITION_CATEGORY);				document.removePositionUpdater(positioner);			} catch (BadPositionCategoryException exception) {				// Should not happen			}			if (extension2 != null)				extension2.resumeListenerNotification();			if (extension != null) {				extension.resumePostNotificationProcessing();				extension.stopSequentialRewrite();			}		}	}