Most editors that support language servers (https://langserver.org/) can do this. They use "real compiler's" lexer/parser for this.
If I understand you right, I think all the Jetbrains IDEs do this. They actually analyze code (not just syntax) and point out various errors in logic, scope, references, parameters, etc.
Sounds like a job for custom lint rules.
Python lsp in vscode does it. Other lsp-s probably too.
Perhaps this: Semantic Highlighting in Neovim
https://gist.github.com/swarn/fb37d9eefe1bc616c2a7e476c0bc03...
In the comments there's also a link to a plugin that does a different kind "Where every variable is a different color":
https://github.com/jaxbot/semantic-highlight.vim