| OLD | NEW |
| 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 testing.mock_sdk; | 5 library testing.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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 197 |
| 197 MockSdk() { | 198 MockSdk() { |
| 198 LIBRARIES.forEach((_MockSdkLibrary library) { | 199 LIBRARIES.forEach((_MockSdkLibrary library) { |
| 199 provider.newFile(library.path, library.content); | 200 provider.newFile(library.path, library.content); |
| 200 }); | 201 }); |
| 201 } | 202 } |
| 202 | 203 |
| 203 @override | 204 @override |
| 204 AnalysisContext get context { | 205 AnalysisContext get context { |
| 205 if (_analysisContext == null) { | 206 if (_analysisContext == null) { |
| 206 _analysisContext = new SdkAnalysisContext(); | 207 if (AnalysisEngine.instance.useTaskModel) { |
| 208 _analysisContext = new newContext.SdkAnalysisContext(); |
| 209 } else { |
| 210 _analysisContext = new SdkAnalysisContext(); |
| 211 } |
| 207 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]); | 212 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]); |
| 208 _analysisContext.sourceFactory = factory; | 213 _analysisContext.sourceFactory = factory; |
| 209 ChangeSet changeSet = new ChangeSet(); | 214 ChangeSet changeSet = new ChangeSet(); |
| 210 for (String uri in uris) { | 215 for (String uri in uris) { |
| 211 Source source = factory.forUri(uri); | 216 Source source = factory.forUri(uri); |
| 212 changeSet.addedSource(source); | 217 changeSet.addedSource(source); |
| 213 } | 218 } |
| 214 _analysisContext.applyChanges(changeSet); | 219 _analysisContext.applyChanges(changeSet); |
| 215 } | 220 } |
| 216 return _analysisContext; | 221 return _analysisContext; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 bool get isInternal => shortName.startsWith('dart:_'); | 327 bool get isInternal => shortName.startsWith('dart:_'); |
| 323 | 328 |
| 324 @override | 329 @override |
| 325 bool get isShared => throw unimplemented; | 330 bool get isShared => throw unimplemented; |
| 326 | 331 |
| 327 @override | 332 @override |
| 328 bool get isVmLibrary => throw unimplemented; | 333 bool get isVmLibrary => throw unimplemented; |
| 329 | 334 |
| 330 UnimplementedError get unimplemented => new UnimplementedError(); | 335 UnimplementedError get unimplemented => new UnimplementedError(); |
| 331 } | 336 } |
| OLD | NEW |