File tree Expand file tree Collapse file tree
csharp/ql/lib/semmle/code/csharp Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -277,15 +277,31 @@ module AssignableInternal {
277277 def = TParameterDefaultDefinition ( _, result )
278278 }
279279
280- /** A local variable declaration at the top-level of a pattern . */
281- class TopLevelPatternDecl extends LocalVariableDeclExpr {
280+ /** A pattern containing a local variable declaration . */
281+ class LocalVariablePatternDecl extends LocalVariableDeclExpr {
282282 private PatternMatch pm ;
283283
284- TopLevelPatternDecl ( ) { this = pm .getPattern ( ) .( BindingPatternExpr ) .getVariableDeclExpr ( ) }
284+ LocalVariablePatternDecl ( ) {
285+ exists ( BindingPatternExpr bpe |
286+ this = bpe .getVariableDeclExpr ( ) and pm = bpe .getPatternMatch ( )
287+ )
288+ }
289+
290+ /** Holds if the local variable definition is at the top level of the pattern. */
291+ predicate isTopLevel ( ) { this = pm .getPattern ( ) .( BindingPatternExpr ) .getVariableDeclExpr ( ) }
285292
293+ /** Holds of this local variable definition is a part of a tuple pattern. */
294+ predicate isInTuple ( ) { this .getParent ( ) instanceof TuplePatternExpr }
295+
296+ /** Gets the pattern match that this local variable declaration (pattern) belongs to. */
286297 PatternMatch getMatch ( ) { result = pm }
287298 }
288299
300+ /** A local variable declaration at the top-level of a pattern. */
301+ class TopLevelPatternDecl extends LocalVariablePatternDecl {
302+ TopLevelPatternDecl ( ) { this .isTopLevel ( ) }
303+ }
304+
289305 cached
290306 private module Cached {
291307 cached
You can’t perform that action at this time.
0 commit comments