1 /*******************************************************************************
2 * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v0.5
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v05.html
9 * IBM Corporation - initial API and implementation
10 ******************************************************************************/
11 package net.sourceforge.phpdt.core;
14 * Specification for a generic source code formatter. Client plug-ins can contribute
15 * an implementation for an ICodeFormatter, through the extension point "net.sourceforge.phpdt.core.codeFormatter".
16 * In case none is found, a default formatter can be provided through the ToolFactory.
18 * @see ToolFactory#createCodeFormatter()
19 * @see ToolFactory#createDefaultCodeFormatter(Map options)
22 public interface ICodeFormatter {
25 * Formats the String <code>sourceString</code>,
26 * and returns a string containing the formatted version.
28 * @param string the string to format
29 * @param indentationLevel the initial indentation level, used
30 * to shift left/right the entire source fragment. An initial indentation
31 * level of zero has no effect.
32 * @param positions an array of positions to map. These are
33 * character-based source positions inside the original source,
34 * for which corresponding positions in the formatted source will
35 * be computed (so as to relocate elements associated with the original
36 * source). It updates the positions array with updated positions.
37 * If set to <code>null</code>, then no positions are mapped.
38 * @param lineSeparator the line separator to use in formatted source,
39 * if set to <code>null</code>, then the platform default one will be used.
40 * @return the formatted output string.
42 String format(String string, int indentationLevel, int[] positions, String lineSeparator);