mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 15:24:46 +08:00
get rid of the completer of Aaron Griffin
This commit is contained in:
@@ -205,22 +205,27 @@ def showdbg():
|
||||
for d in debugstmts:
|
||||
print "DBG: %s " % d
|
||||
|
||||
|
||||
pyfuzzyparser.debug_function = pyfuzzyparser.dbg()
|
||||
text = cStringIO.StringIO(open('test.py').read())
|
||||
cmpl = Completer()
|
||||
cmpl.evalsource(text, 51)
|
||||
#print cmpl.sc.get_code()
|
||||
#all = cmpl.get_completions("cdef.", '')
|
||||
|
||||
showdbg()
|
||||
|
||||
#print "Completions:", len(all)
|
||||
#for c in all:
|
||||
# print c['word'],
|
||||
# print ',',
|
||||
#print ''
|
||||
showdbg()
|
||||
|
||||
print cmpl.parser.top.get_code()
|
||||
def show_debug(*args):
|
||||
print args
|
||||
|
||||
pyfuzzyparser.debug_function = show_debug
|
||||
|
||||
text = open('test.py').read()
|
||||
parser = pyfuzzyparser.PyFuzzyParser(text)
|
||||
|
||||
|
||||
print parser.top.get_code()
|
||||
#print cmpl.parser.top.subscopes[1].subscopes[0].get_code()
|
||||
|
||||
def handle_names(names):
|
||||
@@ -232,30 +237,29 @@ def handle_names(names):
|
||||
print 'star!', n.from_ns
|
||||
|
||||
print 'global names:'
|
||||
names = cmpl.parser.top.get_set_vars()
|
||||
names = parser.top.get_set_vars()
|
||||
handle_names(names)
|
||||
|
||||
print
|
||||
print 'func names:'
|
||||
names = cmpl.parser.top.subscopes[7].get_set_vars()
|
||||
names = parser.top.subscopes[7].get_set_vars()
|
||||
handle_names(names)
|
||||
|
||||
print
|
||||
print 'class names:'
|
||||
names = cmpl.parser.top.subscopes[2].get_set_vars()
|
||||
names = parser.top.subscopes[2].get_set_vars()
|
||||
handle_names(names)
|
||||
for s in cmpl.parser.top.subscopes[2].subscopes:
|
||||
for s in parser.top.subscopes[2].subscopes:
|
||||
print 'method names:'
|
||||
names = s.get_set_vars()
|
||||
handle_names(names)
|
||||
|
||||
print
|
||||
print 'start/end'
|
||||
for s in cmpl.parser.top.subscopes:
|
||||
for s in parser.top.subscopes:
|
||||
print repr(s)
|
||||
|
||||
p = cmpl.parser
|
||||
s = p.top
|
||||
s = parser.top
|
||||
import code
|
||||
sh = code.InteractiveConsole(locals=locals())
|
||||
#sh.interact("InteractiveConsole")
|
||||
|
||||
@@ -482,13 +482,23 @@ class PyFuzzyParser(object):
|
||||
"""
|
||||
This class is used to parse a Python file, it then divides them into a
|
||||
class structure of different scopes.
|
||||
|
||||
:param code: The codebase for the parser.
|
||||
:type code: str
|
||||
:param user_line: The line, the user is currently on.
|
||||
:type user_line: int
|
||||
"""
|
||||
def __init__(self):
|
||||
def __init__(self, code, user_line=None):
|
||||
self.user_line = user_line
|
||||
self.code = code
|
||||
|
||||
# initialize global Scope
|
||||
self.top = Scope(0, 0)
|
||||
self.scope = self.top
|
||||
self.current = (None, None, None)
|
||||
|
||||
self.parse()
|
||||
|
||||
def _parsedotname(self, pre_used_token=None):
|
||||
"""
|
||||
The dot name parser parses a name, variable or function and returns
|
||||
@@ -773,11 +783,15 @@ class PyFuzzyParser(object):
|
||||
""" Generate the next tokenize pattern. """
|
||||
type, tok, position, dummy, self.parserline = self.gen.next()
|
||||
(self.line_nr, indent) = position
|
||||
if self.line_nr == self.user_line:
|
||||
print 'user scope found [%s] =%s' % \
|
||||
(self.parserline.replace('\n', ''), self.scope.get_name())
|
||||
self.user_scope = self.scope
|
||||
self.last_token = self.current
|
||||
self.current = (type, tok, indent)
|
||||
return self.current
|
||||
|
||||
def parse(self, text):
|
||||
def parse(self):
|
||||
"""
|
||||
The main part of the program. It analyzes the given code-text and
|
||||
returns a tree-like scope. For a more detailed description, see the
|
||||
@@ -788,7 +802,7 @@ class PyFuzzyParser(object):
|
||||
|
||||
:raises: IndentationError
|
||||
"""
|
||||
buf = cStringIO.StringIO(''.join(text) + '\n')
|
||||
buf = cStringIO.StringIO(self.code)
|
||||
self.gen = tokenize.generate_tokens(buf.readline)
|
||||
self.currentscope = self.scope
|
||||
|
||||
|
||||
Reference in New Issue
Block a user