git.delta.rocks / jrsonnet / refs/commits / 014057b0e966

difftreelog

feat(fmt) basic comment formatting in objects

Yaroslav Bolyukin2022-06-22parent: #b1b8b4c.patch.diff
in: master

21 files changed

deleted.cargo/configdiffbeforeafterboth
--- a/.cargo/config
+++ /dev/null
@@ -1,2 +0,0 @@
-[alias]
-xtask = "run --manifest-path ./xtask/Cargo.toml --"
added.cargo/config.tomldiffbeforeafterboth
--- /dev/null
+++ b/.cargo/config.toml
@@ -0,0 +1,2 @@
+[alias]
+xtask = "run --package xtask --bin xtask --"
modifiedcmds/jrsonnet-fmt/Cargo.tomldiffbeforeafterboth
--- a/cmds/jrsonnet-fmt/Cargo.toml
+++ b/cmds/jrsonnet-fmt/Cargo.toml
@@ -6,3 +6,5 @@
 [dependencies]
 dprint-core = "0.58.2"
 jrsonnet-rowan-parser = { path = "../../crates/jrsonnet-rowan-parser" }
+insta = "1.15"
+indoc = "1.0"
addedcmds/jrsonnet-fmt/src/children.rsdiffbeforeafterboth
--- /dev/null
+++ b/cmds/jrsonnet-fmt/src/children.rs
@@ -0,0 +1,168 @@
+use std::{fmt::Debug, marker::PhantomData, mem};
+
+use jrsonnet_rowan_parser::{
+	nodes::{Trivia, TriviaKind},
+	AstNode, AstToken, SyntaxElement,
+	SyntaxKind::*,
+	SyntaxNode, TS,
+};
+
+pub type ChildTrivia = Vec<Trivia>;
+
+pub struct ChildIterator<I, T> {
+	inner: I,
+	_marker: PhantomData<T>,
+}
+
+pub fn children_between<T: AstNode + Debug>(
+	node: SyntaxNode,
+	start: Option<&SyntaxElement>,
+	end: Option<&SyntaxElement>,
+) -> (Vec<Child<T>>, ChildTrivia) {
+	let mut iter = node.children_with_tokens().peekable();
+	while iter.peek() == start {
+		iter.next();
+	}
+	children(
+		iter.take_while(|i| Some(i) != end),
+		start.is_none() || end.is_none(),
+	)
+}
+
+pub fn should_start_with_newline(tt: &ChildTrivia) -> bool {
+	// First for previous item end
+	count_newlines_before(&tt) >= 2
+}
+
+fn count_newlines_before(tt: &ChildTrivia) -> usize {
+	let mut nl_count = 0;
+	for t in tt {
+		match t.kind() {
+			TriviaKind::Whitespace => {
+				nl_count += t.text().bytes().filter(|b| *b == b'\n').count();
+			}
+			_ => break,
+		}
+	}
+	nl_count
+}
+fn count_newlines_after(tt: &ChildTrivia) -> usize {
+	let mut nl_count = 0;
+	for t in tt.iter().rev() {
+		match t.kind() {
+			TriviaKind::Whitespace => {
+				nl_count += t.text().bytes().filter(|b| *b == b'\n').count();
+			}
+			TriviaKind::SingleLineHashComment => {
+				nl_count += 1;
+				break;
+			}
+			TriviaKind::SingleLineSlashComment => {
+				nl_count += 1;
+				break;
+			}
+			_ => {}
+		}
+	}
+	nl_count
+}
+
+pub fn children<'a, T: AstNode + Debug>(
+	items: impl Iterator<Item = SyntaxElement>,
+	loose: bool,
+) -> (Vec<Child<T>>, ChildTrivia) {
+	let mut out = Vec::new();
+	let mut current_child = None::<Child<T>>;
+	let mut next = ChildTrivia::new();
+	// Previous element ended, do not add more inline comments
+	let mut started_next = false;
+	let mut had_some = false;
+
+	for item in items {
+		if let Some(value) = item.as_node().cloned().and_then(T::cast) {
+			let before_trivia = mem::take(&mut next);
+			let last_child = current_child.replace(Child {
+				newlines_above: if had_some {
+					count_newlines_before(&before_trivia)
+						+ current_child
+							.as_ref()
+							.map(|c| count_newlines_after(&c.inline_trivia))
+							.unwrap_or_default()
+				} else {
+					0
+				},
+				before_trivia,
+				value,
+				inline_trivia: Vec::new(),
+			});
+			if let Some(last_child) = last_child {
+				out.push(last_child)
+			}
+			had_some = true;
+			started_next = false;
+		} else if let Some(trivia) = item.as_token().cloned().and_then(Trivia::cast) {
+			let is_single_line_comment = trivia.kind() == TriviaKind::SingleLineHashComment
+				|| trivia.kind() == TriviaKind::SingleLineSlashComment;
+			if started_next
+				|| current_child.is_none()
+				|| trivia.text().contains('\n') && !is_single_line_comment
+			{
+				next.push(trivia.clone());
+				started_next = true;
+			} else {
+				let cur = current_child.as_mut().expect("checked not none");
+				cur.inline_trivia.push(trivia);
+				if is_single_line_comment {
+					started_next = true;
+				}
+			}
+			had_some = true;
+		} else if loose {
+			if had_some {
+				break;
+			}
+			started_next = true;
+		} else {
+			assert!(
+				TS![, ;].contains(item.kind()) || item.kind() == ERROR,
+				"silently eaten token: {:?}",
+				item.kind()
+			)
+		}
+	}
+
+	if let Some(current_child) = current_child {
+		out.push(current_child);
+	}
+
+	(out, next)
+}
+
+#[derive(Debug)]
+pub struct Child<T> {
+	newlines_above: usize,
+	/// Comment before item, i.e
+	///
+	/// ```ignore
+	/// // Comment
+	/// item
+	/// ```
+	pub before_trivia: ChildTrivia,
+	pub value: T,
+	/// Comment after line, but located at same line
+	///
+	/// ```ignore
+	/// item1, // Inline comment
+	/// // Not inline comment
+	/// item2,
+	/// ```
+	pub inline_trivia: ChildTrivia,
+}
+
+impl<T> Child<T> {
+	/// If this child has two newlines above in source code, so it needs to have it in output
+	pub fn needs_newline_above(&self) -> bool {
+		// First line for end of previous item
+		self.newlines_above >= 2
+	}
+}
addedcmds/jrsonnet-fmt/src/comments.rsdiffbeforeafterboth
--- /dev/null
+++ b/cmds/jrsonnet-fmt/src/comments.rs
@@ -0,0 +1,159 @@
+use dprint_core::formatting::PrintItems;
+use jrsonnet_rowan_parser::{nodes::TriviaKind, AstToken};
+
+use crate::{children::ChildTrivia, p, pi};
+
+pub enum CommentLocation {
+	/// Above local, field, other things
+	AboveItem,
+	/// After item
+	ItemInline,
+	/// After all items in object
+	EndOfItems,
+}
+
+pub fn format_comments(comments: &ChildTrivia, loc: CommentLocation) -> PrintItems {
+	let mut pi = p!(new:);
+
+	for c in comments {
+		match c.kind() {
+			TriviaKind::Whitespace => {}
+			TriviaKind::MultiLineComment => {
+				let mut text = c
+					.text()
+					.strip_prefix("/*")
+					.expect("ml comment starts with /*")
+					.strip_suffix("*/")
+					.expect("ml comment ends with */");
+				// doc-style comment, /**
+				let doc = if text.starts_with('*') {
+					text = &text[1..];
+					true
+				} else {
+					false
+				};
+				// Is comment starts with text immediatly, i.e /*text
+				let mut immediate_start = true;
+				let mut lines = text
+					.split('\n')
+					.map(|l| l.trim_end())
+					.skip_while(|l| {
+						if l.is_empty() {
+							immediate_start = false;
+							true
+						} else {
+							false
+						}
+					})
+					.collect::<Vec<_>>();
+				while lines.last().map(|l| l.is_empty()).unwrap_or(false) {
+					lines.pop();
+				}
+				if lines.len() == 1 && !doc {
+					p!(pi: str("/* ") str(lines[0].trim()) str(" */") nl)
+				} else if !lines.is_empty() {
+					fn common_ws_prefix<'a>(a: &'a str, b: &str) -> &'a str {
+						let offset = a
+							.bytes()
+							.zip(b.bytes())
+							.take_while(|(a, b)| a == b && (a.is_ascii_whitespace() || *a == b'*'))
+							.count();
+						&a[..offset]
+					}
+					// First line is not empty, extract ws prefix of it
+					let mut common_ws_padding = if immediate_start && lines.len() > 1 {
+						common_ws_prefix(lines[1], lines[1])
+					} else {
+						common_ws_prefix(lines[0], lines[0])
+					};
+					for line in lines
+						.iter()
+						.skip(if immediate_start { 2 } else { 1 })
+						.filter(|l| !l.is_empty())
+					{
+						common_ws_padding = common_ws_prefix(common_ws_padding, line);
+					}
+					for line in lines
+						.iter_mut()
+						.skip(if immediate_start { 1 } else { 0 })
+						.filter(|l| !l.is_empty())
+					{
+						*line = line
+							.strip_prefix(common_ws_padding)
+							.expect("all non-empty lines start with this padding");
+					}
+
+					p!(pi: str("/*"));
+					if doc {
+						p!(pi: str("*"));
+					}
+					p!(pi: nl);
+					for mut line in lines {
+						if doc {
+							p!(pi: str(" *"));
+						}
+						if line.is_empty() {
+							p!(pi: nl);
+						} else {
+							if doc {
+								p!(pi: str(" "));
+							}
+							while let Some(new_line) = line.strip_prefix('\t') {
+								if doc {
+									p!(pi: str("    "));
+								} else {
+									p!(pi: tab);
+								}
+								line = new_line;
+							}
+							p!(pi: str(line) nl)
+						}
+					}
+					if doc {
+						p!(pi: str(" "));
+					}
+					p!(pi: str("*/") nl)
+				}
+			}
+			// TODO: Keep common padding for multiple continous lines of single-line comments
+			// I.e
+			// ```
+			// #  Line1
+			// #    Line2
+			// ```
+			// Should be reformatted as
+			// ```
+			// # Line1
+			// #   Line2
+			// ```
+			// But currently comment formatter is not aware of continous comment lines, and reformats it as
+			// ```
+			// # Line1
+			// # Line2
+			// ```
+			TriviaKind::SingleLineHashComment => {
+				if matches!(loc, CommentLocation::ItemInline) {
+					p!(pi: str(" "))
+				}
+				p!(pi: str("# ") str(c.text().strip_prefix('#').expect("hash comment starts with #").trim()));
+				if !matches!(loc, CommentLocation::ItemInline) {
+					p!(pi: nl)
+				}
+			}
+			TriviaKind::SingleLineSlashComment => {
+				if matches!(loc, CommentLocation::ItemInline) {
+					p!(pi: str(" "))
+				}
+				p!(pi: str("// ") str(c.text().strip_prefix("//").expect("comment starts with //").trim()));
+				if !matches!(loc, CommentLocation::ItemInline) {
+					p!(pi: nl)
+				}
+			}
+			// Garbage in - garbage out
+			TriviaKind::ErrorCommentTooShort => p!(pi: str("/*/")),
+			TriviaKind::ErrorCommentUnterminated => p!(pi: str(c.text())),
+		}
+	}
+
+	pi
+}
modifiedcmds/jrsonnet-fmt/src/main.rsdiffbeforeafterboth
--- a/cmds/jrsonnet-fmt/src/main.rs
+++ b/cmds/jrsonnet-fmt/src/main.rs
@@ -1,6 +1,7 @@
 use std::any::type_name;
 
-use dprint_core::formatting::{PrintItems, PrintOptions, Signal};
+use children::children_between;
+use dprint_core::formatting::{PrintItems, PrintOptions};
 use jrsonnet_rowan_parser::{
 	nodes::{
 		ArgsDesc, Assertion, BinaryOperator, Bind, CompSpec, Destruct, DestructArrayPart,
@@ -8,9 +9,19 @@
 		Member, Name, Number, ObjBody, ObjLocal, ParamsDesc, SliceDesc, SourceFile, Text,
 		UnaryOperator,
 	},
-	AstToken, SyntaxToken,
+	AstNode, AstToken, SyntaxToken,
 };
 
+use crate::{
+	children::should_start_with_newline,
+	comments::{format_comments, CommentLocation},
+};
+
+mod children;
+mod comments;
+#[cfg(test)]
+mod tests;
+
 pub trait Printable {
 	fn print(&self) -> PrintItems;
 }
@@ -18,7 +29,7 @@
 macro_rules! pi {
 	(@i; $($t:tt)*) => {{
 		#[allow(unused_mut)]
-		let mut o = PrintItems::new();
+		let mut o = dprint_core::formatting::PrintItems::new();
 		pi!(@s; o: $($t)*);
 		o
 	}};
@@ -27,21 +38,29 @@
 		pi!(@s; $o: $($t)*);
 	}};
 	(@s; $o:ident: nl $($t:tt)*) => {{
-		$o.push_signal(Signal::NewLine);
+		$o.push_signal(dprint_core::formatting::Signal::NewLine);
 		pi!(@s; $o: $($t)*);
 	}};
+	(@s; $o:ident: tab $($t:tt)*) => {{
+		$o.push_signal(dprint_core::formatting::Signal::Tab);
+		pi!(@s; $o: $($t)*);
+	}};
 	(@s; $o:ident: >i $($t:tt)*) => {{
-		$o.push_signal(Signal::StartIndent);
+		$o.push_signal(dprint_core::formatting::Signal::StartIndent);
 		pi!(@s; $o: $($t)*);
 	}};
 	(@s; $o:ident: <i $($t:tt)*) => {{
-		$o.push_signal(Signal::FinishIndent);
+		$o.push_signal(dprint_core::formatting::Signal::FinishIndent);
 		pi!(@s; $o: $($t)*);
 	}};
 	(@s; $o:ident: {$expr:expr} $($t:tt)*) => {{
 		$o.extend($expr.print());
 		pi!(@s; $o: $($t)*);
 	}};
+	(@s; $o:ident: items($expr:expr) $($t:tt)*) => {{
+		$o.extend($expr);
+		pi!(@s; $o: $($t)*);
+	}};
 	(@s; $o:ident: if ($e:expr)($($then:tt)*) $($t:tt)*) => {{
 		if $e {
 			pi!(@s; $o: $($then)*);
@@ -66,6 +85,8 @@
 		pi!(@s; $o: $($t)*)
 	};
 }
+pub(crate) use p;
+pub(crate) use pi;
 
 impl<P> Printable for Option<P>
 where
@@ -266,9 +287,18 @@
 		match self {
 			ObjBody::ObjBodyComp(_) => todo!(),
 			ObjBody::ObjBodyMemberList(l) => {
-				let mut pi = p!(new:);
-				for mem in l.members() {
-					match mem {
+				let mut pi = p!(new: str("{") >i nl);
+				let (children, end_comments) = children_between::<Member>(
+					l.syntax().clone(),
+					l.l_brace_token().map(Into::into).as_ref(),
+					l.r_brace_token().map(Into::into).as_ref(),
+				);
+				for mem in children.into_iter() {
+					if mem.needs_newline_above() {
+						p!(pi: nl);
+					}
+					p!(pi: items(format_comments(&mem.before_trivia, CommentLocation::AboveItem)));
+					match mem.value {
 						Member::MemberBindStmt(b) => {
 							p!(pi: {b.obj_local()})
 						}
@@ -279,8 +309,17 @@
 							p!(pi: {f.field()})
 						}
 					}
-					p!(pi: str(",") nl)
+					p!(pi: str(","));
+					p!(pi: items(format_comments(&mem.inline_trivia, CommentLocation::ItemInline)));
+					p!(pi: nl)
 				}
+
+				// TODO: implement same thing as needs_newline_above, but for end comments
+				if should_start_with_newline(&end_comments) {
+					p!(pi: nl);
+				}
+				p!(pi: items(format_comments(&end_comments, CommentLocation::EndOfItems)));
+				p!(pi: <i str("}"));
 				pi
 			}
 		}
@@ -382,7 +421,7 @@
 				pi
 			}
 			Expr::ExprObject(o) => {
-				p!(new: str("{") >i nl {o.obj_body()} <i str("}"))
+				p!(new: {o.obj_body()})
 			}
 			Expr::ExprArrayComp(arr) => {
 				let mut pi = p!(new: str("[") {arr.expr()});
@@ -485,6 +524,47 @@
 		  ],
 		  m: a[1::],
 		  m: b[::],
+
+		  comments: {
+			_: '',
+			//     Plain comment
+			a: '',
+
+			#    Plain comment with empty line before
+			b: '',
+			/*Single-line multiline comment
+
+			*/
+			c: '',
+
+			/**Single-line multiline doc comment
+
+			*/
+			c: '',
+
+			/**multiline doc comment
+			s
+			*/
+			c: '',
+
+			/*
+
+	Multi-line
+
+	comment
+			*/
+			d: '',
+
+			e: '', // Inline comment
+
+			k: '',
+
+			// Text after everything
+		  },
+		  comments2: {
+			k: '',
+			// Text after everything, but no newline above
+		  },
 		  k: if a         == b    then
 
 
addedcmds/jrsonnet-fmt/src/snapshots/jrsonnet_fmt__tests__complex_comments_snapshot.snapdiffbeforeafterboth
--- /dev/null
+++ b/cmds/jrsonnet-fmt/src/snapshots/jrsonnet_fmt__tests__complex_comments_snapshot.snap
@@ -0,0 +1,53 @@
+---
+source: cmds/jrsonnet-fmt/src/tests.rs
+expression: "reformat(indoc!(\"{\n\t\t  comments: {\n\t\t\t_: '',\n\t\t\t//     Plain comment\n\t\t\ta: '',\n\n\t\t\t#    Plain comment with empty line before\n\t\t\tb: '',\n\t\t\t/*Single-line multiline comment\n\n\t\t\t*/\n\t\t\tc: '',\n\n\t\t\t/**Single-line multiline doc comment\n\n\t\t\t*/\n\t\t\tc: '',\n\n\t\t\t/**Multiline doc\n\t\t\tComment\n\t\t\t*/\n\t\t\tc: '',\n\n\t\t\t/*\n\n\tMulti-line\n\n\tcomment\n\t\t\t*/\n\t\t\td: '',\n\n\t\t\te: '', // Inline comment\n\n\t\t\tk: '',\n\n\t\t\t// Text after everything\n\t\t  },\n\t\t  comments2: {\n\t\t\tk: '',\n\t\t\t// Text after everything, but no newline above\n\t\t  },\n          spacing: {\n            a: '',\n\n            b: '',\n          },\n          noSpacing: {\n            a: '',\n            b: '',\n          },\n        }\"))"
+---
+{
+  comments: {
+    _: '',
+    // Plain comment
+    a: '',
+
+    # Plain comment with empty line before
+    b: '',
+    /* Single-line multiline comment */
+    c: '',
+
+    /**
+     * Single-line multiline doc comment
+     */
+    c: '',
+
+    /**
+     * Multiline doc
+     * Comment
+     */
+    c: '',
+
+    /*
+    Multi-line
+
+    comment
+    */
+    d: '',
+
+    e: '', // Inline comment
+
+    k: '',
+
+    // Text after everything
+  },
+  comments2: {
+    k: '',
+    // Text after everything, but no newline above
+  },
+  spacing: {
+    a: '',
+
+    b: '',
+  },
+  noSpacing: {
+    a: '',
+    b: '',
+  },
+}
addedcmds/jrsonnet-fmt/src/tests.rsdiffbeforeafterboth
--- /dev/null
+++ b/cmds/jrsonnet-fmt/src/tests.rs
@@ -0,0 +1,124 @@
+use dprint_core::formatting::PrintOptions;
+use indoc::indoc;
+
+use crate::Printable;
+
+fn reformat(input: &str) -> String {
+	let (source, _) = jrsonnet_rowan_parser::parse(input);
+
+	dprint_core::formatting::format(
+		|| source.print(),
+		PrintOptions {
+			indent_width: 2,
+			max_width: 100,
+			use_tabs: false,
+			new_line_text: "\n",
+		},
+	)
+}
+
+macro_rules! assert_formatted {
+	($input:literal, $output:literal) => {
+		let formatted = reformat(indoc!($input));
+		let expected = indoc!($output);
+		if formatted != expected {
+			panic!(
+				"bad formatting, expected\n```\n{formatted}\n```\nto be equal to\n```\n{expected}\n```",
+			)
+		}
+	};
+}
+
+#[test]
+fn padding_stripped_for_multiline_comment() {
+	assert_formatted!(
+		"{
+            /*
+                Hello
+                    World
+            */
+            _: null,
+        }",
+		"{
+          /*
+          Hello
+              World
+          */
+          _: null,
+        }"
+	);
+}
+
+// Fails
+#[test]
+fn last_comment_respects_spacing_with_inline_comment_above() {
+	assert_formatted!(
+		"{
+			a: '', // Inline
+
+			// Comment
+        }",
+		"{
+		  a: '', // Inline
+
+		  // Comment
+		}"
+	);
+}
+
+#[test]
+fn complex_comments_snapshot() {
+	insta::assert_display_snapshot!(reformat(indoc!(
+		"{
+		  comments: {
+			_: '',
+			//     Plain comment
+			a: '',
+
+			#    Plain comment with empty line before
+			b: '',
+			/*Single-line multiline comment
+
+			*/
+			c: '',
+
+			/**Single-line multiline doc comment
+
+			*/
+			c: '',
+
+			/**Multiline doc
+			Comment
+			*/
+			c: '',
+
+			/*
+
+	Multi-line
+
+	comment
+			*/
+			d: '',
+
+			e: '', // Inline comment
+
+			k: '',
+
+			// Text after everything
+		  },
+		  comments2: {
+			k: '',
+			// Text after everything, but no newline above
+		  },
+          spacing: {
+            a: '',
+
+            b: '',
+          },
+          noSpacing: {
+            a: '',
+            b: '',
+          },
+        }"
+	)))
+}
addedcmds/jrsonnet-lsp/Cargo.tomldiffbeforeafterboth
--- /dev/null
+++ b/cmds/jrsonnet-lsp/Cargo.toml
@@ -0,0 +1,13 @@
+[package]
+name = "jrsonnet-lsp"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+anyhow = "1.0.48"
+jrsonnet-evaluator = { path = "../../crates/jrsonnet-evaluator" }
+jrsonnet-rowan-parser = { path = "../../crates/jrsonnet-rowan-parser" }
+lsp-server = "0.6.0"
+lsp-types = "0.93.0"
+serde = "1.0.130"
+serde_json = "1.0.71"
addedcmds/jrsonnet-lsp/src/main.rsdiffbeforeafterboth
--- /dev/null
+++ b/cmds/jrsonnet-lsp/src/main.rs
@@ -0,0 +1,188 @@
+use std::{fs::File, io::Write, path::PathBuf, str::FromStr};
+
+use lsp_server::{Connection, ErrorCode, Message, Request, RequestId, Response};
+use lsp_types::{
+	notification::{DidChangeTextDocument, DidOpenTextDocument, Notification},
+	request::{DocumentLinkRequest, HoverRequest},
+	CompletionOptions, DidChangeTextDocumentParams, DidOpenTextDocumentParams, DocumentLink,
+	DocumentLinkOptions, ServerCapabilities, TextDocumentSyncCapability, TextDocumentSyncKind,
+	TextDocumentSyncOptions, Url, WorkDoneProgressOptions,
+};
+
+fn main() {
+	let mut log = File::create("test").unwrap();
+	writeln!(log, "start").unwrap();
+	let (connection, io_threads) = Connection::stdio();
+	let capabilities = serde_json::to_value(&ServerCapabilities {
+		completion_provider: Some(CompletionOptions::default()),
+		definition_provider: Some(lsp_types::OneOf::Left(true)),
+		document_link_provider: Some(DocumentLinkOptions {
+			resolve_provider: Some(false),
+			work_done_progress_options: WorkDoneProgressOptions::default(),
+		}),
+		hover_provider: Some(lsp_types::HoverProviderCapability::Simple(true)),
+		text_document_sync: Some(TextDocumentSyncCapability::Options(
+			TextDocumentSyncOptions {
+				change: Some(TextDocumentSyncKind::FULL),
+				open_close: Some(true),
+				..TextDocumentSyncOptions::default()
+			},
+		)),
+		..ServerCapabilities::default()
+	})
+	.expect("failed to convert capabilities to json");
+
+	connection
+		.initialize(capabilities)
+		.expect("failed to initialize connection");
+
+	writeln!(log, "initialized").unwrap();
+
+	main_loop(&mut log, &connection).expect("main loop failed");
+
+	io_threads.join().expect("failed to join io_threads");
+}
+fn main_loop(log: &mut File, connection: &Connection) -> anyhow::Result<()> {
+	// let mut es = EvaluationState::default();
+	// es.set_import_resolver(Box::new(FileImportResolver::default()));
+
+	let reply = |response: Response| {
+		connection
+			.sender
+			.send(Message::Response(response))
+			.expect("failed to respond");
+	};
+
+	for msg in &connection.receiver {
+		match msg {
+			Message::Response(_) => (),
+			Message::Request(req) => {
+				if connection.handle_shutdown(&req)? {
+					return Ok(());
+				}
+				if let Some((id, params)) = cast::<DocumentLinkRequest>(&req) {
+					reply(Response::new_ok(id, <Vec<DocumentLink>>::new()));
+				} else if let Some((id, params)) = cast::<HoverRequest>(&req) {
+					let pos = params
+						.text_document_position_params
+						.text_document
+						.uri
+						.path();
+					let buf = PathBuf::from_str(pos).unwrap();
+				// let pos = es
+				// 	.map_from_source_location(
+				// 		&buf,
+				// 		params.text_document_position_params.position.line as usize + 1,
+				// 		params.text_document_position_params.position.character as usize + 1,
+				// 	)
+				// 	.unwrap();
+				// let el = ExprLocation(buf.clone().into(), pos as usize, pos as usize);
+				// let es2 = es.clone();
+				// reply(Response::new_ok(
+				// 	id,
+				// 	Some(Hover {
+				// 		range: None,
+				// 		contents: HoverContents::Markup(MarkupContent {
+				// 			kind: MarkupKind::Markdown,
+				// 			value: es
+				// 				.run_in_state_with_breakpoint(el, move || {
+				// 					es2.reset_evaluation_state(&buf);
+				// 					es2.import_file(&PathBuf::new(), &buf)?
+				// 						.to_string()
+				// 						.map(|_| ())
+				// 				})
+				// 				.unwrap()
+				// 				.unwrap_or_else(|| Val::Null)
+				// 				.value_type()
+				// 				.to_string(),
+				// 		}),
+				// 	}),
+				// ));
+				} else {
+					reply(Response::new_err(
+						req.id,
+						ErrorCode::MethodNotFound as i32,
+						format!("unrecognized request {}", req.method),
+					))
+				}
+				/*
+				if let Some((id, params)) = cast::<DocumentLinkRequest>(&req) {
+					 let links = handle_links(&files, params).unwrap_or_default();
+					 reply(Response::new_ok(id, links));
+				} else if let Some((id, params)) = cast::<GotoDefinition>(&req) {
+					 if let Some(loc) = handle_goto(&files, params) {
+						  reply(Response::new_ok(id, loc))
+					 } else {
+						  reply(Response::new_ok(id, ()))
+					 }
+				} else if let Some((id, params)) = cast::<HoverRequest>(&req) {
+					 match handle_hover(&files, params) {
+						  Some((range, markdown)) => {
+								reply(Response::new_ok(
+									 id,
+									 Hover {
+										  contents: HoverContents::Markup(MarkupContent {
+												kind: MarkupKind::Markdown,
+												value: markdown,
+										  }),
+										  range,
+									 },
+								));
+						  }
+						  None => {
+								reply(Response::new_ok(id, ()));
+						  }
+					 }
+				} else if let Some((id, params)) = cast::<Completion>(&req) {
+					 let completions = handle_completion(&files, params.text_document_position)
+						  .unwrap_or_default();
+					 reply(Response::new_ok(id, completions));
+				} else
+				*/
+			}
+			Message::Notification(req) => {
+				let mut handle = |text: String, uri: Url| {
+					writeln!(log, "updated file: {:?}", uri).unwrap();
+					let path = match PathBuf::from_str(uri.path()) {
+						Ok(x) => x,
+						Err(_) => return,
+					};
+					let (ast, errors) = jrsonnet_rowan_parser::parse(&text);
+					// es.add_parsed_file(path.into(), text.into(), parsed)
+					// 	.unwrap();
+					writeln!(log, "parsed: {:?}", uri).unwrap();
+				};
+
+				match &*req.method {
+					DidOpenTextDocument::METHOD => {
+						let params: DidOpenTextDocumentParams =
+							match serde_json::from_value(req.params) {
+								Ok(x) => x,
+								Err(_) => continue,
+							};
+						handle(params.text_document.text, params.text_document.uri);
+					}
+					DidChangeTextDocument::METHOD => {
+						let params: DidChangeTextDocumentParams =
+							match serde_json::from_value(req.params) {
+								Ok(x) => x,
+								Err(_) => continue,
+							};
+						for change in params.content_changes.into_iter() {
+							handle(change.text, params.text_document.uri.clone());
+						}
+					}
+					_ => continue,
+				}
+			}
+		}
+	}
+	Ok(())
+}
+fn cast<R>(req: &Request) -> Option<(RequestId, R::Params)>
+where
+	R: lsp_types::request::Request,
+	R::Params: serde::de::DeserializeOwned,
+{
+	req.clone().extract(R::METHOD).ok()
+}
modifiedcrates/jrsonnet-rowan-parser/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/Cargo.toml
+++ b/crates/jrsonnet-rowan-parser/Cargo.toml
@@ -4,19 +4,19 @@
 edition = "2021"
 
 [dependencies]
-anyhow = "1.0.51"
+anyhow = "1.0"
 backtrace = "0.3.63"
 drop_bomb = "0.1.5"
-indoc = "1.0.3"
-logos = "0.12.0"
-miette = { version = "4.2.1", features = ["fancy"] }
-rowan = "0.15.0"
-text-size = "1.1.0"
-thiserror = "1.0.30"
+indoc = "1.0"
+logos = "0.12"
+miette = { version = "4.2", features = ["fancy"] }
+rowan = "0.15"
+text-size = "1.1"
+thiserror = "1.0"
 
 [dev-dependencies]
 backtrace = "0.3.63"
-indoc = "1.0.3"
-insta = "1.10.0"
-anyhow = "1.0.57"
+indoc = "1.0"
+insta = "1.15"
+anyhow = "1.0"
 jrsonnet-stdlib = { path = "../jrsonnet-stdlib" }
modifiedcrates/jrsonnet-rowan-parser/jsonnet.ungramdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/jsonnet.ungram
+++ b/crates/jrsonnet-rowan-parser/jsonnet.ungram
@@ -56,9 +56,7 @@
     (Expr (',' Expr)* ','?)?
     ']'
 ExprObject =
-    '{'
     ObjBody
-    '}'
 ExprArrayComp =
     '['
     Expr
@@ -168,6 +166,7 @@
     (name:Name '=')? Expr
 
 ObjBodyComp =
+    '{'
     pre:ObjLocalPostComma*
     '['
     key:LhsExpr
@@ -177,8 +176,11 @@
     value:Expr
     post:ObjLocalPreComma*
     CompSpec*
+    '}'
 ObjBodyMemberList =
+    '{'
     (Member (',' Member)* ','?)?
+    '}'
 ObjBody =
     ObjBodyComp
 |   ObjBodyMemberList
modifiedcrates/jrsonnet-rowan-parser/src/event.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/event.rs
+++ b/crates/jrsonnet-rowan-parser/src/event.rs
@@ -24,6 +24,10 @@
 	Token {
 		kind: SyntaxKind,
 	},
+	/// Push token, but do not eat anything,
+	VirtualToken {
+		kind: SyntaxKind,
+	},
 	/// Position of finished node
 	Finish {
 		/// Same as forward_parent of Start, but for wrapping
@@ -105,6 +109,13 @@
 					self.token(kind);
 					eat_start_whitespace = true;
 				}
+				Event::VirtualToken { kind } => {
+					if eat_start_whitespace {
+						self.skip_whitespace();
+					}
+					self.virtual_token(kind);
+					eat_start_whitespace = false;
+				}
 				Event::Finish { wrapper } => {
 					self.builder.finish_node();
 					depth -= 1;
@@ -124,7 +135,7 @@
 					}
 					eat_start_whitespace = true;
 				}
-				Event::Pending => panic!("placeholder should not end in events"),
+				Event::Pending => panic!("pending event should not appear in finished events"),
 				Event::Noop => {}
 				Event::Error(e) => {
 					self.errors.push(e);
@@ -137,6 +148,9 @@
 			errors: self.errors,
 		}
 	}
+	fn virtual_token(&mut self, kind: SyntaxKind) {
+		self.builder.token(JsonnetLanguage::kind_to_raw(kind), "")
+	}
 	fn token(&mut self, kind: SyntaxKind) {
 		let lexeme = self.lexemes[self.offset];
 		self.builder
modifiedcrates/jrsonnet-rowan-parser/src/generated/nodes.rsdiffbeforeafterboth
before · crates/jrsonnet-rowan-parser/src/generated/nodes.rs
1//! This is a generated file, please do not edit manually. Changes can be2//! made in codegeneration that lives in `xtask` top-level dir.34#![allow(non_snake_case, clippy::match_like_matches_macro)]5use crate::{6	ast::{support, AstChildren, AstNode, AstToken},7	SyntaxKind::{self, *},8	SyntaxNode, SyntaxToken, T,9};1011#[derive(Debug, Clone, PartialEq, Eq, Hash)]12pub struct SourceFile {13	pub(crate) syntax: SyntaxNode,14}15impl SourceFile {16	pub fn expr(&self) -> Option<Expr> {17		support::child(&self.syntax)18	}19}2021#[derive(Debug, Clone, PartialEq, Eq, Hash)]22pub struct ExprBinary {23	pub(crate) syntax: SyntaxNode,24}25impl ExprBinary {26	pub fn lhs(&self) -> Option<LhsExpr> {27		support::child(&self.syntax)28	}29	pub fn binary_operator(&self) -> Option<BinaryOperator> {30		support::token_child(&self.syntax)31	}32	pub fn rhs(&self) -> Option<Expr> {33		support::child(&self.syntax)34	}35}3637#[derive(Debug, Clone, PartialEq, Eq, Hash)]38pub struct LhsExpr {39	pub(crate) syntax: SyntaxNode,40}41impl LhsExpr {42	pub fn expr(&self) -> Option<Expr> {43		support::child(&self.syntax)44	}45}4647#[derive(Debug, Clone, PartialEq, Eq, Hash)]48pub struct ExprUnary {49	pub(crate) syntax: SyntaxNode,50}51impl ExprUnary {52	pub fn unary_operator(&self) -> Option<UnaryOperator> {53		support::token_child(&self.syntax)54	}55	pub fn rhs(&self) -> Option<Expr> {56		support::child(&self.syntax)57	}58}5960#[derive(Debug, Clone, PartialEq, Eq, Hash)]61pub struct ExprSlice {62	pub(crate) syntax: SyntaxNode,63}64impl ExprSlice {65	pub fn expr(&self) -> Option<Expr> {66		support::child(&self.syntax)67	}68	pub fn slice_desc(&self) -> Option<SliceDesc> {69		support::child(&self.syntax)70	}71}7273#[derive(Debug, Clone, PartialEq, Eq, Hash)]74pub struct SliceDesc {75	pub(crate) syntax: SyntaxNode,76}77impl SliceDesc {78	pub fn l_brack_token(&self) -> Option<SyntaxToken> {79		support::token(&self.syntax, T!['['])80	}81	pub fn from(&self) -> Option<Expr> {82		support::child(&self.syntax)83	}84	pub fn colon_token(&self) -> Option<SyntaxToken> {85		support::token(&self.syntax, T![:])86	}87	pub fn end(&self) -> Option<SliceDescEnd> {88		support::child(&self.syntax)89	}90	pub fn step(&self) -> Option<SliceDescStep> {91		support::child(&self.syntax)92	}93	pub fn r_brack_token(&self) -> Option<SyntaxToken> {94		support::token(&self.syntax, T![']'])95	}96}9798#[derive(Debug, Clone, PartialEq, Eq, Hash)]99pub struct ExprIndex {100	pub(crate) syntax: SyntaxNode,101}102impl ExprIndex {103	pub fn expr(&self) -> Option<Expr> {104		support::child(&self.syntax)105	}106	pub fn dot_token(&self) -> Option<SyntaxToken> {107		support::token(&self.syntax, T![.])108	}109	pub fn index(&self) -> Option<Name> {110		support::child(&self.syntax)111	}112}113114#[derive(Debug, Clone, PartialEq, Eq, Hash)]115pub struct Name {116	pub(crate) syntax: SyntaxNode,117}118impl Name {119	pub fn ident_lit(&self) -> Option<SyntaxToken> {120		support::token(&self.syntax, IDENT)121	}122}123124#[derive(Debug, Clone, PartialEq, Eq, Hash)]125pub struct ExprIndexExpr {126	pub(crate) syntax: SyntaxNode,127}128impl ExprIndexExpr {129	pub fn base(&self) -> Option<LhsExpr> {130		support::child(&self.syntax)131	}132	pub fn l_brack_token(&self) -> Option<SyntaxToken> {133		support::token(&self.syntax, T!['['])134	}135	pub fn index(&self) -> Option<Expr> {136		support::child(&self.syntax)137	}138	pub fn r_brack_token(&self) -> Option<SyntaxToken> {139		support::token(&self.syntax, T![']'])140	}141}142143#[derive(Debug, Clone, PartialEq, Eq, Hash)]144pub struct ExprApply {145	pub(crate) syntax: SyntaxNode,146}147impl ExprApply {148	pub fn expr(&self) -> Option<Expr> {149		support::child(&self.syntax)150	}151	pub fn args_desc(&self) -> Option<ArgsDesc> {152		support::child(&self.syntax)153	}154	pub fn tailstrict_kw_token(&self) -> Option<SyntaxToken> {155		support::token(&self.syntax, T![tailstrict])156	}157}158159#[derive(Debug, Clone, PartialEq, Eq, Hash)]160pub struct ArgsDesc {161	pub(crate) syntax: SyntaxNode,162}163impl ArgsDesc {164	pub fn l_paren_token(&self) -> Option<SyntaxToken> {165		support::token(&self.syntax, T!['('])166	}167	pub fn args(&self) -> AstChildren<Arg> {168		support::children(&self.syntax)169	}170	pub fn r_paren_token(&self) -> Option<SyntaxToken> {171		support::token(&self.syntax, T![')'])172	}173}174175#[derive(Debug, Clone, PartialEq, Eq, Hash)]176pub struct ExprObjExtend {177	pub(crate) syntax: SyntaxNode,178}179impl ExprObjExtend {180	pub fn lhs_expr(&self) -> Option<LhsExpr> {181		support::child(&self.syntax)182	}183	pub fn expr(&self) -> Option<Expr> {184		support::child(&self.syntax)185	}186}187188#[derive(Debug, Clone, PartialEq, Eq, Hash)]189pub struct ExprParened {190	pub(crate) syntax: SyntaxNode,191}192impl ExprParened {193	pub fn l_paren_token(&self) -> Option<SyntaxToken> {194		support::token(&self.syntax, T!['('])195	}196	pub fn expr(&self) -> Option<Expr> {197		support::child(&self.syntax)198	}199	pub fn r_paren_token(&self) -> Option<SyntaxToken> {200		support::token(&self.syntax, T![')'])201	}202}203204#[derive(Debug, Clone, PartialEq, Eq, Hash)]205pub struct ExprLiteral {206	pub(crate) syntax: SyntaxNode,207}208impl ExprLiteral {209	pub fn literal(&self) -> Option<Literal> {210		support::token_child(&self.syntax)211	}212}213214#[derive(Debug, Clone, PartialEq, Eq, Hash)]215pub struct ExprIntrinsicThisFile {216	pub(crate) syntax: SyntaxNode,217}218impl ExprIntrinsicThisFile {219	pub fn intrinsic_this_file_token(&self) -> Option<SyntaxToken> {220		support::token(&self.syntax, T!["$intrinsicThisFile"])221	}222}223224#[derive(Debug, Clone, PartialEq, Eq, Hash)]225pub struct ExprIntrinsicId {226	pub(crate) syntax: SyntaxNode,227}228impl ExprIntrinsicId {229	pub fn intrinsic_id_token(&self) -> Option<SyntaxToken> {230		support::token(&self.syntax, T!["$intrinsicId"])231	}232}233234#[derive(Debug, Clone, PartialEq, Eq, Hash)]235pub struct ExprIntrinsic {236	pub(crate) syntax: SyntaxNode,237}238impl ExprIntrinsic {239	pub fn intrinsic_token(&self) -> Option<SyntaxToken> {240		support::token(&self.syntax, T!["$intrinsic"])241	}242	pub fn l_paren_token(&self) -> Option<SyntaxToken> {243		support::token(&self.syntax, T!['('])244	}245	pub fn name(&self) -> Option<Name> {246		support::child(&self.syntax)247	}248	pub fn r_paren_token(&self) -> Option<SyntaxToken> {249		support::token(&self.syntax, T![')'])250	}251}252253#[derive(Debug, Clone, PartialEq, Eq, Hash)]254pub struct ExprString {255	pub(crate) syntax: SyntaxNode,256}257impl ExprString {258	pub fn text(&self) -> Option<Text> {259		support::token_child(&self.syntax)260	}261}262263#[derive(Debug, Clone, PartialEq, Eq, Hash)]264pub struct ExprNumber {265	pub(crate) syntax: SyntaxNode,266}267impl ExprNumber {268	pub fn number(&self) -> Option<Number> {269		support::token_child(&self.syntax)270	}271}272273#[derive(Debug, Clone, PartialEq, Eq, Hash)]274pub struct ExprArray {275	pub(crate) syntax: SyntaxNode,276}277impl ExprArray {278	pub fn l_brack_token(&self) -> Option<SyntaxToken> {279		support::token(&self.syntax, T!['['])280	}281	pub fn exprs(&self) -> AstChildren<Expr> {282		support::children(&self.syntax)283	}284	pub fn r_brack_token(&self) -> Option<SyntaxToken> {285		support::token(&self.syntax, T![']'])286	}287}288289#[derive(Debug, Clone, PartialEq, Eq, Hash)]290pub struct ExprObject {291	pub(crate) syntax: SyntaxNode,292}293impl ExprObject {294	pub fn l_brace_token(&self) -> Option<SyntaxToken> {295		support::token(&self.syntax, T!['{'])296	}297	pub fn obj_body(&self) -> Option<ObjBody> {298		support::child(&self.syntax)299	}300	pub fn r_brace_token(&self) -> Option<SyntaxToken> {301		support::token(&self.syntax, T!['}'])302	}303}304305#[derive(Debug, Clone, PartialEq, Eq, Hash)]306pub struct ExprArrayComp {307	pub(crate) syntax: SyntaxNode,308}309impl ExprArrayComp {310	pub fn l_brack_token(&self) -> Option<SyntaxToken> {311		support::token(&self.syntax, T!['['])312	}313	pub fn expr(&self) -> Option<Expr> {314		support::child(&self.syntax)315	}316	pub fn comma_token(&self) -> Option<SyntaxToken> {317		support::token(&self.syntax, T![,])318	}319	pub fn comp_specs(&self) -> AstChildren<CompSpec> {320		support::children(&self.syntax)321	}322	pub fn r_brack_token(&self) -> Option<SyntaxToken> {323		support::token(&self.syntax, T![']'])324	}325}326327#[derive(Debug, Clone, PartialEq, Eq, Hash)]328pub struct ExprImport {329	pub(crate) syntax: SyntaxNode,330}331impl ExprImport {332	pub fn import_kind(&self) -> Option<ImportKind> {333		support::token_child(&self.syntax)334	}335	pub fn text(&self) -> Option<Text> {336		support::token_child(&self.syntax)337	}338}339340#[derive(Debug, Clone, PartialEq, Eq, Hash)]341pub struct ExprVar {342	pub(crate) syntax: SyntaxNode,343}344impl ExprVar {345	pub fn name(&self) -> Option<Name> {346		support::child(&self.syntax)347	}348}349350#[derive(Debug, Clone, PartialEq, Eq, Hash)]351pub struct ExprLocal {352	pub(crate) syntax: SyntaxNode,353}354impl ExprLocal {355	pub fn local_kw_token(&self) -> Option<SyntaxToken> {356		support::token(&self.syntax, T![local])357	}358	pub fn binds(&self) -> AstChildren<Bind> {359		support::children(&self.syntax)360	}361	pub fn semi_token(&self) -> Option<SyntaxToken> {362		support::token(&self.syntax, T![;])363	}364	pub fn expr(&self) -> Option<Expr> {365		support::child(&self.syntax)366	}367}368369#[derive(Debug, Clone, PartialEq, Eq, Hash)]370pub struct ExprIfThenElse {371	pub(crate) syntax: SyntaxNode,372}373impl ExprIfThenElse {374	pub fn if_kw_token(&self) -> Option<SyntaxToken> {375		support::token(&self.syntax, T![if])376	}377	pub fn cond(&self) -> Option<Expr> {378		support::child(&self.syntax)379	}380	pub fn then_kw_token(&self) -> Option<SyntaxToken> {381		support::token(&self.syntax, T![then])382	}383	pub fn then(&self) -> Option<TrueExpr> {384		support::child(&self.syntax)385	}386	pub fn else_kw_token(&self) -> Option<SyntaxToken> {387		support::token(&self.syntax, T![else])388	}389	pub fn else_(&self) -> Option<FalseExpr> {390		support::child(&self.syntax)391	}392}393394#[derive(Debug, Clone, PartialEq, Eq, Hash)]395pub struct TrueExpr {396	pub(crate) syntax: SyntaxNode,397}398impl TrueExpr {399	pub fn expr(&self) -> Option<Expr> {400		support::child(&self.syntax)401	}402}403404#[derive(Debug, Clone, PartialEq, Eq, Hash)]405pub struct FalseExpr {406	pub(crate) syntax: SyntaxNode,407}408impl FalseExpr {409	pub fn expr(&self) -> Option<Expr> {410		support::child(&self.syntax)411	}412}413414#[derive(Debug, Clone, PartialEq, Eq, Hash)]415pub struct ExprFunction {416	pub(crate) syntax: SyntaxNode,417}418impl ExprFunction {419	pub fn function_kw_token(&self) -> Option<SyntaxToken> {420		support::token(&self.syntax, T![function])421	}422	pub fn l_paren_token(&self) -> Option<SyntaxToken> {423		support::token(&self.syntax, T!['('])424	}425	pub fn params_desc(&self) -> Option<ParamsDesc> {426		support::child(&self.syntax)427	}428	pub fn r_paren_token(&self) -> Option<SyntaxToken> {429		support::token(&self.syntax, T![')'])430	}431	pub fn expr(&self) -> Option<Expr> {432		support::child(&self.syntax)433	}434}435436#[derive(Debug, Clone, PartialEq, Eq, Hash)]437pub struct ParamsDesc {438	pub(crate) syntax: SyntaxNode,439}440impl ParamsDesc {441	pub fn l_paren_token(&self) -> Option<SyntaxToken> {442		support::token(&self.syntax, T!['('])443	}444	pub fn params(&self) -> AstChildren<Param> {445		support::children(&self.syntax)446	}447	pub fn r_paren_token(&self) -> Option<SyntaxToken> {448		support::token(&self.syntax, T![')'])449	}450}451452#[derive(Debug, Clone, PartialEq, Eq, Hash)]453pub struct ExprAssert {454	pub(crate) syntax: SyntaxNode,455}456impl ExprAssert {457	pub fn assertion(&self) -> Option<Assertion> {458		support::child(&self.syntax)459	}460	pub fn semi_token(&self) -> Option<SyntaxToken> {461		support::token(&self.syntax, T![;])462	}463	pub fn expr(&self) -> Option<Expr> {464		support::child(&self.syntax)465	}466}467468#[derive(Debug, Clone, PartialEq, Eq, Hash)]469pub struct Assertion {470	pub(crate) syntax: SyntaxNode,471}472impl Assertion {473	pub fn assert_kw_token(&self) -> Option<SyntaxToken> {474		support::token(&self.syntax, T![assert])475	}476	pub fn condition(&self) -> Option<LhsExpr> {477		support::child(&self.syntax)478	}479	pub fn colon_token(&self) -> Option<SyntaxToken> {480		support::token(&self.syntax, T![:])481	}482	pub fn message(&self) -> Option<Expr> {483		support::child(&self.syntax)484	}485}486487#[derive(Debug, Clone, PartialEq, Eq, Hash)]488pub struct ExprError {489	pub(crate) syntax: SyntaxNode,490}491impl ExprError {492	pub fn error_kw_token(&self) -> Option<SyntaxToken> {493		support::token(&self.syntax, T![error])494	}495	pub fn expr(&self) -> Option<Expr> {496		support::child(&self.syntax)497	}498}499500#[derive(Debug, Clone, PartialEq, Eq, Hash)]501pub struct SliceDescEnd {502	pub(crate) syntax: SyntaxNode,503}504impl SliceDescEnd {505	pub fn expr(&self) -> Option<Expr> {506		support::child(&self.syntax)507	}508}509510#[derive(Debug, Clone, PartialEq, Eq, Hash)]511pub struct SliceDescStep {512	pub(crate) syntax: SyntaxNode,513}514impl SliceDescStep {515	pub fn expr(&self) -> Option<Expr> {516		support::child(&self.syntax)517	}518}519520#[derive(Debug, Clone, PartialEq, Eq, Hash)]521pub struct Arg {522	pub(crate) syntax: SyntaxNode,523}524impl Arg {525	pub fn name(&self) -> Option<Name> {526		support::child(&self.syntax)527	}528	pub fn assign_token(&self) -> Option<SyntaxToken> {529		support::token(&self.syntax, T![=])530	}531	pub fn expr(&self) -> Option<Expr> {532		support::child(&self.syntax)533	}534}535536#[derive(Debug, Clone, PartialEq, Eq, Hash)]537pub struct ObjBodyComp {538	pub(crate) syntax: SyntaxNode,539}540impl ObjBodyComp {541	pub fn pre(&self) -> AstChildren<ObjLocalPostComma> {542		support::children(&self.syntax)543	}544	pub fn l_brack_token(&self) -> Option<SyntaxToken> {545		support::token(&self.syntax, T!['['])546	}547	pub fn key(&self) -> Option<LhsExpr> {548		support::child(&self.syntax)549	}550	pub fn r_brack_token(&self) -> Option<SyntaxToken> {551		support::token(&self.syntax, T![']'])552	}553	pub fn plus_token(&self) -> Option<SyntaxToken> {554		support::token(&self.syntax, T![+])555	}556	pub fn colon_token(&self) -> Option<SyntaxToken> {557		support::token(&self.syntax, T![:])558	}559	pub fn value(&self) -> Option<Expr> {560		support::child(&self.syntax)561	}562	pub fn post(&self) -> AstChildren<ObjLocalPreComma> {563		support::children(&self.syntax)564	}565	pub fn comp_specs(&self) -> AstChildren<CompSpec> {566		support::children(&self.syntax)567	}568}569570#[derive(Debug, Clone, PartialEq, Eq, Hash)]571pub struct ObjLocalPostComma {572	pub(crate) syntax: SyntaxNode,573}574impl ObjLocalPostComma {575	pub fn obj_local(&self) -> Option<ObjLocal> {576		support::child(&self.syntax)577	}578	pub fn comma_token(&self) -> Option<SyntaxToken> {579		support::token(&self.syntax, T![,])580	}581}582583#[derive(Debug, Clone, PartialEq, Eq, Hash)]584pub struct ObjLocalPreComma {585	pub(crate) syntax: SyntaxNode,586}587impl ObjLocalPreComma {588	pub fn comma_token(&self) -> Option<SyntaxToken> {589		support::token(&self.syntax, T![,])590	}591	pub fn obj_local(&self) -> Option<ObjLocal> {592		support::child(&self.syntax)593	}594}595596#[derive(Debug, Clone, PartialEq, Eq, Hash)]597pub struct ObjBodyMemberList {598	pub(crate) syntax: SyntaxNode,599}600impl ObjBodyMemberList {601	pub fn members(&self) -> AstChildren<Member> {602		support::children(&self.syntax)603	}604}605606#[derive(Debug, Clone, PartialEq, Eq, Hash)]607pub struct ObjLocal {608	pub(crate) syntax: SyntaxNode,609}610impl ObjLocal {611	pub fn local_kw_token(&self) -> Option<SyntaxToken> {612		support::token(&self.syntax, T![local])613	}614	pub fn bind(&self) -> Option<Bind> {615		support::child(&self.syntax)616	}617}618619#[derive(Debug, Clone, PartialEq, Eq, Hash)]620pub struct MemberBindStmt {621	pub(crate) syntax: SyntaxNode,622}623impl MemberBindStmt {624	pub fn obj_local(&self) -> Option<ObjLocal> {625		support::child(&self.syntax)626	}627}628629#[derive(Debug, Clone, PartialEq, Eq, Hash)]630pub struct MemberAssertStmt {631	pub(crate) syntax: SyntaxNode,632}633impl MemberAssertStmt {634	pub fn assertion(&self) -> Option<Assertion> {635		support::child(&self.syntax)636	}637}638639#[derive(Debug, Clone, PartialEq, Eq, Hash)]640pub struct MemberField {641	pub(crate) syntax: SyntaxNode,642}643impl MemberField {644	pub fn field(&self) -> Option<Field> {645		support::child(&self.syntax)646	}647}648649#[derive(Debug, Clone, PartialEq, Eq, Hash)]650pub struct FieldNormal {651	pub(crate) syntax: SyntaxNode,652}653impl FieldNormal {654	pub fn field_name(&self) -> Option<FieldName> {655		support::child(&self.syntax)656	}657	pub fn plus_token(&self) -> Option<SyntaxToken> {658		support::token(&self.syntax, T![+])659	}660	pub fn visibility(&self) -> Option<Visibility> {661		support::token_child(&self.syntax)662	}663	pub fn expr(&self) -> Option<Expr> {664		support::child(&self.syntax)665	}666}667668#[derive(Debug, Clone, PartialEq, Eq, Hash)]669pub struct FieldMethod {670	pub(crate) syntax: SyntaxNode,671}672impl FieldMethod {673	pub fn field_name(&self) -> Option<FieldName> {674		support::child(&self.syntax)675	}676	pub fn params_desc(&self) -> Option<ParamsDesc> {677		support::child(&self.syntax)678	}679	pub fn visibility(&self) -> Option<Visibility> {680		support::token_child(&self.syntax)681	}682	pub fn expr(&self) -> Option<Expr> {683		support::child(&self.syntax)684	}685}686687#[derive(Debug, Clone, PartialEq, Eq, Hash)]688pub struct FieldNameFixed {689	pub(crate) syntax: SyntaxNode,690}691impl FieldNameFixed {692	pub fn id(&self) -> Option<Name> {693		support::child(&self.syntax)694	}695	pub fn text(&self) -> Option<Text> {696		support::token_child(&self.syntax)697	}698}699700#[derive(Debug, Clone, PartialEq, Eq, Hash)]701pub struct FieldNameDynamic {702	pub(crate) syntax: SyntaxNode,703}704impl FieldNameDynamic {705	pub fn l_brack_token(&self) -> Option<SyntaxToken> {706		support::token(&self.syntax, T!['['])707	}708	pub fn expr(&self) -> Option<Expr> {709		support::child(&self.syntax)710	}711	pub fn r_brack_token(&self) -> Option<SyntaxToken> {712		support::token(&self.syntax, T![']'])713	}714}715716#[derive(Debug, Clone, PartialEq, Eq, Hash)]717pub struct ForSpec {718	pub(crate) syntax: SyntaxNode,719}720impl ForSpec {721	pub fn for_kw_token(&self) -> Option<SyntaxToken> {722		support::token(&self.syntax, T![for])723	}724	pub fn bind(&self) -> Option<Name> {725		support::child(&self.syntax)726	}727	pub fn in_kw_token(&self) -> Option<SyntaxToken> {728		support::token(&self.syntax, T![in])729	}730	pub fn expr(&self) -> Option<Expr> {731		support::child(&self.syntax)732	}733}734735#[derive(Debug, Clone, PartialEq, Eq, Hash)]736pub struct IfSpec {737	pub(crate) syntax: SyntaxNode,738}739impl IfSpec {740	pub fn if_kw_token(&self) -> Option<SyntaxToken> {741		support::token(&self.syntax, T![if])742	}743	pub fn expr(&self) -> Option<Expr> {744		support::child(&self.syntax)745	}746}747748#[derive(Debug, Clone, PartialEq, Eq, Hash)]749pub struct BindDestruct {750	pub(crate) syntax: SyntaxNode,751}752impl BindDestruct {753	pub fn into(&self) -> Option<Destruct> {754		support::child(&self.syntax)755	}756	pub fn assign_token(&self) -> Option<SyntaxToken> {757		support::token(&self.syntax, T![=])758	}759	pub fn value(&self) -> Option<Expr> {760		support::child(&self.syntax)761	}762}763764#[derive(Debug, Clone, PartialEq, Eq, Hash)]765pub struct BindFunction {766	pub(crate) syntax: SyntaxNode,767}768impl BindFunction {769	pub fn name(&self) -> Option<Name> {770		support::child(&self.syntax)771	}772	pub fn params(&self) -> Option<ParamsDesc> {773		support::child(&self.syntax)774	}775	pub fn assign_token(&self) -> Option<SyntaxToken> {776		support::token(&self.syntax, T![=])777	}778	pub fn value(&self) -> Option<Expr> {779		support::child(&self.syntax)780	}781}782783#[derive(Debug, Clone, PartialEq, Eq, Hash)]784pub struct Param {785	pub(crate) syntax: SyntaxNode,786}787impl Param {788	pub fn destruct(&self) -> Option<Destruct> {789		support::child(&self.syntax)790	}791	pub fn assign_token(&self) -> Option<SyntaxToken> {792		support::token(&self.syntax, T![=])793	}794	pub fn expr(&self) -> Option<Expr> {795		support::child(&self.syntax)796	}797}798799#[derive(Debug, Clone, PartialEq, Eq, Hash)]800pub struct DestructFull {801	pub(crate) syntax: SyntaxNode,802}803impl DestructFull {804	pub fn name(&self) -> Option<Name> {805		support::child(&self.syntax)806	}807}808809#[derive(Debug, Clone, PartialEq, Eq, Hash)]810pub struct DestructSkip {811	pub(crate) syntax: SyntaxNode,812}813impl DestructSkip {814	pub fn question_mark_token(&self) -> Option<SyntaxToken> {815		support::token(&self.syntax, T![?])816	}817}818819#[derive(Debug, Clone, PartialEq, Eq, Hash)]820pub struct DestructArray {821	pub(crate) syntax: SyntaxNode,822}823impl DestructArray {824	pub fn l_brack_token(&self) -> Option<SyntaxToken> {825		support::token(&self.syntax, T!['['])826	}827	pub fn destruct_array_parts(&self) -> AstChildren<DestructArrayPart> {828		support::children(&self.syntax)829	}830	pub fn r_brack_token(&self) -> Option<SyntaxToken> {831		support::token(&self.syntax, T![']'])832	}833}834835#[derive(Debug, Clone, PartialEq, Eq, Hash)]836pub struct DestructObject {837	pub(crate) syntax: SyntaxNode,838}839impl DestructObject {840	pub fn l_brace_token(&self) -> Option<SyntaxToken> {841		support::token(&self.syntax, T!['{'])842	}843	pub fn destruct_object_fields(&self) -> AstChildren<DestructObjectField> {844		support::children(&self.syntax)845	}846	pub fn destruct_rest(&self) -> Option<DestructRest> {847		support::child(&self.syntax)848	}849	pub fn comma_token(&self) -> Option<SyntaxToken> {850		support::token(&self.syntax, T![,])851	}852	pub fn r_brace_token(&self) -> Option<SyntaxToken> {853		support::token(&self.syntax, T!['}'])854	}855}856857#[derive(Debug, Clone, PartialEq, Eq, Hash)]858pub struct DestructObjectField {859	pub(crate) syntax: SyntaxNode,860}861impl DestructObjectField {862	pub fn field(&self) -> Option<Name> {863		support::child(&self.syntax)864	}865	pub fn colon_token(&self) -> Option<SyntaxToken> {866		support::token(&self.syntax, T![:])867	}868	pub fn destruct(&self) -> Option<Destruct> {869		support::child(&self.syntax)870	}871	pub fn assign_token(&self) -> Option<SyntaxToken> {872		support::token(&self.syntax, T![=])873	}874	pub fn expr(&self) -> Option<Expr> {875		support::child(&self.syntax)876	}877}878879#[derive(Debug, Clone, PartialEq, Eq, Hash)]880pub struct DestructRest {881	pub(crate) syntax: SyntaxNode,882}883impl DestructRest {884	pub fn dotdotdot_token(&self) -> Option<SyntaxToken> {885		support::token(&self.syntax, T![...])886	}887	pub fn into(&self) -> Option<Name> {888		support::child(&self.syntax)889	}890}891892#[derive(Debug, Clone, PartialEq, Eq, Hash)]893pub struct DestructArrayElement {894	pub(crate) syntax: SyntaxNode,895}896impl DestructArrayElement {897	pub fn destruct(&self) -> Option<Destruct> {898		support::child(&self.syntax)899	}900}901902#[derive(Debug, Clone, PartialEq, Eq, Hash)]903pub enum Expr {904	ExprBinary(ExprBinary),905	ExprUnary(ExprUnary),906	ExprSlice(ExprSlice),907	ExprIndex(ExprIndex),908	ExprIndexExpr(ExprIndexExpr),909	ExprApply(ExprApply),910	ExprObjExtend(ExprObjExtend),911	ExprParened(ExprParened),912	ExprIntrinsicThisFile(ExprIntrinsicThisFile),913	ExprIntrinsicId(ExprIntrinsicId),914	ExprIntrinsic(ExprIntrinsic),915	ExprString(ExprString),916	ExprNumber(ExprNumber),917	ExprLiteral(ExprLiteral),918	ExprArray(ExprArray),919	ExprObject(ExprObject),920	ExprArrayComp(ExprArrayComp),921	ExprImport(ExprImport),922	ExprVar(ExprVar),923	ExprLocal(ExprLocal),924	ExprIfThenElse(ExprIfThenElse),925	ExprFunction(ExprFunction),926	ExprAssert(ExprAssert),927	ExprError(ExprError),928}929930#[derive(Debug, Clone, PartialEq, Eq, Hash)]931pub enum ObjBody {932	ObjBodyComp(ObjBodyComp),933	ObjBodyMemberList(ObjBodyMemberList),934}935936#[derive(Debug, Clone, PartialEq, Eq, Hash)]937pub enum CompSpec {938	ForSpec(ForSpec),939	IfSpec(IfSpec),940}941942#[derive(Debug, Clone, PartialEq, Eq, Hash)]943pub enum Bind {944	BindDestruct(BindDestruct),945	BindFunction(BindFunction),946}947948#[derive(Debug, Clone, PartialEq, Eq, Hash)]949pub enum Member {950	MemberBindStmt(MemberBindStmt),951	MemberAssertStmt(MemberAssertStmt),952	MemberField(MemberField),953}954955#[derive(Debug, Clone, PartialEq, Eq, Hash)]956pub enum Field {957	FieldNormal(FieldNormal),958	FieldMethod(FieldMethod),959}960961#[derive(Debug, Clone, PartialEq, Eq, Hash)]962pub enum FieldName {963	FieldNameFixed(FieldNameFixed),964	FieldNameDynamic(FieldNameDynamic),965}966967#[derive(Debug, Clone, PartialEq, Eq, Hash)]968pub enum Destruct {969	DestructFull(DestructFull),970	DestructSkip(DestructSkip),971	DestructArray(DestructArray),972	DestructObject(DestructObject),973}974975#[derive(Debug, Clone, PartialEq, Eq, Hash)]976pub enum DestructArrayPart {977	DestructArrayElement(DestructArrayElement),978	DestructRest(DestructRest),979}980981#[derive(Debug, Clone, PartialEq, Eq, Hash)]982pub struct BinaryOperator {983	syntax: SyntaxToken,984	kind: BinaryOperatorKind,985}986987#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]988pub enum BinaryOperatorKind {989	Or,990	And,991	BitOr,992	BitXor,993	BitAnd,994	Eq,995	Ne,996	Lt,997	Gt,998	Le,999	Ge,1000	InKw,1001	Lhs,1002	Rhs,1003	Plus,1004	Minus,1005	Mul,1006	Div,1007	Modulo,1008	MetaObjectApply,1009	ErrorNoOperator,1010}10111012#[derive(Debug, Clone, PartialEq, Eq, Hash)]1013pub struct UnaryOperator {1014	syntax: SyntaxToken,1015	kind: UnaryOperatorKind,1016}10171018#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1019pub enum UnaryOperatorKind {1020	Minus,1021	Not,1022	BitNot,1023}10241025#[derive(Debug, Clone, PartialEq, Eq, Hash)]1026pub struct Literal {1027	syntax: SyntaxToken,1028	kind: LiteralKind,1029}10301031#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1032pub enum LiteralKind {1033	NullKw,1034	TrueKw,1035	FalseKw,1036	SelfKw,1037	Dollar,1038	SuperKw,1039}10401041#[derive(Debug, Clone, PartialEq, Eq, Hash)]1042pub struct Text {1043	syntax: SyntaxToken,1044	kind: TextKind,1045}10461047#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1048pub enum TextKind {1049	StringDouble,1050	ErrorStringDoubleUnterminated,1051	StringSingle,1052	ErrorStringSingleUnterminated,1053	StringDoubleVerbatim,1054	ErrorStringDoubleVerbatimUnterminated,1055	StringSingleVerbatim,1056	ErrorStringSingleVerbatimUnterminated,1057	ErrorStringVerbatimMissingQuotes,1058	StringBlock,1059	ErrorStringBlockUnexpectedEnd,1060	ErrorStringBlockMissingNewLine,1061	ErrorStringBlockMissingTermination,1062	ErrorStringBlockMissingIndent,1063}10641065#[derive(Debug, Clone, PartialEq, Eq, Hash)]1066pub struct Number {1067	syntax: SyntaxToken,1068	kind: NumberKind,1069}10701071#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1072pub enum NumberKind {1073	Float,1074	ErrorFloatJunkAfterPoint,1075	ErrorFloatJunkAfterExponent,1076	ErrorFloatJunkAfterExponentSign,1077}10781079#[derive(Debug, Clone, PartialEq, Eq, Hash)]1080pub struct ImportKind {1081	syntax: SyntaxToken,1082	kind: ImportKindKind,1083}10841085#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1086pub enum ImportKindKind {1087	ImportstrKw,1088	ImportbinKw,1089	ImportKw,1090}10911092#[derive(Debug, Clone, PartialEq, Eq, Hash)]1093pub struct Visibility {1094	syntax: SyntaxToken,1095	kind: VisibilityKind,1096}10971098#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1099pub enum VisibilityKind {1100	Coloncoloncolon,1101	Coloncolon,1102	Colon,1103}11041105#[derive(Debug, Clone, PartialEq, Eq, Hash)]1106pub struct Trivia {1107	syntax: SyntaxToken,1108	kind: TriviaKind,1109}11101111#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]1112pub enum TriviaKind {1113	Whitespace,1114	MultiLineComment,1115	ErrorCommentTooShort,1116	ErrorCommentUnterminated,1117	SingleLineHashComment,1118	SingleLineSlashComment,1119}1120impl AstNode for SourceFile {1121	fn can_cast(kind: SyntaxKind) -> bool {1122		kind == SOURCE_FILE1123	}1124	fn cast(syntax: SyntaxNode) -> Option<Self> {1125		if Self::can_cast(syntax.kind()) {1126			Some(Self { syntax })1127		} else {1128			None1129		}1130	}1131	fn syntax(&self) -> &SyntaxNode {1132		&self.syntax1133	}1134}1135impl AstNode for ExprBinary {1136	fn can_cast(kind: SyntaxKind) -> bool {1137		kind == EXPR_BINARY1138	}1139	fn cast(syntax: SyntaxNode) -> Option<Self> {1140		if Self::can_cast(syntax.kind()) {1141			Some(Self { syntax })1142		} else {1143			None1144		}1145	}1146	fn syntax(&self) -> &SyntaxNode {1147		&self.syntax1148	}1149}1150impl AstNode for LhsExpr {1151	fn can_cast(kind: SyntaxKind) -> bool {1152		kind == LHS_EXPR1153	}1154	fn cast(syntax: SyntaxNode) -> Option<Self> {1155		if Self::can_cast(syntax.kind()) {1156			Some(Self { syntax })1157		} else {1158			None1159		}1160	}1161	fn syntax(&self) -> &SyntaxNode {1162		&self.syntax1163	}1164}1165impl AstNode for ExprUnary {1166	fn can_cast(kind: SyntaxKind) -> bool {1167		kind == EXPR_UNARY1168	}1169	fn cast(syntax: SyntaxNode) -> Option<Self> {1170		if Self::can_cast(syntax.kind()) {1171			Some(Self { syntax })1172		} else {1173			None1174		}1175	}1176	fn syntax(&self) -> &SyntaxNode {1177		&self.syntax1178	}1179}1180impl AstNode for ExprSlice {1181	fn can_cast(kind: SyntaxKind) -> bool {1182		kind == EXPR_SLICE1183	}1184	fn cast(syntax: SyntaxNode) -> Option<Self> {1185		if Self::can_cast(syntax.kind()) {1186			Some(Self { syntax })1187		} else {1188			None1189		}1190	}1191	fn syntax(&self) -> &SyntaxNode {1192		&self.syntax1193	}1194}1195impl AstNode for SliceDesc {1196	fn can_cast(kind: SyntaxKind) -> bool {1197		kind == SLICE_DESC1198	}1199	fn cast(syntax: SyntaxNode) -> Option<Self> {1200		if Self::can_cast(syntax.kind()) {1201			Some(Self { syntax })1202		} else {1203			None1204		}1205	}1206	fn syntax(&self) -> &SyntaxNode {1207		&self.syntax1208	}1209}1210impl AstNode for ExprIndex {1211	fn can_cast(kind: SyntaxKind) -> bool {1212		kind == EXPR_INDEX1213	}1214	fn cast(syntax: SyntaxNode) -> Option<Self> {1215		if Self::can_cast(syntax.kind()) {1216			Some(Self { syntax })1217		} else {1218			None1219		}1220	}1221	fn syntax(&self) -> &SyntaxNode {1222		&self.syntax1223	}1224}1225impl AstNode for Name {1226	fn can_cast(kind: SyntaxKind) -> bool {1227		kind == NAME1228	}1229	fn cast(syntax: SyntaxNode) -> Option<Self> {1230		if Self::can_cast(syntax.kind()) {1231			Some(Self { syntax })1232		} else {1233			None1234		}1235	}1236	fn syntax(&self) -> &SyntaxNode {1237		&self.syntax1238	}1239}1240impl AstNode for ExprIndexExpr {1241	fn can_cast(kind: SyntaxKind) -> bool {1242		kind == EXPR_INDEX_EXPR1243	}1244	fn cast(syntax: SyntaxNode) -> Option<Self> {1245		if Self::can_cast(syntax.kind()) {1246			Some(Self { syntax })1247		} else {1248			None1249		}1250	}1251	fn syntax(&self) -> &SyntaxNode {1252		&self.syntax1253	}1254}1255impl AstNode for ExprApply {1256	fn can_cast(kind: SyntaxKind) -> bool {1257		kind == EXPR_APPLY1258	}1259	fn cast(syntax: SyntaxNode) -> Option<Self> {1260		if Self::can_cast(syntax.kind()) {1261			Some(Self { syntax })1262		} else {1263			None1264		}1265	}1266	fn syntax(&self) -> &SyntaxNode {1267		&self.syntax1268	}1269}1270impl AstNode for ArgsDesc {1271	fn can_cast(kind: SyntaxKind) -> bool {1272		kind == ARGS_DESC1273	}1274	fn cast(syntax: SyntaxNode) -> Option<Self> {1275		if Self::can_cast(syntax.kind()) {1276			Some(Self { syntax })1277		} else {1278			None1279		}1280	}1281	fn syntax(&self) -> &SyntaxNode {1282		&self.syntax1283	}1284}1285impl AstNode for ExprObjExtend {1286	fn can_cast(kind: SyntaxKind) -> bool {1287		kind == EXPR_OBJ_EXTEND1288	}1289	fn cast(syntax: SyntaxNode) -> Option<Self> {1290		if Self::can_cast(syntax.kind()) {1291			Some(Self { syntax })1292		} else {1293			None1294		}1295	}1296	fn syntax(&self) -> &SyntaxNode {1297		&self.syntax1298	}1299}1300impl AstNode for ExprParened {1301	fn can_cast(kind: SyntaxKind) -> bool {1302		kind == EXPR_PARENED1303	}1304	fn cast(syntax: SyntaxNode) -> Option<Self> {1305		if Self::can_cast(syntax.kind()) {1306			Some(Self { syntax })1307		} else {1308			None1309		}1310	}1311	fn syntax(&self) -> &SyntaxNode {1312		&self.syntax1313	}1314}1315impl AstNode for ExprLiteral {1316	fn can_cast(kind: SyntaxKind) -> bool {1317		kind == EXPR_LITERAL1318	}1319	fn cast(syntax: SyntaxNode) -> Option<Self> {1320		if Self::can_cast(syntax.kind()) {1321			Some(Self { syntax })1322		} else {1323			None1324		}1325	}1326	fn syntax(&self) -> &SyntaxNode {1327		&self.syntax1328	}1329}1330impl AstNode for ExprIntrinsicThisFile {1331	fn can_cast(kind: SyntaxKind) -> bool {1332		kind == EXPR_INTRINSIC_THIS_FILE1333	}1334	fn cast(syntax: SyntaxNode) -> Option<Self> {1335		if Self::can_cast(syntax.kind()) {1336			Some(Self { syntax })1337		} else {1338			None1339		}1340	}1341	fn syntax(&self) -> &SyntaxNode {1342		&self.syntax1343	}1344}1345impl AstNode for ExprIntrinsicId {1346	fn can_cast(kind: SyntaxKind) -> bool {1347		kind == EXPR_INTRINSIC_ID1348	}1349	fn cast(syntax: SyntaxNode) -> Option<Self> {1350		if Self::can_cast(syntax.kind()) {1351			Some(Self { syntax })1352		} else {1353			None1354		}1355	}1356	fn syntax(&self) -> &SyntaxNode {1357		&self.syntax1358	}1359}1360impl AstNode for ExprIntrinsic {1361	fn can_cast(kind: SyntaxKind) -> bool {1362		kind == EXPR_INTRINSIC1363	}1364	fn cast(syntax: SyntaxNode) -> Option<Self> {1365		if Self::can_cast(syntax.kind()) {1366			Some(Self { syntax })1367		} else {1368			None1369		}1370	}1371	fn syntax(&self) -> &SyntaxNode {1372		&self.syntax1373	}1374}1375impl AstNode for ExprString {1376	fn can_cast(kind: SyntaxKind) -> bool {1377		kind == EXPR_STRING1378	}1379	fn cast(syntax: SyntaxNode) -> Option<Self> {1380		if Self::can_cast(syntax.kind()) {1381			Some(Self { syntax })1382		} else {1383			None1384		}1385	}1386	fn syntax(&self) -> &SyntaxNode {1387		&self.syntax1388	}1389}1390impl AstNode for ExprNumber {1391	fn can_cast(kind: SyntaxKind) -> bool {1392		kind == EXPR_NUMBER1393	}1394	fn cast(syntax: SyntaxNode) -> Option<Self> {1395		if Self::can_cast(syntax.kind()) {1396			Some(Self { syntax })1397		} else {1398			None1399		}1400	}1401	fn syntax(&self) -> &SyntaxNode {1402		&self.syntax1403	}1404}1405impl AstNode for ExprArray {1406	fn can_cast(kind: SyntaxKind) -> bool {1407		kind == EXPR_ARRAY1408	}1409	fn cast(syntax: SyntaxNode) -> Option<Self> {1410		if Self::can_cast(syntax.kind()) {1411			Some(Self { syntax })1412		} else {1413			None1414		}1415	}1416	fn syntax(&self) -> &SyntaxNode {1417		&self.syntax1418	}1419}1420impl AstNode for ExprObject {1421	fn can_cast(kind: SyntaxKind) -> bool {1422		kind == EXPR_OBJECT1423	}1424	fn cast(syntax: SyntaxNode) -> Option<Self> {1425		if Self::can_cast(syntax.kind()) {1426			Some(Self { syntax })1427		} else {1428			None1429		}1430	}1431	fn syntax(&self) -> &SyntaxNode {1432		&self.syntax1433	}1434}1435impl AstNode for ExprArrayComp {1436	fn can_cast(kind: SyntaxKind) -> bool {1437		kind == EXPR_ARRAY_COMP1438	}1439	fn cast(syntax: SyntaxNode) -> Option<Self> {1440		if Self::can_cast(syntax.kind()) {1441			Some(Self { syntax })1442		} else {1443			None1444		}1445	}1446	fn syntax(&self) -> &SyntaxNode {1447		&self.syntax1448	}1449}1450impl AstNode for ExprImport {1451	fn can_cast(kind: SyntaxKind) -> bool {1452		kind == EXPR_IMPORT1453	}1454	fn cast(syntax: SyntaxNode) -> Option<Self> {1455		if Self::can_cast(syntax.kind()) {1456			Some(Self { syntax })1457		} else {1458			None1459		}1460	}1461	fn syntax(&self) -> &SyntaxNode {1462		&self.syntax1463	}1464}1465impl AstNode for ExprVar {1466	fn can_cast(kind: SyntaxKind) -> bool {1467		kind == EXPR_VAR1468	}1469	fn cast(syntax: SyntaxNode) -> Option<Self> {1470		if Self::can_cast(syntax.kind()) {1471			Some(Self { syntax })1472		} else {1473			None1474		}1475	}1476	fn syntax(&self) -> &SyntaxNode {1477		&self.syntax1478	}1479}1480impl AstNode for ExprLocal {1481	fn can_cast(kind: SyntaxKind) -> bool {1482		kind == EXPR_LOCAL1483	}1484	fn cast(syntax: SyntaxNode) -> Option<Self> {1485		if Self::can_cast(syntax.kind()) {1486			Some(Self { syntax })1487		} else {1488			None1489		}1490	}1491	fn syntax(&self) -> &SyntaxNode {1492		&self.syntax1493	}1494}1495impl AstNode for ExprIfThenElse {1496	fn can_cast(kind: SyntaxKind) -> bool {1497		kind == EXPR_IF_THEN_ELSE1498	}1499	fn cast(syntax: SyntaxNode) -> Option<Self> {1500		if Self::can_cast(syntax.kind()) {1501			Some(Self { syntax })1502		} else {1503			None1504		}1505	}1506	fn syntax(&self) -> &SyntaxNode {1507		&self.syntax1508	}1509}1510impl AstNode for TrueExpr {1511	fn can_cast(kind: SyntaxKind) -> bool {1512		kind == TRUE_EXPR1513	}1514	fn cast(syntax: SyntaxNode) -> Option<Self> {1515		if Self::can_cast(syntax.kind()) {1516			Some(Self { syntax })1517		} else {1518			None1519		}1520	}1521	fn syntax(&self) -> &SyntaxNode {1522		&self.syntax1523	}1524}1525impl AstNode for FalseExpr {1526	fn can_cast(kind: SyntaxKind) -> bool {1527		kind == FALSE_EXPR1528	}1529	fn cast(syntax: SyntaxNode) -> Option<Self> {1530		if Self::can_cast(syntax.kind()) {1531			Some(Self { syntax })1532		} else {1533			None1534		}1535	}1536	fn syntax(&self) -> &SyntaxNode {1537		&self.syntax1538	}1539}1540impl AstNode for ExprFunction {1541	fn can_cast(kind: SyntaxKind) -> bool {1542		kind == EXPR_FUNCTION1543	}1544	fn cast(syntax: SyntaxNode) -> Option<Self> {1545		if Self::can_cast(syntax.kind()) {1546			Some(Self { syntax })1547		} else {1548			None1549		}1550	}1551	fn syntax(&self) -> &SyntaxNode {1552		&self.syntax1553	}1554}1555impl AstNode for ParamsDesc {1556	fn can_cast(kind: SyntaxKind) -> bool {1557		kind == PARAMS_DESC1558	}1559	fn cast(syntax: SyntaxNode) -> Option<Self> {1560		if Self::can_cast(syntax.kind()) {1561			Some(Self { syntax })1562		} else {1563			None1564		}1565	}1566	fn syntax(&self) -> &SyntaxNode {1567		&self.syntax1568	}1569}1570impl AstNode for ExprAssert {1571	fn can_cast(kind: SyntaxKind) -> bool {1572		kind == EXPR_ASSERT1573	}1574	fn cast(syntax: SyntaxNode) -> Option<Self> {1575		if Self::can_cast(syntax.kind()) {1576			Some(Self { syntax })1577		} else {1578			None1579		}1580	}1581	fn syntax(&self) -> &SyntaxNode {1582		&self.syntax1583	}1584}1585impl AstNode for Assertion {1586	fn can_cast(kind: SyntaxKind) -> bool {1587		kind == ASSERTION1588	}1589	fn cast(syntax: SyntaxNode) -> Option<Self> {1590		if Self::can_cast(syntax.kind()) {1591			Some(Self { syntax })1592		} else {1593			None1594		}1595	}1596	fn syntax(&self) -> &SyntaxNode {1597		&self.syntax1598	}1599}1600impl AstNode for ExprError {1601	fn can_cast(kind: SyntaxKind) -> bool {1602		kind == EXPR_ERROR1603	}1604	fn cast(syntax: SyntaxNode) -> Option<Self> {1605		if Self::can_cast(syntax.kind()) {1606			Some(Self { syntax })1607		} else {1608			None1609		}1610	}1611	fn syntax(&self) -> &SyntaxNode {1612		&self.syntax1613	}1614}1615impl AstNode for SliceDescEnd {1616	fn can_cast(kind: SyntaxKind) -> bool {1617		kind == SLICE_DESC_END1618	}1619	fn cast(syntax: SyntaxNode) -> Option<Self> {1620		if Self::can_cast(syntax.kind()) {1621			Some(Self { syntax })1622		} else {1623			None1624		}1625	}1626	fn syntax(&self) -> &SyntaxNode {1627		&self.syntax1628	}1629}1630impl AstNode for SliceDescStep {1631	fn can_cast(kind: SyntaxKind) -> bool {1632		kind == SLICE_DESC_STEP1633	}1634	fn cast(syntax: SyntaxNode) -> Option<Self> {1635		if Self::can_cast(syntax.kind()) {1636			Some(Self { syntax })1637		} else {1638			None1639		}1640	}1641	fn syntax(&self) -> &SyntaxNode {1642		&self.syntax1643	}1644}1645impl AstNode for Arg {1646	fn can_cast(kind: SyntaxKind) -> bool {1647		kind == ARG1648	}1649	fn cast(syntax: SyntaxNode) -> Option<Self> {1650		if Self::can_cast(syntax.kind()) {1651			Some(Self { syntax })1652		} else {1653			None1654		}1655	}1656	fn syntax(&self) -> &SyntaxNode {1657		&self.syntax1658	}1659}1660impl AstNode for ObjBodyComp {1661	fn can_cast(kind: SyntaxKind) -> bool {1662		kind == OBJ_BODY_COMP1663	}1664	fn cast(syntax: SyntaxNode) -> Option<Self> {1665		if Self::can_cast(syntax.kind()) {1666			Some(Self { syntax })1667		} else {1668			None1669		}1670	}1671	fn syntax(&self) -> &SyntaxNode {1672		&self.syntax1673	}1674}1675impl AstNode for ObjLocalPostComma {1676	fn can_cast(kind: SyntaxKind) -> bool {1677		kind == OBJ_LOCAL_POST_COMMA1678	}1679	fn cast(syntax: SyntaxNode) -> Option<Self> {1680		if Self::can_cast(syntax.kind()) {1681			Some(Self { syntax })1682		} else {1683			None1684		}1685	}1686	fn syntax(&self) -> &SyntaxNode {1687		&self.syntax1688	}1689}1690impl AstNode for ObjLocalPreComma {1691	fn can_cast(kind: SyntaxKind) -> bool {1692		kind == OBJ_LOCAL_PRE_COMMA1693	}1694	fn cast(syntax: SyntaxNode) -> Option<Self> {1695		if Self::can_cast(syntax.kind()) {1696			Some(Self { syntax })1697		} else {1698			None1699		}1700	}1701	fn syntax(&self) -> &SyntaxNode {1702		&self.syntax1703	}1704}1705impl AstNode for ObjBodyMemberList {1706	fn can_cast(kind: SyntaxKind) -> bool {1707		kind == OBJ_BODY_MEMBER_LIST1708	}1709	fn cast(syntax: SyntaxNode) -> Option<Self> {1710		if Self::can_cast(syntax.kind()) {1711			Some(Self { syntax })1712		} else {1713			None1714		}1715	}1716	fn syntax(&self) -> &SyntaxNode {1717		&self.syntax1718	}1719}1720impl AstNode for ObjLocal {1721	fn can_cast(kind: SyntaxKind) -> bool {1722		kind == OBJ_LOCAL1723	}1724	fn cast(syntax: SyntaxNode) -> Option<Self> {1725		if Self::can_cast(syntax.kind()) {1726			Some(Self { syntax })1727		} else {1728			None1729		}1730	}1731	fn syntax(&self) -> &SyntaxNode {1732		&self.syntax1733	}1734}1735impl AstNode for MemberBindStmt {1736	fn can_cast(kind: SyntaxKind) -> bool {1737		kind == MEMBER_BIND_STMT1738	}1739	fn cast(syntax: SyntaxNode) -> Option<Self> {1740		if Self::can_cast(syntax.kind()) {1741			Some(Self { syntax })1742		} else {1743			None1744		}1745	}1746	fn syntax(&self) -> &SyntaxNode {1747		&self.syntax1748	}1749}1750impl AstNode for MemberAssertStmt {1751	fn can_cast(kind: SyntaxKind) -> bool {1752		kind == MEMBER_ASSERT_STMT1753	}1754	fn cast(syntax: SyntaxNode) -> Option<Self> {1755		if Self::can_cast(syntax.kind()) {1756			Some(Self { syntax })1757		} else {1758			None1759		}1760	}1761	fn syntax(&self) -> &SyntaxNode {1762		&self.syntax1763	}1764}1765impl AstNode for MemberField {1766	fn can_cast(kind: SyntaxKind) -> bool {1767		kind == MEMBER_FIELD1768	}1769	fn cast(syntax: SyntaxNode) -> Option<Self> {1770		if Self::can_cast(syntax.kind()) {1771			Some(Self { syntax })1772		} else {1773			None1774		}1775	}1776	fn syntax(&self) -> &SyntaxNode {1777		&self.syntax1778	}1779}1780impl AstNode for FieldNormal {1781	fn can_cast(kind: SyntaxKind) -> bool {1782		kind == FIELD_NORMAL1783	}1784	fn cast(syntax: SyntaxNode) -> Option<Self> {1785		if Self::can_cast(syntax.kind()) {1786			Some(Self { syntax })1787		} else {1788			None1789		}1790	}1791	fn syntax(&self) -> &SyntaxNode {1792		&self.syntax1793	}1794}1795impl AstNode for FieldMethod {1796	fn can_cast(kind: SyntaxKind) -> bool {1797		kind == FIELD_METHOD1798	}1799	fn cast(syntax: SyntaxNode) -> Option<Self> {1800		if Self::can_cast(syntax.kind()) {1801			Some(Self { syntax })1802		} else {1803			None1804		}1805	}1806	fn syntax(&self) -> &SyntaxNode {1807		&self.syntax1808	}1809}1810impl AstNode for FieldNameFixed {1811	fn can_cast(kind: SyntaxKind) -> bool {1812		kind == FIELD_NAME_FIXED1813	}1814	fn cast(syntax: SyntaxNode) -> Option<Self> {1815		if Self::can_cast(syntax.kind()) {1816			Some(Self { syntax })1817		} else {1818			None1819		}1820	}1821	fn syntax(&self) -> &SyntaxNode {1822		&self.syntax1823	}1824}1825impl AstNode for FieldNameDynamic {1826	fn can_cast(kind: SyntaxKind) -> bool {1827		kind == FIELD_NAME_DYNAMIC1828	}1829	fn cast(syntax: SyntaxNode) -> Option<Self> {1830		if Self::can_cast(syntax.kind()) {1831			Some(Self { syntax })1832		} else {1833			None1834		}1835	}1836	fn syntax(&self) -> &SyntaxNode {1837		&self.syntax1838	}1839}1840impl AstNode for ForSpec {1841	fn can_cast(kind: SyntaxKind) -> bool {1842		kind == FOR_SPEC1843	}1844	fn cast(syntax: SyntaxNode) -> Option<Self> {1845		if Self::can_cast(syntax.kind()) {1846			Some(Self { syntax })1847		} else {1848			None1849		}1850	}1851	fn syntax(&self) -> &SyntaxNode {1852		&self.syntax1853	}1854}1855impl AstNode for IfSpec {1856	fn can_cast(kind: SyntaxKind) -> bool {1857		kind == IF_SPEC1858	}1859	fn cast(syntax: SyntaxNode) -> Option<Self> {1860		if Self::can_cast(syntax.kind()) {1861			Some(Self { syntax })1862		} else {1863			None1864		}1865	}1866	fn syntax(&self) -> &SyntaxNode {1867		&self.syntax1868	}1869}1870impl AstNode for BindDestruct {1871	fn can_cast(kind: SyntaxKind) -> bool {1872		kind == BIND_DESTRUCT1873	}1874	fn cast(syntax: SyntaxNode) -> Option<Self> {1875		if Self::can_cast(syntax.kind()) {1876			Some(Self { syntax })1877		} else {1878			None1879		}1880	}1881	fn syntax(&self) -> &SyntaxNode {1882		&self.syntax1883	}1884}1885impl AstNode for BindFunction {1886	fn can_cast(kind: SyntaxKind) -> bool {1887		kind == BIND_FUNCTION1888	}1889	fn cast(syntax: SyntaxNode) -> Option<Self> {1890		if Self::can_cast(syntax.kind()) {1891			Some(Self { syntax })1892		} else {1893			None1894		}1895	}1896	fn syntax(&self) -> &SyntaxNode {1897		&self.syntax1898	}1899}1900impl AstNode for Param {1901	fn can_cast(kind: SyntaxKind) -> bool {1902		kind == PARAM1903	}1904	fn cast(syntax: SyntaxNode) -> Option<Self> {1905		if Self::can_cast(syntax.kind()) {1906			Some(Self { syntax })1907		} else {1908			None1909		}1910	}1911	fn syntax(&self) -> &SyntaxNode {1912		&self.syntax1913	}1914}1915impl AstNode for DestructFull {1916	fn can_cast(kind: SyntaxKind) -> bool {1917		kind == DESTRUCT_FULL1918	}1919	fn cast(syntax: SyntaxNode) -> Option<Self> {1920		if Self::can_cast(syntax.kind()) {1921			Some(Self { syntax })1922		} else {1923			None1924		}1925	}1926	fn syntax(&self) -> &SyntaxNode {1927		&self.syntax1928	}1929}1930impl AstNode for DestructSkip {1931	fn can_cast(kind: SyntaxKind) -> bool {1932		kind == DESTRUCT_SKIP1933	}1934	fn cast(syntax: SyntaxNode) -> Option<Self> {1935		if Self::can_cast(syntax.kind()) {1936			Some(Self { syntax })1937		} else {1938			None1939		}1940	}1941	fn syntax(&self) -> &SyntaxNode {1942		&self.syntax1943	}1944}1945impl AstNode for DestructArray {1946	fn can_cast(kind: SyntaxKind) -> bool {1947		kind == DESTRUCT_ARRAY1948	}1949	fn cast(syntax: SyntaxNode) -> Option<Self> {1950		if Self::can_cast(syntax.kind()) {1951			Some(Self { syntax })1952		} else {1953			None1954		}1955	}1956	fn syntax(&self) -> &SyntaxNode {1957		&self.syntax1958	}1959}1960impl AstNode for DestructObject {1961	fn can_cast(kind: SyntaxKind) -> bool {1962		kind == DESTRUCT_OBJECT1963	}1964	fn cast(syntax: SyntaxNode) -> Option<Self> {1965		if Self::can_cast(syntax.kind()) {1966			Some(Self { syntax })1967		} else {1968			None1969		}1970	}1971	fn syntax(&self) -> &SyntaxNode {1972		&self.syntax1973	}1974}1975impl AstNode for DestructObjectField {1976	fn can_cast(kind: SyntaxKind) -> bool {1977		kind == DESTRUCT_OBJECT_FIELD1978	}1979	fn cast(syntax: SyntaxNode) -> Option<Self> {1980		if Self::can_cast(syntax.kind()) {1981			Some(Self { syntax })1982		} else {1983			None1984		}1985	}1986	fn syntax(&self) -> &SyntaxNode {1987		&self.syntax1988	}1989}1990impl AstNode for DestructRest {1991	fn can_cast(kind: SyntaxKind) -> bool {1992		kind == DESTRUCT_REST1993	}1994	fn cast(syntax: SyntaxNode) -> Option<Self> {1995		if Self::can_cast(syntax.kind()) {1996			Some(Self { syntax })1997		} else {1998			None1999		}2000	}2001	fn syntax(&self) -> &SyntaxNode {2002		&self.syntax2003	}2004}2005impl AstNode for DestructArrayElement {2006	fn can_cast(kind: SyntaxKind) -> bool {2007		kind == DESTRUCT_ARRAY_ELEMENT2008	}2009	fn cast(syntax: SyntaxNode) -> Option<Self> {2010		if Self::can_cast(syntax.kind()) {2011			Some(Self { syntax })2012		} else {2013			None2014		}2015	}2016	fn syntax(&self) -> &SyntaxNode {2017		&self.syntax2018	}2019}2020impl From<ExprBinary> for Expr {2021	fn from(node: ExprBinary) -> Expr {2022		Expr::ExprBinary(node)2023	}2024}2025impl From<ExprUnary> for Expr {2026	fn from(node: ExprUnary) -> Expr {2027		Expr::ExprUnary(node)2028	}2029}2030impl From<ExprSlice> for Expr {2031	fn from(node: ExprSlice) -> Expr {2032		Expr::ExprSlice(node)2033	}2034}2035impl From<ExprIndex> for Expr {2036	fn from(node: ExprIndex) -> Expr {2037		Expr::ExprIndex(node)2038	}2039}2040impl From<ExprIndexExpr> for Expr {2041	fn from(node: ExprIndexExpr) -> Expr {2042		Expr::ExprIndexExpr(node)2043	}2044}2045impl From<ExprApply> for Expr {2046	fn from(node: ExprApply) -> Expr {2047		Expr::ExprApply(node)2048	}2049}2050impl From<ExprObjExtend> for Expr {2051	fn from(node: ExprObjExtend) -> Expr {2052		Expr::ExprObjExtend(node)2053	}2054}2055impl From<ExprParened> for Expr {2056	fn from(node: ExprParened) -> Expr {2057		Expr::ExprParened(node)2058	}2059}2060impl From<ExprIntrinsicThisFile> for Expr {2061	fn from(node: ExprIntrinsicThisFile) -> Expr {2062		Expr::ExprIntrinsicThisFile(node)2063	}2064}2065impl From<ExprIntrinsicId> for Expr {2066	fn from(node: ExprIntrinsicId) -> Expr {2067		Expr::ExprIntrinsicId(node)2068	}2069}2070impl From<ExprIntrinsic> for Expr {2071	fn from(node: ExprIntrinsic) -> Expr {2072		Expr::ExprIntrinsic(node)2073	}2074}2075impl From<ExprString> for Expr {2076	fn from(node: ExprString) -> Expr {2077		Expr::ExprString(node)2078	}2079}2080impl From<ExprNumber> for Expr {2081	fn from(node: ExprNumber) -> Expr {2082		Expr::ExprNumber(node)2083	}2084}2085impl From<ExprLiteral> for Expr {2086	fn from(node: ExprLiteral) -> Expr {2087		Expr::ExprLiteral(node)2088	}2089}2090impl From<ExprArray> for Expr {2091	fn from(node: ExprArray) -> Expr {2092		Expr::ExprArray(node)2093	}2094}2095impl From<ExprObject> for Expr {2096	fn from(node: ExprObject) -> Expr {2097		Expr::ExprObject(node)2098	}2099}2100impl From<ExprArrayComp> for Expr {2101	fn from(node: ExprArrayComp) -> Expr {2102		Expr::ExprArrayComp(node)2103	}2104}2105impl From<ExprImport> for Expr {2106	fn from(node: ExprImport) -> Expr {2107		Expr::ExprImport(node)2108	}2109}2110impl From<ExprVar> for Expr {2111	fn from(node: ExprVar) -> Expr {2112		Expr::ExprVar(node)2113	}2114}2115impl From<ExprLocal> for Expr {2116	fn from(node: ExprLocal) -> Expr {2117		Expr::ExprLocal(node)2118	}2119}2120impl From<ExprIfThenElse> for Expr {2121	fn from(node: ExprIfThenElse) -> Expr {2122		Expr::ExprIfThenElse(node)2123	}2124}2125impl From<ExprFunction> for Expr {2126	fn from(node: ExprFunction) -> Expr {2127		Expr::ExprFunction(node)2128	}2129}2130impl From<ExprAssert> for Expr {2131	fn from(node: ExprAssert) -> Expr {2132		Expr::ExprAssert(node)2133	}2134}2135impl From<ExprError> for Expr {2136	fn from(node: ExprError) -> Expr {2137		Expr::ExprError(node)2138	}2139}2140impl AstNode for Expr {2141	fn can_cast(kind: SyntaxKind) -> bool {2142		match kind {2143			EXPR_BINARY2144			| EXPR_UNARY2145			| EXPR_SLICE2146			| EXPR_INDEX2147			| EXPR_INDEX_EXPR2148			| EXPR_APPLY2149			| EXPR_OBJ_EXTEND2150			| EXPR_PARENED2151			| EXPR_INTRINSIC_THIS_FILE2152			| EXPR_INTRINSIC_ID2153			| EXPR_INTRINSIC2154			| EXPR_STRING2155			| EXPR_NUMBER2156			| EXPR_LITERAL2157			| EXPR_ARRAY2158			| EXPR_OBJECT2159			| EXPR_ARRAY_COMP2160			| EXPR_IMPORT2161			| EXPR_VAR2162			| EXPR_LOCAL2163			| EXPR_IF_THEN_ELSE2164			| EXPR_FUNCTION2165			| EXPR_ASSERT2166			| EXPR_ERROR => true,2167			_ => false,2168		}2169	}2170	fn cast(syntax: SyntaxNode) -> Option<Self> {2171		let res = match syntax.kind() {2172			EXPR_BINARY => Expr::ExprBinary(ExprBinary { syntax }),2173			EXPR_UNARY => Expr::ExprUnary(ExprUnary { syntax }),2174			EXPR_SLICE => Expr::ExprSlice(ExprSlice { syntax }),2175			EXPR_INDEX => Expr::ExprIndex(ExprIndex { syntax }),2176			EXPR_INDEX_EXPR => Expr::ExprIndexExpr(ExprIndexExpr { syntax }),2177			EXPR_APPLY => Expr::ExprApply(ExprApply { syntax }),2178			EXPR_OBJ_EXTEND => Expr::ExprObjExtend(ExprObjExtend { syntax }),2179			EXPR_PARENED => Expr::ExprParened(ExprParened { syntax }),2180			EXPR_INTRINSIC_THIS_FILE => {2181				Expr::ExprIntrinsicThisFile(ExprIntrinsicThisFile { syntax })2182			}2183			EXPR_INTRINSIC_ID => Expr::ExprIntrinsicId(ExprIntrinsicId { syntax }),2184			EXPR_INTRINSIC => Expr::ExprIntrinsic(ExprIntrinsic { syntax }),2185			EXPR_STRING => Expr::ExprString(ExprString { syntax }),2186			EXPR_NUMBER => Expr::ExprNumber(ExprNumber { syntax }),2187			EXPR_LITERAL => Expr::ExprLiteral(ExprLiteral { syntax }),2188			EXPR_ARRAY => Expr::ExprArray(ExprArray { syntax }),2189			EXPR_OBJECT => Expr::ExprObject(ExprObject { syntax }),2190			EXPR_ARRAY_COMP => Expr::ExprArrayComp(ExprArrayComp { syntax }),2191			EXPR_IMPORT => Expr::ExprImport(ExprImport { syntax }),2192			EXPR_VAR => Expr::ExprVar(ExprVar { syntax }),2193			EXPR_LOCAL => Expr::ExprLocal(ExprLocal { syntax }),2194			EXPR_IF_THEN_ELSE => Expr::ExprIfThenElse(ExprIfThenElse { syntax }),2195			EXPR_FUNCTION => Expr::ExprFunction(ExprFunction { syntax }),2196			EXPR_ASSERT => Expr::ExprAssert(ExprAssert { syntax }),2197			EXPR_ERROR => Expr::ExprError(ExprError { syntax }),2198			_ => return None,2199		};2200		Some(res)2201	}2202	fn syntax(&self) -> &SyntaxNode {2203		match self {2204			Expr::ExprBinary(it) => &it.syntax,2205			Expr::ExprUnary(it) => &it.syntax,2206			Expr::ExprSlice(it) => &it.syntax,2207			Expr::ExprIndex(it) => &it.syntax,2208			Expr::ExprIndexExpr(it) => &it.syntax,2209			Expr::ExprApply(it) => &it.syntax,2210			Expr::ExprObjExtend(it) => &it.syntax,2211			Expr::ExprParened(it) => &it.syntax,2212			Expr::ExprIntrinsicThisFile(it) => &it.syntax,2213			Expr::ExprIntrinsicId(it) => &it.syntax,2214			Expr::ExprIntrinsic(it) => &it.syntax,2215			Expr::ExprString(it) => &it.syntax,2216			Expr::ExprNumber(it) => &it.syntax,2217			Expr::ExprLiteral(it) => &it.syntax,2218			Expr::ExprArray(it) => &it.syntax,2219			Expr::ExprObject(it) => &it.syntax,2220			Expr::ExprArrayComp(it) => &it.syntax,2221			Expr::ExprImport(it) => &it.syntax,2222			Expr::ExprVar(it) => &it.syntax,2223			Expr::ExprLocal(it) => &it.syntax,2224			Expr::ExprIfThenElse(it) => &it.syntax,2225			Expr::ExprFunction(it) => &it.syntax,2226			Expr::ExprAssert(it) => &it.syntax,2227			Expr::ExprError(it) => &it.syntax,2228		}2229	}2230}2231impl From<ObjBodyComp> for ObjBody {2232	fn from(node: ObjBodyComp) -> ObjBody {2233		ObjBody::ObjBodyComp(node)2234	}2235}2236impl From<ObjBodyMemberList> for ObjBody {2237	fn from(node: ObjBodyMemberList) -> ObjBody {2238		ObjBody::ObjBodyMemberList(node)2239	}2240}2241impl AstNode for ObjBody {2242	fn can_cast(kind: SyntaxKind) -> bool {2243		match kind {2244			OBJ_BODY_COMP | OBJ_BODY_MEMBER_LIST => true,2245			_ => false,2246		}2247	}2248	fn cast(syntax: SyntaxNode) -> Option<Self> {2249		let res = match syntax.kind() {2250			OBJ_BODY_COMP => ObjBody::ObjBodyComp(ObjBodyComp { syntax }),2251			OBJ_BODY_MEMBER_LIST => ObjBody::ObjBodyMemberList(ObjBodyMemberList { syntax }),2252			_ => return None,2253		};2254		Some(res)2255	}2256	fn syntax(&self) -> &SyntaxNode {2257		match self {2258			ObjBody::ObjBodyComp(it) => &it.syntax,2259			ObjBody::ObjBodyMemberList(it) => &it.syntax,2260		}2261	}2262}2263impl From<ForSpec> for CompSpec {2264	fn from(node: ForSpec) -> CompSpec {2265		CompSpec::ForSpec(node)2266	}2267}2268impl From<IfSpec> for CompSpec {2269	fn from(node: IfSpec) -> CompSpec {2270		CompSpec::IfSpec(node)2271	}2272}2273impl AstNode for CompSpec {2274	fn can_cast(kind: SyntaxKind) -> bool {2275		match kind {2276			FOR_SPEC | IF_SPEC => true,2277			_ => false,2278		}2279	}2280	fn cast(syntax: SyntaxNode) -> Option<Self> {2281		let res = match syntax.kind() {2282			FOR_SPEC => CompSpec::ForSpec(ForSpec { syntax }),2283			IF_SPEC => CompSpec::IfSpec(IfSpec { syntax }),2284			_ => return None,2285		};2286		Some(res)2287	}2288	fn syntax(&self) -> &SyntaxNode {2289		match self {2290			CompSpec::ForSpec(it) => &it.syntax,2291			CompSpec::IfSpec(it) => &it.syntax,2292		}2293	}2294}2295impl From<BindDestruct> for Bind {2296	fn from(node: BindDestruct) -> Bind {2297		Bind::BindDestruct(node)2298	}2299}2300impl From<BindFunction> for Bind {2301	fn from(node: BindFunction) -> Bind {2302		Bind::BindFunction(node)2303	}2304}2305impl AstNode for Bind {2306	fn can_cast(kind: SyntaxKind) -> bool {2307		match kind {2308			BIND_DESTRUCT | BIND_FUNCTION => true,2309			_ => false,2310		}2311	}2312	fn cast(syntax: SyntaxNode) -> Option<Self> {2313		let res = match syntax.kind() {2314			BIND_DESTRUCT => Bind::BindDestruct(BindDestruct { syntax }),2315			BIND_FUNCTION => Bind::BindFunction(BindFunction { syntax }),2316			_ => return None,2317		};2318		Some(res)2319	}2320	fn syntax(&self) -> &SyntaxNode {2321		match self {2322			Bind::BindDestruct(it) => &it.syntax,2323			Bind::BindFunction(it) => &it.syntax,2324		}2325	}2326}2327impl From<MemberBindStmt> for Member {2328	fn from(node: MemberBindStmt) -> Member {2329		Member::MemberBindStmt(node)2330	}2331}2332impl From<MemberAssertStmt> for Member {2333	fn from(node: MemberAssertStmt) -> Member {2334		Member::MemberAssertStmt(node)2335	}2336}2337impl From<MemberField> for Member {2338	fn from(node: MemberField) -> Member {2339		Member::MemberField(node)2340	}2341}2342impl AstNode for Member {2343	fn can_cast(kind: SyntaxKind) -> bool {2344		match kind {2345			MEMBER_BIND_STMT | MEMBER_ASSERT_STMT | MEMBER_FIELD => true,2346			_ => false,2347		}2348	}2349	fn cast(syntax: SyntaxNode) -> Option<Self> {2350		let res = match syntax.kind() {2351			MEMBER_BIND_STMT => Member::MemberBindStmt(MemberBindStmt { syntax }),2352			MEMBER_ASSERT_STMT => Member::MemberAssertStmt(MemberAssertStmt { syntax }),2353			MEMBER_FIELD => Member::MemberField(MemberField { syntax }),2354			_ => return None,2355		};2356		Some(res)2357	}2358	fn syntax(&self) -> &SyntaxNode {2359		match self {2360			Member::MemberBindStmt(it) => &it.syntax,2361			Member::MemberAssertStmt(it) => &it.syntax,2362			Member::MemberField(it) => &it.syntax,2363		}2364	}2365}2366impl From<FieldNormal> for Field {2367	fn from(node: FieldNormal) -> Field {2368		Field::FieldNormal(node)2369	}2370}2371impl From<FieldMethod> for Field {2372	fn from(node: FieldMethod) -> Field {2373		Field::FieldMethod(node)2374	}2375}2376impl AstNode for Field {2377	fn can_cast(kind: SyntaxKind) -> bool {2378		match kind {2379			FIELD_NORMAL | FIELD_METHOD => true,2380			_ => false,2381		}2382	}2383	fn cast(syntax: SyntaxNode) -> Option<Self> {2384		let res = match syntax.kind() {2385			FIELD_NORMAL => Field::FieldNormal(FieldNormal { syntax }),2386			FIELD_METHOD => Field::FieldMethod(FieldMethod { syntax }),2387			_ => return None,2388		};2389		Some(res)2390	}2391	fn syntax(&self) -> &SyntaxNode {2392		match self {2393			Field::FieldNormal(it) => &it.syntax,2394			Field::FieldMethod(it) => &it.syntax,2395		}2396	}2397}2398impl From<FieldNameFixed> for FieldName {2399	fn from(node: FieldNameFixed) -> FieldName {2400		FieldName::FieldNameFixed(node)2401	}2402}2403impl From<FieldNameDynamic> for FieldName {2404	fn from(node: FieldNameDynamic) -> FieldName {2405		FieldName::FieldNameDynamic(node)2406	}2407}2408impl AstNode for FieldName {2409	fn can_cast(kind: SyntaxKind) -> bool {2410		match kind {2411			FIELD_NAME_FIXED | FIELD_NAME_DYNAMIC => true,2412			_ => false,2413		}2414	}2415	fn cast(syntax: SyntaxNode) -> Option<Self> {2416		let res = match syntax.kind() {2417			FIELD_NAME_FIXED => FieldName::FieldNameFixed(FieldNameFixed { syntax }),2418			FIELD_NAME_DYNAMIC => FieldName::FieldNameDynamic(FieldNameDynamic { syntax }),2419			_ => return None,2420		};2421		Some(res)2422	}2423	fn syntax(&self) -> &SyntaxNode {2424		match self {2425			FieldName::FieldNameFixed(it) => &it.syntax,2426			FieldName::FieldNameDynamic(it) => &it.syntax,2427		}2428	}2429}2430impl From<DestructFull> for Destruct {2431	fn from(node: DestructFull) -> Destruct {2432		Destruct::DestructFull(node)2433	}2434}2435impl From<DestructSkip> for Destruct {2436	fn from(node: DestructSkip) -> Destruct {2437		Destruct::DestructSkip(node)2438	}2439}2440impl From<DestructArray> for Destruct {2441	fn from(node: DestructArray) -> Destruct {2442		Destruct::DestructArray(node)2443	}2444}2445impl From<DestructObject> for Destruct {2446	fn from(node: DestructObject) -> Destruct {2447		Destruct::DestructObject(node)2448	}2449}2450impl AstNode for Destruct {2451	fn can_cast(kind: SyntaxKind) -> bool {2452		match kind {2453			DESTRUCT_FULL | DESTRUCT_SKIP | DESTRUCT_ARRAY | DESTRUCT_OBJECT => true,2454			_ => false,2455		}2456	}2457	fn cast(syntax: SyntaxNode) -> Option<Self> {2458		let res = match syntax.kind() {2459			DESTRUCT_FULL => Destruct::DestructFull(DestructFull { syntax }),2460			DESTRUCT_SKIP => Destruct::DestructSkip(DestructSkip { syntax }),2461			DESTRUCT_ARRAY => Destruct::DestructArray(DestructArray { syntax }),2462			DESTRUCT_OBJECT => Destruct::DestructObject(DestructObject { syntax }),2463			_ => return None,2464		};2465		Some(res)2466	}2467	fn syntax(&self) -> &SyntaxNode {2468		match self {2469			Destruct::DestructFull(it) => &it.syntax,2470			Destruct::DestructSkip(it) => &it.syntax,2471			Destruct::DestructArray(it) => &it.syntax,2472			Destruct::DestructObject(it) => &it.syntax,2473		}2474	}2475}2476impl From<DestructArrayElement> for DestructArrayPart {2477	fn from(node: DestructArrayElement) -> DestructArrayPart {2478		DestructArrayPart::DestructArrayElement(node)2479	}2480}2481impl From<DestructRest> for DestructArrayPart {2482	fn from(node: DestructRest) -> DestructArrayPart {2483		DestructArrayPart::DestructRest(node)2484	}2485}2486impl AstNode for DestructArrayPart {2487	fn can_cast(kind: SyntaxKind) -> bool {2488		match kind {2489			DESTRUCT_ARRAY_ELEMENT | DESTRUCT_REST => true,2490			_ => false,2491		}2492	}2493	fn cast(syntax: SyntaxNode) -> Option<Self> {2494		let res = match syntax.kind() {2495			DESTRUCT_ARRAY_ELEMENT => {2496				DestructArrayPart::DestructArrayElement(DestructArrayElement { syntax })2497			}2498			DESTRUCT_REST => DestructArrayPart::DestructRest(DestructRest { syntax }),2499			_ => return None,2500		};2501		Some(res)2502	}2503	fn syntax(&self) -> &SyntaxNode {2504		match self {2505			DestructArrayPart::DestructArrayElement(it) => &it.syntax,2506			DestructArrayPart::DestructRest(it) => &it.syntax,2507		}2508	}2509}2510impl AstToken for BinaryOperator {2511	fn can_cast(kind: SyntaxKind) -> bool {2512		BinaryOperatorKind::can_cast(kind)2513	}2514	fn cast(syntax: SyntaxToken) -> Option<Self> {2515		let kind = BinaryOperatorKind::cast(syntax.kind())?;2516		Some(BinaryOperator { syntax, kind })2517	}2518	fn syntax(&self) -> &SyntaxToken {2519		&self.syntax2520	}2521}2522impl BinaryOperatorKind {2523	fn can_cast(kind: SyntaxKind) -> bool {2524		match kind {2525			OR | AND | BIT_OR | BIT_XOR | BIT_AND | EQ | NE | LT | GT | LE | GE | IN_KW | LHS2526			| RHS | PLUS | MINUS | MUL | DIV | MODULO | META_OBJECT_APPLY | ERROR_NO_OPERATOR => true,2527			_ => false,2528		}2529	}2530	pub fn cast(kind: SyntaxKind) -> Option<Self> {2531		let res = match kind {2532			OR => Self::Or,2533			AND => Self::And,2534			BIT_OR => Self::BitOr,2535			BIT_XOR => Self::BitXor,2536			BIT_AND => Self::BitAnd,2537			EQ => Self::Eq,2538			NE => Self::Ne,2539			LT => Self::Lt,2540			GT => Self::Gt,2541			LE => Self::Le,2542			GE => Self::Ge,2543			IN_KW => Self::InKw,2544			LHS => Self::Lhs,2545			RHS => Self::Rhs,2546			PLUS => Self::Plus,2547			MINUS => Self::Minus,2548			MUL => Self::Mul,2549			DIV => Self::Div,2550			MODULO => Self::Modulo,2551			META_OBJECT_APPLY => Self::MetaObjectApply,2552			ERROR_NO_OPERATOR => Self::ErrorNoOperator,2553			_ => return None,2554		};2555		Some(res)2556	}2557}2558impl BinaryOperator {2559	pub fn kind(&self) -> BinaryOperatorKind {2560		self.kind2561	}2562}2563impl std::fmt::Display for BinaryOperator {2564	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2565		std::fmt::Display::fmt(self.syntax(), f)2566	}2567}2568impl AstToken for UnaryOperator {2569	fn can_cast(kind: SyntaxKind) -> bool {2570		UnaryOperatorKind::can_cast(kind)2571	}2572	fn cast(syntax: SyntaxToken) -> Option<Self> {2573		let kind = UnaryOperatorKind::cast(syntax.kind())?;2574		Some(UnaryOperator { syntax, kind })2575	}2576	fn syntax(&self) -> &SyntaxToken {2577		&self.syntax2578	}2579}2580impl UnaryOperatorKind {2581	fn can_cast(kind: SyntaxKind) -> bool {2582		match kind {2583			MINUS | NOT | BIT_NOT => true,2584			_ => false,2585		}2586	}2587	pub fn cast(kind: SyntaxKind) -> Option<Self> {2588		let res = match kind {2589			MINUS => Self::Minus,2590			NOT => Self::Not,2591			BIT_NOT => Self::BitNot,2592			_ => return None,2593		};2594		Some(res)2595	}2596}2597impl UnaryOperator {2598	pub fn kind(&self) -> UnaryOperatorKind {2599		self.kind2600	}2601}2602impl std::fmt::Display for UnaryOperator {2603	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2604		std::fmt::Display::fmt(self.syntax(), f)2605	}2606}2607impl AstToken for Literal {2608	fn can_cast(kind: SyntaxKind) -> bool {2609		LiteralKind::can_cast(kind)2610	}2611	fn cast(syntax: SyntaxToken) -> Option<Self> {2612		let kind = LiteralKind::cast(syntax.kind())?;2613		Some(Literal { syntax, kind })2614	}2615	fn syntax(&self) -> &SyntaxToken {2616		&self.syntax2617	}2618}2619impl LiteralKind {2620	fn can_cast(kind: SyntaxKind) -> bool {2621		match kind {2622			NULL_KW | TRUE_KW | FALSE_KW | SELF_KW | DOLLAR | SUPER_KW => true,2623			_ => false,2624		}2625	}2626	pub fn cast(kind: SyntaxKind) -> Option<Self> {2627		let res = match kind {2628			NULL_KW => Self::NullKw,2629			TRUE_KW => Self::TrueKw,2630			FALSE_KW => Self::FalseKw,2631			SELF_KW => Self::SelfKw,2632			DOLLAR => Self::Dollar,2633			SUPER_KW => Self::SuperKw,2634			_ => return None,2635		};2636		Some(res)2637	}2638}2639impl Literal {2640	pub fn kind(&self) -> LiteralKind {2641		self.kind2642	}2643}2644impl std::fmt::Display for Literal {2645	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2646		std::fmt::Display::fmt(self.syntax(), f)2647	}2648}2649impl AstToken for Text {2650	fn can_cast(kind: SyntaxKind) -> bool {2651		TextKind::can_cast(kind)2652	}2653	fn cast(syntax: SyntaxToken) -> Option<Self> {2654		let kind = TextKind::cast(syntax.kind())?;2655		Some(Text { syntax, kind })2656	}2657	fn syntax(&self) -> &SyntaxToken {2658		&self.syntax2659	}2660}2661impl TextKind {2662	fn can_cast(kind: SyntaxKind) -> bool {2663		match kind {2664			STRING_DOUBLE2665			| ERROR_STRING_DOUBLE_UNTERMINATED2666			| STRING_SINGLE2667			| ERROR_STRING_SINGLE_UNTERMINATED2668			| STRING_DOUBLE_VERBATIM2669			| ERROR_STRING_DOUBLE_VERBATIM_UNTERMINATED2670			| STRING_SINGLE_VERBATIM2671			| ERROR_STRING_SINGLE_VERBATIM_UNTERMINATED2672			| ERROR_STRING_VERBATIM_MISSING_QUOTES2673			| STRING_BLOCK2674			| ERROR_STRING_BLOCK_UNEXPECTED_END2675			| ERROR_STRING_BLOCK_MISSING_NEW_LINE2676			| ERROR_STRING_BLOCK_MISSING_TERMINATION2677			| ERROR_STRING_BLOCK_MISSING_INDENT => true,2678			_ => false,2679		}2680	}2681	pub fn cast(kind: SyntaxKind) -> Option<Self> {2682		let res = match kind {2683			STRING_DOUBLE => Self::StringDouble,2684			ERROR_STRING_DOUBLE_UNTERMINATED => Self::ErrorStringDoubleUnterminated,2685			STRING_SINGLE => Self::StringSingle,2686			ERROR_STRING_SINGLE_UNTERMINATED => Self::ErrorStringSingleUnterminated,2687			STRING_DOUBLE_VERBATIM => Self::StringDoubleVerbatim,2688			ERROR_STRING_DOUBLE_VERBATIM_UNTERMINATED => {2689				Self::ErrorStringDoubleVerbatimUnterminated2690			}2691			STRING_SINGLE_VERBATIM => Self::StringSingleVerbatim,2692			ERROR_STRING_SINGLE_VERBATIM_UNTERMINATED => {2693				Self::ErrorStringSingleVerbatimUnterminated2694			}2695			ERROR_STRING_VERBATIM_MISSING_QUOTES => Self::ErrorStringVerbatimMissingQuotes,2696			STRING_BLOCK => Self::StringBlock,2697			ERROR_STRING_BLOCK_UNEXPECTED_END => Self::ErrorStringBlockUnexpectedEnd,2698			ERROR_STRING_BLOCK_MISSING_NEW_LINE => Self::ErrorStringBlockMissingNewLine,2699			ERROR_STRING_BLOCK_MISSING_TERMINATION => Self::ErrorStringBlockMissingTermination,2700			ERROR_STRING_BLOCK_MISSING_INDENT => Self::ErrorStringBlockMissingIndent,2701			_ => return None,2702		};2703		Some(res)2704	}2705}2706impl Text {2707	pub fn kind(&self) -> TextKind {2708		self.kind2709	}2710}2711impl std::fmt::Display for Text {2712	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2713		std::fmt::Display::fmt(self.syntax(), f)2714	}2715}2716impl AstToken for Number {2717	fn can_cast(kind: SyntaxKind) -> bool {2718		NumberKind::can_cast(kind)2719	}2720	fn cast(syntax: SyntaxToken) -> Option<Self> {2721		let kind = NumberKind::cast(syntax.kind())?;2722		Some(Number { syntax, kind })2723	}2724	fn syntax(&self) -> &SyntaxToken {2725		&self.syntax2726	}2727}2728impl NumberKind {2729	fn can_cast(kind: SyntaxKind) -> bool {2730		match kind {2731			FLOAT2732			| ERROR_FLOAT_JUNK_AFTER_POINT2733			| ERROR_FLOAT_JUNK_AFTER_EXPONENT2734			| ERROR_FLOAT_JUNK_AFTER_EXPONENT_SIGN => true,2735			_ => false,2736		}2737	}2738	pub fn cast(kind: SyntaxKind) -> Option<Self> {2739		let res = match kind {2740			FLOAT => Self::Float,2741			ERROR_FLOAT_JUNK_AFTER_POINT => Self::ErrorFloatJunkAfterPoint,2742			ERROR_FLOAT_JUNK_AFTER_EXPONENT => Self::ErrorFloatJunkAfterExponent,2743			ERROR_FLOAT_JUNK_AFTER_EXPONENT_SIGN => Self::ErrorFloatJunkAfterExponentSign,2744			_ => return None,2745		};2746		Some(res)2747	}2748}2749impl Number {2750	pub fn kind(&self) -> NumberKind {2751		self.kind2752	}2753}2754impl std::fmt::Display for Number {2755	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2756		std::fmt::Display::fmt(self.syntax(), f)2757	}2758}2759impl AstToken for ImportKind {2760	fn can_cast(kind: SyntaxKind) -> bool {2761		ImportKindKind::can_cast(kind)2762	}2763	fn cast(syntax: SyntaxToken) -> Option<Self> {2764		let kind = ImportKindKind::cast(syntax.kind())?;2765		Some(ImportKind { syntax, kind })2766	}2767	fn syntax(&self) -> &SyntaxToken {2768		&self.syntax2769	}2770}2771impl ImportKindKind {2772	fn can_cast(kind: SyntaxKind) -> bool {2773		match kind {2774			IMPORTSTR_KW | IMPORTBIN_KW | IMPORT_KW => true,2775			_ => false,2776		}2777	}2778	pub fn cast(kind: SyntaxKind) -> Option<Self> {2779		let res = match kind {2780			IMPORTSTR_KW => Self::ImportstrKw,2781			IMPORTBIN_KW => Self::ImportbinKw,2782			IMPORT_KW => Self::ImportKw,2783			_ => return None,2784		};2785		Some(res)2786	}2787}2788impl ImportKind {2789	pub fn kind(&self) -> ImportKindKind {2790		self.kind2791	}2792}2793impl std::fmt::Display for ImportKind {2794	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2795		std::fmt::Display::fmt(self.syntax(), f)2796	}2797}2798impl AstToken for Visibility {2799	fn can_cast(kind: SyntaxKind) -> bool {2800		VisibilityKind::can_cast(kind)2801	}2802	fn cast(syntax: SyntaxToken) -> Option<Self> {2803		let kind = VisibilityKind::cast(syntax.kind())?;2804		Some(Visibility { syntax, kind })2805	}2806	fn syntax(&self) -> &SyntaxToken {2807		&self.syntax2808	}2809}2810impl VisibilityKind {2811	fn can_cast(kind: SyntaxKind) -> bool {2812		match kind {2813			COLONCOLONCOLON | COLONCOLON | COLON => true,2814			_ => false,2815		}2816	}2817	pub fn cast(kind: SyntaxKind) -> Option<Self> {2818		let res = match kind {2819			COLONCOLONCOLON => Self::Coloncoloncolon,2820			COLONCOLON => Self::Coloncolon,2821			COLON => Self::Colon,2822			_ => return None,2823		};2824		Some(res)2825	}2826}2827impl Visibility {2828	pub fn kind(&self) -> VisibilityKind {2829		self.kind2830	}2831}2832impl std::fmt::Display for Visibility {2833	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2834		std::fmt::Display::fmt(self.syntax(), f)2835	}2836}2837impl AstToken for Trivia {2838	fn can_cast(kind: SyntaxKind) -> bool {2839		TriviaKind::can_cast(kind)2840	}2841	fn cast(syntax: SyntaxToken) -> Option<Self> {2842		let kind = TriviaKind::cast(syntax.kind())?;2843		Some(Trivia { syntax, kind })2844	}2845	fn syntax(&self) -> &SyntaxToken {2846		&self.syntax2847	}2848}2849impl TriviaKind {2850	fn can_cast(kind: SyntaxKind) -> bool {2851		match kind {2852			WHITESPACE2853			| MULTI_LINE_COMMENT2854			| ERROR_COMMENT_TOO_SHORT2855			| ERROR_COMMENT_UNTERMINATED2856			| SINGLE_LINE_HASH_COMMENT2857			| SINGLE_LINE_SLASH_COMMENT => true,2858			_ => false,2859		}2860	}2861	pub fn cast(kind: SyntaxKind) -> Option<Self> {2862		let res = match kind {2863			WHITESPACE => Self::Whitespace,2864			MULTI_LINE_COMMENT => Self::MultiLineComment,2865			ERROR_COMMENT_TOO_SHORT => Self::ErrorCommentTooShort,2866			ERROR_COMMENT_UNTERMINATED => Self::ErrorCommentUnterminated,2867			SINGLE_LINE_HASH_COMMENT => Self::SingleLineHashComment,2868			SINGLE_LINE_SLASH_COMMENT => Self::SingleLineSlashComment,2869			_ => return None,2870		};2871		Some(res)2872	}2873}2874impl Trivia {2875	pub fn kind(&self) -> TriviaKind {2876		self.kind2877	}2878}2879impl std::fmt::Display for Trivia {2880	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2881		std::fmt::Display::fmt(self.syntax(), f)2882	}2883}2884impl std::fmt::Display for Expr {2885	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2886		std::fmt::Display::fmt(self.syntax(), f)2887	}2888}2889impl std::fmt::Display for ObjBody {2890	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2891		std::fmt::Display::fmt(self.syntax(), f)2892	}2893}2894impl std::fmt::Display for CompSpec {2895	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2896		std::fmt::Display::fmt(self.syntax(), f)2897	}2898}2899impl std::fmt::Display for Bind {2900	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2901		std::fmt::Display::fmt(self.syntax(), f)2902	}2903}2904impl std::fmt::Display for Member {2905	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2906		std::fmt::Display::fmt(self.syntax(), f)2907	}2908}2909impl std::fmt::Display for Field {2910	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2911		std::fmt::Display::fmt(self.syntax(), f)2912	}2913}2914impl std::fmt::Display for FieldName {2915	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2916		std::fmt::Display::fmt(self.syntax(), f)2917	}2918}2919impl std::fmt::Display for Destruct {2920	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2921		std::fmt::Display::fmt(self.syntax(), f)2922	}2923}2924impl std::fmt::Display for DestructArrayPart {2925	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2926		std::fmt::Display::fmt(self.syntax(), f)2927	}2928}2929impl std::fmt::Display for SourceFile {2930	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2931		std::fmt::Display::fmt(self.syntax(), f)2932	}2933}2934impl std::fmt::Display for ExprBinary {2935	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2936		std::fmt::Display::fmt(self.syntax(), f)2937	}2938}2939impl std::fmt::Display for LhsExpr {2940	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2941		std::fmt::Display::fmt(self.syntax(), f)2942	}2943}2944impl std::fmt::Display for ExprUnary {2945	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2946		std::fmt::Display::fmt(self.syntax(), f)2947	}2948}2949impl std::fmt::Display for ExprSlice {2950	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2951		std::fmt::Display::fmt(self.syntax(), f)2952	}2953}2954impl std::fmt::Display for SliceDesc {2955	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2956		std::fmt::Display::fmt(self.syntax(), f)2957	}2958}2959impl std::fmt::Display for ExprIndex {2960	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2961		std::fmt::Display::fmt(self.syntax(), f)2962	}2963}2964impl std::fmt::Display for Name {2965	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2966		std::fmt::Display::fmt(self.syntax(), f)2967	}2968}2969impl std::fmt::Display for ExprIndexExpr {2970	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2971		std::fmt::Display::fmt(self.syntax(), f)2972	}2973}2974impl std::fmt::Display for ExprApply {2975	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2976		std::fmt::Display::fmt(self.syntax(), f)2977	}2978}2979impl std::fmt::Display for ArgsDesc {2980	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2981		std::fmt::Display::fmt(self.syntax(), f)2982	}2983}2984impl std::fmt::Display for ExprObjExtend {2985	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2986		std::fmt::Display::fmt(self.syntax(), f)2987	}2988}2989impl std::fmt::Display for ExprParened {2990	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2991		std::fmt::Display::fmt(self.syntax(), f)2992	}2993}2994impl std::fmt::Display for ExprLiteral {2995	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {2996		std::fmt::Display::fmt(self.syntax(), f)2997	}2998}2999impl std::fmt::Display for ExprIntrinsicThisFile {3000	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3001		std::fmt::Display::fmt(self.syntax(), f)3002	}3003}3004impl std::fmt::Display for ExprIntrinsicId {3005	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3006		std::fmt::Display::fmt(self.syntax(), f)3007	}3008}3009impl std::fmt::Display for ExprIntrinsic {3010	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3011		std::fmt::Display::fmt(self.syntax(), f)3012	}3013}3014impl std::fmt::Display for ExprString {3015	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3016		std::fmt::Display::fmt(self.syntax(), f)3017	}3018}3019impl std::fmt::Display for ExprNumber {3020	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3021		std::fmt::Display::fmt(self.syntax(), f)3022	}3023}3024impl std::fmt::Display for ExprArray {3025	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3026		std::fmt::Display::fmt(self.syntax(), f)3027	}3028}3029impl std::fmt::Display for ExprObject {3030	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3031		std::fmt::Display::fmt(self.syntax(), f)3032	}3033}3034impl std::fmt::Display for ExprArrayComp {3035	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3036		std::fmt::Display::fmt(self.syntax(), f)3037	}3038}3039impl std::fmt::Display for ExprImport {3040	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3041		std::fmt::Display::fmt(self.syntax(), f)3042	}3043}3044impl std::fmt::Display for ExprVar {3045	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3046		std::fmt::Display::fmt(self.syntax(), f)3047	}3048}3049impl std::fmt::Display for ExprLocal {3050	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3051		std::fmt::Display::fmt(self.syntax(), f)3052	}3053}3054impl std::fmt::Display for ExprIfThenElse {3055	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3056		std::fmt::Display::fmt(self.syntax(), f)3057	}3058}3059impl std::fmt::Display for TrueExpr {3060	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3061		std::fmt::Display::fmt(self.syntax(), f)3062	}3063}3064impl std::fmt::Display for FalseExpr {3065	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3066		std::fmt::Display::fmt(self.syntax(), f)3067	}3068}3069impl std::fmt::Display for ExprFunction {3070	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3071		std::fmt::Display::fmt(self.syntax(), f)3072	}3073}3074impl std::fmt::Display for ParamsDesc {3075	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3076		std::fmt::Display::fmt(self.syntax(), f)3077	}3078}3079impl std::fmt::Display for ExprAssert {3080	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3081		std::fmt::Display::fmt(self.syntax(), f)3082	}3083}3084impl std::fmt::Display for Assertion {3085	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3086		std::fmt::Display::fmt(self.syntax(), f)3087	}3088}3089impl std::fmt::Display for ExprError {3090	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3091		std::fmt::Display::fmt(self.syntax(), f)3092	}3093}3094impl std::fmt::Display for SliceDescEnd {3095	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3096		std::fmt::Display::fmt(self.syntax(), f)3097	}3098}3099impl std::fmt::Display for SliceDescStep {3100	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3101		std::fmt::Display::fmt(self.syntax(), f)3102	}3103}3104impl std::fmt::Display for Arg {3105	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3106		std::fmt::Display::fmt(self.syntax(), f)3107	}3108}3109impl std::fmt::Display for ObjBodyComp {3110	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3111		std::fmt::Display::fmt(self.syntax(), f)3112	}3113}3114impl std::fmt::Display for ObjLocalPostComma {3115	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3116		std::fmt::Display::fmt(self.syntax(), f)3117	}3118}3119impl std::fmt::Display for ObjLocalPreComma {3120	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3121		std::fmt::Display::fmt(self.syntax(), f)3122	}3123}3124impl std::fmt::Display for ObjBodyMemberList {3125	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3126		std::fmt::Display::fmt(self.syntax(), f)3127	}3128}3129impl std::fmt::Display for ObjLocal {3130	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3131		std::fmt::Display::fmt(self.syntax(), f)3132	}3133}3134impl std::fmt::Display for MemberBindStmt {3135	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3136		std::fmt::Display::fmt(self.syntax(), f)3137	}3138}3139impl std::fmt::Display for MemberAssertStmt {3140	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3141		std::fmt::Display::fmt(self.syntax(), f)3142	}3143}3144impl std::fmt::Display for MemberField {3145	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3146		std::fmt::Display::fmt(self.syntax(), f)3147	}3148}3149impl std::fmt::Display for FieldNormal {3150	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3151		std::fmt::Display::fmt(self.syntax(), f)3152	}3153}3154impl std::fmt::Display for FieldMethod {3155	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3156		std::fmt::Display::fmt(self.syntax(), f)3157	}3158}3159impl std::fmt::Display for FieldNameFixed {3160	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3161		std::fmt::Display::fmt(self.syntax(), f)3162	}3163}3164impl std::fmt::Display for FieldNameDynamic {3165	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3166		std::fmt::Display::fmt(self.syntax(), f)3167	}3168}3169impl std::fmt::Display for ForSpec {3170	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3171		std::fmt::Display::fmt(self.syntax(), f)3172	}3173}3174impl std::fmt::Display for IfSpec {3175	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3176		std::fmt::Display::fmt(self.syntax(), f)3177	}3178}3179impl std::fmt::Display for BindDestruct {3180	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3181		std::fmt::Display::fmt(self.syntax(), f)3182	}3183}3184impl std::fmt::Display for BindFunction {3185	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3186		std::fmt::Display::fmt(self.syntax(), f)3187	}3188}3189impl std::fmt::Display for Param {3190	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3191		std::fmt::Display::fmt(self.syntax(), f)3192	}3193}3194impl std::fmt::Display for DestructFull {3195	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3196		std::fmt::Display::fmt(self.syntax(), f)3197	}3198}3199impl std::fmt::Display for DestructSkip {3200	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3201		std::fmt::Display::fmt(self.syntax(), f)3202	}3203}3204impl std::fmt::Display for DestructArray {3205	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3206		std::fmt::Display::fmt(self.syntax(), f)3207	}3208}3209impl std::fmt::Display for DestructObject {3210	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3211		std::fmt::Display::fmt(self.syntax(), f)3212	}3213}3214impl std::fmt::Display for DestructObjectField {3215	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3216		std::fmt::Display::fmt(self.syntax(), f)3217	}3218}3219impl std::fmt::Display for DestructRest {3220	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3221		std::fmt::Display::fmt(self.syntax(), f)3222	}3223}3224impl std::fmt::Display for DestructArrayElement {3225	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {3226		std::fmt::Display::fmt(self.syntax(), f)3227	}3228}
modifiedcrates/jrsonnet-rowan-parser/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/lib.rs
+++ b/crates/jrsonnet-rowan-parser/src/lib.rs
@@ -1,5 +1,11 @@
 #![deny(unused_must_use)]
 
+use event::Sink;
+use generated::nodes::{SourceFile, Trivia};
+use lex::lex;
+use parser::{Parser, SyntaxError};
+pub use rowan;
+
 mod ast;
 mod event;
 mod generated;
@@ -13,18 +19,18 @@
 mod token_set;
 
 pub use ast::{AstChildren, AstNode, AstToken};
-use event::Sink;
-use generated::nodes::SourceFile;
 pub use generated::{nodes, syntax_kinds::SyntaxKind};
-pub use language::{
-	JsonnetLanguage, PreorderWithTokens, SyntaxElement, SyntaxElementChildren, SyntaxNode,
-	SyntaxNodeChildren, SyntaxToken,
-};
-use lex::lex;
-use parser::{Parser, SyntaxError};
+pub use language::*;
+pub use token_set::SyntaxKindSet;
+
 pub fn parse(input: &str) -> (SourceFile, Vec<SyntaxError>) {
 	let lexemes = lex(input);
-	let parser = Parser::new(&lexemes);
+	let kinds = lexemes
+		.iter()
+		.map(|l| l.kind)
+		.filter(|k| !Trivia::can_cast(*k))
+		.collect();
+	let parser = Parser::new(kinds);
 	let events = parser.parse();
 	let sink = Sink::new(events, &lexemes);
 
modifiedcrates/jrsonnet-rowan-parser/src/marker.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/marker.rs
+++ b/crates/jrsonnet-rowan-parser/src/marker.rs
@@ -113,21 +113,3 @@
 		completed
 	}
 }
-
-pub trait AsRange {
-	fn as_range(&self, p: &Parser) -> TextRange;
-	fn end_token(&self) -> usize;
-}
-
-impl AsRange for FinishedRanger {
-	fn as_range(&self, p: &Parser) -> TextRange {
-		TextRange::new(
-			p.start_of_token(self.start_token),
-			p.end_of_token(self.end_token),
-		)
-	}
-
-	fn end_token(&self) -> usize {
-		self.end_token
-	}
-}
modifiedcrates/jrsonnet-rowan-parser/src/parser.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/parser.rs
+++ b/crates/jrsonnet-rowan-parser/src/parser.rs
@@ -6,7 +6,7 @@
 use crate::{
 	event::Event,
 	lex::Lexeme,
-	marker::{AsRange, CompletedMarker, Marker, Ranger},
+	marker::{CompletedMarker, Marker, Ranger},
 	nodes::{BinaryOperatorKind, Literal, Number, Text, Trivia, UnaryOperatorKind},
 	token_set::SyntaxKindSet,
 	AstToken, SyntaxKind,
@@ -33,9 +33,9 @@
 	}
 }
 
-pub struct Parser<'i> {
+pub struct Parser {
 	// TODO: remove all trivia before feeding to parser?
-	lexemes: &'i [Lexeme<'i>],
+	kinds: Vec<SyntaxKind>,
 	pub offset: usize,
 	pub events: Vec<Event>,
 	pub entered: u32,
@@ -103,10 +103,10 @@
 	}
 }
 
-impl<'i> Parser<'i> {
-	pub fn new(lexemes: &'i [Lexeme<'i>]) -> Self {
+impl Parser {
+	pub fn new(kinds: Vec<SyntaxKind>) -> Self {
 		Self {
-			lexemes,
+			kinds,
 			offset: 0,
 			events: vec![],
 			entered: 0,
@@ -134,14 +134,12 @@
 			.set(ExpectedSyntaxTrackingState::Unnamed);
 	}
 	pub fn start(&mut self) -> Marker {
-		self.skip_trivia();
 		let start_event_idx = self.events.len();
 		self.events.push(Event::Pending);
 		self.entered += 1;
 		Marker::new(start_event_idx)
 	}
 	pub fn start_ranger(&mut self) -> Ranger {
-		self.skip_trivia();
 		let pos = self.offset;
 		Ranger { pos }
 	}
@@ -178,45 +176,7 @@
 		} else {
 			self.error_with_no_skip();
 		}
-	}
-	fn current_token(&self) -> Lexeme<'i> {
-		self.lexemes[self.offset]
-	}
-	fn previous_token(&mut self) -> Option<Lexeme<'i>> {
-		if self.offset == 0 {
-			return None;
-		}
-		let mut previous_token_idx = self.offset - 1;
-		while self
-			.lexemes
-			.get(previous_token_idx)
-			.map_or(false, |l| Trivia::can_cast(l.kind))
-			&& previous_token_idx != 0
-		{
-			previous_token_idx -= 1;
-		}
-
-		Some(self.lexemes[previous_token_idx])
-	}
-	pub fn start_of_token(&self, mut idx: usize) -> TextSize {
-		while Trivia::can_cast(self.lexemes[idx].kind) {
-			idx += 1;
-		}
-		self.lexemes[idx].range.start()
 	}
-	pub fn end_of_token(&self, mut idx: usize) -> TextSize {
-		while Trivia::can_cast(self.lexemes[idx].kind) {
-			idx -= 1;
-		}
-		self.lexemes[idx].range.end()
-	}
-	pub(crate) fn custom_error(&mut self, marker: impl AsRange, error: impl AsRef<str>) {
-		self.last_error_token = marker.end_token();
-		self.events.push(Event::Error(SyntaxError::Custom {
-			error: error.as_ref().to_string(),
-			range: marker.as_range(self),
-		}));
-	}
 	pub(crate) fn error_with_recovery_set(
 		&mut self,
 		recovery_set: SyntaxKindSet,
@@ -238,27 +198,26 @@
 		self.expected_syntax_tracking_state
 			.set(ExpectedSyntaxTrackingState::Unnamed);
 
-		self.skip_trivia();
 		if self.at_end() || self.at_ts(recovery_set) {
-			let range = self
-				.previous_token()
-				.map(|t| t.range)
-				.unwrap_or_else(|| TextRange::at(TextSize::from(0), TextSize::from(0)));
+			// let range = self
+			// 	.previous_token()
+			// 	.map(|t| t.range)
+			// 	.unwrap_or_else(|| TextRange::at(TextSize::from(0), TextSize::from(0)));
 
-			self.events.push(Event::Error(SyntaxError::Missing {
-				expected: expected_syntax,
-				offset: range.end(),
-			}));
+			// self.events.push(Event::Error(SyntaxError::Missing {
+			// 	expected: expected_syntax,
+			// 	offset: range.end(),
+			// }));
 			return None;
 		}
 
-		let current_token = self.current_token();
+		let current_token = self.current();
 
-		self.events.push(Event::Error(SyntaxError::Unexpected {
-			expected: expected_syntax,
-			found: current_token.kind,
-			range: current_token.range,
-		}));
+		// self.events.push(Event::Error(SyntaxError::Unexpected {
+		// 	expected: expected_syntax,
+		// 	found: current_token.kind,
+		// 	range: current_token.range,
+		// }));
 		self.clear_expected_syntaxes();
 		self.last_error_token = self.offset;
 
@@ -267,17 +226,14 @@
 		Some(m.complete(self, SyntaxKind::ERROR))
 	}
 	fn bump_assert(&mut self, kind: SyntaxKind) {
-		self.skip_trivia();
 		assert!(self.at(kind), "expected {:?}", kind);
 		self.bump_remap(self.current());
 	}
 	fn bump(&mut self) {
-		self.skip_trivia();
 		self.bump_remap(self.current());
 	}
 	fn bump_remap(&mut self, kind: SyntaxKind) {
-		self.skip_trivia();
-		assert_ne!(self.offset, self.lexemes.len(), "already at end");
+		assert_ne!(self.offset, self.kinds.len(), "already at end");
 		self.events.push(Event::Token { kind });
 		self.offset += 1;
 		self.clear_expected_syntaxes();
@@ -302,7 +258,7 @@
 			{
 				let next = 20;
 				write!(out, "\n\nNext {next} tokens:").unwrap();
-				for (i, tok) in self.lexemes.iter().skip(self.offset).take(next).enumerate() {
+				for (i, tok) in self.kinds.iter().skip(self.offset).take(next).enumerate() {
 					write!(out, "\n{i}. {tok:?}").unwrap();
 				}
 			}
@@ -314,39 +270,12 @@
 		self.step();
 		let mut offset = self.offset;
 		for _ in 0..i {
-			while self
-				.lexemes
-				.get(offset)
-				.map(|l| Trivia::can_cast(l.kind))
-				.unwrap_or(false)
-			{
-				offset += 1;
-			}
 			offset += 1;
 		}
-		while self
-			.lexemes
-			.get(offset)
-			.map(|l| Trivia::can_cast(l.kind))
-			.unwrap_or(false)
-		{
-			offset += 1;
-		}
-		self.lexemes.get(offset).map(|l| l.kind).unwrap_or(EOF)
+		self.kinds.get(offset).copied().unwrap_or(EOF)
 	}
 	fn current(&self) -> SyntaxKind {
 		self.nth(0)
-	}
-	fn skip_trivia(&mut self) {
-		while Trivia::can_cast(self.peek_raw()) {
-			self.offset += 1;
-		}
-	}
-	fn peek_raw(&mut self) -> SyntaxKind {
-		self.lexemes
-			.get(self.offset)
-			.map(|l| l.kind)
-			.unwrap_or(SyntaxKind::EOF)
 	}
 	#[must_use]
 	pub(crate) fn expected_syntax_name(&mut self, name: &'static str) -> ExpectedSyntaxGuard {
@@ -507,15 +436,15 @@
 		None
 	};
 	let params = if p.at(T!['(']) {
-		if let Some(plus) = plus {
-			p.custom_error(plus, "can't extend with method");
-		}
+		// if let Some(plus) = plus {
+		// 	p.custom_error(plus, "can't extend with method");
+		// }
 		params_desc(p);
-		if p.at(T![+]) {
-			let r = p.start_ranger();
-			p.bump();
-			p.custom_error(r.finish(p), "can't extend with method");
-		}
+		// if p.at(T![+]) {
+		// 	let r = p.start_ranger();
+		// 	p.bump();
+		// 	p.custom_error(r.finish(p), "can't extend with method");
+		// }
 		true
 	} else {
 		false
@@ -669,10 +598,10 @@
 
 	if elems > 1 && !compspecs.is_empty() {
 		for spec in compspecs {
-			p.custom_error(
-				spec,
-				"compspec may only be used if there is only one array element",
-			)
+			// p.custom_error(
+			// 	spec,
+			// 	"compspec may only be used if there is only one array element",
+			// )
 		}
 
 		m.complete(p, EXPR_ARRAY)
@@ -797,9 +726,9 @@
 			} else if p.at(T![...]) {
 				let m_err = p.start_ranger();
 				destruct_rest(p);
-				if had_rest {
-					p.custom_error(m_err.finish(p), "only one rest can be present in array");
-				}
+				// if had_rest {
+				// 	p.custom_error(m_err.finish(p), "only one rest can be present in array");
+				// }
 				had_rest = true;
 			} else {
 				destruct(p);
@@ -822,9 +751,9 @@
 			} else if p.at(T![...]) {
 				let m_err = p.start_ranger();
 				destruct_rest(p);
-				if had_rest {
-					p.custom_error(m_err.finish(p), "only one rest can be present in object");
-				}
+				// if had_rest {
+				// 	p.custom_error(m_err.finish(p), "only one rest can be present in object");
+				// }
 				had_rest = true;
 			} else {
 				if had_rest {
modifiedcrates/jrsonnet-rowan-parser/src/token_set.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/token_set.rs
+++ b/crates/jrsonnet-rowan-parser/src/token_set.rs
@@ -34,9 +34,9 @@
 #[macro_export]
 macro_rules! TS {
 	($($tt:tt)*) => {
-		SyntaxKindSet::new(&[
+		$crate::SyntaxKindSet::new(&[
 			$(
-				T![$tt]
+				$crate::T![$tt]
 			),*
 		])
 	};
deletedjrsonnet-lsp/Cargo.tomldiffbeforeafterboth
--- a/jrsonnet-lsp/Cargo.toml
+++ /dev/null
@@ -1,15 +0,0 @@
-[package]
-name = "jrsonnet-lsp"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-anyhow = "1.0.48"
-jrsonnet-evaluator = { path = "../jrsonnet-evaluator" }
-jrsonnet-parser = { path = "../jrsonnet-parser" }
-lsp-server = "0.5.2"
-lsp-types = "0.92.0"
-serde = "1.0.130"
-serde_json = "1.0.71"
deletedjrsonnet-lsp/src/main.rsdiffbeforeafterboth
--- a/jrsonnet-lsp/src/main.rs
+++ /dev/null
@@ -1,211 +0,0 @@
-use std::{
-	collections::HashMap,
-	fs::File,
-	path::{Path, PathBuf},
-	str::FromStr,
-};
-
-use jrsonnet_evaluator::{EvaluationState, FileImportResolver, Val};
-use jrsonnet_parser::{ExprLocation, ParserSettings};
-use lsp_server::{Connection, ErrorCode, Message, Request, RequestId, Response};
-use lsp_types::{
-	notification::{DidChangeTextDocument, DidOpenTextDocument, Notification},
-	request::{DocumentLinkRequest, HoverRequest},
-	CompletionOptions, DidChangeTextDocumentParams, DidOpenTextDocumentParams, DocumentLink,
-	DocumentLinkOptions, Hover, HoverContents, MarkupContent, MarkupKind, ServerCapabilities,
-	TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions, Url,
-	WorkDoneProgressOptions,
-};
-
-use std::io::Write;
-
-fn main() {
-	let mut log = File::create("test").unwrap();
-	writeln!(log, "start").unwrap();
-	let (connection, io_threads) = Connection::stdio();
-	let capabilities = serde_json::to_value(&ServerCapabilities {
-		completion_provider: Some(CompletionOptions::default()),
-		definition_provider: Some(lsp_types::OneOf::Left(true)),
-		document_link_provider: Some(DocumentLinkOptions {
-			resolve_provider: Some(false),
-			work_done_progress_options: WorkDoneProgressOptions::default(),
-		}),
-		hover_provider: Some(lsp_types::HoverProviderCapability::Simple(true)),
-		text_document_sync: Some(TextDocumentSyncCapability::Options(
-			TextDocumentSyncOptions {
-				change: Some(TextDocumentSyncKind::FULL),
-				open_close: Some(true),
-				..TextDocumentSyncOptions::default()
-			},
-		)),
-		..ServerCapabilities::default()
-	})
-	.expect("failed to convert capabilities to json");
-
-	connection
-		.initialize(capabilities)
-		.expect("failed to initialize connection");
-
-	writeln!(log, "initialized").unwrap();
-
-	main_loop(&mut log, &connection).expect("main loop failed");
-
-	io_threads.join().expect("failed to join io_threads");
-}
-fn main_loop(log: &mut File, connection: &Connection) -> anyhow::Result<()> {
-	let mut es = EvaluationState::default();
-	es.set_import_resolver(Box::new(FileImportResolver::default()));
-
-	let reply = |response: Response| {
-		connection
-			.sender
-			.send(Message::Response(response))
-			.expect("failed to respond");
-	};
-
-	for msg in &connection.receiver {
-		match msg {
-			Message::Response(_) => (),
-			Message::Request(req) => {
-				if connection.handle_shutdown(&req)? {
-					return Ok(());
-				}
-				if let Some((id, params)) = cast::<DocumentLinkRequest>(&req) {
-					reply(Response::new_ok(id, <Vec<DocumentLink>>::new()));
-				} else if let Some((id, params)) = cast::<HoverRequest>(&req) {
-					let pos = params
-						.text_document_position_params
-						.text_document
-						.uri
-						.path();
-					let buf = PathBuf::from_str(pos).unwrap();
-					let pos = es
-						.map_from_source_location(
-							&buf,
-							params.text_document_position_params.position.line as usize + 1,
-							params.text_document_position_params.position.character as usize + 1,
-						)
-						.unwrap();
-					let el = ExprLocation(buf.clone().into(), pos as usize, pos as usize);
-					let es2 = es.clone();
-				// reply(Response::new_ok(
-				// 	id,
-				// 	Some(Hover {
-				// 		range: None,
-				// 		contents: HoverContents::Markup(MarkupContent {
-				// 			kind: MarkupKind::Markdown,
-				// 			value: es
-				// 				.run_in_state_with_breakpoint(el, move || {
-				// 					es2.reset_evaluation_state(&buf);
-				// 					es2.import_file(&PathBuf::new(), &buf)?
-				// 						.to_string()
-				// 						.map(|_| ())
-				// 				})
-				// 				.unwrap()
-				// 				.unwrap_or_else(|| Val::Null)
-				// 				.value_type()
-				// 				.to_string(),
-				// 		}),
-				// 	}),
-				// ));
-				} else
-				/*
-				if let Some((id, params)) = cast::<DocumentLinkRequest>(&req) {
-					 let links = handle_links(&files, params).unwrap_or_default();
-					 reply(Response::new_ok(id, links));
-				} else if let Some((id, params)) = cast::<GotoDefinition>(&req) {
-					 if let Some(loc) = handle_goto(&files, params) {
-						  reply(Response::new_ok(id, loc))
-					 } else {
-						  reply(Response::new_ok(id, ()))
-					 }
-				} else if let Some((id, params)) = cast::<HoverRequest>(&req) {
-					 match handle_hover(&files, params) {
-						  Some((range, markdown)) => {
-								reply(Response::new_ok(
-									 id,
-									 Hover {
-										  contents: HoverContents::Markup(MarkupContent {
-												kind: MarkupKind::Markdown,
-												value: markdown,
-										  }),
-										  range,
-									 },
-								));
-						  }
-						  None => {
-								reply(Response::new_ok(id, ()));
-						  }
-					 }
-				} else if let Some((id, params)) = cast::<Completion>(&req) {
-					 let completions = handle_completion(&files, params.text_document_position)
-						  .unwrap_or_default();
-					 reply(Response::new_ok(id, completions));
-				} else
-				*/
-				{
-					reply(Response::new_err(
-						req.id,
-						ErrorCode::MethodNotFound as i32,
-						format!("unrecognized request {}", req.method),
-					))
-				}
-			}
-			Message::Notification(req) => {
-				let mut handle = |text: String, uri: Url| {
-					writeln!(log, "updated file: {:?}", uri).unwrap();
-					let path = match PathBuf::from_str(uri.path()) {
-						Ok(x) => x,
-						Err(_) => return,
-					};
-					let parsed = match jrsonnet_parser::parse(
-						&text,
-						&ParserSettings {
-							file_name: path.clone().into(),
-						},
-					) {
-						Ok(v) => v,
-						Err(e) => {
-							writeln!(log, "fuck D: {:?}", e).unwrap();
-							return;
-							// connection.sender.send(Message::Notification(Notification::new_err(req.id, ErrorCode::ParseError as i32, format!("Fuck D: {:?}", e))))
-						}
-					};
-					es.add_parsed_file(path.into(), text.into(), parsed)
-						.unwrap();
-					writeln!(log, "parsed: {:?}", uri).unwrap();
-				};
-
-				match &*req.method {
-					DidOpenTextDocument::METHOD => {
-						let params: DidOpenTextDocumentParams =
-							match serde_json::from_value(req.params) {
-								Ok(x) => x,
-								Err(_) => continue,
-							};
-						handle(params.text_document.text, params.text_document.uri);
-					}
-					DidChangeTextDocument::METHOD => {
-						let params: DidChangeTextDocumentParams =
-							match serde_json::from_value(req.params) {
-								Ok(x) => x,
-								Err(_) => continue,
-							};
-						for change in params.content_changes.into_iter() {
-							handle(change.text, params.text_document.uri.clone());
-						}
-					}
-					_ => continue,
-				}
-			}
-		}
-	}
-	Ok(())
-}
-fn cast<R>(req: &Request) -> Option<(RequestId, R::Params)>
-where
-	R: lsp_types::request::Request,
-	R::Params: serde::de::DeserializeOwned,
-{
-	req.clone().extract(R::METHOD).ok()
-}
modifiedxtask/src/sourcegen/ast.rsdiffbeforeafterboth
--- a/xtask/src/sourcegen/ast.rs
+++ b/xtask/src/sourcegen/ast.rs
@@ -151,6 +151,19 @@
 						if let Some(old) = types.insert(field.ty(), field.method_name(kinds)) {
 							panic!("{name}.{} has same type as {name}.{}, resolve conflict by wrapping one field: {}", old, field.method_name(kinds), field.ty());
 						}
+						// TODO: check for assignable field types, i.e you can have
+						// ```
+						// SomeEnum =
+						//     SomeItem
+						// |   SomeOtherItem
+						// ```
+						// And check above will fail to detect conflict in
+						// ```
+						// SomeStruct =
+						//     SomeEnum
+						//     SomeItem
+						// ```
+						// Despite generating getters, which will both return SomeEnum
 					}
 					res.nodes.push(AstNodeSrc {
 						doc: Vec::new(),