本文整理汇总了Java中org.eclipse.jdt.core.dom.FieldAccess.resolveFieldBinding方法的典型用法代码示例。如果您正苦于以下问题:Java FieldAccess.resolveFieldBinding方法的具体用法?Java FieldAccess.resolveFieldBinding怎么用?Java FieldAccess.resolveFieldBinding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.FieldAccess
的用法示例。
在下文中一共展示了FieldAccess.resolveFieldBinding方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLeftHandSideVarBinding
import org.eclipse.jdt.core.dom.FieldAccess; //导入方法依赖的package包/类
/**
* for an assignment x = y returns the variable binding of x
*
* @param varBinding
* @param assignment
* @return
*/
private static IVariableBinding getLeftHandSideVarBinding(Assignment assignment) {
Expression leftHnsd = assignment.getLeftHandSide();
if (leftHnsd instanceof SimpleName) {
IBinding bind = ((SimpleName) leftHnsd).resolveBinding();
if (bind instanceof IVariableBinding) {
return ((IVariableBinding) bind).getVariableDeclaration();
}
}
if (leftHnsd instanceof FieldAccess) {
FieldAccess fa = (FieldAccess) leftHnsd;
return fa.resolveFieldBinding();
}
// Leave it null - cannot determine actual domains for arrays
// workaround for bugs related to objects created in complex expression
// if (leftHnsd instanceof ArrayAccess) {
// ArrayAccess aa = (ArrayAccess) leftHnsd;
// return getArrayAccessVarBinding(aa);
// }
return null;
}
示例2: visit
import org.eclipse.jdt.core.dom.FieldAccess; //导入方法依赖的package包/类
/**
* Add the variable to the node aliases.
*/
public boolean visit(FieldAccess node){
/* All we really need from this is the variable binding. */
IBinding binding = node.resolveFieldBinding();
if(binding == null){
if(this.aliases.contains(node.getName().toString())){
this.result = true;
return false;
}
}
else if(binding instanceof IVariableBinding){
if(this.aliases.contains(binding.getKey())){
this.result = true;
return false;
}
}
return true;
}
示例3: visit
import org.eclipse.jdt.core.dom.FieldAccess; //导入方法依赖的package包/类
/**
* Add the variable to the node aliases.
*/
public boolean visit(FieldAccess node){
/* All we really need from this is the variable binding. */
IBinding binding = node.resolveFieldBinding();
if(binding == null){
if(!seedVariables.contains(node.getName().toString()))
seedVariables.add(node.getName().toString());
}
else if(binding instanceof IVariableBinding){
if(!seedVariables.contains(binding.getKey()))
seedVariables.add(binding.getKey());
}
return false;
}
示例4: visit
import org.eclipse.jdt.core.dom.FieldAccess; //导入方法依赖的package包/类
@Override
public boolean visit(FieldAccess node) {
IBinding binding= node.resolveFieldBinding();
if (isSourceAccess(binding)) {
if (isMovedMember(binding)) {
if (node.getExpression() != null)
rewrite(node, fTarget);
} else
rewrite(node, fSource);
} else if (isTargetAccess(binding)) {
fCuRewrite.getASTRewrite().remove(node.getExpression(), null);
fCuRewrite.getImportRemover().registerRemovedNode(node.getExpression());
}
return super.visit(node);
}
示例5: visit
import org.eclipse.jdt.core.dom.FieldAccess; //导入方法依赖的package包/类
@Override
public final boolean visit(FieldAccess node) {
IVariableBinding fieldBinding = node.resolveFieldBinding();
if (fieldBinding != null) {
handleTypeBinding(node, fieldBinding.getDeclaringClass(), false);
handleFieldBinding(node, fieldBinding);
}
return true;
}
示例6: visit
import org.eclipse.jdt.core.dom.FieldAccess; //导入方法依赖的package包/类
public boolean visit(FieldAccess node)
{
IVariableBinding ivb = node.resolveFieldBinding();
if (this.mtbStack.isEmpty()) {
return true;
}
IMethodBinding mtb = (IMethodBinding)this.mtbStack.peek();
try
{
if ((!node.getName().toString().equals("length")) ||
(ivb.getDeclaringClass() != null)) {
this.facts.add(Fact.makeAccessesFact(
getQualifiedName(node.resolveFieldBinding()),
getQualifiedName(mtb)));
}
}
catch (Exception localException1)
{
System.err.println("Cannot resolve field access \"" +
node.getName().toString() + "\"");
}
try
{
String simpleMethodName = getSimpleName(mtb);
if (simpleMethodName.toLowerCase().startsWith("get")) {
this.facts.add(Fact.makeGetterFact(getQualifiedName(mtb),
getQualifiedName(node.resolveFieldBinding())));
} else if (simpleMethodName.toLowerCase().startsWith("set")) {
this.facts.add(Fact.makeSetterFact(getQualifiedName(mtb),
getQualifiedName(node.resolveFieldBinding())));
}
}
catch (Exception localException2)
{
System.err.println("Cannot resolve bindings for exceptions");
}
return true;
}
示例7: visit
import org.eclipse.jdt.core.dom.FieldAccess; //导入方法依赖的package包/类
@Override
public final boolean visit(final FieldAccess node) {
Assert.isNotNull(node);
final Expression expression= node.getExpression();
final IVariableBinding variable= node.resolveFieldBinding();
final AST ast= fRewrite.getAST();
if (expression instanceof ThisExpression) {
if (Bindings.equals(fTarget, variable)) {
if (fAnonymousClass > 0) {
final ThisExpression target= ast.newThisExpression();
target.setQualifier(ast.newSimpleName(fTargetType.getElementName()));
fRewrite.replace(node, target, null);
} else
fRewrite.replace(node, ast.newThisExpression(), null);
return false;
} else {
expression.accept(this);
return false;
}
} else if (expression instanceof FieldAccess) {
final FieldAccess access= (FieldAccess) expression;
final IBinding binding= access.getName().resolveBinding();
if (access.getExpression() instanceof ThisExpression && Bindings.equals(fTarget, binding)) {
ASTNode newFieldAccess= getFieldReference(node.getName(), fRewrite);
fRewrite.replace(node, newFieldAccess, null);
return false;
}
} else if (expression != null) {
expression.accept(this);
return false;
}
return true;
}
示例8: visit
import org.eclipse.jdt.core.dom.FieldAccess; //导入方法依赖的package包/类
@Override
public boolean visit(FieldAccess node) {
IVariableBinding fieldBinding= node.resolveFieldBinding();
return checkVariableBinding(fieldBinding);
}
示例9: endVisit
import org.eclipse.jdt.core.dom.FieldAccess; //导入方法依赖的package包/类
@Override
public final void endVisit(final FieldAccess node) {
final IVariableBinding binding= node.resolveFieldBinding();
if (binding != null)
endVisit(binding, node.getExpression(), node);
}