Monaco-editor: Idenfifying a word as token in the editor

Created on 17 Sep 2018  路  1Comment  路  Source: microsoft/monaco-editor


monaco-editor version: 0.14.3
Browser:Chrome
OS: Windows
Steps or JS usage snippet reproducing the issue:
From Hover provider example in monaco playground
i got the Hovers word with the below code
var keyword=model.getWordAtPosition(position).word
but how can i identify whether the word is a keyword or identifier or some other token that we have registered??

*question

>All comments

There is currently no API to retrieve the token types because they are not stored anywhere. Only the resulting colors are stored.

You can use the independent API monaco.editor.tokenize(text, languageId).

Was this page helpful?
0 / 5 - 0 ratings