Bug fix in the override_contributor.dart, don't generate the override completions if the target is in a comment text.

Change-Id: Ifbde00721858c9ad58b9d50cadf7775e37cf235b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144802
Reviewed-by: Jaime Wren <jwren@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Jaime Wren <jwren@google.com>
This commit is contained in:
Jaime Wren
2020-04-24 20:34:47 +00:00
committed by commit-bot@chromium.org
parent 8236400594
commit 455886420c
2 changed files with 50 additions and 0 deletions
@@ -39,6 +39,11 @@ class OverrideContributor implements DartCompletionContributor {
return const <CompletionSuggestion>[];
}
var comment = containingNode.thisOrAncestorOfType<Comment>();
if (target.isCommentText || comment != null) {
return const <CompletionSuggestion>[];
}
var sourceRange = _getTargetSourceRange(target);
sourceRange ??= range.startOffsetEndOffset(request.offset, 0);
@@ -303,6 +303,51 @@ class B implements A {
}''', displayText: 'foo() { … }', selectionOffset: 51, selectionLength: 0);
}
Future<void> test_no_target_inComment() async {
addTestSource('''
class A {
void foo() {}
}
class B implements A {
// comment ^
void m() {}
}
''');
await computeSuggestions();
_assertNoOverrideContaining('foo');
}
Future<void> test_no_target_inComment2() async {
addTestSource('''
class A {
void foo() {}
}
class B implements A {
/// dartdoc ^
void m() {}
}
''');
await computeSuggestions();
_assertNoOverrideContaining('foo');
}
Future<void> test_no_target_inComment3() async {
addTestSource('''
class A {
void foo() {}
}
class B implements A {
/// Asdf [St^]
void m() {}
}
''');
await computeSuggestions();
_assertNoOverrideContaining('foo');
}
Future<void> test_outsideOfWorkspace() async {
testFile = convertPath('/home/other/lib/a.dart');
addTestSource('''