本文整理匯總了Java中org.eclipse.jdt.core.dom.MethodInvocation.ARGUMENTS_PROPERTY屬性的典型用法代碼示例。如果您正苦於以下問題:Java MethodInvocation.ARGUMENTS_PROPERTY屬性的具體用法?Java MethodInvocation.ARGUMENTS_PROPERTY怎麽用?Java MethodInvocation.ARGUMENTS_PROPERTY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.eclipse.jdt.core.dom.MethodInvocation
的用法示例。
在下文中一共展示了MethodInvocation.ARGUMENTS_PROPERTY屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getArgumentsProperty
public static ChildListPropertyDescriptor getArgumentsProperty(ASTNode invocation) {
switch (invocation.getNodeType()) {
case ASTNode.METHOD_INVOCATION:
return MethodInvocation.ARGUMENTS_PROPERTY;
case ASTNode.SUPER_METHOD_INVOCATION:
return SuperMethodInvocation.ARGUMENTS_PROPERTY;
case ASTNode.CONSTRUCTOR_INVOCATION:
return ConstructorInvocation.ARGUMENTS_PROPERTY;
case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
return SuperConstructorInvocation.ARGUMENTS_PROPERTY;
case ASTNode.CLASS_INSTANCE_CREATION:
return ClassInstanceCreation.ARGUMENTS_PROPERTY;
case ASTNode.ENUM_CONSTANT_DECLARATION:
return EnumConstantDeclaration.ARGUMENTS_PROPERTY;
default:
throw new IllegalArgumentException(invocation.toString());
}
}
示例2: needsExplicitCast
/**
* @param status the status
* @return <code>true</code> if explicit cast is needed otherwise <code>false</code>
*/
private boolean needsExplicitCast(RefactoringStatus status) {
// if the return type of the method is the same as the type of the
// returned expression then we don't need an explicit cast.
if (fSourceProvider.returnTypeMatchesReturnExpressions()) return false;
List<Expression> returnExprs = fSourceProvider.getReturnExpressions();
// it is inferred that only methods consisting of a single
// return statement can be inlined as parameters in other
// method invocations
if (returnExprs.size() != 1) return false;
if (fTargetNode.getLocationInParent() == MethodInvocation.ARGUMENTS_PROPERTY) {
MethodInvocation methodInvocation = (MethodInvocation) fTargetNode.getParent();
if (methodInvocation.getExpression() == fTargetNode) return false;
IMethodBinding method = methodInvocation.resolveMethodBinding();
if (method == null) {
status.addError(
RefactoringCoreMessages.CallInliner_cast_analysis_error,
JavaStatusContext.create(fCUnit, methodInvocation));
return false;
}
ITypeBinding[] parameters = method.getParameterTypes();
int argumentIndex = methodInvocation.arguments().indexOf(fInvocation);
ITypeBinding parameterType = returnExprs.get(0).resolveTypeBinding();
if (method.isVarargs() && argumentIndex >= parameters.length - 1) {
argumentIndex = parameters.length - 1;
parameterType = parameterType.createArrayType(1);
}
parameters[argumentIndex] = parameterType;
ITypeBinding type = ASTNodes.getReceiverTypeBinding(methodInvocation);
TypeBindingVisitor visitor =
new AmbiguousMethodAnalyzer(
fTypeEnvironment, method, fTypeEnvironment.create(parameters));
if (!visitor.visit(type)) {
return true;
} else if (type.isInterface()) {
return !Bindings.visitInterfaces(type, visitor);
} else if (Modifier.isAbstract(type.getModifiers())) {
return !Bindings.visitHierarchy(type, visitor);
} else {
// it is not needed to visit interfaces if receiver is a concrete class
return !Bindings.visitSuperclasses(type, visitor);
}
} else {
ITypeBinding explicitCast =
ASTNodes.getExplicitCast(returnExprs.get(0), (Expression) fTargetNode);
return explicitCast != null;
}
}
示例3: isMethodArgument
private static boolean isMethodArgument(Expression expression) {
ASTNode parent = expression;
while (parent instanceof Expression) {
if (parent.getLocationInParent() == MethodInvocation.ARGUMENTS_PROPERTY) return true;
if (parent.getLocationInParent() == ConstructorInvocation.ARGUMENTS_PROPERTY) return true;
parent = ((Expression) parent).getParent();
}
return false;
}