mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
Use StringBuilder
This commit is contained in:
parent
fec33bb137
commit
5f53601812
5 changed files with 109 additions and 109 deletions
|
@ -224,9 +224,9 @@ public class IndentAction extends TextEditorAction {
|
|||
|
||||
wsStart= offset + slashes;
|
||||
|
||||
StringBuffer computed= indenter.computeIndentation(offset);
|
||||
StringBuilder computed= indenter.computeIndentation(offset);
|
||||
if (computed == null)
|
||||
computed= new StringBuffer(0);
|
||||
computed= new StringBuilder(0);
|
||||
int tabSize= getTabSize();
|
||||
while (slashes > 0 && computed.length() > 0) {
|
||||
char c= computed.charAt(0);
|
||||
|
@ -251,7 +251,7 @@ public class IndentAction extends TextEditorAction {
|
|||
|
||||
// standard C code indentation
|
||||
if (indent == null) {
|
||||
StringBuffer computed= indenter.computeIndentation(offset);
|
||||
StringBuilder computed= indenter.computeIndentation(offset);
|
||||
if (computed != null)
|
||||
indent= computed.toString();
|
||||
else
|
||||
|
|
|
@ -181,10 +181,10 @@ public final class IndentUtil {
|
|||
|
||||
boolean indentInsideLineComments= indentInsideLineComments(project);
|
||||
String current= getCurrentIndent(document, lines.getStartLine(), indentInsideLineComments);
|
||||
StringBuffer correct= new StringBuffer(computeIndent(document, lines.getStartLine(), indenter, scanner));
|
||||
StringBuilder correct= new StringBuilder(computeIndent(document, lines.getStartLine(), indenter, scanner));
|
||||
|
||||
int tabSize= CodeFormatterUtil.getTabWidth(project);
|
||||
StringBuffer addition= new StringBuffer();
|
||||
StringBuilder addition= new StringBuilder();
|
||||
int difference= subtractIndent(correct, current, addition, tabSize);
|
||||
|
||||
if (difference == 0)
|
||||
|
@ -308,7 +308,7 @@ public final class IndentUtil {
|
|||
* @param difference a string buffer - if the return value is positive, it will be cleared and set to the substring of <code>current</code> of that length
|
||||
* @return the difference in lenght of <code>correct</code> and <code>current</code>
|
||||
*/
|
||||
private static int subtractIndent(CharSequence correct, CharSequence current, StringBuffer difference, int tabSize) {
|
||||
private static int subtractIndent(CharSequence correct, CharSequence current, StringBuilder difference, int tabSize) {
|
||||
int c1= computeVisualLength(correct, tabSize);
|
||||
int c2= computeVisualLength(current, tabSize);
|
||||
int diff= c1 - c2;
|
||||
|
@ -454,7 +454,7 @@ public final class IndentUtil {
|
|||
|
||||
// standard C code indentation
|
||||
if (indent == null) {
|
||||
StringBuffer computed= indenter.computeIndentation(offset);
|
||||
StringBuilder computed= indenter.computeIndentation(offset);
|
||||
if (computed != null)
|
||||
indent= computed.toString();
|
||||
else
|
||||
|
@ -517,7 +517,7 @@ public final class IndentUtil {
|
|||
|
||||
// standard C code indentation
|
||||
if (indent == null) {
|
||||
StringBuffer computed= indenter.computeIndentation(offset);
|
||||
StringBuilder computed= indenter.computeIndentation(offset);
|
||||
if (computed != null)
|
||||
indent= computed.toString();
|
||||
else
|
||||
|
@ -559,7 +559,7 @@ public final class IndentUtil {
|
|||
int previousLineLength= previousLine.getLength();
|
||||
int previousLineEnd= previousLineStart + previousLineLength;
|
||||
|
||||
StringBuffer buf= new StringBuffer();
|
||||
StringBuilder buf= new StringBuilder();
|
||||
int previousLineNonWS= scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
|
||||
if (previousLineNonWS == CHeuristicScanner.NOT_FOUND || document.getChar(previousLineNonWS) != '*') {
|
||||
// align with the comment start if the previous line is not an asterix line
|
||||
|
@ -598,9 +598,9 @@ public final class IndentUtil {
|
|||
CHeuristicScanner ppScanner= new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, partition.getType());
|
||||
CIndenter ppIndenter= new CIndenter(document, ppScanner);
|
||||
if (line == ppFirstLine + 1) {
|
||||
return ppIndenter.createReusingIndent(new StringBuffer(), 1).toString();
|
||||
return ppIndenter.createReusingIndent(new StringBuilder(), 1).toString();
|
||||
}
|
||||
StringBuffer computed= ppIndenter.computeIndentation(document.getLineOffset(line), false);
|
||||
StringBuilder computed= ppIndenter.computeIndentation(document.getLineOffset(line), false);
|
||||
if (computed != null) {
|
||||
return computed.toString();
|
||||
}
|
||||
|
@ -612,7 +612,7 @@ public final class IndentUtil {
|
|||
|
||||
int previousLineNonWS= ppScanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
|
||||
String previousIndent= document.get(previousLineStart, previousLineNonWS - previousLineStart);
|
||||
computed= new StringBuffer(previousIndent);
|
||||
computed= new StringBuilder(previousIndent);
|
||||
return computed.toString();
|
||||
}
|
||||
|
||||
|
@ -628,7 +628,7 @@ public final class IndentUtil {
|
|||
if (column > displayedWidth) {
|
||||
return prefix;
|
||||
}
|
||||
final StringBuffer buffer = new StringBuffer(prefix);
|
||||
final StringBuilder buffer = new StringBuilder(prefix);
|
||||
appendIndent(buffer, displayedWidth, tabWidth, useSpaces, column);
|
||||
return buffer.toString();
|
||||
}
|
||||
|
@ -640,9 +640,9 @@ public final class IndentUtil {
|
|||
* @param tabWidth the configured tab width
|
||||
* @param useSpaces whether tabs should be substituted by spaces
|
||||
* @param startColumn the column where to start measurement
|
||||
* @return StringBuffer
|
||||
* @return StringBuilder
|
||||
*/
|
||||
private static StringBuffer appendIndent(StringBuffer buffer, int width, int tabWidth, boolean useSpaces, int startColumn) {
|
||||
private static StringBuilder appendIndent(StringBuilder buffer, int width, int tabWidth, boolean useSpaces, int startColumn) {
|
||||
assert tabWidth > 0;
|
||||
int tabStop = startColumn - startColumn % tabWidth;
|
||||
int tabs = useSpaces ? 0 : (width-tabStop) / tabWidth;
|
||||
|
|
|
@ -49,15 +49,15 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
|
|||
private static final String LINE_COMMENT= "//"; //$NON-NLS-1$
|
||||
// private static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
|
||||
|
||||
private static class CompilationUnitInfo {
|
||||
char[] buffer;
|
||||
int delta;
|
||||
|
||||
CompilationUnitInfo(char[] buffer, int delta) {
|
||||
this.buffer = buffer;
|
||||
this.delta = delta;
|
||||
}
|
||||
}
|
||||
// private static class CompilationUnitInfo {
|
||||
// char[] buffer;
|
||||
// int delta;
|
||||
//
|
||||
// CompilationUnitInfo(char[] buffer, int delta) {
|
||||
// this.buffer = buffer;
|
||||
// this.delta = delta;
|
||||
// }
|
||||
// }
|
||||
|
||||
private boolean fCloseBrace;
|
||||
private boolean fIsSmartMode;
|
||||
|
@ -186,7 +186,7 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
|
|||
int indLine = d.getLineOfOffset(reference);
|
||||
if (indLine != -1 && indLine != line) {
|
||||
// take the indent of the found line
|
||||
StringBuffer replaceText = new StringBuffer(getIndentOfLine(d, indLine));
|
||||
StringBuilder replaceText = new StringBuilder(getIndentOfLine(d, indLine));
|
||||
// add the rest of the current line including the just added close bracket
|
||||
replaceText.append(d.get(whiteend, c.offset - whiteend));
|
||||
replaceText.append(c.text);
|
||||
|
@ -230,7 +230,7 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
|
|||
// Only shift if the last C line is further up and is a braceless block candidate
|
||||
if (lastLine < line) {
|
||||
CIndenter indenter = new CIndenter(d, scanner, fProject);
|
||||
StringBuffer indent = indenter.computeIndentation(p, true);
|
||||
StringBuilder indent = indenter.computeIndentation(p, true);
|
||||
String toDelete = d.get(lineOffset, c.offset - lineOffset);
|
||||
if (indent != null && !indent.toString().equals(toDelete)) {
|
||||
c.text = indent.append(c.text).toString();
|
||||
|
@ -253,7 +253,7 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
|
|||
CHeuristicScanner scanner= new CHeuristicScanner(d);
|
||||
try {
|
||||
ITypedRegion partition= TextUtilities.getPartition(d, fPartitioning, c.offset, false);
|
||||
if (ICPartitions.C_PREPROCESSOR.equals(partition.getType()) && d.get(c.offset-1, 1).charAt(0) == '\\') {
|
||||
if (ICPartitions.C_PREPROCESSOR.equals(partition.getType()) && c.offset > 0 && d.getChar(c.offset-1) == '\\') {
|
||||
scanner = new CHeuristicScanner(d, fPartitioning, ICPartitions.C_PREPROCESSOR);
|
||||
addIndent= 1;
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
|
|||
int start = reg.getOffset();
|
||||
int lineEnd = start + reg.getLength();
|
||||
|
||||
StringBuffer indent= null;
|
||||
StringBuilder indent= null;
|
||||
CIndenter indenter= new CIndenter(d, scanner, fProject);
|
||||
if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_AUTO_INDENT)) {
|
||||
indent= indenter.computeIndentation(c.offset);
|
||||
|
@ -271,18 +271,18 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
|
|||
// reuse existing indent
|
||||
int wsEnd= findEndOfWhiteSpace(d, start, c.offset);
|
||||
if (wsEnd > start) {
|
||||
indent= new StringBuffer(d.get(start, wsEnd - start));
|
||||
indent= new StringBuilder(d.get(start, wsEnd - start));
|
||||
addIndent= 0;
|
||||
}
|
||||
}
|
||||
if (indent == null) {
|
||||
indent= new StringBuffer();
|
||||
indent= new StringBuilder();
|
||||
}
|
||||
if (addIndent > 0 && indent.length() == 0) {
|
||||
indent= indenter.createReusingIndent(indent, addIndent);
|
||||
}
|
||||
|
||||
StringBuffer buf = new StringBuffer(c.text + indent);
|
||||
StringBuilder buf = new StringBuilder(c.text + indent);
|
||||
int contentStart = findEndOfWhiteSpace(d, c.offset, lineEnd);
|
||||
c.length = Math.max(contentStart - c.offset, 0);
|
||||
|
||||
|
@ -301,10 +301,10 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
|
|||
}
|
||||
|
||||
buf.append(TextUtilities.getDefaultLineDelimiter(d));
|
||||
StringBuffer reference = null;
|
||||
StringBuilder reference = null;
|
||||
int nonWS = findEndOfWhiteSpace(d, start, lineEnd);
|
||||
if (nonWS < c.offset && d.getChar(nonWS) == '{')
|
||||
reference = new StringBuffer(d.get(start, nonWS - start));
|
||||
reference = new StringBuilder(d.get(start, nonWS - start));
|
||||
else
|
||||
reference = indenter.getReferenceIndentation(c.offset);
|
||||
if (reference != null)
|
||||
|
@ -326,10 +326,10 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
|
|||
c.caretOffset = c.offset + buf.length();
|
||||
c.shiftsCaret = false;
|
||||
|
||||
StringBuffer reference = null;
|
||||
StringBuilder reference = null;
|
||||
int nonWS = findEndOfWhiteSpace(d, start, lineEnd);
|
||||
if (nonWS < c.offset && d.getChar(nonWS) == '{')
|
||||
reference = new StringBuffer(d.get(start, nonWS - start));
|
||||
reference = new StringBuilder(d.get(start, nonWS - start));
|
||||
else
|
||||
reference = indenter.getReferenceIndentation(c.offset);
|
||||
|
||||
|
@ -408,12 +408,12 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
|
|||
}
|
||||
|
||||
private boolean isClosedBrace(IDocument document, int offset, int length) {
|
||||
CompilationUnitInfo info = getCompilationUnitForMethod(document, offset, fPartitioning);
|
||||
if (info == null)
|
||||
return false;
|
||||
|
||||
return getBlockBalance(document, offset, fPartitioning) <= 0;
|
||||
//TODO: Use smarter algorithm based on
|
||||
// CompilationUnitInfo info = getCompilationUnitForMethod(document, offset, fPartitioning);
|
||||
// if (info == null)
|
||||
// return false;
|
||||
//
|
||||
// CodeReader reader = new CodeReader(info.buffer);
|
||||
// ICodeReaderFactory fileCreator = CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE);
|
||||
//
|
||||
|
@ -582,7 +582,7 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
|
|||
// (as the first might be partially selected) and use the value to
|
||||
// indent all other lines.
|
||||
boolean isIndentDetected= false;
|
||||
StringBuffer addition= new StringBuffer();
|
||||
StringBuilder addition= new StringBuilder();
|
||||
int insertLength= 0;
|
||||
int first= document.computeNumberOfLines(prefix) + firstLine; // don't format first line
|
||||
int lines= temp.getNumberOfLines();
|
||||
|
@ -600,7 +600,7 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
|
|||
if (!isIndentDetected) {
|
||||
// indent the first pasted line
|
||||
String current= IndentUtil.getCurrentIndent(temp, l, indentInsideLineComments);
|
||||
StringBuffer correct= new StringBuffer(IndentUtil.computeIndent(temp, l, indenter, scanner));
|
||||
StringBuilder correct= new StringBuilder(IndentUtil.computeIndent(temp, l, indenter, scanner));
|
||||
|
||||
insertLength= subtractIndent(correct, current, addition);
|
||||
// workaround for bug 181139
|
||||
|
@ -651,7 +651,7 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
|
|||
* @param difference a string buffer - if the return value is positive, it will be cleared and set to the substring of <code>current</code> of that length
|
||||
* @return the difference in lenght of <code>correct</code> and <code>current</code>
|
||||
*/
|
||||
private int subtractIndent(CharSequence correct, CharSequence current, StringBuffer difference) {
|
||||
private int subtractIndent(CharSequence correct, CharSequence current, StringBuilder difference) {
|
||||
int c1= computeVisualLength(correct);
|
||||
int c2= computeVisualLength(current);
|
||||
int diff= c1 - c2;
|
||||
|
@ -1164,29 +1164,29 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
|
|||
return false;
|
||||
}
|
||||
|
||||
private static CompilationUnitInfo getCompilationUnitForMethod(IDocument document, int offset, String partitioning) {
|
||||
try {
|
||||
CHeuristicScanner scanner = new CHeuristicScanner(document);
|
||||
|
||||
IRegion sourceRange = scanner.findSurroundingBlock(offset);
|
||||
if (sourceRange == null)
|
||||
return null;
|
||||
String source = document.get(sourceRange.getOffset(), sourceRange.getLength());
|
||||
|
||||
StringBuffer contents = new StringBuffer();
|
||||
contents.append("class ____C{void ____m()"); //$NON-NLS-1$
|
||||
final int methodOffset = contents.length();
|
||||
contents.append(source);
|
||||
contents.append("};"); //$NON-NLS-1$
|
||||
|
||||
char[] buffer = contents.toString().toCharArray();
|
||||
return new CompilationUnitInfo(buffer, sourceRange.getOffset() - methodOffset);
|
||||
} catch (BadLocationException e) {
|
||||
CUIPlugin.log(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
// private static CompilationUnitInfo getCompilationUnitForMethod(IDocument document, int offset, String partitioning) {
|
||||
// try {
|
||||
// CHeuristicScanner scanner = new CHeuristicScanner(document);
|
||||
//
|
||||
// IRegion sourceRange = scanner.findSurroundingBlock(offset);
|
||||
// if (sourceRange == null)
|
||||
// return null;
|
||||
// String source = document.get(sourceRange.getOffset(), sourceRange.getLength());
|
||||
//
|
||||
// StringBuilder contents = new StringBuilder();
|
||||
// contents.append("class ____C{void ____m()"); //$NON-NLS-1$
|
||||
// final int methodOffset = contents.length();
|
||||
// contents.append(source);
|
||||
// contents.append("};"); //$NON-NLS-1$
|
||||
//
|
||||
// char[] buffer = contents.toString().toCharArray();
|
||||
// return new CompilationUnitInfo(buffer, sourceRange.getOffset() - methodOffset);
|
||||
// } catch (BadLocationException e) {
|
||||
// CUIPlugin.log(e);
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns the block balance, i.e. zero if the blocks are balanced at
|
||||
|
|
|
@ -409,7 +409,7 @@ public final class CIndenter {
|
|||
* reference position to <code>offset</code> resides, or <code>null</code>
|
||||
* if it cannot be determined
|
||||
*/
|
||||
public StringBuffer getReferenceIndentation(int offset) {
|
||||
public StringBuilder getReferenceIndentation(int offset) {
|
||||
return getReferenceIndentation(offset, false);
|
||||
}
|
||||
|
||||
|
@ -422,7 +422,7 @@ public final class CIndenter {
|
|||
* reference position to <code>offset</code> resides, or <code>null</code>
|
||||
* if it cannot be determined
|
||||
*/
|
||||
private StringBuffer getReferenceIndentation(int offset, boolean assumeOpeningBrace) {
|
||||
private StringBuilder getReferenceIndentation(int offset, boolean assumeOpeningBrace) {
|
||||
int unit;
|
||||
if (assumeOpeningBrace)
|
||||
unit= findReferencePosition(offset, Symbols.TokenLBRACE);
|
||||
|
@ -444,7 +444,7 @@ public final class CIndenter {
|
|||
* which offset resides, or <code>null</code> if it cannot be
|
||||
* determined
|
||||
*/
|
||||
public StringBuffer computeIndentation(int offset) {
|
||||
public StringBuilder computeIndentation(int offset) {
|
||||
return computeIndentation(offset, false);
|
||||
}
|
||||
|
||||
|
@ -457,8 +457,8 @@ public final class CIndenter {
|
|||
* which offset resides, or <code>null</code> if it cannot be
|
||||
* determined
|
||||
*/
|
||||
public StringBuffer computeIndentation(int offset, boolean assumeOpeningBrace) {
|
||||
StringBuffer reference= getReferenceIndentation(offset, assumeOpeningBrace);
|
||||
public StringBuilder computeIndentation(int offset, boolean assumeOpeningBrace) {
|
||||
StringBuilder reference= getReferenceIndentation(offset, assumeOpeningBrace);
|
||||
|
||||
// handle special alignment
|
||||
if (fAlign != CHeuristicScanner.NOT_FOUND) {
|
||||
|
@ -483,13 +483,13 @@ public final class CIndenter {
|
|||
* Computes the indentation for a continuation line at <code>offset</code>.
|
||||
*
|
||||
* @param offset the offset in the document
|
||||
* @return a StringBuffer which reflects the correct indentation for
|
||||
* @return a StringBuilder which reflects the correct indentation for
|
||||
* the line in which offset resides, or <code>null</code> if it cannot be
|
||||
* determined.
|
||||
* @throws BadLocationException
|
||||
*/
|
||||
public StringBuffer computeContinuationLineIndentation(int offset) throws BadLocationException {
|
||||
StringBuffer reference= getLeadingWhitespace(offset);
|
||||
public StringBuilder computeContinuationLineIndentation(int offset) throws BadLocationException {
|
||||
StringBuilder reference= getLeadingWhitespace(offset);
|
||||
IRegion line= fDocument.getLineInformationOfOffset(offset);
|
||||
String string= fDocument.get(line.getOffset(), offset - line.getOffset());
|
||||
if (string.trim().length() == 0)
|
||||
|
@ -534,7 +534,7 @@ public final class CIndenter {
|
|||
* @param indentLength the maximum visual indentation length
|
||||
* @return the stripped <code>reference</code>
|
||||
*/
|
||||
private StringBuffer stripExceedingChars(StringBuffer reference, int indentLength) {
|
||||
private StringBuilder stripExceedingChars(StringBuilder reference, int indentLength) {
|
||||
final int tabSize= fPrefs.prefTabSize;
|
||||
int measured= 0;
|
||||
int chars= reference.length();
|
||||
|
@ -560,15 +560,15 @@ public final class CIndenter {
|
|||
|
||||
/**
|
||||
* Returns the indentation of the line at <code>offset</code> as a
|
||||
* <code>StringBuffer</code>. If the offset is not valid, the empty string
|
||||
* <code>StringBuilder</code>. If the offset is not valid, the empty string
|
||||
* is returned.
|
||||
*
|
||||
* @param offset the offset in the document
|
||||
* @return the indentation (leading whitespace) of the line in which
|
||||
* <code>offset</code> is located
|
||||
*/
|
||||
private StringBuffer getLeadingWhitespace(int offset) {
|
||||
StringBuffer indent= new StringBuffer();
|
||||
private StringBuilder getLeadingWhitespace(int offset) {
|
||||
StringBuilder indent= new StringBuilder();
|
||||
try {
|
||||
IRegion line= fDocument.getLineInformationOfOffset(offset);
|
||||
int lineOffset= line.getOffset();
|
||||
|
@ -600,10 +600,10 @@ public final class CIndenter {
|
|||
* @return the indentation corresponding to the document content specified
|
||||
* by <code>start</code> and <code>indent</code>
|
||||
*/
|
||||
private StringBuffer createIndent(int start, final int indent, final boolean convertSpaceRunsToTabs) {
|
||||
private StringBuilder createIndent(int start, final int indent, final boolean convertSpaceRunsToTabs) {
|
||||
final boolean convertTabs= fPrefs.prefUseTabs && convertSpaceRunsToTabs;
|
||||
final int tabLen= fPrefs.prefTabSize;
|
||||
final StringBuffer ret= new StringBuffer();
|
||||
final StringBuilder ret= new StringBuilder();
|
||||
try {
|
||||
int spaces= 0;
|
||||
while (start < indent) {
|
||||
|
@ -643,7 +643,7 @@ public final class CIndenter {
|
|||
* @return the modified <code>buffer</code> reflecting the indentation
|
||||
* adapted to <code>additional</code>
|
||||
*/
|
||||
public StringBuffer createReusingIndent(StringBuffer buffer, int additional) {
|
||||
public StringBuilder createReusingIndent(StringBuilder buffer, int additional) {
|
||||
int refLength= computeVisualLength(buffer);
|
||||
int addLength= fPrefs.prefIndentationSize * additional; // may be < 0
|
||||
int totalLength= Math.max(0, refLength + addLength);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2007 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 2008 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
|
||||
|
@ -44,7 +44,7 @@ public class CStringAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy
|
|||
*/
|
||||
private String displayString(String inputString, CharSequence indentation, String delimiter) {
|
||||
int length = inputString.length();
|
||||
StringBuffer buffer = new StringBuffer(length);
|
||||
StringBuilder buffer = new StringBuilder(length);
|
||||
java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(inputString, "\n\r", true); //$NON-NLS-1$
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
String token = tokenizer.nextToken();
|
||||
|
@ -73,7 +73,7 @@ public class CStringAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy
|
|||
continue;
|
||||
}
|
||||
|
||||
StringBuffer tokenBuffer = new StringBuffer();
|
||||
StringBuilder tokenBuffer = new StringBuilder();
|
||||
for (int i = 0; i < token.length(); i++){
|
||||
char c = token.charAt(i);
|
||||
switch (c) {
|
||||
|
@ -143,9 +143,9 @@ public class CStringAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy
|
|||
|
||||
CHeuristicScanner scanner = new CHeuristicScanner(document);
|
||||
CIndenter indenter = new CIndenter(document, scanner, fProject);
|
||||
StringBuffer indentation = indenter.computeContinuationLineIndentation(offset);
|
||||
StringBuilder indentation = indenter.computeContinuationLineIndentation(offset);
|
||||
if (indentation == null)
|
||||
indentation = new StringBuffer();
|
||||
indentation = new StringBuilder();
|
||||
|
||||
String delimiter= TextUtilities.getDefaultLineDelimiter(document);
|
||||
IPreferenceStore preferenceStore= CUIPlugin.getDefault().getPreferenceStore();
|
||||
|
|
Loading…
Add table
Reference in a new issue