[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:
Xi Ge
2016-03-23 17:25:53 -07:00
parent 41efb3d4d3
commit fda0751cae
20 changed files with 110 additions and 13 deletions

View File

@@ -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;