当前位置: 首页>>代码示例>>Java>>正文


Java PrefixExpression.setOperand方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.PrefixExpression.setOperand方法的典型用法代码示例。如果您正苦于以下问题:Java PrefixExpression.setOperand方法的具体用法?Java PrefixExpression.setOperand怎么用?Java PrefixExpression.setOperand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.dom.PrefixExpression的用法示例。


在下文中一共展示了PrefixExpression.setOperand方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createOuterComparison

import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
private Statement createOuterComparison() {
	MethodInvocation outer1= fAst.newMethodInvocation();
	outer1.setName(fAst.newSimpleName(METHODNAME_OUTER_TYPE));

	MethodInvocation outer2= fAst.newMethodInvocation();
	outer2.setName(fAst.newSimpleName(METHODNAME_OUTER_TYPE));
	outer2.setExpression(fAst.newSimpleName(VARIABLE_NAME_EQUALS_CASTED));

	MethodInvocation outerEql= fAst.newMethodInvocation();
	outerEql.setName(fAst.newSimpleName(METHODNAME_EQUALS));
	outerEql.setExpression(outer1);
	outerEql.arguments().add(outer2);

	PrefixExpression not= fAst.newPrefixExpression();
	not.setOperand(outerEql);
	not.setOperator(PrefixExpression.Operator.NOT);

	IfStatement notEqNull= fAst.newIfStatement();
	notEqNull.setExpression(not);
	notEqNull.setThenStatement(getThenStatement(getReturnFalse()));
	return notEqNull;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:GenerateHashCodeEqualsOperation.java

示例2: createArrayComparison

import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
private Statement createArrayComparison(String name) {
	MethodInvocation invoc= fAst.newMethodInvocation();
	invoc.setName(fAst.newSimpleName(METHODNAME_EQUALS));
	invoc.setExpression(getQualifiedName(JAVA_UTIL_ARRAYS));
	invoc.arguments().add(getThisAccessForEquals(name));
	invoc.arguments().add(getOtherAccess(name));

	PrefixExpression pe= fAst.newPrefixExpression();
	pe.setOperator(PrefixExpression.Operator.NOT);
	pe.setOperand(invoc);

	IfStatement ifSt= fAst.newIfStatement();
	ifSt.setExpression(pe);
	ifSt.setThenStatement(getThenStatement(getReturnFalse()));

	return ifSt;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:GenerateHashCodeEqualsOperation.java

示例3: createMultiArrayComparison

import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
private Statement createMultiArrayComparison(String name) {
	MethodInvocation invoc= fAst.newMethodInvocation();
	invoc.setName(fAst.newSimpleName(METHODNAME_DEEP_EQUALS));
	invoc.setExpression(getQualifiedName(JAVA_UTIL_ARRAYS));
	invoc.arguments().add(getThisAccessForEquals(name));
	invoc.arguments().add(getOtherAccess(name));

	PrefixExpression pe= fAst.newPrefixExpression();
	pe.setOperator(PrefixExpression.Operator.NOT);
	pe.setOperand(invoc);

	IfStatement ifSt= fAst.newIfStatement();
	ifSt.setExpression(pe);
	ifSt.setThenStatement(getThenStatement(getReturnFalse()));

	return ifSt;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:GenerateHashCodeEqualsOperation.java

示例4: makeFixedExpression

import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Expression makeFixedExpression(ASTRewrite rewrite, IsNANVisitor visitor) {
    AST ast = rewrite.getAST();
    MethodInvocation fixedMethod = ast.newMethodInvocation();
    fixedMethod.setName(ast.newSimpleName("isNaN"));

    if (visitor.isPrimitive) {
        // make a reference to Double or Float
        SimpleName staticType = ast.newSimpleName(doubleOrFloat(visitor.isDouble));
        fixedMethod.setExpression(staticType);
        fixedMethod.arguments().add(rewrite.createMoveTarget(visitor.testedVariable));
    } else {
        // call isNaN directly on the boxed variable
        fixedMethod.setExpression((Expression) rewrite.createMoveTarget(visitor.testedVariable));
    }

    if (!visitor.isEquals) {
        PrefixExpression not = ast.newPrefixExpression();
        not.setOperator(PrefixExpression.Operator.NOT);
        not.setOperand(fixedMethod);
        return not;
    }

    return fixedMethod;
}
 
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:26,代码来源:IsNANResolution.java

示例5: makeCallToIsEmpty

import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
private Expression makeCallToIsEmpty(ASTRewrite rewrite, ResolutionBundle bundle) {

        AST ast = rewrite.getAST();
        MethodInvocation callToEmpty = ast.newMethodInvocation();
        callToEmpty.setName(ast.newSimpleName("isEmpty"));
        callToEmpty.setExpression((Expression) rewrite.createCopyTarget(bundle.collectionToFix));

        if (bundle.wasNegated) {
            PrefixExpression negatedExpression = ast.newPrefixExpression();
            negatedExpression.setOperator(PrefixExpression.Operator.NOT);
            negatedExpression.setOperand(callToEmpty);
            return negatedExpression;
        }

        return callToEmpty;
    }
 
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:17,代码来源:IsEmptyResolution.java

示例6: getInversedNotExpression

import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
private static Expression getInversedNotExpression(ASTRewrite rewrite, Expression expression, AST ast) {
	PrefixExpression prefixExpression= ast.newPrefixExpression();
	prefixExpression.setOperator(PrefixExpression.Operator.NOT);
	ParenthesizedExpression parenthesizedExpression= getParenthesizedExpression(ast, (Expression)rewrite.createCopyTarget(expression));
	prefixExpression.setOperand(parenthesizedExpression);
	return prefixExpression;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:AdvancedQuickAssistProcessor.java

示例7: getPullNegationUpProposals

import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
private static boolean getPullNegationUpProposals(IInvocationContext context, ArrayList<ASTNode> coveredNodes, Collection<ICommandAccess> resultingCollections) {
	if (coveredNodes.size() != 1) {
		return false;
	}
	//
	ASTNode fullyCoveredNode= coveredNodes.get(0);

	Expression expression= getBooleanExpression(fullyCoveredNode);
	if (expression == null || (!(expression instanceof InfixExpression) && !(expression instanceof ConditionalExpression))) {
		return false;
	}
	//  we could produce quick assist
	if (resultingCollections == null) {
		return true;
	}
	//
	AST ast= expression.getAST();
	final ASTRewrite rewrite= ASTRewrite.create(ast);
	// prepared inverted expression
	Expression inversedExpression= getInversedExpression(rewrite, expression);
	// prepare ParenthesizedExpression
	ParenthesizedExpression parenthesizedExpression= ast.newParenthesizedExpression();
	parenthesizedExpression.setExpression(inversedExpression);
	// prepare NOT prefix expression
	PrefixExpression prefixExpression= ast.newPrefixExpression();
	prefixExpression.setOperator(PrefixExpression.Operator.NOT);
	prefixExpression.setOperand(parenthesizedExpression);
	// replace old expression
	rewrite.replace(expression, prefixExpression, null);
	// add correction proposal
	String label= CorrectionMessages.AdvancedQuickAssistProcessor_pullNegationUp;
	Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
	ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.PULL_NEGATION_UP, image);
	resultingCollections.add(proposal);
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:37,代码来源:AdvancedQuickAssistProcessor.java

示例8: getPullNegationUpProposals

import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
private static boolean getPullNegationUpProposals(IInvocationContext context, ArrayList<ASTNode> coveredNodes, Collection<ICommandAccess> resultingCollections) {
	if (coveredNodes.size() != 1) {
		return false;
	}
	//
	ASTNode fullyCoveredNode= coveredNodes.get(0);

	Expression expression= getBooleanExpression(fullyCoveredNode);
	if (expression == null || (!(expression instanceof InfixExpression) && !(expression instanceof ConditionalExpression))) {
		return false;
	}
	//  we could produce quick assist
	if (resultingCollections == null) {
		return true;
	}
	//
	AST ast= expression.getAST();
	final ASTRewrite rewrite= ASTRewrite.create(ast);
	// prepared inverted expression
	Expression inversedExpression= getInversedExpression(rewrite, expression);
	// prepare ParenthesizedExpression
	ParenthesizedExpression parenthesizedExpression= ast.newParenthesizedExpression();
	parenthesizedExpression.setExpression(inversedExpression);
	// prepare NOT prefix expression
	PrefixExpression prefixExpression= ast.newPrefixExpression();
	prefixExpression.setOperator(PrefixExpression.Operator.NOT);
	prefixExpression.setOperand(parenthesizedExpression);
	// replace old expression
	rewrite.replace(expression, prefixExpression, null);
	// add correction proposal
	String label= CorrectionMessages.AdvancedQuickAssistProcessor_pullNegationUp;
	Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
	ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 1, image);
	resultingCollections.add(proposal);
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:37,代码来源:AdvancedQuickAssistProcessor.java

示例9: makeIfExpression

import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
private Expression makeIfExpression(ASTRewrite rewrite, ReturnValueResolutionVisitor rvrFinder, boolean isNegated) {
    if (isNegated)
    {
        AST rootNode = rewrite.getAST();
        PrefixExpression negation = rootNode.newPrefixExpression();
        negation.setOperator(PrefixExpression.Operator.NOT);
        negation.setOperand((Expression) rewrite.createMoveTarget(rvrFinder.badMethodInvocation));
        return negation;
    }
    return (Expression) rewrite.createMoveTarget(rvrFinder.badMethodInvocation);
}
 
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:12,代码来源:ReturnValueIgnoreResolution.java

示例10: createQualifiedComparison

import org.eclipse.jdt.core.dom.PrefixExpression; //导入方法依赖的package包/类
/**
 * Creates a comparison of reference types.
 *
 * <pre>
 * if (this.a == null) {
 * 	if (other.a != null)
 * 		return false;
 * } else {
 * 	if (!this.a.equals(other.a))
 * 		return false;
 * }
 * </pre>
 * @param name the field name
 * @return the comparison statement
 */
private Statement createQualifiedComparison(String name) {
	InfixExpression newCondition= fAst.newInfixExpression();
	newCondition.setOperator(Operator.EQUALS);
	newCondition.setLeftOperand(getThisAccessForEquals(name));
	newCondition.setRightOperand(fAst.newNullLiteral());

	// THEN
	InfixExpression notEqNull= fAst.newInfixExpression();
	notEqNull.setOperator(Operator.NOT_EQUALS);
	notEqNull.setLeftOperand(getOtherAccess(name));
	notEqNull.setRightOperand(fAst.newNullLiteral());

	IfStatement thenPart= fAst.newIfStatement();
	thenPart.setExpression(notEqNull);
	thenPart.setThenStatement(getThenStatement(getReturnFalse()));

	Block thenPart2= fAst.newBlock();
	thenPart2.statements().add(thenPart);

	// ELSE
	MethodInvocation invoc= fAst.newMethodInvocation();
	invoc.setName(fAst.newSimpleName(METHODNAME_EQUALS));
	invoc.setExpression(getThisAccessForEquals(name));
	invoc.arguments().add(getOtherAccess(name));

	PrefixExpression pe= fAst.newPrefixExpression();
	pe.setOperator(PrefixExpression.Operator.NOT);
	pe.setOperand(invoc);

	IfStatement elsePart= fAst.newIfStatement();
	elsePart.setExpression(pe);
	elsePart.setThenStatement(getThenStatement(getReturnFalse()));

	// ALL
	IfStatement isNull= fAst.newIfStatement();
	isNull.setExpression(newCondition);
	isNull.setThenStatement(thenPart2);
	isNull.setElseStatement(elsePart);

	return isNull;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:57,代码来源:GenerateHashCodeEqualsOperation.java


注:本文中的org.eclipse.jdt.core.dom.PrefixExpression.setOperand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。