• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Implementing code completion ...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementing code completion ...


  • Subject: Re: Implementing code completion ...
  • From: WT <email@hidden>
  • Date: Tue, 21 Apr 2009 14:11:24 +0200

Hi Mic,

I'm going to sound like a broken record because I mentioned tries here not too long ago, but code completion is a good example of searching for shared prefixes among strings, which is the prototypical use for the trie data structure.

First you preprocess all known identifiers by building a trie out of them. Then, as the user types each successive character, you search the trie for all partial matches (ie, all strings that share the same prefix, equal to the partial string typed by the user so far) and present them to the user.

You can read more about tries here:
<http://en.wikipedia.org/wiki/Trie>

An Objective-C implementation by the great folks at OMNI is found here:
<http://www.omnigroup.com/developer/>

A related data structure, the ternary search tree, can also be used for code completion. Here's an article explaining how to do that in a different context (automatic spelling-check as the user types), using Java. Converting that to an Objective-C solution shouldn't be too hard:

<http://www.javaworld.com/javaworld/jw-02-2001/jw-0216-ternary.html>

Hope this helps.
Wagner

On Apr 21, 2009, at 1:38 PM, Mic Pringle wrote:

Hi,

Does anyone have any ideas/examples/best practice suggestions on how
best to go about implementing code completion within a NSTextview ?

I've had a search via Google and CocoaBuilder but can't seem to find
anything relevant.

Thanks

-Mic
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Implementing code completion ... (From: Mic Pringle <email@hidden>)

  • Prev by Date: MDItemCopyAttribute and kMDItemFinderComment
  • Next by Date: Re: Notifications for the low battery...?
  • Previous by thread: Implementing code completion ...
  • Next by thread: MDItemCopyAttribute and kMDItemFinderComment
  • Index(es):
    • Date
    • Thread