| 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 dev_compiler.src.testing; | 5 library dev_compiler.src.testing; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; | 9 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; |
| 10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 /// } | 48 /// } |
| 49 /// ''' | 49 /// ''' |
| 50 /// }); | 50 /// }); |
| 51 /// | 51 /// |
| 52 CheckerResults testChecker(Map<String, String> testFiles, | 52 CheckerResults testChecker(Map<String, String> testFiles, |
| 53 {bool allowConstCasts: true, String sdkDir, CheckerReporter reporter, | 53 {bool allowConstCasts: true, String sdkDir, CheckerReporter reporter, |
| 54 covariantGenerics: true, relaxedCasts: true, | 54 covariantGenerics: true, relaxedCasts: true, |
| 55 inferDownwards: RulesOptions.inferDownwardsDefault, | 55 inferDownwards: RulesOptions.inferDownwardsDefault, |
| 56 inferFromOverrides: ResolverOptions.inferFromOverridesDefault, | 56 inferFromOverrides: ResolverOptions.inferFromOverridesDefault, |
| 57 inferTransitively: ResolverOptions.inferTransitivelyDefault, | 57 inferTransitively: ResolverOptions.inferTransitivelyDefault, |
| 58 nonnullableTypes: TypeOptions.NONNULLABLE_TYPES}) { | 58 nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, |
| 59 wrapClosures: RulesOptions.wrapClosuresDefault}) { |
| 59 expect(testFiles.containsKey('/main.dart'), isTrue, | 60 expect(testFiles.containsKey('/main.dart'), isTrue, |
| 60 reason: '`/main.dart` is missing in testFiles'); | 61 reason: '`/main.dart` is missing in testFiles'); |
| 61 | 62 |
| 62 // Create a resolver that can load test files from memory. | 63 // Create a resolver that can load test files from memory. |
| 63 var testUriResolver = new TestUriResolver(testFiles); | 64 var testUriResolver = new TestUriResolver(testFiles); |
| 64 var options = new CompilerOptions( | 65 var options = new CompilerOptions( |
| 65 allowConstCasts: allowConstCasts, | 66 allowConstCasts: allowConstCasts, |
| 66 covariantGenerics: covariantGenerics, | 67 covariantGenerics: covariantGenerics, |
| 67 relaxedCasts: relaxedCasts, | 68 relaxedCasts: relaxedCasts, |
| 68 inferDownwards: inferDownwards, | 69 inferDownwards: inferDownwards, |
| 69 inferFromOverrides: inferFromOverrides, | 70 inferFromOverrides: inferFromOverrides, |
| 70 inferTransitively: inferTransitively, | 71 inferTransitively: inferTransitively, |
| 71 nonnullableTypes: nonnullableTypes, | 72 nonnullableTypes: nonnullableTypes, |
| 73 wrapClosures: wrapClosures, |
| 72 useMockSdk: sdkDir == null, | 74 useMockSdk: sdkDir == null, |
| 73 dartSdkPath: sdkDir, | 75 dartSdkPath: sdkDir, |
| 74 runtimeDir: '/dev_compiler_runtime/', | 76 runtimeDir: '/dev_compiler_runtime/', |
| 75 entryPointFile: '/main.dart'); | 77 entryPointFile: '/main.dart'); |
| 76 var resolver = sdkDir == null | 78 var resolver = sdkDir == null |
| 77 ? new TypeResolver.fromMock(mockSdkSources, options, | 79 ? new TypeResolver.fromMock(mockSdkSources, options, |
| 78 otherResolvers: [testUriResolver]) | 80 otherResolvers: [testUriResolver]) |
| 79 : new TypeResolver.fromDir(sdkDir, options, | 81 : new TypeResolver.fromDir(sdkDir, options, |
| 80 otherResolvers: [testUriResolver]); | 82 otherResolvers: [testUriResolver]); |
| 81 | 83 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 340 |
| 339 SourceSpan spanFor(AstNode node) { | 341 SourceSpan spanFor(AstNode node) { |
| 340 final begin = node is AnnotatedNode | 342 final begin = node is AnnotatedNode |
| 341 ? node.firstTokenAfterCommentAndMetadata.offset | 343 ? node.firstTokenAfterCommentAndMetadata.offset |
| 342 : node.offset; | 344 : node.offset; |
| 343 return _file.span(begin, node.end); | 345 return _file.span(begin, node.end); |
| 344 } | 346 } |
| 345 | 347 |
| 346 String toString() => '[$runtimeType: $uri]'; | 348 String toString() => '[$runtimeType: $uri]'; |
| 347 } | 349 } |
| OLD | NEW |