简体   繁体   中英

How does Eclipse IDE quick fix display suggestions?

I'm interested in how the eclipse ide can display suggestions to you and display the results so quickly. I work with a huge codebase with 1000's and 1000's of classes and I thought there would be some lag in suggesting misspelt class names for example.

How does it search for possible suggestions? Why is it so quick? Does it index all possibly situations to it can be quickly accessed?

Just something thats interests me because I use eclipse everyday :) Cheers

Same way Google can search in billions of entries, or a text-indexing system like Lucene works. These systems first index the text to be searched, and it can be quite lengthy; you can see it when you first import a project in Eclipse, it takes a lot of time in the background to index everything.

Once the data is indexed, however, it can be searched at an incredible speed. I believe the complexity of such search is O(log n), meaning it will take 1 unit of time to search among 10 items, 2 for 100 items, 3 for 1000 items, 6 for one million, 9 for one billion, etc...

For such an efficient algorithm, data size is almost of little relevance.

Here's an excerpt from the JDT Core (Java development tools) page:

JDT Core is the Java infrastructure of the Java IDE. It includes:

...

  • An indexed based search infrastructure that is used for searching, code assist, type hierarchy computation, and refactoring. The Java search engine can accurately find precise matches either in sources or binaries.

It probably has a K-gram index to do a fast prefix search. Or maybe a Trie data structure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM