Community
Participate
Working Groups
20060127 Please offer an API to create a IResourceProxy from an IResource. In the search plugin we use the IResourceProxy in a public API: TextSearchScope.contains(IResourceProxy proxy) This is essential as we use a resource visitor and have to avoid resolving resources unless really needed. Hoever, the TextSearchScope also has its uses in other contexts where users only have an IFile and want to test it against the scope. Adding a second API TextSearchScope.contains(IResource res) would mean code duplication in an implementation of a TextSearchScope. A method IResource.getResourceProxy() would help to keep the code simple.
Sure, why not.
Released. Note that when you create a proxy, you are obtaining a copy of the info about that resource. The proxy will not get updated if the resource changes. This could actually be useful to other clients as an optimization. Every time you call an IResource method it has to do a lookup in the workspace tree. So, if you want several pieces of information, it's likely less expensive to create a proxy and then query its state instead. The client just has to realize that if the resource is modified concurrently, the proxy will become stale.
Great. I found that the spec of IResourceProxy should be refined and the references to 'visit' should be generalized. * <p> * Note that a resource proxy is a transient object that is only valid for the * duration of a single visit method. A proxy should not be referenced once the * single resource visit is complete. The equals and hashCode methods should not * be relied on. * </p> I would change it the way to say that a resource proxy is a transient object and that clients should not hold a reference to it. About your last comment in comment 2. The name of the class is IResourceProxy, so I wouldn't let it keep state, but really just be a proxy. But as said as these elements are not to be kept in structures, and are therefore not long-lived, this doesn't really matter.
I have clarified the javadoc. However, the behaviour of IResourceProxy during a visit is special so I still distinguish this in the doc. During a visit, the same proxy object is reused, so it really cannot be referenced outside the visit method. When IResource#createProxy is used, there is no context that we can define in which the proxy is valid.