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

Unified Diff: pkg/compiler/lib/src/io/source_file.dart

Issue 925943002: Refactor SourceFile, SourceFileProvider and SourceLocation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 5 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/io/code_output.dart ('k') | pkg/compiler/lib/src/io/source_information.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/io/source_file.dart
diff --git a/pkg/compiler/lib/src/io/source_file.dart b/pkg/compiler/lib/src/io/source_file.dart
index a106e5e0d42fc29fbc8f012c23bef7b99f9aebc4..c8f79cd4c7ac198f3733fa2c068e98b24372c117 100644
--- a/pkg/compiler/lib/src/io/source_file.dart
+++ b/pkg/compiler/lib/src/io/source_file.dart
@@ -14,9 +14,13 @@ import 'line_column_provider.dart';
* a UTF-8 encoded [List<int>] of bytes.
*/
abstract class SourceFile implements LineColumnProvider {
+ /// The absolute URI of the source file.
+ Uri get uri;
- /** The name of the file. */
- String get filename;
+ /// The name of the file.
+ ///
+ /// This is [uri], maybe relativized to a more human-readable form.
+ String get filename => uri.toString();
/** The text content of the file represented as a String. */
String slowText();
@@ -165,12 +169,12 @@ abstract class SourceFile implements LineColumnProvider {
}
class Utf8BytesSourceFile extends SourceFile {
- final String filename;
+ final Uri uri;
/** The UTF-8 encoded content of the source file. */
final List<int> content;
- Utf8BytesSourceFile(this.filename, this.content);
+ Utf8BytesSourceFile(this.uri, this.content);
String slowText() => UTF8.decode(content);
@@ -195,9 +199,10 @@ class Utf8BytesSourceFile extends SourceFile {
class CachingUtf8BytesSourceFile extends Utf8BytesSourceFile {
String cachedText;
+ final String filename;
- CachingUtf8BytesSourceFile(String filename, List<int> content)
- : super(filename, content);
+ CachingUtf8BytesSourceFile(Uri uri, this.filename, List<int> content)
+ : super(uri, content);
String slowText() {
if (cachedText == null) {
@@ -208,10 +213,17 @@ class CachingUtf8BytesSourceFile extends Utf8BytesSourceFile {
}
class StringSourceFile extends SourceFile {
+ final Uri uri;
final String filename;
final String text;
- StringSourceFile(this.filename, this.text);
+ StringSourceFile(this.uri, this.filename, this.text);
+
+ StringSourceFile.fromUri(Uri uri, String text)
+ : this(uri, uri.toString(), text);
+
+ StringSourceFile.fromName(String filename, String text)
+ : this(new Uri(path: filename), filename, text);
int get length => text.length;
set length(int v) { }
« no previous file with comments | « pkg/compiler/lib/src/io/code_output.dart ('k') | pkg/compiler/lib/src/io/source_information.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698