[cfe-commits] [PATCH] Add callback object to Sema::CorrectTypo
dgregor at apple.com
Tue Jan 10 20:23:06 PST 2012
On Jan 10, 2012, at 5:06 PM, Kaelyn Uhrain wrote:
> This patch is a rough draft of my attempt to replace the Sema::CorrectTypoContext enum with a callback object for performing finer grained validation of potential typo corrections. This version just includes a wrapper for Sema::CorrectTypo to translate a CorrectTypoContext value into a corresponding callback object. The idea is to give CorrectTypo a way to filter potential corrections with more accuracy by being able to take into account e.g. what kinds of decls are allowed/expected, instead of giving a very rough guide on what corrections are acceptable (CorrectTypoContext values mainly affect which keywords should be added to the set of possible corrections; the exceptions are that CTC_ObjCMessageReceiver would give precedence to the "super" keyword over other corrections with the same edit distance, and CTC_ObjCIvarLookup would trigger ObjC ivar lookup before other forms of lookup when looking up potential typo correction identifiers).
> I'll be surprised if the interface of the callback class doesn't expand or improve as I fix up callers of CorrectTypo to use callback objects directly. I also hope to entirely remove or at least come up with a cleaner solution than the flags in the callback class that control which keywords are added to the candidate pool. I'm sending this initial patch to start gathering feedback on the approach while fixing up the CorrectTypo callers, as those changes will most likely dwarf the changes that add the callback infrastructure to CorrectTypo. As such, I'm fine with either submitting this patch or holding off until the conversion is further along.
I like this approach, and I'm fine with the callback interface evolving as you switch callers over to using it. I do suggest migrating one caller over to its own CorrectionCandidateCallback subclass so you're exercising that code path, and then committing this patch and the change to that one one caller at once.
Then, you can switch each of the other call sites over, one-by-one, improving the callback interface as necessary.
More information about the cfe-commits