@@ -1023,6 +1023,7 @@ struct SemaCompleteInput {
1023
1023
PathRef FileName;
1024
1024
const tooling::CompileCommand &Command;
1025
1025
const PreambleData &Preamble;
1026
+ const PreamblePatch &Patch;
1026
1027
llvm::StringRef Contents;
1027
1028
size_t Offset;
1028
1029
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS;
@@ -1060,7 +1061,6 @@ bool semaCodeComplete(std::unique_ptr<CodeCompleteConsumer> Consumer,
1060
1061
ParseInput.CompileCommand = Input.Command ;
1061
1062
ParseInput.FS = VFS;
1062
1063
ParseInput.Contents = std::string (Input.Contents );
1063
- ParseInput.Opts = ParseOptions ();
1064
1064
1065
1065
IgnoreDiagnostics IgnoreDiags;
1066
1066
auto CI = buildCompilerInvocation (ParseInput, IgnoreDiags);
@@ -1096,6 +1096,7 @@ bool semaCodeComplete(std::unique_ptr<CodeCompleteConsumer> Consumer,
1096
1096
PreambleBounds PreambleRegion =
1097
1097
ComputePreambleBounds (*CI->getLangOpts (), ContentsBuffer.get (), 0 );
1098
1098
bool CompletingInPreamble = PreambleRegion.Size > Input.Offset ;
1099
+ Input.Patch .apply (*CI);
1099
1100
// NOTE: we must call BeginSourceFile after prepareCompilerInstance. Otherwise
1100
1101
// the remapped buffers do not get freed.
1101
1102
auto Clang = prepareCompilerInstance (
@@ -1754,8 +1755,10 @@ codeComplete(PathRef FileName, const tooling::CompileCommand &Command,
1754
1755
SpecFuzzyFind, Opts);
1755
1756
return (!Preamble || Opts.RunParser == CodeCompleteOptions::NeverParse)
1756
1757
? std::move (Flow).runWithoutSema (Contents, *Offset, VFS)
1757
- : std::move (Flow).run (
1758
- {FileName, Command, *Preamble, Contents, *Offset, VFS});
1758
+ : std::move (Flow).run ({FileName, Command, *Preamble,
1759
+ // We want to serve code completions with
1760
+ // low latency, so don't bother patching.
1761
+ PreamblePatch (), Contents, *Offset, VFS});
1759
1762
}
1760
1763
1761
1764
SignatureHelp signatureHelp (PathRef FileName,
@@ -1775,10 +1778,15 @@ SignatureHelp signatureHelp(PathRef FileName,
1775
1778
Options.IncludeMacros = false ;
1776
1779
Options.IncludeCodePatterns = false ;
1777
1780
Options.IncludeBriefComments = false ;
1778
- IncludeStructure PreambleInclusions; // Unused for signatureHelp
1781
+
1782
+ ParseInputs PI;
1783
+ PI.CompileCommand = Command;
1784
+ PI.Contents = Contents.str ();
1785
+ PI.FS = std::move (VFS);
1786
+ auto PP = PreamblePatch::create (FileName, PI, Preamble);
1779
1787
semaCodeComplete (
1780
1788
std::make_unique<SignatureHelpCollector>(Options, Index, Result), Options,
1781
- {FileName, Command, Preamble, Contents, *Offset, std::move (VFS )});
1789
+ {FileName, Command, Preamble, PP, Contents, *Offset, std::move (PI. FS )});
1782
1790
return Result;
1783
1791
}
1784
1792
0 commit comments