Organized imports
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / core / ICodeFormatter.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  ******************************************************************************/
11 package net.sourceforge.phpdt.core;
12
13 import java.util.Map;
14
15 /**
16  * Specification for a generic source code formatter. Client plug-ins can contribute
17  * an implementation for an ICodeFormatter, through the extension point "org.phpeclipse.phpdt.core.codeFormatter".
18  * In case none is found, a default formatter can be provided through the ToolFactory.
19  * 
20  * @see ToolFactory#createCodeFormatter()
21  * @see ToolFactory#createDefaultCodeFormatter(Map options)
22  * @since 2.0
23  */
24 public interface ICodeFormatter {
25
26         /** 
27          * Formats the String <code>sourceString</code>,
28          * and returns a string containing the formatted version.
29          * 
30          * @param string the string to format
31          * @param indentationLevel the initial indentation level, used 
32          *      to shift left/right the entire source fragment. An initial indentation
33          *      level of zero has no effect.
34          * @param positions an array of positions to map. These are
35          *      character-based source positions inside the original source,
36          *     for which corresponding positions in the formatted source will
37          *     be computed (so as to relocate elements associated with the original
38          *     source). It updates the positions array with updated positions.
39          *     If set to <code>null</code>, then no positions are mapped.
40          * @param lineSeparator the line separator to use in formatted source,
41          *     if set to <code>null</code>, then the platform default one will be used.
42          * @return the formatted output string.
43          */
44         String format(String string, int indentationLevel, int[] positions, String lineSeparator);
45 }