Commit Graph

19 Commits

Author SHA1 Message Date
Douglas Gregor 400f59763b When provide code completions for a variadic Objective-C method
declaration send or a variadic function call, collapse the ", ..."
into the parameter before it, so that we don't get a second
placeholder.

llvm-svn: 112579
2010-08-31 05:13:43 +00:00
Douglas Gregor 0de55cecb2 When combining the code-completion results from Sema long with the
code-completion results cached by ASTUnit, sort the resulting result
set. This makes testing far, far easier, so this commit also includes
tests for the previous few fixes.

llvm-svn: 112070
2010-08-25 18:41:16 +00:00
Douglas Gregor 115837041e Introduce a preprocessor code-completion hook for contexts where we
expect "natural" language and should not provide any completions,
e.g., comments, string literals, #error.

llvm-svn: 112054
2010-08-25 17:04:25 +00:00
Douglas Gregor 4d755e86b4 Give a slight preference to functions returning "void" when we're
performing code completion at the statement level (rather than in an
arbitrary expression).

llvm-svn: 112001
2010-08-24 23:58:17 +00:00
Douglas Gregor 45140a9040 In code-completion contexts where both types and other values are
present, prefer values to types, since it's more common to compute
with values than it is to declare new entities or perform type
casts. So, tweak the ranking of types vs. other declarations and
constants accordingly.

llvm-svn: 111998
2010-08-24 23:40:45 +00:00
Douglas Gregor dbb71db4cc When calling a function or messaging a method marked "sentinel", add
the ", nil", ", NULL", or ", (void*)0" to the end of the code
completion, since it always has to be there anyway.

llvm-svn: 111867
2010-08-23 23:51:41 +00:00
Douglas Gregor f757a12dfc Introduce new libclang API functions that determine the availability
of a cursor or code-completion result, e.g., whether that result
refers to an unavailable, deleted, or deprecated declaration.

llvm-svn: 111858
2010-08-23 23:00:57 +00:00
Douglas Gregor ce0e856809 Include __FUNCTION__, __PRETTY_FUNCTION_, __func__ in code-completion
results for expression contexts within a function.

llvm-svn: 111851
2010-08-23 21:54:33 +00:00
Douglas Gregor b61c07aca0 When caching code completions for global declarations, keep track of
the usage type of each declaration result, then compare those types to
the preferred type of the completion. This provides parity in the
priority calculation between the code-completion results produced
directly from Sema and those cached by ASTUnit. 

For the standard Cocoa.h (+ others) example, there's a penalty of 3-4
hundredeths of a second when caching the global results (for ~31,000
results), because we need an ASTContext-agnostic representation of
types for the comparison, and therefore we use... strings. Eventually,
we'd like to implement a more efficient ASTContext-agnostic encoding
of types.

llvm-svn: 111165
2010-08-16 18:08:11 +00:00
Douglas Gregor 6e24033bd2 When caching global completion results, keep track of the simplified
type class, so that we can adjust priorities appropriately when the
preferred type for the context and the actual type of the completion
are similar.

This gets us one step closer to parity of the cached completion
results with the non-cached completion results.

llvm-svn: 111139
2010-08-16 16:18:59 +00:00
Douglas Gregor 3998219789 Extend the code-completion caching infrastructure to include global
declarations (in addition to macros). Each kind of declaration maps to
a certain set of completion contexts, and the ASTUnit completion logic
introduces the completion strings for those declarations if the actual
code-completion occurs in one of the contexts where it matters. 

There are a few new code-completion-context kinds. Without these,
certain completions (e.g., after "using namespace") would need to
suppress all global completions, which would be unfortunate.

Note that we don't get the priorities right for global completions,
because we don't have enough type information. We'll need a way to
compare types in an ASTContext-agnostic way before this can be
implemented.

llvm-svn: 111093
2010-08-15 06:18:01 +00:00
Douglas Gregor 8e984da800 Add code-completion support directly to ASTUnit, which performs code
completion within the translation unit using the same command-line
arguments for parsing the translation unit. Eventually, we'll reuse
the precompiled preamble to improve code-completion performance, and
this also gives us a place to cache results.

Expose this function via the new libclang function
clang_codeCompleteAt(), which performs the code completion within a
CXTranslationUnit. The completion occurs in-process
(clang_codeCompletion() runs code completion out-of-process).

llvm-svn: 110210
2010-08-04 16:47:14 +00:00
Douglas Gregor fe4a4107d8 Improve our handling of NULL after an escaping '\' in a string
literal. Fixes <rdar://problem/8044135>.

llvm-svn: 105181
2010-05-30 22:59:50 +00:00
Douglas Gregor 2683c28ff6 Improve parser recovery when we try to parse a call expression but the
called function itself is invalid (e.g., because of a semantic error
referring to that declaration). Fixes <rdar://problem/8044142>.

llvm-svn: 105175
2010-05-30 22:23:08 +00:00
Douglas Gregor 7aa6b229fe Teach code completion to adjust its completion priorities based on the
type that we expect to see at a given point in the grammar, e.g., when
initializing a variable, returning a result, or calling a function. We
don't prune the candidate set at all, just adjust priorities to favor
things that should type-check, using an ultra-simplified type system.

llvm-svn: 105128
2010-05-30 01:49:25 +00:00
Douglas Gregor 70febae768 Do not produce types as valid code completions when we're in an
expression context in C/Objective-C, or when we're in an
@interface/@implementation/@protocol in Objective-C(++).

llvm-svn: 104908
2010-05-28 00:49:12 +00:00
Douglas Gregor a2db793ff0 Introduce priorities into the code-completion results.
llvm-svn: 104751
2010-05-26 22:00:08 +00:00
Douglas Gregor f64acca2f5 Only enable code patterns (e.g., try { statements } catch (...) {
statements }) in the code-completion results if explicitly requested.

llvm-svn: 104637
2010-05-25 21:41:55 +00:00
Douglas Gregor be9ea80abf Perform code-completion within ParseCastExpression, which handles,
e.g., the right-hand side of binary expressions.

llvm-svn: 100526
2010-04-06 15:09:27 +00:00