Reputation: 18552
Where? Can someone give me example with source retrieval methods in the IDEs of these popular languages:
Upvotes: 2
Views: 198
Reputation: 1944
Major IDEs such as Visual Studio, Eclipse and IntelliJ Idea use indexing approach: parsing all of the project files and storing possible completion symbols(i.e. method names). So, when the user presses Ctrl+Space to invoke completion list, the editor looks up through the stored symbols to filter the most appropriate candidates.
These kind of source code parsers named "incremental parsers" and they are distinguish from the ordinary parsers by two features:
Incremental parsers reach these goals by utilizing some form of caching. This visual demo illustrates how they work in a nutshell: Incremental JSON parser. I recommend you to try it.
Also you may be interested in reading these sources:
Unfortunately, there is a real lack of tools to build your own incremental parser. Core parsers of the most IDEs are hardcoded, and they don't share any common approach. The demo I mentioned above is one of the rare exceptions that uses distinct incremental parser library - Papa Carlo for building parsers in Java, Scala and JavaScript. Another example is Parsley - incremental parsing library for Clojure language.
Upvotes: 5