clang 20.0.0git
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
clang::CorrectionCandidateCallback Class Referenceabstract

Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo correction. More...

#include "clang/Sema/TypoCorrection.h"

Inheritance diagram for clang::CorrectionCandidateCallback:
Inheritance graph
[legend]

Public Member Functions

 CorrectionCandidateCallback (const IdentifierInfo *Typo=nullptr, NestedNameSpecifier *TypoNNS=nullptr)
 
virtual ~CorrectionCandidateCallback ()=default
 
virtual bool ValidateCandidate (const TypoCorrection &candidate)
 Simple predicate used by the default RankCandidate to determine whether to return an edit distance of 0 or InvalidDistance.
 
virtual unsigned RankCandidate (const TypoCorrection &candidate)
 Method used by Sema::CorrectTypo to assign an "edit distance" rank to a candidate (where a lower value represents a better candidate), or returning InvalidDistance if the candidate is not at all viable.
 
virtual std::unique_ptr< CorrectionCandidateCallbackclone ()=0
 Clone this CorrectionCandidateCallback.
 
void setTypoName (const IdentifierInfo *II)
 
void setTypoNNS (NestedNameSpecifier *NNS)
 

Public Attributes

bool WantTypeSpecifiers = true
 
bool WantExpressionKeywords = true
 
bool WantCXXNamedCasts = true
 
bool WantFunctionLikeCasts = true
 
bool WantRemainingKeywords = true
 
bool WantObjCSuper = false
 
bool IsObjCIvarLookup = false
 
bool IsAddressOfOperand = false
 

Static Public Attributes

static const unsigned InvalidDistance = TypoCorrection::InvalidDistance
 

Protected Member Functions

bool MatchesTypo (const TypoCorrection &candidate)
 

Protected Attributes

const IdentifierInfoTypo
 
NestedNameSpecifierTypoNNS
 

Detailed Description

Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo correction.

Definition at line 281 of file TypoCorrection.h.

Constructor & Destructor Documentation

◆ CorrectionCandidateCallback()

clang::CorrectionCandidateCallback::CorrectionCandidateCallback ( const IdentifierInfo Typo = nullptr,
NestedNameSpecifier TypoNNS = nullptr 
)
inlineexplicit

Definition at line 285 of file TypoCorrection.h.

◆ ~CorrectionCandidateCallback()

virtual clang::CorrectionCandidateCallback::~CorrectionCandidateCallback ( )
virtualdefault

Member Function Documentation

◆ clone()

virtual std::unique_ptr< CorrectionCandidateCallback > clang::CorrectionCandidateCallback::clone ( )
pure virtual

Clone this CorrectionCandidateCallback.

CorrectionCandidateCallbacks are initially stack-allocated. However in case where delayed typo-correction is done we need to move the callback to storage with a longer lifetime. Every class deriving from CorrectionCandidateCallback must implement this method.

Implemented in clang::DefaultFilterCCC, clang::DeclFilterCCC< C >, clang::FunctionCallFilterCCC, and clang::NoTypoCorrectionCCC.

◆ MatchesTypo()

bool clang::CorrectionCandidateCallback::MatchesTypo ( const TypoCorrection candidate)
inlineprotected

◆ RankCandidate()

virtual unsigned clang::CorrectionCandidateCallback::RankCandidate ( const TypoCorrection candidate)
inlinevirtual

Method used by Sema::CorrectTypo to assign an "edit distance" rank to a candidate (where a lower value represents a better candidate), or returning InvalidDistance if the candidate is not at all viable.

For validation callbacks that only need to determine if a candidate is viable, the default RankCandidate returns either 0 or InvalidDistance depending whether ValidateCandidate returns true or false.

Definition at line 309 of file TypoCorrection.h.

References InvalidDistance, MatchesTypo(), and ValidateCandidate().

Referenced by isCandidateViable().

◆ setTypoName()

void clang::CorrectionCandidateCallback::setTypoName ( const IdentifierInfo II)
inline

Definition at line 322 of file TypoCorrection.h.

References Typo.

Referenced by clang::Sema::ActOnIdExpression().

◆ setTypoNNS()

void clang::CorrectionCandidateCallback::setTypoNNS ( NestedNameSpecifier NNS)
inline

Definition at line 323 of file TypoCorrection.h.

References TypoNNS.

Referenced by clang::Sema::ActOnIdExpression().

◆ ValidateCandidate()

bool CorrectionCandidateCallback::ValidateCandidate ( const TypoCorrection candidate)
virtual

Simple predicate used by the default RankCandidate to determine whether to return an edit distance of 0 or InvalidDistance.

This can be overridden by validators that only need to determine if a candidate is viable, without ranking potentially viable candidates. Only ValidateCandidate or RankCandidate need to be overridden by a callback wishing to check the viability of correction candidates. The default predicate always returns true if the candidate is not a type name or keyword, true for types if WantTypeSpecifiers is true, and true for keywords if WantTypeSpecifiers, WantExpressionKeywords, WantCXXNamedCasts, WantRemainingKeywords, or WantObjCSuper is true.

Reimplemented in clang::DeclFilterCCC< C >, clang::FunctionCallFilterCCC, and clang::NoTypoCorrectionCCC.

Definition at line 5416 of file SemaLookup.cpp.

References D, clang::TypoCorrection::getCorrectionSpecifier(), IsAddressOfOperand, clang::TypoCorrection::isKeyword(), clang::TypoCorrection::isResolved(), WantCXXNamedCasts, WantExpressionKeywords, WantObjCSuper, WantRemainingKeywords, and WantTypeSpecifiers.

Referenced by RankCandidate().

Member Data Documentation

◆ InvalidDistance

const unsigned clang::CorrectionCandidateCallback::InvalidDistance = TypoCorrection::InvalidDistance
static

Definition at line 283 of file TypoCorrection.h.

Referenced by RankCandidate().

◆ IsAddressOfOperand

bool clang::CorrectionCandidateCallback::IsAddressOfOperand = false

Definition at line 337 of file TypoCorrection.h.

Referenced by clang::Sema::ActOnIdExpression(), and ValidateCandidate().

◆ IsObjCIvarLookup

bool clang::CorrectionCandidateCallback::IsObjCIvarLookup = false

Definition at line 336 of file TypoCorrection.h.

Referenced by LookupMemberExpr().

◆ Typo

const IdentifierInfo* clang::CorrectionCandidateCallback::Typo
protected

Definition at line 348 of file TypoCorrection.h.

Referenced by MatchesTypo(), and setTypoName().

◆ TypoNNS

NestedNameSpecifier* clang::CorrectionCandidateCallback::TypoNNS
protected

Definition at line 349 of file TypoCorrection.h.

Referenced by MatchesTypo(), and setTypoNNS().

◆ WantCXXNamedCasts

bool clang::CorrectionCandidateCallback::WantCXXNamedCasts = true

◆ WantExpressionKeywords

bool clang::CorrectionCandidateCallback::WantExpressionKeywords = true

◆ WantFunctionLikeCasts

bool clang::CorrectionCandidateCallback::WantFunctionLikeCasts = true

◆ WantObjCSuper

bool clang::CorrectionCandidateCallback::WantObjCSuper = false

◆ WantRemainingKeywords

bool clang::CorrectionCandidateCallback::WantRemainingKeywords = true

◆ WantTypeSpecifiers

bool clang::CorrectionCandidateCallback::WantTypeSpecifiers = true

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