-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initial Semantic token #133
Conversation
This PR has a serious problems, causes latency problem and makes other requests slower to response because it does not run concurrently. |
I have no idea how to make it runs concurrently. That method needs to access |
How about let others task can interrupt "semantic tokens"? |
It needs to access the text buffer during the whole process. It obtains the text contained in the text buffer, calculate the tokens, then also use the text buffer class method to convert the token positions from character position format into line/character position format. If it got interrupted in the middle of calculate tokens then the text buffer might got updated and produce unpredictable result. |
I found we can use line/character style position directly after I states the whole process before. And there is another problem that if people types quickly, then it can produce multiple requests. I guess we can always process only one request, and let new request replace the old processing one, like how we did for the traverse that send diagnostics. |
It simply copy the text buffer and use it during processing. It has usable latency now, although the fan is running loudly. |
The design that new incoming task replace old running task can't apply. Because client can reuse the result of old requests, for example, insert some whitespaces, then client can calculate the offset and keeps old content highlight. But if the interrupted task returns an empty result, then the highlight would lost. The interrupted task can't just give up to return, because client might wait that request forever and cause resource leak. I think this PR is completed now. |
Thank you! |
Supported tokens:
(variable function string number regexp)
Supported modifiers:
(definition)
Supported method: textDocument/semanticTokens/range and textDocument/semanticTokens/full.
There are some difficulties to support tokens like comment, struct, class, etc.
I don't know how to implement a embeded sexp comment reader. And struct, class, etc requires a full functional type infer.
image:
image with a semantic highlight plugin which gives different variable different color: