monaco-editor version: 0.15.6
Browser: Google Chrome 68.0.3440.106
OS: Windows 10 64-bit
When I implement the provideCompletionItems function, it looks that the tokens information is important for me to recognize the current state(for example, whether we are in the comment area).
Since I have implemented a Monarch tokens provider, I wonder if I can got the parsed result from the tokens provider in provideCompletionItems. If possible, I need not to implement another parser to get tokens from the whole text, which would be very inefficient.
Any idea? Thanks!
This is not API, but since this is JS you can hack your way around.
On the model, you can call model.getLineTokens(lineNumber). This will return a class of type LineTokens. You can loop through tokens or search one given a certain text offset and you can use the getStandardTokenType method to determine what "general" kind of token this is:
export const enum StandardTokenType {
Other = 0,
Comment = 1,
String = 2,
RegEx = 4
}
But that is kind of the only thing that survives (besides the coloring) from the tokenizer. i.e. token types are not stored in a string format as returned from the tokenizer.
Thanks, Alexandru. I have implemented another tokenizer to solve this problem. Although it looks inefficient that my tokenizer works with Monarch concurrently, it really works.
I hope Monarch may provide more interface or more info, it could provide much more convenience for us.
Anyway, thanks.
Most helpful comment
Thanks, Alexandru. I have implemented another tokenizer to solve this problem. Although it looks inefficient that my tokenizer works with Monarch concurrently, it really works.
I hope Monarch may provide more interface or more info, it could provide much more convenience for us.
Anyway, thanks.