I build my own language on codemirror , I have array contain the name of my classes and I have also temp array (when I type name of class then I loaded the fields of this class in temp array)
For example, if I have two classes:
The name of first class is Data and it's fields are:
fname, lname, age
The name of second class is info and its fields are:
mother, father
when I type on codemirror Data then the temp array contain (fname,lname,data) when I type on codemirror info then the temp array contain (mother,father)
What I want
To color the fields in specific color only if it comes after the name of own class (i.e when I type on codemirror Data.fname I want to color the word fname in blue color But when I type on codemirror info.fname I did not want to color the word fname in blue color because (fname not contain in the class "info"))
What I try
<pre lang="Javascript">CodeMirror.defineMode("mymode", function() {
return {
token: function(stream,state) {
for (var i = 0; i <classname.length ;="" i++)="" {="" if="" (stream.match(classname[i])="" )="" return="" "style1";="" }="" for="" (var="" i="0;" <temp.length="" (stream.match(temp[i])="" "style2";="" };="" });<="" pre="">
My problem in my try
the contain of array temp is change when I type the name of class on codemirror ... so what happen is : when I type on codemirror Data.fname then the word fname color in blue But if I type on codemirror Data.fname info.mother (Before I type info.mother the word fname color in blue because it is contain in temp array (fname,lname,data), but after I type info.mother the contain of temp array is change to (mother,father) ) so the the color of fname became black
this picture show you the execute
here the word "fname" color in blue :
[
^]
here the color of word "fname" change and became black:
https://i.stack.imgur.com/DF2U7.png[
^]
I knew my problem because the contain of array temp is change... But I can't find way to solve it... so any help?
What I have tried:
my try in my question above ... any help I try a lot