@@ -75,7 +75,9 @@ private module Ast implements AstSig<Location> {
7575 Callable getEnclosingCallable ( AstNode node ) {
7676 result = node .( ControlFlowElement ) .getEnclosingCallable ( ) or
7777 result .( ObjectInitMethod ) .initializes ( getParent * ( node ) ) or
78- Initializers:: staticMemberInitializer ( result , getParent * ( node ) )
78+ Initializers:: staticMemberInitializer ( result , getParent * ( node ) ) or
79+ result = node .( Parameter ) .getCallable ( ) or
80+ node = any ( Parameter p | result = p .getCallable ( ) ) .getDefaultValue ( )
7981 }
8082
8183 class Callable = CS:: Callable ;
@@ -85,6 +87,17 @@ private module Ast implements AstSig<Location> {
8587 result = c .getBody ( )
8688 }
8789
90+ final private class ParameterFinal = CS:: Parameter ;
91+
92+ class Parameter extends ParameterFinal {
93+ Expr getDefaultValue ( ) {
94+ result = super .getDefaultValue ( ) and
95+ getCompilation ( result .getFile ( ) ) = getCompilation ( this .getFile ( ) )
96+ }
97+ }
98+
99+ Parameter callableGetParameter ( Callable c , int i ) { result = c .getParameter ( i ) }
100+
88101 class Stmt = CS:: Stmt ;
89102
90103 class Expr = CS:: Expr ;
@@ -234,7 +247,7 @@ private class CompilationExt extends TCompilationExt {
234247/** Gets the compilation that source file `f` belongs to. */
235248private CompilationExt getCompilation ( File f ) {
236249 exists ( Compilation c |
237- f = c .getAFileCompiled ( ) and
250+ f = [ c .getAFileCompiled ( ) , c . getAReference ( ) ] and
238251 result = TCompilation ( c )
239252 )
240253 or
@@ -415,10 +428,10 @@ private module Input implements InputSig1, InputSig2 {
415428 l = TLblGoto ( n .( LabelStmt ) .getLabel ( ) )
416429 }
417430
418- class CallableBodyPartContext = CompilationExt ;
431+ class CallableContext = CompilationExt ;
419432
420433 pragma [ nomagic]
421- Ast:: AstNode callableGetBodyPart ( Callable c , CallableBodyPartContext ctx , int index ) {
434+ Ast:: AstNode callableGetBodyPart ( Callable c , CallableContext ctx , int index ) {
422435 not Ast:: skipControlFlow ( result ) and
423436 ctx = getCompilation ( result .getFile ( ) ) and
424437 (
@@ -437,9 +450,19 @@ private module Input implements InputSig1, InputSig2 {
437450 or
438451 i = 2 and result = ctor .getBody ( )
439452 )
453+ or
454+ not c instanceof Constructor and
455+ result = c .getBody ( ) and
456+ index = 0
440457 )
441458 }
442459
460+ pragma [ nomagic]
461+ Ast:: Parameter callableGetParameter ( Callable c , CallableContext ctx , int index ) {
462+ result = Ast:: callableGetParameter ( c , index ) and
463+ ctx = getCompilation ( result .getFile ( ) )
464+ }
465+
443466 private Expr getQualifier ( QualifiableExpr qe ) {
444467 result = qe .getQualifier ( ) or
445468 result = qe .( ExtensionMethodCall ) .getArgument ( 0 )
0 commit comments