I am not the expert on this...
As for the exception. When codetool inserts the unit, the in order to keep working on the unit it desires to know what idents are defined in that unit (in the interface part). Well, technically it needs that, when it needs to lookup any identifier that is not declared in that unit.
var a: TMyTypeFromOtherUnit;
TMyTypeFromOtherUnit could have several declarations in several units. The codetool needs to go through the uses, and for each unit make sure that it is not in there, before going to the next.
....
Some hear-say that I found way down memory lane....
It might be that codetool can find some of that from ppu. Afaik a ppu probably has the names of stuff in your interface. Because if another unit refers to it, then the compiler must be able to find it.
Even if it's a ppu, if I use it in my unit, then my unit can use anything from it's interface. Just as if it was source. Only I can't get it human readable.
So, if my memory is right there, then codetool could work, if it finds the ppu (and if it indeed knows how to read it).
For that codetool would probably still need a package. That package still needs to say, I have that unit, and the ppu must be in the configure path (it should be by default if you compiled the unit from source before, and only removed the pas files).
Mind, then that if you are using the latest trunk fpc, maybe the ppu format is not compatible.
Or maybe I am entirely wrong.... Sorry, but I only got those breadcrumbs.