| 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 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 '''); | 91 '''); |
| 92 | 92 |
| 93 Source addPackageSource(String packageName, String filePath, String content) { | 93 Source addPackageSource(String packageName, String filePath, String content) { |
| 94 packageMap[packageName] = [(newFolder('/pubcache/$packageName'))]; | 94 packageMap[packageName] = [(newFolder('/pubcache/$packageName'))]; |
| 95 File file = newFile('/pubcache/$packageName/$filePath', content); | 95 File file = newFile('/pubcache/$packageName/$filePath', content); |
| 96 return file.createSource(); | 96 return file.createSource(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 Source addSource(String path, String content, [Uri uri]) { | 99 Source addSource(String path, String content, [Uri uri]) { |
| 100 File file = newFile(path, content); | 100 File file = newFile(path, content); |
| 101 Source source = file.createSource(uri); |
| 101 if (enableNewAnalysisDriver) { | 102 if (enableNewAnalysisDriver) { |
| 102 driver.addFile(path); | 103 driver.addFile(path); |
| 103 driver.changeFile(path); | 104 driver.changeFile(path); |
| 104 _fileContentOverlay[path] = content; | 105 _fileContentOverlay[path] = content; |
| 105 return null; | |
| 106 } else { | 106 } else { |
| 107 Source source = file.createSource(uri); | |
| 108 ChangeSet changeSet = new ChangeSet(); | 107 ChangeSet changeSet = new ChangeSet(); |
| 109 changeSet.addedSource(source); | 108 changeSet.addedSource(source); |
| 110 context.applyChanges(changeSet); | 109 context.applyChanges(changeSet); |
| 111 context.setContents(source, content); | 110 context.setContents(source, content); |
| 112 return source; | |
| 113 } | 111 } |
| 112 return source; |
| 114 } | 113 } |
| 115 | 114 |
| 116 File newFile(String path, [String content]) => | 115 File newFile(String path, [String content]) => |
| 117 provider.newFile(provider.convertPath(path), content ?? ''); | 116 provider.newFile(provider.convertPath(path), content ?? ''); |
| 118 | 117 |
| 119 Folder newFolder(String path) => | 118 Folder newFolder(String path) => |
| 120 provider.newFolder(provider.convertPath(path)); | 119 provider.newFolder(provider.convertPath(path)); |
| 121 | 120 |
| 122 /** | 121 /** |
| 123 * Performs all analysis tasks in [context]. | 122 * Performs all analysis tasks in [context]. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 * [engine.GeneralizingElementVisitor]. | 215 * [engine.GeneralizingElementVisitor]. |
| 217 */ | 216 */ |
| 218 class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor { | 217 class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor { |
| 219 final _ElementVisitorFunction function; | 218 final _ElementVisitorFunction function; |
| 220 _ElementVisitorFunctionWrapper(this.function); | 219 _ElementVisitorFunctionWrapper(this.function); |
| 221 visitElement(Element element) { | 220 visitElement(Element element) { |
| 222 function(element); | 221 function(element); |
| 223 super.visitElement(element); | 222 super.visitElement(element); |
| 224 } | 223 } |
| 225 } | 224 } |
| OLD | NEW |