本文整理匯總了Java中org.eclipse.jdt.core.compiler.IProblem.NullableFieldReference方法的典型用法代碼示例。如果您正苦於以下問題:Java IProblem.NullableFieldReference方法的具體用法?Java IProblem.NullableFieldReference怎麽用?Java IProblem.NullableFieldReference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.compiler.IProblem
的用法示例。
在下文中一共展示了IProblem.NullableFieldReference方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findProblemFieldName
import org.eclipse.jdt.core.compiler.IProblem; //導入方法依賴的package包/類
private static SimpleName findProblemFieldName(ASTNode selectedNode, int problemID) {
// if a field access occurs in an compatibility situation (assignment/return/argument)
// with expected type declared @NonNull we first need to find the SimpleName inside:
if (selectedNode instanceof FieldAccess) selectedNode = ((FieldAccess) selectedNode).getName();
else if (selectedNode instanceof QualifiedName)
selectedNode = ((QualifiedName) selectedNode).getName();
if (selectedNode instanceof SimpleName) {
SimpleName name = (SimpleName) selectedNode;
if (problemID == IProblem.NullableFieldReference) return name;
// not field dereference, but compatibility issue - is value a field reference?
IBinding binding = name.resolveBinding();
if ((binding instanceof IVariableBinding) && ((IVariableBinding) binding).isField())
return name;
}
return null;
}