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

Unified Diff: pkg/analyzer/lib/src/summary/pub_summary.dart

Issue 2233083002: Compute both strong and spec mode unlinked bundles. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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/analyzer/test/src/summary/pub_summary_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/pub_summary.dart
diff --git a/pkg/analyzer/lib/src/summary/pub_summary.dart b/pkg/analyzer/lib/src/summary/pub_summary.dart
index 21c074db34ed7751bb38b4cd0f54b8aeffefbc55..983aaca614c16209a4d4447a83a6fa6bb3ff53df 100644
--- a/pkg/analyzer/lib/src/summary/pub_summary.dart
+++ b/pkg/analyzer/lib/src/summary/pub_summary.dart
@@ -28,6 +28,16 @@ import 'package:analyzer/src/util/fast_uri.dart';
import 'package:path/path.dart' as pathos;
/**
+ * Unlinked and linked information about a [PubPackage].
+ */
+class LinkedPubPackage {
+ final PubPackage package;
+ final PackageBundle unlinked;
+ final PackageBundle linked;
+ LinkedPubPackage(this.package, this.unlinked, this.linked);
+}
+
+/**
* A package in the pub cache.
*/
class PubPackage {
@@ -51,16 +61,6 @@ class PubPackage {
}
/**
- * Unlinked and linked information about a [PubPackage].
- */
-class LinkedPubPackage {
- final PubPackage package;
- final PackageBundle unlinked;
- final PackageBundle linked;
- LinkedPubPackage(this.package, this.unlinked, this.linked);
-}
-
-/**
* Class that manages summaries for pub packages.
*
* The client should call [getLinkedBundles] after creating a new
@@ -69,7 +69,8 @@ class LinkedPubPackage {
* configure [ResynthesizerResultProvider] for the context.
*/
class PubSummaryManager {
- static const UNLINKED_BUNDLE_FILE_NAME = 'unlinked.ds';
+ static const UNLINKED_NAME = 'unlinked.ds';
+ static const UNLINKED_SPEC_NAME = 'unlinked_spec.ds';
final ResourceProvider resourceProvider;
@@ -185,6 +186,7 @@ class PubSummaryManager {
* maybe an empty map, but not `null`.
*/
Map<PubPackage, PackageBundle> getUnlinkedBundles(AnalysisContext context) {
+ bool strongMode = context.analysisOptions.strongMode;
Map<PubPackage, PackageBundle> unlinkedBundles =
new HashMap<PubPackage, PackageBundle>();
Map<String, List<Folder>> packageMap = context.sourceFactory.packageMap;
@@ -194,7 +196,8 @@ class PubSummaryManager {
Folder libFolder = libFolders.first;
if (isPathInPubCache(pathContext, libFolder.path)) {
PubPackage package = new PubPackage(packageName, libFolder);
- PackageBundle unlinkedBundle = _getUnlinkedOrSchedule(package);
+ PackageBundle unlinkedBundle =
+ _getUnlinkedOrSchedule(package, strongMode);
if (unlinkedBundle != null) {
unlinkedBundles[package] = unlinkedBundle;
}
@@ -212,7 +215,8 @@ class PubSummaryManager {
void _computeNextUnlinked() {
if (packagesToComputeUnlinked.isNotEmpty) {
PubPackage package = packagesToComputeUnlinked.first;
- _computeUnlinked(package);
+ _computeUnlinked(package, false);
+ _computeUnlinked(package, true);
packagesToComputeUnlinked.remove(package);
_scheduleNextUnlinked();
} else {
@@ -229,7 +233,7 @@ class PubSummaryManager {
*
* TODO(scheglov) Consider moving into separate isolate(s).
*/
- void _computeUnlinked(PubPackage package) {
+ void _computeUnlinked(PubPackage package, bool strongMode) {
Folder libFolder = package.libFolder;
String libPath = libFolder.path + pathContext.separator;
PackageBundleAssembler assembler = new PackageBundleAssembler();
@@ -253,7 +257,7 @@ class PubSummaryManager {
if (AnalysisEngine.isDartFileName(path)) {
Uri uri = getUri(path);
Source source = file.createSource(uri);
- CompilationUnit unit = _parse(source);
+ CompilationUnit unit = _parse(source, strongMode);
UnlinkedUnitBuilder unlinkedUnit = serializeAstUnlinked(unit);
assembler.addUnlinkedUnit(source, unlinkedUnit);
}
@@ -279,25 +283,37 @@ class PubSummaryManager {
try {
addDartFiles(libFolder);
List<int> bytes = assembler.assemble().toBuffer();
- _writeAtomic(package.folder, UNLINKED_BUNDLE_FILE_NAME, bytes);
+ String fileName = _getUnlinkedName(strongMode);
+ _writeAtomic(package.folder, fileName, bytes);
} on FileSystemException {
// Ignore file system exceptions.
}
}
/**
+ * Return the name of the file for an unlinked bundle, in strong or spec mode.
+ */
+ String _getUnlinkedName(bool strongMode) {
+ if (strongMode) {
+ return UNLINKED_NAME;
+ } else {
+ return UNLINKED_SPEC_NAME;
+ }
+ }
+
+ /**
* Return the unlinked [PackageBundle] for the given [package]. If the bundle
* has not been compute yet, return `null` and schedule its computation.
*/
- PackageBundle _getUnlinkedOrSchedule(PubPackage package) {
+ PackageBundle _getUnlinkedOrSchedule(PubPackage package, bool strongMode) {
// Try to find in the cache.
PackageBundle bundle = unlinkedBundleMap[package];
if (bundle != null) {
return bundle;
}
// Try to read from the file system.
- File unlinkedFile =
- package.folder.getChildAssumingFile(UNLINKED_BUNDLE_FILE_NAME);
+ String fileName = _getUnlinkedName(strongMode);
+ File unlinkedFile = package.folder.getChildAssumingFile(fileName);
if (unlinkedFile.exists) {
try {
List<int> bytes = unlinkedFile.readAsBytesSync();
@@ -322,14 +338,16 @@ class PubSummaryManager {
/**
* Parse the given [source] into AST.
*/
- CompilationUnit _parse(Source source) {
+ CompilationUnit _parse(Source source, bool strongMode) {
String code = source.contents.data;
AnalysisErrorListener errorListener = AnalysisErrorListener.NULL_LISTENER;
CharSequenceReader reader = new CharSequenceReader(code);
Scanner scanner = new Scanner(source, reader, errorListener);
+ scanner.scanGenericMethodComments = strongMode;
Token token = scanner.tokenize();
LineInfo lineInfo = new LineInfo(scanner.lineStarts);
Parser parser = new Parser(source, errorListener);
+ parser.parseGenericMethodComments = strongMode;
CompilationUnit unit = parser.parseCompilationUnit(token);
unit.lineInfo = lineInfo;
return unit;
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/pub_summary_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698