| 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 analyzer2dart.driver; | 5 library analyzer2dart.driver; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/element.dart'; | 7 import 'package:analyzer/src/generated/element.dart'; |
| 8 import 'package:analyzer/src/generated/engine.dart'; | 8 import 'package:analyzer/src/generated/engine.dart'; |
| 9 import 'package:analyzer/src/generated/java_io.dart'; | 9 import 'package:analyzer/src/generated/java_io.dart'; |
| 10 import 'package:analyzer/src/generated/sdk_io.dart'; | 10 import 'package:analyzer/src/generated/sdk_io.dart'; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * Add the given file as the root of analysis, and return the corresponding | 58 * Add the given file as the root of analysis, and return the corresponding |
| 59 * source. | 59 * source. |
| 60 */ | 60 */ |
| 61 Source setRealRoot(String path) { | 61 Source setRealRoot(String path) { |
| 62 // Tell the analysis server about the root | 62 // Tell the analysis server about the root |
| 63 ChangeSet changeSet = new ChangeSet(); | 63 ChangeSet changeSet = new ChangeSet(); |
| 64 JavaFile javaFile = new JavaFile(path); | 64 JavaFile javaFile = new JavaFile(path); |
| 65 Source source = new FileBasedSource.con1(javaFile); | 65 Source source = new FileBasedSource.con1(javaFile); |
| 66 changeSet.addedSources.add(source); | 66 changeSet.addedSource(source); |
| 67 context.applyChanges(changeSet); | 67 context.applyChanges(changeSet); |
| 68 return source; | 68 return source; |
| 69 } | 69 } |
| 70 |
| 71 /** |
| 72 * Add the given file contents as the root of analysis. For unit testing. |
| 73 */ |
| 74 Source setFakeRoot(String contents) { |
| 75 String path = 'root.dart'; |
| 76 // Tell the analysis server about the root |
| 77 ChangeSet changeSet = new ChangeSet(); |
| 78 JavaFile javaFile = new JavaFile(path); |
| 79 Source source = new FileBasedSource.con1(javaFile); |
| 80 changeSet.addedSource(source); |
| 81 changeSet.changedContent(source, contents); |
| 82 context.applyChanges(changeSet); |
| 83 return source; |
| 84 } |
| 70 } | 85 } |
| 71 | 86 |
| OLD | NEW |