Index: pkg/compiler/lib/src/source_file_provider.dart |
diff --git a/pkg/compiler/lib/src/source_file_provider.dart b/pkg/compiler/lib/src/source_file_provider.dart |
index cbc6ff3383cb5be3d3422cfebbf71900054185de..932864a53ac4c99c5663792eb60bf4e6a9826cc3 100644 |
--- a/pkg/compiler/lib/src/source_file_provider.dart |
+++ b/pkg/compiler/lib/src/source_file_provider.dart |
@@ -10,12 +10,14 @@ import 'dart:io'; |
import 'dart:math' as math; |
import '../compiler.dart' as api show Diagnostic, DiagnosticHandler; |
+import '../compiler_new.dart' as api show CompilerInput, CompilerDiagnostics; |
import 'dart2js.dart' show AbortLeg; |
import 'colors.dart' as colors; |
import 'io/source_file.dart'; |
import 'filenames.dart'; |
import 'util/uri_extras.dart'; |
import 'dart:typed_data'; |
+import '../compiler_new.dart'; |
List<int> readAll(String filename) { |
var file = (new File(filename)).openSync(); |
@@ -27,7 +29,7 @@ List<int> readAll(String filename) { |
return buffer; |
} |
-abstract class SourceFileProvider { |
+abstract class SourceFileProvider implements CompilerInput { |
bool isWindows = (Platform.operatingSystem == 'windows'); |
Uri cwd = currentDirectory; |
Map<Uri, SourceFile> sourceFiles = <Uri, SourceFile>{}; |
@@ -100,6 +102,8 @@ abstract class SourceFileProvider { |
}); |
} |
+ // TODO(johnniwinther): Remove this when no longer needed for the old compiler |
+ // API. |
Future/*<List<int> | String>*/ call(Uri resourceUri); |
relativizeUri(Uri uri) => relativize(cwd, uri, isWindows); |
@@ -110,10 +114,15 @@ abstract class SourceFileProvider { |
} |
class CompilerSourceFileProvider extends SourceFileProvider { |
- Future<List<int>> call(Uri resourceUri) => readUtf8BytesFromUri(resourceUri); |
+ // TODO(johnniwinther): Remove this when no longer needed for the old compiler |
+ // API. |
+ Future<List<int>> call(Uri resourceUri) => readFromUri(resourceUri); |
+ |
+ @override |
+ Future readFromUri(Uri uri) => readUtf8BytesFromUri(uri); |
} |
-class FormattingDiagnosticHandler { |
+class FormattingDiagnosticHandler implements CompilerDiagnostics { |
final SourceFileProvider provider; |
bool showWarnings = true; |
bool showHints = true; |
@@ -160,8 +169,9 @@ class FormattingDiagnosticHandler { |
throw 'Unexpected diagnostic kind: $kind (${kind.ordinal})'; |
} |
- void diagnosticHandler(Uri uri, int begin, int end, String message, |
- api.Diagnostic kind) { |
+ @override |
+ void report(Uri uri, int begin, int end, String message, |
+ api.Diagnostic kind) { |
// TODO(ahe): Remove this when source map is handled differently. |
if (identical(kind.name, 'source map')) return; |
@@ -223,8 +233,10 @@ class FormattingDiagnosticHandler { |
} |
} |
+ // TODO(johnniwinther): Remove this when no longer needed for the old compiler |
+ // API. |
void call(Uri uri, int begin, int end, String message, api.Diagnostic kind) { |
- return diagnosticHandler(uri, begin, end, message, kind); |
+ return report(uri, begin, end, message, kind); |
} |
} |