org.eclipse.jdt.core.dom.SimpleName#resolveTypeBinding ( )源码实例Demo

下面列出了org.eclipse.jdt.core.dom.SimpleName#resolveTypeBinding ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: eclipse.jdt.ls   文件: JdtASTMatcher.java
@Override
public boolean match(SimpleName node, Object other) {
	boolean isomorphic = super.match(node, other);
	if (!isomorphic || !(other instanceof SimpleName)) {
		return false;
	}
	SimpleName name = (SimpleName) other;
	IBinding nodeBinding = node.resolveBinding();
	IBinding otherBinding = name.resolveBinding();
	if (nodeBinding == null) {
		if (otherBinding != null) {
			return false;
		}
	} else {
		if (nodeBinding != otherBinding) {
			return false;
		}
	}
	if (node.resolveTypeBinding() != name.resolveTypeBinding()) {
		return false;
	}
	return true;
}
 
@Override
public final boolean visit(final SimpleName node) {
	final ITypeBinding binding= node.resolveTypeBinding();
	if (binding != null && binding.isTypeVariable()) {
		String name= null;
		for (int index= 0; index < fMapping.length; index++) {
			name= binding.getName();
			if (fMapping[index].getSourceName().equals(name) && node.getIdentifier().equals(name)) {
				final MethodDeclaration declaration= (MethodDeclaration) ASTNodes.getParent(node, MethodDeclaration.class);
				if (declaration != null) {
					final IMethodBinding method= declaration.resolveBinding();
					if (method != null) {
						final ITypeBinding[] bindings= method.getTypeParameters();
						for (int offset= 0; offset < bindings.length; offset++) {
							if (bindings[offset].isEqualTo(binding))
								return true;
						}
					}
				}
				fRewrite.set(node, SimpleName.IDENTIFIER_PROPERTY, fMapping[index].getTargetName(), null);
			}
		}
	}
	return true;
}
 
@Override
public boolean match(SimpleName node, Object other) {
	boolean isomorphic= super.match(node, other);
	if (! isomorphic || !(other instanceof SimpleName))
		return false;
	SimpleName name= (SimpleName)other;
	IBinding nodeBinding= node.resolveBinding();
	IBinding otherBinding= name.resolveBinding();
	if (nodeBinding == null) {
		if (otherBinding != null) {
			return false;
		}
	} else {
		if (nodeBinding != otherBinding) {
			return false;
		}
	}
	if (node.resolveTypeBinding() != name.resolveTypeBinding())
		return false;
	return true;
}
 
源代码4 项目: eclipse.jdt.ls   文件: ExtractFieldRefactoring.java
@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 final boolean visit(final SimpleName node) {
	Assert.isNotNull(node);
	final ITypeBinding binding= node.resolveTypeBinding();
	if (binding != null && binding.isTypeVariable() && !fBindings.containsKey(binding.getKey())) {
		fBindings.put(binding.getKey(), binding);
		fFound.add(binding);
	}
	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) {
	ITypeBinding binding= node.resolveTypeBinding();
	if (binding != null) {
		boolean res= fVisitor.visit(binding);
		if (res) {
			res= Bindings.visitHierarchy(binding, fVisitor);
		}
		if (!res) {
			throw new VisitCancelledException();
		}
	}
	return false;
}