Commit cc57e5c1 authored by David Lamparter's avatar David Lamparter

Propagate DocComments into binary schema

parent 981814eb
......@@ -1428,6 +1428,9 @@ void NodeTranslator::compileNode(Declaration::Reader decl, schema::Node::Builder
}
builder.adoptAnnotations(compileAnnotationApplications(decl.getAnnotations(), targetsFlagName));
if (decl.hasDocComment())
builder.setDocComment(decl.getDocComment());
}
static kj::StringPtr getExpressionTargetName(Expression::Reader exp) {
......@@ -1740,6 +1743,8 @@ private:
// Information about the field declaration. We don't use Declaration::Reader because it might
// have come from a Declaration::Param instead.
kj::Maybe<::capnp::Text::Reader> docComment = nullptr;
kj::Maybe<schema::Field::Builder> schema;
// Schema for the field. Initialized when getSchema() is first called.
......@@ -1776,6 +1781,8 @@ private:
hasDefaultValue = true;
fieldDefaultValue = fieldDecl.getDefaultValue().getValue();
}
if (decl.hasDocComment())
docComment = decl.getDocComment();
}
inline MemberInfo(MemberInfo& parent, uint codeOrder,
const Declaration::Param::Reader& decl,
......@@ -1802,6 +1809,8 @@ private:
startByte(decl.getStartByte()), endByte(decl.getEndByte()),
node(node), unionScope(nullptr) {
KJ_REQUIRE(decl.which() != Declaration::FIELD);
if (decl.hasDocComment())
docComment = decl.getDocComment();
}
schema::Field::Builder getSchema() {
......@@ -1815,6 +1824,9 @@ private:
}
builder.setName(name);
builder.setCodeOrder(codeOrder);
KJ_IF_MAYBE(docCommentReal, docComment) {
builder.setDocComment(*docCommentReal);
}
schema = builder;
return builder;
}
......
......@@ -77,6 +77,9 @@ struct Node {
annotations @5 :List(Annotation);
# Annotations applied to this node.
docComment @34 :Text;
# This line, but on a node not on a Field...
union {
# Info specific to each kind of node.
......@@ -186,6 +189,9 @@ struct Field {
annotations @2 :List(Annotation);
docComment @11 :Text;
# This line.
const noDiscriminant :UInt16 = 0xffff;
discriminantValue @3 :UInt16 = Field.noDiscriminant;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment