use of org.jenkinsci.plugins.structs.describable.HeterogeneousObjectType in project workflow-cps-plugin by jenkinsci.
the class Snippetizer method getQuasiDescriptors.
@Restricted(NoExternalUse.class)
public Collection<QuasiDescriptor> getQuasiDescriptors(boolean advanced) {
TreeSet<QuasiDescriptor> t = new TreeSet<>();
for (StepDescriptor d : StepDescriptor.all()) {
if (d.isAdvanced() == advanced) {
t.add(new QuasiDescriptor(d));
if (d.isMetaStep()) {
DescribableModel<?> m = DescribableModel.of(d.clazz);
Collection<DescribableParameter> parameters = m.getParameters();
if (parameters.size() == 1) {
DescribableParameter delegate = parameters.iterator().next();
if (delegate.isRequired()) {
if (delegate.getType() instanceof HeterogeneousObjectType) {
// TODO HeterogeneousObjectType does not yet expose symbol information, and DescribableModel.symbolOf is private
for (DescribableModel<?> delegateOptionSchema : ((HeterogeneousObjectType) delegate.getType()).getTypes().values()) {
Class<?> delegateOptionType = delegateOptionSchema.getType();
Descriptor<?> delegateDescriptor = Jenkins.getActiveInstance().getDescriptorOrDie(delegateOptionType.asSubclass(Describable.class));
Set<String> symbols = SymbolLookup.getSymbolValue(delegateDescriptor);
if (!symbols.isEmpty()) {
t.add(new QuasiDescriptor(delegateDescriptor));
}
}
}
}
}
// TODO currently not handling metasteps with other parameters, either required or (like GenericSCMStep) not
}
}
}
return t;
}
Aggregations