Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2011-10-26 18:24:10 -0400
committerSergey Prigogin2011-11-07 14:02:21 -0500
commit168e1f446012ffb85c26de067475e52622f4e280 (patch)
treebd9cc72cc26e52a9029b9def148fa34e86a55a36 /core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite
parent0ebca71a1d033d48e706a847f113a4c8c86951de (diff)
downloadorg.eclipse.cdt-168e1f446012ffb85c26de067475e52622f4e280.tar.gz
org.eclipse.cdt-168e1f446012ffb85c26de067475e52622f4e280.tar.xz
org.eclipse.cdt-168e1f446012ffb85c26de067475e52622f4e280.zip
Cosmetics.
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/Scribe.java61
1 files changed, 28 insertions, 33 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/Scribe.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/Scribe.java
index 7a35655c1f..9751cefd6a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/Scribe.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/Scribe.java
@@ -12,20 +12,16 @@
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
/**
- *
- * This class is responsible for the string concatination and the management of
+ * This class is responsible for the string concatenation and the management of
* the indentations.
*
* @since 5.0
* @author Emanuel Graf IFS
- *
*/
public class Scribe {
-
-
private int indentationLevel = 0;
private int indentationSize = 4; //HSR tcorbat: could be a tab character too - this is not a very elegant solution
- private StringBuffer buffer = new StringBuffer();
+ private StringBuilder buffer = new StringBuilder();
private boolean isAtLineBeginning = true;
private String newLine = System.getProperty("line.separator"); //$NON-NLS-1$
private String givenIndentation = null;
@@ -33,32 +29,32 @@ public class Scribe {
private boolean noNewLine = false;
private boolean noSemicolon = false;
- public void newLine(){
- if(!noNewLine) {
+ public void newLine() {
+ if (!noNewLine) {
isAtLineBeginning = true;
buffer.append(getNewline());
}
}
- private void indent(){
- if( givenIndentation != null ){
- buffer.append( givenIndentation );
+ private void indent() {
+ if (givenIndentation != null) {
+ buffer.append(givenIndentation);
}
printSpaces(indentationLevel * indentationSize);
}
- private void indentIfNewLine(){
- if(isAtLineBeginning){
+ private void indentIfNewLine() {
+ if (isAtLineBeginning) {
isAtLineBeginning = false;
indent();
}
}
- private String getNewline(){
+ private String getNewline() {
return newLine;
}
- public void print(String code){
+ public void print(String code) {
indentIfNewLine();
buffer.append(code);
}
@@ -78,15 +74,15 @@ public class Scribe {
newLine();
}
- public void println(String code , char[] code2) {
+ public void println(String code, char[] code2) {
print(code);
buffer.append(code2);
newLine();
}
- public void printSpaces(int number){
+ public void printSpaces(int number) {
indentIfNewLine();
- for(int i = 0; i < number; ++i){
+ for (int i = 0; i < number; ++i) {
printSpace();
}
}
@@ -95,18 +91,17 @@ public class Scribe {
noSemicolon = true;
}
- public void printSemicolon(){
- if(!noSemicolon) {
+ public void printSemicolon() {
+ if (!noSemicolon) {
indentIfNewLine();
buffer.append(';');
- }
- else {
+ } else {
noSemicolon = false;
}
}
@Override
- public String toString(){
+ public String toString() {
return buffer.toString();
}
@@ -125,13 +120,13 @@ public class Scribe {
newLine();
}
- public void printStringSpace(String code){
+ public void printStringSpace(String code) {
print(code);
printSpace();
}
/**
- * Prints a { to the Buffer an increases the Indentationlevel.
+ * Prints a { to the Buffer an increases the indentation level.
*/
public void printLBrace() {
print('{');
@@ -139,33 +134,33 @@ public class Scribe {
}
/**
- * Prints a } to the Buffer an decrease the Indentationlevel.
+ * Prints a } to the Buffer an decrease the indentation level.
*/
public void printRBrace() {
--indentationLevel;
print('}');
}
- public void incrementIndentationLevel(){
+ public void incrementIndentationLevel() {
++indentationLevel;
}
- public void decrementIndentationLevel(){
- if(indentationLevel>0) {
+ public void decrementIndentationLevel() {
+ if (indentationLevel > 0) {
--indentationLevel;
}
}
- protected void noNewLines(){
+ protected void noNewLines() {
noNewLine = true;
}
- protected void newLines(){
+ protected void newLines() {
noNewLine = false;
}
public void newLine(int i) {
- while(i > 0) {
+ while (i > 0) {
newLine();
--i;
}
@@ -184,6 +179,6 @@ public class Scribe {
}
public void cleanCache() {
- buffer = new StringBuffer();
+ buffer = new StringBuilder();
}
}

Back to the top