def parsetext(win, editor): pref = Globals.pref if editor.edittype == 'edit' and editor.languagename == 'python': if not hasattr(editor, 'syntax_info') or not editor.syntax_info: from modules import PyParse nodes = PyParse.parseString(editor.GetText()) else: nodes = editor.syntax_info else: return #add doc_nodes to editor editor.doc_nodes = {} imports = nodes.get_imports(1) if imports: for i, v in enumerate(imports): importline, lineno = v win.replacenode(None, i, importline, win.get_image_id('MODULE'), None, {'data':lineno}, win.get_image_id('MODULE'), sorttype=pref.python_classbrowser_sort) functions = nodes.find('function') #process locals addlocals(win, nodes, nodes, None) if functions: funcs = [(x.name, x.info, x.lineno, x.docstring) for x in functions.values] if pref.python_classbrowser_sort: funcs.sort(c) for i, v in enumerate(funcs): name, info, lineno, docstring = v _id, obj = win.replacenode(None, i, info, win.get_image_id('FUNCTION'), None, {'data':lineno}, win.get_image_id('FUNCTION'), sorttype=pref.python_classbrowser_sort) editor.doc_nodes[_id] = docstring classes = nodes.find('class') if classes: clses = [(x.name, x.info, x.lineno, x) for x in classes.values] if pref.python_classbrowser_sort: clses.sort(c) for i, v in enumerate(clses): name, info, lineno, obj = v #process classes and functions _id, node = win.replacenode(None, i, name, win.get_image_id('CLASS_CLOSE'), win.get_image_id('CLASS_OPEN'), {'data':lineno}, win.get_image_id('CLASS_CLOSE'), sorttype=pref.python_classbrowser_sort) editor.doc_nodes[_id] = obj.docstring #process locals addlocals(win, nodes, obj, node) objs = [(x.name, x.type, x.info, x.lineno, x) for x in obj.values] if pref.python_classbrowser_sort: objs.sort(c) for i, v in enumerate(objs): oname, otype, oinfo, olineno, oo = v imagetype = None if otype == 'class' or otype == 'function': _id, obj = win.replacenode(node, i, oinfo, win.get_image_id('METHOD'), None, {'data':olineno}, win.get_image_id('METHOD'), sorttype=pref.python_classbrowser_sort) editor.doc_nodes[_id] = oo.docstring
def on_jump_definition(editor, word): if editor.edittype == 'edit' and editor.languagename == 'python': if not hasattr(editor, 'syntax_info') or not editor.syntax_info: from modules import PyParse nodes = PyParse.parseString(editor.GetText()) else: nodes = editor.syntax_info lineno = editor.GetCurrentLine() + 1 #syntax line is based on 1, but editor line is base on 0 result = nodes.search_name(lineno, word) if result: t, v, line = result editor.goto(line)
def analysis(win, syncvar): try: win except: return line = win.GetCurrentLine() root = PyParse.parseString(win.getRawText(), syncvar) if not syncvar.empty or not root: return win.lock.acquire() win.syntax_info = root win.lock.release()
def on_jump_definition(editor, word): if editor.edittype == 'edit' and editor.languagename == 'python': if not hasattr(editor, 'syntax_info') or not editor.syntax_info: from modules import PyParse nodes = PyParse.parseString(editor.GetText()) else: nodes = editor.syntax_info lineno = editor.GetCurrentLine( ) + 1 #syntax line is based on 1, but editor line is base on 0 result = nodes.search_name(lineno, word) if result: t, v, line = result editor.goto(line)
def parsetext(win, editor): pref = Globals.pref if editor.edittype == 'edit' and editor.languagename == 'python': if not hasattr(editor, 'syntax_info') or not editor.syntax_info: from modules import PyParse nodes = PyParse.parseString(editor.GetText()) else: nodes = editor.syntax_info else: return #add doc_nodes to editor editor.doc_nodes = {} imports = nodes.get_imports(1) if imports: for i, v in enumerate(imports): importline, lineno = v win.replacenode(None, i, importline, win.get_image_id('MODULE'), None, {'data': lineno}, win.get_image_id('MODULE'), sorttype=pref.python_classbrowser_sort) functions = nodes.find('function') #process locals addlocals(win, nodes, nodes, None) if functions: funcs = [(x.name, x.info, x.lineno, x.docstring) for x in functions.values] if pref.python_classbrowser_sort: funcs.sort(c) for i, v in enumerate(funcs): name, info, lineno, docstring = v _id, obj = win.replacenode(None, i, info, win.get_image_id('FUNCTION'), None, {'data': lineno}, win.get_image_id('FUNCTION'), sorttype=pref.python_classbrowser_sort) editor.doc_nodes[_id] = docstring classes = nodes.find('class') if classes: clses = [(x.name, x.info, x.lineno, x) for x in classes.values] if pref.python_classbrowser_sort: clses.sort(c) for i, v in enumerate(clses): name, info, lineno, obj = v #process classes and functions _id, node = win.replacenode(None, i, name, win.get_image_id('CLASS_CLOSE'), win.get_image_id('CLASS_OPEN'), {'data': lineno}, win.get_image_id('CLASS_CLOSE'), sorttype=pref.python_classbrowser_sort) editor.doc_nodes[_id] = obj.docstring #process locals addlocals(win, nodes, obj, node) objs = [(x.name, x.type, x.info, x.lineno, x) for x in obj.values] if pref.python_classbrowser_sort: objs.sort(c) for i, v in enumerate(objs): oname, otype, oinfo, olineno, oo = v imagetype = None if otype == 'class' or otype == 'function': _id, obj = win.replacenode( node, i, oinfo, win.get_image_id('METHOD'), None, {'data': olineno}, win.get_image_id('METHOD'), sorttype=pref.python_classbrowser_sort) editor.doc_nodes[_id] = oo.docstring