本文整理汇总了Java中org.eclipse.jdt.internal.corext.util.JdtFlags.isProtected方法的典型用法代码示例。如果您正苦于以下问题:Java JdtFlags.isProtected方法的具体用法?Java JdtFlags.isProtected怎么用?Java JdtFlags.isProtected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.corext.util.JdtFlags
的用法示例。
在下文中一共展示了JdtFlags.isProtected方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNeededVisibility
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private static int getNeededVisibility(
ASTNode currNode, ITypeBinding targetType, IBinding binding) {
ITypeBinding currNodeBinding = Bindings.getBindingOfParentType(currNode);
if (currNodeBinding == null) { // import
return Modifier.PUBLIC;
}
if (Bindings.isSuperType(targetType, currNodeBinding)) {
if (binding != null
&& (JdtFlags.isProtected(binding) || binding.getKind() == IBinding.TYPE)) {
return Modifier.PUBLIC;
}
return Modifier.PROTECTED;
}
if (currNodeBinding.getPackage().getKey().equals(targetType.getPackage().getKey())) {
return 0;
}
return Modifier.PUBLIC;
}
示例2: checkAccessModifiers
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private void checkAccessModifiers(final RefactoringStatus result, final Set<IMember> notDeletedMembersInSubtypes) throws JavaModelException {
if (fDestinationType.isInterface())
return;
final List<IMethod> toDeclareAbstract= Arrays.asList(fAbstractMethods);
for (final Iterator<IMember> iter= notDeletedMembersInSubtypes.iterator(); iter.hasNext();) {
final IMember member= iter.next();
if (member.getElementType() == IJavaElement.METHOD && !toDeclareAbstract.contains(member)) {
final IMethod method= ((IMethod) member);
if (method.getDeclaringType().getPackageFragment().equals(fDestinationType.getPackageFragment())) {
if (JdtFlags.isPrivate(method))
result.addError(Messages.format(RefactoringCoreMessages.PullUpRefactoring_lower_default_visibility, new String[] { JavaElementLabels.getTextLabel(method, JavaElementLabels.ALL_FULLY_QUALIFIED), JavaElementLabels.getTextLabel(method.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)}), JavaStatusContext.create(method));
} else if (!JdtFlags.isPublic(method) && !JdtFlags.isProtected(method))
result.addError(Messages.format(RefactoringCoreMessages.PullUpRefactoring_lower_protected_visibility, new String[] { JavaElementLabels.getTextLabel(method, JavaElementLabels.ALL_FULLY_QUALIFIED), JavaElementLabels.getTextLabel(method.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)}), JavaStatusContext.create(method));
}
}
}
示例3: getNeededVisibility
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private static int getNeededVisibility(ASTNode currNode, ITypeBinding targetType, IBinding binding) {
ITypeBinding currNodeBinding= Bindings.getBindingOfParentType(currNode);
if (currNodeBinding == null) { // import
return Modifier.PUBLIC;
}
if (Bindings.isSuperType(targetType, currNodeBinding)) {
if (binding != null && (JdtFlags.isProtected(binding) || binding.getKind() == IBinding.TYPE)) {
return Modifier.PUBLIC;
}
return Modifier.PROTECTED;
}
if (currNodeBinding.getPackage().getKey().equals(targetType.getPackage().getKey())) {
return 0;
}
return Modifier.PUBLIC;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:ModifierCorrectionSubProcessor.java
示例4: needsVisibilityAdjustment
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
protected boolean needsVisibilityAdjustment(final IMember member, final boolean references, final IProgressMonitor monitor, final RefactoringStatus status) throws JavaModelException {
if (JdtFlags.isPublic(member) || JdtFlags.isProtected(member))
return false;
if (!references)
return true;
return hasNonMovedReferences(member, monitor, status);
}
示例5: createNewTypeDeclarationNode
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private BodyDeclaration createNewTypeDeclarationNode(final IType type, final AbstractTypeDeclaration oldType, final CompilationUnit declaringCuNode, final TypeVariableMaplet[] mapping, final ASTRewrite rewrite) throws JavaModelException {
final ICompilationUnit declaringCu= getDeclaringType().getCompilationUnit();
if (!JdtFlags.isPublic(type) && !JdtFlags.isProtected(type)) {
if (mapping.length > 0)
return createPlaceholderForTypeDeclaration(oldType, declaringCu, mapping, rewrite, true);
return createPlaceholderForProtectedTypeDeclaration(oldType, declaringCuNode, declaringCu, rewrite, true);
}
if (mapping.length > 0)
return createPlaceholderForTypeDeclaration(oldType, declaringCu, mapping, rewrite, true);
return createPlaceholderForTypeDeclaration(oldType, declaringCu, rewrite, true);
}
示例6: getVisibility
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private static int getVisibility(IMember member) throws JavaModelException {
if (JdtFlags.isPrivate(member))
return 0;
if (JdtFlags.isPackageVisible(member))
return 1;
if (JdtFlags.isProtected(member))
return 2;
return 4;
}
示例7: canBeAccessedFrom
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private boolean canBeAccessedFrom(IMethod sourceMethod, final IMember member, final IType target,
final ITypeHierarchy hierarchy) throws JavaModelException {
Assert.isTrue(!(member instanceof IInitializer));
if (member.exists()) {
if (target.equals(member.getDeclaringType()))
return true;
if (target.equals(member))
return true;
// NOTE: We are not creating stubs (for now).
// Related to https://bugs.eclipse.org/bugs/show_bug.cgi?id=495439.
/*
* if (member instanceof IMethod) { final IMethod method = (IMethod)
* member; final IMethod stub =
* target.getMethod(method.getElementName(),
* method.getParameterTypes()); if (stub.exists()) return true; }
*/
if (member.getDeclaringType() == null) {
if (!(member instanceof IType))
return false;
if (JdtFlags.isPublic(member))
return true;
if (!JdtFlags.isPackageVisible(member))
return false;
if (JavaModelUtil.isSamePackage(((IType) member).getPackageFragment(), target.getPackageFragment()))
return true;
final IType type = member.getDeclaringType();
if (type != null)
return hierarchy.contains(type);
return false;
}
final IType declaringType = member.getDeclaringType();
// if the member's declaring type isn't accessible from the target
// type.
if (!canBeAccessedFrom(sourceMethod, declaringType, target, hierarchy))
return false; // then, the member isn't accessible from the
// target type.
// otherwise, the member's declaring type is accessible from the
// target type.
// We are going to be moving the source method from it's
// declaring type.
// We know that the member's declaring type is accessible from
// the target.
// We also know that the member's declaring type and the target
// type are different.
// The question now is if the target type can access the
// particular member given that
// the target type can access the member's declaring type.
// if it's public, the answer is yes.
if (JdtFlags.isPublic(member))
return true;
// if the member is private, the answer is no.
else if (JdtFlags.isPrivate(member))
return false;
// if it's package-private or protected.
else if (JdtFlags.isPackageVisible(member) || JdtFlags.isProtected(member)) {
// then, if the member's declaring type in the same package
// as the target's declaring type, the answer is yes.
if (JavaModelUtil.isVisible(member, target.getPackageFragment()))
return true;
// otherwise, if it's protected.
else if (JdtFlags.isProtected(member))
// then, the answer is yes if the target type is a
// sub-type of the member's declaring type. Otherwise,
// the answer is no.
return hierarchy.contains(declaringType);
else
return false; // not accessible.
} else
throw new IllegalStateException("Member: " + member + " has no known visibility.");
}
return false;
}
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:73,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java
示例8: getVisibility
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private static int getVisibility(IMember member) throws JavaModelException {
if (JdtFlags.isPrivate(member)) return 0;
if (JdtFlags.isPackageVisible(member)) return 1;
if (JdtFlags.isProtected(member)) return 2;
return 4;
}