Auto-complete suggestions in the source editor

Most IDEs (Eclipse, Netbeans, Intelij) provide context-sensitive suggestions for the current application you are writing. We would like to do the same (in Java for Java).

We looked at input tokenization and building our own abstract syntax trees, but quickly realized that this could be a monthly project inside and on its own. We also started digging the source code for the above IDEs, but it appears (correct me if I am mistaken) that the autocomplete code is pretty tightly intertwined with the rest of the IDE.

We are wondering if anyone knows about a relatively isolated package that we could use in our project to provide this autocomplete feature.

Thanks!

+4
source share
5 answers

You should check out the creation of a custom editor for Eclipse. Without much effort, the tokenizer, code support, and coloring support can be easily integrated into your editor. With some effort, you can minimize addiction and send only the necessary plugins. With any eclipse, there is no longer a standard way for you to analyze content for you. You can use Xtext or write your client parser with antlr.

+1
source

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

+1
source

If you use SWT and JFace, you can be happy: auto-kits on the GUI side are already included in the editor and are discussed in many totals.

However, with Swing you can look a little further.

What is useful in your context, you need to decide yourself, as far as I know, there are no tools for this, except when you use a DSL infrastructure such as xText.

0
source

JIDE-Commons offers a simple "completion" function that can be used, for example, to complete simple words or file names. Perhaps this simple solution already works for you.

0
source

Source: https://habr.com/ru/post/1308752/


All Articles