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 12 package org.eclipse.jface.text.formatter; 13 14 15 /** 16 * A formatting strategy is assumed to be specialized on formatting text 17 * of a particular content type. Each formatting process calls the strategy's 18 * methods in the following sequence: 19 * <ul> 20 * <li><code>formatterStarts</code> 21 * <li><code>format</code> 22 * <li><code>formatterStops</code> 23 * </ul> 24 * <p> 25 * This interface must be implemented by clients. Implementers should be registered with 26 * a content formatter in order get involved in the formatting process.</p> 27 */ 28 public interface IFormattingStrategy { 29 30 /** 31 * Informs the strategy about the start of a formatting process in which it will 32 * participate. 33 * 34 * @param initialIndentation the indent string of the first line at which the 35 * overall formatting process starts. 36 */ 37 void formatterStarts(String initialIndentation); 38 39 /** 40 * Formats the given string. During the formatting process this strategy must update 41 * the given character positions according to the changes applied to the given string. 42 * 43 * @param content the initial string to be formatted 44 * @param isLineStart indicates whether the beginning of content is a line start in its document 45 * @param indentation the indentation string to be used 46 * @param positions the character positions to be updated 47 * @return the formatted string 48 */ 49 String format(String content, boolean isLineStart, String indentation, int[] positions); 50 51 /** 52 * Informs the strategy that the formatting process in which it has participated 53 * has been finished. 54 */ 55 void formatterStops(); 56 } 57