Provide a frontend option to disable typo correction.

rdar://29003217
This commit is contained in:
John McCall
2016-11-02 14:08:56 -07:00
parent bfab9d607e
commit d123345689
4 changed files with 11 additions and 0 deletions

View File

@@ -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;

View File

@@ -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>">;

View File

@@ -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);

View File

@@ -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,