mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
add AST printer support for _documentation attribute (#64326)
fixes #64309 fixes rdar://106657906
This commit is contained in:
@@ -1393,6 +1393,32 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
|
||||
break;
|
||||
}
|
||||
|
||||
case DAK_Documentation: {
|
||||
auto *attr = cast<DocumentationAttr>(this);
|
||||
|
||||
Printer.printAttrName("@_documentation");
|
||||
Printer << "(";
|
||||
|
||||
bool needs_comma = !attr->Metadata.empty() && attr->Visibility;
|
||||
|
||||
if (attr->Visibility) {
|
||||
Printer << "visibility: ";
|
||||
Printer << getAccessLevelSpelling(*attr->Visibility);
|
||||
}
|
||||
|
||||
if (needs_comma) {
|
||||
Printer << ", ";
|
||||
}
|
||||
|
||||
if (!attr->Metadata.empty()) {
|
||||
Printer << "metadata: ";
|
||||
Printer << attr->Metadata;
|
||||
}
|
||||
|
||||
Printer << ")";
|
||||
break;
|
||||
}
|
||||
|
||||
case DAK_Count:
|
||||
llvm_unreachable("exceed declaration attribute kinds");
|
||||
|
||||
|
||||
9
test/SourceKit/CursorInfo/doc_attr.swift
Normal file
9
test/SourceKit/CursorInfo/doc_attr.swift
Normal file
@@ -0,0 +1,9 @@
|
||||
@_documentation(visibility: public)
|
||||
enum E
|
||||
{
|
||||
}
|
||||
|
||||
// The @_documentation attribute caused sourcekit-lsp to crash
|
||||
// cf. https://github.com/apple/swift/issues/64309
|
||||
|
||||
// RUN: %sourcekitd-test -req=cursor -pos=2:6 %s -- %s
|
||||
Reference in New Issue
Block a user