| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 analyzer.src.context.context; | 5 library analyzer.src.context.context; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 * to stand in for a real one if one does not exist | 725 * to stand in for a real one if one does not exist |
| 726 * facilitating creation a type provider without dart:async. | 726 * facilitating creation a type provider without dart:async. |
| 727 */ | 727 */ |
| 728 LibraryElement createMockAsyncLib(LibraryElement coreLibrary) { | 728 LibraryElement createMockAsyncLib(LibraryElement coreLibrary) { |
| 729 InterfaceType objType = coreLibrary.getType('Object').type; | 729 InterfaceType objType = coreLibrary.getType('Object').type; |
| 730 | 730 |
| 731 ClassElement _classElement(String typeName, [List<String> parameterNames]) { | 731 ClassElement _classElement(String typeName, [List<String> parameterNames]) { |
| 732 ClassElementImpl element = | 732 ClassElementImpl element = |
| 733 new ClassElementImpl.forNode(AstFactory.identifier3(typeName)); | 733 new ClassElementImpl.forNode(AstFactory.identifier3(typeName)); |
| 734 element.supertype = objType; | 734 element.supertype = objType; |
| 735 InterfaceTypeImpl type = new InterfaceTypeImpl(element); | |
| 736 element.type = type; | |
| 737 if (parameterNames != null) { | 735 if (parameterNames != null) { |
| 738 int count = parameterNames.length; | 736 int count = parameterNames.length; |
| 739 if (count > 0) { | 737 if (count > 0) { |
| 740 List<TypeParameterElementImpl> typeParameters = | 738 List<TypeParameterElementImpl> typeParameters = |
| 741 new List<TypeParameterElementImpl>(count); | 739 new List<TypeParameterElementImpl>(count); |
| 742 List<TypeParameterTypeImpl> typeArguments = | 740 List<TypeParameterTypeImpl> typeArguments = |
| 743 new List<TypeParameterTypeImpl>(count); | 741 new List<TypeParameterTypeImpl>(count); |
| 744 for (int i = 0; i < count; i++) { | 742 for (int i = 0; i < count; i++) { |
| 745 TypeParameterElementImpl typeParameter = | 743 TypeParameterElementImpl typeParameter = |
| 746 new TypeParameterElementImpl.forNode( | 744 new TypeParameterElementImpl.forNode( |
| 747 AstFactory.identifier3(parameterNames[i])); | 745 AstFactory.identifier3(parameterNames[i])); |
| 748 typeParameters[i] = typeParameter; | 746 typeParameters[i] = typeParameter; |
| 749 typeArguments[i] = new TypeParameterTypeImpl(typeParameter); | 747 typeArguments[i] = new TypeParameterTypeImpl(typeParameter); |
| 750 typeParameter.type = typeArguments[i]; | 748 typeParameter.type = typeArguments[i]; |
| 751 } | 749 } |
| 752 element.typeParameters = typeParameters; | 750 element.typeParameters = typeParameters; |
| 753 type.typeArguments = typeArguments; | |
| 754 } | 751 } |
| 755 } | 752 } |
| 756 return element; | 753 return element; |
| 757 } | 754 } |
| 758 | 755 |
| 759 InterfaceType futureType = _classElement('Future', ['T']).type; | 756 InterfaceType futureType = _classElement('Future', ['T']).type; |
| 760 InterfaceType streamType = _classElement('Stream', ['T']).type; | 757 InterfaceType streamType = _classElement('Stream', ['T']).type; |
| 761 CompilationUnitElementImpl asyncUnit = | 758 CompilationUnitElementImpl asyncUnit = |
| 762 new CompilationUnitElementImpl("mock_async.dart"); | 759 new CompilationUnitElementImpl("mock_async.dart"); |
| 763 asyncUnit.types = <ClassElement>[futureType.element, streamType.element]; | 760 asyncUnit.types = <ClassElement>[futureType.element, streamType.element]; |
| (...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2219 } | 2216 } |
| 2220 DartSdk sdk = factory.dartSdk; | 2217 DartSdk sdk = factory.dartSdk; |
| 2221 if (sdk == null) { | 2218 if (sdk == null) { |
| 2222 throw new IllegalArgumentException( | 2219 throw new IllegalArgumentException( |
| 2223 "The source factory for an SDK analysis context must have a DartUriRes
olver"); | 2220 "The source factory for an SDK analysis context must have a DartUriRes
olver"); |
| 2224 } | 2221 } |
| 2225 return new AnalysisCache( | 2222 return new AnalysisCache( |
| 2226 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); | 2223 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); |
| 2227 } | 2224 } |
| 2228 } | 2225 } |
| OLD | NEW |