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>
This commit is contained in:
Konstantin Shcheglov
2018-05-18 18:57:59 +00:00
committed by commit-bot@chromium.org
parent 7ac05a120a
commit be5b189c19
2 changed files with 21 additions and 0 deletions
@@ -115,6 +115,9 @@ library _runtimeCompletion;
);
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);
@@ -269,4 +269,22 @@ class C {
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')));
}
}
}