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".
llvm-svn: 82166
2009-09-18 05:32:03 +08:00
|
|
|
struct Base1 {
|
|
|
|
int member1;
|
|
|
|
float member2;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Base2 {
|
|
|
|
int member1;
|
|
|
|
double member3;
|
|
|
|
void memfun1(int);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Base3 : Base1, Base2 {
|
|
|
|
void memfun1(float);
|
|
|
|
void memfun1(double);
|
|
|
|
void memfun2(int);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Derived : Base3 {
|
|
|
|
int member4;
|
|
|
|
int memfun3(int);
|
|
|
|
};
|
|
|
|
|
|
|
|
class Proxy {
|
|
|
|
public:
|
|
|
|
Derived *operator->() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
void test(const Proxy &p) {
|
2009-09-23 05:11:38 +08:00
|
|
|
p->
|
2009-11-08 09:45:36 +08:00
|
|
|
// RUN: clang-cc -fsyntax-only -code-completion-at=%s:29:6 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
|
2009-09-23 07:15:58 +08:00
|
|
|
// CHECK-CC1: member1 : 0 : [#Base1::#]member1
|
|
|
|
// CHECK-CC1: member1 : 0 : [#Base2::#]member1
|
|
|
|
// CHECK-CC1: member2 : 0 : [#Base1::#]member2
|
|
|
|
// CHECK-CC1: member3 : 0
|
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".
llvm-svn: 82166
2009-09-18 05:32:03 +08:00
|
|
|
// CHECK-CC1: member4 : 0
|
2009-09-23 07:15:58 +08:00
|
|
|
// CHECK-CC1: memfun1 : 0 : [#Base3::#]memfun1(<#float#>)
|
|
|
|
// CHECK-CC1: memfun1 : 0 : [#Base3::#]memfun1(<#double#>)
|
|
|
|
// CHECK-CC1: memfun2 : 0 : [#Base3::#]memfun2(<#int#>)
|
|
|
|
// CHECK-CC1: memfun3 : 0 : memfun3(<#int#>)
|
|
|
|
// CHECK-CC1: memfun1 : 0 (Hidden) : Base2::memfun1(<#int#>)
|
2009-12-12 01:31:05 +08:00
|
|
|
// CHECK-CC1: Base1 : 3 : Base1::
|
2009-09-23 05:11:38 +08:00
|
|
|
|