Is that possible?
Yes, it is, but it’s a complicated process that requires you to know how your major-mode parses whatever language you’re working in.
Syntax highlighting annoys me, so I turn it off and can’t give you much more info than that.