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


Java PrefixExpression类代码示例

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


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

示例1: visit

import org.eclipse.jdt.core.dom.PrefixExpression; //导入依赖的package包/类
@Override
public boolean visit(PrefixExpression exp) {
	if(exp.getOperand() instanceof SimpleName) {
		String varName = exp.getOperand().toString(); 
		VariableOperation op = null;
		if(exp.getOperator() == PrefixExpression.Operator.INCREMENT)
			op = new VariableOperation(varName, VariableOperation.Type.INC);

		else if(exp.getOperator() == PrefixExpression.Operator.DECREMENT)
			op = new VariableOperation(varName, VariableOperation.Type.DEC);

		if(op != null)
			current.addOperation(op);
	}
	return true;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:17,代码来源:VarParser.java

示例2: analyze

import org.eclipse.jdt.core.dom.PrefixExpression; //导入依赖的package包/类
/**
 * @param expression
 */
public void analyze(Expression expression) {
    // param == null, null == param
    if (expression.getNodeType() == ASTNode.NULL_LITERAL) {
	setNullLiteral((NullLiteral) expression);
    } else if (expression.getNodeType() == ASTNode.SIMPLE_NAME) {
	setSimpleName((SimpleName) expression);
    } else if (expression.getNodeType() == ASTNode.NUMBER_LITERAL) {
	setNumberLiteral((NumberLiteral) expression);
    } else if (expression.getNodeType() == ASTNode.PREFIX_EXPRESSION) {
	setPrefixExpression((PrefixExpression) expression);
    } else if (expression.getNodeType() == ASTNode.POSTFIX_EXPRESSION) {
	setPostfixExpression((PostfixExpression) expression);
    } else if (expression.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION
	    || expression.getNodeType() == ASTNode.INFIX_EXPRESSION
	    || expression.getNodeType() == ASTNode.METHOD_INVOCATION) {
	// addTestCasesToMerge(processIfExpressions(expression,
	// tmlMethod));
    } else {
	// TODO
	System.out.println("Expression could not be analyzed: "
		+ expression.getNodeType() + ". Expression: "
		+ expression.toString());
    }
}
 
开发者ID:junit-tools-team,项目名称:junit-tools,代码行数:28,代码来源:TestCasesGenerator.java

示例3: getNumber

import org.eclipse.jdt.core.dom.PrefixExpression; //导入依赖的package包/类
protected String getNumber(PrefixExpression prefixExpression) {
String number = null;

Expression operand = prefixExpression.getOperand();
if (operand.getNodeType() == ASTNode.NUMBER_LITERAL) {
    org.eclipse.jdt.core.dom.PrefixExpression.Operator operator = prefixExpression
	    .getOperator();

    if (org.eclipse.jdt.core.dom.PrefixExpression.Operator.MINUS
	    .equals(operator)) {
	number = "-" + operand.toString();
    } else if (org.eclipse.jdt.core.dom.PrefixExpression.Operator.PLUS
	    .equals(operator)
	    || org.eclipse.jdt.core.dom.PrefixExpression.Operator.DECREMENT
		    .equals(operator)
	    || org.eclipse.jdt.core.dom.PrefixExpression.Operator.INCREMENT
		    .equals(operator)) {
	number = operand.toString();
    } else {
	number = "0";
    }

}

return number;
   }
 
开发者ID:junit-tools-team,项目名称:junit-tools,代码行数:27,代码来源:TestCasesGenerator.java

示例4: visit

import org.eclipse.jdt.core.dom.PrefixExpression; //导入依赖的package包/类
@Override
public boolean visit(PrefixExpression node) {
  Expression operand = node.getOperand();
  if (!considerBinding(resolveBinding(operand), operand)) return true;

  PrefixExpression.Operator operator = node.getOperator();
  if (operator != PrefixExpression.Operator.INCREMENT
      && operator != PrefixExpression.Operator.DECREMENT) return true;

  checkParent(node);

  fRewriter.replace(
      node,
      createInvocation(node.getAST(), node.getOperand(), node.getOperator().toString()),
      createGroupDescription(PREFIX_ACCESS));
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:AccessAnalyzer.java

示例5: visit

import org.eclipse.jdt.core.dom.PrefixExpression; //导入依赖的package包/类
@Override
public boolean visit(PrefixExpression prefixExpression) {
	if (prefixExpression.getOperand() == null)
		return true;
	if (! (prefixExpression.getOperand() instanceof SimpleName))
		return true;
	if (! prefixExpression.getOperator().equals(Operator.DECREMENT) &&
		! prefixExpression.getOperator().equals(Operator.INCREMENT))
		return true;
	SimpleName simpleName= (SimpleName)prefixExpression.getOperand();
	if (! isNameReferenceToTemp(simpleName))
		return true;

	fFirstAssignment= prefixExpression;
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:TempAssignmentFinder.java

示例6: isLeftValue

import org.eclipse.jdt.core.dom.PrefixExpression; //导入依赖的package包/类
private static boolean isLeftValue(ASTNode node) {
	ASTNode parent= node.getParent();
	if (parent instanceof Assignment) {
		Assignment assignment= (Assignment) parent;
		if (assignment.getLeftHandSide() == node)
			return true;
	}
	if (parent instanceof PostfixExpression)
		return true;
	if (parent instanceof PrefixExpression) {
		PrefixExpression.Operator op= ((PrefixExpression) parent).getOperator();
		if (op.equals(PrefixExpression.Operator.DECREMENT))
			return true;
		if (op.equals(PrefixExpression.Operator.INCREMENT))
			return true;
		return false;
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:ExtractTempRefactoring.java

示例7: visit

import org.eclipse.jdt.core.dom.PrefixExpression; //导入依赖的package包/类
@Override
public boolean visit(PrefixExpression node) {
	Expression operand= node.getOperand();
	if (!considerBinding(resolveBinding(operand), operand))
		return true;

	PrefixExpression.Operator operator= node.getOperator();
	if (operator != PrefixExpression.Operator.INCREMENT && operator != PrefixExpression.Operator.DECREMENT)
		return true;

	checkParent(node);

	fRewriter.replace(node,
		createInvocation(node.getAST(), node.getOperand(), node.getOperator().toString()),
		createGroupDescription(PREFIX_ACCESS));
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:AccessAnalyzer.java

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: handle

import org.eclipse.jdt.core.dom.PrefixExpression; //导入依赖的package包/类
@Override
public DSubTree handle() {
    DSubTree sub = new DOMExpression(expression.getOperand()).handle();
    if (expression.getOperator() == PrefixExpression.Operator.NOT && sub.getNodes().size() == 1) {
        // encode the ! predicate into the API call name
        DAPICall call = (DAPICall) sub.getNodes().get(0);
        call.setNotPredicate();
    }
    return sub;
}
 
开发者ID:capergroup,项目名称:bayou,代码行数:11,代码来源:DOMPrefixExpression.java

示例14: visit

import org.eclipse.jdt.core.dom.PrefixExpression; //导入依赖的package包/类
@Override
public boolean visit(PrefixExpression node) {
	Object operator= node.getOperator();
	if (operator == PrefixExpression.Operator.INCREMENT || operator == PrefixExpression.Operator.DECREMENT) {
		fSideEffectNodes.add(node);
		return false;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:10,代码来源:UnusedCodeFix.java

示例15: endVisit

import org.eclipse.jdt.core.dom.PrefixExpression; //导入依赖的package包/类
@Override
public void endVisit(PrefixExpression node) {
	PrefixExpression.Operator op = node.getOperator();
	if (PrefixExpression.Operator.INCREMENT.equals(op) || PrefixExpression.Operator.DECREMENT.equals(op)) {
		endVisitIncDecOperation(node, node.getOperand());
	} else {
		assignFlowInfo(node, node.getOperand());
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:10,代码来源:FlowAnalyzer.java


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