Lines Matching refs:self
143 def __init__(self):
144 self.compldict = {}
145 self.parser = PyParser()
147 def evalsource(self,text,line=0):
148 sc = self.parser.parse(text,line)
151 try: exec(src) in self.compldict
154 try: exec(l) in self.compldict
157 def _cleanstr(self,doc):
160 def get_arguments(self,func_obj):
209 def get_completions(self,context,match):
219 result = eval(_sanitize(stmt[:-1]), self.compldict)
222 args = self.get_arguments(result)
223 return [{'word':self._cleanstr(args),'info':self._cleanstr(doc)}]
226 all = self.compldict
230 result = eval(stmt, self.compldict)
252 c = {'word':wrd, 'abbr':m, 'info':self._cleanstr(doc)}
255 c['abbr'] += '(' + self._cleanstr(self.get_arguments(inst))
258 c['abbr'] += '(' + self._cleanstr(self.get_arguments(inst))
275 def __init__(self,name,indent,docstr=''):
276 self.subscopes = []
277 self.docstr = docstr
278 self.locals = []
279 self.parent = None
280 self.name = name
281 self.indent = indent
283 def add(self,sub):
285 sub.parent = self
286 self.subscopes.append(sub)
289 def doc(self,str):
296 dbg("Scope(%s)::docstr = %s" % (self,d))
297 self.docstr = d
299 def local(self,loc):
300 self._checkexisting(loc)
301 self.locals.append(loc)
303 def copy_decl(self,indent=0):
305 return Scope(self.name,indent,self.docstr)
307 def _checkexisting(self,test):
311 for l in self.locals:
313 self.locals.remove(l)
315 def get_code(self):
317 if len(self.docstr) > 0: str += '"""'+self.docstr+'"""\n'
318 for l in self.locals:
320 str += 'class _PyCmplNoType:\n def __getattr__(self,name):\n return None\n'
321 for sub in self.subscopes:
323 for l in self.locals:
328 def pop(self,indent):
329 #print 'pop scope: [%s] to [%s]' % (self.indent,indent)
330 outer = self
335 def currentindent(self):
336 #print 'parse current indent: %s' % self.indent
337 return ' '*self.indent
339 def childindent(self):
340 #print 'parse child indent: [%s]' % (self.indent+1)
341 return ' '*(self.indent+1)
344 def __init__(self, name, supers, indent, docstr=''):
345 Scope.__init__(self,name,indent, docstr)
346 self.supers = supers
347 def copy_decl(self,indent=0):
348 c = Class(self.name,self.supers,indent, self.docstr)
349 for s in self.subscopes:
352 def get_code(self):
353 str = '%sclass %s' % (self.currentindent(),self.name)
354 if len(self.supers) > 0: str += '(%s)' % ','.join(self.supers)
356 if len(self.docstr) > 0: str += self.childindent()+'"""'+self.docstr+'"""\n'
357 if len(self.subscopes) > 0:
358 for s in self.subscopes: str += s.get_code()
360 str += '%spass\n' % self.childindent()
365 def __init__(self, name, params, indent, docstr=''):
366 Scope.__init__(self,name,indent, docstr)
367 self.params = params
368 def copy_decl(self,indent=0):
369 return Function(self.name,self.params,indent, self.docstr)
370 def get_code(self):
372 (self.currentindent(),self.name,','.join(self.params))
373 if len(self.docstr) > 0: str += self.childindent()+'"""'+self.docstr+'"""\n'
374 str += "%spass\n" % self.childindent()
378 def __init__(self):
379 self.top = Scope('global',0)
380 self.scope = self.top
381 self.parserline = 0
383 def _parsedotname(self,pre=None):
387 tokentype, token, indent = self.next()
393 tokentype, token, indent = self.next()
395 tokentype, token, indent = self.next()
400 def _parseimportlist(self):
403 name, token = self._parsedotname()
406 if token == 'as': name2, token = self._parsedotname()
409 tokentype, token, indent = self.next()
413 def _parenparse(self):
418 tokentype, token, indent = self.next()
436 def _parsefunction(self,indent):
437 self.scope=self.scope.pop(indent)
438 tokentype, fname, ind = self.next()
441 tokentype, open, ind = self.next()
443 params=self._parenparse()
445 tokentype, colon, ind = self.next()
450 def _parseclass(self,indent):
451 self.scope=self.scope.pop(indent)
452 tokentype, cname, ind = self.next()
456 tokentype, next, ind = self.next()
458 super=self._parenparse()
463 def _parseassignment(self):
465 tokentype, token, indent = self.next()
486 tokentype, token, indent = self.next()
497 def next(self):
498 type, token, (lineno, indent), end, self.parserline = self.gen.next()
499 if lineno == self.curline:
500 #print 'line found [%s] scope=%s' % (line.replace('\n',''),self.scope.name)
501 self.currentscope = self.scope
504 def _adjustvisibility(self):
506 scp = self.currentscope
510 #Handle 'self' params
540 self.currentscope = newscope
541 return self.currentscope
544 def parse(self,text,curline=0):
545 self.curline = int(curline)
547 self.gen = tokenize.generate_tokens(buf.readline)
548 self.currentscope = self.scope
553 tokentype, token, indent = self.next()
557 self.scope = self.scope.pop(indent)
559 func = self._parsefunction(indent)
565 self.scope = self.scope.add(func)
567 cls = self._parseclass(indent)
573 self.scope = self.scope.add(cls)
576 imports = self._parseimportlist()
580 self.scope.local(loc)
583 mod, token = self._parsedotname()
587 names = self._parseimportlist()
591 self.scope.local(loc)
594 if freshscope: self.scope.doc(token)
596 name,token = self._parsedotname(token)
598 stmt = self._parseassignment()
601 self.scope.local("%s = %s" % (name,stmt))
607 (sys.exc_info()[0], sys.exc_info()[1], self.parserline))
608 return self._adjustvisibility()