• Post Reply Bookmark Topic Watch Topic
  • New Topic

Code completion

 
Stefan Krompass
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a problem with implementing code completion. I know that there are Open Source Projects (Eclipse, Netbeans, ...) where I could have a look at the source code. Since the programmers of these projects invested a lot of time in optimizing the code, it is not self-explanatory. So can anybody show me a simpler way to implement code completion?
Thanks for help!

Stefan
 
Jeffrey Bennett
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know about simple, but here's the general way to go about it.

First, construct a dictionary representing the fully specified target words or phrases.

As the user types, build up a buffer. You'll probably want some sort of timer with a threshhold so that keys entered in rapid succession are added to the buffer, while a significant pause will cause the buffer to be purged.

Then, per keyclick, you simply check your buffer against your dictionary and return the best match (or null).

Assuming the user accepts the match, you simply do the replacement of what they typed with the dictionary value.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!