artem3213212 / cuda_tree_pascal Goto Github PK
View Code? Open in Web Editor NEWCudaText's TreeHelper for Pascal lexer
CudaText's TreeHelper for Pascal lexer
Ощущение что нужен класс и доступ к полям по
if self.nnn == ...
вместо "глобал нн"
regexpr.pas - парсер показыват вложенные TRegexpr.NNN внутри ф-ции ParseAtom
идея - при доходе парсера до "funcion N.N" закрывать всю вложенность и парсить этот узел для N.N как будто он найден в корне.
tests/jsonreader.pp
line
IJSONConsumer = Interface ['{60F9D640-2A69-4AAB-8EE1-0DB6DC614D27}']
можно на этап 2.
@Artem3213212
to fix
Alexey-T/CudaText#3209
I made a change.
def std_block_parse(var_at_begin=False,LowStop=False):
if var_at_begin:
vars = var_block_parse()
else:
vars = []
TO_SKIP = ['class','interface']
z=[]
funcreg=[]
while not ended:
s = get().lower()
begin_pos = line
if s in TO_SKIP:
continue
if s == '[':
while not ended and get()!=']':
pass
elif s.lower() == 'implementation':
z+=std_block_parse()
elif s.lower() == 'uses':
....
tree is better now - missed class is here.
but parasitic "var" block appered.
Нашёл два места где можно юзать этот оп, по регулярке можеш найти ещё
method TLinkedList.DoNotify shown not in correct level of tree.
Regexpr.pas
Показывает глоб вар «inline”
константы называют обычно КАПСОМ.
Нужна еше одна-
FUNCS = ['function', 'procedure', 'constructor', 'destructor']
self.queue.put(tuple(['',(0,0),(0,0),True]))
короче писать как
self.queue.put( ('',(0,0),(0,0),True) )
jsonconf.pp
узлы видны
TJsonConfig.NNNNN
надо же чтобы они были не отдельные узлы а чтобы клик по старым NNNN внутри TJsonConfig клал каретку на тело ф-ции.
Тоже самое в atsynedit_form_complete_synwrite.pas
видно TAcp.DoLoadNnnn
Лучше кликом в дереве по методу класса переходить на _реализацию ф-ций а не на class def
e.g. tests/dumpclass.pp
Заметил что клики в Пас файлах не меняют положение в дереве. смотрю что дает хелпер. он дает такие узкие ranges, что Куд не может их найти по позиции каретки
пример файла
unit formkey;
....
function DoCommandDialog(AEdit: TATSynEdit): integer;
begin
Result:= 0;
with TfmCmd.Create(nil) do
try
edit:= AEdit;
if ShowModal=mrOk then
if List.Selected<>nil then
Result:= StrToIntDef(List.Selected.SubItems[2], 0);
finally
Free
end;
end;
...
procedure TfmCmd.ListDblClick(Sender: TObject);
begin
//ModalResult:= mrOk;
end;
end.
ranges
[((2, 7, 9, 7), 1, 'uses', 0), ((2, 7, 9, 7), 2, 'Classes', 4), ((11, 7, 19, 7), 2, 'SysUtils', 4), ((21, 7, 29, 7), 2, 'FileUtil', 4), ((31, 7, 36, 7), 2, 'Forms', 4), ((38, 7, 46, 7), 2, 'Controls', 4), ((48, 7, 56, 7), 2, 'Graphics', 4), ((58, 7, 65, 7), 2, 'Dialogs', 4), ((67, 7, 75, 7), 2, 'comctrls', 4), ((2, 8, 13, 8), 2, 'ButtonPanel', 4), ((15, 8, 24, 8), 2, 'ATSynedit', 4), ((2, 33, 7, 33), 2, 'Menus', 4), ((9, 33, 16, 33), 2, 'LCLProc', 4), ((2, 26, 7, 26), 1, 'var/const', 2), ((2, 26, 7, 26), 2, 'fmCmd', 7), ((2, 13, 8, 13), 1, 'TfmCmd', 1), ((4, 14, 16, 14), 2, 'var/const', 2), ((4, 14, 16, 14), 3, 'ButtonPanel1', 7), ((4, 15, 8, 15), 3, 'List', 7), ((4, 22, 8, 22), 3, 'edit', 7), ((0, 53, 9, 53), 2, 'FormShow', 5), ((2, 55, 3, 55), 3, 'var/const', 2), ((2, 55, 3, 55), 4, 'i', 7), ((0, 71, 9, 71), 2, 'ListDblClick', 5), ((0, 37, 8, 37), 1, 'DoCommandDialog', 5)]
видим что для ListDblClick - range это слово procedure И ВСЕ!
для DoCommandsDialog - слово function И ВСЕ.
можно дать БОЛЬШИЕ ranges?
надо сделать консты для индексов иконок-
ICON_USES = тут уже можно менять число
ICON_CLASS =
ICON_PROPERTY =
ICON_INTERFACE =
ICON_VAR =
ICON_FUNC =
чтобы твикатть числа потом.
if len(uses)!=0:
в Пи есть неявное приведение к Бул. можно писать
if uses:
это как проверка на None, '', 0, []
файл тут--
https://github.com/alexey-t/atbinhex-lazarus
ATSynedit/ .. / atsynedit_form_complete_synwrite.pas
Startup: total: 1010ms, including plugins: 16ms
Python 3.6.5
TreeHelpers: Markdown, PHP, Pascal
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/user/.cudatext/py/cuda_tree/__init__.py", line 100, in on_open
self.check_and_update(ed_self)
File "/home/user/.cudatext/py/cuda_tree/__init__.py", line 94, in check_and_update
self.update_tree(lexer)
File "/home/user/.cudatext/py/cuda_tree/__init__.py", line 62, in update_tree
heads = list(getter(filename, lines))
File "/home/user/.cudatext/py/cuda_tree_pascal/__init__.py", line 282, in get_headers
main_data=std_block_parse()
File "/home/user/.cudatext/py/cuda_tree_pascal/__init__.py", line 50, in std_block_parse
zz+=[(z[0][0],z[0][1],5,z[1:]+begin_block_parse())]
IndexError: list index out of range
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/user/.cudatext/py/cuda_tree/__init__.py", line 97, in on_change_slow
self.check_and_update(ed_self)
File "/home/user/.cudatext/py/cuda_tree/__init__.py", line 94, in check_and_update
self.update_tree(lexer)
File "/home/user/.cudatext/py/cuda_tree/__init__.py", line 62, in update_tree
heads = list(getter(filename, lines))
File "/home/user/.cudatext/py/cuda_tree_pascal/__init__.py", line 282, in get_headers
main_data=std_block_parse()
File "/home/user/.cudatext/py/cuda_tree_pascal/__init__.py", line 50, in std_block_parse
zz+=[(z[0][0],z[0][1],5,z[1:]+begin_block_parse())]
IndexError: list index out of range
FPC's unit regexpr.pas
tree shows: TRegExpr / var-const /
function Replace (Const AInputStr : RegExprString;
const AReplaceStr : RegExprString;
AUseSubstitution : boolean{$IFDEF DefParam}= False{$ENDIF}) //###0.946
: RegExprString; {$IFDEF OverMeth} overload;
function Replace (Const AInputStr : RegExprString;
AReplaceFunc : TRegExprReplaceFunction)
: RegExprString; overload;
FPC's regexpr.pas
кажется неверные диапазоны кое где.
const
RegExprInvertCaseFunction : TRegExprInvertCaseFunction = {$IFDEF FPC} nil {$ELSE} TRegExpr.InvertCaseFunction{$ENDIF};
// defaul for InvertCase property
дерево переходит куда-то не туда. а на ноду класса ERegExpr.
if s[i0][i1] in ['(',')','[',']','/','|','\\','@','#','=','>','<',':',';',',','.','$','+','-','*']:
список надо глобальную константу, напр. SYMBOLS.
s[i0] встреается 10+ раз- надо переменную
file in tests/ dir.
need also
+=
-=
*=
/=
FPC's regexpr.pp
кликаю на код
function Dump : RegExprString;
дерево не переходит никуда. кажется Dump в дереве нету
NODE_VARS = 'var&const'
завис Куды при открытии ( ui_reopen_session ) сессии с pas file.
так и думал что виснет Хелпер.
вот видно- у cuda_tree дергается евент, и потом Питон тред у тебя делает "лок"
#0 futex_abstimed_wait_cancelable(0, 0x0, 0, 0x11eda10) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
#1 do_futex_wait(0x11eda10, 0x11eda10) at sem_waitcommon.c:111
#2 __new_sem_wait_slow(0x11eda10) at sem_waitcommon.c:181
#3 PyThread_acquire_lock_timed at :0
#4 ?? at :0
#5 _PyCFunction_FastCallDict at :0
#6 ?? at :0
#7 _PyEval_EvalFrameDefault at :0
#8 _PyFunction_FastCallDict at :0
#9 _PyObject_FastCallDict at :0
#10 _PyObject_Call_Prepend at :0
#11 _PyObject_FastCallDict at :0
#12 PyObject_CallFunctionObjArgs at :0
#13 _PyEval_EvalFrameDefault at :0
#14 ?? at :0
#15 ?? at :0
#16 _PyEval_EvalFrameDefault at :0
#17 ?? at :0
#18 _PyEval_EvalFrameDefault at :0
#19 ?? at :0
#20 _PyEval_EvalFrameDefault at :0
#21 ?? at :0
#22 _PyEval_EvalFrameDefault at :0
#23 ?? at :0
#24 _PyEval_EvalFrameDefault at :0
#25 ?? at :0
#26 ?? at :0
#27 ?? at :0
#28 ?? at :0
#29 _PyObject_FastCallDict at :0
#30 ?? at :0
#31 _PyEval_EvalFrameDefault at :0
#32 ?? at :0
#33 ?? at :0
#34 _PyEval_EvalFrameDefault at :0
#35 ?? at :0
#36 _PyEval_EvalFrameDefault at :0
#37 ?? at :0
#38 _PyEval_EvalFrameDefault at :0
#39 ?? at :0
#40 PyEval_EvalCodeEx at :0
#41 PyEval_EvalCode at :0
#42 PyRun_StringFlags at :0
#43 RUN_COMMANDASOBJECTWITHDICT(0x7ffff7f8d210, 0x7fffe6065778 '_cudacmd_cuda_tree.on_cha'..., 258, 0x0, 0x0) at Sources/Core/PythonEngine.pas:5257
#44 RUN_COMMANDASOBJECT(0x7ffff7f8d210, 0x7fffe6065778 '_cudacmd_cuda_tree.on_cha'..., 258) at Sources/Core/PythonEngine.pas:5225
#45 RUN_COMMANDASSTRING(0x7ffff7f8d210, 0x7fffe6065778 '_cudacmd_cuda_tree.on_cha'..., 258) at Sources/Core/PythonEngine.pas:5218
#46 EVALSTRINGASSTR(0x7ffff7f8d210, 0x7fffe6065778 '_cudacmd_cuda_tree.on_cha'...) at Sources/Core/PythonEngine.pas:5200
#47 PY_EVALSTRINGASSTRING(0x7fffe6065778 '_cudacmd_cuda_tree.on_cha'...) at proc_py.pas:97
#48 PY_RUNPLUGIN_EVENT(0x7fffe637a398 'cuda_tree', 0x962958 'on_change_slow', 0x7fffe6570c50, 0x7fffffffe000, -1, false) at proc_py.pas:132
#49 DOPYEVENT(0x7ffff7fa1030, 0x7fffe6570c50, CEVENTONCHANGESLOW, 0x7fffffffe000, -1) at formmain_py_helpers.inc:109
#50 DOPYEVENT(0x7fffe65669d0, 0x7fffe6570c50, CEVENTONCHANGESLOW, 0x7fffffffe000, -1) at formframe.pas:2285
#51 TIMERCHANGETIMER(0x7fffe65669d0, 0x7fffe64c0a80) at formframe.pas:485
#52 DOONTIMER(0x7fffe64c0a80) at customtimer.pas:175
#53 TIMER(0x7fffe64c0a80) at customtimer.pas:150
#54 GTKTIMERCB(0x7fffe6512680) at gtk2/gtk2callback.inc:2703
#55 ?? at :0
#56 g_main_context_dispatch at :0
#57 ?? at :0
#58 g_main_context_iteration at :0
#59 APPWAITMESSAGE(0x7ffff7f64f30) at gtk2/gtk2widgetset.inc:2431
#60 IDLE(0x7ffff7f648f0, true) at include/application.inc:414
#61 HANDLEMESSAGE(0x7ffff7f648f0) at include/application.inc:1283
#62 RUNLOOP(0x7ffff7f648f0) at include/application.inc:1419
#63 APPRUN(0x7ffff7f64f30, {Proc = {procedure (POINTER)} 0x7fffffffe390, Self = 0x7ffff7f648f0}) at include/interfacebase.inc:54
#64 RUN(0x7ffff7f648f0) at include/application.inc:1407
#65 main at cudatext.lpr:35
tests/jsonscanner.pp
now shown: TJsonToken = (...,...,...)
может енумам иконку другую дать.
you get "s" in lowercase, so next checks
if s.lower() == ...
are not needeing .lower()
.
it's slowdown w/o need.
while not ended:
s = get().lower()
begin_pos = line
if s in TO_SKIP:
continue
if s == '[':
while not ended and get()!=']':
pass
elif s.lower() == 'implementation':
z+=std_block_parse()
elif s.lower() == 'uses':
uses_block_parse()
elif s.lower() == 'type':
z+=type_block_parse()
elif s.lower() in ['const','resourcestring']:
vars+=const_block_parse()
elif s.lower() in ['var']+ACCESS_CONTROL:
vars+=var_block_parse()
elif s.lower() in FUNCS:
vars.append(False)
z+=function_parse(begin_pos,funcreg)
elif s.lower() == 'property':
z+=property_parse()
elif s.lower() == 'begin':
кажется надо поменять апи.
сейчас АПИ дает тоьько "номер строки". и тогда CudaTree не поймет где кончается тело ф-ции.
давай я поменяю? вместо line_num можно туда давать
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.