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


Java JdtFlags.isPublic方法代码示例

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


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

示例1: isVisible

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private boolean isVisible(TypeNameMatch curr) {
	int flags= curr.getModifiers();
	if (Flags.isPrivate(flags)) {
		return false;
	}
	boolean isPublic;
	try {
		isPublic= JdtFlags.isPublic(curr.getType());
	} catch (JavaModelException e) {
		isPublic= Flags.isPublic(flags);
	}
	if (isPublic || Flags.isProtected(flags)) {
		return true;
	}
	return curr.getPackageName().equals(fCurrPackage.getElementName());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:17,代码来源:OrganizeImportsOperation.java

示例2: analyzeImportedTypes

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private void analyzeImportedTypes(IType[] types, RefactoringStatus result, IImportDeclaration imp)
    throws CoreException {
  for (int i = 0; i < types.length; i++) {
    // could this be a problem (same package imports)?
    if (JdtFlags.isPublic(types[i]) && types[i].getElementName().equals(getNewElementName())) {
      String msg =
          Messages.format(
              RefactoringCoreMessages.RenameTypeRefactoring_name_conflict1,
              new Object[] {
                JavaElementLabels.getElementLabel(
                    types[i], JavaElementLabels.ALL_FULLY_QUALIFIED),
                BasicElementLabels.getPathLabel(getCompilationUnit(imp).getPath(), false)
              });
      result.addError(msg, JavaStatusContext.create(imp));
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:RenameTypeProcessor.java

示例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));
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:PullUpRefactoringProcessor.java

示例4: filters

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
@Override
public boolean filters(JavaElementMatch match) {
  Object element = match.getElement();
  if (element instanceof IMember) {
    try {
      return !JdtFlags.isPublic((IMember) element);
    } catch (JavaModelException e) {
      JavaPlugin.log(e);
    }
  }
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:JavaMatchFilter.java

示例5: 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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:HierarchyProcessor.java

示例6: getNewModifiersForCopyInSubclass

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
int getNewModifiersForCopyInSubclass(int oldModifiers) throws JavaModelException {
	if (isFieldInfo())
		return oldModifiers;
	if (isToBeDeletedFromDeclaringClass())
		return oldModifiers;
	int modifiers= oldModifiers;
	if (isNewMethodToBeDeclaredAbstract()) {
		if (!JdtFlags.isPublic(fMember))
			modifiers= Modifier.PROTECTED | JdtFlags.clearAccessModifiers(modifiers);
	}
	return modifiers;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:PushDownRefactoringProcessor.java

示例7: getNewModifiersForOriginal

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
int getNewModifiersForOriginal(int oldModifiers) throws JavaModelException {
	if (isFieldInfo())
		return oldModifiers;
	if (isToBeDeletedFromDeclaringClass())
		return oldModifiers;
	int modifiers= oldModifiers;
	if (isNewMethodToBeDeclaredAbstract()) {
		modifiers= JdtFlags.clearFlag(Modifier.FINAL | Modifier.NATIVE, oldModifiers);
		modifiers|= Modifier.ABSTRACT;

		if (!JdtFlags.isPublic(fMember))
			modifiers= Modifier.PROTECTED | JdtFlags.clearAccessModifiers(modifiers);
	}
	return modifiers;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:PushDownRefactoringProcessor.java

示例8: isExtractableMember

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
/**
 * Is the specified member extractable from the type?
 *
 * @param member
 *            the member to test
 * @return <code>true</code> if the member is extractable,
 *         <code>false</code> otherwise
 * @throws JavaModelException
 *             if an error occurs
 */
protected static boolean isExtractableMember(final IMember member) throws JavaModelException {
	Assert.isNotNull(member);
	switch (member.getElementType()) {
		case IJavaElement.METHOD:
			return JdtFlags.isPublic(member) && !JdtFlags.isStatic(member) && !((IMethod) member).isConstructor();
		case IJavaElement.FIELD:
			return JdtFlags.isPublic(member) && JdtFlags.isStatic(member) && JdtFlags.isFinal(member) && !JdtFlags.isEnum(member);
		default:
			return false;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:ExtractInterfaceProcessor.java

示例9: canBeAccessedFrom

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
@Override
protected boolean canBeAccessedFrom(final IMember member, final IType target, final ITypeHierarchy hierarchy) throws JavaModelException {
	if (super.canBeAccessedFrom(member, target, hierarchy)) {
		if (target.isInterface())
			return true;
		if (target.equals(member.getDeclaringType()))
			return true;
		if (target.equals(member))
			return true;
		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 (!canBeAccessedFrom(declaringType, target, hierarchy))
			return false;
		if (declaringType.equals(getDeclaringType()))
			return false;
		return true;
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:39,代码来源:PullUpRefactoringProcessor.java

示例10: 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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:PullUpRefactoringProcessor.java

示例11: analyzeImportedTypes

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private void analyzeImportedTypes(IType[] types, RefactoringStatus result, IImportDeclaration imp) throws CoreException {
	for (int i= 0; i < types.length; i++) {
		//could this be a problem (same package imports)?
		if (JdtFlags.isPublic(types[i]) && types[i].getElementName().equals(getNewElementName())){
			String msg= Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_name_conflict1,
																		new Object[]{ JavaElementLabels.getElementLabel(types[i], JavaElementLabels.ALL_FULLY_QUALIFIED), BasicElementLabels.getPathLabel(getCompilationUnit(imp).getPath(), false)});
			result.addError(msg, JavaStatusContext.create(imp));
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:RenameTypeProcessor.java

示例12: filters

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
@Override
public boolean filters(JavaElementMatch match) {
	Object element= match.getElement();
	if (element instanceof IMember) {
		try {
			return ! JdtFlags.isPublic((IMember) element);
		} catch (JavaModelException e) {
			JavaPlugin.log(e);
		}
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:JavaMatchFilter.java

示例13: 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


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