Package com.cloudbees.groovy.cps
Class Builder
java.lang.Object
com.cloudbees.groovy.cps.Builder
Builder pattern for constructing
Blocks into a tree.
For example, to build a Block that represents "1+1", you'd call plus(one(),one())- Author:
- Kohsuke Kawaguchi
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionassign(int line, LValueBlock lhs, Block rhs) bitwiseAnd(int line, Block lhs, Block rhs) bitwiseAndEqual(int line, LValueBlock lhs, Block rhs) bitwiseNegation(int line, Block b) bitwiseOrEqual(int line, LValueBlock lhs, Block rhs) bitwiseXor(int line, Block lhs, Block rhs) bitwiseXorEqual(int line, LValueBlock lhs, Block rhs) { ... }Cast to type.compareEqual(int line, Block lhs, Block rhs) compareNotEqual(int line, Block lhs, Block rhs) contextualize(CallSiteTag... tags) Returns a newBuilderthat contextualizes call sites with the given tags.declareVariable(int line, Class type, String name, Block init) declareVariable(Class type, String name) divEqual(int line, LValueBlock lhs, Block rhs) x ?: yfalse_()lhs =~ rhsfor (x in col) { ... }for (e1; e2; e3) { ... }functionCall(int line, Block lhs, Block name, boolean safe, Block... argExps) functionCall(int line, Block lhs, String name, Block... argExps) LHS.name(...)greaterThan(int line, Block lhs, Block rhs) greaterThanEqual(int line, Block lhs, Block rhs) "Foo bar zot ${x}"kind of stringif (...) { ... } else { ... }instanceOf(int line, Block value, Block type) intdivEqual(int line, LValueBlock lhs, Block rhs) lhs in rhslhs << rhsleftShiftEqual(int line, LValueBlock lhs, Block rhs) lhs <<= rhslessThanEqual(int line, Block lhs, Block rhs) [a,b,c,d]that creates a List.localVariable(int line, String name) localVariable(String name) localVariableAssignOp(int line, String name, String operator, Block rhs) Assignment operator to a local variable, such asx += 3logicalAnd(int line, Block lhs, Block rhs) lhs && rhslhs || rhsMap literal:[ a:b, c:d, e:f ] ...We expect arguments to be multiple of two.matchRegex(int line, Block lhs, Block rhs) lhs ==~ rhsmethodPointer(int line, Block lhs, Block methodName) minusEqual(int line, LValueBlock lhs, Block rhs) modEqual(int line, LValueBlock lhs, Block rhs) multiplyEqual(int line, LValueBlock lhs, Block rhs) Object instantiation.Array instantiation likenew String[1][5]newArrayFromInitializers(Block... args) Array with initializers likenew Object[] {1, "two"}which exists in Java but not Groovy.noop()!bnull_()one()plusEqual(int line, LValueBlock lhs, Block rhs) postfixDec(int line, LValueBlock body) x--postfixInc(int line, LValueBlock body) x++powerEqual(int line, LValueBlock lhs, Block rhs) prefixDec(int line, LValueBlock body) --xprefixInc(int line, LValueBlock body) ++xx..yorx..>yto create a rangereturn exp;rightShift(int line, Block lhs, Block rhs) lhs >> rhsrightShiftEqual(int line, LValueBlock lhs, Block rhs) lhs >>= rhsrightShiftUnsigned(int line, Block lhs, Block rhs) lhs >>> rhsrightShiftUnsignedEqual(int line, LValueBlock lhs, Block rhs) lhs >>>= rhssandboxCast(int line, Block block, Class<?> type, boolean ignoreAutoboxing, boolean strict) Deprecated.sandboxCastOrCoerce(int line, Block block, Class<?> type, boolean ignoreAutoboxing, boolean coerce, boolean strict) Deprecated.Just for compatibility with old scripts; prefercast(int, com.cloudbees.groovy.cps.Block, java.lang.Class, boolean)Likeblock(Block...)but it doesn't create a new scope.setLocalVariable(int line, String name, Block rhs) setProperty(int line, Block lhs, Block property, Block rhs) setProperty(int line, Block lhs, String property, Block rhs) staticCall(int line, Class lhs, String name, Block... argExps) staticField(int line, Class type, String name) Block that's only valid as a LHS of a method call likesuper.foo(...)switch_(String label, Block switchExp, Block defaultStmt, CaseExpression... caseExps) this_()throw exp;true_()tryCatch(Block body, Block finally_, CatchExpression... catches) tryCatch(Block body, List<CatchExpression> catches) try { ... } catch (T v) { ... } catch (T v) { ... }tryCatch(Block body, List<CatchExpression> catches, Block finally_) two()unaryMinus(int line, Block lhs) with(groovy.lang.Closure c) Evaluate the given closure by passing this object as an argument.withClosureType(Class<? extends CpsClosure> t) Overrides the actual instance type ofCpsClosureto be created.zero()
-
Constructor Details
-
Builder
-
-
Method Details
-
withClosureType
Overrides the actual instance type ofCpsClosureto be created.- Returns:
- 'this' object for the fluent API pattern.
-
contextualize
Returns a newBuilderthat contextualizes call sites with the given tags.- See Also:
-
with
Evaluate the given closure by passing this object as an argument. Used to bind literal Builder to a local variable. -
null_
-
noop
-
constant
-
methodPointer
-
zero
-
one
-
two
-
true_
-
false_
-
block
{ ... } -
sequence
Likeblock(Block...)but it doesn't create a new scope. -
sequence
-
sequence
-
closure
-
localVariable
-
localVariable
-
setLocalVariable
-
declareVariable
-
declareVariable
-
this_
-
super_
Block that's only valid as a LHS of a method call likesuper.foo(...) -
javaThis_
-
localVariableAssignOp
Assignment operator to a local variable, such asx += 3 -
if_
if (...) { ... } else { ... } -
if_
-
forLoop
for (e1; e2; e3) { ... } -
forInLoop
public Block forInLoop(int line, String label, Class type, String variable, Block collection, Block body) for (x in col) { ... } -
break_
-
continue_
-
while_
-
doWhile
-
tryCatch
-
tryCatch
try { ... } catch (T v) { ... } catch (T v) { ... } -
tryCatch
-
throw_
throw exp; -
map
Map literal:[ a:b, c:d, e:f ] ...We expect arguments to be multiple of two. -
map
-
staticCall
-
plus
-
plusEqual
-
minus
-
minusEqual
-
multiply
-
multiplyEqual
-
div
-
divEqual
-
intdiv
-
intdivEqual
-
mod
-
modEqual
-
power
-
powerEqual
-
unaryMinus
-
unaryPlus
-
ternaryOp
-
elvisOp
x ?: y -
compareEqual
-
compareNotEqual
-
compareTo
-
lessThan
-
lessThanEqual
-
greaterThan
-
greaterThanEqual
-
findRegex
lhs =~ rhs -
matchRegex
lhs ==~ rhs -
isCase
lhs in rhs -
logicalAnd
lhs && rhs -
logicalOr
lhs || rhs -
leftShift
lhs << rhs -
leftShiftEqual
lhs <<= rhs -
rightShift
lhs >> rhs -
rightShiftEqual
lhs >>= rhs -
rightShiftUnsigned
lhs >>> rhs -
rightShiftUnsignedEqual
lhs >>>= rhs -
not
!b -
bitwiseAnd
-
bitwiseAndEqual
-
bitwiseOr
-
bitwiseOrEqual
-
bitwiseXor
-
bitwiseXorEqual
-
bitwiseNegation
-
prefixInc
++x -
prefixDec
--x -
postfixInc
x++ -
postfixDec
x-- -
cast
Cast to type.- Parameters:
coerce- If true, the cast will use ScriptBytecodeAdapter.asType. If false, it will use ScriptBytecodeAdapter.castToType. Both methods are very willing to coerce their values to other types, so the name is a bit misleading. Generally speaking, Groovy will use coerce=true for casts using the "as" operator, whereas coerce=false will be used in all other cases, such as Java-syntax casts and implicit casts inserted by the Groovy runtime.
-
sandboxCast
@Deprecated public Block sandboxCast(int line, Block block, Class<?> type, boolean ignoreAutoboxing, boolean strict) Deprecated.Just for compatibility with old scripts; prefercast(int, com.cloudbees.groovy.cps.Block, java.lang.Class, boolean) -
sandboxCastOrCoerce
@Deprecated public Block sandboxCastOrCoerce(int line, Block block, Class<?> type, boolean ignoreAutoboxing, boolean coerce, boolean strict) Deprecated.Just for compatibility with old scripts; prefercast(int, com.cloudbees.groovy.cps.Block, java.lang.Class, boolean) -
instanceOf
-
functionCall
LHS.name(...) -
functionCall
-
assign
-
property
-
property
-
array
-
attribute
-
staticField
-
setProperty
-
setProperty
-
new_
Object instantiation. -
new_
-
newArray
Array instantiation likenew String[1][5] -
newArrayFromInitializers
Array with initializers likenew Object[] {1, "two"}which exists in Java but not Groovy. Only used byCpsDefaultGroovyMethodsand friends. -
return_
return exp; -
list
[a,b,c,d]that creates a List. -
range
x..yorx..>yto create a range -
assert_
-
assert_
-
gstring
"Foo bar zot ${x}"kind of string -
switch_
- See Also:
-
case_
-
yield
-
spread
-
spreadMap
-
cast(int, com.cloudbees.groovy.cps.Block, java.lang.Class, boolean)