diff options
author | paltherr <paltherr@epfl.ch> | 2004-03-25 08:46:20 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2004-03-25 08:46:20 +0000 |
commit | d7541a389ad3fcac61091568bcbf39f1fe7d7d15 (patch) | |
tree | 95a95b493426713db14f3763af94119909c7baf3 /sources/scalac/symtab/SymbolNameWriter.java | |
parent | 95749d947ceb65bb0b49c487d11cd77bb2e1f4af (diff) | |
download | scala-d7541a389ad3fcac61091568bcbf39f1fe7d7d15.tar.gz scala-d7541a389ad3fcac61091568bcbf39f1fe7d7d15.tar.bz2 scala-d7541a389ad3fcac61091568bcbf39f1fe7d7d15.zip |
- Added appendSymbol with prefix in SymbolNameW...
- Added appendSymbol with prefix in SymbolNameWriter Added toString
- methods in SymbolNameWriter
Diffstat (limited to 'sources/scalac/symtab/SymbolNameWriter.java')
-rw-r--r-- | sources/scalac/symtab/SymbolNameWriter.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/sources/scalac/symtab/SymbolNameWriter.java b/sources/scalac/symtab/SymbolNameWriter.java index 2a9b5ccb04..d9edc856ba 100644 --- a/sources/scalac/symtab/SymbolNameWriter.java +++ b/sources/scalac/symtab/SymbolNameWriter.java @@ -77,6 +77,9 @@ public class SymbolNameWriter { /** The number of pending characters */ private int pending; + /** The prefix for the current operation (null if none) */ + private String prefix; + //######################################################################## // Public Constructors @@ -181,6 +184,29 @@ public class SymbolNameWriter { } //######################################################################## + // Public Method - To string operations + + /** Returns the string formed by the symbol. */ + public String toString(Symbol symbol) { + return appendSymbol(symbol).toString(); + } + + /** Returns the string formed by the prefix and symbol. */ + public String toString(String prefix, Symbol symbol) { + return appendSymbol(prefix, symbol).toString(); + } + + /** Returns the string formed by the symbol and suffix. */ + public String toString(Symbol symbol, String suffix) { + return appendSymbol(symbol, suffix).toString(); + } + + /** Returns the string formed by the prefix, symbol and suffix. */ + public String toString(String prefix, Symbol symbol, String suffix) { + return appendSymbol(prefix, symbol, suffix).toString(); + } + + //######################################################################## // Public Method - Append operations /** Appends given symbol. */ @@ -191,12 +217,29 @@ public class SymbolNameWriter { return appendPrefix(symbol.owner(), separator).append(name);; } + /** Appends given prefix and symbol. */ + public StringBuffer appendSymbol(String prefix, Symbol symbol) { + assert this.prefix == null && prefix != null; + this.prefix = prefix; + return appendSymbol(symbol); + } + /** Appends given symbol and suffix. */ public StringBuffer appendSymbol(Symbol symbol, String suffix) { this.pending += suffix.length(); return appendSymbol(symbol).append(suffix); } + /** Appends given prefix, symbol and suffix. */ + public StringBuffer appendSymbol(String prefix, Symbol symbol, + String suffix) + { + assert this.prefix == null && prefix != null; + this.prefix = prefix; + this.pending += suffix.length(); + return appendSymbol(symbol).append(suffix); + } + /** Appends prefix formed by given owner and separator. */ public StringBuffer appendPrefix(Symbol owner, char separator) { if (separator == 0) return getStringBuffer(); @@ -230,12 +273,15 @@ public class SymbolNameWriter { /** Returns the string buffer. */ public StringBuffer getStringBuffer() { + if (prefix != null) pending += prefix.length(); if (buffer == null) { this.buffer = new StringBuffer(pending); } else { buffer.ensureCapacity(buffer.length() + pending); } + if (prefix != null) buffer.append(prefix); this.pending = 0; + this.prefix = null; return buffer; } |