clang
22.0.0git
include
clang
Basic
SimpleTypoCorrection.h
Go to the documentation of this file.
1
//===- SimpleTypoCorrection.h - Basic typo correction utility -*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file defines the SimpleTypoCorrection class, which performs basic
10
// typo correction using string similarity based on edit distance.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CLANG_BASIC_SIMPLETYPOCORRECTION_H
15
#define LLVM_CLANG_BASIC_SIMPLETYPOCORRECTION_H
16
17
#include "
clang/Basic/LLVM.h
"
18
#include "llvm/ADT/StringRef.h"
19
20
namespace
clang
{
21
22
class
IdentifierInfo
;
23
24
class
SimpleTypoCorrection
{
25
StringRef BestCandidate;
26
StringRef Typo;
27
28
const
unsigned
MaxEditDistance;
29
unsigned
BestEditDistance;
30
unsigned
BestIndex;
31
unsigned
NextIndex;
32
33
public
:
34
explicit
SimpleTypoCorrection
(StringRef Typo)
35
: BestCandidate(), Typo(Typo), MaxEditDistance((Typo.size() + 2) / 3),
36
BestEditDistance(MaxEditDistance + 1), BestIndex(0), NextIndex(0) {}
37
38
void
add
(
const
StringRef Candidate);
39
void
add
(
const
char
*Candidate);
40
void
add
(
const
IdentifierInfo
*Candidate);
41
42
std::optional<StringRef>
getCorrection
()
const
;
43
bool
hasCorrection
()
const
;
44
unsigned
getCorrectionIndex
()
const
;
45
};
46
}
// namespace clang
47
48
#endif
// LLVM_CLANG_BASIC_SIMPLETYPOCORRECTION_H
LLVM.h
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition
IdentifierTable.h:116
clang::SimpleTypoCorrection::getCorrection
std::optional< StringRef > getCorrection() const
Definition
SimpleTypoCorrection.cpp:55
clang::SimpleTypoCorrection::add
void add(const StringRef Candidate)
Definition
SimpleTypoCorrection.cpp:21
clang::SimpleTypoCorrection::SimpleTypoCorrection
SimpleTypoCorrection(StringRef Typo)
Definition
SimpleTypoCorrection.h:34
clang::SimpleTypoCorrection::getCorrectionIndex
unsigned getCorrectionIndex() const
Definition
SimpleTypoCorrection.cpp:53
clang::SimpleTypoCorrection::hasCorrection
bool hasCorrection() const
Definition
SimpleTypoCorrection.cpp:61
clang
The JSON file list parser is used to communicate input to InstallAPI.
Definition
CalledOnceCheck.h:17
Generated on
for clang by
1.14.0