|
12 | 12 |
|
13 | 13 | #include "SwiftASTManager.h"
|
14 | 14 | #include "SwiftLangSupport.h"
|
| 15 | +#include "SwiftEditorDiagConsumer.h" |
15 | 16 | #include "swift/Frontend/Frontend.h"
|
16 | 17 | #include "swift/Frontend/PrintingDiagnosticConsumer.h"
|
17 | 18 | #include "swift/IDE/TypeContextInfo.h"
|
@@ -54,13 +55,30 @@ static bool swiftTypeContextInfoImpl(SwiftLangSupport &Lang,
|
54 | 55 | auto bufferIdentifier =
|
55 | 56 | Lang.resolvePathSymlinks(UnresolvedInputFile->getBufferIdentifier());
|
56 | 57 |
|
| 58 | + auto origOffset = Offset; |
57 | 59 | auto newBuffer = makeCodeCompletionMemoryBuffer(UnresolvedInputFile, Offset,
|
58 | 60 | bufferIdentifier);
|
59 | 61 |
|
60 | 62 | CompilerInstance CI;
|
61 | 63 | PrintingDiagnosticConsumer PrintDiags;
|
62 | 64 | CI.addDiagnosticConsumer(&PrintDiags);
|
63 | 65 |
|
| 66 | + EditorDiagConsumer TraceDiags; |
| 67 | + trace::TracedOperation TracedOp(trace::OperationKind::CodeCompletion); |
| 68 | + if (TracedOp.enabled()) { |
| 69 | + CI.addDiagnosticConsumer(&TraceDiags); |
| 70 | + trace::SwiftInvocation SwiftArgs; |
| 71 | + trace::initTraceInfo(SwiftArgs, bufferIdentifier, Args); |
| 72 | + TracedOp.setDiagnosticProvider( |
| 73 | + [&TraceDiags](SmallVectorImpl<DiagnosticEntryInfo> &diags) { |
| 74 | + TraceDiags.getAllDiagnostics(diags); |
| 75 | + }); |
| 76 | + TracedOp.start( |
| 77 | + SwiftArgs, |
| 78 | + {std::make_pair("OriginalOffset", std::to_string(origOffset)), |
| 79 | + std::make_pair("Offset", std::to_string(Offset))}); |
| 80 | + } |
| 81 | + |
64 | 82 | CompilerInvocation Invocation;
|
65 | 83 | bool Failed = Lang.getASTManager()->initCompilerInvocation(
|
66 | 84 | Invocation, Args, CI.getDiags(), bufferIdentifier, Error);
|
|
0 commit comments