diff options
author | Akshay <[email protected]> | 2021-06-12 18:03:07 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2021-06-12 18:03:07 +0100 |
commit | 6be61101caeb6c46ac74cb9944106e18727b1e77 (patch) | |
tree | 86e6e9ecb041beccfecfae10ecadde27b3013238 | |
parent | 73177af78f61975a0eaef9a88758d59db4ccc473 (diff) |
accessor for token text
-rw-r--r-- | src/lib.rs | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -61,10 +61,17 @@ impl SynNode { | |||
61 | (r.start().into(), r.end().into()).into() | 61 | (r.start().into(), r.end().into()).into() |
62 | } | 62 | } |
63 | 63 | ||
64 | pub fn text(&self) -> String { | 64 | pub fn kind(&self) -> String { |
65 | format!("{:?}", self.node.kind()) | 65 | format!("{:?}", self.node.kind()) |
66 | } | 66 | } |
67 | 67 | ||
68 | pub fn text(&self) -> String { | ||
69 | match &self.node { | ||
70 | NodeOrToken::Node(_) => "".into(), | ||
71 | NodeOrToken::Token(t) => format!("{:?}", t.text()), | ||
72 | } | ||
73 | } | ||
74 | |||
68 | pub fn from_str(s: &str) -> Result<JsValue, JsValue> { | 75 | pub fn from_str(s: &str) -> Result<JsValue, JsValue> { |
69 | FromStr::from_str(s) | 76 | FromStr::from_str(s) |
70 | .map(|p: SynNode| JsValue::from(p)) | 77 | .map(|p: SynNode| JsValue::from(p)) |