Skip to content

Commit

Permalink
Merge branch 'main' into ak/slice-all-collections
Browse files Browse the repository at this point in the history
  • Loading branch information
KuechA authored Oct 21, 2024
2 parents b4ff771 + 6c0682a commit b36e104
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ fun <T : Node> T.codeAndLocationFrom(other: Node): T {
* expression handler.
*/
context(CodeAndLocationProvider<AstNode>)
fun <T : Node, AstNode> T.codeAndLocationFromOtherRawNode(rawNode: AstNode): T {
setCodeAndLocation(this@CodeAndLocationProvider, rawNode)
fun <T : Node, AstNode> T.codeAndLocationFromOtherRawNode(rawNode: AstNode?): T {
rawNode?.let { setCodeAndLocation(this@CodeAndLocationProvider, it) }
return this
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ class StatementHandler(frontend: PythonLanguageFrontend) :
is Python.AST.Assert -> handleAssert(node)
is Python.AST.Try -> handleTryStatement(node)
is Python.AST.Delete -> handleDelete(node)
is Python.AST.With -> handleWithStatement(node)
is Python.AST.With,
is Python.AST.AsyncWith -> handleWithStatement(node)
is Python.AST.Global -> handleGlobal(node)
is Python.AST.Nonlocal -> handleNonLocal(node)
is Python.AST.Raise -> handleRaise(node)
is Python.AST.Match,
is Python.AST.TryStar,
is Python.AST.AsyncWith ->
is Python.AST.TryStar ->
newProblemExpression(
"The statement of class ${node.javaClass} is not supported yet",
rawNode = node
Expand Down Expand Up @@ -133,7 +133,7 @@ class StatementHandler(frontend: PythonLanguageFrontend) :
* manager.__exit__(None, None, None)
* ```
*/
private fun handleWithStatement(node: Python.AST.With): Block {
private fun handleWithStatement(node: Python.AST.NormalOrAsyncWith): Block {
/**
* Prepares the `manager = ContextManager()` and returns the random name for the "manager"
* as well as the assignment.
Expand Down Expand Up @@ -246,8 +246,8 @@ class StatementHandler(frontend: PythonLanguageFrontend) :
tmpValName
)
}

val result = newBlock().codeAndLocationFromOtherRawNode(node).implicit()
val result =
newBlock().codeAndLocationFromOtherRawNode(node as? Python.AST.BaseStmt).implicit()

// If there are multiple elements in node.items, we have to nest the try statements.
// We start with a generic block for the outer context manager.
Expand Down Expand Up @@ -293,7 +293,7 @@ class StatementHandler(frontend: PythonLanguageFrontend) :
)
}
}
.codeAndLocationFromOtherRawNode(node)
.codeAndLocationFromOtherRawNode(node as? Python.AST.BaseStmt)
.implicit()
// Add the catch block
this.catchClauses.add(
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/CPG/specs/dfg.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ The return value flows to the whole statement.
Scheme:
```mermaid
flowchart LR
exception -- DFG --> node([ReturnStatement]);
exception -- DFG --> node([ThrowStatement]);
parentException -- DFG --> node;
exception -.- node;
parentException -.- node;
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/CPG/specs/eog.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ flowchart LR
prev:::outer --EOG--> child1["exception"]
child1 --EOG--> child2["parentException"]
child2 --EOG-->parent
parent(["throw"]) --EOG--> catchingContext:::outer
parent(["ThrowStatement"]) --EOG--> catchingContext:::outer
parent -.-> child1
parent -.-> child2
Expand Down

0 comments on commit b36e104

Please sign in to comment.