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

Unified Diff: pkg/compiler/lib/src/js/js_source_mapping.dart

Issue 2690083002: Add MultiSourceInformationStrategy (Closed)
Patch Set: Cleanup. Created 3 years, 10 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/js/js.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js/js_source_mapping.dart
diff --git a/pkg/compiler/lib/src/js/js_source_mapping.dart b/pkg/compiler/lib/src/js/js_source_mapping.dart
index 11278374bf815195faf6b967a368e465e979b0fb..bef8c191a39e836f7ebbcbae6d5d8995cb9982d4 100644
--- a/pkg/compiler/lib/src/js/js_source_mapping.dart
+++ b/pkg/compiler/lib/src/js/js_source_mapping.dart
@@ -4,7 +4,8 @@
library js.source_mapping;
-import '../io/code_output.dart' show BufferedCodeOutput, SourceLocations;
+import '../io/code_output.dart'
+ show BufferedCodeOutput, SourceLocations, SourceLocationsProvider;
import '../io/source_information.dart'
show SourceLocation, SourceInformation, SourceInformationStrategy;
import 'js.dart';
@@ -15,12 +16,24 @@ class JavaScriptSourceInformationStrategy extends SourceInformationStrategy {
const JavaScriptSourceInformationStrategy();
/// Creates a processor that can associate source information on [Node] with
- /// code offsets in the [sourceMapper].
- SourceInformationProcessor createProcessor(SourceMapper sourceMapper) {
+ /// code offsets in a [SourceMapper] provided by [sourceMapperProvider].
+ /// Source information for each [Node] is provider by [reader].
+ SourceInformationProcessor createProcessor(
+ SourceMapperProvider sourceMapperProvider,
+ SourceInformationReader reader) {
return const SourceInformationProcessor();
}
}
+/// Interface for deriving [SourceInformation] from a [Node].
+///
+/// The base implementation read the value of the node itself.
+class SourceInformationReader {
+ const SourceInformationReader();
+
+ SourceInformation getSourceInformation(Node node) => node.sourceInformation;
+}
+
/// An observer of code positions of printed JavaScript [Node]s.
class CodePositionListener {
const CodePositionListener();
@@ -38,6 +51,23 @@ class CodePositionListener {
Node node, int startPosition, int endPosition, int closingPosition) {}
}
+/// Interface for creating [SourceMapper]s for multiple source information
+/// engines.
+abstract class SourceMapperProvider {
+ SourceMapper createSourceMapper(String name);
+}
+
+/// Base implementation of [SourceMapperProvider].
+class SourceMapperProviderImpl implements SourceMapperProvider {
+ final SourceLocationsProvider provider;
+
+ SourceMapperProviderImpl(this.provider);
+
+ SourceMapper createSourceMapper(String name) {
+ return new SourceLocationsMapper(provider.createSourceLocations(name));
+ }
+}
+
/// An interface for mapping code offsets with [SourceLocation]s for JavaScript
/// [Node]s.
abstract class SourceMapper {
« no previous file with comments | « pkg/compiler/lib/src/js/js.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698