Skip to content

Commit

Permalink
Fix to work with new kcl_lib parser API
Browse files Browse the repository at this point in the history
  • Loading branch information
jtran committed Nov 8, 2024
1 parent fe1d114 commit 616eab3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
8 changes: 2 additions & 6 deletions src/cmd_kcl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ impl crate::cmd::Command for CmdKclFormat {
let input = std::str::from_utf8(&input)?;

// Parse the file.
let tokens = kcl_lib::token::lexer(input)?;
let parser = kcl_lib::parser::Parser::new(tokens);
let program = parser.ast()?;
let program = kcl_lib::parser::top_level_parse(input)?;

// Recast the program to a string.
let formatted = program.recast(
Expand Down Expand Up @@ -1041,9 +1039,7 @@ impl crate::cmd::Command for CmdKclLint {
let input = std::str::from_utf8(&input)?;

// Parse the file.
let tokens = kcl_lib::token::lexer(input)?;
let parser = kcl_lib::parser::Parser::new(tokens);
let program = parser.ast()?;
let program = kcl_lib::parser::top_level_parse(input)?;

for discovered_finding in program.lint_all()? {
let finding_range = discovered_finding.pos.to_lsp_range(input);
Expand Down
5 changes: 1 addition & 4 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,7 @@ impl Context<'_> {
) -> Result<(OkWebSocketResponseData, Option<ModelingSessionData>)> {
let client = self.api_client(hostname)?;

let tokens = kcl_lib::token::lexer(code)?;
let parser = kcl_lib::parser::Parser::new(tokens);
let program = parser
.ast()
let program = kcl_lib::parser::top_level_parse(code)
.map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?;

let ctx = kcl_lib::executor::ExecutorContext::new(&client, settings).await?;
Expand Down

0 comments on commit 616eab3

Please sign in to comment.