本文整理匯總了Java中org.eclipse.jdt.core.dom.ITypeBinding.getPackage方法的典型用法代碼示例。如果您正苦於以下問題:Java ITypeBinding.getPackage方法的具體用法?Java ITypeBinding.getPackage怎麽用?Java ITypeBinding.getPackage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.ITypeBinding
的用法示例。
在下文中一共展示了ITypeBinding.getPackage方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isVisibleInHierarchy
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static boolean isVisibleInHierarchy(IMethodBinding member, IPackageBinding pack) {
int otherflags= member.getModifiers();
ITypeBinding declaringType= member.getDeclaringClass();
if (Modifier.isPublic(otherflags) || Modifier.isProtected(otherflags) || (declaringType != null && declaringType.isInterface())) {
return true;
} else if (Modifier.isPrivate(otherflags)) {
return false;
}
return declaringType != null && pack == declaringType.getPackage();
}
示例2: findNullnessDefault
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
* Answer the annotation binding representing a nullness default
* effective at the point denoted by 'contextBinding'.
* @param contextBinding method binding or type binding denoting the location of interest
* @param javaProject the containing java project, consulted for the actual name of
* the annotation used for nullness defaults (default: <code>@NonNullByDefault</code>).
* @return binding for the effective nullness default annotation
* or null if no nullness default is effective at the context location.
*/
public static IAnnotationBinding findNullnessDefault(IBinding contextBinding, IJavaProject javaProject) {
if (JavaCore.ENABLED.equals(javaProject.getOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, true))) {
String annotationName= javaProject.getOption(JavaCore.COMPILER_NONNULL_BY_DEFAULT_ANNOTATION_NAME, true);
while (contextBinding != null) {
for (IAnnotationBinding annotation : contextBinding.getAnnotations()) {
ITypeBinding annotationType= annotation.getAnnotationType();
if (annotationType != null && annotationType.getQualifiedName().equals(annotationName)) {
return annotation;
}
}
// travel out:
switch (contextBinding.getKind()) {
case IBinding.METHOD:
IMethodBinding methodBinding= (IMethodBinding) contextBinding;
contextBinding= methodBinding.getDeclaringMember();
if (contextBinding == null) {
contextBinding= methodBinding.getDeclaringClass();
}
break;
case IBinding.VARIABLE:
IVariableBinding variableBinding= (IVariableBinding) contextBinding;
contextBinding= variableBinding.getDeclaringMethod();
if (contextBinding == null) {
contextBinding= variableBinding.getDeclaringClass();
}
break;
case IBinding.TYPE:
ITypeBinding currentClass= (ITypeBinding) contextBinding;
contextBinding= currentClass.getDeclaringMember();
if (contextBinding == null) {
contextBinding= currentClass.getDeclaringMethod();
if (contextBinding == null) {
contextBinding= currentClass.getDeclaringClass();
if (contextBinding == null) {
contextBinding= currentClass.getPackage();
}
}
}
break;
default:
contextBinding= null;
break;
}
}
}
return null;
}