Attempted to improve python support

Satoshi Kinebuchi skine at dcrew.jp
Wed Jan 18 08:16:08 UTC 2006


Hi Richard,

Thanks for your advise.
# your ruby support codes really consulted me;-)

Richard Daleさんの<200601171211.28537.Richard_Dale at tipitina.demon.co.uk>から
>Sounds good, but is it possible to add code completion for a dynamic language 
>like python which doesn't have any static type tags? For ruby there is no 
>code completion, although I do add instance variables to the class browser 
>with the line number where they were first initialised as the place where 
>they are 'declared'. 

yeap, I agree:-). It is difficult to make them 'complete' completion.
But there can be many cases to be able to complete without type 
metadata, I think. For example, 'module.class' form, function parameter name
within that function, 'import' form, etc. Python interpreter has type 
information as its internal state at compilation time, so it would be 
able to complete class members. But it is difficult to get 'bar' and 'boo' as 
completion entry in the following case:

class Foo:
  def func(self):
    self.<CTRL+SPACE>

  def __init__(self):
    self.bar = 0
    self.boo = 1


BTW, my short time goal is:

- complete module names, class names following 'import'
- complete parameter names, local names within a function
- complete module names, class names, method names

I'm going to write some working code at any rate.
After that I will solve some sort of problems or difficulties
I will hit in the process.

>Instead of the bash shell running in the konsole window I have the ruby 'irb' 
>as a shell instead, so you could start a python shell by setting the 'SHELL' 
>variable to python. A python debugger would be really good, and you might be 
>able to adapt the ruby one (it should be closer to what you need than the C++ 
>gdb debugger).

It's helpful advise! I don't give consideration at all to debugger yet;-).

>> 2) What a reason or discussion made them decide to create hand-written
>> parsers?
>You can write the parser any way you like as long as you use the kdevelop 
>methods to insert a node for a method or a class into the code model. I think 
>there is a simple regular expression based parser for python at the moment, 
>and so you can look at the methods it uses to build the class browser info. 
>But it will be nice for kdevelop 4 to use a uniform framework based on 
>Roberto's parser generator. That will make adding refactoring support easier 
>for instance.

Certainly kdevelop-pg will become main framework for creating a parser.
I'm divided between 3.4 and 4 becuase I myself want to use these features
I attempt to add as soon as possible so I don't want to wait for 4.

Thanks to your point I come to get organized. Class member completion
maybe requires type information interpreter generates. 

>> 3) In case it would be better to create a parser by hand,
>>    what is the best way to create it?
>It would certainly be nice to have python parser based on Roberto's one for 
>kdevelop 4, but I don't think anyone has thought about using it for kdevelop 
>3.4 yet. That's because there hasn't really been much activity yet in the 3.4 
>branch, but I can't see any reason why it couldn't be used.

First I'm going to create completion feature just to work. I must study more
about python syntax. Next I will get into 4 branch (maybe using kdevelop-pg).

Thanks a lot.

-- 
Satoshi Kinebuchi mailto:skine at dcrew.jp




More information about the KDevelop-devel mailing list