/*******************************************************************************
* Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ *
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
******************************************************************************/
/**
* Creates a new instance of Code Formatter using the given settings.
- *
+ *
* @deprecated backport 1.0 internal functionality
*/
public CodeFormatter(ConfigurableOption[] settings) {
/**
* Creates a new instance of Code Formatter using the FormattingOptions object given as argument
- *
+ *
* @deprecated Use CodeFormatter(ConfigurableOption[]) instead
*/
public CodeFormatter() {
/**
* Formats the char array <code>sourceString</code>, and returns a string containing the formatted version.
- *
+ *
* @return the formatted ouput.
*/
public String formatSourceString(String sourceString) {
/**
* Formats the char array <code>sourceString</code>, and returns a string containing the formatted version.
- *
+ *
* @param string
* the string to format
* @param indentationLevel
/**
* Formats the char array <code>sourceString</code>, and returns a string containing the formatted version. The positions array
* is modified to contain the mapped positions.
- *
+ *
* @param string
* the string to format
* @param indentationLevel
/**
* Formats the char array <code>sourceString</code>, and returns a string containing the formatted version. The initial
* indentation level is 0.
- *
+ *
* @param string
* the string to format
* @return the formatted ouput.
/**
* Formats a given source string, starting indenting it at a particular depth and using the given options
- *
+ *
* @deprecated backport 1.0 internal functionality
*/
public static String format(String sourceString, int initialIndentationLevel, ConfigurableOption[] options) {
/**
* Returns an array of descriptions for the configurable options. The descriptions may be changed and passed back to a different
* compiler.
- *
+ *
* @deprecated backport 1.0 internal functionality
*/
public static ConfigurableOption[] getDefaultOptions(Locale locale) {
/**
* Returns the array of mapped positions. Returns null is no positions have been set.
- *
+ *
* @return int[]
* @deprecated There is no need to retrieve the mapped positions anymore.
*/
/**
* Returns the priority of the token given as argument <br>
* The most prioritary the token is, the smallest the return value is.
- *
+ *
* @return the priority of <code>token</code>
* @param token
* the token of which the priority is requested
/**
* If the length of <code>oneLineBuffer</code> exceeds <code>maxLineLength</code>, it is split and the result is dumped in
* <code>formattedSource</code>
- *
+ *
* @param newLineCount
* the number of new lines to append
*/
return "==="; //$NON-NLS-1$
case TokenNameEQUAL_GREATER:
// -= (15.25.2)
- return "=>"; //$NON-NLS-1$
+ return "=>"; //$NON-NLS-1$
case TokenNameNOT_EQUAL:
// != (15.20, 15.20.1, 15.20.2, 15.20.3)
return "!="; //$NON-NLS-1$
* <li>If its length is < maxLineLength, output
* <li>Otherwise it is split.
* </ul>
- *
+ *
* @param currentString
* string to output
* @param preIndented
String currentResult = result[i];
if (currentResult.length() != 0 || splitOperators[i] != 0) {
int newDepth = (currentResult.startsWith("/*") //$NON-NLS-1$
- || currentResult.startsWith("//")) //$NON-NLS-1$
+ || currentResult.startsWith("//")) //$NON-NLS-1$
? indentationLevel - 1 : depth;
outputLine(currentResult, i == 0 || (i == 1 && emptyFirstSubString) ? preIndented : false,
i == 0 ? newDepth : newDepth + 1, splitOperators[i], i, splitLine.startSubstringsIndexes, currentString
/**
* Pops elements until the stack is empty or the top element is <code>token</code>.<br>
* Does not remove <code>token</code> from the stack.
- *
+ *
* @param token
* the token to be left as the top of the stack
*/
/**
* Pops elements until the stack is empty or the top element is <code>token</code>.<br>
* Removes <code>token</code> from the stack too.
- *
+ *
* @param token
* the token to remove from the stack
*/
/**
* Set the positions to map. The mapped positions should be retrieved using the getMappedPositions() method.
- *
+ *
* @param positions
* int[]
* @deprecated Set the positions to map using the format(String, int, int[]) method.
- *
+ *
* @see #getMappedPositions()
*/
public void setPositionsToMap(int[] positions) {
/**
* Splits <code>stringToSplit</code> on the top level token <br>
* If there are several identical token at the same level, the string is cut into many pieces.
- *
+ *
* @return an object containing the operator and all the substrings or null if the string cannot be split
*/
public SplitLine split(String stringToSplit) {
/**
* Splits <code>stringToSplit</code> on the top level token <br>
* If there are several identical token at the same level, the string is cut into many pieces.
- *
+ *
* @return an object containing the operator and all the substrings or null if the string cannot be split
*/
public SplitLine split(String stringToSplit, int offsetInGlobalLine) {
if (posToMap < 0 || posToMap >= sourceLength) {
// protection against out of bounds position
if (posToMap == sourceLength) {
- mappedPositions[indexToMap] = formattedSource.length();
+ mappedPositions[indexToMap] = formattedSource.length()-1;
}
indexToMap = positionsToMap.length; // no more mapping
return;
} else {
mappedPositions[indexToMap] = posToMap + globalDelta + lineDelta;
}
+ if (mappedPositions[indexToMap]>=formattedSource.length()) {
+ mappedPositions[indexToMap]=formattedSource.length()-1;
+ }
}
indexToMap++;
}
while (indexInMap < mappedPositions.length && startPosition <= mappedPositions[indexInMap]
&& mappedPositions[indexInMap] < endPosition && indexInMap < indexToMap) {
mappedPositions[indexInMap] += splitDelta;
+ if (mappedPositions[indexInMap]>=formattedSource.length()) {
+ mappedPositions[indexInMap]=formattedSource.length()-1;
+ }
indexInMap++;
}
}
/**
* Sets the initial indentation level
- *
+ *
* @param indentationLevel
* new indentation level
- *
+ *
* @deprecated
*/
public void setInitialIndentationLevel(int newIndentationLevel) {