Skip to content
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

[bug] [PiranhaAgent] error thrown after applying the inferred rule to the sample before/after snippet in the doc #561

Open
alexbit-codemod opened this issue Jul 27, 2023 · 3 comments

Comments

@alexbit-codemod
Copy link

  1. successfully installed the playground.
  2. put the before and after code from the doc here: https://github.com/uber/piranha/tree/master/experimental in the relevant boxes
  3. clicked on infer rules from templates. got some rule inferred.
  4. clicked Apply rule to before and got the following error in the code after section
127.0.0.1 - - [24/Jul/2023 16:19:04] "POST /refactor_codebase HTTP/1.1" 400 -
thread '<unnamed>' panicked at 'Could not parse the query : "((method_declaration\n type: (void_type ) @tag2n\n name: (identifier ) @tag3n\n parameters: (formal_parameters \n  (formal_parameter \n   type: (type_identifier ) @tag6n\n   name: (identifier ) @tag7n) @tag5n) @tag4n\n body: (block ) @tag8n) @tag1n\n(#eq? @tag2n \"void\")\n(#eq? @tag3n \"someMethod\")\n(#eq? @tag6n \"String\")\n(#eq? @tag7n \"arg\")\n(#eq? @tag8n \"{\n\n  }\"))" Some(QueryError { row: 12, column: 13, offset: 346, message: "(#eq? @tag8n \"{\n             ^", kind: Syntax })', src/models/language.rs:77:5

Screenshot 2023-07-24 at 4 26 48 PM

@alexbit-codemod alexbit-codemod changed the title [bug] [PiranhaAgent] error thrown after running the inferred rule for the sample before/after snippet in the doc [bug] [PiranhaAgent] error thrown after applying the inferred rule to the sample before/after snippet in the doc Jul 27, 2023
@alexbit-codemod
Copy link
Author

seems that the inferred rule has some syntax issues.

@alexbit-codemod
Copy link
Author

strangely enough, even though the code is in java, when i switch the picker in playground to kotlin and try to infer rule again, i can actually apply the inferred rules and get the correct result!
it just says "Produced syntactically incorrect source code" but it is actually corret. @ketkarameya

@danieltrt
Copy link
Collaborator

The problem is the new lines in 15 through 17 (#eq? tag8n …). The static inference algorithm is not that smart, I’ll fix it.

I assume it’s saying incorrect source code because the Kotlin parser is unable to parse the code

danieltrt added a commit that referenced this issue Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants