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

Java CtAssignment类代码示例

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

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



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

示例1: process

import spoon.reflect.code.CtAssignment; //导入依赖的package包/类
@Override
public void process(CtStatement ctStatement) {
    if (!(ctStatement instanceof CtLocalVariable<?>) && !(ctStatement instanceof CtAssignment<?, ?>))
        return;

    Class<?> localVariableClass = ((CtTypedElement<?>) ctStatement).getType().getActualClass();
    if (localVariableClass.equals(Integer.class) || localVariableClass.equals(int.class)) {
        if (ctStatement instanceof CtAssignment<?, ?>) {
            replaceInteger(((CtAssignment<?, ?>) ctStatement).getAssignment());
        } else {
            replaceInteger(((CtLocalVariable<?>) ctStatement).getDefaultExpression());
        }
    } else if (localVariableClass.equals(Double.class) || localVariableClass.equals(double.class)) {
        if (ctStatement instanceof CtAssignment<?, ?>) {
            replaceDouble(((CtAssignment<?, ?>) ctStatement).getAssignment());
        } else {
            replaceDouble(((CtLocalVariable<?>) ctStatement).getDefaultExpression());
        }
    } else if (localVariableClass.equals(Boolean.class) || localVariableClass.equals(boolean.class)) {
        if (ctStatement instanceof CtAssignment<?, ?>) {
            replaceBoolean(((CtAssignment<?, ?>) ctStatement).getAssignment());
        } else {
            replaceBoolean(((CtLocalVariable<?>) ctStatement).getDefaultExpression());
        }
    }
}
 
开发者ID:SpoonLabs,项目名称:nopol,代码行数:27,代码来源:LiteralReplacer.java


示例2: getAssignedField

import spoon.reflect.code.CtAssignment; //导入依赖的package包/类
/**
 * Get all assigned fields in this block
 */
public Set<CtVariable<?>> getAssignedField(BasicBlock block) {
	Set<CtVariable<?>> res = new HashSet<>();

	for (CtCodeElement line : block.getElements()) {

		if (line instanceof CtAssignment) {
			// CtAssignment<?,?> assignment = (CtAssignment<?,?>) line;
			CtExpression<?> leftPart = ((CtAssignment<?, ?>) line).getAssigned();
			if (leftPart instanceof CtFieldAccess) {
				CtField<?> field = ((CtFieldAccess<?>) leftPart).getVariable().getDeclaration();
				res.add(field);
			}
		}

	}

	return res;
}
 
开发者ID:diverse-project,项目名称:InspectorGuidget,代码行数:22,代码来源:DefUse.java


示例3: findFieldSetters

import spoon.reflect.code.CtAssignment; //导入依赖的package包/类
/**
 * Find field assignment statements
 */
private Set<CtCodeElement> findFieldSetters() { // TODO: refactor with
												// Defuse.getAssignedField()

	Set<CtCodeElement> res = new HashSet<>();

	for (BasicBlock block : cfg.getAllNode()) {
		for (CtCodeElement line : block.getElements()) {
			if (line instanceof CtAssignment) {
				CtAssignment<?, ?> assignment = (CtAssignment<?, ?>) line;
				if (assignment.getAssigned() instanceof CtFieldAccess) {
					res.add(line);
				}
			}
		}
	}

	return res;
}
 
开发者ID:diverse-project,项目名称:InspectorGuidget,代码行数:22,代码来源:MethodSummary.java


示例4: process

import spoon.reflect.code.CtAssignment; //导入依赖的package包/类
@Override
public void process(CtStatement element) {

	if (element instanceof CtIf) {
		add(((CtIf) element).getCondition());
	} else if (element instanceof CtFor) {
		add(((CtFor) element).getExpression());
	} else if (element instanceof CtWhile) {
		add(((CtWhile) element).getLoopingExpression());
	} else if (element instanceof CtDo) {
		add(((CtDo) element).getLoopingExpression());
	} else if (element instanceof CtThrow) {
		add(((CtThrow) element).getThrownExpression());
	} else if (element instanceof CtInvocation && (element.getParent() instanceof CtBlock)) {
		add(element);
	} else if (element instanceof CtAssignment || element instanceof CtConstructorCall
			|| element instanceof CtCFlowBreak || element instanceof CtLocalVariable) {
		add(element);
	}

}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:22,代码来源:SpecialStatementFixSpaceProcessor.java


示例5: LiteralReplacer

import spoon.reflect.code.CtAssignment; //导入依赖的package包/类
public LiteralReplacer(Class<?> cl, CtStatement statement, StatementType statementType) {
    super(statement, statementType);
    if (statement instanceof CtAssignment<?, ?>) {
        super.setDefaultValue(((CtAssignment<?, ?>) statement).getAssignment().toString());
    } else if (statement instanceof CtLocalVariable<?>) {
        super.setDefaultValue(((CtLocalVariable<?>) statement).getDefaultExpression().toString());
    }
    super.setType(cl);
}
 
开发者ID:SpoonLabs,项目名称:nopol,代码行数:10,代码来源:LiteralReplacer.java


示例6: isControlledBy

import spoon.reflect.code.CtAssignment; //导入依赖的package包/类
/**
 * Must return true if the field is used in @action's conditionals and not
 * defined in the @action's method
 */
public boolean isControlledBy(Action action, CtAssignment<?, ?> fieldAssignment) {// TODO:
																					// move
																					// to
																					// Action

	CtField<?> field = null;
	CtExpression<?> leftPart = fieldAssignment.getAssigned();
	if (leftPart instanceof CtFieldAccess) {
		field = ((CtFieldAccess<?>) leftPart).getVariable().getDeclaration();
	}

	for (CtExpression<?> cond : action.getConditions()) {
		List<CtVariableAccess<?>> usedVars = defuse.findUsedVar(cond);
		for (CtVariableAccess<?> usedVar : usedVars) {

			// if(field != null && field ==
			// usedVar.getVariable().getDeclaration()){
			// Set<CtCodeElement> lastDef = defuse.getReachingDef(usedVar);
			// if(lastDef == null) return true;
			// }

			Set<CtVariable<?>> allDep = defuse.getDeepDef(usedVar);
			if (field != null && allDep.contains(field))
				return true;
		}
	}

	return false;
}
 
开发者ID:diverse-project,项目名称:InspectorGuidget,代码行数:34,代码来源:MethodSummary.java


示例7: elementUsesGUIParam

import spoon.reflect.code.CtAssignment; //导入依赖的package包/类
public static boolean elementUsesGUIParam(final CtElement elt, final List<CtParameterReference<?>> guiParams, final CtBlock<?> mainBlock,
										final Set<CtElement> alreadyVisited) {
		if(alreadyVisited.contains(elt)) {
			return false;
		}

		// Check whether a GUI parameter is directly used in the statement.
		//FIXME 5.5
//		if(guiParams.stream().anyMatch(param -> elt.getElements(new BasicFilter<>(CtParameterReference.class)).stream().noneMatch(ref -> ref.equals(param)))){
		if(guiParams.stream().anyMatch(param -> !elt.getReferences(new DirectReferenceFilter<>(param)).isEmpty())) {
			return true;
		}

		alreadyVisited.add(elt);

		// Otherwise, looking for local variables that use a GUI parameter.
		return elt.getElements(new LocalVariableAccessFilter()).stream().
			anyMatch(var ->
				// Maybe the declaration of the variable refers to a GUI parameter
				elementUsesGUIParam(var.getDeclaration(), guiParams, mainBlock, alreadyVisited) ||
					// or an assignment of this variable in the main block refers to a GUI parameter
					// 1. Looking for the assignments in the block
					mainBlock.getElements(new BasicFilter<>(CtAssignment.class)).stream().
						// 2. Keeping only the variable write
						anyMatch(assig -> assig.getAssigned() instanceof CtVariableWrite<?> &&
						// 3. Checking that the assigned variable is our current variable
						((CtVariableWrite<?>)assig.getAssigned()).getVariable().equals(var) &&
							// 4. Checking that the assignment directly or indirectly refers to GUI parameter
							elementUsesGUIParam(assig.getAssignment(), guiParams, mainBlock, alreadyVisited)));
	}
 
开发者ID:diverse-project,项目名称:InspectorGuidget,代码行数:31,代码来源:CommandAnalyser.java


示例8: query

import spoon.reflect.code.CtAssignment; //导入依赖的package包/类
@Override
public Transformation query() throws QueryException {
    ASTDelete delete = new ASTDelete();
    CtAssignment stmt = affectations.remove(random.nextInt(affectations.size()));
    delete.setTransplantationPoint(new Statement(stmt));

    return delete;
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:9,代码来源:DeleteAffectationQuery.java


示例9: process

import spoon.reflect.code.CtAssignment; //导入依赖的package包/类
@Override
public void process(CtExpression element) {

	if (element instanceof CtAssignment || element instanceof CtNewArray || element instanceof CtTypeAccess
			|| element instanceof CtVariableAccess || element instanceof CtLiteral)
		return;
	if (element.getType() != null)
		this.add(element);

}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:ExpressionIngredientSpaceProcessor.java


示例10: VariableAssignmentFilter

import spoon.reflect.code.CtAssignment; //导入依赖的package包/类
public VariableAssignmentFilter(CtVariable<?> variable) {
    super(CtAssignment.class);
    this.variable = variable;
}
 
开发者ID:SpoonLabs,项目名称:nopol,代码行数:5,代码来源:VariableAssignmentFilter.java


示例11: matches

import spoon.reflect.code.CtAssignment; //导入依赖的package包/类
@Override
public boolean matches(CtAssignment<?, ?> element) {
    return element.getAssigned().getShortRepresentation().equals(variable().getShortRepresentation());
}
 
开发者ID:SpoonLabs,项目名称:nopol,代码行数:5,代码来源:VariableAssignmentFilter.java


示例12: reassignDefault

import spoon.reflect.code.CtAssignment; //导入依赖的package包/类
public static <T> CtAssignment<T, T> reassignDefault(CtField<T> field) {
    Factory f = field.getFactory();
    return f.Code().createVariableAssignment(
            field.getReference(), false, f.Core().clone(field.getDefaultExpression()));
}
 
开发者ID:OpenHFT,项目名称:Stage-Compiler,代码行数:6,代码来源:SpoonUtils.java


示例13: containsWriteLocalVarsOnly

import spoon.reflect.code.CtAssignment; //导入依赖的package包/类
public <T extends CtElement> boolean containsWriteLocalVarsOnly(@Nullable List<T> stats) {
	return stats != null && stats.parallelStream().allMatch(s ->
		SpoonHelper.INSTANCE.isReturnBreakStatement(s) ||
		s instanceof CtAssignment && ((CtAssignment<?, ?>) s).getAssigned() instanceof CtVariableWrite ||
		s instanceof CtUnaryOperator && ((CtUnaryOperator<?>) s).getOperand() instanceof CtVariableWrite);
}
 
开发者ID:diverse-project,项目名称:InspectorGuidget,代码行数:7,代码来源:SpoonHelper.java


示例14: DeleteAffectationQuery

import spoon.reflect.code.CtAssignment; //导入依赖的package包/类
public DeleteAffectationQuery(InputProgram inputProgram) {
    super(inputProgram);
    affectations = inputProgram.getAllElement(CtAssignment.class);
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:5,代码来源:DeleteAffectationQuery.java


示例15: visitCtAssignment

import spoon.reflect.code.CtAssignment; //导入依赖的package包/类
@Override
public <T, A extends T> void visitCtAssignment(CtAssignment<T, A> e) {
	label = "=";
}
 
开发者ID:SpoonLabs,项目名称:gumtree-spoon-ast-diff,代码行数:5,代码来源:LabelFinder.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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