当前位置: 首页>>代码示例>>Java>>正文


Java IMember.exists方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.IMember.exists方法的典型用法代码示例。如果您正苦于以下问题:Java IMember.exists方法的具体用法?Java IMember.exists怎么用?Java IMember.exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.IMember的用法示例。


在下文中一共展示了IMember.exists方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isExtractSupertypeAvailable

import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
public static boolean isExtractSupertypeAvailable(IMember member) throws JavaModelException {
  if (!member.exists()) return false;
  final int type = member.getElementType();
  if (type != IJavaElement.METHOD && type != IJavaElement.FIELD && type != IJavaElement.TYPE)
    return false;
  if (JdtFlags.isEnum(member) && type != IJavaElement.TYPE) return false;
  if (!Checks.isAvailable(member)) return false;
  if (member instanceof IMethod) {
    final IMethod method = (IMethod) member;
    if (method.isConstructor()) return false;
    if (JdtFlags.isNative(method)) return false;
    member = method.getDeclaringType();
  } else if (member instanceof IField) {
    member = member.getDeclaringType();
  }
  if (member instanceof IType) {
    if (JdtFlags.isEnum(member) || JdtFlags.isAnnotation(member)) return false;
    if (member.getDeclaringType() != null && !JdtFlags.isStatic(member)) return false;
    if (((IType) member).isAnonymous())
      return false; // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=253727
    if (((IType) member).isLambda()) return false;
  }
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:RefactoringAvailabilityTester.java

示例2: isMoveStaticAvailable

import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
public static boolean isMoveStaticAvailable(final IMember member) throws JavaModelException {
  if (!member.exists()) return false;
  final int type = member.getElementType();
  if (type != IJavaElement.METHOD && type != IJavaElement.FIELD && type != IJavaElement.TYPE)
    return false;
  if (JdtFlags.isEnum(member) && type != IJavaElement.TYPE) return false;
  final IType declaring = member.getDeclaringType();
  if (declaring == null) return false;
  if (!Checks.isAvailable(member)) return false;
  if (type == IJavaElement.METHOD && declaring.isInterface()) {
    boolean is18OrHigher = JavaModelUtil.is18OrHigher(member.getJavaProject());
    if (!is18OrHigher || !Flags.isStatic(member.getFlags())) return false;
  }
  if (type == IJavaElement.METHOD && !JdtFlags.isStatic(member)) return false;
  if (type == IJavaElement.METHOD && ((IMethod) member).isConstructor()) return false;
  if (type == IJavaElement.TYPE && !JdtFlags.isStatic(member)) return false;
  if (!declaring.isInterface() && !JdtFlags.isStatic(member)) return false;
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:RefactoringAvailabilityTester.java

示例3: isPullUpAvailable

import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
public static boolean isPullUpAvailable(IMember member) throws JavaModelException {
  if (!member.exists()) return false;
  final int type = member.getElementType();
  if (type != IJavaElement.METHOD && type != IJavaElement.FIELD && type != IJavaElement.TYPE)
    return false;
  if (JdtFlags.isEnum(member) && type != IJavaElement.TYPE) return false;
  if (!Checks.isAvailable(member)) return false;
  if (member instanceof IType) {
    if (!JdtFlags.isStatic(member) && !JdtFlags.isEnum(member) && !JdtFlags.isAnnotation(member))
      return false;
  }
  if (member instanceof IMethod) {
    final IMethod method = (IMethod) member;
    if (method.isConstructor()) return false;
    if (JdtFlags.isNative(method)) return false;
    final IType declaring = method.getDeclaringType();
    if (declaring != null && declaring.isAnnotation()) return false;
  }
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:RefactoringAvailabilityTester.java

示例4: isPushDownAvailable

import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
public static boolean isPushDownAvailable(final IMember member) throws JavaModelException {
  if (!member.exists()) return false;
  final int type = member.getElementType();
  if (type != IJavaElement.METHOD && type != IJavaElement.FIELD) return false;
  if (JdtFlags.isEnum(member)) return false;
  if (!Checks.isAvailable(member)) return false;
  if (JdtFlags.isStatic(member)) return false;
  if (type == IJavaElement.METHOD) {
    final IMethod method = (IMethod) member;
    if (method.isConstructor()) return false;
    if (JdtFlags.isNative(method)) return false;
    final IType declaring = method.getDeclaringType();
    if (declaring != null && declaring.isAnnotation()) return false;
  }
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:RefactoringAvailabilityTester.java

示例5: canBeAccessedFrom

import org.eclipse.jdt.core.IMember; //导入方法依赖的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

示例6: checkExistence

import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
private RefactoringStatus checkExistence(IMember member, PreconditionFailure failure) {
	if (member == null || !member.exists())
		return createError(failure, member);
	return new RefactoringStatus();
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:6,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java

示例7: create

import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
/**
 * Creates an status entry context for the given member
 *
 * @param member
 *            the java member for which the context is supposed to be
 *            created
 * @return the status entry context or <code>null</code> if the context
 *         cannot be created
 */
public static RefactoringStatusContext create(IMember member) {
	if (member == null || !member.exists()) {
		return null;
	}
	return new MemberSourceContext(member);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:16,代码来源:JavaStatusContext.java

示例8: create

import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
/**
 * Creates an status entry context for the given member
 *
 * @param member the java member for which the context is supposed to be created
 * @return the status entry context or <code>null</code> if the context cannot be created
 */
public static RefactoringStatusContext create(IMember member) {
  if (member == null || !member.exists()) return null;
  return new MemberSourceContext(member);
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:JavaStatusContext.java


注:本文中的org.eclipse.jdt.core.IMember.exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。