下面列出了org.eclipse.jdt.core.dom.SimpleName#isDeclaration ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public boolean consumes(final SemanticToken token) {
final SimpleName node= token.getNode();
if (node.isDeclaration()) {
return false;
}
final IBinding binding= token.getBinding();
if (binding == null || binding.getKind() != IBinding.VARIABLE) {
return false;
}
ITypeBinding currentType= Bindings.getBindingOfParentType(node);
ITypeBinding declaringType= ((IVariableBinding) binding).getDeclaringClass();
if (declaringType == null || currentType == declaringType)
return false;
return Bindings.isSuperType(declaringType, currentType);
}
@Override
public boolean consumes(SemanticToken token) {
SimpleName node = token.getNode();
if (node.isDeclaration()) {
return false;
}
IBinding binding = token.getBinding();
if (binding == null || binding.getKind() != IBinding.METHOD) {
return false;
}
ITypeBinding currentType = Bindings.getBindingOfParentType(node);
ITypeBinding declaringType = ((IMethodBinding) binding).getDeclaringClass();
if (currentType == declaringType || currentType == null) {
return false;
}
return Bindings.isSuperType(declaringType, currentType);
}
@Override
public boolean consumes(final SemanticToken token) {
final SimpleName node = token.getNode();
if (node.isDeclaration()) {
return false;
}
final IBinding binding = token.getBinding();
if (binding == null || binding.getKind() != IBinding.VARIABLE) {
return false;
}
ITypeBinding currentType = Bindings.getBindingOfParentType(node);
ITypeBinding declaringType = ((IVariableBinding) binding).getDeclaringClass();
if (declaringType == null || currentType == declaringType) {
return false;
}
return Bindings.isSuperType(declaringType, currentType);
}
@Override
public void endVisit(SimpleName node) {
if (skipNode(node) || node.isDeclaration()) {
return;
}
IBinding binding = node.resolveBinding();
if (binding instanceof IVariableBinding) {
IVariableBinding variable = (IVariableBinding) binding;
if (!variable.isField()) {
setFlowInfo(node, new LocalFlowInfo(variable, FlowInfo.READ, fFlowContext));
}
} else if (binding instanceof ITypeBinding) {
ITypeBinding type = (ITypeBinding) binding;
if (type.isTypeVariable()) {
setFlowInfo(node, new TypeVariableFlowInfo(type, fFlowContext));
}
}
}
@Override
public void endVisit(SimpleName node) {
if (skipNode(node) || node.isDeclaration())
return;
IBinding binding= node.resolveBinding();
if (binding instanceof IVariableBinding) {
IVariableBinding variable= (IVariableBinding)binding;
if (!variable.isField()) {
setFlowInfo(node, new LocalFlowInfo(
variable,
FlowInfo.READ,
fFlowContext));
}
} else if (binding instanceof ITypeBinding) {
ITypeBinding type= (ITypeBinding)binding;
if (type.isTypeVariable()) {
setFlowInfo(node, new TypeVariableFlowInfo(type, fFlowContext));
}
}
}
@Override
public boolean consumes(SemanticToken token) {
SimpleName node= token.getNode();
if (node.isDeclaration())
return false;
IBinding binding= token.getBinding();
boolean isAbstractMethod= binding != null && binding.getKind() == IBinding.METHOD && (binding.getModifiers() & Modifier.ABSTRACT) == Modifier.ABSTRACT;
if (!isAbstractMethod)
return false;
// filter out annotation value references
if (binding != null) {
ITypeBinding declaringType= ((IMethodBinding)binding).getDeclaringClass();
if (declaringType.isAnnotation())
return false;
}
return true;
}
@Override
public boolean consumes(SemanticToken token) {
SimpleName node= token.getNode();
if (node.isDeclaration())
return false;
IBinding binding= token.getBinding();
if (binding == null || binding.getKind() != IBinding.METHOD)
return false;
ITypeBinding currentType= Bindings.getBindingOfParentType(node);
ITypeBinding declaringType= ((IMethodBinding) binding).getDeclaringClass();
if (currentType == declaringType || currentType == null)
return false;
return Bindings.isSuperType(declaringType, currentType);
}
@Override
public boolean consumes(SemanticToken token) {
SimpleName node = token.getNode();
if (node.isDeclaration()) {
return false;
}
IBinding binding = token.getBinding();
return binding != null && binding.getKind() == IBinding.METHOD && (binding.getModifiers() & Modifier.STATIC) == Modifier.STATIC;
}
@Override
public boolean match(SimpleName candidate, Object s) {
if (!(s instanceof SimpleName)) {
return false;
}
SimpleName snippet = (SimpleName) s;
if (candidate.isDeclaration() != snippet.isDeclaration()) {
return false;
}
IBinding cb = candidate.resolveBinding();
IBinding sb = snippet.resolveBinding();
if (cb == null || sb == null) {
return false;
}
IVariableBinding vcb = ASTNodes.getVariableBinding(candidate);
IVariableBinding vsb = ASTNodes.getVariableBinding(snippet);
if (vcb == null || vsb == null) {
return Bindings.equals(cb, sb);
}
if (!vcb.isField() && !vsb.isField() && Bindings.equals(vcb.getType(), vsb.getType())) {
SimpleName mapped = fMatch.getMappedName(vsb);
if (mapped != null) {
IVariableBinding mappedBinding = ASTNodes.getVariableBinding(mapped);
if (!Bindings.equals(vcb, mappedBinding)) {
return false;
}
}
fMatch.addLocal(vsb, candidate);
return true;
}
return Bindings.equals(cb, sb);
}
@Override
public boolean visit(SimpleName node) {
if (node.isDeclaration()) {
return true;
}
IBinding binding = node.resolveBinding();
if (binding instanceof ITypeBinding) {
processLocalTypeBinding((ITypeBinding) binding, fSelection.getVisitSelectionMode(node));
}
return true;
}
@Override
public boolean visit(SimpleName node) {
ITypeBinding typeBinding = node.resolveTypeBinding();
if (typeBinding != null && typeBinding.isLocal()) {
if (node.isDeclaration()) {
fLocalDefinitions.add(typeBinding);
} else if (!fLocalDefinitions.contains(typeBinding)) {
fLocalReferencesToEnclosing.add(node);
}
}
if (typeBinding != null && typeBinding.isTypeVariable()) {
if (node.isDeclaration()) {
fLocalDefinitions.add(typeBinding);
} else if (!fLocalDefinitions.contains(typeBinding)) {
if (fMethodTypeVariables.contains(typeBinding)) {
fLocalReferencesToEnclosing.add(node);
} else {
fClassTypeVariablesUsed = true;
}
}
}
IBinding binding = node.resolveBinding();
if (binding != null && binding.getKind() == IBinding.VARIABLE && !((IVariableBinding) binding).isField()) {
if (node.isDeclaration()) {
fLocalDefinitions.add(binding);
} else if (!fLocalDefinitions.contains(binding)) {
fLocalReferencesToEnclosing.add(node);
}
}
return super.visit(node);
}
@Override
public boolean visit(SimpleName node) {
if (!node.isDeclaration() && considerBinding(node.resolveBinding(), node)) {
fReferencingGetter = true;
fRewriter.replace(node, fRewriter.createStringPlaceholder(fGetter + "()", ASTNode.METHOD_INVOCATION), //$NON-NLS-1$
createGroupDescription(READ_ACCESS));
}
return true;
}
@Override
public boolean visit(SimpleName node) {
if (node.isDeclaration() || isProcessed(node))
return super.visit(node);
IBinding binding= node.resolveBinding();
if (isMovedMember(binding))
return super.visit(node);
if (isSourceAccess(binding))
rewrite(node, fSource);
return super.visit(node);
}
@Override
public boolean visit(SimpleName node) {
ITypeBinding typeBinding= node.resolveTypeBinding();
if (typeBinding != null && typeBinding.isLocal()) {
if (node.isDeclaration()) {
fLocalDefinitions.add(typeBinding);
} else if (! fLocalDefinitions.contains(typeBinding)) {
fLocalReferencesToEnclosing.add(node);
}
}
if (typeBinding != null && typeBinding.isTypeVariable()) {
if (node.isDeclaration()) {
fLocalDefinitions.add(typeBinding);
} else if (! fLocalDefinitions.contains(typeBinding)) {
if (fMethodTypeVariables.contains(typeBinding)) {
fLocalReferencesToEnclosing.add(node);
} else {
fClassTypeVariablesUsed= true;
}
}
}
IBinding binding= node.resolveBinding();
if (binding != null && binding.getKind() == IBinding.VARIABLE && ! ((IVariableBinding)binding).isField()) {
if (node.isDeclaration()) {
fLocalDefinitions.add(binding);
} else if (! fLocalDefinitions.contains(binding)) {
fLocalReferencesToEnclosing.add(node);
}
}
return super.visit(node);
}
@Override
public boolean match(SimpleName candidate, Object s) {
if (!(s instanceof SimpleName))
return false;
SimpleName snippet= (SimpleName)s;
if (candidate.isDeclaration() != snippet.isDeclaration())
return false;
IBinding cb= candidate.resolveBinding();
IBinding sb= snippet.resolveBinding();
if (cb == null || sb == null)
return false;
IVariableBinding vcb= ASTNodes.getVariableBinding(candidate);
IVariableBinding vsb= ASTNodes.getVariableBinding(snippet);
if (vcb == null || vsb == null)
return Bindings.equals(cb, sb);
if (!vcb.isField() && !vsb.isField() && Bindings.equals(vcb.getType(), vsb.getType())) {
SimpleName mapped= fMatch.getMappedName(vsb);
if (mapped != null) {
IVariableBinding mappedBinding= ASTNodes.getVariableBinding(mapped);
if (!Bindings.equals(vcb, mappedBinding))
return false;
}
fMatch.addLocal(vsb, candidate);
return true;
}
return Bindings.equals(cb, sb);
}
@Override
public boolean visit(SimpleName node) {
if (node.isDeclaration())
return true;
IBinding binding= node.resolveBinding();
if (binding instanceof ITypeBinding)
processLocalTypeBinding((ITypeBinding) binding, fSelection.getVisitSelectionMode(node));
return true;
}
@Override
public boolean visit(SimpleName node) {
IVariableBinding binding= null;
if (node.isDeclaration() || !considerNode(node) || (binding= ASTNodes.getLocalVariableBinding(node)) == null)
return false;
handleReferenceToLocal(node, binding);
return true;
}
@Override
public boolean visit(SimpleName node) {
if (!node.isDeclaration() && considerBinding(node.resolveBinding(), node)) {
fReferencingGetter= true;
fRewriter.replace(
node,
fRewriter.createStringPlaceholder(fGetter + "()", ASTNode.METHOD_INVOCATION), //$NON-NLS-1$
createGroupDescription(READ_ACCESS));
}
return true;
}
@Override
public boolean consumes(SemanticToken token) {
SimpleName node= token.getNode();
if (node.isDeclaration())
return false;
IBinding binding= token.getBinding();
return binding != null && binding.getKind() == IBinding.METHOD && (binding.getModifiers() & Modifier.STATIC) == Modifier.STATIC;
}
@Override
public boolean visit(SimpleName node) {
if (! node.isDeclaration() && isMovedMember(node.resolveBinding()) && ! isProcessed(node))
rewrite(node, fTarget);
return false;
}