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

Side by Side Diff: pkg/analyzer/test/src/mock_sdk.dart

Issue 1149723004: Fix context creation in tests (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Back-out unintended change Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « pkg/analysis_server/test/mock_sdk.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.src.mock_sdk; 5 library test.src.mock_sdk;
6 6
7 import 'package:analyzer/file_system/file_system.dart' as resource; 7 import 'package:analyzer/file_system/file_system.dart' as resource;
8 import 'package:analyzer/file_system/memory_file_system.dart' as resource; 8 import 'package:analyzer/file_system/memory_file_system.dart' as resource;
9 import 'package:analyzer/src/context/context.dart' as newContext;
9 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/sdk.dart'; 11 import 'package:analyzer/src/generated/sdk.dart';
11 import 'package:analyzer/src/generated/source.dart'; 12 import 'package:analyzer/src/generated/source.dart';
12 13
13 class MockSdk implements DartSdk { 14 class MockSdk implements DartSdk {
14 static const _MockSdkLibrary LIB_CORE = const _MockSdkLibrary('dart:core', 15 static const _MockSdkLibrary LIB_CORE = const _MockSdkLibrary('dart:core',
15 '/lib/core/core.dart', ''' 16 '/lib/core/core.dart', '''
16 library dart.core; 17 library dart.core;
17 18
18 import 'dart:async'; 19 import 'dart:async';
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 182
182 MockSdk() { 183 MockSdk() {
183 LIBRARIES.forEach((_MockSdkLibrary library) { 184 LIBRARIES.forEach((_MockSdkLibrary library) {
184 provider.newFile(library.path, library.content); 185 provider.newFile(library.path, library.content);
185 }); 186 });
186 } 187 }
187 188
188 @override 189 @override
189 AnalysisContext get context { 190 AnalysisContext get context {
190 if (_analysisContext == null) { 191 if (_analysisContext == null) {
191 _analysisContext = new SdkAnalysisContext(); 192 if (AnalysisEngine.instance.useTaskModel) {
193 _analysisContext = new newContext.SdkAnalysisContext();
194 } else {
195 _analysisContext = new SdkAnalysisContext();
196 }
192 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]); 197 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]);
193 _analysisContext.sourceFactory = factory; 198 _analysisContext.sourceFactory = factory;
194 ChangeSet changeSet = new ChangeSet(); 199 ChangeSet changeSet = new ChangeSet();
195 for (String uri in uris) { 200 for (String uri in uris) {
196 Source source = factory.forUri(uri); 201 Source source = factory.forUri(uri);
197 changeSet.addedSource(source); 202 changeSet.addedSource(source);
198 } 203 }
199 _analysisContext.applyChanges(changeSet); 204 _analysisContext.applyChanges(changeSet);
200 } 205 }
201 return _analysisContext; 206 return _analysisContext;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 bool get isInternal => throw unimplemented; 311 bool get isInternal => throw unimplemented;
307 312
308 @override 313 @override
309 bool get isShared => throw unimplemented; 314 bool get isShared => throw unimplemented;
310 315
311 @override 316 @override
312 bool get isVmLibrary => throw unimplemented; 317 bool get isVmLibrary => throw unimplemented;
313 318
314 UnimplementedError get unimplemented => new UnimplementedError(); 319 UnimplementedError get unimplemented => new UnimplementedError();
315 } 320 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/mock_sdk.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698