Skip to content

Language Support for StringsΒ #483

@MBoegers

Description

@MBoegers

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 βœ…

Image

IntelliJ βœ…

Image

VS Code 🚫

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions