• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JCConditional类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.JCConditional的典型用法代码示例。如果您正苦于以下问题:Java JCConditional类的具体用法?Java JCConditional怎么用?Java JCConditional使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JCConditional类属于com.sun.tools.javac.tree.JCTree包,在下文中一共展示了JCConditional类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: diffConditional

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
protected int diffConditional(JCConditional oldT, JCConditional newT, int[] bounds) {
    int localPointer = bounds[0];
    // cond
    int[] condBounds = getBounds(oldT.cond);
    copyTo(localPointer, condBounds[0]);
    localPointer = diffTree(oldT.cond, newT.cond, condBounds);
    // true
    int[] trueBounds = getBounds(oldT.truepart);
    copyTo(localPointer, trueBounds[0]);
    localPointer = diffTree(oldT.truepart, newT.truepart, trueBounds);
    // false
    int[] falseBounds = getBounds(oldT.falsepart);
    copyTo(localPointer, falseBounds[0]);
    localPointer = diffTree(oldT.falsepart, newT.falsepart, falseBounds);
    copyTo(localPointer, bounds[1]);

    return bounds[1];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CasualDiff.java


示例2: visitConditional

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
@Override public void visitConditional(JCConditional tree) {
	print(tree.cond);
	print(" ? ");
	print(tree.truepart);
	print(" : ");
	print(tree.falsepart);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:8,代码来源:PrettyPrinter.java


示例3: visitConditional

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
public void visitConditional(JCConditional that) {
    try {
        print("JCConditional:");
    } catch (Exception e) {
    }
    super.visitConditional(that);
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:8,代码来源:PrintAstVisitor.java


示例4: visitConditional

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
public void visitConditional(JCConditional tree) {
	try {
		open(prec, TreeInfo.condPrec);
		printExpr(tree.cond, TreeInfo.condPrec);
		print(" ? ");
		printExpr(tree.truepart, TreeInfo.condPrec);
		print(" : ");
		printExpr(tree.falsepart, TreeInfo.condPrec);
		close(prec, TreeInfo.condPrec);
	} catch (IOException e) {
		throw new UncheckedIOException(e);
	}
}
 
开发者ID:mobmead,项目名称:EasyMPermission,代码行数:14,代码来源:PrettyCommentsPrinter.java


示例5: inline

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
@Override
public JCConditional inline(Inliner inliner) throws CouldNotResolveImportException {
  return inliner.maker().Conditional(
      getCondition().inline(inliner),
      getTrueExpression().inline(inliner), 
      getFalseExpression().inline(inliner));
}
 
开发者ID:sivakumar-kailasam,项目名称:refactor-faster,代码行数:8,代码来源:UConditional.java


示例6: visitConditional

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
@Override public void visitConditional(JCConditional tree) {
	printNode(tree);
	child("cond", tree.cond);
	child("truepart", tree.truepart);
	child("falsepart", tree.falsepart);
	indent--;
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:8,代码来源:JcTreePrinter.java


示例7: visitConditional

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
@Override public void visitConditional(JCConditional node) {
	InlineIfExpression iie = new InlineIfExpression();
	iie.rawCondition(toTree(node.getCondition()));
	iie.rawIfTrue(toTree(node.getTrueExpression()));
	iie.rawIfFalse(toTree(node.getFalseExpression()));
	set(node, iie);
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:8,代码来源:JcTreeConverter.java


示例8: inline

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
@Override
public JCConditional inline(Inliner inliner) throws CouldNotResolveImportException {
  return inliner
      .maker()
      .Conditional(
          getCondition().inline(inliner),
          getTrueExpression().inline(inliner),
          getFalseExpression().inline(inliner));
}
 
开发者ID:google,项目名称:error-prone,代码行数:10,代码来源:UConditional.java


示例9: visitConditionalExpression

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
@Override
public Choice<State<JCConditional>> visitConditionalExpression(
    final ConditionalExpressionTree node, State<?> state) {
  return chooseSubtrees(
      state,
      s -> unifyExpression(node.getCondition(), s),
      s -> unifyExpression(node.getTrueExpression(), s),
      s -> unifyExpression(node.getFalseExpression(), s),
      maker()::Conditional);
}
 
开发者ID:google,项目名称:error-prone,代码行数:11,代码来源:PlaceholderUnificationVisitor.java


示例10: visitConditional

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
public void visitConditional(JCConditional tree) {
    try {
        open(prec, TreeInfo.condPrec);
        printExpr(tree.cond, TreeInfo.condPrec);
        print(" ? ");
        printExpr(tree.truepart, TreeInfo.condPrec);
        print(" : ");
        printExpr(tree.falsepart, TreeInfo.condPrec);
        close(prec, TreeInfo.condPrec);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
开发者ID:sebastianoe,项目名称:s4j,代码行数:14,代码来源:Pretty.java


示例11: visitConditional

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
public void visitConditional(JCConditional tree) {
    attribExpr(tree.cond, env, syms.booleanType);
    attribExpr(tree.truepart, env);
    attribExpr(tree.falsepart, env);
    result = check(tree,
                   capture(condType(tree.pos(), tree.cond.type,
                                    tree.truepart.type, tree.falsepart.type)),
                   VAL, pkind, pt);
}
 
开发者ID:sebastianoe,项目名称:s4j,代码行数:10,代码来源:Attr.java


示例12: createSimpleGetterBody

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
private List<JCStatement> createSimpleGetterBody(TreeMaker treeMaker, JavacNode field) {
	JCVariableDecl fieldDecl = (JCVariableDecl) field.get();
	JCExpression fieldRef = createFieldAccessor(treeMaker, field, FieldAccess.ALWAYS_FIELD);

	JCStatement returnExpression = null;
	
	String varTypeString = fieldDecl.vartype.toString();
	boolean isMutable = false;
	boolean isTypeCastNeeded = false;
	if (Timestamp.class.getSimpleName().equals(varTypeString) || Timestamp.class.getName().equals(varTypeString)) {
		isMutable = true;
		isTypeCastNeeded = true;
	} else if (varTypeString.endsWith("[]")) {
		isMutable = true;
	}
	
	if (isMutable) {
		JCExpression nullCheck = treeMaker.Binary(CTC_EQUAL, fieldRef, treeMaker.Literal(CTC_BOT, null));
		JCExpression callClone = treeMaker.Apply(List.<JCExpression>nil(), treeMaker.Select(fieldRef, field.toName("clone")), List.<JCExpression>nil());					
		if (isTypeCastNeeded) {
			callClone = treeMaker.TypeCast(
					fieldDecl.vartype,
					callClone
			);
		}
		
		JCConditional conditional = treeMaker.Conditional(
				nullCheck, 
				treeMaker.Literal(CTC_BOT, null), 
				callClone
		);
		
		returnExpression = treeMaker.Return(conditional);
	} else {
		returnExpression = treeMaker.Return(fieldRef);
	}
	
	return List.<JCStatement>of(returnExpression);
}
 
开发者ID:redundent,项目名称:lombok,代码行数:40,代码来源:HandleGetter.java


示例13: matchConditional

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
private boolean matchConditional(JCConditional t1, JCConditional t2) {
    return treesMatch(t1.cond, t2.cond) && treesMatch(t1.truepart, t2.truepart) &&
           treesMatch(t1.falsepart, t2.falsepart);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:CasualDiff.java


示例14: visitConditional

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
@Override
public void visitConditional(JCConditional that) {
    processArg(that, speculativeTree -> new ConditionalType(that, env, speculativeTree));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:ArgumentAttr.java


示例15: ConditionalType

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
ConditionalType(JCExpression tree, Env<AttrContext> env, JCConditional speculativeCond) {
    this(tree, env, speculativeCond, new HashMap<>());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:ArgumentAttr.java


示例16: dup

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
@Override
ArgumentType<JCConditional> dup(JCConditional tree, Env<AttrContext> env) {
    return new ConditionalType(tree, env, speculativeTree, speculativeTypes);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:ArgumentAttr.java


示例17: Conditional

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
public JCConditional Conditional(JCExpression cond, JCExpression thenpart, JCExpression elsepart) {
	return invoke(Conditional, cond, thenpart, elsepart);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:4,代码来源:JavacTreeMaker.java


示例18: createWither

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
public JCMethodDecl createWither(long access, JavacNode field, JavacTreeMaker maker, JavacNode source, List<JCAnnotation> onMethod, List<JCAnnotation> onParam, boolean makeAbstract) {
	String witherName = toWitherName(field);
	if (witherName == null) return null;
	
	JCVariableDecl fieldDecl = (JCVariableDecl) field.get();
	
	List<JCAnnotation> nonNulls = findAnnotations(field, NON_NULL_PATTERN);
	List<JCAnnotation> nullables = findAnnotations(field, NULLABLE_PATTERN);
	
	Name methodName = field.toName(witherName);
	
	JCExpression returnType = cloneSelfType(field);
	
	JCBlock methodBody = null;
	long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, field.getContext());
	List<JCAnnotation> annsOnParam = copyAnnotations(onParam).appendList(nonNulls).appendList(nullables);
	
	JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, annsOnParam), fieldDecl.name, fieldDecl.vartype, null);
	
	if (!makeAbstract) {
		ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
		
		JCExpression selfType = cloneSelfType(field);
		if (selfType == null) return null;
		
		ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
		for (JavacNode child : field.up().down()) {
			if (child.getKind() != Kind.FIELD) continue;
			JCVariableDecl childDecl = (JCVariableDecl) child.get();
			// Skip fields that start with $
			if (childDecl.name.toString().startsWith("$")) continue;
			long fieldFlags = childDecl.mods.flags;
			// Skip static fields.
			if ((fieldFlags & Flags.STATIC) != 0) continue;
			// Skip initialized final fields.
			if (((fieldFlags & Flags.FINAL) != 0) && childDecl.init != null) continue;
			if (child.get() == field.get()) {
				args.append(maker.Ident(fieldDecl.name));
			} else {
				args.append(createFieldAccessor(maker, child, FieldAccess.ALWAYS_FIELD));
			}
		}
		
		JCNewClass newClass = maker.NewClass(null, List.<JCExpression>nil(), selfType, args.toList(), null);
		JCExpression identityCheck = maker.Binary(CTC_EQUAL, createFieldAccessor(maker, field, FieldAccess.ALWAYS_FIELD), maker.Ident(fieldDecl.name));
		JCConditional conditional = maker.Conditional(identityCheck, maker.Ident(field.toName("this")), newClass);
		JCReturn returnStatement = maker.Return(conditional);
		
		if (nonNulls.isEmpty()) {
			statements.append(returnStatement);
		} else {
			JCStatement nullCheck = generateNullCheck(maker, field, source);
			if (nullCheck != null) statements.append(nullCheck);
			statements.append(returnStatement);
		}
		
		methodBody = maker.Block(0, statements.toList());
	}
	List<JCTypeParameter> methodGenericParams = List.nil();
	List<JCVariableDecl> parameters = List.of(param);
	List<JCExpression> throwsClauses = List.nil();
	JCExpression annotationMethodDefaultValue = null;
	
	List<JCAnnotation> annsOnMethod = copyAnnotations(onMethod);
	
	if (isFieldDeprecated(field)) {
		annsOnMethod = annsOnMethod.prepend(maker.Annotation(genJavaLangTypeRef(field, "Deprecated"), List.<JCExpression>nil()));
	}
	if (makeAbstract) access = access | Flags.ABSTRACT;
	JCMethodDecl decl = recursiveSetGeneratedBy(maker.MethodDef(maker.Modifiers(access, annsOnMethod), methodName, returnType,
			methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source.get(), field.getContext());
	copyJavadoc(field, decl, CopyJavadoc.WITHER);
	return decl;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:75,代码来源:HandleWither.java


示例19: AJCConditional

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
public AJCConditional(JCConditional ltree) {
    super(ltree.cond, ltree.truepart, ltree.falsepart);
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:4,代码来源:AJCConditional.java


示例20: createWither

import com.sun.tools.javac.tree.JCTree.JCConditional; //导入依赖的package包/类
public JCMethodDecl createWither(long access, JavacNode field, JavacTreeMaker maker, JavacNode source, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) {
	String witherName = toWitherName(field);
	if (witherName == null) return null;
	
	JCVariableDecl fieldDecl = (JCVariableDecl) field.get();
	
	ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
	List<JCAnnotation> nonNulls = findAnnotations(field, NON_NULL_PATTERN);
	List<JCAnnotation> nullables = findAnnotations(field, NULLABLE_PATTERN);
	
	Name methodName = field.toName(witherName);
	List<JCAnnotation> annsOnParam = copyAnnotations(onParam).appendList(nonNulls).appendList(nullables);
	
	long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, field.getContext());
	JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, annsOnParam), fieldDecl.name, fieldDecl.vartype, null);
	
	JCExpression selfType = cloneSelfType(field);
	if (selfType == null) return null;
	
	ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
	for (JavacNode child : field.up().down()) {
		if (child.getKind() != Kind.FIELD) continue;
		JCVariableDecl childDecl = (JCVariableDecl) child.get();
		// Skip fields that start with $
		if (childDecl.name.toString().startsWith("$")) continue;
		long fieldFlags = childDecl.mods.flags;
		// Skip static fields.
		if ((fieldFlags & Flags.STATIC) != 0) continue;
		// Skip initialized final fields.
		if (((fieldFlags & Flags.FINAL) != 0) && childDecl.init != null) continue;
		if (child.get() == field.get()) {
			args.append(maker.Ident(fieldDecl.name));
		} else {
			args.append(createFieldAccessor(maker, child, FieldAccess.ALWAYS_FIELD));
		}
	}
	
	JCNewClass newClass = maker.NewClass(null, List.<JCExpression>nil(), selfType, args.toList(), null);
	JCExpression identityCheck = maker.Binary(CTC_EQUAL, createFieldAccessor(maker, field, FieldAccess.ALWAYS_FIELD), maker.Ident(fieldDecl.name));
	JCConditional conditional = maker.Conditional(identityCheck, maker.Ident(field.toName("this")), newClass);
	JCReturn returnStatement = maker.Return(conditional);
	
	if (nonNulls.isEmpty()) {
		statements.append(returnStatement);
	} else {
		JCStatement nullCheck = generateNullCheck(maker, field, source);
		if (nullCheck != null) statements.append(nullCheck);
		statements.append(returnStatement);
	}
	
	JCExpression returnType = cloneSelfType(field);
	
	JCBlock methodBody = maker.Block(0, statements.toList());
	List<JCTypeParameter> methodGenericParams = List.nil();
	List<JCVariableDecl> parameters = List.of(param);
	List<JCExpression> throwsClauses = List.nil();
	JCExpression annotationMethodDefaultValue = null;
	
	List<JCAnnotation> annsOnMethod = copyAnnotations(onMethod);
	
	if (isFieldDeprecated(field)) {
		annsOnMethod = annsOnMethod.prepend(maker.Annotation(genJavaLangTypeRef(field, "Deprecated"), List.<JCExpression>nil()));
	}
	JCMethodDecl decl = recursiveSetGeneratedBy(maker.MethodDef(maker.Modifiers(access, annsOnMethod), methodName, returnType,
			methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source.get(), field.getContext());
	copyJavadoc(field, decl, CopyJavadoc.WITHER);
	return decl;
}
 
开发者ID:mobmead,项目名称:EasyMPermission,代码行数:69,代码来源:HandleWither.java



注:本文中的com.sun.tools.javac.tree.JCTree.JCConditional类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JLabeledTextField类代码示例发布时间:2022-05-22
下一篇:
Java TestBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap