Extension API: add token type provider
There are no commits yet
Push commits to the source branch or add previously merged commits to review them.
Created by: chrismwendt
Prior to this change, hover tooltips (specifically the "Find references" button) would be shown even on comments, whitespace, etc. There was no way for extensions to prevent that from happening.
After this change, there will be a token type provider in the extension API that can be used to prevent hover tooltips from showing up on comments, whitespace, etc. Here's how you will be able to use it:
const identifier: sourcegraph.TokenType = 'identifier'
const whitespace: sourcegraph.TokenType = 'whitespace'
ctx.subscriptions.add(
sourcegraph.languages.registerTokenTypeProvider(
[{ pattern: '*.go' }],
{
provideTokenType: (doc, pos) => {
// toy example: returns identifier on even lines and whitespace on odd
return Promise.resolve(pos.line % 2 === 0 ? identifier : whitespace)
},
}
)
)
Test plan:
identifier
on even lines and whitespace
on odd lines, make sure hover tooltips show up on even lines and not on odd linesPrevious implementation attempt https://github.com/sourcegraph/sourcegraph/pull/3188
TODO
Push commits to the source branch or add previously merged commits to review them.