clang  6.0.0svn
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
clang::TypoCorrection Class Reference

Simple class containing the result of Sema::CorrectTypo. More...

#include "clang/Sema/TypoCorrection.h"

Collaboration diagram for clang::TypoCorrection:
Collaboration graph
[legend]

Public Types

typedef SmallVectorImpl< NamedDecl * >::iterator decl_iterator
 
typedef SmallVectorImpl< NamedDecl * >::const_iterator const_decl_iterator
 

Public Member Functions

 TypoCorrection (const DeclarationName &Name, NamedDecl *NameDecl, NestedNameSpecifier *NNS=nullptr, unsigned CharDistance=0, unsigned QualifierDistance=0)
 
 TypoCorrection (NamedDecl *Name, NestedNameSpecifier *NNS=nullptr, unsigned CharDistance=0)
 
 TypoCorrection (DeclarationName Name, NestedNameSpecifier *NNS=nullptr, unsigned CharDistance=0)
 
 TypoCorrection ()
 
DeclarationName getCorrection () const
 Gets the DeclarationName of the typo correction. More...
 
IdentifierInfogetCorrectionAsIdentifierInfo () const
 
NestedNameSpecifiergetCorrectionSpecifier () const
 Gets the NestedNameSpecifier needed to use the typo correction. More...
 
void setCorrectionSpecifier (NestedNameSpecifier *NNS)
 
void WillReplaceSpecifier (bool ForceReplacement)
 
bool WillReplaceSpecifier () const
 
void setQualifierDistance (unsigned ED)
 
void setCallbackDistance (unsigned ED)
 
unsigned getEditDistance (bool Normalized=true) const
 Gets the "edit distance" of the typo correction from the typo. More...
 
NamedDeclgetFoundDecl () const
 Get the correction declaration found by name lookup (before we looked through using shadow declarations and the like). More...
 
NamedDeclgetCorrectionDecl () const
 Gets the pointer to the declaration of the typo correction. More...
 
template<class DeclClass >
DeclClass * getCorrectionDeclAs () const
 
void ClearCorrectionDecls ()
 Clears the list of NamedDecls. More...
 
void setCorrectionDecl (NamedDecl *CDecl)
 Clears the list of NamedDecls before adding the new one. More...
 
void setCorrectionDecls (ArrayRef< NamedDecl *> Decls)
 Clears the list of NamedDecls and adds the given set. More...
 
void addCorrectionDecl (NamedDecl *CDecl)
 Add the given NamedDecl to the list of NamedDecls that are the declarations associated with the DeclarationName of this TypoCorrection. More...
 
std::string getAsString (const LangOptions &LO) const
 
std::string getQuoted (const LangOptions &LO) const
 
 operator bool () const
 Returns whether this TypoCorrection has a non-empty DeclarationName. More...
 
void makeKeyword ()
 Mark this TypoCorrection as being a keyword. More...
 
bool isKeyword () const
 
template<std::size_t StrLen>
bool isKeyword (const char(&Str)[StrLen]) const
 
bool isResolved () const
 
bool isOverloaded () const
 
void setCorrectionRange (CXXScopeSpec *SS, const DeclarationNameInfo &TypoName)
 
SourceRange getCorrectionRange () const
 
decl_iterator begin ()
 
decl_iterator end ()
 
const_decl_iterator begin () const
 
const_decl_iterator end () const
 
bool requiresImport () const
 Returns whether this typo correction is correcting to a declaration that was declared in a module that has not been imported. More...
 
void setRequiresImport (bool Req)
 
void addExtraDiagnostic (PartialDiagnostic PD)
 Extra diagnostics are printed after the first diagnostic for the typo. More...
 
ArrayRef< PartialDiagnosticgetExtraDiagnostics () const
 

Static Public Member Functions

static unsigned NormalizeEditDistance (unsigned ED)
 

Static Public Attributes

static const unsigned InvalidDistance = ~0U
 
static const unsigned MaximumDistance = 10000U
 
static const unsigned CharDistanceWeight = 100U
 
static const unsigned QualifierDistanceWeight = 110U
 
static const unsigned CallbackDistanceWeight = 150U
 

Detailed Description

Simple class containing the result of Sema::CorrectTypo.

Definition at line 26 of file TypoCorrection.h.

Member Typedef Documentation

◆ const_decl_iterator

Definition at line 222 of file TypoCorrection.h.

◆ decl_iterator

Definition at line 217 of file TypoCorrection.h.

Constructor & Destructor Documentation

◆ TypoCorrection() [1/4]

clang::TypoCorrection::TypoCorrection ( const DeclarationName Name,
NamedDecl NameDecl,
NestedNameSpecifier NNS = nullptr,
unsigned  CharDistance = 0,
unsigned  QualifierDistance = 0 
)
inline

Definition at line 42 of file TypoCorrection.h.

◆ TypoCorrection() [2/4]

clang::TypoCorrection::TypoCorrection ( NamedDecl Name,
NestedNameSpecifier NNS = nullptr,
unsigned  CharDistance = 0 
)
inline

Definition at line 53 of file TypoCorrection.h.

◆ TypoCorrection() [3/4]

clang::TypoCorrection::TypoCorrection ( DeclarationName  Name,
NestedNameSpecifier NNS = nullptr,
unsigned  CharDistance = 0 
)
inline

Definition at line 62 of file TypoCorrection.h.

◆ TypoCorrection() [4/4]

clang::TypoCorrection::TypoCorrection ( )
inline

Definition at line 68 of file TypoCorrection.h.

Member Function Documentation

◆ addCorrectionDecl()

void TypoCorrection::addCorrectionDecl ( NamedDecl CDecl)

Add the given NamedDecl to the list of NamedDecls that are the declarations associated with the DeclarationName of this TypoCorrection.

Definition at line 4887 of file SemaLookup.cpp.

References clang::NamedDecl::getDeclName().

Referenced by setCorrectionDecl(), and setCorrectionDecls().

◆ addExtraDiagnostic()

void clang::TypoCorrection::addExtraDiagnostic ( PartialDiagnostic  PD)
inline

Extra diagnostics are printed after the first diagnostic for the typo.

This can be used to attach external notes to the diag.

Definition at line 235 of file TypoCorrection.h.

◆ begin() [1/2]

decl_iterator clang::TypoCorrection::begin ( )
inline

◆ begin() [2/2]

const_decl_iterator clang::TypoCorrection::begin ( ) const
inline

Definition at line 223 of file TypoCorrection.h.

References isKeyword().

◆ ClearCorrectionDecls()

void clang::TypoCorrection::ClearCorrectionDecls ( )
inline

Clears the list of NamedDecls.

Definition at line 149 of file TypoCorrection.h.

◆ end() [1/2]

decl_iterator clang::TypoCorrection::end ( )
inline

Definition at line 221 of file TypoCorrection.h.

Referenced by checkCorrectionVisibility().

◆ end() [2/2]

const_decl_iterator clang::TypoCorrection::end ( ) const
inline

Definition at line 226 of file TypoCorrection.h.

◆ getAsString()

std::string TypoCorrection::getAsString ( const LangOptions LO) const

Definition at line 4899 of file SemaLookup.cpp.

Referenced by clang::Sema::diagnoseTypo(), getQuoted(), and setCorrectionDecls().

◆ getCorrection()

DeclarationName clang::TypoCorrection::getCorrection ( ) const
inline

Gets the DeclarationName of the typo correction.

Definition at line 74 of file TypoCorrection.h.

◆ getCorrectionAsIdentifierInfo()

IdentifierInfo* clang::TypoCorrection::getCorrectionAsIdentifierInfo ( ) const
inline

◆ getCorrectionDecl()

NamedDecl* clang::TypoCorrection::getCorrectionDecl ( ) const
inline

Gets the pointer to the declaration of the typo correction.

Definition at line 139 of file TypoCorrection.h.

References getFoundDecl().

Referenced by findDirectBaseWithType(), getCorrectionDeclAs(), IsUsingDirectiveInToplevelContext(), and clang::FunctionCallFilterCCC::ValidateCandidate().

◆ getCorrectionDeclAs()

template<class DeclClass >
DeclClass* clang::TypoCorrection::getCorrectionDeclAs ( ) const
inline

◆ getCorrectionRange()

SourceRange clang::TypoCorrection::getCorrectionRange ( ) const
inline

Definition at line 213 of file TypoCorrection.h.

Referenced by attemptRecovery(), and clang::Sema::diagnoseTypo().

◆ getCorrectionSpecifier()

NestedNameSpecifier* clang::TypoCorrection::getCorrectionSpecifier ( ) const
inline

Gets the NestedNameSpecifier needed to use the typo correction.

Definition at line 80 of file TypoCorrection.h.

Referenced by attemptRecovery(), and findDirectBaseWithType().

◆ getEditDistance()

unsigned clang::TypoCorrection::getEditDistance ( bool  Normalized = true) const
inline

Gets the "edit distance" of the typo correction from the typo.

If Normalized is true, scale the distance down by the CharDistanceWeight to return the edit distance in terms of single-character edits.

Definition at line 116 of file TypoCorrection.h.

References CallbackDistanceWeight, InvalidDistance, and NormalizeEditDistance().

Referenced by isCandidateViable().

◆ getExtraDiagnostics()

ArrayRef<PartialDiagnostic> clang::TypoCorrection::getExtraDiagnostics ( ) const
inline

Definition at line 238 of file TypoCorrection.h.

References isKeyword().

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

◆ getFoundDecl()

NamedDecl* clang::TypoCorrection::getFoundDecl ( ) const
inline

Get the correction declaration found by name lookup (before we looked through using shadow declarations and the like).

Definition at line 134 of file TypoCorrection.h.

Referenced by attemptRecovery(), clang::Sema::diagnoseTypo(), and getCorrectionDecl().

◆ getQuoted()

std::string clang::TypoCorrection::getQuoted ( const LangOptions LO) const
inline

Definition at line 170 of file TypoCorrection.h.

References getAsString().

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

◆ isKeyword() [1/2]

bool clang::TypoCorrection::isKeyword ( ) const
inline

◆ isKeyword() [2/2]

template<std::size_t StrLen>
bool clang::TypoCorrection::isKeyword ( const char(&)  Str[StrLen]) const
inline

◆ isOverloaded()

bool clang::TypoCorrection::isOverloaded ( ) const
inline

Definition at line 202 of file TypoCorrection.h.

◆ isResolved()

bool clang::TypoCorrection::isResolved ( ) const
inline

◆ makeKeyword()

void clang::TypoCorrection::makeKeyword ( )
inline

Mark this TypoCorrection as being a keyword.

Since addCorrectionDeclsand setCorrectionDecl don't allow NULL to be added to the list of the correction's NamedDecl pointers, NULL is added as the only element in the list to mark this TypoCorrection as a keyword.

Definition at line 181 of file TypoCorrection.h.

◆ NormalizeEditDistance()

static unsigned clang::TypoCorrection::NormalizeEditDistance ( unsigned  ED)
inlinestatic

◆ operator bool()

clang::TypoCorrection::operator bool ( ) const
inlineexplicit

Returns whether this TypoCorrection has a non-empty DeclarationName.

Definition at line 175 of file TypoCorrection.h.

References bool.

◆ requiresImport()

bool clang::TypoCorrection::requiresImport ( ) const
inline

Returns whether this typo correction is correcting to a declaration that was declared in a module that has not been imported.

Definition at line 230 of file TypoCorrection.h.

Referenced by clang::Sema::diagnoseTypo(), and clang::TypoCorrectionConsumer::getNextCorrection().

◆ setCallbackDistance()

void clang::TypoCorrection::setCallbackDistance ( unsigned  ED)
inline

Definition at line 100 of file TypoCorrection.h.

Referenced by isCandidateViable().

◆ setCorrectionDecl()

void clang::TypoCorrection::setCorrectionDecl ( NamedDecl CDecl)
inline

Clears the list of NamedDecls before adding the new one.

Definition at line 154 of file TypoCorrection.h.

References addCorrectionDecl().

◆ setCorrectionDecls()

void clang::TypoCorrection::setCorrectionDecls ( ArrayRef< NamedDecl *>  Decls)
inline

Clears the list of NamedDecls and adds the given set.

Definition at line 160 of file TypoCorrection.h.

References addCorrectionDecl(), and getAsString().

Referenced by checkCorrectionVisibility().

◆ setCorrectionRange()

void clang::TypoCorrection::setCorrectionRange ( CXXScopeSpec SS,
const DeclarationNameInfo TypoName 
)
inline

◆ setCorrectionSpecifier()

void clang::TypoCorrection::setCorrectionSpecifier ( NestedNameSpecifier NNS)
inline

Definition at line 83 of file TypoCorrection.h.

◆ setQualifierDistance()

void clang::TypoCorrection::setQualifierDistance ( unsigned  ED)
inline

Definition at line 96 of file TypoCorrection.h.

◆ setRequiresImport()

void clang::TypoCorrection::setRequiresImport ( bool  Req)
inline

Definition at line 231 of file TypoCorrection.h.

Referenced by checkCorrectionVisibility().

◆ WillReplaceSpecifier() [1/2]

void clang::TypoCorrection::WillReplaceSpecifier ( bool  ForceReplacement)
inline

Definition at line 88 of file TypoCorrection.h.

Referenced by attemptRecovery(), and findDirectBaseWithType().

◆ WillReplaceSpecifier() [2/2]

bool clang::TypoCorrection::WillReplaceSpecifier ( ) const
inline

Definition at line 92 of file TypoCorrection.h.

Member Data Documentation

◆ CallbackDistanceWeight

const unsigned clang::TypoCorrection::CallbackDistanceWeight = 150U
static

Definition at line 40 of file TypoCorrection.h.

Referenced by getEditDistance().

◆ CharDistanceWeight

const unsigned clang::TypoCorrection::CharDistanceWeight = 100U
static

Definition at line 38 of file TypoCorrection.h.

Referenced by NormalizeEditDistance().

◆ InvalidDistance

const unsigned clang::TypoCorrection::InvalidDistance = ~0U
static

◆ MaximumDistance

const unsigned clang::TypoCorrection::MaximumDistance = 10000U
static

Definition at line 32 of file TypoCorrection.h.

◆ QualifierDistanceWeight

const unsigned clang::TypoCorrection::QualifierDistanceWeight = 110U
static

Definition at line 39 of file TypoCorrection.h.


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