Exclude synthetic import prefixes from runtime completion.

R=brianwilkerson@google.com

Change-Id: I6ebcef8eab433782cc120810f50b872faa097314
Reviewed-on: https://dart-review.googlesource.com/55913
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analysis_server/lib/src/domains/execution/completion.dart b/pkg/analysis_server/lib/src/domains/execution/completion.dart
index 3ccff5e..e4120f6 100644
--- a/pkg/analysis_server/lib/src/domains/execution/completion.dart
+++ b/pkg/analysis_server/lib/src/domains/execution/completion.dart
@@ -115,6 +115,9 @@
     );
     var suggestions = await contributor.computeSuggestions(request);
 
+    // Remove completions with synthetic import prefixes.
+    suggestions.removeWhere((s) => s.completion.startsWith('__prefix'));
+
     // TODO(scheglov) Add support for expressions.
     var expressions = <RuntimeCompletionExpression>[];
     return new RuntimeCompletionResult(expressions, suggestions);
diff --git a/pkg/analysis_server/test/src/domains/execution/completion_test.dart b/pkg/analysis_server/test/src/domains/execution/completion_test.dart
index cd48659..47f838d 100644
--- a/pkg/analysis_server/test/src/domains/execution/completion_test.dart
+++ b/pkg/analysis_server/test/src/domains/execution/completion_test.dart
@@ -269,4 +269,22 @@
     assertSuggested('b', returnType: 'int');
     assertSuggested('c', returnType: 'double');
   }
+
+  test_syntheticImportPrefix() async {
+    newFile('/test/lib/a.dart', content: 'class A {}');
+    newFile('/test/lib/b.dart', content: 'class B {}');
+    addContextFile(r'''
+import 'a.dart';
+impoty 'b.dart';
+main() {
+  var a = new A();
+  var b = new B();
+  // context line
+}
+''');
+    await computeCompletion('^');
+    for (var suggestion in result.suggestions) {
+      expect(suggestion.completion, isNot(startsWith('__prefix')));
+    }
+  }
 }