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

Unified Diff: lib/src/dart_sdk.dart

Issue 1840203002: More analyzer updates, and handle negative_tests (Closed) Base URL: git@github.com:dart-lang/dev_compiler.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
Index: lib/src/dart_sdk.dart
diff --git a/lib/src/dart_sdk.dart b/lib/src/dart_sdk.dart
index eed80844cc788643628a1a7b4d40ad8c4518fb44..468a68bc9b5fd09b19d4a9f0e4f9132366b527ea 100644
--- a/lib/src/dart_sdk.dart
+++ b/lib/src/dart_sdk.dart
@@ -7,10 +7,14 @@
/// definitions to provide mock sdks.
import 'package:analyzer/src/generated/engine.dart'
- show AnalysisContext, TimestampedData;
-import 'package:analyzer/src/generated/sdk.dart';
-import 'package:analyzer/src/generated/source.dart';
-import 'package:analyzer/src/context/context.dart';
+ show AnalysisContext, AnalysisEngine, TimestampedData;
+import 'package:analyzer/src/generated/sdk.dart'
+ show DartSdk, SdkLibrary, SdkLibraryImpl;
+import 'package:analyzer/src/generated/source.dart'
+ show DartUriResolver, Source, SourceFactory, UriKind;
+import 'package:analyzer/src/context/context.dart' show AnalysisContextImpl;
+import 'package:analyzer/src/context/cache.dart'
+ show AnalysisCache, CachePartition;
/// Dart SDK which contains a mock implementation of the SDK libraries. May be
/// used to speed up execution when most of the core libraries is not needed.
@@ -20,11 +24,12 @@ class MockDartSdk implements DartSdk {
final Map<String, SdkLibrary> _libs = {};
final String sdkVersion = '0';
List<String> get uris => _sources.keys.map((uri) => '$uri').toList();
- final AnalysisContext context = new SdkAnalysisContext(null);
+ AnalysisContext context;
DartUriResolver _resolver;
DartUriResolver get resolver => _resolver;
MockDartSdk(Map<String, String> sources, {this.reportMissing}) {
+ context = new _SdkAnalysisContext(this);
sources.forEach((uriString, contents) {
var uri = Uri.parse(uriString);
_sources[uri] = new _MockSdkSource(uri, contents);
@@ -180,3 +185,19 @@ final Map<String, String> mockSdkSources = {
num max(num x, num y) {}
''',
};
+
+/// An [AnalysisContextImpl] that only contains sources for a Dart SDK.
+class _SdkAnalysisContext extends AnalysisContextImpl {
+ final DartSdk sdk;
+
+ _SdkAnalysisContext(this.sdk);
+
+ @override
+ AnalysisCache createCacheFromSourceFactory(SourceFactory factory) {
+ if (factory == null) {
+ return super.createCacheFromSourceFactory(factory);
+ }
+ return new AnalysisCache(
+ <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698