IProjectFileManager::import and parse

Andreas Pakulat apaku at gmx.de
Thu Jun 21 23:38:00 UTC 2007


On 22.06.07 02:13:22, Andras Mantia wrote:
> Hi,
> 
>  I'd like some extra information about the above methods as the docs, 
> well, they are not very detailed. ;)
> 
> As I understand import shouldn't do anything else but return the 
> toplevel project item, usually the toplevel folder of the project.
> 
> As *I* understood, parse would then parse the *whole* project and return 
> a list with the folders belonging to the project, and *only* folders 
> (probably not the files, as they are anyway children of folder items).
> 
> Well, the main problem is that the shell has a different idea of parse 
> than I do, as it works like this:
> - call parse, get a list of directories
> - call parse for each of the directories from the above list
> - repeat this until no directories are found
> 
> So this is a recursive call.
> 
> The documentation for parse is: "This method initialize the model item."
> 
> So the questions:
> 
> 1) Why shouldn't parse be the recursive method instead of the 
> ImportProjectJob::start() ?

Because then each manager would have to do it and we can't decide in the
platform how to handle project parsing, i.e. if we want to do everything
in a separate thread, or we want to do each parse() in a thread or we
want to call processEvents() after each parse() or whatever.

> The problem with the recursiveness in the upper level is that
> sometimes a project file can contain just some urls to the files
> belonging to the project (somewhat similar to KDevelop's custom
> project). In such a case it is really hard to provide first the
> top-level directories, then the ones one level below (separately for
> each top-level directory), and so on. This would require multiple
> parsing of the project file. For such cases its much simple to parse
> the project file once and create *every* Project*Item there.

Uhm, you can easily create the whole structure in your item and then
just use the given item to return the sub-folders. I don't see why you'd
need to reparse every time.

> 2) Is there a real need to "parse" for anything else than the top level 
> item? Of course now it is, due to the code in ImportProjectJob::start, 
> but I don't see any other need for it. The project file manager plugin 
> should read only once the project file: when the project is loaded. If 
> there is a need for a list of files/folders under one folder, this list 
> should (and can) be obtained from the Project*Item tree structure.

Uhm, this is also the interface for the buildsystem managers and these
have multiple files in multiple dirs to parse.

> 3) Why is there the "import" and "parse" separation, if parse could also 
> create the top level item as well?

I'm not sure, but one reason could be that they actually do different
things. The first one could check wether it actually finds the right
project structure for the manager (think .pro files only given to a
CMake manager) while the second function already knows that its working
with a known project structure.

Andreas

-- 
Chicken Little only has to be right once.




More information about the KDevelop-devel mailing list