mirror of
https://github.com/dart-lang/sdk
synced 2024-09-22 18:13:39 +00:00
b419906c80
"Project files" is the feature for serving the sources of Try Dart! to itself. R=kasperl@google.com Review URL: https://codereview.chromium.org//214513005 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34498 260f80e4-7a28-3924-810f-c04153c831b5
39 lines
1.1 KiB
Dart
39 lines
1.1 KiB
Dart
// 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);
|
|
}
|
|
}
|
|
}
|