IProjectFileManager::import and parse

Matt Rogers mattr at kde.org
Sat Jun 23 01:07:07 UTC 2007


On Jun 21, 2007, at 6:13 PM, 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() ? 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.
>
> 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.
>

Now that I understand clearly what you mean by project file, I can  
answer #2 and #3.

There may not be a true need for it in your case. It works though,  
and there's nothing wrong with it. You can choose to do all the  
importing in import() or you can use a combination of import() and  
parse(). If you're pulling the information out of a file list like is  
done for the kdevelop 3 custom build manager, then import is really  
all you need.


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

Get Roberto Raggi's input on this (and in addition your second  
question), since he wrote the original code, so he's the only one  
that will really know.

> Of course 1-2-3 depend on each other. ;)
>
> Andras


Matt






More information about the KDevelop-devel mailing list