Visitar URL original
Java: Add Expr.getAnEnclosingStmt · Issue #3631 · github/codeql · GitHub
The Wayback Machine - https://web.archive.org/web/20260603220619/https://github.com/github/codeql/issues/3631
Skip to content

Java: Add Expr.getAnEnclosingStmt #3631

@Marcono1234

Description

@Marcono1234

Description of the issue
Now and then I want to find out if a Stmt encloses (directly or transitively) an Expr.
Maybe I am missing something, but it appears doing this is rather verbose because it is not possible to use a transitive closure for Expr.getEnclosingStmt, so instead of

from Stmt stmt, Expr expr
where
  expr.getEnclosingStmt+() = stmt
select stmt, expr

you have to write

from Stmt stmt, Expr expr
where
  expr.getEnclosingStmt().getEnclosingStmt*() = stmt
select stmt, expr

Would it be possible to add an getAnEnclosingStmt (or similar) predicate to Expr?
Example implementation:

Stmt getAnEnclosingStmt() {
  result = getEnclosingStmt().getEnclosingStmt*()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    JavaquestionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions