當前位置: 首頁>>代碼示例>>Java>>正文


Java MethodInvocation.arguments方法代碼示例

本文整理匯總了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");
}
 
開發者ID:opaluchlukasz,項目名稱:junit2spock,代碼行數:18,代碼來源:MockitoThrowFeature.java

示例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;
}
 
開發者ID:qhanam,項目名稱:Slicer,代碼行數:26,代碼來源:BDDVisitor.java

示例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");
}
 
開發者ID:opaluchlukasz,項目名稱:junit2spock,代碼行數:12,代碼來源:AssertTrueFeature.java

示例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");
}
 
開發者ID:opaluchlukasz,項目名稱:junit2spock,代碼行數:16,代碼來源:AssertEqualsFeature.java

示例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");
}
 
開發者ID:opaluchlukasz,項目名稱:junit2spock,代碼行數:16,代碼來源:AssertNullFeature.java

示例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");
}
 
開發者ID:opaluchlukasz,項目名稱:junit2spock,代碼行數:16,代碼來源:AssertNotNullFeature.java

示例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");
}
 
開發者ID:opaluchlukasz,項目名稱:junit2spock,代碼行數:12,代碼來源:AssertFalseFeature.java

示例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))));
}
 
開發者ID:opaluchlukasz,項目名稱:junit2spock,代碼行數:8,代碼來源:MockitoVerifyNoMoreInteractionsFeature.java

示例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))));
}
 
開發者ID:opaluchlukasz,項目名稱:junit2spock,代碼行數:12,代碼來源:MockitoVerifyFeature.java

示例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;
}
 
開發者ID:andre-santos-pt,項目名稱:pandionj,代碼行數:14,代碼來源:VarParser.java

示例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;
}
 
開發者ID:petablox-project,項目名稱:petablox,代碼行數:17,代碼來源:PetabloxAdapterNew.java

示例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;
}
 
開發者ID:qhanam,項目名稱:Slicer,代碼行數:25,代碼來源:FDDSeedVisitor.java

示例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;
}
 
開發者ID:qhanam,項目名稱:Slicer,代碼行數:18,代碼來源:FDDVisitor.java

示例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()]);
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:76,代碼來源:ExtractMethodRefactoring.java

示例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;
			}
		}
	};
}
 
開發者ID:Ragnaroek,項目名稱:eclipse-astparser,代碼行數:50,代碼來源:Wait.java


注:本文中的org.eclipse.jdt.core.dom.MethodInvocation.arguments方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。