pharo
pharo copied to clipboard
Refactoring - Extract Method on a seemingly valid sub expression gives invalid unmatched on string literal error
Bug description I wanted to extract a portion of a string concatenation sequence, and hiliting what I would consider a valid expression gives the error Invalid source to extract - unmmatched ` in string literal.
To Reproduce Steps to reproduce the behavior:
- Create a method like:
| searchRule replaceRule methodParseTree rewriter |
searchRule := aMethod selector asString, ' arg','
| `@temps |
`.@before.
', original, '
`.@after'.
- Select the text from aMethod up to the end of arg' (meta -2 selects this as an expression
- Select the extract method command
- See error
Expected behavior I would expect to be able to extract this as a valid method - I think the error is incorrect.
Screenshots If applicable, add screenshots to help explain your problem.
Version information:
- OS: [e.g. iOS]
- Version: [e.g. 1.6.1]
- Pharo Version P12
Expected development cost Medium - needs a bit of understanding of parsing and the refactoring engine
Additional context Add any other context about the problem here.
Splitting the above expression and terminating it with a "." vs a "," correctly lets you extract method - so it looks like this is a question of interpreting the ast.
eg. you can extract the text in this rework (but I still think it should be possible to do my original intent).
searchRule := aMethod selector asString, ' `arg'.
searchRule := searchRule ,'
| `@temps |
`.@before.
', original, '
`.@after'.
In fact looking at the AST it would seem that the refactoring is basing its decision on the wrong node - there is a complete expression that it could use and it must be looking up the wrong one.