diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-10-11 22:12:15 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-10-11 22:12:15 +0000 |
commit | a9f4f620daf073805b89e893afcdc5eb7a9bdc50 (patch) | |
tree | ebccf89549cf75188b5af2a7e3e5947cf491194f /lib/Sema/CodeCompleteConsumer.cpp | |
parent | d3ab63e0f66429abf2a3e4cde889e420e41e8790 (diff) |
Eliminate the (de-)serialization of code completion results, now that
libclang does not support out-of-process code completion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116253 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/CodeCompleteConsumer.cpp')
-rw-r--r-- | lib/Sema/CodeCompleteConsumer.cpp | 154 |
1 files changed, 0 insertions, 154 deletions
diff --git a/lib/Sema/CodeCompleteConsumer.cpp b/lib/Sema/CodeCompleteConsumer.cpp index 5c95324f4e..ee6fb3bf0e 100644 --- a/lib/Sema/CodeCompleteConsumer.cpp +++ b/lib/Sema/CodeCompleteConsumer.cpp @@ -297,126 +297,6 @@ CodeCompletionString::Clone(CodeCompletionString *Result) const { return Result; } -static void WriteUnsigned(llvm::raw_ostream &OS, unsigned Value) { - OS.write((const char *)&Value, sizeof(unsigned)); -} - -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; -} - -void CodeCompletionString::Serialize(llvm::raw_ostream &OS) const { - // Write the number of chunks. - WriteUnsigned(OS, size()); - - for (iterator C = begin(), CEnd = end(); C != CEnd; ++C) { - WriteUnsigned(OS, C->Kind); - - switch (C->Kind) { - case CK_TypedText: - case CK_Text: - case CK_Placeholder: - case CK_Informative: - case CK_ResultType: - case CK_CurrentParameter: { - const char *Text = C->Text; - unsigned StrLen = strlen(Text); - WriteUnsigned(OS, StrLen); - OS.write(Text, StrLen); - break; - } - - case CK_Optional: - C->Optional->Serialize(OS); - 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: - case CK_Colon: - case CK_SemiColon: - case CK_Equal: - case CK_HorizontalSpace: - case CK_VerticalSpace: - break; - } - } -} - -bool CodeCompletionString::Deserialize(const char *&Str, const char *StrEnd) { - if (Str == StrEnd || *Str == 0) - return false; - - unsigned NumBlocks; - if (ReadUnsigned(Str, StrEnd, NumBlocks)) - return false; - - for (unsigned I = 0; I != NumBlocks; ++I) { - if (Str + 1 >= StrEnd) - break; - - // Parse the next kind. - unsigned KindValue; - if (ReadUnsigned(Str, StrEnd, KindValue)) - return false; - - switch (ChunkKind Kind = (ChunkKind)KindValue) { - case CK_TypedText: - case CK_Text: - case CK_Placeholder: - case CK_Informative: - case CK_ResultType: - case CK_CurrentParameter: { - unsigned StrLen; - if (ReadUnsigned(Str, StrEnd, StrLen) || (Str + StrLen > StrEnd)) - return false; - - AddChunk(Chunk(Kind, StringRef(Str, StrLen))); - Str += StrLen; - break; - } - - case CK_Optional: { - std::auto_ptr<CodeCompletionString> Optional(new CodeCompletionString()); - if (Optional->Deserialize(Str, StrEnd)) - AddOptionalChunk(Optional); - 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: - case CK_Colon: - case CK_SemiColon: - case CK_Equal: - case CK_HorizontalSpace: - case CK_VerticalSpace: - AddChunk(Chunk(Kind)); - break; - } - }; - - return true; -} - void CodeCompletionResult::Destroy() { if (Kind == RK_Pattern) { delete Pattern; @@ -636,37 +516,3 @@ bool clang::operator<(const CodeCompletionResult &X, return false; } - -void -CIndexCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef, - CodeCompletionContext Context, - CodeCompletionResult *Results, - unsigned NumResults) { - // Print the results. - for (unsigned I = 0; I != NumResults; ++I) { - WriteUnsigned(OS, Results[I].CursorKind); - WriteUnsigned(OS, Results[I].Priority); - WriteUnsigned(OS, Results[I].Availability); - CodeCompletionString *CCS = Results[I].CreateCodeCompletionString(SemaRef); - assert(CCS && "No code-completion string?"); - CCS->Serialize(OS); - delete CCS; - } -} - -void -CIndexCodeCompleteConsumer::ProcessOverloadCandidates(Sema &SemaRef, - unsigned CurrentArg, - OverloadCandidate *Candidates, - unsigned NumCandidates) { - for (unsigned I = 0; I != NumCandidates; ++I) { - WriteUnsigned(OS, CXCursor_NotImplemented); - WriteUnsigned(OS, /*Priority=*/I); - WriteUnsigned(OS, /*Availability=*/CXAvailability_Available); - CodeCompletionString *CCS - = Candidates[I].CreateSignatureString(CurrentArg, SemaRef); - assert(CCS && "No code-completion string?"); - CCS->Serialize(OS); - delete CCS; - } -} |