简体   繁体   English

在源代码编辑器中自动完成建议

[英]Auto-Complete Suggestions in Source Code Editor

Most IDEs (Eclipse, Netbeans, Intelij) provide contextually smart suggestions about the current statement you're writing. 大多数IDE(Eclipse,Netbeans,Intelij)都提供有关您正在编写的当前语句的上下文智能建议。 We would like to do the same thing (In Java for Java). 我们想做同样的事情(在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. 我们还开始研究上述IDE的源代码,但是似乎自动完成代码与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. 您应该检查为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. Eclipse可以为您做最多的事情,但是没有标准的方法来解析内容。 You could use Xtext or write your customer parser with antlr. 您可以使用Xtext或使用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. 如果愿意支持自动编译并将自动完成功能限制为已编译的类,则可以尝试使用Reflection API 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. 如果您使用SWT和JFace,您会很高兴:编辑器中的GUI端自动完成功能已经包括在内,并且在许多摘要中都有讨论。

However with Swing you might look a bit further. 但是,使用Swing可能会更进一步。

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. 据我所知,在您的上下文中有用的内容必须由您自己决定,除非您使用xText之类的DSL框架,否则没有任何工具可以使用。

JIDE-Commons offers a simple "completion" feature which can be used, eg, to complete simple words or file names. JIDE-Commons提供了一个简单的“完成”功能,可用于例如完成简单的单词或文件名。 Maybe this simple solution already works for you. 也许这个简单的解决方案已经为您服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM