feat: add raw method

This commit is contained in:
PoiScript 2024-03-31 18:55:49 +08:00
parent a11f7a5007
commit ddb71dc714
No known key found for this signature in database
GPG key ID: 22C2B1249D99985E
2 changed files with 324 additions and 143 deletions

View file

@ -32,11 +32,6 @@ const nodes = [
children: [["headlines", "Headline"]],
post_blank: true,
},
{
struct: "HeadlineTitle",
kind: ["HEADLINE_TITLE"],
parent: [["headline", "Headline"]],
},
{
struct: "PropertyDrawer",
kind: ["PROPERTY_DRAWER"],
@ -307,14 +302,18 @@ impl AstNode for ${node.struct} {
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl ${node.struct} {
/// Equals to \`self.syntax().text_range().start()\`
/// Beginning position of this element
pub fn start(&self) -> TextSize {
self.syntax.text_range().start()
}
/// Equals to \`self.syntax().text_range().end()\`
/// Ending position of this element
pub fn end(&self) -> TextSize {
self.syntax.text_range().end()
}
/// Raw text of this element
pub fn raw(&self) -> String {
self.syntax.to_string()
}
`;
for (const [method, kind] of node.token || []) {
content += ` pub fn ${method}(&self) -> Option<super::Token> { super::token(&self.syntax, ${kind}) }\n`;

File diff suppressed because it is too large Load diff