Full Text Search: The Key to Better Natural Language Queries for NoSQL in Node.js
Environment: VC6 (probably any VC)
What's all this then?Having programmed on a UNIX platform, where I used the vi editor, and since then on a PC using Lemmy, I have missed the ability to use tags when using Visual Studio. The macro published here provides tags support.
The functions are as follows:
PushContext: Invoking this function picks up the currently selected text, and looks for a reference to it in the tags file. If it finds it in the file, it then opens the file it is contained in and jumps to the correct line or text. The current cursor position (and file) is added to the tag stack.
PopContext: This function will take the top entry from the tag stack, and jump to the file and cursor position listed there. This enables you to jump to a definition, and then come back to where you were previously working. This works regardless of whether the tag jumped to was in the same file or a different file.
So why not use the browser facilities built-in to Visual Studio?One of the things I like about tags that the browser info doesn't give me is the ability to stack the tags, so I jump back to where I came from.
Mmm, looks useful, but how do I generate my tags?To generate my tags I use Exuberant Ctags, by Darren Hiebert. This is available as a free download from http://ctags.sourceforge.net/. One thing to be careful of is that if you create the tags file by specifying a directory, then the file paths are stored as relative paths in the tags file. This then causes problems, as Visual Studio may change its current directory each time you open a file.
How it worksWhen you first execute the PushContext function, the tags file is sought in the directory in which the current file lives. If it is found, then its contents are read in line by line, and the tag text is added to a dictionary, along with the tag information (file path, and line number or search text). (This does mean that the first time you read a tags file, there is a bit of a delay, but after that it is quite fast.)
A separate dictionary is kept for each tags file you read, and a dictionary of dictionaries is used to get back the correct dictionary. This means that different directories can use different tags files.
Before reading in a tags file, the master dictionary is searched to see if there is already a dictionary for that file. If there is, then the time stamp of the file is compared to a saved timestamp in the dictionary, to see if the tags file needs re-reading. This enables you to update your tags at any time, and still be able to use them correctly.