Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4162)

Unified Diff: pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart

Issue 3001733002: Correctly handle adding imports when pasting into part files (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
diff --git a/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart b/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
index 23462db61e2d0d5514d7732b09cfc6440543f392..497b5459750967c57239c921035019b48d4b81ae 100644
--- a/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
@@ -151,6 +151,36 @@ bool randomBool() {
expect(elements.elements, unorderedEquals(['Random']));
}
+ test_multiple() async {
+ String selection = r'''
+main() {
+ Random r = new Random();
+ String s = r.nextBool().toString();
+ print(s);
+}
+''';
+ String content = '''
+import 'dart:math';
+
+$selection
+''';
+ List<ImportedElements> elementsList = await _computeElements(
+ content, content.indexOf(selection), selection.length);
+ expect(elementsList, hasLength(2));
+
+ ImportedElements mathElements = elementsList[0];
+ expect(mathElements, isNotNull);
+ expect(mathElements.path, '/lib/math/math.dart');
+ expect(mathElements.prefix, '');
+ expect(mathElements.elements, unorderedEquals(['Random']));
+
+ ImportedElements coreElements = elementsList[1];
+ expect(coreElements, isNotNull);
+ expect(coreElements.path, '/lib/core/core.dart');
+ expect(coreElements.prefix, '');
+ expect(coreElements.elements, unorderedEquals(['String', 'print']));
+ }
+
test_none_comment() async {
String selection = 'comment';
String content = """

Powered by Google App Engine
This is Rietveld 408576698