The IDE is basically applying static code analysis methods to "understand" the code structure.
Something that works extremely well in Java, reasonably well in Typescript, and seems quite shaky in other languages.
Fair point. Looks like some IDEs can provide some kind of extract functionality, but can't say I have had enough experience with them to say how reliable it is.