mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[sourcekit] Tweak traced operation to be single-operator per RAII object
This is how it was used in all but one place anyway, and makes it easier to understand. It also aligns better with some further refactoring I want to do...
This commit is contained in:
@@ -1230,12 +1230,12 @@ static void resolveCursor(SwiftLangSupport &Lang,
|
||||
return;
|
||||
}
|
||||
|
||||
trace::TracedOperation TracedOp;
|
||||
trace::TracedOperation TracedOp(trace::OperationKind::CursorInfoForSource);
|
||||
if (trace::enabled()) {
|
||||
trace::SwiftInvocation SwiftArgs;
|
||||
ASTInvok->raw(SwiftArgs.Args.Args, SwiftArgs.Args.PrimaryFile);
|
||||
trace::initTraceFiles(SwiftArgs, CompIns);
|
||||
TracedOp.start(trace::OperationKind::CursorInfoForSource, SwiftArgs,
|
||||
TracedOp.start(SwiftArgs,
|
||||
{std::make_pair("Offset", std::to_string(Offset))});
|
||||
}
|
||||
|
||||
@@ -1424,12 +1424,12 @@ static void resolveName(SwiftLangSupport &Lang, StringRef InputFile,
|
||||
return;
|
||||
}
|
||||
|
||||
trace::TracedOperation TracedOp;
|
||||
trace::TracedOperation TracedOp(trace::OperationKind::CursorInfoForSource);
|
||||
if (trace::enabled()) {
|
||||
trace::SwiftInvocation SwiftArgs;
|
||||
ASTInvok->raw(SwiftArgs.Args.Args, SwiftArgs.Args.PrimaryFile);
|
||||
trace::initTraceFiles(SwiftArgs, CompIns);
|
||||
TracedOp.start(trace::OperationKind::CursorInfoForSource, SwiftArgs,
|
||||
TracedOp.start(SwiftArgs,
|
||||
{std::make_pair("Offset", std::to_string(Offset))});
|
||||
}
|
||||
|
||||
@@ -1584,7 +1584,7 @@ void SwiftLangSupport::getCursorInfo(
|
||||
std::function<void(const CursorInfoData &)> Receiver) {
|
||||
|
||||
if (auto IFaceGenRef = IFaceGenContexts.get(InputFile)) {
|
||||
trace::TracedOperation TracedOp;
|
||||
trace::TracedOperation TracedOp(trace::OperationKind::CursorInfoForIFaceGen);
|
||||
if (trace::enabled()) {
|
||||
trace::SwiftInvocation SwiftArgs;
|
||||
trace::initTraceInfo(SwiftArgs, InputFile, Args);
|
||||
@@ -1593,8 +1593,7 @@ void SwiftLangSupport::getCursorInfo(
|
||||
std::make_pair("DocumentName", IFaceGenRef->getDocumentName()),
|
||||
std::make_pair("ModuleOrHeaderName", IFaceGenRef->getModuleOrHeaderName()),
|
||||
std::make_pair("Offset", std::to_string(Offset))};
|
||||
TracedOp.start(trace::OperationKind::CursorInfoForIFaceGen,
|
||||
SwiftArgs, OpArgs);
|
||||
TracedOp.start(SwiftArgs, OpArgs);
|
||||
}
|
||||
|
||||
IFaceGenRef->accessASTAsync([this, IFaceGenRef, Offset, Actionables, Receiver] {
|
||||
@@ -1666,7 +1665,7 @@ getNameInfo(StringRef InputFile, unsigned Offset, NameTranslatingInfo &Input,
|
||||
std::function<void(const NameTranslatingInfo &)> Receiver) {
|
||||
|
||||
if (auto IFaceGenRef = IFaceGenContexts.get(InputFile)) {
|
||||
trace::TracedOperation TracedOp;
|
||||
trace::TracedOperation TracedOp(trace::OperationKind::CursorInfoForIFaceGen);
|
||||
if (trace::enabled()) {
|
||||
trace::SwiftInvocation SwiftArgs;
|
||||
trace::initTraceInfo(SwiftArgs, InputFile, Args);
|
||||
@@ -1675,8 +1674,7 @@ getNameInfo(StringRef InputFile, unsigned Offset, NameTranslatingInfo &Input,
|
||||
std::make_pair("DocumentName", IFaceGenRef->getDocumentName()),
|
||||
std::make_pair("ModuleOrHeaderName", IFaceGenRef->getModuleOrHeaderName()),
|
||||
std::make_pair("Offset", std::to_string(Offset))};
|
||||
TracedOp.start(trace::OperationKind::CursorInfoForIFaceGen,
|
||||
SwiftArgs, OpArgs);
|
||||
TracedOp.start(SwiftArgs, OpArgs);
|
||||
}
|
||||
|
||||
IFaceGenRef->accessASTAsync([IFaceGenRef, Offset, Input, Receiver] {
|
||||
@@ -1762,13 +1760,12 @@ resolveCursorFromUSR(SwiftLangSupport &Lang, StringRef InputFile, StringRef USR,
|
||||
unsigned BufferID =
|
||||
AstUnit->getPrimarySourceFile().getBufferID().getValue();
|
||||
|
||||
trace::TracedOperation TracedOp;
|
||||
trace::TracedOperation TracedOp(trace::OperationKind::CursorInfoForSource);
|
||||
if (trace::enabled()) {
|
||||
trace::SwiftInvocation SwiftArgs;
|
||||
ASTInvok->raw(SwiftArgs.Args.Args, SwiftArgs.Args.PrimaryFile);
|
||||
trace::initTraceFiles(SwiftArgs, CompIns);
|
||||
TracedOp.start(trace::OperationKind::CursorInfoForSource, SwiftArgs,
|
||||
{std::make_pair("USR", USR)});
|
||||
TracedOp.start(SwiftArgs, {std::make_pair("USR", USR)});
|
||||
}
|
||||
|
||||
if (USR.startswith("c:")) {
|
||||
@@ -1956,16 +1953,16 @@ void SwiftLangSupport::findRelatedIdentifiersInFile(
|
||||
auto &CompInst = AstUnit->getCompilerInstance();
|
||||
auto &SrcFile = AstUnit->getPrimarySourceFile();
|
||||
|
||||
trace::TracedOperation TracedOp;
|
||||
|
||||
SmallVector<std::pair<unsigned, unsigned>, 8> Ranges;
|
||||
|
||||
auto Action = [&]() {
|
||||
trace::TracedOperation TracedOp(trace::OperationKind::RelatedIdents);
|
||||
if (trace::enabled()) {
|
||||
trace::SwiftInvocation SwiftArgs;
|
||||
Invok->raw(SwiftArgs.Args.Args, SwiftArgs.Args.PrimaryFile);
|
||||
trace::initTraceFiles(SwiftArgs, CompInst);
|
||||
TracedOp.start(trace::OperationKind::RelatedIdents, SwiftArgs,
|
||||
TracedOp.start(SwiftArgs,
|
||||
{std::make_pair("Offset", std::to_string(Offset))});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user