Is it possible to reprocess the whole sytanx tree again?
The context:
I’m creating a language package for Excel functions. One of the peculiarities is that some tokens change according to the idiom. For example, the Boolean token can be TRUE (English) or VERDADEIRO (Portuguese).
I created an external token that handles this based on the currIdiom
variable:
File: tokens.ts
let currIdiom = 'en-US';
const i18n = {
BoolToken: {
'en-US': ['TRUE', 'FALSE'],
'pt-BR': ['VERDADEIRO', 'FALSO']
}
}
export const isBoolean = (value: string, stack: Stack): number => {
return i18n.BoolToken[currIdiom].indexOf(value.toUpperCase()) !== -1
? tokens['BoolToken']
: -1;
}
To be able to change the idiom, I exported a function that changes the currIdiom
variable:
export const setLezerIdiom = (newIdiom: supportedIdioms): supportedIdioms =>
(currIdiom = newIdiom);
Everything is working, but when I switch between languages, it seems to me that it keeps the previous syntax tree, I need to type something to update. See the example below, TRUE is in purple (recognized as a BoolToken when language is en-US), but when I change it to Portuguese, I need to type something to stop being purple (= no longer recognized as a BoolToken):
How can I force a reprocess so that highlighting works when switching idiom?