AkelPad Forum Index AkelPad
Support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Интеграция Code Intelligence

 
Post new topic   Reply to topic    AkelPad Forum Index -> Discussion (Russian)
View previous topic :: View next topic  
Author Message
lexa



Joined: 14 Jan 2011
Posts: 16

PostPosted: Mon May 13, 2013 5:29 pm    Post subject: Интеграция Code Intelligence Reply with quote

Привет.

У Komodo IDE есть отличная штука для автокомплита - Code Intelligence. Она доступна под лицензией MPL, как часть Open Komodo. К сожалению, я второй день не могу достучаться до их SVN-репозитория поэтому использую код библиотеки из проекта SublimeCodeIntel (плагин к Sublime Text).

Привожу пример работы Code Intelligence. Тестовые файлы созданы в директории [SublimeCodeIntel-master]\libs\ для простоты использования.

Для работы нужен Python 2.6. С 2.7 проблемы у модуля SilverCity (нужно перекомпилировать модули pyd в директориях _sys, где sys ваша система - _win32, _linux_libcpp6_x86 и т.д.).

Для теста я создал три файла:
_test.php - основной "код",
_test2.php - файл для подключения,
_test.py - точка входа.

_test.php:
Code:
<?
include '_test2.php';

$testo = new Test;
$testo->


_test2.php:
Code:
<?
class Test {
    public $var = 10;

    public function hello(){
    }

    public function nice(){
    }

    public function __get($name){
    }

    public function toString(){
    }
}


_test.py:
Code:
from codeintel2.manager import Manager;

mgr = Manager();
mgr.upgrade();
mgr.initialize();

try:
    buf = mgr.buf_from_path('_test.php', 'PHP', None, 'utf-8');
    buf.scan();

    trg = buf.trg_from_pos(57);
    cplns = buf.cplns_from_trg(trg, 2);
   
    print cplns;

    mgr.finalize();
except Exception, e:
    print e;


И запуск:
Code:
python _test.py

Code:
[('function', 'hello'), ('function', 'nice'), ('function', 'toString'), ('function', '__get')]


Достаточно интересно, правда? Code Intelligence поддерживает не только пользовательские, но, конечно же, и стандартные библиотеки языков. Достаточно ввести "str" и CI выдаст все строковые функции совпадающие с именем.

Я первым делом решил интегрировать Code Intelligence для себя через внешний JScript API. Но алгоритм пришедший в голову, мягко говоря, дикий: exec + чтение stdout + ShowMenu.js (как дополнять окошечко автокомплита плагина Coder я не представляю).

Наверное, я смог бы использовать код в Си подключив python.h и по схеме. Но точно не смогу подключить решение к AkelPad'у в виде плагина.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AkelPad Forum Index -> Discussion (Russian) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


SourceForge.net Logo Powered by phpBB © 2001, 2005 phpBB Group