Skip to content

Conversation

lihaoyi
Copy link
Contributor

@lihaoyi lihaoyi commented Aug 29, 2025

SIP language feature discussion https://contributors.scala-lang.org/t/sip-xx-dedented-multiline-string-literals/7197

  • Add new token types: tDEDENTED_STRING, tINTERPOLATED_DEDENTED_STRING, tINTERPOLATED_DEDENTED_RAW_STRING
  • Update lexer grammar to recognize ''' delimiters with extended delimiter support
  • Add INSIDE_DEDENTED_INTERPOLATED_STRING state and DedentedLevel class
  • Support string interpolation for dedented strings
  • Add comprehensive test coverage for basic, extended, and interpolated dedented strings
  • Regenerated _ScalaCoreLexer.java from updated flex grammar

🤖 Generated with Claude Code

@lihaoyi lihaoyi changed the title Add support for '''- delimited strings (dedented string literals) in Scala 3 [WIP] Add support for '''- delimited strings (dedented string literals) in Scala 3 Aug 29, 2025
@lihaoyi
Copy link
Contributor Author

lihaoyi commented Aug 29, 2025

I'm having trouble testing this manually, it seems the head of intellij-scala doesn't work on the latest intellij 2025.2 (Plugin 'Scala' (version 'SNAPSHOT') is not compatible with the current version of the IDE, because it requires build 252.25557 or newer but the current build is IU-252.23892.409), and ./installers.cmd in intellij-community seems to be taking forever. Is there an easy way to test this out manually?

@lihaoyi
Copy link
Contributor Author

lihaoyi commented Aug 29, 2025

Managed to get this working locally by building intellij-scala on a slightly older commit

Screenshot 2025-08-29 at 4 24 40 PM

@lihaoyi lihaoyi force-pushed the idea252.x-dedented-strings branch from 21973f0 to 649c5f9 Compare August 29, 2025 09:32
@lihaoyi
Copy link
Contributor Author

lihaoyi commented Aug 29, 2025

Now it works for extensible delimiters too, at least up to a point:

Screenshot 2025-08-29 at 5 31 47 PM

So far hardcoded to work up to length=6 ''''''. There is probably a better way to do this so it works with arbitrarily long delimiters, but this works in a pinch

@lihaoyi lihaoyi force-pushed the idea252.x-dedented-strings branch from 649c5f9 to 36d92fa Compare August 29, 2025 09:38
@lihaoyi lihaoyi marked this pull request as draft August 29, 2025 14:21
@SrTobi
Copy link
Contributor

SrTobi commented Aug 29, 2025

Hey @lihaoyi. Cool that you got it to work. We also looked at the sip and came up with the following points that have to be investigated and potentially adjusted when the SIP is greenlighted:

  • Auto-indent on Enter/Delete/Backspace
  • Insert/delete complementary quote
  • Don't modify the contents on Format
  • Don't add .stripMargin
  • Copy/Paste handling
  • IntelliLang (language injection)

Features:

  • Re-indent on indenting val
  • Intention: convert between different literal kinds
  • Additional inspections (preferable to lexer errors)

We'd like to wait for the sip to be accepted before we start working on it or merge any feature regarding it.

@lihaoyi
Copy link
Contributor Author

lihaoyi commented Aug 29, 2025

Yes of course. This is just an initial proof of concept, I expect it'll take some work to polish but that can wait until the SIP is reviewed and accepted into the language

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

Successfully merging this pull request may close these issues.

2 participants