本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.JCLambda类的典型用法代码示例。如果您正苦于以下问题:Java JCLambda类的具体用法?Java JCLambda怎么用?Java JCLambda使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JCLambda类属于com.sun.tools.javac.tree.JCTree包,在下文中一共展示了JCLambda类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: methodParamIndex
import com.sun.tools.javac.tree.JCTree.JCLambda; //导入依赖的package包/类
private int methodParamIndex(List<JCTree> path, JCTree param) {
List<JCTree> curr = path;
while (curr.head.getTag() != Tag.METHODDEF &&
curr.head.getTag() != Tag.LAMBDA) {
curr = curr.tail;
}
if (curr.head.getTag() == Tag.METHODDEF) {
JCMethodDecl method = (JCMethodDecl)curr.head;
return method.params.indexOf(param);
} else if (curr.head.getTag() == Tag.LAMBDA) {
JCLambda lambda = (JCLambda)curr.head;
return lambda.params.indexOf(param);
} else {
Assert.error("methodParamIndex expected to find method or lambda for param: " + param);
return -1;
}
}
示例2: TypeAnnotationPosition
import com.sun.tools.javac.tree.JCTree.JCLambda; //导入依赖的package包/类
private TypeAnnotationPosition(final TargetType ttype,
final int pos,
final int parameter_index,
final JCLambda onLambda,
final int type_index,
final int bound_index,
final List<TypePathEntry> location) {
Assert.checkNonNull(location);
this.type = ttype;
this.pos = pos;
this.parameter_index = parameter_index;
this.onLambda = onLambda;
this.type_index = type_index;
this.bound_index = bound_index;
this.location = location;
}
示例3: methodThrowsTAPosition
import com.sun.tools.javac.tree.JCTree.JCLambda; //导入依赖的package包/类
public static TypeAnnotationPosition methodThrowsTAPosition(SourceVersion ver, final int tidx, final int pos) {
return call8or9(ver,
new TAPCall() {
@Override
public TypeAnnotationPosition call8(Object ... p) throws InstantiationException, IllegalAccessException, IllegalArgumentException, NoSuchFieldException, SecurityException {
TypeAnnotationPosition tapos = TypeAnnotationPosition.class.newInstance();
TypeAnnotationPosition.class.getField("type").set(tapos, TargetType.THROWS);
TypeAnnotationPosition.class.getField("type_index").set(tapos, tidx);
TypeAnnotationPosition.class.getField("pos").set(tapos, pos);
return tapos;
}
@Override
public TypeAnnotationPosition call9(Object... param) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, NoSuchFieldException {
return (TypeAnnotationPosition) TypeAnnotationPosition.class
.getMethod("methodThrows", List.class, JCLambda.class, int.class, int.class)
.invoke(null, TypeAnnotationPosition.class.getField("emptyPath").get(null), null, tidx, pos);
}
}
);
}
示例4: typeParameterTAPosition
import com.sun.tools.javac.tree.JCTree.JCLambda; //导入依赖的package包/类
public static TypeAnnotationPosition typeParameterTAPosition(SourceVersion ver, final int tpidx, final int pos) {
return call8or9(ver,
new TAPCall() {
@Override
public TypeAnnotationPosition call8(Object ... p) throws InstantiationException, IllegalAccessException, IllegalArgumentException, NoSuchFieldException, SecurityException {
TypeAnnotationPosition tapos = TypeAnnotationPosition.class.newInstance();
TypeAnnotationPosition.class.getField("type").set(tapos, TargetType.CLASS_TYPE_PARAMETER);
TypeAnnotationPosition.class.getField("parameter_index").set(tapos, tpidx);
TypeAnnotationPosition.class.getField("pos").set(tapos, pos);
return tapos;
}
@Override
public TypeAnnotationPosition call9(Object... param) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, NoSuchFieldException {
return (TypeAnnotationPosition) TypeAnnotationPosition.class
.getMethod("typeParameter", List.class, JCLambda.class, int.class, int.class)
.invoke(null, TypeAnnotationPosition.class.getField("emptyPath").get(null), null, tpidx, pos);
}
}
);
}
示例5: methodTypeParameterTAPosition
import com.sun.tools.javac.tree.JCTree.JCLambda; //导入依赖的package包/类
public static TypeAnnotationPosition methodTypeParameterTAPosition(SourceVersion ver, final int tpidx, final int pos) {
return call8or9(ver,
new TAPCall() {
@Override
public TypeAnnotationPosition call8(Object ... p) throws InstantiationException, IllegalAccessException, IllegalArgumentException, NoSuchFieldException, SecurityException {
TypeAnnotationPosition tapos = TypeAnnotationPosition.class.newInstance();
TypeAnnotationPosition.class.getField("type").set(tapos, TargetType.METHOD_TYPE_PARAMETER);
TypeAnnotationPosition.class.getField("parameter_index").set(tapos, tpidx);
TypeAnnotationPosition.class.getField("pos").set(tapos, pos);
return tapos;
}
@Override
public TypeAnnotationPosition call9(Object... param) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, NoSuchFieldException {
return (TypeAnnotationPosition) TypeAnnotationPosition.class
.getMethod("methodTypeParameter", List.class, JCLambda.class, int.class, int.class)
.invoke(null, TypeAnnotationPosition.class.getField("emptyPath").get(null), null, tpidx, pos);
}
}
);
}
示例6: typeParameterBoundTAPosition
import com.sun.tools.javac.tree.JCTree.JCLambda; //导入依赖的package包/类
public static TypeAnnotationPosition typeParameterBoundTAPosition(SourceVersion ver, final int tpidx, final int bndidx, final int pos) {
return call8or9(ver,
new TAPCall() {
@Override
public TypeAnnotationPosition call8(Object ... p) throws InstantiationException, IllegalAccessException, IllegalArgumentException, NoSuchFieldException, SecurityException {
TypeAnnotationPosition tapos = TypeAnnotationPosition.class.newInstance();
TypeAnnotationPosition.class.getField("type").set(tapos, TargetType.CLASS_TYPE_PARAMETER_BOUND);
TypeAnnotationPosition.class.getField("parameter_index").set(tapos, tpidx);
TypeAnnotationPosition.class.getField("bound_index").set(tapos, bndidx);
TypeAnnotationPosition.class.getField("pos").set(tapos, pos);
return tapos;
}
@Override
public TypeAnnotationPosition call9(Object... param) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, NoSuchFieldException {
return (TypeAnnotationPosition) TypeAnnotationPosition.class
.getMethod("typeParameterBound", List.class, JCLambda.class, int.class, int.class, int.class)
.invoke(null, TypeAnnotationPosition.class.getField("emptyPath").get(null), null, tpidx, bndidx, pos);
}
}
);
}
示例7: methodTypeParameterBoundTAPosition
import com.sun.tools.javac.tree.JCTree.JCLambda; //导入依赖的package包/类
public static TypeAnnotationPosition methodTypeParameterBoundTAPosition(SourceVersion ver, final int tpidx, final int bndidx, final int pos) {
return call8or9(ver,
new TAPCall() {
@Override
public TypeAnnotationPosition call8(Object ... p) throws InstantiationException, IllegalAccessException, IllegalArgumentException, NoSuchFieldException, SecurityException {
TypeAnnotationPosition tapos = TypeAnnotationPosition.class.newInstance();
TypeAnnotationPosition.class.getField("type").set(tapos, TargetType.METHOD_TYPE_PARAMETER_BOUND);
TypeAnnotationPosition.class.getField("parameter_index").set(tapos, tpidx);
TypeAnnotationPosition.class.getField("bound_index").set(tapos, bndidx);
TypeAnnotationPosition.class.getField("pos").set(tapos, pos);
return tapos;
}
@Override
public TypeAnnotationPosition call9(Object... param) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, NoSuchFieldException {
return (TypeAnnotationPosition) TypeAnnotationPosition.class
.getMethod("methodTypeParameterBound", List.class, JCLambda.class, int.class, int.class, int.class)
.invoke(null, TypeAnnotationPosition.class.getField("emptyPath").get(null), null, tpidx, bndidx, pos);
}
}
);
}
示例8: visitLambda
import com.sun.tools.javac.tree.JCTree.JCLambda; //导入依赖的package包/类
public void visitLambda(JCLambda tree) {
JCLambda prevLambda = currentLambda;
try {
currentLambda = tree;
int i = 0;
for (JCVariableDecl param : tree.params) {
if (!param.mods.annotations.isEmpty()) {
// Nothing to do for separateAnnotationsKinds if
// there are no annotations of either kind.
TypeAnnotationPosition pos = new TypeAnnotationPosition();
pos.type = TargetType.METHOD_FORMAL_PARAMETER;
pos.parameter_index = i;
pos.pos = param.vartype.pos;
pos.onLambda = tree;
separateAnnotationsKinds(param.vartype, param.sym.type, param.sym, pos);
}
++i;
}
push(tree);
scan(tree.body);
scan(tree.params);
pop();
} finally {
currentLambda = prevLambda;
}
}
示例9: isSimpleStringArg
import com.sun.tools.javac.tree.JCTree.JCLambda; //导入依赖的package包/类
boolean isSimpleStringArg(JCExpression e) {
switch (e.getTag()) {
case LAMBDA:
JCLambda lambda = (JCLambda)e;
return (lambda.getBodyKind() == BodyKind.EXPRESSION) &&
isSimpleStringArg((JCExpression)lambda.body);
default:
Symbol argSym = TreeInfo.symbolFor(e);
return (e.type.constValue() != null ||
(argSym != null && argSym.kind == Kinds.Kind.VAR));
}
}
示例10: visitLambda
import com.sun.tools.javac.tree.JCTree.JCLambda; //导入依赖的package包/类
public void visitLambda(JCLambda tree) {
JCLambda prevLambda = currentLambda;
try {
currentLambda = tree;
int i = 0;
for (JCVariableDecl param : tree.params) {
if (!param.mods.annotations.isEmpty()) {
// Nothing to do for separateAnnotationsKinds if
// there are no annotations of either kind.
final TypeAnnotationPosition pos = TypeAnnotationPosition
.methodParameter(tree, i, param.vartype.pos);
push(param);
try {
separateAnnotationsKinds(param.vartype, param.sym.type, param.sym, pos);
} finally {
pop();
}
}
++i;
}
scan(tree.body);
scan(tree.params);
} finally {
currentLambda = prevLambda;
}
}
示例11: methodReturn
import com.sun.tools.javac.tree.JCTree.JCLambda; //导入依赖的package包/类
/**
* Create a {@code TypeAnnotationPosition} for a method return.
*
* @param location The type path.
* @param onLambda The lambda for this parameter.
* @param pos The position from the associated tree node.
*/
public static TypeAnnotationPosition
methodReturn(final List<TypePathEntry> location,
final JCLambda onLambda,
final int pos) {
return new TypeAnnotationPosition(TargetType.METHOD_RETURN, pos,
Integer.MIN_VALUE, onLambda,
Integer.MIN_VALUE, Integer.MIN_VALUE,
location);
}
示例12: methodReceiver
import com.sun.tools.javac.tree.JCTree.JCLambda; //导入依赖的package包/类
/**
* Create a {@code TypeAnnotationPosition} for a method receiver parameter.
*
* @param location The type path.
* @param onLambda The lambda for this parameter.
* @param pos The position from the associated tree node.
*/
public static TypeAnnotationPosition
methodReceiver(final List<TypePathEntry> location,
final JCLambda onLambda,
final int pos) {
return new TypeAnnotationPosition(TargetType.METHOD_RECEIVER, pos,
Integer.MIN_VALUE, onLambda,
Integer.MIN_VALUE, Integer.MIN_VALUE,
location);
}
示例13: methodParameter
import com.sun.tools.javac.tree.JCTree.JCLambda; //导入依赖的package包/类
/**
* Create a {@code TypeAnnotationPosition} for a method formal parameter.
*
* @param location The type path.
* @param onLambda The lambda for this parameter.
* @param parameter_index The index of the parameter.
* @param pos The position from the associated tree node.
*/
public static TypeAnnotationPosition
methodParameter(final List<TypePathEntry> location,
final JCLambda onLambda,
final int parameter_index,
final int pos) {
return new TypeAnnotationPosition(TargetType.METHOD_FORMAL_PARAMETER,
pos, parameter_index, onLambda,
Integer.MIN_VALUE, Integer.MIN_VALUE,
location);
}
示例14: methodRef
import com.sun.tools.javac.tree.JCTree.JCLambda; //导入依赖的package包/类
/**
* Create a {@code TypeAnnotationPosition} for a method reference.
*
* @param location The type path.
* @param onLambda The lambda for this method reference.
* @param pos The position from the associated tree node.
*/
public static TypeAnnotationPosition
methodRef(final List<TypePathEntry> location,
final JCLambda onLambda,
final int pos) {
return new TypeAnnotationPosition(TargetType.METHOD_REFERENCE, pos,
Integer.MIN_VALUE, onLambda,
Integer.MIN_VALUE, Integer.MIN_VALUE,
location);
}
示例15: constructorRef
import com.sun.tools.javac.tree.JCTree.JCLambda; //导入依赖的package包/类
/**
* Create a {@code TypeAnnotationPosition} for a constructor reference.
*
* @param location The type path.
* @param onLambda The lambda for this constructor reference.
* @param pos The position from the associated tree node.
*/
public static TypeAnnotationPosition
constructorRef(final List<TypePathEntry> location,
final JCLambda onLambda,
final int pos) {
return new TypeAnnotationPosition(TargetType.CONSTRUCTOR_REFERENCE, pos,
Integer.MIN_VALUE, onLambda,
Integer.MIN_VALUE, Integer.MIN_VALUE,
location);
}