It is SynHighlighterPas.pp
The highlighter does not make a list of known types. (So it does not have a list of all the names)
In type/var blocks (an it alreadyknows if it is in such a block), it could determine the type-names lexically.
- In a type block, anything before "=" is a type.
Also anything after a = can be a type, if it is not an inline declaration "record ... end", "(enum)", "0..9", ... then it is a typename and should be highlighted.
e.g. type TFoo = OtherUnit.TheFooType;
- In a var/const block it is similar but after the colon.
- Same in function parameter lists (declaration).
Now in code it is way more complex.
A := THis.Meth();
THis could be a class (type). Or it could be a variable (object).
B := Foo(1);
Function or typecast?
Not only does one need to know if there is a type THis or Foo. It is needed to know if this identifier is a type in this scope.
type Foo = Byte;
procedure Bar;
procedure Foo(a: integer); begin end;
begin
x := Foo(1);
end;
There is a type Foo. But above code refers to the function.
Yes all this can be determined. In fact codetools already do this.
The best way to go about this would be a TSynEditMarkup module.
In the HL look at
TSynPasSyn.IdentKind
TSynPasSyn.NExt
and
cfbtVarType, cfbtLocalVarType
as well as
rsAfterEqualOrColon, // very first word after "=" or ":"
rsAfterEqual, // between "=" and ";" (or block end) // a ^ means ctrl-char, not pointer to type
An ident after a equal or colon, if inside a vartype block.....
I need to spent a bit more time for more info.
Also not sure, if it should at all go into the HL (it can for a personal mod). Because for future extension it may be better as a markup module. (But that needs a lot more explanation than I could write up right now)
Btw to understand how HL do work, read
https://wiki.lazarus.freepascal.org/SynEdit_Highlighter