Index: dart/site/try/src/compilation_unit.dart |
diff --git a/dart/site/try/src/compilation_unit.dart b/dart/site/try/src/compilation_unit.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..728db2f1845964a721b3321dbfdb60b1869fb0b2 |
--- /dev/null |
+++ b/dart/site/try/src/compilation_unit.dart |
@@ -0,0 +1,38 @@ |
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+library trydart.compilationUnit; |
+ |
+import 'dart:async' show |
+ Stream, |
+ StreamController; |
+ |
+class CompilationUnitData { |
+ final String name; |
+ String content; |
+ |
+ CompilationUnitData(this.name, this.content); |
+} |
+ |
+class CompilationUnit extends CompilationUnitData { |
+ // Extending [CompilationUnitData] allows this class to hide the storage |
+ // allocated for [content] without introducing new names. The conventional |
+ // way of acheiving this is to introduce a library-private field, but library |
+ // privacy isn't without problems. |
+ |
+ static StreamController<CompilationUnit> controller = |
+ new StreamController<CompilationUnit>(sync: false); |
+ |
+ static Stream<CompilationUnit> get onChanged => controller.stream; |
+ |
+ CompilationUnit(String name, String content) |
+ : super(name, content); |
+ |
+ void set content(String newContent) { |
+ if (content != newContent) { |
+ super.content = newContent; |
+ controller.add(this); |
+ } |
+ } |
+} |