简体   繁体   中英

Auto-Complete Suggestions in Source Code Editor

Most IDEs (Eclipse, Netbeans, Intelij) provide contextually smart suggestions about the current statement you're writing. We would like to do the same thing (In Java for Java).

We considered tokenizing the input and building our own abstract syntax trees, but quickly realized that could be a month long project in and of its self. We also started digging through the source code for the above mentioned IDEs, but it appears (correct me if I'm wrong) that the auto-complete code is pretty tightly woven with the rest of the IDE.

We're wondering if anyone knows of a relatively isolated package that we could pull into our project to provide this auto-complete functionality.

Thanks!

You should check creating custom editor for Eclipse. Without much effort tokenizer, code assist and coloring support could easliy integrated to your editor. With some effort you could minimize dependency and ship only required plugins. Altough eclipse do the most things for you there is no standard way to parse content. You could use Xtext or write your customer parser with antlr.

You could try using the Reflection API if you are willing to support auto-compilation and limit your auto-complete to already-compiled classes. Otherwise, you're looking at a very large, long project that will require a lot of resources to complete.

If you use SWT and JFace you can be happy: Autocompletions on the GUI side in Editors are already included, and is discussed in many toturials.

However with Swing you might look a bit further.

What is useful in your context has to be decided by yourself, as far as i am aware, there are no tools for that, except when you using a DSL framework like xText.

JIDE-Commons offers a simple "completion" feature which can be used, eg, to complete simple words or file names. Maybe this simple solution already works for you.

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