| 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/context/context.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| 11 import 'package:analyzer/src/generated/sdk.dart'; | 11 import 'package:analyzer/src/generated/sdk.dart'; |
| 12 import 'package:analyzer/src/generated/source.dart'; | 12 import 'package:analyzer/src/generated/source.dart'; |
| 13 | 13 |
| 14 class MockSdk implements DartSdk { | 14 class MockSdk implements DartSdk { |
| 15 static const _MockSdkLibrary LIB_CORE = const _MockSdkLibrary( | 15 static const _MockSdkLibrary LIB_CORE = const _MockSdkLibrary( |
| 16 'dart:core', | 16 'dart:core', |
| 17 '/lib/core/core.dart', | 17 '/lib/core/core.dart', |
| 18 ''' | 18 ''' |
| 19 library dart.core; | 19 library dart.core; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 MockSdk() { | 213 MockSdk() { |
| 214 LIBRARIES.forEach((_MockSdkLibrary library) { | 214 LIBRARIES.forEach((_MockSdkLibrary library) { |
| 215 provider.newFile(library.path, library.content); | 215 provider.newFile(library.path, library.content); |
| 216 }); | 216 }); |
| 217 } | 217 } |
| 218 | 218 |
| 219 @override | 219 @override |
| 220 AnalysisContext get context { | 220 AnalysisContext get context { |
| 221 if (_analysisContext == null) { | 221 if (_analysisContext == null) { |
| 222 if (AnalysisEngine.instance.useTaskModel) { | 222 _analysisContext = new SdkAnalysisContext(); |
| 223 _analysisContext = new newContext.SdkAnalysisContext(); | |
| 224 } else { | |
| 225 _analysisContext = new SdkAnalysisContext(); | |
| 226 } | |
| 227 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]); | 223 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]); |
| 228 _analysisContext.sourceFactory = factory; | 224 _analysisContext.sourceFactory = factory; |
| 229 ChangeSet changeSet = new ChangeSet(); | 225 ChangeSet changeSet = new ChangeSet(); |
| 230 for (String uri in uris) { | 226 for (String uri in uris) { |
| 231 Source source = factory.forUri(uri); | 227 Source source = factory.forUri(uri); |
| 232 changeSet.addedSource(source); | 228 changeSet.addedSource(source); |
| 233 } | 229 } |
| 234 _analysisContext.applyChanges(changeSet); | 230 _analysisContext.applyChanges(changeSet); |
| 235 } | 231 } |
| 236 return _analysisContext; | 232 return _analysisContext; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 bool get isInternal => shortName.startsWith('dart:_'); | 338 bool get isInternal => shortName.startsWith('dart:_'); |
| 343 | 339 |
| 344 @override | 340 @override |
| 345 bool get isShared => throw unimplemented; | 341 bool get isShared => throw unimplemented; |
| 346 | 342 |
| 347 @override | 343 @override |
| 348 bool get isVmLibrary => throw unimplemented; | 344 bool get isVmLibrary => throw unimplemented; |
| 349 | 345 |
| 350 UnimplementedError get unimplemented => new UnimplementedError(); | 346 UnimplementedError get unimplemented => new UnimplementedError(); |
| 351 } | 347 } |
| OLD | NEW |