KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > refactoring > code > CallContext


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.corext.refactoring.code;
12
13 import org.eclipse.jdt.core.dom.ASTNode;
14 import org.eclipse.jdt.core.dom.Expression;
15 import org.eclipse.jdt.core.dom.IMethodBinding;
16 import org.eclipse.jdt.core.dom.ITypeBinding;
17 import org.eclipse.jdt.core.dom.rewrite.ImportRewrite;
18
19 import org.eclipse.jdt.internal.corext.dom.CodeScopeBuilder;
20
21 public class CallContext {
22
23     public ASTNode invocation;
24     public String JavaDoc[] arguments;
25     public String JavaDoc receiver;
26     public boolean receiverIsStatic;
27     public CodeScopeBuilder.Scope scope;
28     public int callMode;
29     public ImportRewrite importer;
30
31     public CallContext(ASTNode inv, CodeScopeBuilder.Scope s, int cm, ImportRewrite i) {
32         super();
33         invocation= inv;
34         scope= s;
35         callMode= cm;
36         importer= i;
37     }
38     
39     public ITypeBinding getReceiverType() {
40         Expression expression= Invocations.getExpression(invocation);
41         if (expression != null) {
42             return expression.resolveTypeBinding();
43         }
44         IMethodBinding method= Invocations.resolveBinding(invocation);
45         if (method != null) {
46             return method.getDeclaringClass();
47         }
48         return null;
49     }
50 }
51
Popular Tags