本文整理匯總了Java中org.eclipse.jdt.core.dom.MethodInvocation.getExpression方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodInvocation.getExpression方法的具體用法?Java MethodInvocation.getExpression怎麽用?Java MethodInvocation.getExpression使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.MethodInvocation
的用法示例。
在下文中一共展示了MethodInvocation.getExpression方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getNewCastTypeNode
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
private Type getNewCastTypeNode(ASTRewrite rewrite, ImportRewrite importRewrite) {
AST ast= rewrite.getAST();
ImportRewriteContext context= new ContextSensitiveImportRewriteContext((CompilationUnit) fNodeToCast.getRoot(), fNodeToCast.getStartPosition(), importRewrite);
if (fCastType != null) {
return importRewrite.addImport(fCastType, ast,context, TypeLocation.CAST);
}
ASTNode node= fNodeToCast;
ASTNode parent= node.getParent();
if (parent instanceof CastExpression) {
node= parent;
parent= parent.getParent();
}
while (parent instanceof ParenthesizedExpression) {
node= parent;
parent= parent.getParent();
}
if (parent instanceof MethodInvocation) {
MethodInvocation invocation= (MethodInvocation) node.getParent();
if (invocation.getExpression() == node) {
IBinding targetContext= ASTResolving.getParentMethodOrTypeBinding(node);
ITypeBinding[] bindings= ASTResolving.getQualifierGuess(node.getRoot(), invocation.getName().getIdentifier(), invocation.arguments(), targetContext);
if (bindings.length > 0) {
ITypeBinding first= getCastFavorite(bindings, fNodeToCast.resolveTypeBinding());
Type newTypeNode= importRewrite.addImport(first, ast, context, TypeLocation.CAST);
return newTypeNode;
}
}
}
Type newCastType= ast.newSimpleType(ast.newSimpleName("Object")); //$NON-NLS-1$
return newCastType;
}
示例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: getExpressionType
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
private ITypeBinding getExpressionType(MethodInvocation invocation) {
Expression expression = invocation.getExpression();
ITypeBinding typeBinding = null;
if (expression == null) {
typeBinding = invocation.resolveMethodBinding().getDeclaringClass();
} else {
typeBinding = expression.resolveTypeBinding();
}
if (typeBinding != null && typeBinding.isTypeVariable()) {
ITypeBinding[] typeBounds = typeBinding.getTypeBounds();
if (typeBounds.length > 0) {
for (ITypeBinding typeBound : typeBounds) {
ITypeBinding expressionType = getExpressionType(invocation, typeBound);
if (expressionType != null) {
return expressionType;
}
}
typeBinding = typeBounds[0].getTypeDeclaration();
} else {
typeBinding = invocation.getAST().resolveWellKnownType("java.lang.Object"); // $NON-NLS-1$
}
}
Assert.isNotNull(
typeBinding, "Type binding of target expression may not be null"); // $NON-NLS-1$
return typeBinding;
}
示例4: getReceiverTypeBinding
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
/**
* Returns the receiver's type binding of the given method invocation.
*
* @param invocation method invocation to resolve type of
* @return the type binding of the receiver
*/
public static ITypeBinding getReceiverTypeBinding(MethodInvocation invocation) {
ITypeBinding result= null;
Expression exp= invocation.getExpression();
if(exp != null) {
return exp.resolveTypeBinding();
}
else {
AbstractTypeDeclaration type= (AbstractTypeDeclaration)getParent(invocation, AbstractTypeDeclaration.class);
if (type != null) {
return type.resolveBinding();
}
}
return result;
}
示例5: visit
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
public boolean visit(MethodInvocation node) {
Expression receiver = node.getExpression();
if (receiver == null) {
SimpleName name = node.getName();
if (fIgnoreBinding == null || !Bindings.equals(fIgnoreBinding, name.resolveBinding())) {
node.getName().accept(this);
}
} else {
receiver.accept(this);
}
accept(node.arguments());
return false;
}
示例6: visit
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
public boolean visit(MethodInvocation node) {
Expression exp = node.getExpression();
if (exp != null) {
fIgnore.add(node.getName());
}
return true;
}
示例7: evaluateVariableType
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
private Type evaluateVariableType(AST ast, ImportRewrite imports, ImportRewriteContext importRewriteContext, IBinding targetContext, TypeLocation location) {
if (fOriginalNode.getParent() instanceof MethodInvocation) {
MethodInvocation parent= (MethodInvocation) fOriginalNode.getParent();
if (parent.getExpression() == fOriginalNode) {
// _x_.foo() -> guess qualifier type by looking for a type with method 'foo'
ITypeBinding[] bindings= ASTResolving.getQualifierGuess(fOriginalNode.getRoot(), parent.getName().getIdentifier(), parent.arguments(), targetContext);
if (bindings.length > 0) {
return imports.addImport(bindings[0], ast, importRewriteContext, location);
}
}
}
ITypeBinding binding= ASTResolving.guessBindingForReference(fOriginalNode);
if (binding != null) {
if (binding.isWildcardType()) {
binding= ASTResolving.normalizeWildcardType(binding, isVariableAssigned(), ast);
if (binding == null) {
// only null binding applies
binding= ast.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$
}
}
return imports.addImport(binding, ast, importRewriteContext, location);
}
// no binding, find type AST node instead -> ABC a= x-> use 'ABC' as is
Type type = ASTResolving.guessTypeForReference(ast, fOriginalNode);
if (type != null) {
return type;
}
if (fVariableKind == CONST_FIELD) {
return ast.newSimpleType(ast.newSimpleName("String")); //$NON-NLS-1$
}
return ast.newSimpleType(ast.newSimpleName("Object")); //$NON-NLS-1$
}
示例8: visit
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
public boolean visit(MethodInvocation methodInvocation) {
IMethodBinding methodBinding = methodInvocation.resolveMethodBinding();
if (methodBinding != null) {
IJavaElement javaElement = methodBinding.getJavaElement();
if (javaElement == null)
MigrateSkeletalImplementationToInterfaceRefactoringProcessor
.logWarning("Could not get Java element from binding: " + methodBinding + " while processing: "
+ methodInvocation);
else if (javaElement.equals(accessedMethod)) {
Expression expression = methodInvocation.getExpression();
expression = (Expression) Util.stripParenthesizedExpressions(expression);
// FIXME: It's not really that the expression is a `this`
// expression but that the type of the expression comes from
// a
// `this` expression. In other words, we may need to climb
// the
// AST.
if (expression == null || expression.getNodeType() == ASTNode.THIS_EXPRESSION)
this.encounteredThisReceiver = true;
}
}
return super.visit(methodInvocation);
}
開發者ID:ponder-lab,項目名稱:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代碼行數:28,代碼來源:MethodReceiverAnalysisVisitor.java
示例9: visit
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
public boolean visit(MethodInvocation node)
{
IMethodBinding mmtb = node.resolveMethodBinding();
if (this.mtbStack.isEmpty()) {
return true;
}
try
{
if (node.getExpression() != null) {
if (mmtb.getDeclaringClass().getQualifiedName().startsWith("java.awt.geom.Path2D"))
{
Expression e = node.getExpression();
ITypeBinding itb = e.resolveTypeBinding();
this.facts.add(Fact.makeCallsFact(getQualifiedName((IMethodBinding)this.mtbStack.peek()),
getQualifiedName(itb) + "#" + getSimpleName(mmtb)));
break label179;
}
}
this.facts.add(Fact.makeCallsFact(getQualifiedName((IMethodBinding)this.mtbStack.peek()),
getQualifiedName(mmtb)));
}
catch (Exception localException)
{
System.err.println("Cannot resolve method invocation \"" +
node.getName().toString() + "\"");
}
label179:
return true;
}
示例10: visit
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
public boolean visit(MethodInvocation node) {
Expression receiver = node.getExpression();
if (receiver == null) {
SimpleName name = node.getName();
if (fIgnoreBinding == null || !Bindings.equals(fIgnoreBinding, name.resolveBinding()))
node.getName().accept(this);
} else {
receiver.accept(this);
}
accept(node.arguments());
return false;
}
示例11: visit
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
public boolean visit(MethodInvocation node) {
IMethodBinding binding = node.resolveMethodBinding();
if (binding != null
&& !JdtFlags.isStatic(binding)
&& node.getExpression() == null
&& Bindings.isSuperType(binding.getDeclaringClass(), fFunctionalInterface, false))
throw new AbortSearchException();
return true;
}
示例12: visit
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public boolean visit(MethodInvocation node) {
if (!fFindUnqualifiedMethodAccesses && !fFindUnqualifiedStaticMethodAccesses) return true;
if (node.getExpression() != null) return true;
IBinding binding = node.getName().resolveBinding();
if (!(binding instanceof IMethodBinding)) return true;
handleMethod(node.getName(), (IMethodBinding) binding);
return true;
}
示例13: retrieveCalleeReference
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
private VariableReference retrieveCalleeReference(MethodInvocation methodInvocation) {
Expression expression = methodInvocation.getExpression();
if (expression != null) {
return retrieveVariableReference(expression, null);
}
throw new RuntimeException("Callee was null for expression: " + expression);
}
示例14: visit
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
public boolean visit(MethodInvocation invocation) {
if (invocation.getExpression() == null)
qualifyUnqualifiedMemberNameIfNecessary(invocation.getName());
else invocation.getExpression().accept(this);
for (Iterator<Expression> it = invocation.arguments().iterator(); it.hasNext(); )
it.next().accept(this);
return false;
}
示例15: visit
import org.eclipse.jdt.core.dom.MethodInvocation; //導入方法依賴的package包/類
@Override
public boolean visit(MethodInvocation node) {
if (node.getExpression() == null) {
visitName(node.getName());
} else {
fResult &=
new LoadTimeConstantChecker(
(IExpressionFragment)
ASTFragmentFactory.createFragmentForFullSubtree(node.getExpression()))
.check();
}
return false;
}