elimitate the irrelative asts that included in this file.
(ast: &'a mut Node, headers: &Vec<PathBuf>)
| 143 | |
| 144 | /// elimitate the irrelative asts that included in this file. |
| 145 | fn eliminate_irrelative_ast<'a>(ast: &'a mut Node, headers: &Vec<PathBuf>) -> &'a Node { |
| 146 | ast.inner.retain_mut(|child| match &child.kind { |
| 147 | Clang::EnumDecl(el) => is_defined_in_headers(&el.loc, headers), |
| 148 | Clang::FunctionDecl(fd) => is_defined_in_headers(&fd.loc, headers), |
| 149 | Clang::RecordDecl(rd) => is_defined_in_headers(&rd.loc, headers), |
| 150 | Clang::CXXRecordDecl(crd) => is_defined_in_headers(&crd.loc, headers), |
| 151 | Clang::TypedefDecl(td) => is_defined_in_headers(&td.loc, headers), |
| 152 | Clang::LinkageSpecDecl(lsd) => { |
| 153 | if is_defined_in_headers(&lsd.loc, headers) { |
| 154 | eliminate_irrelative_ast(child, headers); |
| 155 | return true; |
| 156 | } |
| 157 | false |
| 158 | } |
| 159 | _ => false, |
| 160 | }); |
| 161 | ast |
| 162 | } |
| 163 | |
| 164 | /// whether the ast element is definied inside the header file |
| 165 | fn is_defined_in_headers(loc: &SourceLocation, headers: &Vec<PathBuf>) -> bool { |
no test coverage detected