-
-
Notifications
You must be signed in to change notification settings - Fork 389
add Method_TextDocumentSemanticTokensFullDelta #4073
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
Conversation
I'm on holiday but I'll take a look next week! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me, I mostly have minor suggestions.
While I do approve, let's wait until michael also had time to look at this :)
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Internal.hs
Outdated
Show resolved
Hide resolved
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Internal.hs
Outdated
Show resolved
Hide resolved
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Internal.hs
Outdated
Show resolved
Hide resolved
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Internal.hs
Outdated
Show resolved
Hide resolved
Co-authored-by: fendor <[email protected]>
…ns/Internal.hs Co-authored-by: fendor <[email protected]>
Thanx for the reviews @fendor . Fixed most of them.
Sure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly worried about adding lots of stuff to ShakeExtras
if we don't have to.
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Internal.hs
Outdated
Show resolved
Hide resolved
@@ -259,6 +261,11 @@ data ShakeExtras = ShakeExtras | |||
,publishedDiagnostics :: STM.Map NormalizedUri [Diagnostic] | |||
-- ^ This represents the set of diagnostics that we have published. | |||
-- Due to debouncing not every change might get published. | |||
,semanticTokensCache:: STM.Map NormalizedUri SemanticTokens |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these could probably be variables local to the plugin? I think we only need to put thing in here if they're really shared across multiple rules etc.
So the function that creates the plugin would run in IO
or similar and create the TVars, which then get passed into the handlers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree that putting it in shakeExtras is suboptimal, but I am also not sure about local state to plugin too.
Since no other plugins have their own plugin state. It would mean we need to change idePlugins :: Recorder (WithPriority Log) -> IdePlugins IdeState
to idePlugins :: Recorder (WithPriority Log) -> IO (IdePlugins IdeState)
.
And open a door to introduce state to plugins breaking the current centralized state management in the hls build system. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think plugin-local state is inherently problematic. But I admit that it's not totally clear to me what stuff should be in ShakeExtras
🤔 thoughts @fendor ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a comment to the shakeExtra stating it might not be ideal to store the varaibles there, but we do not find a better place to store it yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not have any specific thoughts, if the variable could be easily plugin local, I think I would prefer that.
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Internal.hs
Outdated
Show resolved
Hide resolved
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Internal.hs
Outdated
Show resolved
Hide resolved
@@ -98,9 +131,6 @@ getSemanticTokensRule recorder = | |||
let hsFinder = idSemantic getTyThingMap (hieKindFunMasksKind hieKind) refMap | |||
return $ computeRangeHsSemanticTokenTypeList hsFinder virtualFile ast | |||
|
|||
-- | Persistent rule to ensure that semantic tokens doesn't block on startup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why drop this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For semantic tokens,
lastValueIO return []
(case with persistent key) or Nothing
(case without persistent key).
Between faking a stale value []
and mark the semantic tokens rules' value actually Failed
in shake state
.
The former would hide the failure in both user of the rule and in the shake caching result(I don't think it is wise, we want to know if we fail in this case).
Also we are not using IdeAction with useWithStaleFastMT
(Which look directly into the caching and demand instance response) for semantic tokens as in other IdeAction that requires instance response(e.g. hover, this fix startup of hover when the rule first compute without any stale value in the cach).
The persistent rule is rather useless for us and might shadow some actual failures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, so does this mean we have to wait quite a while to get responses when we start up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, as we have been. Persistent rule won't help us here(Since it is not ideAction
, the persistent rule serves only as a fall back when the actual computation of the rule failed and not already having a cache) .
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Internal.hs
Show resolved
Hide resolved
Thanx for the reviews, welcom back from vacation! @michaelpj , I fixed some of them, and some might need discussion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wz1000 still interested in your feedback on the ShakeExtras
vs plugin-local state vars question, but for now we're going to leave it as it is with a note.
@@ -257,8 +259,18 @@ data ShakeExtras = ShakeExtras | |||
,diagnostics :: STMDiagnosticStore | |||
,hiddenDiagnostics :: STMDiagnosticStore | |||
,publishedDiagnostics :: STM.Map NormalizedUri [Diagnostic] | |||
|
|||
-- storing semantic tokens for each file in shakeExtras might |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment is in the wrong place, it's interrupting the haddock for the field above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe put it in a Note or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Did it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-approving, LGTM :)
* add Method_TextDocumentSemanticTokensFullDelta * remove persistentGetSemanticTokensRule * add doc about semanticTokensCache location * add Note [Semantic Tokens Cache Location] --------- Co-authored-by: fendor <[email protected]>
Mainly the following things have been done:
semanticTokensCache
andsemanticTokensId
to shake extras.Method_TextDocumentSemanticTokensFullDelta
Method_TextDocumentSemanticTokensFullDelta
persistentGetSemanticTokensRule
since it is of no use since we do not useuseWithStaleFastMT
for semantic tokens rule.