[libIDE] Refactor type-interface APIs. (#3537)

This commit is contained in:
Xi Ge
2016-07-15 15:59:22 -07:00
committed by GitHub
parent 18406900ba
commit 17e49422e7
5 changed files with 51 additions and 46 deletions

View File

@@ -147,6 +147,29 @@ getUnderlyingClangModuleForImport(ImportDecl *Import) {
return nullptr;
}
bool swift::ide::
printTypeInterface(ModuleDecl *M, Type Ty, ASTPrinter &Printer,
std::string &Error) {
if (!Ty)
return false;
Ty = Ty->getRValueType();
if (auto ND = Ty->getNominalOrBoundGenericNominal()) {
PrintOptions Options = PrintOptions::printTypeInterface(Ty.getPointer(), M);
ND->print(Printer, Options);
return true;
}
Error = "cannot find declaration of type.";
return false;
}
bool swift::ide::
printTypeInterface(ModuleDecl *M, StringRef TypeUSR, ASTPrinter &Printer,
std::string &Error) {
return printTypeInterface(M, getTypeFromMangledSymbolname(M->getASTContext(),
TypeUSR, Error),
Printer, Error);
}
void swift::ide::printModuleInterface(Module *M, Optional<StringRef> Group,
ModuleTraversalOptions TraversalOptions,
ASTPrinter &Printer,