-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
[c#] refactor composeMethodFullName-alikes (#5267)
1 parent
21f2bc7
commit 6b9c87e
Showing
4 changed files
with
36 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
joern-cli/frontends/csharpsrc2cpg/src/main/scala/io/joern/csharpsrc2cpg/utils/Utils.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
package io.joern.csharpsrc2cpg.utils | ||
|
||
import io.joern.x2cpg.Ast | ||
import io.shiftleft.codepropertygraph.generated.nodes.NewMethodParameterIn | ||
|
||
object Utils { | ||
def composeMethodLikeSignature(returnType: String, parameterTypes: collection.Seq[String]): String = { | ||
s"$returnType(${parameterTypes.mkString(",")})" | ||
} | ||
|
||
def composeMethodLikeSignature(returnType: String, parameters: Seq[Ast] = Nil): String = { | ||
composeMethodLikeSignature( | ||
returnType, | ||
parameters.flatMap(_.nodes.collectFirst { case x: NewMethodParameterIn => x.typeFullName }) | ||
) | ||
} | ||
|
||
def composeMethodFullName(typeDeclFullName: String, name: String, signature: String): String = { | ||
s"$typeDeclFullName.$name:$signature" | ||
} | ||
|
||
def composeGetterName(fieldIdentifierName: String): String = s"get_$fieldIdentifierName" | ||
|
||
} |