mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 14:34:31 +08:00
cleaning
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import types
|
|
||||||
if sys.hexversion >= 0x03000000:
|
if sys.hexversion >= 0x03000000:
|
||||||
import io
|
import io
|
||||||
|
else:
|
||||||
|
import types
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
import debug
|
import debug
|
||||||
@@ -31,7 +32,7 @@ class CachedModule(object):
|
|||||||
if not self.path or timestamp == os.path.getmtime(self.path):
|
if not self.path or timestamp == os.path.getmtime(self.path):
|
||||||
self._parser = parser
|
self._parser = parser
|
||||||
else:
|
else:
|
||||||
raise KeyError
|
raise KeyError()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self._load_module()
|
self._load_module()
|
||||||
return self._parser
|
return self._parser
|
||||||
@@ -243,7 +244,8 @@ class Parser(CachedModule):
|
|||||||
# class members (functions) properties?
|
# class members (functions) properties?
|
||||||
for name, func in members.items():
|
for name, func in members.items():
|
||||||
# recursion problem in properties TODO remove
|
# recursion problem in properties TODO remove
|
||||||
if name in ['fget', 'fset', 'fdel']: continue
|
if name in ['fget', 'fset', 'fdel']:
|
||||||
|
continue
|
||||||
ret = 'pass'
|
ret = 'pass'
|
||||||
code += '@property\ndef %s(self):\n' % (name)
|
code += '@property\ndef %s(self):\n' % (name)
|
||||||
code += parsing.indent_block(get_doc(func) + '%s\n\n' % ret)
|
code += parsing.indent_block(get_doc(func) + '%s\n\n' % ret)
|
||||||
|
|||||||
@@ -896,7 +896,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
|
|||||||
except DecoratorNotFound:
|
except DecoratorNotFound:
|
||||||
continue
|
continue
|
||||||
res_new.append(r)
|
res_new.append(r)
|
||||||
debug.dbg(a+'sfn remove, new: %s, old: %s' % (res_new, result))
|
debug.dbg('sfn remove, new: %s, old: %s' % (res_new, result))
|
||||||
return res_new
|
return res_new
|
||||||
|
|
||||||
def filter_name(scope_generator):
|
def filter_name(scope_generator):
|
||||||
@@ -961,7 +961,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
|
|||||||
# if there are results, ignore the other scopes
|
# if there are results, ignore the other scopes
|
||||||
if result:
|
if result:
|
||||||
break
|
break
|
||||||
debug.dbg(a+'sfn filter "%s" in %s: %s' % (name_str, scope, result))
|
debug.dbg('sfn filter "%s" in %s: %s' % (name_str, scope, result))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def descriptor_check(result):
|
def descriptor_check(result):
|
||||||
@@ -979,7 +979,6 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
|
|||||||
res_new.append(r)
|
res_new.append(r)
|
||||||
return res_new
|
return res_new
|
||||||
|
|
||||||
import random; a = str(random.randint(0,99))
|
|
||||||
if search_global:
|
if search_global:
|
||||||
scope_generator = get_names_for_scope(scope, position=position)
|
scope_generator = get_names_for_scope(scope, position=position)
|
||||||
else:
|
else:
|
||||||
@@ -1200,5 +1199,3 @@ def follow_path(path, scope, position=None):
|
|||||||
result = imports.strip_imports(get_scopes_for_name(scope, current,
|
result = imports.strip_imports(get_scopes_for_name(scope, current,
|
||||||
position=position))
|
position=position))
|
||||||
return follow_paths(path, result, position=position)
|
return follow_paths(path, result, position=position)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -985,7 +985,6 @@ class PyFuzzyParser(object):
|
|||||||
else:
|
else:
|
||||||
self.user_stmt = simple
|
self.user_stmt = simple
|
||||||
|
|
||||||
|
|
||||||
def _parsedotname(self, pre_used_token=None):
|
def _parsedotname(self, pre_used_token=None):
|
||||||
"""
|
"""
|
||||||
The dot name parser parses a name, variable or function and returns
|
The dot name parser parses a name, variable or function and returns
|
||||||
@@ -1484,8 +1483,8 @@ class PyFuzzyParser(object):
|
|||||||
# (This is a rather unlikely error message, for normal code,
|
# (This is a rather unlikely error message, for normal code,
|
||||||
# tokenize seems to be pretty tolerant)
|
# tokenize seems to be pretty tolerant)
|
||||||
self._line_of_tokenize_restart = self.start_pos[0] + 1
|
self._line_of_tokenize_restart = self.start_pos[0] + 1
|
||||||
self._tokenize_start_pos = (0,0)
|
self._tokenize_start_pos = (0, 0)
|
||||||
self._tokenize_end_pos = (0,0)
|
self._tokenize_end_pos = (0, 0)
|
||||||
debug.warning('indentation error on line %s, ignoring it' %
|
debug.warning('indentation error on line %s, ignoring it' %
|
||||||
(self.start_pos[0]))
|
(self.start_pos[0]))
|
||||||
self.gen = tokenize.generate_tokens(buf.readline)
|
self.gen = tokenize.generate_tokens(buf.readline)
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ def run_completion_test(correct, source, line_nr, line, path):
|
|||||||
# difference for testing)
|
# difference for testing)
|
||||||
try:
|
try:
|
||||||
completions = functions.complete(source, line_nr, len(line), path)
|
completions = functions.complete(source, line_nr, len(line), path)
|
||||||
|
#import cProfile as profile
|
||||||
|
#profile.run('functions.complete("""%s""", %i, %i, "%s")'
|
||||||
|
# % (source, line_nr, len(line), path))
|
||||||
except Exception:
|
except Exception:
|
||||||
print('test @%s: %s' % (line_nr - 1, line))
|
print('test @%s: %s' % (line_nr - 1, line))
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
|
|||||||
Reference in New Issue
Block a user