Skip to content

Commit

Permalink
Make the AI rabbit happy
Browse files Browse the repository at this point in the history
  • Loading branch information
arendjr committed Mar 26, 2024
1 parent 14083df commit 7efd67e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions crates/core/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ use tree_sitter::Parser;
#[cfg(feature = "grit-parser")]
pub fn parse_input_file(lang: &TargetLanguage, input: &str, path: &Path) -> Result<InputFile> {
use crate::tree_sitter_serde::tree_sitter_node_to_json;
use anyhow::Context;
use marzano_language::language::Language;
use serde_json::to_string_pretty;

let mut parser = Parser::new().unwrap();
parser.set_language(lang.get_ts_language()).unwrap();
let tree = parser.parse(input.as_bytes(), None).unwrap().unwrap();
let input_file_debug_text = to_string_pretty(&tree_sitter_node_to_json(
to_string_pretty(&tree_sitter_node_to_json(
&tree.root_node(),
input,
Some(lang),
))
.unwrap();
Ok(InputFile {
.context("Failed to convert tree to pretty JSON string")
.map(|syntax_tree| InputFile {
source_file: path.to_string_lossy().to_string(),
syntax_tree: input_file_debug_text,
syntax_tree,
})
}
#[cfg(not(feature = "grit-parser"))]
Expand Down

0 comments on commit 7efd67e

Please sign in to comment.