Javascript、SublimeCodeIntel 和提示代码智能自动完成

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11360659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 12:54:22  来源:igfitidea点击:

Javascript, SublimeCodeIntel and hinting Code Intelligence auto-completion

javascriptautocompleteidesublimetextcode-intelligence

提问by Mikko Ohtamaa

Are there any tips or tutorials to set-up Javascript auto-completion with Sublime Text 2and SublimeCodeIntel?

是否有任何提示或教程可以使用Sublime Text 2SublimeCodeIntel设置 Javascript 自动完成?

  • What are the limitations of Code Intel auto-completion (modules inside wrapper functon, etc.)

  • How Javascript namespace tree is build and can you give manual hints for the Code Intel when it fails to guess correctly (e.g. give somekind of @class my.module.Foobar hint in comments)

  • Code Intel 自动完成的限制是什么(包装函数内的模块等)

  • Javascript 命名空间树是如何构建的,当代码英特尔无法正确猜测时,您能否为代码提供手动提示(例如,在注释中提供某种 @class my.module.Foobar 提示)

The problem is that SublimeCodeIntel itself does not describe the process and the orignal authors of Code Intelligence assume you use it with Komodo IDE (where it works fine what I have heard)

问题是 SublimeCodeIntel 本身并没有描述这个过程,而 Code Intelligence 的原始作者假设你将它与 Komodo IDE 一起使用(我听说它在那里工作得很好)

Also heregoes forum thread without answers

这里也有没有答案的论坛主题

回答by Martin Vseticka

I had a look at SublimeCodeIntel(SCI) source codes and my understanding is that lang_javascript.pydescribes what SCI is capable of. A simple grep of the file showsthat it relies on its own implementation and it does not use external JavaScript lexer. It tries to checkJSDoc to some point but the implementation looks rather like an ad-hoc one to me.

我查看了SublimeCodeIntel(SCI) 源代码,我的理解是lang_javascript.py描述了 SCI 的能力。该文件的简单 grep表明它依赖于自己的实现,并且不使用外部 JavaScript 词法分析器。它试图在某个时候检查JSDoc,但对我来说,实现看起来更像是一个特别的实现。

The JavaScript lexer does not seem to have any tests so it's hard to know what it can do exactly but there are logging commands so you enable themand give it a go what it does. Personally, I have rather bad experience with SCI (it was slow for me and not accurate enough), so I would try to use something more robust - it's old now as the question is two years old.

JavaScript 词法分析器似乎没有任何测试,因此很难知道它究竟能做什么,但有日志命令,因此您可以启用它们并试一试它的作用。就我个人而言,我对 SCI 的体验相当糟糕(对我来说它很慢而且不够准确),所以我会尝试使用更强大的东西 - 现在它已经过时了,因为问题已经两年了。

This is not a direct answer to your questions, it's just an analysis and you'll have to contact the author or dig some more in the source code (which is fairly easy since it's written in Python), if you are still interested.

这不是对您问题的直接回答,它只是一个分析,如果您仍然感兴趣,您必须联系作者或在源代码中挖掘更多内容(这很容易,因为它是用 Python 编写的)。



There are hidden gemsin the source code though:

但是,源代码中有隐藏的宝石

# Everything is JS is an object.... MUMUHAHAHAHAHAHAAAA.......

# Everything is JS is an object.... MUMUHAHAHAHAHAHAAAA.......

:-)

:-)

回答by Joe Johnson

This is a good question. However, your answer is not something that is attainable via this forum. Since the SublimeCodeIntel project is open-source, your best resource is to simply read the code. This may be time-consuming especially if the documentation is weak, but it's ultimately the best way to go when using open-source products. The nice (and, IMO, cool) thing is that you can easily contribute to making it a better product, if so inclined.

这是一个很好的问题。但是,您的答案不是通过此论坛可以获得的。由于 SublimeCodeIntel 项目是开源的,因此您最好的资源就是简单地阅读代码。这可能很耗时,尤其是在文档薄弱的情况下,但它最终是使用开源产品时的最佳方式。好的(而且,IMO,很酷)的事情是,如果愿意,您可以轻松地为使其成为更好的产品做出贡献。

You're obviously familiar enough with Sublime Text 2 and it's code completion plugin to the point in which you feel comfortable positing this question. Someone could read through the code and spoon-feed you an answer, but that would help no one, especially you, given your interest. I've personally experienced issues regarding a few Sublime Text plugins and just learn to ignore them blissfully while evangelizing the fundamental merits of this IDE.

您显然对 Sublime Text 2 足够熟悉,它是代码完成插件,您可以轻松地提出这个问题。有人可以通读代码并用勺子喂你一个答案,但考虑到你的兴趣,这对任何人都没有帮助,尤其是你。我个人在一些 Sublime Text 插件方面遇到过问题,并且在宣传这个 IDE 的基本优点时学会了幸福地忽略它们。

I look forward to the possibility (at this point) of seeing someone post a listing summarizing your questions -- I would find it helpful too ... but, only for a week. It's open-source and as such changes rapidly. Your question can ultimately only be answered within the context of the effort you wish to put into contributing to it's further development.

我期待看到有人发布总结您问题的列表的可能性(此时) - 我会发现它也有帮助......但是,只有一个星期。它是开源的,因此变化很快。您的问题最终只能在您希望为其进一步发展做出贡献的努力范围内得到解答。

https://github.com/Kronuz/SublimeCodeIntel

https://github.com/Kronuz/SublimeCodeIntel