我对 SublimeCodeIntel 插件(后来简称为“SCI”)的正常工作有疑问。当我尝试从烧瓶模块导入 Flask 类时,我希望 SCI 会自动完成该类。不幸的是,在这种情况下,SCI 无法识别 Flask 类和任何方法。SublimeCodeIntel 有什么问题?为什么它不能识别 Flask 模块的类、方法等?
请参阅以下屏幕截图和codeintel.log
日志文件的输出。
截图:
```codeintel.log`` 日志文件的输出:
Starting logging SublimeCodeIntel v2.0.6 ...
============================================
+ Info: processing `Python': please wait...
New env with catalogs for 'Python': PyWin32
...
Updating indexes for 'Python'... The first time this can take a while.
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\hello-flask.py' lang: Python
Doing CodeIntel for 'Python' (hold on)...
eval 'Flask' at hello-flask.py#2 <Trigger 'python-defn-defn' at 21 (explicit)>
start scope is (<Element 'scope' at 0x0560B8B0>, [])
find 'Flask ...' starting at (<Element 'scope' at 0x0560B8B0>, []):
is blob 'flask' from <Python curdirlib>? no
is blob 'flask' from <Python envlib>? no
is blob 'flask' from <Python sitelib>? yes
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\exthook.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\debughelpers.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\module.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\signals.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\globals.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\views.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\_compat.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\wrappers.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\logging.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\sessions.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\helpers.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\templating.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\ext\\__init__.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\testsuite\\__init__.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\ctx.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\app.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\json.py' lang: Python
+ Info: Doing CodeIntel for 'Python' (hold on)...
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\config.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\testing.py' lang: Python
scan_purelang: path: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask\\blueprints.py' lang: Python
imports:: setting reldirlib to: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask'
is blob 'app' from <Python curdirlib>? no
is blob 'app.Flask' from <Python curdirlib>? no
could not import 'Flask' from <Element 'import' at 0x0560B9F0>
is blob 'flask.Flask' from <Python curdirlib>? no
is blob 'flask.Flask' from <Python envlib>? no
is blob 'flask.Flask' from <Python sitelib>? no
is blob 'flask.Flask' from <Python cataloglib: PyWin32>? no
is blob 'flask.Flask' from <python-2.7 stdlib>? no
could not import 'Flask' from <Element 'import' at 0x0560B6F0>
is 'Flask' accessible on (<Element 'scope' at 0x0560B8B0>, [])? no
is 'Flask' accessible on (<Element 'scope' at 0x05606A70>, [])? no
evaluating 'Flask' at test-2.py#2: could not resolve first part of 'Flask'
done eval: eval error
...
eval 'app.route' at hello-flask.py#6 <Trigger 'python-calltip-call-signature' at 60 (explicit)>
start scope is (<Element 'scope' at 0x05606070>, [])
find 'app ...' starting at (<Element 'scope' at 0x05606070>, []):
is 'app' accessible on (<Element 'scope' at 0x05606070>, [])? yes: <Element 'variable' at 0x056062F0>
resolve getattr 'route' on <Element 'variable' at 0x056062F0> in (<Element 'scope' at 0x05606070>, []):
resolve 'Flask()' type inference for <Element 'variable' at 0x056062F0>:
find 'Flask ...' starting at (<Element 'scope' at 0x05606070>, []):
is blob 'flask' from <Python curdirlib>? no
is blob 'flask' from <Python envlib>? no
is blob 'flask' from <Python sitelib>? yes
imports:: setting reldirlib to: 'C:\\Python\\tmp\\flasky\\venv\\lib\\site-packages\\flask'
is blob 'app' from <Python curdirlib>? no
is blob 'app.Flask' from <Python curdirlib>? no
could not import 'Flask' from <Element 'import' at 0x02CD0870>
is blob 'flask.Flask' from <Python curdirlib>? no
is blob 'flask.Flask' from <Python envlib>? no
is blob 'flask.Flask' from <Python sitelib>? no
is blob 'flask.Flask' from <Python cataloglib: PyWin32>? no
is blob 'flask.Flask' from <python-2.7 stdlib>? no
could not import 'Flask' from <Element 'import' at 0x05606BF0>
is 'Flask' accessible on (<Element 'scope' at 0x05606070>, [])? no
is 'Flask' accessible on (<Element 'scope' at 0x05606A70>, [])? no
evaluating 'app.route' at hello-flask.py#6: could not resolve first part of 'Flask()'
done eval: eval error
顺便说一句,我对 SublimeCodeIntel 插件很生气,并尝试了SublimeJEDI插件。恕我直言,SublimeJEDI 更适合 Python 编码。在具有自动完成功能的 SublimeJEDI 中查看以下屏幕截图,没有问题。
根据我使用这两个插件的经验,我有以下看法。
SublimeJEDI 插件与 SublimeCodeIntel 插件相比的优点:
- 极快
- 轻的
- 易于配置且有据可查
- 没有问题
SublimeCodeIntel 插件的优点:
- 支持多种语言(不仅是 Python)