Java Code Examples for org.eclipse.jdt.core.dom.SimpleName#isDeclaration()

The following examples show how to use org.eclipse.jdt.core.dom.SimpleName#isDeclaration() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@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);
}
 
Example 2
@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);
}
 
Example 3
@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);
}
 
Example 4
@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));
		}
	}
}
 
Example 5
@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));
		}
	}
}
 
Example 6
@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;
}
 
Example 7
@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);
}
 
Example 8
@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;
}
 
Example 9
@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);
}
 
Example 10
@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;
}
 
Example 11
@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);
}
 
Example 12
@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;
}
 
Example 13
@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);
}
 
Example 14
@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);
}
 
Example 15
@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);
}
 
Example 16
@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;
}
 
Example 17
@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;
}
 
Example 18
@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;
}
 
Example 19
@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;
}
 
Example 20
@Override
public boolean visit(SimpleName node) {
	if (! node.isDeclaration() && isMovedMember(node.resolveBinding()) && ! isProcessed(node))
		rewrite(node, fTarget);
	return false;
}