clang 22.0.0git
clang::TypoCorrectionConsumer Class Reference

#include "clang/Sema/SemaInternal.h"

Inheritance diagram for clang::TypoCorrectionConsumer:
[legend]

Public Member Functions

 TypoCorrectionConsumer (Sema &SemaRef, const DeclarationNameInfo &TypoName, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, DeclContext *MemberContext, bool EnteringContext)
bool includeHiddenDecls () const override
 Determine whether hidden declarations (from unimported modules) should be given to this consumer.
void FoundDecl (NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx, bool InBaseClass) override
 Invoked each time Sema::LookupVisibleDecls() finds a declaration visible from the current scope or context.
void FoundName (StringRef Name)
void addKeywordResult (StringRef Keyword)
void addCorrection (TypoCorrection Correction)
bool empty () const
TypoResultListoperator[] (StringRef Name)
 Return the list of TypoCorrections for the given identifier from the set of corrections that have the closest edit distance, if any.
unsigned getBestEditDistance (bool Normalized)
 Return the edit distance of the corrections that have the closest/best edit distance from the original typop.
void addNamespaces (const llvm::MapVector< NamespaceDecl *, bool > &KnownNamespaces)
 Set-up method to add to the consumer the set of namespaces to use in performing corrections to nested name specifiers.
const TypoCorrectiongetNextCorrection ()
 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.
const TypoCorrectiongetCurrentCorrection ()
 Get the last correction returned by getNextCorrection().
const TypoCorrectionpeekNextCorrection ()
 Return the next typo correction like getNextCorrection, but keep the internal state pointed to the current correction (i.e.
bool hasMadeAnyCorrectionProgress () const
 In the case of deeply invalid expressions, getNextCorrection() will never be called since the transform never makes progress.
void resetCorrectionStream ()
 Reset the consumer's position in the stream of viable corrections (i.e.
bool finished ()
 Return whether the end of the stream of corrections has been reached.
void saveCurrentPosition ()
 Save the current position in the correction stream (overwriting any previously saved position).
void restoreSavedPosition ()
 Restore the saved position in the correction stream.
ASTContextgetContext () const
const LookupResultgetLookupResult () const
bool isAddressOfOperand () const
const CXXScopeSpecgetSS () const
ScopegetScope () const
CorrectionCandidateCallbackgetCorrectionValidator () const
Public Member Functions inherited from clang::VisibleDeclConsumer
virtual ~VisibleDeclConsumer ()
 Destroys the visible declaration consumer.
virtual void EnteredContext (DeclContext *Ctx)
 Callback to inform the client that Sema entered into a new context to find a visible declaration.

Detailed Description

Definition at line 87 of file SemaInternal.h.

Constructor & Destructor Documentation

◆ TypoCorrectionConsumer()

clang::TypoCorrectionConsumer::TypoCorrectionConsumer ( Sema & SemaRef,
const DeclarationNameInfo & TypoName,
Sema::LookupNameKind LookupKind,
Scope * S,
CXXScopeSpec * SS,
std::unique_ptr< CorrectionCandidateCallback > CCC,
DeclContext * MemberContext,
bool EnteringContext )
inline

Definition at line 93 of file SemaInternal.h.

References false, and clang::nullptr.

Member Function Documentation

◆ addCorrection()

◆ addKeywordResult()

void TypoCorrectionConsumer::addKeywordResult ( StringRef Keyword)

Definition at line 4671 of file SemaLookup.cpp.

References clang::Keyword.

Referenced by AddKeywordsToConsumer().

◆ addNamespaces()

void TypoCorrectionConsumer::addNamespaces ( const llvm::MapVector< NamespaceDecl *, bool > & KnownNamespaces)

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.

Definition at line 4762 of file SemaLookup.cpp.

References clang::NestedNameSpecifier::getAsType(), clang::NestedNameSpecifier::getKind(), clang::Type::getTypeClass(), clang::isa(), and clang::NestedNameSpecifier::Type.

◆ empty()

bool clang::TypoCorrectionConsumer::empty ( ) const
inline

Definition at line 121 of file SemaInternal.h.

◆ finished()

bool clang::TypoCorrectionConsumer::finished ( )
inline

Return whether the end of the stream of corrections has been reached.

Definition at line 187 of file SemaInternal.h.

◆ FoundDecl()

void TypoCorrectionConsumer::FoundDecl ( NamedDecl * ND,
NamedDecl * Hiding,
DeclContext * Ctx,
bool InBaseClass )
overridevirtual

Invoked each time Sema::LookupVisibleDecls() finds a declaration visible from the current scope or context.

Parameters
NDthe declaration found.
Hidinga declaration that hides the declaration ND, or NULL if no such declaration exists.
Ctxthe original context from which the lookup started.
InBaseClasswhether this declaration was found in base class of the context we searched.

Implements clang::VisibleDeclConsumer.

Definition at line 4644 of file SemaLookup.cpp.

References FoundName(), clang::NamedDecl::getIdentifier(), clang::IdentifierInfo::getName(), and clang::LookupResult::isVisible().

◆ FoundName()

void TypoCorrectionConsumer::FoundName ( StringRef Name)

Definition at line 4665 of file SemaLookup.cpp.

Referenced by FoundDecl().

◆ getBestEditDistance()

unsigned clang::TypoCorrectionConsumer::getBestEditDistance ( bool Normalized)
inline

Return the edit distance of the corrections that have the closest/best edit distance from the original typop.

Definition at line 133 of file SemaInternal.h.

References clang::TypoCorrection::NormalizeEditDistance().

◆ getContext()

ASTContext & clang::TypoCorrectionConsumer::getContext ( ) const
inline

Definition at line 203 of file SemaInternal.h.

◆ getCorrectionValidator()

CorrectionCandidateCallback * clang::TypoCorrectionConsumer::getCorrectionValidator ( ) const
inline

Definition at line 209 of file SemaInternal.h.

◆ getCurrentCorrection()

const TypoCorrection & clang::TypoCorrectionConsumer::getCurrentCorrection ( )
inline

Get the last correction returned by getNextCorrection().

Definition at line 156 of file SemaInternal.h.

◆ getLookupResult()

const LookupResult & clang::TypoCorrectionConsumer::getLookupResult ( ) const
inline

Definition at line 204 of file SemaInternal.h.

◆ getNextCorrection()

const TypoCorrection & TypoCorrectionConsumer::getNextCorrection ( )

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.

Definition at line 4792 of file SemaLookup.cpp.

References clang::TypoCorrection::isResolved(), and clang::TypoCorrection::requiresImport().

Referenced by peekNextCorrection().

◆ getScope()

Scope * clang::TypoCorrectionConsumer::getScope ( ) const
inline

Definition at line 208 of file SemaInternal.h.

◆ getSS()

const CXXScopeSpec * clang::TypoCorrectionConsumer::getSS ( ) const
inline

Definition at line 207 of file SemaInternal.h.

◆ hasMadeAnyCorrectionProgress()

bool clang::TypoCorrectionConsumer::hasMadeAnyCorrectionProgress ( ) const
inline

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.

Definition at line 176 of file SemaInternal.h.

◆ includeHiddenDecls()

bool clang::TypoCorrectionConsumer::includeHiddenDecls ( ) const
inlineoverridevirtual

Determine whether hidden declarations (from unimported modules) should be given to this consumer.

By default, they are not included.

Reimplemented from clang::VisibleDeclConsumer.

Definition at line 112 of file SemaInternal.h.

◆ isAddressOfOperand()

bool clang::TypoCorrectionConsumer::isAddressOfOperand ( ) const
inline

Definition at line 206 of file SemaInternal.h.

◆ operator[]()

TypoResultList & clang::TypoCorrectionConsumer::operator[] ( StringRef Name)
inline

Return the list of TypoCorrections for the given identifier from the set of corrections that have the closest edit distance, if any.

Definition at line 127 of file SemaInternal.h.

◆ peekNextCorrection()

const TypoCorrection & clang::TypoCorrectionConsumer::peekNextCorrection ( )
inline

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

Definition at line 166 of file SemaInternal.h.

References getNextCorrection().

◆ resetCorrectionStream()

void clang::TypoCorrectionConsumer::resetCorrectionStream ( )
inline

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

Definition at line 181 of file SemaInternal.h.

◆ restoreSavedPosition()

void clang::TypoCorrectionConsumer::restoreSavedPosition ( )
inline

Restore the saved position in the correction stream.

Definition at line 199 of file SemaInternal.h.

◆ saveCurrentPosition()

void clang::TypoCorrectionConsumer::saveCurrentPosition ( )
inline

Save the current position in the correction stream (overwriting any previously saved position).

Definition at line 194 of file SemaInternal.h.


The documentation for this class was generated from the following files: