Skip to content

Commit 0639a9e

Browse files
review: rename Attribute to InlineAttributes
1 parent 76fe621 commit 0639a9e

File tree

6 files changed

+21
-17
lines changed

6 files changed

+21
-17
lines changed

include/swift/Markup/AST.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,16 +589,20 @@ class Image final : public InlineContent,
589589
}
590590
};
591591

592-
class Attribute final : public InlineContent, private llvm::TrailingObjects<Image, MarkupASTNode *> {
592+
class InlineAttributes final : public InlineContent, private llvm::TrailingObjects<Image, MarkupASTNode *> {
593593
friend TrailingObjects;
594594

595+
// Note that inline attributes are like links, in that there are child inline nodes that are
596+
// collectively styled by the attribute text. The child nodes are the text that should be
597+
// displayed.
598+
595599
size_t NumChildren;
596600
StringRef Attributes;
597601

598-
Attribute(StringRef Attributes, ArrayRef<MarkupASTNode *> Children);
602+
InlineAttributes(StringRef Attributes, ArrayRef<MarkupASTNode *> Children);
599603

600604
public:
601-
static Attribute *create(MarkupContext &MC, StringRef Attributes, ArrayRef<MarkupASTNode *> Children);
605+
static InlineAttributes *create(MarkupContext &MC, StringRef Attributes, ArrayRef<MarkupASTNode *> Children);
602606

603607
StringRef getAttributes() const { return Attributes; }
604608

@@ -611,7 +615,7 @@ class Attribute final : public InlineContent, private llvm::TrailingObjects<Imag
611615
}
612616

613617
static bool classof(const MarkupASTNode *N) {
614-
return N->getKind() == ASTNodeKind::Attribute;
618+
return N->getKind() == ASTNodeKind::InlineAttributes;
615619
}
616620
};
617621

include/swift/Markup/ASTNodes.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ ABSTRACT_MARKUP_AST_NODE(InlineContent, MarkupASTNode)
4040
MARKUP_AST_NODE(Strong, InlineContent)
4141
MARKUP_AST_NODE(Link, InlineContent)
4242
MARKUP_AST_NODE(Image, InlineContent)
43-
MARKUP_AST_NODE(Attribute, InlineContent)
44-
MARKUP_AST_NODE_RANGE(Inline, Text, Attribute)
43+
MARKUP_AST_NODE(InlineAttributes, InlineContent)
44+
MARKUP_AST_NODE_RANGE(Inline, Text, InlineAttributes)
4545

4646
/// Private Markdown Extensions - these should not be implemented in the
4747
/// underlying cmark parser.

lib/Frontend/PrintingDiagnosticConsumer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ namespace {
142142
}
143143
}
144144

145-
void visitAttribute(const Attribute *A) {
145+
void visitInlineAttributes(const InlineAttributes *A) {
146146
print("^[");
147147
for (const auto *Child : A->getChildren())
148148
visit(Child);

lib/IDE/CommentConversion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct CommentToXMLConverter {
7272
llvm_unreachable("Can't print a swift::markup::Document as XML directly");
7373
}
7474

75-
void printAttribute(const Attribute *A) {
75+
void printInlineAttributes(const InlineAttributes *A) {
7676
OS << "<Attribute attributes=\"";
7777
appendWithXMLEscaping(OS, A->getAttributes());
7878
OS << "\">";
@@ -650,7 +650,7 @@ class DoxygenConverter : public MarkupASTVisitor<DoxygenConverter> {
650650
visit(Child);
651651
}
652652

653-
void visitAttribute(const Attribute *A) {
653+
void visitInlineAttributes(const InlineAttributes *A) {
654654
// attributed strings don't have an analogue in Doxygen, so just print out the text
655655
for (const auto *Child : A->getChildren())
656656
visit(Child);

lib/Markup/AST.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ Paragraph *Paragraph::create(MarkupContext &MC,
157157
return new (Mem) Paragraph(Children);
158158
}
159159

160-
Attribute::Attribute(StringRef Attributes, ArrayRef<MarkupASTNode *> Children) : InlineContent(ASTNodeKind::Attribute), NumChildren(Children.size()), Attributes(Attributes) {
160+
InlineAttributes::InlineAttributes(StringRef Attributes, ArrayRef<MarkupASTNode *> Children) : InlineContent(ASTNodeKind::InlineAttributes), NumChildren(Children.size()), Attributes(Attributes) {
161161
std::uninitialized_copy(Children.begin(), Children.end(), getTrailingObjects<MarkupASTNode *>());
162162
}
163163

164-
Attribute *Attribute::create(MarkupContext &MC, StringRef Attributes, ArrayRef<MarkupASTNode *> Children) {
165-
void *Mem = MC.allocate(totalSizeToAlloc<MarkupASTNode *>(Children.size()), alignof(Attribute));
164+
InlineAttributes *InlineAttributes::create(MarkupContext &MC, StringRef Attributes, ArrayRef<MarkupASTNode *> Children) {
165+
void *Mem = MC.allocate(totalSizeToAlloc<MarkupASTNode *>(Children.size()), alignof(InlineAttributes));
166166
StringRef AttrsCopy = MC.allocateCopy(Attributes);
167-
return new (Mem) Attribute(AttrsCopy, Children);
167+
return new (Mem) InlineAttributes(AttrsCopy, Children);
168168
}
169169

170170
HRule *HRule::create(MarkupContext &MC) {
@@ -418,8 +418,8 @@ void swift::markup::dump(const MarkupASTNode *Node, llvm::raw_ostream &OS,
418418
dumpChildren(Node->getChildren(), OS, indent + 1);
419419
break;
420420
}
421-
case swift::markup::ASTNodeKind::Attribute: {
422-
auto A = cast<Attribute>(Node);
421+
case swift::markup::ASTNodeKind::InlineAttributes: {
422+
auto A = cast<InlineAttributes>(Node);
423423
OS << "Attribute:";
424424
OS << " Attributes=" << A->getAttributes();
425425
OS << " Children=" << Node->getChildren().size();

lib/Markup/Markup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,13 @@ ParseResult<Link> parseLink(MarkupContext &MC, ParseState State) {
216216
return { Link::create(MC, Destination, Children), ResultState.next() };
217217
}
218218

219-
ParseResult<Attribute> parseAttribute(MarkupContext &MC, ParseState State) {
219+
ParseResult<InlineAttributes> parseAttribute(MarkupContext &MC, ParseState State) {
220220
assert(cmark_node_get_type(State.Node) == CMARK_NODE_ATTRIBUTE && State.Event == CMARK_EVENT_ENTER);
221221
std::string Attributes(cmark_node_get_attributes(State.Node));
222222
SmallVector<MarkupASTNode *, 2> Children;
223223
auto ResultState = parseChildren(MC, State, Children);
224224
assert(State.Node == ResultState.Node && ResultState.Event == CMARK_EVENT_EXIT);
225-
return { Attribute::create(MC, Attributes, Children), ResultState.next() };
225+
return { InlineAttributes::create(MC, Attributes, Children), ResultState.next() };
226226
}
227227

228228
ParseResult<List> parseList(MarkupContext &MC, ParseState State) {

0 commit comments

Comments
 (0)