diff --git a/crates/html-macro/src/parser/braced.rs b/crates/html-macro/src/parser/braced.rs index a6304a61..a77d452f 100644 --- a/crates/html-macro/src/parser/braced.rs +++ b/crates/html-macro/src/parser/braced.rs @@ -1,9 +1,8 @@ -use crate::parser::{is_self_closing, HtmlParser}; -use crate::tag::{Attr, Tag}; -use proc_macro2::{Ident, Span}; -use quote::{quote, quote_spanned}; +use crate::parser::HtmlParser; +use proc_macro2::Ident; +use quote::quote; use syn::spanned::Spanned; -use syn::{Block, Expr}; +use syn::Block; impl HtmlParser { /// Parse an incoming Tag::Braced text node diff --git a/crates/html-macro/src/parser/close_tag.rs b/crates/html-macro/src/parser/close_tag.rs index 1870406a..56918042 100644 --- a/crates/html-macro/src/parser/close_tag.rs +++ b/crates/html-macro/src/parser/close_tag.rs @@ -1,17 +1,12 @@ use crate::parser::{is_self_closing, HtmlParser}; -use crate::tag::{Attr, Tag}; use proc_macro2::Ident; -use quote::{quote, quote_spanned}; -use syn::Expr; +use quote::quote_spanned; impl HtmlParser { /// Parse an incoming Tag::Close pub(crate) fn parse_close_tag(&mut self, name: Ident) { - let idx = &mut self.current_idx; - let parent_to_children = &mut self.parent_to_children; let parent_stack = &mut self.parent_stack; let tokens = &mut self.tokens; - let node_order = &mut self.node_order; let close_span = name.span(); let close_tag = name.to_string(); diff --git a/crates/html-macro/src/parser/mod.rs b/crates/html-macro/src/parser/mod.rs index 2b3fde07..099dd100 100644 --- a/crates/html-macro/src/parser/mod.rs +++ b/crates/html-macro/src/parser/mod.rs @@ -3,9 +3,7 @@ use proc_macro2::LineColumn; use quote::{quote, quote_spanned}; use std::collections::HashMap; use syn::export::Span; -use syn::group::parse_braces; -use syn::spanned::Spanned; -use syn::{Expr, Ident}; +use syn::Ident; mod braced; mod close_tag; @@ -56,12 +54,6 @@ impl HtmlParser { /// Generate the tokens for the incoming Tag and update our parser's heuristics that keep /// track of information about what we've parsed. pub fn push_tag(&mut self, tag: Tag) { - let idx = &mut self.current_idx; - let parent_stack = &mut self.parent_stack; - let node_order = &mut self.node_order; - let parent_to_children = &mut self.parent_to_children; - let tokens = &mut self.tokens; - match tag { Tag::Open { name, attrs } => { self.parse_open_tag(name, attrs); @@ -129,22 +121,14 @@ impl HtmlParser { }; node } -} -// TODO: Cache this as a HashSet inside of our parser -fn is_self_closing(tag: &str) -> bool { - let whitelist = [ - "area", "base", "br", "col", "hr", "img", "input", "link", "meta", "param", "command", - "keygen", "source", - ]; - - for whitelisted in whitelist.iter() { - if &tag == whitelisted { - return true; - } + /// Set the location of the most recent start tag's ending LineColumn + fn set_most_recent_start_tag_end (&mut self, span: Span) { } - return false; + /// Set the location of the most recent start tag's ending LineColumn + fn set_most_recent_block_start (&mut self, span: Span) { + } } /// Keep track of the locations of different kinds of tokens that we encounter. @@ -161,3 +145,19 @@ struct RecentSpanLocations { most_recent_start_tag_end: Option, most_recent_block_start: Option, } + +// TODO: Cache this as a HashSet inside of our parser +fn is_self_closing(tag: &str) -> bool { + let whitelist = [ + "area", "base", "br", "col", "hr", "img", "input", "link", "meta", "param", "command", + "keygen", "source", + ]; + + for whitelisted in whitelist.iter() { + if &tag == whitelisted { + return true; + } + } + + return false; +} diff --git a/crates/html-macro/src/parser/open_tag.rs b/crates/html-macro/src/parser/open_tag.rs index 655c30df..12c1f234 100644 --- a/crates/html-macro/src/parser/open_tag.rs +++ b/crates/html-macro/src/parser/open_tag.rs @@ -1,5 +1,5 @@ use crate::parser::{is_self_closing, HtmlParser}; -use crate::tag::{Attr, Tag}; +use crate::tag::Attr; use proc_macro2::Ident; use quote::quote; use syn::Expr; diff --git a/crates/html-macro/src/parser/text.rs b/crates/html-macro/src/parser/text.rs index b38b6be6..9afe5eed 100644 --- a/crates/html-macro/src/parser/text.rs +++ b/crates/html-macro/src/parser/text.rs @@ -1,8 +1,6 @@ -use crate::parser::{is_self_closing, HtmlParser}; -use crate::tag::{Attr, Tag}; +use crate::parser::HtmlParser; use proc_macro2::{Ident, Span}; -use quote::{quote, quote_spanned}; -use syn::Expr; +use quote::quote; impl HtmlParser { /// Parse an incoming Tag::Text text node diff --git a/crates/html-macro/src/tag.rs b/crates/html-macro/src/tag.rs index e8f0fecb..091538ac 100644 --- a/crates/html-macro/src/tag.rs +++ b/crates/html-macro/src/tag.rs @@ -162,7 +162,7 @@ fn parse_block(input: &mut ParseStream) -> Result { fn parse_text_node(input: &mut ParseStream) -> Result { // Continue parsing tokens until we see a closing tag < - let text_tokens = TokenStream::new(); + let _text_tokens = TokenStream::new(); let mut text = "".to_string();