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

Unified Diff: pkg/kernel/lib/analyzer/loader.dart

Issue 2587673004: Include source in kernel. (Closed)
Patch Set: Fixed some rebase errors Created 3 years, 12 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/kernel/binary.md ('k') | pkg/kernel/lib/ast.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/kernel/lib/analyzer/loader.dart
diff --git a/pkg/kernel/lib/analyzer/loader.dart b/pkg/kernel/lib/analyzer/loader.dart
index 4fb962ee485781f16b56395112489e0870b018f0..43a1b3dd41f31055c6a0e81bafb19d4ae56108b9 100644
--- a/pkg/kernel/lib/analyzer/loader.dart
+++ b/pkg/kernel/lib/analyzer/loader.dart
@@ -120,7 +120,7 @@ class DartLoader implements ReferenceLevelLoader {
var uri = applicationRoot.relativeUri(element.source.uri);
return repository.getLibraryReference(uri)
..name ??= getLibraryName(element)
- ..fileUri = "file://${element.source.fullName}";
+ ..fileUri = '${element.source.uri}';
}
void _buildTopLevelMember(
@@ -268,7 +268,7 @@ class DartLoader implements ReferenceLevelLoader {
_classes[element] = classNode = new ast.Class(
name: element.name,
isAbstract: element.isAbstract,
- fileUri: "file://${element.source.fullName}");
+ fileUri: '${element.source.uri}');
classNode.level = ast.ClassLevel.Temporary;
var library = getLibraryReference(element.library);
library.addClass(classNode);
@@ -332,7 +332,8 @@ class DartLoader implements ReferenceLevelLoader {
isAbstract: true,
typeParameters: freshParameters.freshTypeParameters,
supertype: freshParameters.substituteSuper(supertype),
- mixedInType: freshParameters.substituteSuper(mixinType));
+ mixedInType: freshParameters.substituteSuper(mixinType),
+ fileUri: classNode.fileUri);
mixinClass.level = ast.ClassLevel.Type;
supertype = new ast.Supertype(mixinClass,
classNode.typeParameters.map(makeTypeParameterType).toList());
@@ -445,7 +446,7 @@ class DartLoader implements ReferenceLevelLoader {
isStatic: true,
isExternal: constructor.isExternal,
isConst: constructor.isConst,
- fileUri: "file://${element.source.fullName}");
+ fileUri: '${element.source.uri}');
}
return new ast.Constructor(scope.buildFunctionInterface(constructor),
name: _nameOfMember(element),
@@ -460,8 +461,7 @@ class DartLoader implements ReferenceLevelLoader {
isFinal: variable.isFinal,
isConst: variable.isConst,
type: scope.buildType(variable.type),
- fileUri: "file://${element.source.fullName}")
- ..fileOffset = element.nameOffset;
+ fileUri: '${element.source.uri}')..fileOffset = element.nameOffset;
case ElementKind.METHOD:
case ElementKind.GETTER:
@@ -480,7 +480,7 @@ class DartLoader implements ReferenceLevelLoader {
isAbstract: executable.isAbstract,
isStatic: executable.isStatic,
isExternal: executable.isExternal,
- fileUri: "file://${element.source.fullName}");
+ fileUri: '${element.source.uri}');
default:
throw 'Unexpected member kind: $element';
@@ -586,7 +586,7 @@ class DartLoader implements ReferenceLevelLoader {
typeParameters: fresh.freshTypeParameters,
supertype: new ast.Supertype(superclass, superArgs),
mixedInType: new ast.Supertype(mixedInClass, mixinArgs),
- fileUri: mixedInClass.fileUri);
+ fileUri: library.fileUri);
result.level = ast.ClassLevel.Type;
library.addClass(result);
return result;
@@ -694,9 +694,15 @@ class DartLoader implements ReferenceLevelLoader {
in libraryElement.units) {
var source = compilationUnitElement.source;
LineInfo lineInfo = context.computeLineInfo(source);
- program.uriToLineStarts["file://${source.fullName}"] =
- new List<int>.generate(lineInfo.lineCount, lineInfo.getOffsetOfLine,
- growable: false);
+ String sourceCode;
+ try {
+ sourceCode = context.getContents(source).data;
+ } catch (e) {
+ // The source's contents could not be accessed.
+ sourceCode = '';
+ }
+ program.uriToSource['${source.uri}'] =
+ new ast.Source(lineInfo.lineStarts, sourceCode);
}
}
return program;
« no previous file with comments | « pkg/kernel/binary.md ('k') | pkg/kernel/lib/ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698