Lines Matching refs:self
126 def __init__(self):
127 self.compldict = {}
128 self.parser = PyParser()
130 def evalsource(self,text,line=0):
131 sc = self.parser.parse(text,line)
134 try: exec(src,self.compldict)
137 try: exec(l,self.compldict)
140 def _cleanstr(self,doc):
143 def get_arguments(self,func_obj):
191 def get_completions(self,context,match):
201 result = eval(_sanitize(stmt[:-1]), self.compldict)
204 args = self.get_arguments(result)
205 return [{'word':self._cleanstr(args),'info':self._cleanstr(doc)}]
208 all = self.compldict
212 result = eval(stmt, self.compldict)
234 c = {'word':wrd, 'abbr':m, 'info':self._cleanstr(doc)}
237 c['abbr'] += '(' + self._cleanstr(self.get_arguments(inst))
240 c['abbr'] += '(' + self._cleanstr(self.get_arguments(inst))
257 def __init__(self,name,indent,docstr=''):
258 self.subscopes = []
259 self.docstr = docstr
260 self.locals = []
261 self.parent = None
262 self.name = name
263 self.indent = indent
265 def add(self,sub):
267 sub.parent = self
268 self.subscopes.append(sub)
271 def doc(self,str):
278 dbg("Scope(%s)::docstr = %s" % (self,d))
279 self.docstr = d
281 def local(self,loc):
282 self._checkexisting(loc)
283 self.locals.append(loc)
285 def copy_decl(self,indent=0):
287 return Scope(self.name,indent,self.docstr)
289 def _checkexisting(self,test):
293 for l in self.locals:
295 self.locals.remove(l)
297 def get_code(self):
299 if len(self.docstr) > 0: str += '"""'+self.docstr+'"""\n'
300 for l in self.locals:
302 str += 'class _PyCmplNoType:\n def __getattr__(self,name):\n return None\n'
303 for sub in self.subscopes:
305 for l in self.locals:
310 def pop(self,indent):
311 #print('pop scope: [%s] to [%s]' % (self.indent,indent))
312 outer = self
317 def currentindent(self):
318 #print('parse current indent: %s' % self.indent)
319 return ' '*self.indent
321 def childindent(self):
322 #print('parse child indent: [%s]' % (self.indent+1))
323 return ' '*(self.indent+1)
326 def __init__(self, name, supers, indent, docstr=''):
327 Scope.__init__(self,name,indent, docstr)
328 self.supers = supers
329 def copy_decl(self,indent=0):
330 c = Class(self.name,self.supers,indent, self.docstr)
331 for s in self.subscopes:
334 def get_code(self):
335 str = '%sclass %s' % (self.currentindent(),self.name)
336 if len(self.supers) > 0: str += '(%s)' % ','.join(self.supers)
338 if len(self.docstr) > 0: str += self.childindent()+'"""'+self.docstr+'"""\n'
339 if len(self.subscopes) > 0:
340 for s in self.subscopes: str += s.get_code()
342 str += '%spass\n' % self.childindent()
347 def __init__(self, name, params, indent, docstr=''):
348 Scope.__init__(self,name,indent, docstr)
349 self.params = params
350 def copy_decl(self,indent=0):
351 return Function(self.name,self.params,indent, self.docstr)
352 def get_code(self):
354 (self.currentindent(),self.name,','.join(self.params))
355 if len(self.docstr) > 0: str += self.childindent()+'"""'+self.docstr+'"""\n'
356 str += "%spass\n" % self.childindent()
360 def __init__(self):
361 self.top = Scope('global',0)
362 self.scope = self.top
363 self.parserline = 0
365 def _parsedotname(self,pre=None):
369 tokentype, token, indent = self.donext()
375 tokentype, token, indent = self.donext()
377 tokentype, token, indent = self.donext()
382 def _parseimportlist(self):
385 name, token = self._parsedotname()
388 if token == 'as': name2, token = self._parsedotname()
391 tokentype, token, indent = self.donext()
395 def _parenparse(self):
400 tokentype, token, indent = self.donext()
418 def _parsefunction(self,indent):
419 self.scope=self.scope.pop(indent)
420 tokentype, fname, ind = self.donext()
423 tokentype, open, ind = self.donext()
425 params=self._parenparse()
427 tokentype, colon, ind = self.donext()
432 def _parseclass(self,indent):
433 self.scope=self.scope.pop(indent)
434 tokentype, cname, ind = self.donext()
438 tokentype, thenext, ind = self.donext()
440 super=self._parenparse()
445 def _parseassignment(self):
447 tokentype, token, indent = self.donext()
468 tokentype, token, indent = self.donext()
479 def donext(self):
480 type, token, (lineno, indent), end, self.parserline = next(self.gen)
481 if lineno == self.curline:
482 #print('line found [%s] scope=%s' % (line.replace('\n',''),self.scope.name))
483 self.currentscope = self.scope
486 def _adjustvisibility(self):
488 scp = self.currentscope
492 #Handle 'self' params
522 self.currentscope = newscope
523 return self.currentscope
526 def parse(self,text,curline=0):
527 self.curline = int(curline)
529 self.gen = tokenize.generate_tokens(buf.readline)
530 self.currentscope = self.scope
535 tokentype, token, indent = self.donext()
539 self.scope = self.scope.pop(indent)
541 func = self._parsefunction(indent)
547 self.scope = self.scope.add(func)
549 cls = self._parseclass(indent)
555 self.scope = self.scope.add(cls)
558 imports = self._parseimportlist()
562 self.scope.local(loc)
565 mod, token = self._parsedotname()
569 names = self._parseimportlist()
573 self.scope.local(loc)
576 if freshscope: self.scope.doc(token)
578 name,token = self._parsedotname(token)
580 stmt = self._parseassignment()
583 self.scope.local("%s = %s" % (name,stmt))
589 (sys.exc_info()[0], sys.exc_info()[1], self.parserline))
590 return self._adjustvisibility()