2009-09-21 20:56:56 +04:00
|
|
|
//===--- CodeCompleteConsumer.cpp - Code Completion Interface ---*- C++ -*-===//
|
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-18 01:32:03 +04:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the CodeCompleteConsumer class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "clang/Sema/CodeCompleteConsumer.h"
|
2010-08-20 22:27:03 +04:00
|
|
|
#include "clang/Sema/Scope.h"
|
2010-08-13 00:07:10 +04:00
|
|
|
#include "clang/Sema/Sema.h"
|
2009-09-18 21:54:00 +04:00
|
|
|
#include "clang/AST/DeclCXX.h"
|
2010-08-24 11:21:54 +04:00
|
|
|
#include "clang/AST/DeclObjC.h"
|
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-18 01:32:03 +04:00
|
|
|
#include "clang/Lex/Preprocessor.h"
|
2009-12-01 08:55:20 +03:00
|
|
|
#include "clang-c/Index.h"
|
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-18 01:32:03 +04:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
#include <algorithm>
|
2009-09-19 02:15:54 +04:00
|
|
|
#include <cstring>
|
|
|
|
#include <functional>
|
2009-11-17 19:43:05 +03:00
|
|
|
|
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-18 01:32:03 +04:00
|
|
|
using namespace clang;
|
2009-11-17 19:43:05 +03:00
|
|
|
using llvm::StringRef;
|
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-18 01:32:03 +04:00
|
|
|
|
2009-09-19 02:15:54 +04:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Code completion string implementation
|
|
|
|
//===----------------------------------------------------------------------===//
|
2009-11-07 03:00:49 +03:00
|
|
|
CodeCompletionString::Chunk::Chunk(ChunkKind Kind, llvm::StringRef Text)
|
2009-11-12 21:40:12 +03:00
|
|
|
: Kind(Kind), Text("")
|
2009-09-23 03:15:58 +04:00
|
|
|
{
|
2009-11-07 03:00:49 +03:00
|
|
|
switch (Kind) {
|
|
|
|
case CK_TypedText:
|
|
|
|
case CK_Text:
|
|
|
|
case CK_Placeholder:
|
|
|
|
case CK_Informative:
|
2009-12-18 21:53:37 +03:00
|
|
|
case CK_ResultType:
|
2009-11-07 03:00:49 +03:00
|
|
|
case CK_CurrentParameter: {
|
|
|
|
char *New = new char [Text.size() + 1];
|
|
|
|
std::memcpy(New, Text.data(), Text.size());
|
|
|
|
New[Text.size()] = '\0';
|
|
|
|
this->Text = New;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CK_Optional:
|
2009-12-12 08:05:38 +03:00
|
|
|
llvm_unreachable("Optional strings cannot be created from text");
|
2009-11-07 03:00:49 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CK_LeftParen:
|
|
|
|
this->Text = "(";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CK_RightParen:
|
|
|
|
this->Text = ")";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CK_LeftBracket:
|
|
|
|
this->Text = "[";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CK_RightBracket:
|
|
|
|
this->Text = "]";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CK_LeftBrace:
|
|
|
|
this->Text = "{";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CK_RightBrace:
|
|
|
|
this->Text = "}";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CK_LeftAngle:
|
|
|
|
this->Text = "<";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CK_RightAngle:
|
|
|
|
this->Text = ">";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CK_Comma:
|
|
|
|
this->Text = ", ";
|
|
|
|
break;
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 02:08:15 +03:00
|
|
|
|
|
|
|
case CK_Colon:
|
2010-04-07 04:21:17 +04:00
|
|
|
this->Text = ":";
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 02:08:15 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CK_SemiColon:
|
|
|
|
this->Text = ";";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CK_Equal:
|
|
|
|
this->Text = " = ";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CK_HorizontalSpace:
|
|
|
|
this->Text = " ";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CK_VerticalSpace:
|
|
|
|
this->Text = "\n";
|
|
|
|
break;
|
2009-11-07 03:00:49 +03:00
|
|
|
}
|
2009-09-23 03:15:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
CodeCompletionString::Chunk
|
2009-11-17 19:43:05 +03:00
|
|
|
CodeCompletionString::Chunk::CreateText(StringRef Text) {
|
2009-09-23 03:15:58 +04:00
|
|
|
return Chunk(CK_Text, Text);
|
2009-09-19 02:15:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
CodeCompletionString::Chunk
|
|
|
|
CodeCompletionString::Chunk::CreateOptional(
|
|
|
|
std::auto_ptr<CodeCompletionString> Optional) {
|
|
|
|
Chunk Result;
|
|
|
|
Result.Kind = CK_Optional;
|
|
|
|
Result.Optional = Optional.release();
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
CodeCompletionString::Chunk
|
2009-11-17 19:43:05 +03:00
|
|
|
CodeCompletionString::Chunk::CreatePlaceholder(StringRef Placeholder) {
|
2009-09-23 03:15:58 +04:00
|
|
|
return Chunk(CK_Placeholder, Placeholder);
|
|
|
|
}
|
|
|
|
|
|
|
|
CodeCompletionString::Chunk
|
2009-11-17 19:43:05 +03:00
|
|
|
CodeCompletionString::Chunk::CreateInformative(StringRef Informative) {
|
2009-09-23 03:15:58 +04:00
|
|
|
return Chunk(CK_Informative, Informative);
|
2009-09-19 02:15:54 +04:00
|
|
|
}
|
|
|
|
|
2009-12-18 21:53:37 +03:00
|
|
|
CodeCompletionString::Chunk
|
|
|
|
CodeCompletionString::Chunk::CreateResultType(StringRef ResultType) {
|
|
|
|
return Chunk(CK_ResultType, ResultType);
|
|
|
|
}
|
|
|
|
|
2009-11-07 03:00:49 +03:00
|
|
|
CodeCompletionString::Chunk
|
|
|
|
CodeCompletionString::Chunk::CreateCurrentParameter(
|
2009-11-17 19:43:05 +03:00
|
|
|
StringRef CurrentParameter) {
|
2009-11-07 03:00:49 +03:00
|
|
|
return Chunk(CK_CurrentParameter, CurrentParameter);
|
|
|
|
}
|
|
|
|
|
2009-11-19 03:01:57 +03:00
|
|
|
CodeCompletionString::Chunk CodeCompletionString::Chunk::Clone() const {
|
|
|
|
switch (Kind) {
|
|
|
|
case CK_TypedText:
|
|
|
|
case CK_Text:
|
|
|
|
case CK_Placeholder:
|
|
|
|
case CK_Informative:
|
2009-12-18 21:53:37 +03:00
|
|
|
case CK_ResultType:
|
2009-11-19 03:01:57 +03:00
|
|
|
case CK_CurrentParameter:
|
|
|
|
case CK_LeftParen:
|
|
|
|
case CK_RightParen:
|
|
|
|
case CK_LeftBracket:
|
|
|
|
case CK_RightBracket:
|
|
|
|
case CK_LeftBrace:
|
|
|
|
case CK_RightBrace:
|
|
|
|
case CK_LeftAngle:
|
|
|
|
case CK_RightAngle:
|
|
|
|
case CK_Comma:
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 02:08:15 +03:00
|
|
|
case CK_Colon:
|
|
|
|
case CK_SemiColon:
|
|
|
|
case CK_Equal:
|
|
|
|
case CK_HorizontalSpace:
|
|
|
|
case CK_VerticalSpace:
|
2009-11-19 03:01:57 +03:00
|
|
|
return Chunk(Kind, Text);
|
|
|
|
|
|
|
|
case CK_Optional: {
|
|
|
|
std::auto_ptr<CodeCompletionString> Opt(Optional->Clone());
|
|
|
|
return CreateOptional(Opt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Silence GCC warning.
|
|
|
|
return Chunk();
|
|
|
|
}
|
2009-11-07 03:00:49 +03:00
|
|
|
|
2009-09-19 02:15:54 +04:00
|
|
|
void
|
|
|
|
CodeCompletionString::Chunk::Destroy() {
|
|
|
|
switch (Kind) {
|
2009-09-23 03:15:58 +04:00
|
|
|
case CK_Optional:
|
|
|
|
delete Optional;
|
|
|
|
break;
|
|
|
|
|
2009-11-07 03:00:49 +03:00
|
|
|
case CK_TypedText:
|
2009-09-23 03:15:58 +04:00
|
|
|
case CK_Text:
|
|
|
|
case CK_Placeholder:
|
|
|
|
case CK_Informative:
|
2009-12-18 21:53:37 +03:00
|
|
|
case CK_ResultType:
|
2009-11-07 03:00:49 +03:00
|
|
|
case CK_CurrentParameter:
|
|
|
|
delete [] Text;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CK_LeftParen:
|
|
|
|
case CK_RightParen:
|
|
|
|
case CK_LeftBracket:
|
|
|
|
case CK_RightBracket:
|
|
|
|
case CK_LeftBrace:
|
|
|
|
case CK_RightBrace:
|
|
|
|
case CK_LeftAngle:
|
|
|
|
case CK_RightAngle:
|
|
|
|
case CK_Comma:
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 02:08:15 +03:00
|
|
|
case CK_Colon:
|
|
|
|
case CK_SemiColon:
|
|
|
|
case CK_Equal:
|
|
|
|
case CK_HorizontalSpace:
|
|
|
|
case CK_VerticalSpace:
|
2009-09-23 03:15:58 +04:00
|
|
|
break;
|
2009-09-19 02:15:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-27 02:00:08 +04:00
|
|
|
void CodeCompletionString::clear() {
|
2009-09-19 02:15:54 +04:00
|
|
|
std::for_each(Chunks.begin(), Chunks.end(),
|
|
|
|
std::mem_fun_ref(&Chunk::Destroy));
|
2010-05-27 02:00:08 +04:00
|
|
|
Chunks.clear();
|
2009-09-19 02:15:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string CodeCompletionString::getAsString() const {
|
|
|
|
std::string Result;
|
|
|
|
llvm::raw_string_ostream OS(Result);
|
|
|
|
|
|
|
|
for (iterator C = begin(), CEnd = end(); C != CEnd; ++C) {
|
|
|
|
switch (C->Kind) {
|
|
|
|
case CK_Optional: OS << "{#" << C->Optional->getAsString() << "#}"; break;
|
2009-09-23 03:15:58 +04:00
|
|
|
case CK_Placeholder: OS << "<#" << C->Text << "#>"; break;
|
2009-12-18 21:53:37 +03:00
|
|
|
|
|
|
|
case CK_Informative:
|
|
|
|
case CK_ResultType:
|
|
|
|
OS << "[#" << C->Text << "#]";
|
|
|
|
break;
|
|
|
|
|
2009-11-07 03:00:49 +03:00
|
|
|
case CK_CurrentParameter: OS << "<#" << C->Text << "#>"; break;
|
|
|
|
default: OS << C->Text; break;
|
2009-09-19 02:15:54 +04:00
|
|
|
}
|
|
|
|
}
|
2010-07-27 01:33:22 +04:00
|
|
|
return OS.str();
|
2009-09-19 02:15:54 +04:00
|
|
|
}
|
|
|
|
|
2009-11-19 03:01:57 +03:00
|
|
|
const char *CodeCompletionString::getTypedText() const {
|
|
|
|
for (iterator C = begin(), CEnd = end(); C != CEnd; ++C)
|
|
|
|
if (C->Kind == CK_TypedText)
|
|
|
|
return C->Text;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-08-04 20:47:14 +04:00
|
|
|
CodeCompletionString *
|
|
|
|
CodeCompletionString::Clone(CodeCompletionString *Result) const {
|
|
|
|
if (!Result)
|
|
|
|
Result = new CodeCompletionString;
|
2009-11-19 03:01:57 +03:00
|
|
|
for (iterator C = begin(), CEnd = end(); C != CEnd; ++C)
|
|
|
|
Result->AddChunk(C->Clone());
|
|
|
|
return Result;
|
|
|
|
}
|
2009-11-07 03:00:49 +03:00
|
|
|
|
2009-12-01 08:55:20 +03:00
|
|
|
static void WriteUnsigned(llvm::raw_ostream &OS, unsigned Value) {
|
|
|
|
OS.write((const char *)&Value, sizeof(unsigned));
|
|
|
|
}
|
2009-11-07 03:00:49 +03:00
|
|
|
|
2009-12-01 08:55:20 +03:00
|
|
|
static bool ReadUnsigned(const char *&Memory, const char *MemoryEnd,
|
|
|
|
unsigned &Value) {
|
|
|
|
if (Memory + sizeof(unsigned) > MemoryEnd)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
memmove(&Value, Memory, sizeof(unsigned));
|
|
|
|
Memory += sizeof(unsigned);
|
|
|
|
return false;
|
2009-11-07 03:00:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CodeCompletionString::Serialize(llvm::raw_ostream &OS) const {
|
2009-12-01 08:55:20 +03:00
|
|
|
// Write the number of chunks.
|
|
|
|
WriteUnsigned(OS, size());
|
|
|
|
|
2009-11-07 03:00:49 +03:00
|
|
|
for (iterator C = begin(), CEnd = end(); C != CEnd; ++C) {
|
2009-12-01 08:55:20 +03:00
|
|
|
WriteUnsigned(OS, C->Kind);
|
|
|
|
|
2009-11-07 03:00:49 +03:00
|
|
|
switch (C->Kind) {
|
|
|
|
case CK_TypedText:
|
|
|
|
case CK_Text:
|
|
|
|
case CK_Placeholder:
|
|
|
|
case CK_Informative:
|
2009-12-18 21:53:37 +03:00
|
|
|
case CK_ResultType:
|
2009-12-01 08:55:20 +03:00
|
|
|
case CK_CurrentParameter: {
|
|
|
|
const char *Text = C->Text;
|
|
|
|
unsigned StrLen = strlen(Text);
|
|
|
|
WriteUnsigned(OS, StrLen);
|
|
|
|
OS.write(Text, StrLen);
|
2009-11-07 03:00:49 +03:00
|
|
|
break;
|
2009-12-01 08:55:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
case CK_Optional:
|
|
|
|
C->Optional->Serialize(OS);
|
2009-11-07 03:00:49 +03:00
|
|
|
break;
|
2009-12-01 08:55:20 +03:00
|
|
|
|
2009-11-07 03:00:49 +03:00
|
|
|
case CK_LeftParen:
|
|
|
|
case CK_RightParen:
|
|
|
|
case CK_LeftBracket:
|
|
|
|
case CK_RightBracket:
|
|
|
|
case CK_LeftBrace:
|
|
|
|
case CK_RightBrace:
|
|
|
|
case CK_LeftAngle:
|
|
|
|
case CK_RightAngle:
|
|
|
|
case CK_Comma:
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 02:08:15 +03:00
|
|
|
case CK_Colon:
|
|
|
|
case CK_SemiColon:
|
|
|
|
case CK_Equal:
|
|
|
|
case CK_HorizontalSpace:
|
|
|
|
case CK_VerticalSpace:
|
2009-11-07 03:00:49 +03:00
|
|
|
break;
|
2009-12-01 08:55:20 +03:00
|
|
|
}
|
2009-11-07 03:00:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-27 02:00:08 +04:00
|
|
|
bool CodeCompletionString::Deserialize(const char *&Str, const char *StrEnd) {
|
2009-12-01 08:55:20 +03:00
|
|
|
if (Str == StrEnd || *Str == 0)
|
2010-05-27 02:00:08 +04:00
|
|
|
return false;
|
2009-11-07 03:00:49 +03:00
|
|
|
|
2009-12-01 08:55:20 +03:00
|
|
|
unsigned NumBlocks;
|
|
|
|
if (ReadUnsigned(Str, StrEnd, NumBlocks))
|
2010-05-27 02:00:08 +04:00
|
|
|
return false;
|
2009-12-01 08:55:20 +03:00
|
|
|
|
|
|
|
for (unsigned I = 0; I != NumBlocks; ++I) {
|
|
|
|
if (Str + 1 >= StrEnd)
|
2009-11-07 03:00:49 +03:00
|
|
|
break;
|
2009-12-01 08:55:20 +03:00
|
|
|
|
|
|
|
// Parse the next kind.
|
|
|
|
unsigned KindValue;
|
|
|
|
if (ReadUnsigned(Str, StrEnd, KindValue))
|
2010-05-27 02:00:08 +04:00
|
|
|
return false;
|
2009-12-01 08:55:20 +03:00
|
|
|
|
|
|
|
switch (ChunkKind Kind = (ChunkKind)KindValue) {
|
|
|
|
case CK_TypedText:
|
|
|
|
case CK_Text:
|
|
|
|
case CK_Placeholder:
|
|
|
|
case CK_Informative:
|
2009-12-18 21:53:37 +03:00
|
|
|
case CK_ResultType:
|
2009-12-01 08:55:20 +03:00
|
|
|
case CK_CurrentParameter: {
|
|
|
|
unsigned StrLen;
|
|
|
|
if (ReadUnsigned(Str, StrEnd, StrLen) || (Str + StrLen > StrEnd))
|
2010-05-27 02:00:08 +04:00
|
|
|
return false;
|
2009-12-01 08:55:20 +03:00
|
|
|
|
2010-05-27 02:00:08 +04:00
|
|
|
AddChunk(Chunk(Kind, StringRef(Str, StrLen)));
|
2009-12-01 08:55:20 +03:00
|
|
|
Str += StrLen;
|
2009-11-07 03:00:49 +03:00
|
|
|
break;
|
|
|
|
}
|
2009-12-01 08:55:20 +03:00
|
|
|
|
|
|
|
case CK_Optional: {
|
2010-05-27 02:00:08 +04:00
|
|
|
std::auto_ptr<CodeCompletionString> Optional(new CodeCompletionString());
|
|
|
|
if (Optional->Deserialize(Str, StrEnd))
|
|
|
|
AddOptionalChunk(Optional);
|
2009-12-01 08:55:20 +03:00
|
|
|
break;
|
2009-11-07 03:00:49 +03:00
|
|
|
}
|
2009-12-01 08:55:20 +03:00
|
|
|
|
|
|
|
case CK_LeftParen:
|
|
|
|
case CK_RightParen:
|
|
|
|
case CK_LeftBracket:
|
|
|
|
case CK_RightBracket:
|
|
|
|
case CK_LeftBrace:
|
|
|
|
case CK_RightBrace:
|
|
|
|
case CK_LeftAngle:
|
|
|
|
case CK_RightAngle:
|
|
|
|
case CK_Comma:
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 02:08:15 +03:00
|
|
|
case CK_Colon:
|
|
|
|
case CK_SemiColon:
|
|
|
|
case CK_Equal:
|
|
|
|
case CK_HorizontalSpace:
|
|
|
|
case CK_VerticalSpace:
|
2010-05-27 02:00:08 +04:00
|
|
|
AddChunk(Chunk(Kind));
|
2009-12-01 08:55:20 +03:00
|
|
|
break;
|
2009-11-07 03:00:49 +03:00
|
|
|
}
|
2009-12-01 08:55:20 +03:00
|
|
|
};
|
2009-11-07 03:00:49 +03:00
|
|
|
|
2010-05-27 02:00:08 +04:00
|
|
|
return true;
|
2009-11-07 03:00:49 +03:00
|
|
|
}
|
|
|
|
|
2009-11-19 03:01:57 +03:00
|
|
|
void CodeCompleteConsumer::Result::Destroy() {
|
|
|
|
if (Kind == RK_Pattern) {
|
|
|
|
delete Pattern;
|
|
|
|
Pattern = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-27 02:00:08 +04:00
|
|
|
unsigned CodeCompleteConsumer::Result::getPriorityFromDecl(NamedDecl *ND) {
|
|
|
|
if (!ND)
|
|
|
|
return CCP_Unlikely;
|
|
|
|
|
|
|
|
// Context-based decisions.
|
|
|
|
DeclContext *DC = ND->getDeclContext()->getLookupContext();
|
|
|
|
if (DC->isFunctionOrMethod() || isa<BlockDecl>(DC))
|
|
|
|
return CCP_LocalDeclaration;
|
|
|
|
if (DC->isRecord() || isa<ObjCContainerDecl>(DC))
|
|
|
|
return CCP_MemberDeclaration;
|
|
|
|
|
|
|
|
// Content-based decisions.
|
|
|
|
if (isa<EnumConstantDecl>(ND))
|
|
|
|
return CCP_Constant;
|
|
|
|
if (isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND))
|
|
|
|
return CCP_Type;
|
|
|
|
return CCP_Declaration;
|
|
|
|
}
|
|
|
|
|
2009-09-23 04:16:58 +04:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Code completion overload candidate implementation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
FunctionDecl *
|
|
|
|
CodeCompleteConsumer::OverloadCandidate::getFunction() const {
|
|
|
|
if (getKind() == CK_Function)
|
|
|
|
return Function;
|
|
|
|
else if (getKind() == CK_FunctionTemplate)
|
|
|
|
return FunctionTemplate->getTemplatedDecl();
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const FunctionType *
|
|
|
|
CodeCompleteConsumer::OverloadCandidate::getFunctionType() const {
|
|
|
|
switch (Kind) {
|
|
|
|
case CK_Function:
|
|
|
|
return Function->getType()->getAs<FunctionType>();
|
|
|
|
|
|
|
|
case CK_FunctionTemplate:
|
|
|
|
return FunctionTemplate->getTemplatedDecl()->getType()
|
|
|
|
->getAs<FunctionType>();
|
|
|
|
|
|
|
|
case CK_FunctionType:
|
|
|
|
return Type;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-09-19 02:15:54 +04:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Code completion consumer implementation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-09-21 20:56:56 +04:00
|
|
|
CodeCompleteConsumer::~CodeCompleteConsumer() { }
|
2009-09-19 02:15:54 +04:00
|
|
|
|
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-18 01:32:03 +04:00
|
|
|
void
|
2009-11-13 11:58:20 +03:00
|
|
|
PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef,
|
2010-08-12 01:23:17 +04:00
|
|
|
CodeCompletionContext Context,
|
2009-11-13 11:58:20 +03:00
|
|
|
Result *Results,
|
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-18 01:32:03 +04:00
|
|
|
unsigned NumResults) {
|
|
|
|
// Print the results.
|
|
|
|
for (unsigned I = 0; I != NumResults; ++I) {
|
2009-10-10 02:16:47 +04:00
|
|
|
OS << "COMPLETION: ";
|
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-18 01:32:03 +04:00
|
|
|
switch (Results[I].Kind) {
|
|
|
|
case Result::RK_Declaration:
|
2010-04-17 13:33:03 +04:00
|
|
|
OS << Results[I].Declaration;
|
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-18 01:32:03 +04:00
|
|
|
if (Results[I].Hidden)
|
|
|
|
OS << " (Hidden)";
|
2009-09-21 20:56:56 +04:00
|
|
|
if (CodeCompletionString *CCS
|
|
|
|
= Results[I].CreateCodeCompletionString(SemaRef)) {
|
2009-09-19 02:15:54 +04:00
|
|
|
OS << " : " << CCS->getAsString();
|
|
|
|
delete CCS;
|
|
|
|
}
|
|
|
|
|
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-18 01:32:03 +04:00
|
|
|
OS << '\n';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Result::RK_Keyword:
|
2010-01-14 02:24:38 +03:00
|
|
|
OS << Results[I].Keyword << '\n';
|
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-18 01:32:03 +04:00
|
|
|
break;
|
2009-10-30 19:50:04 +03:00
|
|
|
|
|
|
|
case Result::RK_Macro: {
|
2010-01-14 02:24:38 +03:00
|
|
|
OS << Results[I].Macro->getName();
|
2009-10-30 19:50:04 +03:00
|
|
|
if (CodeCompletionString *CCS
|
2010-01-14 02:24:38 +03:00
|
|
|
= Results[I].CreateCodeCompletionString(SemaRef)) {
|
2009-10-30 19:50:04 +03:00
|
|
|
OS << " : " << CCS->getAsString();
|
|
|
|
delete CCS;
|
|
|
|
}
|
|
|
|
OS << '\n';
|
|
|
|
break;
|
|
|
|
}
|
2009-11-19 03:01:57 +03:00
|
|
|
|
|
|
|
case Result::RK_Pattern: {
|
2010-01-14 02:24:38 +03:00
|
|
|
OS << "Pattern : "
|
2009-11-19 03:01:57 +03:00
|
|
|
<< Results[I].Pattern->getAsString() << '\n';
|
|
|
|
break;
|
|
|
|
}
|
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-18 01:32:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-09-23 04:16:58 +04:00
|
|
|
|
|
|
|
void
|
2009-11-13 11:58:20 +03:00
|
|
|
PrintingCodeCompleteConsumer::ProcessOverloadCandidates(Sema &SemaRef,
|
|
|
|
unsigned CurrentArg,
|
2009-09-23 04:16:58 +04:00
|
|
|
OverloadCandidate *Candidates,
|
|
|
|
unsigned NumCandidates) {
|
|
|
|
for (unsigned I = 0; I != NumCandidates; ++I) {
|
2009-09-23 04:34:09 +04:00
|
|
|
if (CodeCompletionString *CCS
|
|
|
|
= Candidates[I].CreateSignatureString(CurrentArg, SemaRef)) {
|
2009-10-10 02:16:47 +04:00
|
|
|
OS << "OVERLOAD: " << CCS->getAsString() << "\n";
|
2009-09-23 04:34:09 +04:00
|
|
|
delete CCS;
|
2009-09-23 04:16:58 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-11-07 03:00:49 +03:00
|
|
|
|
2010-08-24 03:00:57 +04:00
|
|
|
void CodeCompleteConsumer::Result::computeCursorKindAndAvailability() {
|
2010-08-14 02:48:40 +04:00
|
|
|
switch (Kind) {
|
|
|
|
case RK_Declaration:
|
2010-08-24 03:00:57 +04:00
|
|
|
// Set the availability based on attributes.
|
|
|
|
Availability = CXAvailability_Available;
|
|
|
|
if (Declaration->getAttr<UnavailableAttr>())
|
|
|
|
Availability = CXAvailability_NotAvailable;
|
|
|
|
else if (Declaration->getAttr<DeprecatedAttr>())
|
|
|
|
Availability = CXAvailability_Deprecated;
|
|
|
|
|
2010-08-14 02:48:40 +04:00
|
|
|
switch (Declaration->getKind()) {
|
|
|
|
case Decl::Record:
|
|
|
|
case Decl::CXXRecord:
|
|
|
|
case Decl::ClassTemplateSpecialization: {
|
|
|
|
RecordDecl *Record = cast<RecordDecl>(Declaration);
|
|
|
|
if (Record->isStruct())
|
|
|
|
CursorKind = CXCursor_StructDecl;
|
|
|
|
else if (Record->isUnion())
|
|
|
|
CursorKind = CXCursor_UnionDecl;
|
|
|
|
else
|
|
|
|
CursorKind = CXCursor_ClassDecl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Decl::ObjCMethod: {
|
|
|
|
ObjCMethodDecl *Method = cast<ObjCMethodDecl>(Declaration);
|
|
|
|
if (Method->isInstanceMethod())
|
|
|
|
CursorKind = CXCursor_ObjCInstanceMethodDecl;
|
|
|
|
else
|
|
|
|
CursorKind = CXCursor_ObjCClassMethodDecl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Decl::Typedef:
|
|
|
|
CursorKind = CXCursor_TypedefDecl;
|
|
|
|
break;
|
2009-11-07 03:00:49 +03:00
|
|
|
|
2010-08-14 02:48:40 +04:00
|
|
|
case Decl::Enum:
|
|
|
|
CursorKind = CXCursor_EnumDecl;
|
|
|
|
break;
|
2009-12-01 08:55:20 +03:00
|
|
|
|
2010-08-14 02:48:40 +04:00
|
|
|
case Decl::Field:
|
|
|
|
CursorKind = CXCursor_FieldDecl;
|
|
|
|
break;
|
2009-12-01 08:55:20 +03:00
|
|
|
|
2010-08-14 02:48:40 +04:00
|
|
|
case Decl::EnumConstant:
|
|
|
|
CursorKind = CXCursor_EnumConstantDecl;
|
|
|
|
break;
|
2009-12-01 08:55:20 +03:00
|
|
|
|
2010-08-14 02:48:40 +04:00
|
|
|
case Decl::Function:
|
|
|
|
case Decl::CXXMethod:
|
|
|
|
case Decl::CXXConstructor:
|
|
|
|
case Decl::CXXDestructor:
|
|
|
|
case Decl::CXXConversion:
|
|
|
|
CursorKind = CXCursor_FunctionDecl;
|
2010-08-24 03:00:57 +04:00
|
|
|
if (cast<FunctionDecl>(Declaration)->isDeleted())
|
|
|
|
Availability = CXAvailability_NotAvailable;
|
2010-08-14 02:48:40 +04:00
|
|
|
break;
|
2009-12-01 08:55:20 +03:00
|
|
|
|
2010-08-14 02:48:40 +04:00
|
|
|
case Decl::Var:
|
|
|
|
CursorKind = CXCursor_VarDecl;
|
|
|
|
break;
|
2009-12-01 08:55:20 +03:00
|
|
|
|
2010-08-14 02:48:40 +04:00
|
|
|
case Decl::ParmVar:
|
|
|
|
CursorKind = CXCursor_ParmDecl;
|
|
|
|
break;
|
2009-12-01 08:55:20 +03:00
|
|
|
|
2010-08-14 02:48:40 +04:00
|
|
|
case Decl::ObjCInterface:
|
|
|
|
CursorKind = CXCursor_ObjCInterfaceDecl;
|
|
|
|
break;
|
2009-12-01 08:55:20 +03:00
|
|
|
|
2010-08-14 02:48:40 +04:00
|
|
|
case Decl::ObjCCategory:
|
|
|
|
CursorKind = CXCursor_ObjCCategoryDecl;
|
|
|
|
break;
|
2009-11-19 03:01:57 +03:00
|
|
|
|
2010-08-14 02:48:40 +04:00
|
|
|
case Decl::ObjCProtocol:
|
|
|
|
CursorKind = CXCursor_ObjCProtocolDecl;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Decl::ObjCProperty:
|
|
|
|
CursorKind = CXCursor_ObjCPropertyDecl;
|
|
|
|
break;
|
2009-12-01 08:55:20 +03:00
|
|
|
|
2010-08-14 02:48:40 +04:00
|
|
|
case Decl::ObjCIvar:
|
|
|
|
CursorKind = CXCursor_ObjCIvarDecl;
|
|
|
|
break;
|
2009-12-01 08:55:20 +03:00
|
|
|
|
2010-08-14 02:48:40 +04:00
|
|
|
case Decl::ObjCImplementation:
|
|
|
|
CursorKind = CXCursor_ObjCImplementationDecl;
|
|
|
|
break;
|
2009-12-01 08:55:20 +03:00
|
|
|
|
2010-08-14 02:48:40 +04:00
|
|
|
case Decl::ObjCCategoryImpl:
|
|
|
|
CursorKind = CXCursor_ObjCCategoryImplDecl;
|
|
|
|
break;
|
2009-12-01 08:55:20 +03:00
|
|
|
|
2010-08-14 02:48:40 +04:00
|
|
|
default:
|
|
|
|
CursorKind = CXCursor_NotImplemented;
|
2009-12-01 08:55:20 +03:00
|
|
|
break;
|
2009-11-07 03:00:49 +03:00
|
|
|
}
|
2010-08-14 02:48:40 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Result::RK_Macro:
|
2010-08-24 03:00:57 +04:00
|
|
|
Availability = CXAvailability_Available;
|
2010-08-14 02:48:40 +04:00
|
|
|
CursorKind = CXCursor_MacroDefinition;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Result::RK_Keyword:
|
2010-08-24 03:00:57 +04:00
|
|
|
Availability = CXAvailability_Available;
|
2010-08-14 02:48:40 +04:00
|
|
|
CursorKind = CXCursor_NotImplemented;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Result::RK_Pattern:
|
|
|
|
// Do nothing: Patterns can come with cursor kinds!
|
|
|
|
break;
|
2010-08-04 20:47:14 +04:00
|
|
|
}
|
|
|
|
}
|
2009-12-01 08:55:20 +03:00
|
|
|
|
2010-08-04 20:47:14 +04:00
|
|
|
void
|
|
|
|
CIndexCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef,
|
2010-08-12 01:23:17 +04:00
|
|
|
CodeCompletionContext Context,
|
2010-08-04 20:47:14 +04:00
|
|
|
Result *Results,
|
|
|
|
unsigned NumResults) {
|
|
|
|
// Print the results.
|
|
|
|
for (unsigned I = 0; I != NumResults; ++I) {
|
2010-08-14 02:48:40 +04:00
|
|
|
WriteUnsigned(OS, Results[I].CursorKind);
|
2010-05-27 02:00:08 +04:00
|
|
|
WriteUnsigned(OS, Results[I].Priority);
|
2010-08-24 03:00:57 +04:00
|
|
|
WriteUnsigned(OS, Results[I].Availability);
|
2009-12-01 08:55:20 +03:00
|
|
|
CodeCompletionString *CCS = Results[I].CreateCodeCompletionString(SemaRef);
|
|
|
|
assert(CCS && "No code-completion string?");
|
|
|
|
CCS->Serialize(OS);
|
|
|
|
delete CCS;
|
2009-11-07 03:00:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-11-13 11:58:20 +03:00
|
|
|
CIndexCodeCompleteConsumer::ProcessOverloadCandidates(Sema &SemaRef,
|
|
|
|
unsigned CurrentArg,
|
2009-11-07 03:00:49 +03:00
|
|
|
OverloadCandidate *Candidates,
|
|
|
|
unsigned NumCandidates) {
|
|
|
|
for (unsigned I = 0; I != NumCandidates; ++I) {
|
2009-12-01 08:55:20 +03:00
|
|
|
WriteUnsigned(OS, CXCursor_NotImplemented);
|
2010-05-27 02:00:08 +04:00
|
|
|
WriteUnsigned(OS, /*Priority=*/0);
|
2010-08-24 03:00:57 +04:00
|
|
|
WriteUnsigned(OS, /*Availability=*/CXAvailability_Available);
|
2009-12-01 08:55:20 +03:00
|
|
|
CodeCompletionString *CCS
|
|
|
|
= Candidates[I].CreateSignatureString(CurrentArg, SemaRef);
|
|
|
|
assert(CCS && "No code-completion string?");
|
|
|
|
CCS->Serialize(OS);
|
|
|
|
delete CCS;
|
2009-11-07 03:00:49 +03:00
|
|
|
}
|
|
|
|
}
|