Skip to content

Commit

Permalink
Move to source analysis object
Browse files Browse the repository at this point in the history
  • Loading branch information
xd009642 committed Aug 15, 2020
1 parent 6153462 commit 5cab48a
Show file tree
Hide file tree
Showing 7 changed files with 846 additions and 702 deletions.
54 changes: 28 additions & 26 deletions src/source_analysis/attributes.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
use crate::source_analysis::prelude::*;
use syn::*;

pub(crate) fn check_attr_list(
attrs: &[Attribute],
ctx: &Context,
analysis: &mut LineAnalysis,
) -> bool {
let mut check_cover = true;
for attr in attrs {
analysis.ignore_tokens(attr);
if let Ok(x) = attr.parse_meta() {
if check_cfg_attr(&x) {
check_cover = false;
} else if x.path().is_ident("cfg") {
match x {
Meta::List(ref ml) => {
let mut skip = false;
for c in &ml.nested {
if let NestedMeta::Meta(Meta::Path(ref i)) = c {
skip |= i.is_ident("test") && ctx.config.ignore_tests;
impl SourceAnalysis {
pub(crate) fn check_attr_list(&mut self, attrs: &[Attribute], ctx: &Context) -> bool {
let analysis = self
.lines
.entry(ctx.file.to_path_buf())
.or_insert_with(line_analysis_missing);
let mut check_cover = true;
for attr in attrs {
analysis.ignore_tokens(attr);
if let Ok(x) = attr.parse_meta() {
if check_cfg_attr(&x) {
check_cover = false;
} else if x.path().is_ident("cfg") {
match x {
Meta::List(ref ml) => {
let mut skip = false;
for c in &ml.nested {
if let NestedMeta::Meta(Meta::Path(ref i)) = c {
skip |= i.is_ident("test") && ctx.config.ignore_tests;
}
}
if skip {
check_cover = false;
}
}
if skip {
check_cover = false;
}
_ => {}
}
_ => {}
}
}
if !check_cover {
break;
}
}
if !check_cover {
break;
}
check_cover
}
check_cover
}

pub(crate) fn check_cfg_attr(attr: &Meta) -> bool {
Expand Down
Loading

0 comments on commit 5cab48a

Please sign in to comment.