Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-29922] Display single-argument metasteps inline in Snippetizer #38

Merged
merged 4 commits into from Aug 9, 2016

Conversation

Projects
None yet
4 participants
@jglick
Copy link
Member

jglick commented Aug 5, 2016

JENKINS-29922

Means that plugins which offer SimpleBuildSteps or SimpleBuildWrappers with @Symbols will have those extensions be displayed like native steps in Snippet Generator:

snippetizer

Also solves one component of JENKINS-37215, mainly because I had to do something just to make the existing content generators compile again: the static HTML reference (but not GDSL/DSLD) now shows such extensions like top-level steps:

html

@reviewbybees esp. @kohsuke

@reviewbybees

This comment has been minimized.

Copy link

reviewbybees commented Aug 5, 2016

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

}
}
return t;
}

/** Similar to {@link StepDescriptor} but could also represent a metastep’s delegate. */

This comment has been minimized.

Copy link
@kohsuke

kohsuke Aug 5, 2016

Member

IIUC, I suggest this javadoc to be expanded to something like this:

{@code QuasiDescriptor} represents a step and other step-like things that show up in Snippetizer, which can generate some Pipeline Script fragment.

{@link #real} can be a {@code StepDescriptor}, in which case Snippetizer generates an invocation of that step. Or it can be a {@link Descriptor} that can be executed via {@linkplain StepDescriptor#isMetaStep() meta step}, because from users' point of view a regular Describable (say {@code SimpleBuildStep}) executed via a meta step is indistinguishable from a {@code Step}.

This comment has been minimized.

Copy link
@kohsuke

kohsuke Aug 5, 2016

Member

And this scheme will be expanded further with GlobalVariable I assume.

This comment has been minimized.

Copy link
@jglick

jglick Aug 8, 2016

Author Member

And this scheme will be expanded further with GlobalVariable I assume.

I do not think so; why do you say that?

I suggest this javadoc to be expanded

Yes, will do.

}
}
}
} // TODO currently not handling metasteps with other parameters, either required or (like GenericSCMStep) not

This comment has been minimized.

Copy link
@kohsuke

kohsuke Aug 5, 2016

Member

Why? I understand that there's no way to offer configuration for those extra parameters without further change, but isn't it still useful to list them in Snippetizer?

This comment has been minimized.

Copy link
@jglick
Collection<DescribableParameter> parameters = m.getParameters();
if (parameters.size() == 1) {
DescribableParameter delegate = parameters.iterator().next();
if (delegate.isRequired()) {

This comment has been minimized.

Copy link
@kohsuke

kohsuke Aug 5, 2016

Member

I think DescribableModel.getSoleRequiredParameter() captures the intent and the constraints better. A meta step, it should have one and the only one required parameter, so null check against that is purely an error recovery, not a legitimate case.

This comment has been minimized.

Copy link
@jglick

jglick Aug 8, 2016

Author Member

No getSoleRequiredParameter is inappropriate here, because it would return non-null for checkout if made a metastep, which is not a case we are able to handle yet. See the follow-up issue.

DescribableModel model
try {
model = new DescribableModel(d.clazz)
model = new DescribableModel(d.real.clazz)

This comment has been minimized.

Copy link
@kohsuke

kohsuke Aug 5, 2016

Member

Makes one class one Descriptor assumption that will be lifted soon.

This comment has been minimized.

Copy link
@jglick

jglick Aug 8, 2016

Author Member

Yes, see note in #34, the replacement remains TBD.

if (parameters.size() == 1) {
DescribableParameter delegate = parameters.iterator().next();
if (delegate.isRequired()) {
if (delegate.getType() instanceof HeterogeneousObjectType) {

This comment has been minimized.

Copy link
@kohsuke

kohsuke Aug 5, 2016

Member

If we look through ExtensionList.lookup(Descriptor.class) and find all of them that satisfies delegate.getErasedType().isAssignableFrom(Descriptor.clazz) then, single case can cover all ParameterTypes, heterogeneous or not.

This comment has been minimized.

Copy link
@jglick

jglick Aug 8, 2016

Author Member

Perhaps, though a metastep delegate parameter really should be a HeterogeneousObjectType, we are just neglecting to enforce this currently.

@kohsuke

This comment has been minimized.

Copy link
Member

kohsuke commented Aug 5, 2016

I'm done reviewing this. 🐝 to unblock since I'll be away next week

}

public String getSymbol() {
return real instanceof StepDescriptor ? ((StepDescriptor) real).getFunctionName() : real.getClass().getAnnotation(Symbol.class).value()[0];

This comment has been minimized.

Copy link
@oleg-nenashev

oleg-nenashev Aug 8, 2016

Member

🐜 Missing null check in getAnnotation

This comment has been minimized.

Copy link
@jglick

jglick Aug 8, 2016

Author Member

Because we already did the null check on line 373.

@jglick jglick closed this Aug 9, 2016

@jglick jglick reopened this Aug 9, 2016

@oleg-nenashev

This comment has been minimized.

Copy link
Member

oleg-nenashev commented Aug 9, 2016

🐝

@jglick jglick merged commit 7bbc2f3 into jenkinsci:master Aug 9, 2016

1 check passed

Jenkins This pull request looks good
Details

@jglick jglick deleted the jglick:inline-metasteps-JENKINS-29922 branch Aug 9, 2016

svanoort pushed a commit that referenced this pull request Jun 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.