Commit Graph

57 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 85b5063f2c When performing code completion for a case statement in a switch whose
condition is not of enumeration type, provide code-completion results
containing all values of integral or enumeral type.

llvm-svn: 109677
2010-07-28 21:50:18 +00:00
Douglas Gregor 9f1570d993 Only filter out names reserved for the implementation (e.g., __blah or
_Foo) from code-completion results when they come from a system
header.

llvm-svn: 108338
2010-07-14 17:44:04 +00:00
Douglas Gregor f4c33349b5 Make -code-completion-patterns only cover multi-line code
completions. Plus, tweak a few completion patterns to better reflect
the language grammar.

llvm-svn: 104905
2010-05-28 00:22:41 +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
Chris Lattner 561aabd943 when code completing inside a C-style block comment, don't emit errors about
a missing */ since we truncated the file.

This fixes rdar://7948776

llvm-svn: 103913
2010-05-16 19:54:05 +00:00
Douglas Gregor c01890e1cc When code completion produces an overload set as its results (e.g.,
while we're completing in the middle of a function call), also produce
"ordinary" name results that show what can be typed at that point.

llvm-svn: 100558
2010-04-06 20:19:47 +00:00
Douglas Gregor 2cb6c30673 Do not produce semicolons at the end of code-completion results
llvm-svn: 100557
2010-04-06 20:11:37 +00:00
Douglas Gregor 285560929f Only prove macros as code-completion results when we're in a case
statement or for ordinary names. This means that we won't show macros
when completing, e.g., member expressions such as "p->".

llvm-svn: 100555
2010-04-06 20:02:15 +00:00
John McCall 85f9055955 When pretty-printing tag types, only print the tag if we're in C (and
therefore not creating ElaboratedTypes, which are still pretty-printed
with the written tag).

Most of these testcase changes were done by script, so don't feel too
sorry for my fingers.

llvm-svn: 98149
2010-03-10 11:27:22 +00:00
Douglas Gregor ff59f676d0 Teach code-completion to deal with calls to functions without prototypes.
llvm-svn: 94076
2010-01-21 15:46:19 +00:00
Douglas Gregor 52ce62f069 Improve the sorting of code-completion results. We now always sort by
the "typed" text, first, then take into account
nested-name-specifiers, name hiding, etc. This means that the
resulting sort is actually alphabetical :)

llvm-svn: 93370
2010-01-13 23:24:38 +00:00
Douglas Gregor 504a6ae83e Improve code completion by introducing patterns for the various C and
C++ grammatical constructs that show up in top-level (namespace-level)
declarations, member declarations, template declarations, statements,
expressions, conditions, etc. For example, we now provide a pattern
for

  static_cast<type>(expr)

when we can have an expression, or

  using namespace identifier;

when we can have a using directive.

Also, improves the results of code completion at the beginning of a
top-level declaration. Previously, we would see value names (function
names, global variables, etc.); now we see types, namespace names,
etc., but no values.

llvm-svn: 93134
2010-01-10 23:08:15 +00:00
Douglas Gregor 9882a5aac6 Teach Preprocessor::macro_begin/macro_end to lazily load all macro
definitions from a precompiled header. This ensures that
code-completion with macro names behaves the same with or without
precompiled headers.

llvm-svn: 92497
2010-01-04 19:18:44 +00:00
Douglas Gregor b3fa919c2d Extend code-completion results with the type of each result
llvm-svn: 91702
2009-12-18 18:53:37 +00:00
Daniel Dunbar 8fbe78f6fc Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- This is designed to make it obvious that %clang_cc1 is a "test variable"
   which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
   can be useful to redefine what gets run as 'clang -cc1' (for example, to set
   a default target).

llvm-svn: 91446
2009-12-15 20:14:24 +00:00
Fariborz Jahanian a01b67d7b0 Make tests use the new clang -cc1 flag.
llvm-svn: 91303
2009-12-14 18:00:56 +00:00
Douglas Gregor 0f622367d3 Add a function's cv-qualifiers to the code-completion results as an
informative chunk.

llvm-svn: 91139
2009-12-11 18:44:16 +00:00
Douglas Gregor 800f2f0ff0 Teach code completion to instantiate templates when it needs to
llvm-svn: 91138
2009-12-11 18:28:39 +00:00
Douglas Gregor 7078839b0e Member function templates can occur after . or ->
llvm-svn: 91137
2009-12-11 18:14:22 +00:00
Douglas Gregor 99fe2ad8c8 Tweak code-completion results by suppressing class template
specializations and class template partial specializations (they're
never named directly). Also, member access expressions only refer to
value declarations (fields, functions, enumerators, etc.) and
Objective-C property declarations; filter out everything else.

llvm-svn: 91133
2009-12-11 17:31:05 +00:00
Douglas Gregor 83c49b56fe Class template (partial) specializations should not show up in code completion results
llvm-svn: 91125
2009-12-11 16:18:54 +00:00
Douglas Gregor 45f83ee87d Improve code-completion results for the flags in an @property
declaration by providing patterns for "getter = <method>" and "setter
= <method>". As part of this, invented a new "pattern" result kind
that is merely a semantic string. The "pattern" result kind should
help with other kinds of code templates.

llvm-svn: 89277
2009-11-19 00:01:57 +00:00
Douglas Gregor bab2b3c70f Refactor code-completion support for message sends, collecting the
code to find and add Objective-C methods (starting at an
ObjCContainerDecl) into a single, static function. Also, make sure
that we search into the implementations of classes and categories to
find even more methods.

llvm-svn: 89163
2009-11-17 23:22:23 +00:00
Daniel Dunbar 34546ce43d Remove RUN: true lines.
llvm-svn: 86432
2009-11-08 01:47:25 +00:00
Daniel Dunbar 8b57697954 Eliminate &&s in tests.
- 'for i in $(find . -type f); do sed -e 's#\(RUN:.*[^ ]\) *&& *$#\1#g' $i | FileUpdate $i; done', for the curious.

llvm-svn: 86430
2009-11-08 01:45:36 +00:00
Steve Naroff eae650366d Add basic code completion support for ObjC messages.
Still a work in progress...

llvm-svn: 86323
2009-11-07 02:08:14 +00:00
Douglas Gregor 9eb7701dff Various improvements to Clang's code-completion infrastructure:
- Introduce more code-completion string "chunk" kinds that describe
  symbols, the actual text that the user is expected to type, etc.
  - Make the generation of macro results optional, since it can be
  slow
  - Make code-completion accessible through the C API, marshalling the
  code-completion results through a temporary file (ick) to maintain
  process separation.

The last doesn't have tests yet.

llvm-svn: 86306
2009-11-07 00:00:49 +00:00
Douglas Gregor f329c7c3c0 Include macros in code-completion results
llvm-svn: 85594
2009-10-30 16:50:04 +00:00
Steve Naroff 3b08630b06 - Fixup SortCodeCompleteResult() to properly sort keywords on Mac OS (compare was system dependent). Worked on Linux, failed on Mac OS (which caused the recently added testcase to fail on Linux).
- Sort results in testcase.

llvm-svn: 83597
2009-10-08 23:45:10 +00:00
Steve Naroff 936354c62a Add code completion support for ObjC property declarations/attributes.
llvm-svn: 83579
2009-10-08 21:55:05 +00:00
Douglas Gregor e6688e653f Determinism is for wimps. <Wimper>
llvm-svn: 82962
2009-09-28 03:51:44 +00:00
Douglas Gregor 9fb4bf4d57 Clean up the CodeCompletion testsuite's use of FileCheck
llvm-svn: 82726
2009-09-24 22:57:42 +00:00
Douglas Gregor e412a5a8f7 For code completion, note that injected-class-names found as part of
lookup in a member access expression always start a
nested-name-specifier. Additionally, rank names that start
nested-name-specifiers after other names.

llvm-svn: 82663
2009-09-23 22:26:46 +00:00
Douglas Gregor 2a920014d3 When code-completion after a "," is building an overload set, note
that there is one more argument (the one following the comma) and make
the candidate non-viable if the function cannot accept any argument in
that position.

llvm-svn: 82625
2009-09-23 14:56:09 +00:00
Douglas Gregor f0f51985a1 Print the results of code-completion for overloading by displaying the
signature of the function with the current parameter highlighted as a
placeholder.

llvm-svn: 82593
2009-09-23 00:34:09 +00:00
Douglas Gregor 05f477c177 Separate the code-completion results for call completion from the
results for other, textual completion. For call completion, we now
produce enough information to show the function call argument that we
are currently on.

llvm-svn: 82592
2009-09-23 00:16:58 +00:00
Douglas Gregor 2b3ee156fc When code-completion finds a declaration only because it is usable as
the start of a nested-name-specifier, add the "::" after the
nested-name-specifier to the code-completion string.

llvm-svn: 82587
2009-09-22 23:22:24 +00:00
Douglas Gregor 5bf52697b0 Tweak the code-completion results ranking and formation, so that
members found in base classes have the same ranking as members found
in derived classes. However, we will introduce an informative note for
members found in base classes, showing (as a nested-name-specifier)
the qualification to name the base class, to make it clear which
members are from bases.
 

llvm-svn: 82586
2009-09-22 23:15:58 +00:00
Douglas Gregor ba4490399b Teach code-completion to introduce a ", ..." placeholder for variadic functions
llvm-svn: 82577
2009-09-22 21:42:17 +00:00
Douglas Gregor ea9b03e6e2 Replace the -code-completion-dump option with
-code-completion-at=filename:line:column

which performs code completion at the specified location by truncating
the file at that position and enabling code completion. This approach
makes it possible to run multiple tests from a single test file, and
gives a more natural command-line interface.

llvm-svn: 82571
2009-09-22 21:11:38 +00:00
Douglas Gregor cabea40ea3 Implement code completion within a function call, triggered after the
opening parentheses and after each comma. We gather the set of visible
overloaded functions, perform "partial" overloading based on the set
of arguments that we have thus far, and return the still-viable
results sorted by the likelihood that they will be the best candidate.

Most of the changes in this patch are a refactoring of the overloading
routines for a function call, since we needed to separate out the
notion of building an overload set (common to code-completion and
normal semantic analysis) and then what to do with that overload
set. As part of this change, I've pushed explicit template arguments
into a few more subroutines.

There is still much more work to do in this area. Function templates
won't be handled well (unless we happen to deduce all of the template
arguments before we hit the completion point), nor will overloaded
function-call operators or calls to member functions.

llvm-svn: 82549
2009-09-22 15:41:20 +00:00
Douglas Gregor 9d64c5e3a5 Code completion for ordinary names when we're starting a declaration, expression, or statement
llvm-svn: 82481
2009-09-21 20:51:25 +00:00
Douglas Gregor 2af2f670d1 When providing a code-completion suggestion for a hidden name, include
a nested-name-specifier that describes how to refer to that name. For
example, given:

  struct Base { int member; };
  struct Derived : Base { int member; };

the code-completion result for a member access into "Derived" will
provide both "member" to refer to Derived::member (no qualification needed) and
"Base::member" to refer to Base::member (qualification included).

llvm-svn: 82476
2009-09-21 20:12:40 +00:00
Douglas Gregor f251067530 Enhance "case" code completion in C++ to suggest qualified names for
enumerators when either the user intentionally wrote a qualified name
(in which case we just use that nested-name-specifier to match
the user's code) or when this is the first "case" statement and we
need a qualified name to refer to an enumerator in a different scope.

llvm-svn: 82474
2009-09-21 19:57:38 +00:00
Douglas Gregor d328d57c39 Code completion for "case" statements within a switch on an expression
of enumeration type, providing the various unused enumerators as options.

llvm-svn: 82467
2009-09-21 18:10:23 +00:00
Douglas Gregor b5c738b434 In C++ code completion, only suggest the "template" keyword after ".",
"->", or "::" if we will be looking into a dependent context. It's not
wrong to use the "template" keyword, but it's to needed, either.

llvm-svn: 82307
2009-09-18 23:55:56 +00:00
Douglas Gregor ce23bae4f8 Make the construction of the code-completion string for a function
template smarter, by taking into account which function template
parameters are deducible from the call arguments. For example,

  template<typename RandomAccessIterator>
  void sort(RandomAccessIterator first, RandomAccessIterator last);

will have a code-completion string like

  sort({RandomAccessIterator first}, {RandomAccessIterator last})

since the template argument for its template parameter is
deducible. On the other hand,

  template<class X, class Y>
  X* dyn_cast(Y *Val);

will have a code-completion string like

  dyn_cast<{class X}>({Y *Val})

since the template type parameter X is not deducible from the function
call.

llvm-svn: 82306
2009-09-18 23:21:38 +00:00
Douglas Gregor 3f6ca38927 Introduce code completion patterns for templates, which provide the
angle brackets < > along with placeholder template arguments.

llvm-svn: 82304
2009-09-18 22:47:56 +00:00
Douglas Gregor fedc328ae9 Introduce code completion strings, which describe how to *use* the
results of code completion, e.g., by providing function call syntax
with placeholders for each of the parameters.

llvm-svn: 82293
2009-09-18 22:15:54 +00:00