mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
sith refactoring
This commit is contained in:
10
sith.py
10
sith.py
@@ -117,7 +117,7 @@ class TestCase(object):
|
|||||||
try:
|
try:
|
||||||
with open(self.path) as f:
|
with open(self.path) as f:
|
||||||
self.script = jedi.Script(f.read(), self.line, self.column, self.path)
|
self.script = jedi.Script(f.read(), self.line, self.column, self.path)
|
||||||
self.completions = getattr(self.script, self.operation)()
|
self.objects = getattr(self.script, self.operation)()
|
||||||
if print_result:
|
if print_result:
|
||||||
print("{path}: Line {line} column {column}".format(**self.__dict__))
|
print("{path}: Line {line} column {column}".format(**self.__dict__))
|
||||||
self.show_location(self.line, self.column)
|
self.show_location(self.line, self.column)
|
||||||
@@ -152,27 +152,27 @@ class TestCase(object):
|
|||||||
getattr(self, 'show_' + self.operation)()
|
getattr(self, 'show_' + self.operation)()
|
||||||
|
|
||||||
def show_completions(self):
|
def show_completions(self):
|
||||||
for completion in self.completions:
|
for completion in self.objects:
|
||||||
print(completion.name)
|
print(completion.name)
|
||||||
|
|
||||||
# TODO: Support showing the location in other files
|
# TODO: Support showing the location in other files
|
||||||
|
|
||||||
# TODO: Move this printing to the completion objects themselves
|
# TODO: Move this printing to the completion objects themselves
|
||||||
def show_usages(self):
|
def show_usages(self):
|
||||||
for completion in self.completions:
|
for completion in self.objects:
|
||||||
print(completion.description)
|
print(completion.description)
|
||||||
if os.path.abspath(completion.module_path) == os.path.abspath(self.path):
|
if os.path.abspath(completion.module_path) == os.path.abspath(self.path):
|
||||||
self.show_location(completion.line, completion.column)
|
self.show_location(completion.line, completion.column)
|
||||||
|
|
||||||
def show_call_signatures(self):
|
def show_call_signatures(self):
|
||||||
for completion in self.completions:
|
for completion in self.objects:
|
||||||
# This is too complicated to print. It really should be
|
# This is too complicated to print. It really should be
|
||||||
# implemented in str() anyway.
|
# implemented in str() anyway.
|
||||||
print(completion)
|
print(completion)
|
||||||
# Can't print the location here because we don't have the module path
|
# Can't print the location here because we don't have the module path
|
||||||
|
|
||||||
def show_goto_definitions(self):
|
def show_goto_definitions(self):
|
||||||
for completion in self.completions:
|
for completion in self.objects:
|
||||||
print(completion.desc_with_module)
|
print(completion.desc_with_module)
|
||||||
if os.path.abspath(completion.module_path) == os.path.abspath(self.path):
|
if os.path.abspath(completion.module_path) == os.path.abspath(self.path):
|
||||||
self.show_location(completion.line, completion.column)
|
self.show_location(completion.line, completion.column)
|
||||||
|
|||||||
Reference in New Issue
Block a user