Commit Graph

14 Commits

Author SHA1 Message Date
Douglas Gregor 86ad085b40 Give a slight edge to the context-sensitive keyword 'super' over
non-function-local declarations with names similar to what the user
typed. For example, this allows us to correct 'supper' to 'super' in
an Objective-C message send, even though the C function 'isupper' has
the same edit distance.

llvm-svn: 104023
2010-05-18 16:30:22 +00:00
Douglas Gregor 5fd04d4832 Tweak typo-correction logic a bit regarding "super", so that we
consider "super" as a candidate whenever we're parsing an expression
within an Objective-C method in an interface that has a superclass. At
some point, we'd like to give "super" a little edge over non-local
names; that will come later.

llvm-svn: 104022
2010-05-18 16:14:23 +00:00
Ted Kremenek 990783e345 Clean up test case and remove XFAIL. This test can now distinguish between
cases where Clang can suggest and fix and suggest and not auto-fix (because of
current limitations).

llvm-svn: 103987
2010-05-17 23:03:33 +00:00
Nick Lewycky 784fad7a41 Teach clang -fixit to modify files in-place, or -fixit=suffix to create new
files with the additional suffix in the middle.

llvm-svn: 102230
2010-04-24 01:30:46 +00:00
Douglas Gregor 0b59e80db5 When searching for code-completion and typo-correction candidates,
look from an Objective-C class or category to its implementation, to
pick up synthesized ivars. Fixes a problem reported by David
Chisnall.

llvm-svn: 101792
2010-04-19 18:02:19 +00:00
Nick Lewycky a1e20de908 Teach -fixit to modify all of its inputs instead of just the main file, unless
-fixit-at specified a particular fixit to fix, or the -o flag was used.

llvm-svn: 101359
2010-04-15 06:46:58 +00:00
Douglas Gregor 280e1ee0ae Teach typo correction about various language keywords. We can't
generally recover from typos in keywords (since we would effectively
have to mangle the token stream). However, there are still benefits to
typo-correcting with keywords:
  - We don't make stupid suggestions when the user typed something
  that is similar to a keyword. 
  - We can suggest the keyword in a diagnostic (did you mean
  "static_cast"?), even if we can't recover and therefore don't have
  a fix-it.

llvm-svn: 101274
2010-04-14 20:04:41 +00:00
Douglas Gregor 8aa4ebf0bc Implement typo correction for Objective-C message sends when the
receiver is a mis-typed class name. Previously, we would give a non-specific
typo-correction diagnostic from the expression-parsing code, but there
was no fix-it because it was too late to recover. Now, we give a nice
diagnostic

honk.m:6:4: error: unknown receiver 'Hnk'; did you mean 'Honk'?
  [Hnk method];
   ^~~
   Honk
honk.m:1:1: note: 'Honk' declared here
@interface Honk
^

which includes a fix-it.

We still need to recover better from mis-typing "super".

llvm-svn: 101211
2010-04-14 02:46:37 +00:00
Douglas Gregor 0c8a172911 Fix a crash with ill-formed code within a method in an ill-formed
category implementation, which showed up during (attempted) typo
correction. Fixes <rdar://problem/7605289>.

llvm-svn: 95334
2010-02-04 23:42:48 +00:00
Fariborz Jahanian 98609b3a07 Patch to implement required warnings for unimplemented
properties imported frfom protocol. Fixes radar 7544809.

llvm-svn: 93965
2010-01-20 01:51:55 +00:00
Douglas Gregor 6da83624e4 Whenever we emit a typo-correction diagnostic, also emit a note
pointing to the declaration that we found that has that name (if it is
unique).

llvm-svn: 92877
2010-01-07 00:17:44 +00:00
Douglas Gregor 35b0bac8c5 Implement typo correction for a variety of Objective-C-specific
constructs:

  - Instance variable lookup ("foo->ivar" and, in instance methods, "ivar")
  - Property name lookup ("foo.prop")
  - Superclasses
  - Various places where a class name is required
  - Protocol names (e.g., id<proto>)

This seems to cover many of the common places where typos could occur.

llvm-svn: 92449
2010-01-03 18:01:57 +00:00
Douglas Gregor 3f8f44757f Fix typo test RUN lines
llvm-svn: 92396
2010-01-01 17:23:17 +00:00
Douglas Gregor 2536398a5d When typo correction for an id-expression finds a type (or Objective-C
class), provide a suggestion for the type or class found. However,
since we can't recover properly in this case, don't provide a fix-it
hint. Example:

test/FixIt/typo.m:8:3: error: use of undeclared identifier 'NSstring';
did you
      mean 'NSString'?
  NSstring *str = @"A string";
  ...
  ^
1 diagnostic generated.

llvm-svn: 92379
2010-01-01 00:15:04 +00:00