本文整理匯總了Java中org.eclipse.jdt.core.dom.ITypeBinding.isAssignmentCompatible方法的典型用法代碼示例。如果您正苦於以下問題:Java ITypeBinding.isAssignmentCompatible方法的具體用法?Java ITypeBinding.isAssignmentCompatible怎麽用?Java ITypeBinding.isAssignmentCompatible使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.ITypeBinding
的用法示例。
在下文中一共展示了ITypeBinding.isAssignmentCompatible方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: computeProposals
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
@Override
protected Expression computeProposals(AST ast, ITypeBinding returnBinding, int returnOffset, CompilationUnit root, Expression result) {
ScopeAnalyzer analyzer= new ScopeAnalyzer(root);
IBinding[] bindings= analyzer.getDeclarationsInScope(returnOffset, ScopeAnalyzer.VARIABLES | ScopeAnalyzer.CHECK_VISIBILITY);
org.eclipse.jdt.core.dom.NodeFinder finder= new org.eclipse.jdt.core.dom.NodeFinder(root, returnOffset, 0);
ASTNode varDeclFrag= ASTResolving.findAncestor(finder.getCoveringNode(), ASTNode.VARIABLE_DECLARATION_FRAGMENT);
IVariableBinding varDeclFragBinding= null;
if (varDeclFrag != null)
varDeclFragBinding= ((VariableDeclarationFragment) varDeclFrag).resolveBinding();
for (int i= 0; i < bindings.length; i++) {
IVariableBinding curr= (IVariableBinding) bindings[i];
ITypeBinding type= curr.getType();
// Bindings are compared to make sure that a lambda does not return a variable which is yet to be initialised.
if (type != null && type.isAssignmentCompatible(returnBinding) && testModifier(curr) && !Bindings.equals(curr, varDeclFragBinding)) {
if (result == null) {
result= ast.newSimpleName(curr.getName());
}
addLinkedPositionProposal(RETURN_EXPRESSION_KEY, curr.getName());
}
}
return result;
}
示例2: getBaseNameFromLocationInParent
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static String getBaseNameFromLocationInParent(Expression assignedExpression, List<Expression> arguments, IMethodBinding binding) {
if (binding == null) {
return null;
}
ITypeBinding[] parameterTypes= binding.getParameterTypes();
if (parameterTypes.length != arguments.size()) {
return null;
}
int index= arguments.indexOf(assignedExpression);
if (index == -1) {
return null;
}
ITypeBinding expressionBinding= assignedExpression.resolveTypeBinding();
if (expressionBinding != null && !expressionBinding.isAssignmentCompatible(parameterTypes[index])) {
return null;
}
try {
IJavaElement javaElement= binding.getJavaElement();
if (javaElement instanceof IMethod) {
IMethod method= (IMethod)javaElement;
if (method.getOpenable().getBuffer() != null) { // avoid dummy names and lookup from Javadoc
String[] parameterNames= method.getParameterNames();
if (index < parameterNames.length) {
return NamingConventions.getBaseName(NamingConventions.VK_PARAMETER, parameterNames[index], method.getJavaProject());
}
}
}
} catch (JavaModelException e) {
// ignore
}
return null;
}
示例3: updateExceptionsList
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static void updateExceptionsList(List<ITypeBinding> exceptions, ITypeBinding thrownException) {
for (Iterator<ITypeBinding> excep = exceptions.iterator(); excep.hasNext();) {
ITypeBinding exception = excep.next();
if (exception.isAssignmentCompatible(thrownException)) {
excep.remove();
}
}
}
示例4: computeProposals
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
protected Expression computeProposals(AST ast, ITypeBinding returnBinding, int returnOffset, CompilationUnit root, Expression result) {
ScopeAnalyzer analyzer= new ScopeAnalyzer(root);
IBinding[] bindings= analyzer.getDeclarationsInScope(returnOffset, ScopeAnalyzer.VARIABLES | ScopeAnalyzer.CHECK_VISIBILITY);
for (int i= 0; i < bindings.length; i++) {
IVariableBinding curr= (IVariableBinding) bindings[i];
ITypeBinding type= curr.getType();
if (type != null && type.isAssignmentCompatible(returnBinding) && testModifier(curr)) {
if (result == null) {
result= ast.newSimpleName(curr.getName());
}
addLinkedPositionProposal(RETURN_EXPRESSION_KEY, curr.getName());
}
}
return result;
}
示例5: canAssign
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private boolean canAssign(ITypeBinding curr, ITypeBinding best) {
return curr.isAssignmentCompatible(best);
}
示例6: canAssign
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static boolean canAssign(ITypeBinding returnType, ITypeBinding guessedType) {
return returnType.isAssignmentCompatible(guessedType);
}