[PATCH] D42072: [Sema] Expose current scope in qualified-id code completion.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 15 08:07:24 PST 2018
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Repository:
rC Clang
https://reviews.llvm.org/D42072
Files:
include/clang/Sema/CodeCompleteConsumer.h
lib/Sema/SemaCodeComplete.cpp
Index: lib/Sema/SemaCodeComplete.cpp
===================================================================
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -4618,7 +4618,7 @@
// contexts/symbols that are not in the AST.
if (SS.isInvalid()) {
CodeCompletionContext CC(CodeCompletionContext::CCC_Name);
- CC.setCXXScopeSpecifier(SS);
+ CC.setQualifiedCompletionContext({SS, S});
HandleCodeCompleteResults(this, CodeCompleter, CC, nullptr, 0);
return;
}
@@ -4663,7 +4663,7 @@
}
auto CC = Results.getCompletionContext();
- CC.setCXXScopeSpecifier(SS);
+ CC.setQualifiedCompletionContext({SS, S});
HandleCodeCompleteResults(this, CodeCompleter, CC, Results.data(),
Results.size());
Index: include/clang/Sema/CodeCompleteConsumer.h
===================================================================
--- include/clang/Sema/CodeCompleteConsumer.h
+++ include/clang/Sema/CodeCompleteConsumer.h
@@ -29,6 +29,7 @@
namespace clang {
class Decl;
+class Scope;
/// \brief Default priority values for code-completion results based
/// on their kind.
@@ -268,6 +269,14 @@
CCC_Recovery
};
+ struct QualifiedCompletionContext {
+ /// \brief The scope specifier that comes before the completion token e.g.
+ /// "a::b::"
+ CXXScopeSpec ScopeSpecifier;
+ /// \brief The closest scope where the qualified code completion occurs.
+ Scope *ClosestScope;
+ };
+
private:
enum Kind Kind;
@@ -281,9 +290,9 @@
/// \brief The identifiers for Objective-C selector parts.
ArrayRef<IdentifierInfo *> SelIdents;
- /// \brief The scope specifier that comes before the completion token e.g.
- /// "a::b::"
- llvm::Optional<CXXScopeSpec> ScopeSpecifier;
+ /// \brief The context for qualified-id completion, containing information
+ /// about the scope specifier.
+ llvm::Optional<QualifiedCompletionContext> QualifiedCC;
public:
/// \brief Construct a new code-completion context of the given kind.
@@ -321,16 +330,17 @@
/// context.
bool wantConstructorResults() const;
- /// \brief Sets the scope specifier that comes before the completion token.
- /// This is expected to be set in code completions on qualfied specifiers
+ /// \brief Sets the qualified context.
+ /// This is expected to be set in code completions on qualified specifiers
/// (e.g. "a::b::").
- void setCXXScopeSpecifier(CXXScopeSpec SS) {
- this->ScopeSpecifier = std::move(SS);
+ void setQualifiedCompletionContext(QualifiedCompletionContext QCC) {
+ this->QualifiedCC = std::move(QCC);
}
- llvm::Optional<const CXXScopeSpec *> getCXXScopeSpecifier() {
- if (ScopeSpecifier)
- return ScopeSpecifier.getPointer();
+ llvm::Optional<const QualifiedCompletionContext *>
+ getQualifiedCompletionContext() const {
+ if (QualifiedCC)
+ return QualifiedCC.getPointer();
return llvm::None;
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42072.129860.patch
Type: text/x-patch
Size: 2937 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180115/3bdd1fcc/attachment.bin>
More information about the cfe-commits
mailing list