Language-server-protocol: semantic highlighting: multi-line token?

Created on 12 May 2020  路  3Comments  路  Source: microsoft/language-server-protocol

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?

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.

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andfoy picture andfoy  路  6Comments

KVGarg picture KVGarg  路  5Comments

davidanthoff picture davidanthoff  路  3Comments

stamblerre picture stamblerre  路  5Comments

ooxi picture ooxi  路  3Comments