| Index: editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/engine/MainEngine.java
|
| diff --git a/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/engine/MainEngine.java b/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/engine/MainEngine.java
|
| index f3ec11f411795caea126e3fe44d675316debdc95..eed6a1fa2adb345887f27bf91e5bd2926e5fde8e 100644
|
| --- a/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/engine/MainEngine.java
|
| +++ b/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/engine/MainEngine.java
|
| @@ -305,31 +305,59 @@ public class MainEngine {
|
| removeClass(library, "TimeCounter");
|
| removeClass(library, "TimeCounter_TimeCounterHandle");
|
| String source = getFormattedSource(library);
|
| - source += Joiner.on("\n").join(
|
| - new String[] {
|
| - "/**",
|
| - " * Helper for measuring how much time is spent doing some operation.",
|
| - " */",
|
| - "class TimeCounter {",
|
| - " Stopwatch _sw = new Stopwatch();",
|
| - "",
|
| - " /**",
|
| - " * @return the number of milliseconds spent between [start] and [stop].",
|
| - " */",
|
| - " int get result => _sw.elapsedMilliseconds;",
|
| - "",
|
| - " /**",
|
| - " * Starts counting time.",
|
| - " *",
|
| - " * @return the [TimeCounterHandle] that should be used to stop counting.",
|
| - " */",
|
| - " TimeCounter_TimeCounterHandle start() => new TimeCounter_TimeCounterHandle(this);",
|
| - "}", "", "/**",
|
| - " * The handle object that should be used to stop and update counter.", " */",
|
| - "class TimeCounter_TimeCounterHandle {", " final TimeCounter _counter;", "",
|
| - " TimeCounter_TimeCounterHandle(this._counter) {", " _counter._sw.start();",
|
| - " }", "", " /**", " * Stops counting time and updates counter.", " */",
|
| - " void stop() {", " _counter._sw.stop();", " }", "}"});
|
| + source += makeSource(
|
| + "/**",
|
| + " * Helper for measuring how much time is spent doing some operation.",
|
| + " */",
|
| + "class TimeCounter {",
|
| + " static TimeCounter _current = null;",
|
| + " final Stopwatch _sw = new Stopwatch();",
|
| + "",
|
| + " /**",
|
| + " * @return the number of milliseconds spent between [start] and [stop].",
|
| + " */",
|
| + " int get result => _sw.elapsedMilliseconds;",
|
| + "",
|
| + " /**",
|
| + " * Starts counting time.",
|
| + " *",
|
| + " * @return the [TimeCounterHandle] that should be used to stop counting.",
|
| + " */",
|
| + " TimeCounter_TimeCounterHandle start() {",
|
| + " return new TimeCounter_TimeCounterHandle(this);",
|
| + " }",
|
| + "}",
|
| + "",
|
| + "/**",
|
| + " * The handle object that should be used to stop and update counter.",
|
| + " */",
|
| + "class TimeCounter_TimeCounterHandle {",
|
| + " final TimeCounter _counter;",
|
| + " TimeCounter _prev;",
|
| + "",
|
| + " TimeCounter_TimeCounterHandle(this._counter) {",
|
| + " // if there is some counter running, pause it",
|
| + " _prev = TimeCounter._current;",
|
| + " if (_prev != null) {",
|
| + " _prev._sw.stop();",
|
| + " }",
|
| + " TimeCounter._current = _counter;",
|
| + " // start this counter",
|
| + " _counter._sw.start();",
|
| + " }",
|
| + "",
|
| + " /**",
|
| + " * Stops counting time and updates counter.",
|
| + " */",
|
| + " void stop() {",
|
| + " _counter._sw.stop();",
|
| + " // restore previous counter and resume it",
|
| + " TimeCounter._current = _prev;",
|
| + " if (_prev != null) {",
|
| + " _prev._sw.start();",
|
| + " }",
|
| + " }",
|
| + "}");
|
| Files.write(source, new File(targetFolder + "/utilities_general.dart"), Charsets.UTF_8);
|
| }
|
| {
|
|
|