]> granicus.if.org Git - clang/commitdiff
Eliminate the (de-)serialization of code completion results, now that
authorDouglas Gregor <dgregor@apple.com>
Mon, 11 Oct 2010 22:12:15 +0000 (22:12 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 11 Oct 2010 22:12:15 +0000 (22:12 +0000)
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

include/clang/Driver/CC1Options.td
include/clang/Frontend/CompilerInstance.h
include/clang/Frontend/FrontendOptions.h
include/clang/Sema/CodeCompleteConsumer.h
lib/Frontend/CompilerInstance.cpp
lib/Frontend/CompilerInvocation.cpp
lib/Sema/CodeCompleteConsumer.cpp

index aad7d95ad2d104b329dbbf1b3505eeaeec37373f..f08b8015427db1df12bf99adb073cc9d0487488c 100644 (file)
@@ -267,8 +267,6 @@ def remap_file : Separate<"-remap-file">,
   HelpText<"Replace the contents of the <from> file with the contents of the <to> file">;
 def code_completion_at_EQ : Joined<"-code-completion-at=">,
   Alias<code_completion_at>;
-def no_code_completion_debug_printer : Flag<"-no-code-completion-debug-printer">,
-  HelpText<"Don't use the \"debug\" code-completion print">;
 def code_completion_macros : Flag<"-code-completion-macros">,
   HelpText<"Include macros in code-completion results">;
 def code_completion_patterns : Flag<"-code-completion-patterns">,
index 410129ab7a4beda6510519bff7050899e1e94970..e5121e1bf9d1295ac6c4a980590ad9b09f7d4f8d 100644 (file)
@@ -548,7 +548,7 @@ public:
   static CodeCompleteConsumer *
   createCodeCompletionConsumer(Preprocessor &PP, const std::string &Filename,
                                unsigned Line, unsigned Column,
-                               bool UseDebugPrinter, bool ShowMacros,
+                               bool ShowMacros,
                                bool ShowCodePatterns, bool ShowGlobals,
                                llvm::raw_ostream &OS);
 
index 4c16d084fc0dd6a9312d1ec2fced81b810b7b188..b68e9913a6c67f7638eea68420383f6f7fd97eba 100644 (file)
@@ -56,8 +56,6 @@ namespace frontend {
 /// FrontendOptions - Options for controlling the behavior of the frontend.
 class FrontendOptions {
 public:
-  unsigned DebugCodeCompletionPrinter : 1; ///< Use the debug printer for code
-                                           /// completion results.
   unsigned DisableFree : 1;                ///< Disable memory freeing on exit.
   unsigned RelocatablePCH : 1;             ///< When generating PCH files,
                                            /// instruct the AST writer to create
@@ -119,7 +117,6 @@ public:
 
 public:
   FrontendOptions() {
-    DebugCodeCompletionPrinter = 1;
     DisableFree = 0;
     ProgramAction = frontend::ParseSyntaxOnly;
     ActionName = "";
index d607ab149bd0c22150dcc596d6bbd3624fb524a7..c32007115edb773e6db5ee99c6c51e18229e4be2 100644 (file)
@@ -465,14 +465,6 @@ public:
   /// \param Result If non-NULL, points to an empty code-completion
   /// result that will be given a cloned copy of
   CodeCompletionString *Clone(CodeCompletionString *Result = 0) const;
-  
-  /// \brief Serialize this code-completion string to the given stream.
-  void Serialize(llvm::raw_ostream &OS) const;
-  
-  /// \brief Deserialize a code-completion string from the given string.
-  ///
-  /// \returns true if successful, false otherwise.
-  bool Deserialize(const char *&Str, const char *StrEnd);
 };
 
 /// \brief Captures a result of code completion.
@@ -797,32 +789,6 @@ public:
                                          unsigned NumCandidates);  
 };
   
-/// \brief A code-completion consumer that prints the results it receives
-/// in a format that is parsable by the CIndex library.
-class CIndexCodeCompleteConsumer : public CodeCompleteConsumer {
-  /// \brief The raw output stream.
-  llvm::raw_ostream &OS;
-  
-public:
-  /// \brief Create a new CIndex code-completion consumer that prints its
-  /// results to the given raw output stream in a format readable to the CIndex
-  /// library.
-  CIndexCodeCompleteConsumer(bool IncludeMacros, bool IncludeCodePatterns,
-                             bool IncludeGlobals, llvm::raw_ostream &OS)
-    : CodeCompleteConsumer(IncludeMacros, IncludeCodePatterns, IncludeGlobals,
-                           true), OS(OS) {}
-  
-  /// \brief Prints the finalized code-completion results.
-  virtual void ProcessCodeCompleteResults(Sema &S, 
-                                          CodeCompletionContext Context,
-                                          CodeCompletionResult *Results,
-                                          unsigned NumResults);
-  
-  virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
-                                         OverloadCandidate *Candidates,
-                                         unsigned NumCandidates);  
-};
-
 } // end namespace clang
 
 #endif // LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
index 44e5fd2215ca1227bf1c4e6581f702955892fb3e..2777e4dae4833bfdf7d4135f8baf9ccc2b240cff 100644 (file)
@@ -289,7 +289,6 @@ void CompilerInstance::createCodeCompletionConsumer() {
     CompletionConsumer.reset(
       createCodeCompletionConsumer(getPreprocessor(),
                                    Loc.FileName, Loc.Line, Loc.Column,
-                                   getFrontendOpts().DebugCodeCompletionPrinter,
                                    getFrontendOpts().ShowMacrosInCodeCompletion,
                              getFrontendOpts().ShowCodePatternsInCodeCompletion,
                            getFrontendOpts().ShowGlobalSymbolsInCodeCompletion,
@@ -318,7 +317,6 @@ CompilerInstance::createCodeCompletionConsumer(Preprocessor &PP,
                                                const std::string &Filename,
                                                unsigned Line,
                                                unsigned Column,
-                                               bool UseDebugPrinter,
                                                bool ShowMacros,
                                                bool ShowCodePatterns,
                                                bool ShowGlobals,
@@ -327,11 +325,7 @@ CompilerInstance::createCodeCompletionConsumer(Preprocessor &PP,
     return 0;
 
   // Set up the creation routine for code-completion.
-  if (UseDebugPrinter)
-    return new PrintingCodeCompleteConsumer(ShowMacros, ShowCodePatterns, 
-                                            ShowGlobals, OS);
-  else
-    return new CIndexCodeCompleteConsumer(ShowMacros, ShowCodePatterns, 
+  return new PrintingCodeCompleteConsumer(ShowMacros, ShowCodePatterns, 
                                           ShowGlobals, OS);
 }
 
index b4bb61327fc62f047693e02aea447f10d9eabe10..e3ba54cd3904ee253d1201e522f9e24803c6765b 100644 (file)
@@ -353,8 +353,6 @@ static const char *getActionName(frontend::ActionKind Kind) {
 
 static void FrontendOptsToArgs(const FrontendOptions &Opts,
                                std::vector<std::string> &Res) {
-  if (!Opts.DebugCodeCompletionPrinter)
-    Res.push_back("-no-code-completion-debug-printer");
   if (Opts.DisableFree)
     Res.push_back("-disable-free");
   if (Opts.RelocatablePCH)
@@ -1067,8 +1065,6 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
       Diags.Report(diag::err_drv_invalid_value)
         << A->getAsString(Args) << A->getValue(Args);
   }
-  Opts.DebugCodeCompletionPrinter =
-    !Args.hasArg(OPT_no_code_completion_debug_printer);
   Opts.DisableFree = Args.hasArg(OPT_disable_free);
 
   Opts.OutputFile = Args.getLastArgValue(OPT_o);
index 5c95324f4eba310db62b4ee1f859b0a798dc884a..ee6fb3bf0e194fe7cb7f29356863de96394ba8a0 100644 (file)
@@ -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;
-  }
-}