Граф коммитов

28 Коммитов

Автор SHA1 Сообщение Дата
Steve Naroff 7f5111212f - 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83597 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-08 23:45:10 +00:00
Steve Naroff ece8e71d12 Add code completion support for ObjC property declarations/attributes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83579 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-08 21:55:05 +00:00
Douglas Gregor 6a6840326e Determinism is for wimps. <Wimper>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82962 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-28 03:51:44 +00:00
Douglas Gregor 119fa68eb1 Clean up the CodeCompletion testsuite's use of FileCheck
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82726 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 22:57:42 +00:00
Douglas Gregor eb5758bbfd 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82663 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-23 22:26:46 +00:00
Douglas Gregor 5bd1a1151f 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82625 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-23 14:56:09 +00:00
Douglas Gregor 86d802e03a Print the results of code-completion for overloading by displaying the
signature of the function with the current parameter highlighted as a
placeholder.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82593 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-23 00:34:09 +00:00
Douglas Gregor 0594438e06 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82592 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-23 00:16:58 +00:00
Douglas Gregor 3e7253f155 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82587 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-22 23:22:24 +00:00
Douglas Gregor 0563c2677c 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.
 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82586 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-22 23:15:58 +00:00
Douglas Gregor b3d4525c65 Teach code-completion to introduce a ", ..." placeholder for variadic functions
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82577 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-22 21:42:17 +00:00
Douglas Gregor b657f115c3 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82571 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-22 21:11:38 +00:00
Douglas Gregor 9c6a0e92db 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82549 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-22 15:41:20 +00:00
Douglas Gregor 791215b7a2 Code completion for ordinary names when we're starting a declaration, expression, or statement
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82481 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 20:51:25 +00:00
Douglas Gregor 456c4a17f4 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).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82476 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 20:12:40 +00:00
Douglas Gregor b9d0ef7634 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82474 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 19:57:38 +00:00
Douglas Gregor 3e1005f085 Code completion for "case" statements within a switch on an expression
of enumeration type, providing the various unused enumerators as options.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82467 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 18:10:23 +00:00
Douglas Gregor ff360b64a6 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82307 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-18 23:55:56 +00:00
Douglas Gregor 63f07c55d5 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82306 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-18 23:21:38 +00:00
Douglas Gregor 56ff871ae7 Introduce code completion patterns for templates, which provide the
angle brackets < > along with placeholder template arguments.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82304 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-18 22:47:56 +00:00
Douglas Gregor e6e0361984 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82293 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-18 22:15:54 +00:00
Douglas Gregor ed8d322b40 C++ code completion after the "operator" keyword. Provide overloaded
operators, type specifiers, type names, and nested-name-specifiers.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82264 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-18 20:05:18 +00:00
Douglas Gregor 49f40bd0c9 Introduce four new code-completion hooks for C++:
- after "using", show anything that can be a nested-name-specifier.
  - after "using namespace", show any visible namespaces or namespace aliases
  - after "namespace", show any namespace definitions in the current scope
  - after "namespace identifier = ", show any visible namespaces or
    namespace aliases



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82251 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-18 19:03:04 +00:00
Douglas Gregor 75b7128e93 Handle using declarations and overload sets in code completion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82233 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-18 17:54:00 +00:00
Douglas Gregor 33224e61bf For code completion in C++ member access expressions and tag names,
look into the current scope for anything that could start a
nested-names-specifier. These results are ranked worse than any of the
results actually found in the lexical scope.

Perform a little more pruning of the result set, eliminating
constructors, __va_list_tag, and any duplication of declarations in
the result set. For the latter, implemented
NamespaceDecl::getCanonicalDecl.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82231 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-18 17:42:29 +00:00
Douglas Gregor b1c28a1f7e When gathering results for code completion, only include hidden
results when there is some way to refer to them in the language, such
as with a qualified name in C++.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82223 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-18 15:51:54 +00:00
Douglas Gregor 374929f7e8 Implement code completion for tags, e.g., code completion after "enum"
will provide the names of various enumerations currently
visible. Introduced filtering of code-completion results when we build
the result set, so that we can identify just the kinds of declarations
we want.

This implementation is incomplete for C++, since we don't consider
that the token after the tag keyword could start a
nested-name-specifier. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82222 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-18 15:37:17 +00:00
Douglas Gregor 81b747b7fc Initial implementation of a code-completion interface in Clang. In
essence, code completion is triggered by a magic "code completion"
token produced by the lexer [*], which the parser recognizes at
certain points in the grammar. The parser then calls into the Action
object with the appropriate CodeCompletionXXX action.

Sema implements the CodeCompletionXXX callbacks by performing minimal
translation, then forwarding them to a CodeCompletionConsumer
subclass, which uses the results of semantic analysis to provide
code-completion results. At present, only a single, "printing" code
completion consumer is available, for regression testing and
debugging. However, the design is meant to permit other
code-completion consumers.

This initial commit contains two code-completion actions: one for
member access, e.g., "x." or "p->", and one for
nested-name-specifiers, e.g., "std::". More code-completion actions
will follow, along with improved gathering of code-completion results
for the various contexts.

[*] In the current -code-completion-dump testing/debugging mode, the
file is truncated at the completion point and EOF is translated into
"code completion".


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82166 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-17 21:32:03 +00:00