@@ -73,9 +73,16 @@ private module Ast implements AstSig<Location> {
7373 private AstNode getParent ( AstNode n ) { n = getChild ( result , _) }
7474
7575 Callable getEnclosingCallable ( AstNode node ) {
76- result = node .( ControlFlowElement ) .getEnclosingCallable ( ) or
77- result .( ObjectInitMethod ) .initializes ( getParent * ( node ) ) or
76+ result = node .( ControlFlowElement ) .getEnclosingCallable ( )
77+ or
78+ result .( ObjectInitMethod ) .initializes ( getParent * ( node ) )
79+ or
7880 Initializers:: staticMemberInitializer ( result , getParent * ( node ) )
81+ or
82+ result = node .( Parameter ) .getCallable ( )
83+ or
84+ not skipControlFlow ( node ) and
85+ getParent * ( node ) = any ( Parameter p | result = p .getCallable ( ) ) .getDefaultValue ( )
7986 }
8087
8188 class Callable = CS:: Callable ;
@@ -85,6 +92,17 @@ private module Ast implements AstSig<Location> {
8592 result = c .getBody ( )
8693 }
8794
95+ final private class ParameterFinal = CS:: Parameter ;
96+
97+ class Parameter extends ParameterFinal {
98+ Expr getDefaultValue ( ) {
99+ result = super .getDefaultValue ( ) and
100+ getCompilation ( result .getFile ( ) ) = getCompilation ( this .getFile ( ) )
101+ }
102+ }
103+
104+ Parameter callableGetParameter ( Callable c , int i ) { result = c .getParameter ( i ) }
105+
88106 class Stmt = CS:: Stmt ;
89107
90108 class Expr = CS:: Expr ;
@@ -415,10 +433,10 @@ private module Input implements InputSig1, InputSig2 {
415433 l = TLblGoto ( n .( LabelStmt ) .getLabel ( ) )
416434 }
417435
418- class CallableBodyPartContext = CompilationExt ;
436+ class CallableContext = CompilationExt ;
419437
420438 pragma [ nomagic]
421- Ast:: AstNode callableGetBodyPart ( Callable c , CallableBodyPartContext ctx , int index ) {
439+ Ast:: AstNode callableGetBodyPart ( Callable c , CallableContext ctx , int index ) {
422440 not Ast:: skipControlFlow ( result ) and
423441 ctx = getCompilation ( result .getFile ( ) ) and
424442 (
@@ -437,9 +455,19 @@ private module Input implements InputSig1, InputSig2 {
437455 or
438456 i = 2 and result = ctor .getBody ( )
439457 )
458+ or
459+ not c instanceof Constructor and
460+ result = c .getBody ( ) and
461+ index = 0
440462 )
441463 }
442464
465+ pragma [ nomagic]
466+ Ast:: Parameter callableGetParameter ( Callable c , CallableContext ctx , int index ) {
467+ result = Ast:: callableGetParameter ( c , index ) and
468+ ctx = getCompilation ( result .getFile ( ) )
469+ }
470+
443471 private Expr getQualifier ( QualifiableExpr qe ) {
444472 result = qe .getQualifier ( ) or
445473 result = qe .( ExtensionMethodCall ) .getArgument ( 0 )
0 commit comments