It's about Text Block in Java, see https://openjdk.java.net/jeps/355
class Foo {
private String bar = """
hello
world
""";
}
Intuitively I think it should be a token of String kind, covering """\n hello\n world\n """ across lines. But according to current design, it seems not possilbe to define multi-line tokens. I tried in vscode but not working (AFAIK for the moment only vscode implements the feature). I don't know if it's a bug of vscode, or by design.
If it's by design, I have to seperate the text block by defining several tokens for each line. I just feel a little bit unnatural about it. Any clarification to help me understand more?
Regarding VS Code, it is by design that a token cannot be multiline. See microsoft/vscode#86415. The current LSP spec for semantic highlighting is based on VS Code's API so that limitation was inherited.
Clients quite frequently keep token states by line so having tokens that spawn multiple lines is usually hard for them to implement. I do agree that the LSP specification shouldn't limit this in general so I will add a client capability that signals this. Forcing all clients to implement tokens across lines will make it hard for clients to implement that at all.
Addressed via #1077
Most helpful comment
Clients quite frequently keep token states by line so having tokens that spawn multiple lines is usually hard for them to implement. I do agree that the LSP specification shouldn't limit this in general so I will add a client capability that signals this. Forcing all clients to implement tokens across lines will make it hard for clients to implement that at all.