mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SourceKit] In interface-gen request, allow clients to send SourceKit an interested USR from which we can infer the group name.
This commit is contained in:
@@ -275,7 +275,8 @@ static bool getModuleInterfaceInfo(ASTContext &Ctx,
|
||||
Optional<StringRef> Group,
|
||||
SwiftInterfaceGenContext::Implementation &Impl,
|
||||
std::string &ErrMsg,
|
||||
bool SynthesizedExtensions) {
|
||||
bool SynthesizedExtensions,
|
||||
Optional<StringRef> InterestedUSR) {
|
||||
Module *&Mod = Impl.Mod;
|
||||
SourceTextInfo &Info = Impl.Info;
|
||||
|
||||
@@ -316,6 +317,9 @@ static bool getModuleInterfaceInfo(ASTContext &Ctx,
|
||||
SmallString<128> Text;
|
||||
llvm::raw_svector_ostream OS(Text);
|
||||
AnnotatingPrinter Printer(Info, OS);
|
||||
if (!Group && InterestedUSR) {
|
||||
Group = findGroupNameForUSR(Mod, InterestedUSR.getValue());
|
||||
}
|
||||
printSubmoduleInterface(Mod, SplitModuleName,
|
||||
Group.hasValue() ? llvm::makeArrayRef(Group.getValue()) : ArrayRef<StringRef>(),
|
||||
TraversalOptions,
|
||||
@@ -376,7 +380,8 @@ SwiftInterfaceGenContext::create(StringRef DocumentName,
|
||||
Optional<StringRef> Group,
|
||||
CompilerInvocation Invocation,
|
||||
std::string &ErrMsg,
|
||||
bool SynthesizedExtensions) {
|
||||
bool SynthesizedExtensions,
|
||||
Optional<StringRef> InterestedUSR) {
|
||||
SwiftInterfaceGenContextRef IFaceGenCtx{ new SwiftInterfaceGenContext() };
|
||||
IFaceGenCtx->Impl.DocumentName = DocumentName;
|
||||
IFaceGenCtx->Impl.IsModule = IsModule;
|
||||
@@ -405,7 +410,7 @@ SwiftInterfaceGenContext::create(StringRef DocumentName,
|
||||
|
||||
if (IsModule) {
|
||||
if (getModuleInterfaceInfo(Ctx, ModuleOrHeaderName, Group, IFaceGenCtx->Impl,
|
||||
ErrMsg, SynthesizedExtensions))
|
||||
ErrMsg, SynthesizedExtensions, InterestedUSR))
|
||||
return nullptr;
|
||||
} else {
|
||||
auto &FEOpts = Invocation.getFrontendOptions();
|
||||
@@ -585,7 +590,8 @@ void SwiftLangSupport::editorOpenInterface(EditorConsumer &Consumer,
|
||||
StringRef ModuleName,
|
||||
Optional<StringRef> Group,
|
||||
ArrayRef<const char *> Args,
|
||||
bool SynthesizedExtensions) {
|
||||
bool SynthesizedExtensions,
|
||||
Optional<StringRef> InterestedUSR) {
|
||||
CompilerInstance CI;
|
||||
// Display diagnostics to stderr.
|
||||
PrintingDiagnosticConsumer PrintDiags;
|
||||
@@ -619,7 +625,8 @@ void SwiftLangSupport::editorOpenInterface(EditorConsumer &Consumer,
|
||||
Group,
|
||||
Invocation,
|
||||
ErrMsg,
|
||||
SynthesizedExtensions);
|
||||
SynthesizedExtensions,
|
||||
InterestedUSR);
|
||||
if (!IFaceGenRef) {
|
||||
Consumer.handleRequestError(ErrMsg.c_str());
|
||||
return;
|
||||
@@ -725,7 +732,8 @@ void SwiftLangSupport::editorOpenHeaderInterface(EditorConsumer &Consumer,
|
||||
None,
|
||||
Invocation,
|
||||
Error,
|
||||
SynthesizedExtensions);
|
||||
SynthesizedExtensions,
|
||||
None);
|
||||
if (!IFaceGenRef) {
|
||||
Consumer.handleRequestError(Error.c_str());
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user