| Index: dart/site/try/src/caching_compiler.dart
|
| diff --git a/dart/tests/compiler/dart2js/memory_compiler.dart b/dart/site/try/src/caching_compiler.dart
|
| similarity index 55%
|
| copy from dart/tests/compiler/dart2js/memory_compiler.dart
|
| copy to dart/site/try/src/caching_compiler.dart
|
| index 392f51b6bf3a36251bc7e48f634c42bc6fd82ef4..e94bc4561659e6fc4be2f9d89d6624dd32cd0960 100644
|
| --- a/dart/tests/compiler/dart2js/memory_compiler.dart
|
| +++ b/dart/site/try/src/caching_compiler.dart
|
| @@ -2,97 +2,37 @@
|
| // 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 dart2js.test.memory_compiler;
|
| -
|
| -import 'memory_source_file_helper.dart';
|
| -
|
| -import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
|
| - show NullSink;
|
| -
|
| -import '../../../sdk/lib/_internal/compiler/compiler.dart'
|
| - show Diagnostic, DiagnosticHandler, CompilerOutputProvider;
|
| -
|
| -import 'dart:async';
|
| -
|
| -import '../../../sdk/lib/_internal/compiler/implementation/mirrors/source_mirrors.dart';
|
| -import '../../../sdk/lib/_internal/compiler/implementation/mirrors/analyze.dart';
|
| -
|
| -class DiagnosticMessage {
|
| - final Uri uri;
|
| - final int begin;
|
| - final int end;
|
| - final String message;
|
| - final Diagnostic kind;
|
| -
|
| - DiagnosticMessage(this.uri, this.begin, this.end, this.message, this.kind);
|
| -
|
| - String toString() => '$uri:$begin:$end:$message:$kind';
|
| +library trydart.caching_compiler;
|
| +
|
| +import 'package:compiler/compiler.dart' show
|
| + CompilerOutputProvider,
|
| + Diagnostic,
|
| + DiagnosticHandler;
|
| +
|
| +import 'package:compiler/implementation/apiimpl.dart' show
|
| + Compiler;
|
| +
|
| +// This file is copied from a dart2js test which uses dart:io. For now, mock up
|
| +// a bunch of interfaces to silence the analyzer. This file will serve as basis
|
| +// for incremental analysis.
|
| +abstract class SourceFileProvider {}
|
| +class FormattingDiagnosticHandler {
|
| + FormattingDiagnosticHandler(a);
|
| }
|
| -
|
| -class DiagnosticCollector {
|
| - List<DiagnosticMessage> messages = <DiagnosticMessage>[];
|
| -
|
| - void call(Uri uri, int begin, int end, String message,
|
| - Diagnostic kind) {
|
| - messages.add(new DiagnosticMessage(uri, begin, end, message, kind));
|
| - }
|
| -
|
| - Iterable<DiagnosticMessage> filterMessagesByKind(Diagnostic kind) {
|
| - return messages.where(
|
| - (DiagnosticMessage message) => message.kind == kind);
|
| - }
|
| -
|
| - Iterable<DiagnosticMessage> get errors {
|
| - return filterMessagesByKind(Diagnostic.ERROR);
|
| - }
|
| -
|
| - Iterable<DiagnosticMessage> get warnings {
|
| - return filterMessagesByKind(Diagnostic.WARNING);
|
| - }
|
| -
|
| - Iterable<DiagnosticMessage> get hints {
|
| - return filterMessagesByKind(Diagnostic.HINT);
|
| - }
|
| -
|
| - Iterable<DiagnosticMessage> get infos {
|
| - return filterMessagesByKind(Diagnostic.INFO);
|
| - }
|
| +abstract class Platform {
|
| + static var script;
|
| + static var packageRoot;
|
| }
|
| -
|
| -class BufferedEventSink implements EventSink<String> {
|
| - StringBuffer sb = new StringBuffer();
|
| - String text;
|
| -
|
| - void add(String event) {
|
| - sb.write(event);
|
| - }
|
| -
|
| - void addError(errorEvent, [StackTrace stackTrace]) {
|
| - // Do not support this.
|
| - }
|
| -
|
| - void close() {
|
| - text = sb.toString();
|
| - sb = null;
|
| - }
|
| +class MemorySourceFileProvider extends SourceFileProvider {
|
| + var readStringFromUri;
|
| + var memorySourceFiles;
|
| + MemorySourceFileProvider(a);
|
| }
|
| -
|
| -class OutputCollector {
|
| - Map<String, Map<String, BufferedEventSink>> outputMap = {};
|
| -
|
| - EventSink<String> call(String name, String extension) {
|
| - Map<String, BufferedEventSink> sinkMap =
|
| - outputMap.putIfAbsent(extension, () => {});
|
| - return sinkMap.putIfAbsent(name, () => new BufferedEventSink());
|
| - }
|
| -
|
| - String getOutput(String name, String extension) {
|
| - Map<String, BufferedEventSink> sinkMap = outputMap[extension];
|
| - if (sinkMap == null) return null;
|
| - BufferedEventSink sink = sinkMap[name];
|
| - return sink != null ? sink.text : null;
|
| - }
|
| +class NullSink extends EventSink {
|
| + NullSink(a);
|
| }
|
| +var expando;
|
| +abstract class EventSink<T> {}
|
|
|
| DiagnosticHandler createDiagnosticHandler(DiagnosticHandler diagnosticHandler,
|
| SourceFileProvider provider,
|
| @@ -114,9 +54,6 @@ DiagnosticHandler createDiagnosticHandler(DiagnosticHandler diagnosticHandler,
|
| return handler;
|
| }
|
|
|
| -Expando<MemorySourceFileProvider> expando =
|
| - new Expando<MemorySourceFileProvider>();
|
| -
|
| Compiler compilerFor(Map<String,String> memorySourceFiles,
|
| {DiagnosticHandler diagnosticHandler,
|
| CompilerOutputProvider outputProvider,
|
| @@ -196,24 +133,3 @@ Compiler compilerFor(Map<String,String> memorySourceFiles,
|
| }
|
| return compiler;
|
| }
|
| -
|
| -Future<MirrorSystem> mirrorSystemFor(Map<String,String> memorySourceFiles,
|
| - {DiagnosticHandler diagnosticHandler,
|
| - List<String> options: const [],
|
| - bool showDiagnostics: true}) {
|
| - Uri libraryRoot = Uri.base.resolve('sdk/');
|
| - Uri packageRoot = Uri.base.resolve('${Platform.packageRoot}/');
|
| - Uri script = Uri.base.resolveUri(Platform.script);
|
| -
|
| - var provider = new MemorySourceFileProvider(memorySourceFiles);
|
| - var handler =
|
| - createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics);
|
| -
|
| - List<Uri> libraries = <Uri>[];
|
| - memorySourceFiles.forEach((String path, _) {
|
| - libraries.add(new Uri(scheme: 'memory', path: path));
|
| - });
|
| -
|
| - return analyze(libraries, libraryRoot, packageRoot,
|
| - provider, handler, options);
|
| -}
|
|
|