-1

I am a regular user of the Eclipse IDE. I found that it is really fast in finding out the occurences of a given variable name in a very section of code. I would be interested in how to go about building such mechanism or what are the fastest data structures used to do so or any algorithms. Of course eclipse is just and example. Thank you in advance.

  • possible duplicate of [What is the fastest substring search algorithm?](http://stackoverflow.com/questions/3183582/what-is-the-fastest-substring-search-algorithm) – Bernhard Barker Jun 09 '14 at 07:37

1 Answers1

2

As usual, the answer is, "it depends".

There's the case of efficiently searching for a chunk of matching text in a longer string. The most common algorithm for this is the Boyer-More string search algorithm, and I believe that most implementations use a simple array of characters.

However, in the case of finding a variable name in the Eclipse editor, that is probably not what's happening. More likely, Eclipse is creating an Abstract Syntax Tree (AST) from your source code, and searching the tree. See for instance, http://www.eclipse.org/articles/Article-JavaCodeManipulation_AST/

GreyBeardedGeek
  • 29,460
  • 2
  • 47
  • 67