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

Inherited from VisibleDeclConsumer:

Methods

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)

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)

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)

Declared at: clang/include/clang/Sema/SemaInternal.h:117

Parameters

clang::TypoCorrection Correction

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)

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)

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

Declared at: clang/include/clang/Sema/SemaInternal.h:119

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)

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

Declared at: clang/include/clang/Sema/SemaInternal.h:201

clang::CorrectionCandidateCallback*
getCorrectionValidator() const

Declared at: clang/include/clang/Sema/SemaInternal.h:207

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

Declared at: clang/include/clang/Sema/SemaInternal.h:202

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

Declared at: clang/include/clang/Sema/SemaInternal.h:205

clang::Scope* getScope() const

Declared at: clang/include/clang/Sema/SemaInternal.h:206

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

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

Declared at: clang/include/clang/Sema/SemaInternal.h:204

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()

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()

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)

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()

Description

Restore the saved position in the correction stream.

Declared at: clang/include/clang/Sema/SemaInternal.h:197

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