| 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.abstract_context; | 5 library testing.abstract_context; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 typedef void _ElementVisitorFunction(Element element); | 37 typedef void _ElementVisitorFunction(Element element); |
| 38 | 38 |
| 39 class AbstractContextTest { | 39 class AbstractContextTest { |
| 40 static final DartSdk SDK = new MockSdk(); | 40 static final DartSdk SDK = new MockSdk(); |
| 41 static final UriResolver SDK_RESOLVER = new DartUriResolver(SDK); | 41 static final UriResolver SDK_RESOLVER = new DartUriResolver(SDK); |
| 42 | 42 |
| 43 MemoryResourceProvider provider = new MemoryResourceProvider(); | 43 MemoryResourceProvider provider = new MemoryResourceProvider(); |
| 44 UriResolver resourceResolver; | 44 UriResolver resourceResolver; |
| 45 AnalysisContext context; | 45 AnalysisContext context; |
| 46 | 46 |
| 47 Source addSource(String path, String content) { | 47 Source addSource(String path, String content, [Uri uri]) { |
| 48 File file = provider.newFile(path, content); | 48 File file = provider.newFile(path, content); |
| 49 Source source = file.createSource(); | 49 Source source = file.createSource(uri); |
| 50 ChangeSet changeSet = new ChangeSet(); | 50 ChangeSet changeSet = new ChangeSet(); |
| 51 changeSet.addedSource(source); | 51 changeSet.addedSource(source); |
| 52 context.applyChanges(changeSet); | 52 context.applyChanges(changeSet); |
| 53 context.setContents(source, content); | 53 context.setContents(source, content); |
| 54 return source; | 54 return source; |
| 55 } | 55 } |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * Performs all analysis tasks in [context]. | 58 * Performs all analysis tasks in [context]. |
| 59 */ | 59 */ |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 * [engine.GeneralizingElementVisitor]. | 91 * [engine.GeneralizingElementVisitor]. |
| 92 */ | 92 */ |
| 93 class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor { | 93 class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor { |
| 94 final _ElementVisitorFunction function; | 94 final _ElementVisitorFunction function; |
| 95 _ElementVisitorFunctionWrapper(this.function); | 95 _ElementVisitorFunctionWrapper(this.function); |
| 96 visitElement(Element element) { | 96 visitElement(Element element) { |
| 97 function(element); | 97 function(element); |
| 98 super.visitElement(element); | 98 super.visitElement(element); |
| 99 } | 99 } |
| 100 } | 100 } |
| OLD | NEW |