List<TriggerDescriptor> r = new ArrayList<TriggerDescriptor>();
for (TriggerDescriptor t : all()) {
if(!t.isApplicable(i)) continue;
if (i instanceof TopLevelItem) {// ugly
TopLevelItemDescriptor tld = ((TopLevelItem) i).getDescriptor();
// tld shouldn't be really null in contract, but we often write test Describables that
// doesn't have a Descriptor.
if(tld!=null && !tld.isApplicable(t)) continue;
}
r.add(t);
}
return r;