Skip to content

Commit

Permalink
Add relevanceBoost for initializers of variable initializers.
Browse files Browse the repository at this point in the history
[email protected]

Bug: JetBrains/intellij-plugins#665 (comment)
Change-Id: I254639a1582ca5691e96e15612bd2078c65e0b41
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114969
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
  • Loading branch information
scheglov authored and [email protected] committed Aug 29, 2019
1 parent c5d108a commit c07b1fe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,18 @@ class DartCompletionManager implements CompletionContributor {
}
}
}

if (containingNode is VariableDeclaration &&
containingNode.equals != null &&
target.offset >= containingNode.equals.end) {
var parent = containingNode.parent;
if (parent is VariableDeclarationList) {
var type = parent.type?.type;
if (type is InterfaceType) {
addTypeTag(type);
}
}
}
}

static List<String> _ensureList(Map<String, List<String>> map, String key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,26 @@ main() {
''');
}

test_relevanceTags_location_initializer() async {
addTestFile(r'''
int v = // ref;
''');

var results = await _getSuggestions(
testFile,
testCode.indexOf(' // ref'),
);

assertJsonText(results.includedSuggestionRelevanceTags, r'''
[
{
"tag": "dart:core::int",
"relevanceBoost": 10
}
]
''');
}

test_relevanceTags_location_listLiteral() async {
addTestFile(r'''
main() {
Expand Down

0 comments on commit c07b1fe

Please sign in to comment.