Skip to content
Permalink
Browse files

[JENKINS-32925] Handle recursion

Use stack to keep track of traversal.

Originally-Committed-As: ff210c3819a66e6fec7772a3242ff105c3646513
  • Loading branch information
kohsuke committed Mar 29, 2016
1 parent c940766 commit bf6f1fb7f31747315ca1c972e71f88afc96235d8
@@ -15,6 +15,9 @@ import org.jenkinsci.plugins.workflow.steps.StepDescriptor

import javax.servlet.RequestDispatcher

// keeps track of recursion inside generateHelp
stack = new Stack();

Snippetizer snippetizer = my;

def l = namespace(lib.LayoutTagLib)
@@ -91,6 +94,10 @@ def generateHelp(DescribableModel model, int headerLevel) throws Exception {
if (help != null && !help.equals("")) {
div(class:"help", style:"display: block") { raw(help) }
}
if (stack.contains(model.type))
return; // recursion. just show the title & cut the search

stack.push(model.type);
dl(class:'help-list mandatory'){
// TODO else could use RequestDispatcher (as in Descriptor.doHelp) to serve template-based help
model.parameters.findAll{ it.required }.each { p ->
@@ -115,6 +122,7 @@ def generateHelp(DescribableModel model, int headerLevel) throws Exception {
}
}
}
stack.pop();
}.call()
}

0 comments on commit bf6f1fb

Please sign in to comment.
You can’t perform that action at this time.