class TypoCorrectionConsumer
Declaration
class TypoCorrectionConsumer : public VisibleDeclConsumer { /* full declaration omitted */ };
Description
Consumes visible declarations found when searching for all visible names within a given scope or context. This abstract class is meant to be subclassed by clients of \c Sema::LookupVisibleDecls(), each of which should override the \c FoundDecl() function to process declarations as they are found.
Declared at: clang/include/clang/Sema/SemaInternal.h:85
Inherits from: VisibleDeclConsumer
Member Variables
- private clang::IdentifierInfo* Typo
- The name written that is a typo in the source.
- private clang::TypoCorrectionConsumer::TypoEditDistanceMap CorrectionResults
- The pointer value being set to the current DeclContext indicates whether there is a keyword with this name.
- private SmallVector<clang::TypoCorrection, 4> ValidatedCorrections
- private size_t CurrentTCIndex
- private size_t SavedTCIndex
- private clang::Sema& SemaRef
- private clang::Scope* S
- private std::unique_ptr<CXXScopeSpec> SS
- private std::unique_ptr<CorrectionCandidateCallback> CorrectionValidator
- private clang::DeclContext* MemberContext
- private clang::LookupResult Result
- private clang::TypoCorrectionConsumer:: NamespaceSpecifierSet Namespaces
- private SmallVector<clang::TypoCorrection, 2> QualifiedResults
- private bool EnteringContext
- private bool SearchNamespaces
Method Overview
- public void FoundDecl(clang::NamedDecl * ND, clang::NamedDecl * Hiding, clang::DeclContext * Ctx, bool InBaseClass)
- public void FoundName(llvm::StringRef Name)
- public TypoCorrectionConsumer(clang::Sema & SemaRef, const clang::DeclarationNameInfo & TypoName, Sema::LookupNameKind LookupKind, clang::Scope * S, clang::CXXScopeSpec * SS, std::unique_ptr<CorrectionCandidateCallback> CCC, clang::DeclContext * MemberContext, bool EnteringContext)
- public void addCorrection(clang::TypoCorrection Correction)
- public void addKeywordResult(llvm::StringRef Keyword)
- private void addName(llvm::StringRef Name, clang::NamedDecl * ND, clang::NestedNameSpecifier * NNS = nullptr, bool isKeyword = false)
- public void addNamespaces(const llvm::MapVector<NamespaceDecl *, bool> & KnownNamespaces)
- public bool empty() const
- public bool finished()
- public unsigned int getBestEditDistance(bool Normalized)
- public clang::ASTContext & getContext() const
- public clang::CorrectionCandidateCallback * getCorrectionValidator() const
- public const clang::TypoCorrection & getCurrentCorrection()
- public const clang::LookupResult & getLookupResult() const
- public const clang::TypoCorrection & getNextCorrection()
- public const clang::CXXScopeSpec * getSS() const
- public clang::Scope * getScope() const
- public bool hasMadeAnyCorrectionProgress() const
- public bool includeHiddenDecls() const
- public bool isAddressOfOperand() const
- public const clang::TypoCorrection & peekNextCorrection()
- private void performQualifiedLookups()
- public void resetCorrectionStream()
- private bool resolveCorrection(clang::TypoCorrection & Candidate)
- public void restoreSavedPosition()
- public void saveCurrentPosition()
Inherited from VisibleDeclConsumer:
Methods
¶void FoundDecl(clang::NamedDecl* ND,
clang::NamedDecl* Hiding,
clang::DeclContext* Ctx,
bool InBaseClass)
void FoundDecl(clang::NamedDecl* ND,
clang::NamedDecl* Hiding,
clang::DeclContext* Ctx,
bool InBaseClass)
Description
Invoked each time \p Sema::LookupVisibleDecls() finds a declaration visible from the current scope or context.
Declared at: clang/include/clang/Sema/SemaInternal.h:113
Parameters
- clang::NamedDecl* ND
- the declaration found.
- clang::NamedDecl* Hiding
- a declaration that hides the declaration \p ND, or NULL if no such declaration exists.
- clang::DeclContext* Ctx
- the original context from which the lookup started.
- bool InBaseClass
- whether this declaration was found in base class of the context we searched.
¶void FoundName(llvm::StringRef Name)
void FoundName(llvm::StringRef Name)
Declared at: clang/include/clang/Sema/SemaInternal.h:115
Parameters
- llvm::StringRef Name
¶TypoCorrectionConsumer(
clang::Sema& SemaRef,
const clang::DeclarationNameInfo& TypoName,
Sema::LookupNameKind LookupKind,
clang::Scope* S,
clang::CXXScopeSpec* SS,
std::unique_ptr<CorrectionCandidateCallback>
CCC,
clang::DeclContext* MemberContext,
bool EnteringContext)
TypoCorrectionConsumer(
clang::Sema& SemaRef,
const clang::DeclarationNameInfo& TypoName,
Sema::LookupNameKind LookupKind,
clang::Scope* S,
clang::CXXScopeSpec* SS,
std::unique_ptr<CorrectionCandidateCallback>
CCC,
clang::DeclContext* MemberContext,
bool EnteringContext)
Declared at: clang/include/clang/Sema/SemaInternal.h:91
Parameters
- clang::Sema& SemaRef
- const clang::DeclarationNameInfo& TypoName
- Sema::LookupNameKind LookupKind
- clang::Scope* S
- clang::CXXScopeSpec* SS
- std::unique_ptr<CorrectionCandidateCallback> CCC
- clang::DeclContext* MemberContext
- bool EnteringContext
¶void addCorrection(
clang::TypoCorrection Correction)
void addCorrection(
clang::TypoCorrection Correction)
Declared at: clang/include/clang/Sema/SemaInternal.h:117
Parameters
- clang::TypoCorrection Correction
¶void addKeywordResult(llvm::StringRef Keyword)
void addKeywordResult(llvm::StringRef Keyword)
Declared at: clang/include/clang/Sema/SemaInternal.h:116
Parameters
- llvm::StringRef Keyword
¶void addName(
llvm::StringRef Name,
clang::NamedDecl* ND,
clang::NestedNameSpecifier* NNS = nullptr,
bool isKeyword = false)
void addName(
llvm::StringRef Name,
clang::NamedDecl* ND,
clang::NestedNameSpecifier* NNS = nullptr,
bool isKeyword = false)
Declared at: clang/include/clang/Sema/SemaInternal.h:281
Parameters
- llvm::StringRef Name
- clang::NamedDecl* ND
- clang::NestedNameSpecifier* NNS = nullptr
- bool isKeyword = false
¶void addNamespaces(
const llvm::MapVector<NamespaceDecl*, bool>&
KnownNamespaces)
void addNamespaces(
const llvm::MapVector<NamespaceDecl*, bool>&
KnownNamespaces)
Description
Set-up method to add to the consumer the set of namespaces to use in performing corrections to nested name specifiers. This method also implicitly adds all of the known classes in the current AST context to the to the consumer for correcting nested name specifiers.
Declared at: clang/include/clang/Sema/SemaInternal.h:144
Parameters
- const llvm::MapVector<NamespaceDecl*, bool>& KnownNamespaces
¶bool empty() const
bool empty() const
Declared at: clang/include/clang/Sema/SemaInternal.h:119
¶bool finished()
bool finished()
Description
Return whether the end of the stream of corrections has been reached.
Declared at: clang/include/clang/Sema/SemaInternal.h:185
¶unsigned int getBestEditDistance(bool Normalized)
unsigned int getBestEditDistance(bool Normalized)
Description
Return the edit distance of the corrections that have the closest/best edit distance from the original typop.
Declared at: clang/include/clang/Sema/SemaInternal.h:131
Parameters
- bool Normalized
¶clang::ASTContext& getContext() const
clang::ASTContext& getContext() const
Declared at: clang/include/clang/Sema/SemaInternal.h:201
¶clang::CorrectionCandidateCallback*
getCorrectionValidator() const
clang::CorrectionCandidateCallback*
getCorrectionValidator() const
Declared at: clang/include/clang/Sema/SemaInternal.h:207
¶const clang::TypoCorrection&
getCurrentCorrection()
const clang::TypoCorrection&
getCurrentCorrection()
Description
Get the last correction returned by getNextCorrection().
Declared at: clang/include/clang/Sema/SemaInternal.h:154
¶const clang::LookupResult& getLookupResult() const
const clang::LookupResult& getLookupResult() const
Declared at: clang/include/clang/Sema/SemaInternal.h:202
¶const clang::TypoCorrection& getNextCorrection()
const clang::TypoCorrection& getNextCorrection()
Description
Return the next typo correction that passes all internal filters and is deemed valid by the consumer's CorrectionCandidateCallback, starting with the corrections that have the closest edit distance. An empty TypoCorrection is returned once no more viable corrections remain in the consumer.
Declared at: clang/include/clang/Sema/SemaInternal.h:151
¶const clang::CXXScopeSpec* getSS() const
const clang::CXXScopeSpec* getSS() const
Declared at: clang/include/clang/Sema/SemaInternal.h:205
¶clang::Scope* getScope() const
clang::Scope* getScope() const
Declared at: clang/include/clang/Sema/SemaInternal.h:206
¶bool hasMadeAnyCorrectionProgress() const
bool hasMadeAnyCorrectionProgress() const
Description
In the case of deeply invalid expressions, `getNextCorrection()` will never be called since the transform never makes progress. If we don't detect this we risk trying to correct typos forever.
Declared at: clang/include/clang/Sema/SemaInternal.h:174
¶bool includeHiddenDecls() const
bool includeHiddenDecls() const
Description
Determine whether hidden declarations (from unimported modules) should be given to this consumer. By default, they are not included.
Declared at: clang/include/clang/Sema/SemaInternal.h:110
¶bool isAddressOfOperand() const
bool isAddressOfOperand() const
Declared at: clang/include/clang/Sema/SemaInternal.h:204
¶const clang::TypoCorrection& peekNextCorrection()
const clang::TypoCorrection& peekNextCorrection()
Description
Return the next typo correction like getNextCorrection, but keep the internal state pointed to the current correction (i.e. the next time getNextCorrection is called, it will return the same correction returned by peekNextcorrection).
Declared at: clang/include/clang/Sema/SemaInternal.h:164
¶void performQualifiedLookups()
void performQualifiedLookups()
Description
Perform qualified lookups on the queued set of typo correction candidates and add the nested name specifier changes to each candidate if a lookup succeeds (at which point the candidate will be returned to the main pool of potential corrections).
Declared at: clang/include/clang/Sema/SemaInternal.h:293
¶void resetCorrectionStream()
void resetCorrectionStream()
Description
Reset the consumer's position in the stream of viable corrections (i.e. getNextCorrection() will return each of the previously returned corrections in order before returning any new corrections).
Declared at: clang/include/clang/Sema/SemaInternal.h:179
¶bool resolveCorrection(
clang::TypoCorrection& Candidate)
bool resolveCorrection(
clang::TypoCorrection& Candidate)
Description
Find any visible decls for the given typo correction candidate. If none are found, it to the set of candidates for which qualified lookups will be performed to find possible nested name specifier changes.
Declared at: clang/include/clang/Sema/SemaInternal.h:287
Parameters
- clang::TypoCorrection& Candidate
¶void restoreSavedPosition()
void restoreSavedPosition()
Description
Restore the saved position in the correction stream.
Declared at: clang/include/clang/Sema/SemaInternal.h:197
¶void saveCurrentPosition()
void saveCurrentPosition()
Description
Save the current position in the correction stream (overwriting any previously saved position).
Declared at: clang/include/clang/Sema/SemaInternal.h:192