-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New traversal proposal. #1523
base: master
Are you sure you want to change the base?
New traversal proposal. #1523
Conversation
From your description, the advantages clearly outweight the disadvantages. The one thing I ask myself when seeing the example code is whether we can find any ways of making the complexity less visible to the language writer. @mpollmeier what are your thoughts? |
Just discussed this in detail with markus, and he's looking into a few additional points (e.g. support for Additional benefit that's not in the description yet: the end user (not the language designer) doesn't need to learn about Additional downside: when the language designer adds a non-trivial step (like in We also discussed and agreed that it makes sense to bring this in before upgrading to Scala 3, mostly because changing the Scala version and traversal impl wold mean a hard cut for all existing Scala 2 users. It'll be crucial to document this really really well, especially those additional generic terms like InputTraversal(IT) / FlatMapTraversal(IT) and TravNOps. Overall I'm positive for this PR. The complexity certainly goes up, but the benefits seem to outweigh the downsides. |
By using our own type class IsInstanceOfOps we now have the performance of a plain filter(_.isInstanceOf[...]).
moved new AstNode and Local traversals into their own files.
Reorganized implicits.
Always specify implicit return types.
This reverts commit d733696.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stale, please re-request review once you're ready to continue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stale
This is my proposal for a new generic traversal supposed to be used as replacement for our current
Traversal
class to build up our DSL steps.This proposal offers three advantages when compared to the current state:
Iterator
as well as non lazy iterations viaIterable
just buy including a different implicitPipeOps
iterator.Before i go into some of the details i dont want to spare you the drawbacks:
repeat(...)(_.emit)
would need to becomerepeat(..., _.emit)
. With scala 3 we would not need to make that change.I will now provide an example of the new DSL step definitions for the
referencingIdentifiers
step onLOCAL
nodes:Keep in mind this PR is just a proposal so it contains some stuff off less importance.
The new traversal core definitions are under
semanticcpg/src/main/scala/io/shiftleft/semanticcpg/langv2/
andMethodTraversal.scala
,AstNodeTraversal.scala
andLocalTraversal.scala
contain some example step implementations.Please ignore
semanticcpg/src/main/scala/io/shiftleft/semanticcpg/language/MySteps.scala
andsemanticcpg/src/main/scala/io/shiftleft/semanticcpg/language/PipeOps.scala
. They contain my first attempt for a new traversal but that approach while easier for the step writer turned out to be too slow.