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

Unified Diff: pkg/compiler/lib/src/mirrors/analyze.dart

Issue 1805563002: Revert "Delete support for source mirrors" (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | pkg/compiler/lib/src/mirrors/dart2js_instance_mirrors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/mirrors/analyze.dart
diff --git a/pkg/compiler/lib/src/mirrors/analyze.dart b/pkg/compiler/lib/src/mirrors/analyze.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ad3c0eaf31dee80b67f055f070de6c449bc2b4df
--- /dev/null
+++ b/pkg/compiler/lib/src/mirrors/analyze.dart
@@ -0,0 +1,75 @@
+// Copyright (c) 2012, 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 dart2js.source_mirrors.analyze;
+
+import 'dart:async';
+
+import 'source_mirrors.dart';
+import 'dart2js_mirrors.dart' show Dart2JsMirrorSystem;
+import '../../compiler.dart' as api;
+import '../apiimpl.dart' as apiimpl;
+import '../compiler.dart' show Compiler;
+import '../old_to_new_api.dart';
+
+//------------------------------------------------------------------------------
+// Analysis entry point.
+//------------------------------------------------------------------------------
+
+/**
+ * Analyzes set of libraries and provides a mirror system which can be used for
+ * static inspection of the source code.
+ */
+// TODO(johnniwinther): Move this to [compiler/compiler.dart].
+Future<MirrorSystem> analyze(List<Uri> libraries,
+ Uri libraryRoot,
+ Uri packageRoot,
+ api.CompilerInputProvider inputProvider,
+ api.DiagnosticHandler diagnosticHandler,
+ [List<String> options = const <String>[],
+ Uri packageConfig,
+ api.PackagesDiscoveryProvider findPackages]) {
+ if (!libraryRoot.path.endsWith("/")) {
+ throw new ArgumentError("libraryRoot must end with a /");
+ }
+ if (packageRoot != null && !packageRoot.path.endsWith("/")) {
+ throw new ArgumentError("packageRoot must end with a /");
+ }
+ options = new List<String>.from(options);
+ options.add('--analyze-only');
+ options.add('--analyze-signatures-only');
+ options.add('--analyze-all');
+ options.add('--categories=Client,Server');
+ options.add('--enable-async');
+ options.add('--allow-native-extensions');
+
+ bool compilationFailed = false;
+ void internalDiagnosticHandler(Uri uri, int begin, int end,
+ String message, api.Diagnostic kind) {
+ if (kind == api.Diagnostic.ERROR ||
+ kind == api.Diagnostic.CRASH) {
+ compilationFailed = true;
+ }
+ diagnosticHandler(uri, begin, end, message, kind);
+ }
+
+ Compiler compiler = new apiimpl.CompilerImpl(
+ new LegacyCompilerInput(inputProvider),
+ new LegacyCompilerOutput(),
+ new LegacyCompilerDiagnostics(internalDiagnosticHandler),
+ libraryRoot,
+ packageRoot,
+ options,
+ const {},
+ packageConfig,
+ findPackages);
+ compiler.librariesToAnalyzeWhenRun = libraries;
+ return compiler.run(null).then((bool success) {
+ if (success && !compilationFailed) {
+ return new Dart2JsMirrorSystem(compiler);
+ } else {
+ throw new StateError('Failed to create mirror system.');
+ }
+ });
+}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/mirrors/dart2js_instance_mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698