mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 12:43:08 +00:00
Make clippy happy
This commit is contained in:
parent
58233c6a3b
commit
9474ad54cc
4 changed files with 24 additions and 32 deletions
|
@ -119,7 +119,7 @@ fn watch_event<F>(
|
||||||
let mut needs_full_rebuild = false;
|
let mut needs_full_rebuild = false;
|
||||||
|
|
||||||
if let Some(hot_reload) = &hot_reload {
|
if let Some(hot_reload) = &hot_reload {
|
||||||
hotreload_files(hot_reload, &mut needs_full_rebuild, &event, &config);
|
hotreload_files(hot_reload, &mut needs_full_rebuild, &event, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
if needs_full_rebuild {
|
if needs_full_rebuild {
|
||||||
|
@ -142,7 +142,7 @@ fn full_rebuild<F>(
|
||||||
|
|
||||||
#[allow(clippy::redundant_clone)]
|
#[allow(clippy::redundant_clone)]
|
||||||
print_console_info(
|
print_console_info(
|
||||||
&config,
|
config,
|
||||||
PrettierOptions {
|
PrettierOptions {
|
||||||
changed: event.paths.clone(),
|
changed: event.paths.clone(),
|
||||||
warnings: res.warnings,
|
warnings: res.warnings,
|
||||||
|
@ -186,10 +186,7 @@ fn hotreload_files(
|
||||||
// If the file was hotreloaded, update the file map in place
|
// If the file was hotreloaded, update the file map in place
|
||||||
match rsx_file_map.update_rsx(path, &config.crate_dir) {
|
match rsx_file_map.update_rsx(path, &config.crate_dir) {
|
||||||
Ok(UpdateResult::UpdatedRsx(msgs)) => {
|
Ok(UpdateResult::UpdatedRsx(msgs)) => {
|
||||||
messages.extend(
|
messages.extend(msgs.into_iter().map(HotReloadMsg::UpdateTemplate));
|
||||||
msgs.into_iter()
|
|
||||||
.map(|msg| HotReloadMsg::UpdateTemplate(msg)),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the file was not updated, we need to do a full rebuild
|
// If the file was not updated, we need to do a full rebuild
|
||||||
|
@ -227,7 +224,7 @@ fn hotreload_files(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hotreload_file(
|
fn hotreload_file(
|
||||||
path: &PathBuf,
|
path: &Path,
|
||||||
config: &CrateConfig,
|
config: &CrateConfig,
|
||||||
rsx_file_map: &std::sync::MutexGuard<'_, FileMap<HtmlCtx>>,
|
rsx_file_map: &std::sync::MutexGuard<'_, FileMap<HtmlCtx>>,
|
||||||
messages: &mut Vec<HotReloadMsg>,
|
messages: &mut Vec<HotReloadMsg>,
|
||||||
|
@ -282,14 +279,14 @@ fn hotreload_file(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn attempt_css_reload(
|
fn attempt_css_reload(
|
||||||
path: &PathBuf,
|
path: &Path,
|
||||||
asset_dir: PathBuf,
|
asset_dir: PathBuf,
|
||||||
rsx_file_map: &std::sync::MutexGuard<'_, FileMap<HtmlCtx>>,
|
rsx_file_map: &std::sync::MutexGuard<'_, FileMap<HtmlCtx>>,
|
||||||
config: &CrateConfig,
|
config: &CrateConfig,
|
||||||
messages: &mut Vec<HotReloadMsg>,
|
messages: &mut Vec<HotReloadMsg>,
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
// If the path is not in the asset directory, return
|
// If the path is not in the asset directory, return
|
||||||
if !path.starts_with(&asset_dir) {
|
if !path.starts_with(asset_dir) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +309,7 @@ fn attempt_css_reload(
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn local_path_of_asset(path: &PathBuf) -> Option<PathBuf> {
|
fn local_path_of_asset(path: &Path) -> Option<PathBuf> {
|
||||||
path.file_name()?.to_str()?.to_string().parse().ok()
|
path.file_name()?.to_str()?.to_string().parse().ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +320,7 @@ pub(crate) trait Platform {
|
||||||
fn rebuild(&mut self, config: &CrateConfig) -> Result<BuildResult>;
|
fn rebuild(&mut self, config: &CrateConfig) -> Result<BuildResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_backup_file(path: &PathBuf) -> bool {
|
fn is_backup_file(path: &Path) -> bool {
|
||||||
// If there's a tilde at the end of the file, it's a backup file
|
// If there's a tilde at the end of the file, it's a backup file
|
||||||
if let Some(name) = path.file_name() {
|
if let Some(name) = path.file_name() {
|
||||||
if let Some(name) = name.to_str() {
|
if let Some(name) = name.to_str() {
|
||||||
|
|
|
@ -559,7 +559,7 @@ impl VirtualDom {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(RenderReturn::Ready(sync)) = scope.try_root_node() {
|
if let Some(RenderReturn::Ready(sync)) = scope.try_root_node() {
|
||||||
if check_node_for_templates(&sync, template) {
|
if check_node_for_templates(sync, template) {
|
||||||
dirty.push(ScopeId(id));
|
dirty.push(ScopeId(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ impl<Ctx: HotReloadingContext> FileMap<Ctx> {
|
||||||
// If the cached file is not a valid rsx file, rebuild the project, forcing errors
|
// If the cached file is not a valid rsx file, rebuild the project, forcing errors
|
||||||
// TODO: in theory the error is simply in the RsxCallbody. We could attempt to parse it using partial expansion
|
// TODO: in theory the error is simply in the RsxCallbody. We could attempt to parse it using partial expansion
|
||||||
// And collect out its errors instead of giving up to a full rebuild
|
// And collect out its errors instead of giving up to a full rebuild
|
||||||
let old = syn::parse_file(&*old_cached.raw).map_err(|_e| HotreloadError::Parse)?;
|
let old = syn::parse_file(&old_cached.raw).map_err(|_e| HotreloadError::Parse)?;
|
||||||
|
|
||||||
let instances = match diff_rsx(&syntax, &old) {
|
let instances = match diff_rsx(&syntax, &old) {
|
||||||
// If the changes were just some rsx, we can just update the template
|
// If the changes were just some rsx, we can just update the template
|
||||||
|
@ -199,7 +199,7 @@ impl<Ctx: HotReloadingContext> FileMap<Ctx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
// update the cached file
|
// update the cached file
|
||||||
old_cached.templates.insert(template.name, template.clone());
|
old_cached.templates.insert(template.name, template);
|
||||||
|
|
||||||
// Track any new assets
|
// Track any new assets
|
||||||
old_cached
|
old_cached
|
||||||
|
@ -214,27 +214,22 @@ impl<Ctx: HotReloadingContext> FileMap<Ctx> {
|
||||||
|
|
||||||
fn populate_assets(template: Template) -> HashSet<PathBuf> {
|
fn populate_assets(template: Template) -> HashSet<PathBuf> {
|
||||||
fn collect_assetlike_attrs(node: &TemplateNode, asset_urls: &mut HashSet<PathBuf>) {
|
fn collect_assetlike_attrs(node: &TemplateNode, asset_urls: &mut HashSet<PathBuf>) {
|
||||||
match node {
|
if let TemplateNode::Element {
|
||||||
TemplateNode::Element {
|
|
||||||
attrs, children, ..
|
attrs, children, ..
|
||||||
} => {
|
} = node
|
||||||
|
{
|
||||||
for attr in attrs.iter() {
|
for attr in attrs.iter() {
|
||||||
match attr {
|
if let TemplateAttribute::Static { name, value, .. } = attr {
|
||||||
TemplateAttribute::Static { name, value, .. } => {
|
|
||||||
if *name == "src" || *name == "href" {
|
if *name == "src" || *name == "href" {
|
||||||
asset_urls.insert(PathBuf::from(*value));
|
asset_urls.insert(PathBuf::from(*value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for child in children.iter() {
|
for child in children.iter() {
|
||||||
collect_assetlike_attrs(child, asset_urls);
|
collect_assetlike_attrs(child, asset_urls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut asset_urls = HashSet::new();
|
let mut asset_urls = HashSet::new();
|
||||||
|
|
|
@ -53,7 +53,7 @@ pub(crate) fn init() -> UnboundedReceiver<Template> {
|
||||||
console::log_1(&links.clone().into());
|
console::log_1(&links.clone().into());
|
||||||
|
|
||||||
for x in 0..links.length() {
|
for x in 0..links.length() {
|
||||||
console::log_1(&x.clone().into());
|
console::log_1(&x.into());
|
||||||
|
|
||||||
let link: Element = links.get(x).unwrap().unchecked_into();
|
let link: Element = links.get(x).unwrap().unchecked_into();
|
||||||
let href = link.get_attribute("href").unwrap();
|
let href = link.get_attribute("href").unwrap();
|
||||||
|
|
Loading…
Reference in a new issue