{"id":194140,"date":"2013-09-17T20:19:03","date_gmt":"2013-09-17T16:19:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=194140"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=194140","title":{"rendered":"<span class=\"post_title\">\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Code Intelligence<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a\u0430\u044f Python-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043a\u0430\u043a Code Intelligence (\u043f\u0438\u0442\u043e\u043d\u043e\u0432\u043e\u0435 \u0438\u043c\u044f \u00abcodeintel2\u00bb). \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0430\u0432\u043d\u043e, \u043e\u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u0430 ActiveState (\u0430\u0432\u0442\u043e\u0440\u044b ActivePython) \u0438 \u0443\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432 \u0438\u0445 \u0442\u0435\u043a\u0441\u0442-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 Komodo Edit \u0438 \u0441\u0440\u0435\u0434\u044b Komodo IDE.<\/p>\n<p>  \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 \u044f\u0437\u044b\u043a\u0430\u0445 Python, Perl, Ruby, PHP, JavaScript, Tcl, LESS, SCSS, \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0440\u0443\u0433\u0438\u0445, \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<br \/>  <a name=\"habracut\"><\/a>   <\/p>\n<ul>\n<li>\u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a auto-completions \u043a \u043d\u0443\u0436\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0430\u043c\u0438,<\/li>\n<li>\u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (\u0441 \u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438),<\/li>\n<li>\u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445\/\u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 \u043a\u043e\u0434\u0435.<\/li>\n<\/ul>\n<p>  \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0441\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430 <a href=\"https:\/\/github.com\/SublimeCodeIntel\/SublimeCodeIntel\">SublimeCodeIntel<\/a> (\u0447\u0430\u0441\u0442\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043f\u0430\u043f\u043a\u0430\u0445 libs \u0438 arch), \u0430 \u00ab\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0439\u00bb \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 ActiveState \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b \u2014 \u043d\u0435 \u0430\u0444\u0438\u0448\u0438\u0440\u0443\u044e\u0442 \u0435\u0435 \u043e\u043d\u0438. \u041e\u0442 SublimeCodeIntel \u0432\u044b \u0432\u043e\u0437\u044c\u043c\u0435\u0442\u0435 \u0432\u0435\u0440\u0441\u0438\u044e \u0434\u043b\u044f Python 2.6, \u0438\u043c\u0435\u043d\u043d\u043e 2.6, \u0430 \u043d\u0435 2.7, \u0442.\u043a. \u0442\u0430\u043c \u0435\u0441\u0442\u044c \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u043f\u043e\u0434 2.6 (\u0442\u0430\u043a \u0431\u044b\u043b\u043e \u043a\u043e\u0433\u0434\u0430 \u044f \u0435\u0435 \u0431\u0440\u0430\u043b).<\/p>\n<p>  API \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u043a\u043b\u044e\u0436\u0435\u0435 \u0443 CodeIntel. \u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u043f\u043e CodeIntel \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a, \u0441\u043a\u0430\u0436\u0435\u043c, \u043d\u0430\u0439\u0442\u0438 \u0441\u043f\u0438\u0441\u043e\u043a completions \u043a \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0438\u043c\u0435\u043d\u0438 \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>  \u041f\u0443\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0444\u0430\u0439\u043b \u043d\u0430 \u041f\u0438\u0442\u043e\u043d\u0435 \u00abtest.py\u00bb:  <\/p>\n<pre><code class=\"python\"># test class class CName:     prop1 = 0     prop2 = 1     def __init__(self, val1, val2):         pass     def func1(self, par1, par2 = 10, par3 = None):         return par1 + par2 * par3;     def func2(self, l = [], count = 0):         return l[:count]  c = CName() c. <\/code><\/pre>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430: \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a completions \u043a \u0438\u043c\u0435\u043d\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u00abc\u00bb \u0441 \u0442\u043e\u0447\u043a\u043e\u0439. \u041f\u043e \u043a\u043e\u0434\u0443 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u2014 \u044d\u0442\u043e 2 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 prop1, prop2 \u0438 3 \u043c\u0435\u0442\u043e\u0434\u0430 __init__, func1, func2. \u041f\u0438\u0448\u0435\u043c \u043d\u0430\u0448 \u0441\u043a\u0440\u0438\u043f\u0442 \u00abrun.py\u00bb:  <\/p>\n<pre><code class=\"python\">import sys import os  class Info(object): # our demo data     pass info = Info() info.timeout = 15 # max timeout for id searching, sec info.filename = sys.argv[1] # source file name (py, php, pl, etc)  _codeintel = r'g:\\_CodeIntel' # path to libs\/arch folders sys.path.insert(0, os.path.join(_codeintel, 'arch')) sys.path.insert(0, os.path.join(_codeintel, 'libs'))  from codeintel2.manager import Manager from codeintel2.common import EvalController  # need to reset Codeintel cache? if info.filename == '_reset_':     mgr = Manager()     mgr.db.reset(False)     exit(0)  sys.path.append(os.path.basename(info.filename)) info.filepos = os.path.getsize(info.filename) # get end-of-file pos  def _do(buf, trg, timeout):     ctlr = EvalController()     buf.async_eval_at_trg(trg, ctlr)     ctlr.wait(timeout)     if not ctlr.is_done():         ctlr.done(&quot;timed out&quot;)         ctlr.abort()         raise EvalTimeout(&quot;eval for %s timed-out&quot; % trg)     return (ctlr.cplns, ctlr.calltips)  mgr = Manager() mgr.upgrade() mgr.initialize()  # read file buf = mgr.buf_from_path(info.filename) buf.scan()  # get trigger trg = buf.trg_from_pos(info.filepos) result1, result2 = _do(buf, trg, info.timeout)  print 'auto-complete result:' for s1, s2 in result1:     print s1, s2  mgr.finalize() <\/code><\/pre>\n<p>  \u041f\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u0438\u0434\u043d\u043e, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c codeintel. \u041f\u0443\u0441\u043a\u0430\u0435\u043c \u00abpython path\\run.py path2\\test.py\u00bb, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442:<\/p>\n<pre> auto-complete result: function func1 function func2 variable prop1 variable prop2 variable __class__ variable __doc__ function __init__ <\/pre>\n<p>  \u041f\u0440\u0438\u043c.: \u0441\u043a\u0440\u0438\u043f\u0442 run.py \u0438\u0449\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043b\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u00ab\u043a\u043e\u043d\u0435\u0446 \u0444\u0430\u0439\u043b\u0430\u00bb, \u0435\u0441\u043b\u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u00ab\u043a\u0430\u0440\u0435\u0442\u043a\u0438\u00bb \u043d\u0443\u0436\u043d\u0430 \u0434\u0440\u0443\u0433\u0430\u044f, \u0442\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430\u0434\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438 function call-tip \u0434\u043b\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u0443\u043d\u043a\u0446\u0438\u0438 c.func1: \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u043d\u0430\u0434\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043d\u0435 result1, \u0430 result2. \u0422\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b test.py \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u2014 \u043e\u043a\u043e\u043d\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0442\u0430\u043a\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443: <code>c.func1(<\/code>. <\/p>\n<p>  \u041d\u0443 \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446. Codeintel \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0433\u0440\u043e\u043c\u0435\u043d\u043d\u044b\u0439 \u043a\u0435\u0448 \u0432 \u0440\u0430\u0439\u043e\u043d\u0435 &quot;%userprofile%\\.codeintel&quot;. \u0412 run.py \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u043a\u0430\u043a \u044d\u0442\u043e\u0442 \u043a\u0435\u0448 \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c.    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/194140\/\"> http:\/\/habrahabr.ru\/post\/194140\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a\u0430\u044f Python-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043a\u0430\u043a Code Intelligence (\u043f\u0438\u0442\u043e\u043d\u043e\u0432\u043e\u0435 \u0438\u043c\u044f \u00abcodeintel2\u00bb). \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0430\u0432\u043d\u043e, \u043e\u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u0430 ActiveState (\u0430\u0432\u0442\u043e\u0440\u044b ActivePython) \u0438 \u0443\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432 \u0438\u0445 \u0442\u0435\u043a\u0441\u0442-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 Komodo Edit \u0438 \u0441\u0440\u0435\u0434\u044b Komodo IDE.<\/p>\n<p>  \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 \u044f\u0437\u044b\u043a\u0430\u0445 Python, Perl, Ruby, PHP, JavaScript, Tcl, LESS, SCSS, \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0440\u0443\u0433\u0438\u0445, \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-194140","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/194140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=194140"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/194140\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=194140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=194140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=194140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}