-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
790660b
commit 3071c38
Showing
6 changed files
with
87 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use std::collections::LinkedList; | ||
|
||
#[derive(Debug, Default)] | ||
pub(crate) struct Apply { | ||
pub left: Option<rnix::SyntaxElement>, | ||
pub comments: LinkedList<String>, | ||
pub newline: bool, | ||
pub right: Option<rnix::SyntaxElement>, | ||
} | ||
|
||
pub(crate) fn parse( | ||
build_ctx: &crate::builder::BuildCtx, | ||
node: &rnix::SyntaxNode, | ||
) -> Apply { | ||
let mut apply = Apply::default(); | ||
|
||
let mut children = crate::children::Children::new(build_ctx, node); | ||
|
||
// left | ||
apply.left = Some(children.get_next().unwrap()); | ||
|
||
// /**/ | ||
children.drain_trivia(|element| match element { | ||
crate::children::Trivia::Comment(text) => { | ||
apply.comments.push_back(text); | ||
} | ||
crate::children::Trivia::Whitespace(text) => { | ||
if !apply.newline { | ||
apply.newline = crate::utils::count_newlines(&text) > 0; | ||
} | ||
} | ||
}); | ||
|
||
// right | ||
apply.right = Some(children.get_next().unwrap()); | ||
|
||
apply | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub(crate) mod apply; | ||
pub(crate) mod if_else; | ||
pub(crate) mod pattern; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters