本文整理汇总了Java中org.eclipse.jdt.internal.corext.util.JdtFlags.isPrivate方法的典型用法代码示例。如果您正苦于以下问题:Java JdtFlags.isPrivate方法的具体用法?Java JdtFlags.isPrivate怎么用?Java JdtFlags.isPrivate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.corext.util.JdtFlags
的用法示例。
在下文中一共展示了JdtFlags.isPrivate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: classesDeclareMethodName
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private static IMethod[] classesDeclareMethodName(
ITypeHierarchy hier, List<IType> classes, IMethod method, String newName)
throws CoreException {
Set<IMethod> result = new HashSet<IMethod>();
IType type = method.getDeclaringType();
List<IType> subtypes = Arrays.asList(hier.getAllSubtypes(type));
int parameterCount = method.getParameterTypes().length;
boolean isMethodPrivate = JdtFlags.isPrivate(method);
for (Iterator<IType> iter = classes.iterator(); iter.hasNext(); ) {
IType clazz = iter.next();
IMethod[] methods = clazz.getMethods();
boolean isSubclass = subtypes.contains(clazz);
for (int j = 0; j < methods.length; j++) {
IMethod foundMethod =
Checks.findMethod(newName, parameterCount, false, new IMethod[] {methods[j]});
if (foundMethod == null) continue;
if (isSubclass || type.equals(clazz)) result.add(foundMethod);
else if ((!isMethodPrivate) && (!JdtFlags.isPrivate(methods[j]))) result.add(foundMethod);
}
}
return result.toArray(new IMethod[result.size()]);
}
示例2: create
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
/**
* Creates a new search scope with all compilation units possibly referencing <code>javaElement
* </code>.
*
* @param javaElement the java element
* @param considerVisibility consider visibility of javaElement iff <code>true</code>
* @param sourceReferencesOnly consider references in source only (no references in binary)
* @return the search scope
* @throws JavaModelException if an error occurs
*/
public static IJavaSearchScope create(
IJavaElement javaElement, boolean considerVisibility, boolean sourceReferencesOnly)
throws JavaModelException {
if (considerVisibility & javaElement instanceof IMember) {
IMember member = (IMember) javaElement;
if (JdtFlags.isPrivate(member)) {
if (member.getCompilationUnit() != null)
return SearchEngine.createJavaSearchScope(
new IJavaElement[] {member.getCompilationUnit()});
else return SearchEngine.createJavaSearchScope(new IJavaElement[] {member});
}
// Removed code that does some optimizations regarding package visible members. The problem is
// that
// there can be a package fragment with the same name in a different source folder or project.
// So we
// have to treat package visible members like public or protected members.
}
IJavaProject javaProject = javaElement.getJavaProject();
return SearchEngine.createJavaSearchScope(
getAllScopeElements(javaProject, sourceReferencesOnly), false);
}
示例3: 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));
}
}
}
示例4: classesDeclareMethodName
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private static IMethod[] classesDeclareMethodName(ITypeHierarchy hier, List<IType> classes, IMethod method, String newName) throws CoreException {
Set<IMethod> result= new HashSet<IMethod>();
IType type= method.getDeclaringType();
List<IType> subtypes= Arrays.asList(hier.getAllSubtypes(type));
int parameterCount= method.getParameterTypes().length;
boolean isMethodPrivate= JdtFlags.isPrivate(method);
for (Iterator<IType> iter= classes.iterator(); iter.hasNext(); ){
IType clazz= iter.next();
IMethod[] methods= clazz.getMethods();
boolean isSubclass= subtypes.contains(clazz);
for (int j= 0; j < methods.length; j++) {
IMethod foundMethod= Checks.findMethod(newName, parameterCount, false, new IMethod[] {methods[j]});
if (foundMethod == null)
continue;
if (isSubclass || type.equals(clazz))
result.add(foundMethod);
else if ((! isMethodPrivate) && (! JdtFlags.isPrivate(methods[j])))
result.add(foundMethod);
}
}
return result.toArray(new IMethod[result.size()]);
}
示例5: create
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
/**
* Creates a new search scope with all compilation units possibly referencing <code>javaElement</code>.
*
* @param javaElement the java element
* @param considerVisibility consider visibility of javaElement iff <code>true</code>
* @param sourceReferencesOnly consider references in source only (no references in binary)
* @return the search scope
* @throws JavaModelException if an error occurs
*/
public static IJavaSearchScope create(IJavaElement javaElement, boolean considerVisibility, boolean sourceReferencesOnly) throws JavaModelException {
if (considerVisibility & javaElement instanceof IMember) {
IMember member= (IMember) javaElement;
if (JdtFlags.isPrivate(member)) {
if (member.getCompilationUnit() != null)
return SearchEngine.createJavaSearchScope(new IJavaElement[] { member.getCompilationUnit()});
else
return SearchEngine.createJavaSearchScope(new IJavaElement[] { member});
}
// Removed code that does some optimizations regarding package visible members. The problem is that
// there can be a package fragment with the same name in a different source folder or project. So we
// have to treat package visible members like public or protected members.
}
IJavaProject javaProject= javaElement.getJavaProject();
return SearchEngine.createJavaSearchScope(getAllScopeElements(javaProject, sourceReferencesOnly), false);
}
示例6: isVirtual
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private static boolean isVirtual(IMethod method) throws JavaModelException {
if (method.isConstructor()) {
return false;
}
if (JdtFlags.isPrivate(method)) {
return false;
}
if (JdtFlags.isStatic(method)) {
return false;
}
return true;
}
示例7: overridesAnotherMethod
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
public static IMethod overridesAnotherMethod(IMethod method, ITypeHierarchy hierarchy)
throws JavaModelException {
MethodOverrideTester tester = new MethodOverrideTester(method.getDeclaringType(), hierarchy);
IMethod found = tester.findDeclaringMethod(method, true);
boolean overrides =
(found != null
&& !found.equals(method)
&& (!JdtFlags.isStatic(found))
&& (!JdtFlags.isPrivate(found)));
if (overrides) return found;
else return null;
}
示例8: computeAffectedNatures
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
public static String[] computeAffectedNatures(IJavaElement element) throws CoreException {
if (element instanceof IMember) {
IMember member = (IMember) element;
if (JdtFlags.isPrivate(member)) {
return element.getJavaProject().getProject().getDescription().getNatureIds();
}
}
IJavaProject project = element.getJavaProject();
return ResourceProcessors.computeAffectedNatures(project.getProject());
}
示例9: isVirtual
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
/**
* Returns <code>true</code> iff the method could be a virtual method,
* i.e. if it is not a constructor, is private, or is static.
*
* @param method a method
* @return <code>true</code> iff the method could a virtual method
* @throws JavaModelException
*/
public static boolean isVirtual(IMethod method) throws JavaModelException {
if (method.isConstructor())
return false;
if (JdtFlags.isPrivate(method))
return false;
if (JdtFlags.isStatic(method))
return false;
return true;
}
示例10: overridesAnotherMethod
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
public static IMethod overridesAnotherMethod(IMethod method, ITypeHierarchy hierarchy) throws JavaModelException {
MethodOverrideTester tester= new MethodOverrideTester(method.getDeclaringType(), hierarchy);
IMethod found= tester.findDeclaringMethod(method, true);
boolean overrides= (found != null && !found.equals(method) && (!JdtFlags.isStatic(found)) && (!JdtFlags.isPrivate(found)));
if (overrides)
return found;
else
return null;
}
示例11: computeAffectedNatures
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
public static String[] computeAffectedNatures(IJavaElement element) throws CoreException {
if (element instanceof IMember) {
IMember member= (IMember)element;
if (JdtFlags.isPrivate(member)) {
return element.getJavaProject().getProject().getDescription().getNatureIds();
}
}
IJavaProject project= element.getJavaProject();
return ResourceProcessors.computeAffectedNatures(project.getProject());
}
示例12: 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;
}
示例13: getAccurateSearchScope
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private IJavaSearchScope getAccurateSearchScope(IJavaSearchScope defaultSearchScope, IMember member) throws JavaModelException {
if (! JdtFlags.isPrivate(member))
return defaultSearchScope;
if (member.getCompilationUnit() != null) {
return SearchEngine.createJavaSearchScope(new IJavaElement[] { member.getCompilationUnit() });
} else if (member.getClassFile() != null) {
// member could be called from an inner class-> search
// package fragment (see also bug 109053):
return SearchEngine.createJavaSearchScope(new IJavaElement[] { member.getAncestor(IJavaElement.PACKAGE_FRAGMENT) });
} else {
return defaultSearchScope;
}
}
示例14: isOverriddenMethod
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
/**
* Indicates whether a method is overridden.
*
* @param method the method to check
* @return <code>true</code> if the method is overridden, <code>false</code> otherwise
*/
private boolean isOverriddenMethod(IMethod method) {
try {
if (JdtFlags.isPrivate(method) || JdtFlags.isStatic(method) || method.isConstructor())
return false;
if (JavaElementSuperImplementationHyperlink.findSuperImplementation(method) != null)
return true;
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:JavaElementHyperlinkSuperImplementationDetector.java
示例15: 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