本文整理匯總了Java中org.eclipse.jdt.core.dom.MethodInvocation.arguments方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodInvocation.arguments方法的具體用法?Java MethodInvocation.arguments怎麽用?Java MethodInvocation.arguments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.MethodInvocation
的用法示例。
在下文中一共展示了MethodInvocation.arguments方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: apply
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
public Expression apply(Object object, MethodInvocation whenMethodInvocation) {
MethodInvocation methodInvocation = methodInvocation(object, thenThrow).get();
List arguments = methodInvocation.arguments();
if (arguments.size() == 1) {
MethodInvocation mockedMethodInvocation = (MethodInvocation) whenMethodInvocation.arguments().get(0);
Expression toBeThrown = argumentAsExpression(arguments.get(0));
Expression throwingClosure = groovyClosureBuilder.aClosure()
.withBodyStatement(nodeFactory.throwStatement(toBeThrown))
.build()
.asExpression();
return nodeFactory.infixExpression(RIGHT_SHIFT_SIGNED,
mockedMethodWithMatchers(mockedMethodInvocation),
throwingClosure);
}
throw new UnsupportedOperationException("Supported only 1-arity thenThrow invocation");
}
示例2: visit
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
/**
* If we are creating a conservative slice, we treat both
* objects on which we call methods as well as arguments
* for method calls as dependencies. This makes the
* assumption that the method will modify the caller
* and the arguments.
* @param node
* @return
*/
@Override
public boolean visit(MethodInvocation node){
if(this.options.contains(Slicer.Options.CONSERVATIVE)){
/* The expression part (eg. 'result.setFast(arg1, arg2)' expression = 'result' */
Expression expression = node.getExpression();
this.visitExpression(expression, new NoBindingsMethodVisitor(this.aliases));
if(this.result) return false;
/* The argument (eg. 'result.setFast(arg1, arg2)' arguments = {'arg1', 'arg2'}. */
List<Expression> arguments = node.arguments();
for(Expression argument : arguments){
this.visitExpression(argument, new NoBindingsAssignmentVisitor(this.aliases));
}
}
return false;
}
示例3: apply
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
public Expression apply(Object object, MethodInvocation methodInvocation) {
List arguments = methodInvocation.arguments();
if (arguments.size() == 1) {
return argumentAsExpression(arguments.get(0));
}
if (arguments.size() == 2) {
return argumentAsExpression(arguments.get(1));
}
throw new UnsupportedOperationException("Supported only 1-, 2-arity assertTrue invocation");
}
示例4: apply
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
public InfixExpression apply(Object object, MethodInvocation methodInvocation) {
List arguments = methodInvocation.arguments();
if (arguments.size() == 2) {
return astNodeFactory.infixExpression(EQUALS,
argumentAsExpression(arguments.get(1)),
argumentAsExpression(arguments.get(0)));
}
if (arguments.size() == 3) {
return astNodeFactory.infixExpression(EQUALS,
argumentAsExpression(arguments.get(2)),
argumentAsExpression(arguments.get(1)));
}
throw new UnsupportedOperationException("Supported only 2-, 3-arity assertEquals/assertArrayEquals invocation");
}
示例5: apply
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
public InfixExpression apply(Object object, MethodInvocation methodInvocation) {
List arguments = methodInvocation.arguments();
if (arguments.size() == 1) {
return astNodeFactory.infixExpression(EQUALS,
argumentAsExpression(arguments.get(0)),
astNodeFactory.nullLiteral());
}
if (arguments.size() == 2) {
return astNodeFactory.infixExpression(EQUALS,
argumentAsExpression(arguments.get(1)),
astNodeFactory.nullLiteral());
}
throw new UnsupportedOperationException("Supported only 1-, 2-arity assertNull invocation");
}
示例6: apply
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
public InfixExpression apply(Object object, MethodInvocation methodInvocation) {
List arguments = methodInvocation.arguments();
if (arguments.size() == 1) {
return astNodeFactory.infixExpression(NOT_EQUALS,
argumentAsExpression(arguments.get(0)),
astNodeFactory.nullLiteral());
}
if (arguments.size() == 2) {
return astNodeFactory.infixExpression(NOT_EQUALS,
argumentAsExpression(arguments.get(1)),
astNodeFactory.nullLiteral());
}
throw new UnsupportedOperationException("Supported only 1-, 2-arity assertNotNull invocation");
}
示例7: apply
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
public Expression apply(Object object, MethodInvocation methodInvocation) {
List arguments = methodInvocation.arguments();
if (arguments.size() == 1) {
return astNodeFactory.prefixExpression(NOT, argumentAsExpression(arguments.get(0)));
}
if (arguments.size() == 2) {
return astNodeFactory.prefixExpression(NOT, argumentAsExpression(arguments.get(1)));
}
throw new UnsupportedOperationException("Supported only 1-, 2-arity assertFalse invocation");
}
示例8: apply
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
public InfixExpression apply(Object object, MethodInvocation verifyMethodInvocation) {
List arguments = verifyMethodInvocation.arguments();
return nodeFactory.infixExpression(TIMES,
nodeFactory.numberLiteral("0"),
nodeFactory.fieldAccess("_", nodeFactory.clone((Expression) arguments.get(0))));
}
示例9: apply
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
public InfixExpression apply(Object object, MethodInvocation verifyMethodInvocation) {
List arguments = verifyMethodInvocation.arguments();
MethodInvocation parentMethodInvocation = (MethodInvocation) verifyMethodInvocation.getParent();
return nodeFactory.infixExpression(TIMES,
cardinality(arguments.size() == 2 ? Optional.of(arguments.get(1)) : empty()),
nodeFactory.methodInvocation(parentMethodInvocation.getName().getFullyQualifiedName(),
(List<Expression>) parentMethodInvocation.arguments().stream()
.map(matcherHandler::applyMatchers).collect(toList()),
nodeFactory.clone((Expression) arguments.get(0))));
}
示例10: visit
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
public boolean visit(MethodInvocation node) {
List<?> arguments = node.arguments();
for(int i = 0; i < arguments.size(); i++) {
Object arg = arguments.get(i);
if(arg instanceof SimpleName) {
VariableInfo varInfo = current.getVariable(arg.toString());
if(varInfo != null)
varInfo.addOperation(VariableOperation.Type.PARAM, node.getName().toString(), arguments.size(), i);
}
}
return true;
}
示例11: visit
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
public boolean visit(MethodInvocation mi) {
IMethodBinding callee = mi.resolveMethodBinding().getMethodDeclaration();
if(callee == null){
System.out.println("Could not resolve call site " + mi);
return true;
}
List args = mi.arguments();
if(!Modifier.isStatic(callee.getModifiers())){
Expression rcvr = mi.getExpression(); //rcvr can be null if it is implicit
args = new ArrayList(args);
args.add(0, rcvr);
}
int lineNum = cu.getLineNumber(mi.getStartPosition());
processInvkExpr(lineNum, mi.getName(), mi.toString(), callee, args, "invkexpr", "this");
return true;
}
示例12: visit
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
/**
* If we are creating a conservative slice, we treat both
* objects on which we call methods as well as arguments
* for method calls as dependencies. This makes the
* assumption that the method will modify the caller
* and the arguments.
* @param node
* @return
*/
@Override
public boolean visit(MethodInvocation node){
if(this.options.contains(Slicer.Options.CONSERVATIVE)){
/* The expression part (eg. 'result.setFast(arg1, arg2)' expression = 'result' */
Expression expression = node.getExpression();
this.visitExpression(expression, new NoBindingsMethodVisitor(this.seedVariables));
/* The argument (eg. 'result.setFast(arg1, arg2)' arguments = {'arg1', 'arg2'}. */
List<Expression> arguments = node.arguments();
for(Expression argument : arguments){
this.visitExpression(argument, new NoBindingsAssignmentVisitor(this.seedVariables));
}
}
return false;
}
示例13: visit
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
/**
* Since we don't get method parameters when we visit a SimpleName, we
* get them from the actual method invocation.
*
* We visit the argument expressions, but not the method call itself.
*/
public boolean visit(MethodInvocation node){
List<Expression> args = node.arguments();
for(Expression arg : args){
arg.accept(this);
}
if(node.getExpression() != null)
node.getExpression().accept(this);
return false;
}
示例14: createCallNodes
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
private ASTNode[] createCallNodes(SnippetFinder.Match duplicate, int modifiers) {
List<ASTNode> result = new ArrayList<>(2);
IVariableBinding[] locals = fAnalyzer.getCallerLocals();
for (int i = 0; i < locals.length; i++) {
result.add(createDeclaration(locals[i], null));
}
MethodInvocation invocation = fAST.newMethodInvocation();
invocation.setName(fAST.newSimpleName(fMethodName));
ASTNode typeNode = ASTResolving.findParentType(fAnalyzer.getEnclosingBodyDeclaration());
RefactoringStatus status = new RefactoringStatus();
while (fDestination != typeNode) {
fAnalyzer.checkInput(status, fMethodName, typeNode);
if (!status.isOK()) {
SimpleName destinationTypeName = fAST.newSimpleName(ASTNodes.getEnclosingType(fDestination).getName());
if ((modifiers & Modifier.STATIC) == 0) {
ThisExpression thisExpression = fAST.newThisExpression();
thisExpression.setQualifier(destinationTypeName);
invocation.setExpression(thisExpression);
} else {
invocation.setExpression(destinationTypeName);
}
break;
}
typeNode = typeNode.getParent();
}
List<Expression> arguments = invocation.arguments();
for (int i = 0; i < fParameterInfos.size(); i++) {
ParameterInfo parameter = fParameterInfos.get(i);
arguments.add(ASTNodeFactory.newName(fAST, getMappedName(duplicate, parameter)));
}
if (fLinkedProposalModel != null) {
LinkedProposalPositionGroup nameGroup = fLinkedProposalModel.getPositionGroup(KEY_NAME, true);
nameGroup.addPosition(fRewriter.track(invocation.getName()), false);
}
ASTNode call;
int returnKind = fAnalyzer.getReturnKind();
switch (returnKind) {
case ExtractMethodAnalyzer.ACCESS_TO_LOCAL:
IVariableBinding binding = fAnalyzer.getReturnLocal();
if (binding != null) {
VariableDeclarationStatement decl = createDeclaration(getMappedBinding(duplicate, binding), invocation);
call = decl;
} else {
Assignment assignment = fAST.newAssignment();
assignment.setLeftHandSide(ASTNodeFactory.newName(fAST, getMappedBinding(duplicate, fAnalyzer.getReturnValue()).getName()));
assignment.setRightHandSide(invocation);
call = assignment;
}
break;
case ExtractMethodAnalyzer.RETURN_STATEMENT_VALUE:
ReturnStatement rs = fAST.newReturnStatement();
rs.setExpression(invocation);
call = rs;
break;
default:
call = invocation;
}
if (call instanceof Expression && !fAnalyzer.isExpressionSelected()) {
call = fAST.newExpressionStatement((Expression) call);
}
result.add(call);
// We have a void return statement. The code looks like
// extracted();
// return;
if (returnKind == ExtractMethodAnalyzer.RETURN_STATEMENT_VOID && !fAnalyzer.isLastStatementSelected()) {
result.add(fAST.newReturnStatement());
}
return result.toArray(new ASTNode[result.size()]);
}
示例15: createResultVisitor
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
protected ResultVisitor createResultVisitor()
{
return new MethodInvocationResultVisitor("wait")
{
@Override
public void visitMethodInvocation(final MethodInvocation node) {
if( !checkWaitTimout(node) ) {
setMatch(false); //passt doch nicht, zuruecksetzen
setMatchedNode(null);
}
}
private boolean checkWaitTimout(final MethodInvocation invocation)
{
List<?> arguments = invocation.arguments();
if(fTimeout < 0) {
return arguments.size() == 0;
} else { //Timeout angegeben
if(arguments.size() == 1) { //genau 1 Argument fuer wait
Object o = arguments.get(0);
if(o instanceof NumberLiteral) {
NumberLiteral literal = (NumberLiteral)o;
try {
long time = Long.valueOf(literal.getToken());
if(!fAnyTimout) { //nicht irgendein timeout
return time == fTimeout; //nur true wenn genau das timeout angegeben wurde
} else { //irgendein timeout muss angegeben sein
//wenn Ausfuehrung hierhin kommt wurde ein long als Timeout angegeben
return true;
}
} catch (NumberFormatException e) {
e.printStackTrace();
return false;
}
} else { //kein NumberLiteral angegeben, z.B. Methodenaufruf oder new Long(1)...
if(fAnyTimout) { //irgendein timeout ist erfuellt
return true; //deshalb true zurueckgeben
} else { //ein genaues NumberLiteral Timeout jedoch nicht
return false; //deshalb false
}
}
}
return false;
}
}
};
}