feat: add raw method
This commit is contained in:
parent
a11f7a5007
commit
ddb71dc714
2 changed files with 324 additions and 143 deletions
|
|
@ -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
Loading…
Add table
Add a link
Reference in a new issue