Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 465978ace463650eee3178520f16ad6a9af5d7c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*******************************************************************************
 * Copyright (c) 2000, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jface.text.formatter;


import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;


/**
 * The interface of a document content formatter. The formatter formats ranges
 * within documents. The documents are modified by the formatter.<p>
 * The content formatter is assumed to determine the partitioning of the document
 * range to be formatted. For each partition, the formatter determines based
 * on the partition's content type the formatting strategy to be used. Before
 * the first strategy is activated all strategies are informed about the
 * start of the formatting process. After that, the formatting strategies are
 * activated in the sequence defined by the partitioning of the document range to be
 * formatted. It is assumed that a strategy must be finished before the next strategy
 * can be activated. After the last strategy has been finished, all strategies are
 * informed about the termination of the formatting process.<p>
 * The interface can be implemented by clients. By default, clients use <code>ContentFormatter</code>
 * or <code>MultiPassContentFormatter</code> as the standard implementers of this interface.
 *
 * @see IDocument
 * @see IFormattingStrategy
 */
public interface IContentFormatter {

	/**
	 * Formats the given region of the specified document.The formatter may safely
	 * assume that it is the only subject that modifies the document at this point in time.
	 *
	 * @param document the document to be formatted
	 * @param region the region within the document to be formatted
	 */
	void format(IDocument document, IRegion region);

	/**
	 * Returns the formatting strategy registered for the given content type.
	 *
	 * @param contentType the content type for which to look up the formatting strategy
	 * @return the formatting strategy for the given content type, or
	 *		<code>null</code> if there is no such strategy
	 */
	IFormattingStrategy getFormattingStrategy(String contentType);
}

Back to the top