Skip to content

Commit 6d5e1b2

Browse files
committed
[ASTPrinter] Pass down PrintOptions to printModuleRef
1 parent 0f39ce5 commit 6d5e1b2

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

include/swift/AST/ASTPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ class ASTPrinter {
162162
PrintNameContext NameContext = PrintNameContext::Normal);
163163

164164
/// Called when printing the referenced name of a module.
165-
virtual void printModuleRef(ModuleEntity Mod, Identifier Name);
165+
virtual void printModuleRef(ModuleEntity Mod, Identifier Name,
166+
const PrintOptions &Options);
166167

167168
/// Called before printing a synthesized extension.
168169
virtual void printSynthesizedExtensionPre(const ExtensionDecl *ED,

lib/AST/ASTPrinter.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ void ASTPrinter::printTypeRef(Type T, const TypeDecl *RefTo, Identifier Name,
365365
printName(Name, Context);
366366
}
367367

368-
void ASTPrinter::printModuleRef(ModuleEntity Mod, Identifier Name) {
368+
void ASTPrinter::printModuleRef(ModuleEntity Mod, Identifier Name,
369+
const PrintOptions &Options) {
369370
printName(Name);
370371
}
371372

@@ -2503,7 +2504,7 @@ void PrintAST::visitImportDecl(ImportDecl *decl) {
25032504
Name = Declaring->getRealName();
25042505
}
25052506
}
2506-
Printer.printModuleRef(Mods.front(), Name);
2507+
Printer.printModuleRef(Mods.front(), Name, Options);
25072508
Mods = Mods.slice(1);
25082509
} else {
25092510
Printer << Elem.Item.str();
@@ -5391,7 +5392,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
53915392
}
53925393
}
53935394

5394-
Printer.printModuleRef(Mod, Name);
5395+
Printer.printModuleRef(Mod, Name, Options);
53955396
Printer << ".";
53965397
}
53975398

@@ -5742,7 +5743,8 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
57425743
Printer << "module<";
57435744
// Should print the module real name in case module aliasing is
57445745
// used (see -module-alias), since that's the actual binary name.
5745-
Printer.printModuleRef(T->getModule(), T->getModule()->getRealName());
5746+
Printer.printModuleRef(T->getModule(), T->getModule()->getRealName(),
5747+
Options);
57465748
Printer << ">";
57475749
}
57485750

lib/AST/TypeRepr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ void ComponentIdentTypeRepr::printImpl(ASTPrinter &Printer,
269269
const PrintOptions &Opts) const {
270270
if (auto *TD = dyn_cast_or_null<TypeDecl>(getBoundDecl())) {
271271
if (auto MD = dyn_cast<ModuleDecl>(TD))
272-
Printer.printModuleRef(MD, getNameRef().getBaseIdentifier());
272+
Printer.printModuleRef(MD, getNameRef().getBaseIdentifier(), Opts);
273273
else
274274
Printer.printTypeRef(Type(), TD, getNameRef().getBaseIdentifier());
275275
} else {

lib/IDE/ModuleInterfacePrinting.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ class ClangCommentPrinter : public ASTPrinter {
8080
PrintNameContext NameContext) override {
8181
return OtherPrinter.printTypeRef(T, TD, Name, NameContext);
8282
}
83-
void printModuleRef(ModuleEntity Mod, Identifier Name) override {
84-
return OtherPrinter.printModuleRef(Mod, Name);
83+
void printModuleRef(ModuleEntity Mod, Identifier Name,
84+
const PrintOptions &Options) override {
85+
return OtherPrinter.printModuleRef(Mod, Name, Options);
8586
}
8687
void printSynthesizedExtensionPre(const ExtensionDecl *ED,
8788
TypeOrExtensionDecl Target,

tools/SourceKit/lib/SwiftLang/SwiftEditorInterfaceGen.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,11 @@ class AnnotatingPrinter : public StreamPrinter {
185185
StreamPrinter::printTypeRef(T, TD, Name, NameContext);
186186
}
187187

188-
void printModuleRef(ModuleEntity Mod, Identifier Name) override {
188+
void printModuleRef(ModuleEntity Mod, Identifier Name,
189+
const PrintOptions &Options) override {
189190
unsigned StartOffset = OS.tell();
190191
Info.References.emplace_back(Mod, StartOffset, Name.str().size());
191-
StreamPrinter::printModuleRef(Mod, Name);
192+
StreamPrinter::printModuleRef(Mod, Name, Options);
192193
}
193194
};
194195

tools/swift-ide-test/swift-ide-test.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2841,9 +2841,10 @@ class AnnotatingPrinter : public StreamPrinter {
28412841
StreamPrinter::printTypeRef(T, TD, Name, NameContext);
28422842
OS << "</ref>";
28432843
}
2844-
void printModuleRef(ModuleEntity Mod, Identifier Name) override {
2844+
void printModuleRef(ModuleEntity Mod, Identifier Name,
2845+
const PrintOptions &Options) override {
28452846
OS << "<ref:module>";
2846-
StreamPrinter::printModuleRef(Mod, Name);
2847+
StreamPrinter::printModuleRef(Mod, Name, Options);
28472848
OS << "</ref>";
28482849
}
28492850
};

0 commit comments

Comments
 (0)