[SourceKit] Add option for returning fully qualified types in variable type request

This commit is contained in:
Sam Kortekaas
2022-09-27 11:56:54 +02:00
parent 0efc3ea745
commit 1bd0d9753e
8 changed files with 46 additions and 18 deletions

View File

@@ -2591,7 +2591,8 @@ void SwiftLangSupport::collectExpressionTypes(
void SwiftLangSupport::collectVariableTypes(
StringRef FileName, ArrayRef<const char *> Args, Optional<unsigned> Offset,
Optional<unsigned> Length, SourceKitCancellationToken CancellationToken,
Optional<unsigned> Length, bool FullyQualified,
SourceKitCancellationToken CancellationToken,
std::function<void(const RequestResult<VariableTypesInFile> &)> Receiver) {
std::string Error;
SwiftInvocationRef Invok =
@@ -2608,13 +2609,16 @@ void SwiftLangSupport::collectVariableTypes(
std::function<void(const RequestResult<VariableTypesInFile> &)> Receiver;
Optional<unsigned> Offset;
Optional<unsigned> Length;
bool FullyQualified;
public:
VariableTypeCollectorASTConsumer(
std::function<void(const RequestResult<VariableTypesInFile> &)>
Receiver,
Optional<unsigned> Offset, Optional<unsigned> Length)
: Receiver(std::move(Receiver)), Offset(Offset), Length(Length) {}
Optional<unsigned> Offset, Optional<unsigned> Length,
bool FullyQualified)
: Receiver(std::move(Receiver)), Offset(Offset), Length(Length),
FullyQualified(FullyQualified) {}
void handlePrimaryAST(ASTUnitRef AstUnit) override {
auto &CompInst = AstUnit->getCompilerInstance();
@@ -2638,7 +2642,7 @@ void SwiftLangSupport::collectVariableTypes(
llvm::raw_string_ostream OS(TypeBuffer);
VariableTypesInFile Result;
collectVariableType(*SF, Range, Infos, OS);
collectVariableType(*SF, Range, FullyQualified, Infos, OS);
for (auto Info : Infos) {
Result.Results.push_back({Info.Offset, Info.Length, Info.TypeOffset, Info.HasExplicitType});
@@ -2657,7 +2661,7 @@ void SwiftLangSupport::collectVariableTypes(
};
auto Collector = std::make_shared<VariableTypeCollectorASTConsumer>(
Receiver, Offset, Length);
Receiver, Offset, Length, FullyQualified);
/// FIXME: When request cancellation is implemented and Xcode adopts it,
/// don't use 'OncePerASTToken'.
static const char OncePerASTToken = 0;