當前位置: 首頁>>代碼示例>>Java>>正文


Java ITypeBinding.isAssignmentCompatible方法代碼示例

本文整理匯總了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;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:24,代碼來源:MissingReturnTypeInLambdaCorrectionProposal.java

示例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;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:37,代碼來源:StubUtility.java

示例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();
		}
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:9,代碼來源:ExceptionAnalyzer.java

示例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;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:16,代碼來源:MissingReturnTypeCorrectionProposal.java

示例5: canAssign

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private boolean canAssign(ITypeBinding curr, ITypeBinding best) {
	return curr.isAssignmentCompatible(best);
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:4,代碼來源:AddArgumentCorrectionProposal.java

示例6: canAssign

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static boolean canAssign(ITypeBinding returnType, ITypeBinding guessedType) {
	return returnType.isAssignmentCompatible(guessedType);
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:4,代碼來源:UnresolvedElementsSubProcessor.java


注:本文中的org.eclipse.jdt.core.dom.ITypeBinding.isAssignmentCompatible方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。