ocaml-tree-sitter-semgrep icon indicating copy to clipboard operation
ocaml-tree-sitter-semgrep copied to clipboard

[DO NOT MERGE] fix(kotlin): classes with newlines

Open amchiclet opened this issue 11 months ago • 1 comments

This PR refactors Brandon's PR, so the CST to Generic AST process becomes a bit easier. The rest of the description is copied and pasted from https://github.com/semgrep/ocaml-tree-sitter-semgrep/pull/476

What:

This PR makes it so we can parse Kotlin classes that have a newline between the class identifier and constructor.

Why:

Parse rate.

How:

The problem is in cases like:

class Foo
constructor Bar() { ... }

Here, we insert an automatic semicolon between Foo and constructor. This leaves us able to parse class Foo as a class_declaration, but constructor Bar ... is not allowed on its own.

We simply allow constructor Bar ... to be a standalone statement, and resolve to stitch them together at parsing time.

Security

  • [ ] Change has no security implications (otherwise, ping the security team)

amchiclet avatar Mar 27 '24 03:03 amchiclet

I will merge commits from this PR into Brandon's original PR: https://github.com/semgrep/ocaml-tree-sitter-semgrep/pull/476#discussion_r1541492626.

Not closing this PR yet. I'd like the branch to still be alive while merging changes.

amchiclet avatar Mar 27 '24 17:03 amchiclet