Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Unified Diff: pkg/compiler/lib/src/source_file_provider.dart

Issue 1235563003: Add interfaces for a new compiler API. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/old_to_new_api.dart ('k') | pkg/dart2js_incremental/lib/caching_compiler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « pkg/compiler/lib/src/old_to_new_api.dart ('k') | pkg/dart2js_incremental/lib/caching_compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698