本文整理汇总了Java中org.eclipse.jdt.internal.corext.util.JdtFlags类的典型用法代码示例。如果您正苦于以下问题:Java JdtFlags类的具体用法?Java JdtFlags怎么用?Java JdtFlags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JdtFlags类属于org.eclipse.jdt.internal.corext.util包,在下文中一共展示了JdtFlags类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例2: getInterfaceMethodModifiers
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入依赖的package包/类
private int getInterfaceMethodModifiers(ASTNode targetTypeDecl, boolean createAbstractMethod) {
// for interface and annotation members copy the modifiers from an existing member
if (targetTypeDecl instanceof TypeDeclaration) {
TypeDeclaration type= (TypeDeclaration) targetTypeDecl;
MethodDeclaration[] methodDecls= type.getMethods();
if (methodDecls.length > 0) {
if (createAbstractMethod) {
for (MethodDeclaration methodDeclaration : methodDecls) {
IMethodBinding methodBinding= methodDeclaration.resolveBinding();
if (methodBinding != null && JdtFlags.isAbstract(methodBinding)) {
return methodDeclaration.getModifiers();
}
}
}
return methodDecls[0].getModifiers() & Modifier.PUBLIC;
}
List<BodyDeclaration> bodyDecls= type.bodyDeclarations();
if (bodyDecls.size() > 0) {
return bodyDecls.get(0).getModifiers() & Modifier.PUBLIC;
}
}
return 0;
}
示例3: visit
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入依赖的package包/类
@Override
public boolean visit(MethodInvocation node) {
IMethodBinding binding = node.resolveMethodBinding();
if (binding != null
&& !JdtFlags.isStatic(binding)
&& node.getExpression() == null
&& Bindings.isSuperType(binding.getDeclaringClass(), fFunctionalInterface, false))
throw new AbortSearchException();
return true;
}
示例4: checkOriginalVarargs
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入依赖的package包/类
private RefactoringStatus checkOriginalVarargs() throws JavaModelException {
if (JdtFlags.isVarargs(fMethod)) fOldVarargIndex = fMethod.getNumberOfParameters() - 1;
List<ParameterInfo> notDeletedInfos = getNotDeletedInfos();
for (int i = 0; i < notDeletedInfos.size(); i++) {
ParameterInfo info = notDeletedInfos.get(i);
if (info.isOldVarargs() && !info.isNewVarargs())
return RefactoringStatus.createFatalErrorStatus(
Messages.format(
RefactoringCoreMessages.ChangeSignatureRefactoring_cannot_convert_vararg,
BasicElementLabels.getJavaElementName(info.getNewName())));
if (i != notDeletedInfos.size() - 1) {
// not the last parameter
if (info.isNewVarargs())
return RefactoringStatus.createFatalErrorStatus(
Messages.format(
RefactoringCoreMessages.ChangeSignatureRefactoring_vararg_must_be_last,
BasicElementLabels.getJavaElementName(info.getNewName())));
}
}
return null;
}
示例5: checkNativeMethods
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入依赖的package包/类
private RefactoringStatus checkNativeMethods() throws JavaModelException {
RefactoringStatus result = new RefactoringStatus();
for (int i = 0; i < fRippleMethods.length; i++) {
if (JdtFlags.isNative(fRippleMethods[i])) {
String message =
Messages.format(
RefactoringCoreMessages.ChangeSignatureRefactoring_native,
new String[] {
JavaElementUtil.createMethodSignature(fRippleMethods[i]),
BasicElementLabels.getJavaElementName(
fRippleMethods[i].getDeclaringType().getFullyQualifiedName('.'))
});
result.addError(message, JavaStatusContext.create(fRippleMethods[i]));
}
}
return result;
}
示例6: checkInitialConditions
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入依赖的package包/类
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
if (!fMethod.exists()) {
String message =
Messages.format(
RefactoringCoreMessages.RenameMethodRefactoring_deleted,
BasicElementLabels.getFileName(fMethod.getCompilationUnit()));
return RefactoringStatus.createFatalErrorStatus(message);
}
RefactoringStatus result = Checks.checkAvailability(fMethod);
if (result.hasFatalError()) return result;
result.merge(Checks.checkIfCuBroken(fMethod));
if (JdtFlags.isNative(fMethod))
result.addError(RefactoringCoreMessages.RenameMethodRefactoring_no_native);
return result;
}
示例7: 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()]);
}
示例8: 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));
}
}
}
示例9: isExtractSupertypeAvailable
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入依赖的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;
}
示例10: isGeneralizeTypeAvailable
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入依赖的package包/类
public static boolean isGeneralizeTypeAvailable(final IJavaElement element)
throws JavaModelException {
if (element != null && element.exists()) {
String type = null;
if (element instanceof IMethod) type = ((IMethod) element).getReturnType();
else if (element instanceof IField) {
final IField field = (IField) element;
if (JdtFlags.isEnum(field)) return false;
type = field.getTypeSignature();
} else if (element instanceof ILocalVariable) return true;
else if (element instanceof IType) {
final IType clazz = (IType) element;
if (JdtFlags.isEnum(clazz)) return false;
return true;
}
if (type == null || PrimitiveType.toCode(Signature.toString(type)) != null) return false;
return true;
}
return false;
}
示例11: isMoveStaticAvailable
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入依赖的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;
}
示例12: isPullUpAvailable
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入依赖的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;
}
示例13: isPushDownAvailable
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入依赖的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;
}
示例14: addAdjustment
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入依赖的package包/类
private void addAdjustment(
IMember whoToAdjust,
ModifierKeyword neededVisibility,
Map<IMember, IncomingMemberVisibilityAdjustment> adjustments)
throws JavaModelException {
ModifierKeyword currentVisibility =
ModifierKeyword.fromFlagValue(JdtFlags.getVisibilityCode(whoToAdjust));
if (MemberVisibilityAdjustor.hasLowerVisibility(currentVisibility, neededVisibility)
&& MemberVisibilityAdjustor.needsVisibilityAdjustments(
whoToAdjust, neededVisibility, adjustments))
adjustments.put(
whoToAdjust,
new MemberVisibilityAdjustor.IncomingMemberVisibilityAdjustment(
whoToAdjust,
neededVisibility,
RefactoringStatus.createWarningStatus(
Messages.format(
MemberVisibilityAdjustor.getMessage(whoToAdjust),
new String[] {
MemberVisibilityAdjustor.getLabel(whoToAdjust),
MemberVisibilityAdjustor.getLabel(neededVisibility)
}),
JavaStatusContext.create(whoToAdjust))));
}
示例15: checkArgName
import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入依赖的package包/类
private void checkArgName() {
String fieldName = fField.getElementName();
boolean isStatic = true;
try {
isStatic = JdtFlags.isStatic(fField);
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
if ((isStatic
&& fArgName.equals(fieldName)
&& fieldName.equals(fField.getDeclaringType().getElementName()))
|| JavaConventionsUtil.validateIdentifier(fArgName, fField).getSeverity()
== IStatus.ERROR) {
fArgName = "_" + fArgName; // $NON-NLS-1$
}
}