Skip to content

Commit 91b3905

Browse files
authored
call.argument with no args (#1022)
prior to this: ``` semanticcpg/console import io.shiftleft.codepropertygraph.Cpg import io.shiftleft.semanticcpg.language._ def cpg: Cpg = ??? def a = cpg.call.argument def b = cpg.call.head.argument cmd1.sc:1: missing argument list for method argument in class CallMethods Unapplied methods are only converted to functions when a function type is expected. ```
1 parent 64ee283 commit 91b3905

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
package io.shiftleft.semanticcpg.language.nodemethods
22

33
import io.shiftleft.codepropertygraph.generated.nodes
4-
import io.shiftleft.semanticcpg.language._
5-
import scala.jdk.CollectionConverters._
64
import overflowdb.traversal._
75

86
class CallMethods(val node: nodes.Call) extends AnyVal {
97
def arguments(index: Int): Traversal[nodes.Expression] =
10-
node._argumentOut.asScala
8+
node._argumentOut
119
.collect {
1210
case expr: nodes.Expression if expr.argumentIndex == index => expr
1311
}
1412
.to(Traversal)
1513

14+
def argument: Traversal[nodes.Expression] =
15+
node._argumentOut.collectAll[nodes.Expression]
16+
1617
def argument(index: Int): nodes.Expression =
1718
arguments(index).head
1819

1920
def argumentOption(index: Int): Option[nodes.Expression] =
20-
node._argumentOut.asScala
21-
.collectFirst {
22-
case expr: nodes.Expression if expr.argumentIndex == index => expr
23-
}
21+
node._argumentOut.collectFirst {
22+
case expr: nodes.Expression if expr.argumentIndex == index => expr
23+
}
2424
}

semanticcpg/src/main/scala/io/shiftleft/semanticcpg/language/types/expressions/Call.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ class Call(val traversal: Traversal[nodes.Call]) extends AnyVal {
3737
Arguments of the call
3838
*/
3939
def argument: Traversal[nodes.Expression] =
40-
traversal.out(EdgeTypes.ARGUMENT).cast[nodes.Expression]
40+
traversal.flatMap(_.argument)
4141

4242
/**
4343
`i'th` arguments of the call
4444
*/
4545
def argument(i: Integer): Traversal[nodes.Expression] =
46-
argument.argumentIndex(i)
46+
traversal.flatMap(_.argument(i))
4747

4848
/**
4949
To formal method return parameter

0 commit comments

Comments
 (0)