1 /******************************************************************************* 2 * Copyright (c) 2000, 2005 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.jface.text.formatter; 12 13 14 import org.eclipse.jface.text.IDocument; 15 import org.eclipse.jface.text.IRegion; 16 17 18 /** 19 * The interface of a document content formatter. The formatter formats ranges 20 * within documents. The documents are modified by the formatter.<p> 21 * The content formatter is assumed to determine the partitioning of the document 22 * range to be formatted. For each partition, the formatter determines based 23 * on the partition's content type the formatting strategy to be used. Before 24 * the first strategy is activated all strategies are informed about the 25 * start of the formatting process. After that, the formatting strategies are 26 * activated in the sequence defined by the partitioning of the document range to be 27 * formatted. It is assumed that a strategy must be finished before the next strategy 28 * can be activated. After the last strategy has been finished, all strategies are 29 * informed about the termination of the formatting process.</p> 30 * <p> 31 * The interface can be implemented by clients. By default, clients use <code>ContentFormatter</code> 32 * or <code>MultiPassContentFormatter</code> as the standard implementers of this interface.</p> 33 * 34 * @see IDocument 35 * @see IFormattingStrategy 36 */ 37 public interface IContentFormatter { 38 39 /** 40 * Formats the given region of the specified document.The formatter may safely 41 * assume that it is the only subject that modifies the document at this point in time. 42 * 43 * @param document the document to be formatted 44 * @param region the region within the document to be formatted 45 */ 46 void format(IDocument document, IRegion region); 47 48 /** 49 * Returns the formatting strategy registered for the given content type. 50 * 51 * @param contentType the content type for which to look up the formatting strategy 52 * @return the formatting strategy for the given content type, or 53 * <code>null</code> if there is no such strategy 54 */ 55 IFormattingStrategy getFormattingStrategy(String contentType); 56 } 57