mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Provide a frontend option to disable typo correction.
rdar://29003217
This commit is contained in:
@@ -48,6 +48,9 @@ namespace swift {
|
||||
/// \brief Disable API availability checking.
|
||||
bool DisableAvailabilityChecking = false;
|
||||
|
||||
/// \brief Disable typo correction.
|
||||
bool DisableTypoCorrection = false;
|
||||
|
||||
/// Should access control be respected?
|
||||
bool EnableAccessControl = true;
|
||||
|
||||
|
||||
@@ -116,6 +116,9 @@ def serialize_debugging_options : Flag<["-"], "serialize-debugging-options">,
|
||||
def autolink_library : Separate<["-"], "autolink-library">,
|
||||
HelpText<"Add dependent library">, Flags<[FrontendOption]>;
|
||||
|
||||
def disable_typo_correction : Flag<["-"], "disable-typo-correction">,
|
||||
HelpText<"Disable typo correction">;
|
||||
|
||||
} // end let Flags = [FrontendOption, NoDriverOption]
|
||||
|
||||
def debug_crash_Group : OptionGroup<"<automatic crashing options>">;
|
||||
|
||||
@@ -821,6 +821,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
||||
= A->getOption().matches(OPT_enable_access_control);
|
||||
}
|
||||
|
||||
Opts.DisableTypoCorrection |= Args.hasArg(OPT_disable_typo_correction);
|
||||
|
||||
Opts.CodeCompleteInitsInPostfixExpr |=
|
||||
Args.hasArg(OPT_code_complete_inits_in_postfix_expr);
|
||||
|
||||
|
||||
@@ -504,6 +504,9 @@ void TypeChecker::performTypoCorrection(DeclContext *DC, DeclRefKind refKind,
|
||||
NameLookupOptions lookupOptions,
|
||||
LookupResult &result,
|
||||
unsigned maxResults) {
|
||||
if (getLangOpts().DisableTypoCorrection)
|
||||
return;
|
||||
|
||||
// Fill in a collection of the most reasonable entries.
|
||||
TopCollection<unsigned, ValueDecl*> entries(maxResults);
|
||||
auto consumer = makeDeclConsumer([&](ValueDecl *decl,
|
||||
|
||||
Reference in New Issue
Block a user