-
Notifications
You must be signed in to change notification settings - Fork 54
Description
Motivation
Within OpenRewrite we use text blocks a lot to define our test cases.
We define the before and after source code as strings and heavily use IntelliJ's Java Reference feature to help us with formatting, syntax highlighting, and autocomplete.
I noticed VSCode does not provide a feature to interpret the text inside a string with a context.
This is also helpful if working with default Java TextBlock examples like JSON/XML.
Description
Strings often contain text that has a semantic tie to it.
One example is the use of TextBlocks in the JEP 378 here they use TextBlocks to return HTML or SQL.
Working with this content is easier if syntax highlighting, autocompletion, and formatting are available; otherwise, what's the point of using an IDE ;)
In IntelliJ IDEA and Eclipse you can assign context to texts, like the language used in them, to activate language support.
It's possible via the context menus or by adding //language=[XYZ]
above the string definition.
See the result below.
The sources I used to test are availbale here https://github.com/openrewrite/rewrite-hibernate/blob/f1366d4bbbed6c63d7d0a0332eae02de2ae9dec2/src/test/java/org/openrewrite/hibernate/EmptyInterceptorToInterfaceTest.java#L38
Ecplise β

IntelliJ β

VS Code π«
