|
@@ -4603,9 +4603,19 @@ void Sema::CodeCompleteAssignmentRHS(Scope *S, Expr *LHS) {
|
|
|
|
|
|
void Sema::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
|
|
|
bool EnteringContext) {
|
|
|
- if (!SS.getScopeRep() || !CodeCompleter)
|
|
|
+ if (SS.isEmpty() || !CodeCompleter)
|
|
|
return;
|
|
|
|
|
|
+ // We want to keep the scope specifier even if it's invalid (e.g. the scope
|
|
|
+ // "a::b::" is not corresponding to any context/namespace in the AST), since
|
|
|
+ // it can be useful for global code completion which have information about
|
|
|
+ // contexts/symbols that are not in the AST.
|
|
|
+ if (SS.isInvalid()) {
|
|
|
+ CodeCompletionContext CC(CodeCompletionContext::CCC_Name);
|
|
|
+ CC.setCXXScopeSpecifier(SS);
|
|
|
+ HandleCodeCompleteResults(this, CodeCompleter, CC, nullptr, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
// Always pretend to enter a context to ensure that a dependent type
|
|
|
// resolves to a dependent record.
|
|
|
DeclContext *Ctx = computeDeclContext(SS, /*EnteringContext=*/true);
|
|
@@ -4621,7 +4631,7 @@ void Sema::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
|
|
|
CodeCompleter->getCodeCompletionTUInfo(),
|
|
|
CodeCompletionContext::CCC_Name);
|
|
|
Results.EnterNewScope();
|
|
|
-
|
|
|
+
|
|
|
// The "template" keyword can follow "::" in the grammar, but only
|
|
|
// put it into the grammar if the nested-name-specifier is dependent.
|
|
|
NestedNameSpecifier *NNS = SS.getScopeRep();
|
|
@@ -4635,16 +4645,18 @@ void Sema::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
|
|
|
// qualified-id completions.
|
|
|
if (!EnteringContext)
|
|
|
MaybeAddOverrideCalls(*this, Ctx, Results);
|
|
|
- Results.ExitScope();
|
|
|
-
|
|
|
+ Results.ExitScope();
|
|
|
+
|
|
|
CodeCompletionDeclConsumer Consumer(Results, CurContext);
|
|
|
LookupVisibleDecls(Ctx, LookupOrdinaryName, Consumer,
|
|
|
/*IncludeGlobalScope=*/true,
|
|
|
/*IncludeDependentBases=*/true);
|
|
|
|
|
|
- HandleCodeCompleteResults(this, CodeCompleter,
|
|
|
- Results.getCompletionContext(),
|
|
|
- Results.data(),Results.size());
|
|
|
+ auto CC = Results.getCompletionContext();
|
|
|
+ CC.setCXXScopeSpecifier(SS);
|
|
|
+
|
|
|
+ HandleCodeCompleteResults(this, CodeCompleter, CC, Results.data(),
|
|
|
+ Results.size());
|
|
|
}
|
|
|
|
|
|
void Sema::CodeCompleteUsing(Scope *S) {
|