Community
Participate
Working Groups
IMO it is not very client friendly to throw an runtime exception in this case. Wouldn't it be better to return null in this case indicating that no AST can be build ?
Why would you call this API on a classfile that has no source?
The closest thing we could do to match the spec (no null is expected) would be an empty unit, but then you would need to know that no source is associated. An exception is a better way. I agree though that IllegalArgumentExceptions are not very helpful in this case... could improve the message at least. Would it be enough ?
I changed our code to check if the class file as source by checking the source range. The reason why I filed the PR was that I wanted to avoid calling getSource before calling the parse method since otherwise we would have "created" the source twice. No action required from JDT/UI anymore