CodeCompletion 0.2.1 doesn't seem to work

Plugins
Mathieu
2005-04-20
2013-04-26
  • Mathieu
    Mathieu
    2005-04-20

    hi folks, i'm new here so please excuse me if my question is totally dumb...

    I have installed drpython (3.10.12) with codecompletion plugin (0.2.1), and i want to try out the completion feature...

    maybe i don't have understood the way the plugin works, but when i create a class like that

    class foo:
        def bar(self):
            print "foobar"

    if __name__ == "__main__":
        object == foo()
        object. <- i expected the plugin to complete by "bar()" but there's nothing appearing... despite the fact that the plugin seems to be loaded and functionnal.

    maybe something i missed ?
    thx for your advices

    Math

     
    • Hello,

      is the Code Completition enabled? (Options => Enable Code Completition).
      Does after typing wx. pop up a completition list?
      For the object: Python is weak typed, so normally
      you cannot say, what type object is.

      BTW: You meant  object = foo(); not  object == foo()? ;)
      It could be achieved, but never accurate.

      this means a more complex reparsing the source.

       
    • igol
      igol
      2006-01-16

      Hello,

      I think I was able to make it work by making GetMembers() compile the entire code.

      See modified source below for GetMembers() and OnAutoComplete() :

      =====================

          def OnAutoComplete(event):       
              event.Skip()
             
              if not DrFrame.CodeCompletion:
                  return
             
              stc = DrFrame.GetActiveSTC()
             
              if (stc.filetype != 0):
                  return
             
              word, wordalias = GetWordOfInterest(stc, True)
              documentText = stc.GetText()
             
              if (wordalias.find("gtk") > -1) or (wordalias.find("drpython") > -1):
                  #This crashes wxPython resp. drPython
                  return
             
              results = GetMembers(documentText, word)
             
              #if wordalias != word:
              #    results = GetMembers(documentText, wordalias, prepend=word)
              #else:
              #    results = GetMembers(documentText, word)

                 
              if len(results) < 1:
                  return
              if stc.CallTipActive():
                  stc.CallTipCancel()
              stc.AutoCompShow(len(word), results)

      =====================

      def GetMembers(documentText, word, filename='', prepend=''):
              try:
                      try:
                              # Compile the entire document.
                              # - Otherwise, the exec() statement won't know
                              # - about previously created variables, their values
                              # - and/or their types
                              exec(compile(documentText, "", "exec"))
                      except:
                              pass
                      try:
                              exec(compile("import " + word, filename, 'exec'))
                      except:
                              pass
                      # Determine the autocomplete list for the given word
                      exec(compile("members = dir(" + word + ")", filename, 'exec'))
              except:
                      return ''

              if len(prepend) == 0:
                      prepend = word
            
              members.sort()
              members.reverse()
            
              results = ''
            
              for m in members:
                      results = prepend + '.' + m + ' ' + results   
            
              return results.rstrip()

       
    • I tried your patch, but it doesn't seem to
      work. (I hope, I made no mistake).

      If I type
      import wx
      and then wx.

      nothing appears.

      But it would be cool, if you (want and/or have time)
      to investigate this issue.

      Maybe Pycrust's code completion would be helpful
      to study.

      Cheers,