How I can to color an word only after i check to some conditions?

I knew how I can color a specific word where ever the word match … But I did not like it … because I have my own class and some fields follow each class … so suppose I have :

class1 has fields aaa

class2 has fields bbb

so I want to color aaa in red only if it came after class1 like this class1.aaa … But when I write class2.aaa I did not want to color aaa in red t :
and this the the jsfiddle

Note : I have function return true if (aaa) came after class1 … so only what I want to knew how to color aaa in red only if it came after class1 like this class1.aaa ?

This is something you can do with a CodeMirror mode. Keep state that tells you when you’re after a dot and what the word before the dot was, and adjust the styling you return for the token based on that.

I can knew what befor dot … but i did not knew how adjust the styling you return for the token based on that ? @marijn

You return a different string from the token function.

thanks I get it @marijn