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

Correct parsing for f-string string literal concatenation #92

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

knutwannheden
Copy link
Contributor

@knutwannheden knutwannheden commented Oct 19, 2024

Fixes #91

Add support for f-string literal concatenation in the Python parser.

  • Py.java

    • Add a new nested StringLiteralConcatenation type to handle string literal concatenation.
    • Implement getType() to return JavaType.Primitive.String.
    • Implement setType() to return this.
  • _parser_visitor.py

    • Update the visit_Constant method to handle string literal concatenation combined with f-strings.
    • Add logic to produce Py.StringLiteralConcatenation nodes for string literal concatenation.
    • Update the __map_fstring method to handle the difficult piece of logic for f-string concatenation.
  • fstring_test.py

    • Add tests to verify correct parsing of string literal concatenation combined with f-strings.
    • Add tests to verify correct parsing of f-string literal concatenation with comments.

For more details, open the Copilot Workspace session.

Fixes #91

Add support for f-string literal concatenation in the Python parser.

* **Py.java**
  - Add a new nested `StringLiteralConcatenation` type to handle string literal concatenation.
  - Implement `getType()` to return `JavaType.Primitive.String`.
  - Implement `setType()` to return `this`.

* **_parser_visitor.py**
  - Update the `visit_Constant` method to handle string literal concatenation combined with f-strings.
  - Add logic to produce `Py.StringLiteralConcatenation` nodes for string literal concatenation.
  - Update the `__map_fstring` method to handle the difficult piece of logic for f-string concatenation.

* **fstring_test.py**
  - Add tests to verify correct parsing of string literal concatenation combined with f-strings.
  - Add tests to verify correct parsing of f-string literal concatenation with comments.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/openrewrite/rewrite-python/issues/91?shareId=XXXX-XXXX-XXXX-XXXX).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Correct parsing for f-string string literal concatenation
1 participant