Bug 85285 [Contributions] ProjectPersistentPropertyTester should work for IResource
In 3.1 M5, we added a ProjectPersistentPropertyTester that could be used for visibility determination of object contributions to ResourceMapping. It would make sens if this could be used for IResource directly as well. This is not important enough to go into M5 but I think it is worthwhile to have it in 3.1. I will attach a patch.
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/ProjectPersistentPropertyTester.java
/* (non-Javadoc)
    	 * @see org.eclipse.ui.internal.ide.model.WorkbenchResource#getBaseImage(org.eclipse.core.resources.IResource)
    	 */
    	protected ImageDescriptor getBaseImage(IResource resource) {
            return null;
        }
    };
    /* (non-Javadoc)
     * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
     */
    public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
        if (receiver instanceof ResourceMapping) {
            if (property.equals(IResourceActionFilter.PROJECT_PERSISTENT_PROPERTY)) {
                if(args == null) return false;
                String persitentPropertyEntry = (String)args[0];
                IProject[] projects = ((ResourceMapping)receiver).getProjects();
                for (int i = 0; i < projects.length; i++) {
                    IProject project = projects[i];
                    if (!filter.testAttribute(project, property, persitentPropertyEntry))
                        return false;
                }
                
                return true;
            }
        }
        return false;
    }
}