How to avoid duplicates in CompletionResultSet
Answered
Dmitry Kolesnikovich
I try to implement custom CompletionContributor.
There is my code that I simplified for clarity.
public class FeatureaCompletionContributor extends CompletionContributor {
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, final @NotNull CompletionResultSet resultSet) {
resultSet.consume("flipX");
}
}
I noticed that if xml tag that I try to invoke autocompletion for already has "flipX" attribute it shows me "flipX" twice.
How can I prevent this duplication?
Please sign in to leave a comment.
Ideally, your contributor should analyze the context it's invoked in, and not add the variants that would be suggested by other contributors. If it's difficult to do in your case, there's CompletionResultSet#runRemainingContributors API which allows you to see the items other contributors (after yours) provided and modify/filter them. You would need to register your contributor with order="first, before xml" attribute.