ClangCodeModel: Do not offer completion for inaccessible symbols

We should not offer to auto-complete e.g. private members from contexts
where they cannot legally be accessed. This is also consistent with the
existing behavior of not offering non-const members on const objects.

Fixes: QTCREATORBUG-1984
Change-Id: Ic58c1ba2dc0b8023299feebc20bec4f2a5a6ea38
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Christian Kandeler
2020-06-04 17:15:10 +02:00
parent df703b8a5a
commit ca3ad20e64
7 changed files with 77 additions and 0 deletions

View File

@@ -132,6 +132,12 @@ static QList<AssistProposalItemInterface *> toAssistProposalItems(
if (codeCompletion.text.isEmpty())
continue; // It's an OverloadCandidate which has text but no typedText.
// Don't offer symbols that are not accessible here.
if (codeCompletion.availability == CodeCompletion::NotAvailable
|| codeCompletion.availability == CodeCompletion::NotAccessible) {
continue;
}
const QString name = codeCompletion.completionKind == CodeCompletion::KeywordCompletionKind
? CompletionChunksToTextConverter::convertToName(codeCompletion.chunks)
: codeCompletion.text.toString();