@@ -16,7 +16,7 @@ use ra_ap_ide_db::RootDatabase;
1616use ra_ap_ide_db:: line_index:: { LineCol , LineIndex } ;
1717use ra_ap_parser:: SyntaxKind ;
1818use ra_ap_span:: TextSize ;
19- use ra_ap_syntax:: ast:: HasName ;
19+ use ra_ap_syntax:: ast:: { Const , Fn , HasName , Static } ;
2020use ra_ap_syntax:: {
2121 AstNode , NodeOrToken , SyntaxElementChildren , SyntaxError , SyntaxNode , SyntaxToken , TextRange ,
2222 ast,
@@ -598,7 +598,34 @@ impl<'a> Translator<'a> {
598598 } ) ( ) ;
599599 }
600600
601- pub ( crate ) fn should_be_excluded ( & self , item : & impl ast:: HasAttrs ) -> bool {
601+ pub ( crate ) fn should_be_excluded ( & self , item : & ( impl ast:: HasAttrs + ast:: AstNode ) ) -> bool {
602+ if "true"
603+ == std:: env:: var ( "CODEQL_EXTRACTOR_RUST_OPTION_EXCLUDE_BODIES" ) . unwrap_or_default ( )
604+ {
605+ let syntax = item. syntax ( ) ;
606+ if let Some ( body) = syntax. parent ( ) . and_then ( Fn :: cast) . and_then ( |x| x. body ( ) ) {
607+ if body. syntax ( ) == syntax {
608+ tracing:: debug!( "Skipping Fn body" ) ;
609+ return true ;
610+ }
611+ }
612+ if let Some ( body) = syntax. parent ( ) . and_then ( Const :: cast) . and_then ( |x| x. body ( ) ) {
613+ if body. syntax ( ) == syntax {
614+ tracing:: debug!( "Skipping Const body" ) ;
615+ return true ;
616+ }
617+ }
618+ if let Some ( body) = syntax
619+ . parent ( )
620+ . and_then ( Static :: cast)
621+ . and_then ( |x| x. body ( ) )
622+ {
623+ if body. syntax ( ) == syntax {
624+ tracing:: debug!( "Skipping Static body" ) ;
625+ return true ;
626+ }
627+ }
628+ }
602629 self . semantics . is_some_and ( |sema| {
603630 item. attrs ( ) . any ( |attr| {
604631 attr. as_simple_call ( ) . is_some_and ( |( name, tokens) | {
0 commit comments