clang API Documentation

Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes
clang::TypoCorrection Class Reference

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

#include <TypoCorrection.h>

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

List of all members.

Public Types

typedef llvm::SmallVector
< NamedDecl *, 1 >::iterator 
decl_iterator
typedef llvm::SmallVector
< NamedDecl *, 1 >
::const_iterator 
const_decl_iterator

Public Member Functions

 TypoCorrection (const DeclarationName &Name, NamedDecl *NameDecl, NestedNameSpecifier *NNS=0, unsigned CharDistance=0, unsigned QualifierDistance=0)
 TypoCorrection (NamedDecl *Name, NestedNameSpecifier *NNS=0, unsigned CharDistance=0)
 TypoCorrection (DeclarationName Name, NestedNameSpecifier *NNS=0, unsigned CharDistance=0)
 TypoCorrection ()
DeclarationName getCorrection () const
 Gets the DeclarationName of the typo correction.
IdentifierInfogetCorrectionAsIdentifierInfo () const
NestedNameSpecifiergetCorrectionSpecifier () const
 Gets the NestedNameSpecifier needed to use the typo correction.
void setCorrectionSpecifier (NestedNameSpecifier *NNS)
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. If Normalized is true, scale the distance down by the CharDistanceWeight to return the edit distance in terms of single-character edits.
NamedDeclgetCorrectionDecl () const
 Gets the pointer to the declaration of the typo correction.
template<class DeclClass >
DeclClass * getCorrectionDeclAs () const
void setCorrectionDecl (NamedDecl *CDecl)
 Clears the list of NamedDecls before adding the new one.
void addCorrectionDecl (NamedDecl *CDecl)
 Add the given NamedDecl to the list of NamedDecls that are the declarations associated with the DeclarationName of this TypoCorrection.
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.
void makeKeyword ()
 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.
bool isKeyword () const
template<std::size_t StrLen>
bool isKeyword (const char(&Str)[StrLen]) const
bool isResolved () const
bool isOverloaded () const
decl_iterator begin ()
decl_iterator end ()
const_decl_iterator begin () const
const_decl_iterator end () 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 24 of file TypoCorrection.h.


Member Typedef Documentation

typedef llvm::SmallVector<NamedDecl*, 1>::const_iterator clang::TypoCorrection::const_decl_iterator

Definition at line 178 of file TypoCorrection.h.

typedef llvm::SmallVector<NamedDecl*, 1>::iterator clang::TypoCorrection::decl_iterator

Definition at line 173 of file TypoCorrection.h.


Constructor & Destructor Documentation

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

Definition at line 40 of file TypoCorrection.h.

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

Definition at line 50 of file TypoCorrection.h.

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

Definition at line 58 of file TypoCorrection.h.

clang::TypoCorrection::TypoCorrection ( ) [inline]

Definition at line 63 of file TypoCorrection.h.


Member Function Documentation

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 4038 of file SemaLookup.cpp.

References clang::NamedDecl::getDeclName().

Referenced by clang::Sema::CorrectTypo(), and setCorrectionDecl().

decl_iterator clang::TypoCorrection::begin ( ) [inline]

Definition at line 174 of file TypoCorrection.h.

References isKeyword().

Referenced by clang::Sema::DiagnoseEmptyLookup(), and DiagnoseInvalidRedeclaration().

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

Definition at line 179 of file TypoCorrection.h.

References isKeyword().

decl_iterator clang::TypoCorrection::end ( ) [inline]
const_decl_iterator clang::TypoCorrection::end ( ) const [inline]

Definition at line 182 of file TypoCorrection.h.

std::string TypoCorrection::getAsString ( const LangOptions LO) const
DeclarationName clang::TypoCorrection::getCorrection ( ) const [inline]
IdentifierInfo* clang::TypoCorrection::getCorrectionAsIdentifierInfo ( ) const [inline]
NamedDecl* clang::TypoCorrection::getCorrectionDecl ( ) const [inline]
template<class DeclClass >
DeclClass* clang::TypoCorrection::getCorrectionDeclAs ( ) const [inline]
NestedNameSpecifier* clang::TypoCorrection::getCorrectionSpecifier ( ) const [inline]

Gets the NestedNameSpecifier needed to use the typo correction.

Definition at line 74 of file TypoCorrection.h.

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

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 101 of file TypoCorrection.h.

References CallbackDistanceWeight, CharDistanceWeight, InvalidDistance, MaximumDistance, NormalizeEditDistance(), and QualifierDistanceWeight.

Referenced by isCandidateViable().

std::string clang::TypoCorrection::getQuoted ( const LangOptions LO) const [inline]
bool clang::TypoCorrection::isKeyword ( ) const [inline]

Definition at line 155 of file TypoCorrection.h.

Referenced by begin(), clang::Sema::CorrectTypo(), and isKeyword().

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

Definition at line 169 of file TypoCorrection.h.

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

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

Definition at line 167 of file TypoCorrection.h.

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 148 of file TypoCorrection.h.

static unsigned clang::TypoCorrection::NormalizeEditDistance ( unsigned  ED) [inline, static]

Definition at line 92 of file TypoCorrection.h.

References CharDistanceWeight, InvalidDistance, and MaximumDistance.

Referenced by clang::Sema::CorrectTypo(), and getEditDistance().

clang::TypoCorrection::operator bool ( ) const [inline]

Returns whether this TypoCorrection has a non-empty DeclarationName.

Definition at line 142 of file TypoCorrection.h.

References bool.

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

Definition at line 85 of file TypoCorrection.h.

Referenced by isCandidateViable().

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

Clears the list of NamedDecls before adding the new one.

Definition at line 127 of file TypoCorrection.h.

References addCorrectionDecl().

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

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

Definition at line 77 of file TypoCorrection.h.

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

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

Definition at line 81 of file TypoCorrection.h.

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


Member Data Documentation

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

Definition at line 38 of file TypoCorrection.h.

Referenced by getEditDistance().

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

Definition at line 36 of file TypoCorrection.h.

Referenced by getEditDistance(), and NormalizeEditDistance().

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

Definition at line 27 of file TypoCorrection.h.

Referenced by getEditDistance(), isCandidateViable(), and NormalizeEditDistance().

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

Definition at line 30 of file TypoCorrection.h.

Referenced by getEditDistance(), and NormalizeEditDistance().

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

Definition at line 37 of file TypoCorrection.h.

Referenced by getEditDistance().


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