• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java JdtFlags类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



JdtFlags类属于org.eclipse.jdt.internal.corext.util包,在下文中一共展示了JdtFlags类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:24,代码来源:NewMethodCorrectionProposal.java


示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:LambdaExpressionsFix.java


示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:ChangeSignatureProcessor.java


示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:ChangeSignatureProcessor.java


示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:RenameMethodProcessor.java


示例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()]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:RenameMethodProcessor.java


示例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));
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:RenameTypeProcessor.java


示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:RefactoringAvailabilityTester.java


示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:RefactoringAvailabilityTester.java


示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:RefactoringAvailabilityTester.java


示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:RefactoringAvailabilityTester.java


示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:RefactoringAvailabilityTester.java


示例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))));
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:IntroduceIndirectionRefactoring.java


示例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$
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:SelfEncapsulateFieldRefactoring.java


示例16: 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);
}
 
开发者ID:eclipse,项目名称:che,代码行数:33,代码来源:RefactoringScopeFactory.java


示例17: 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:eclipse,项目名称:che,代码行数:21,代码来源:ModifierCorrectionSubProcessor.java


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


示例19: addTypeParameters

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入依赖的package包/类
private static void addTypeParameters(final CompilationUnit unit, final IType type, final Map<String, ITypeBinding> map) throws JavaModelException {
	Assert.isNotNull(unit);
	Assert.isNotNull(type);
	Assert.isNotNull(map);
	final AbstractTypeDeclaration declaration= ASTNodeSearchUtil.getAbstractTypeDeclarationNode(type, unit);
	if (declaration instanceof TypeDeclaration) {
		ITypeBinding binding= null;
		TypeParameter parameter= null;
		for (final Iterator<TypeParameter> iterator= ((TypeDeclaration) declaration).typeParameters().iterator(); iterator.hasNext();) {
			parameter= iterator.next();
			binding= parameter.resolveBinding();
			if (binding != null && !map.containsKey(binding.getKey()))
				map.put(binding.getKey(), binding);
		}
		final IType declaring= type.getDeclaringType();
		if (declaring != null && !JdtFlags.isStatic(type))
			addTypeParameters(unit, declaring, map);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:MoveInnerToTopRefactoring.java


示例20: isGeneralizeTypeAvailable

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入依赖的package包/类
public static boolean isGeneralizeTypeAvailable(final IStructuredSelection selection) throws JavaModelException {
	if (selection.size() == 1) {
		final Object element= selection.getFirstElement();
		if (element instanceof IMethod) {
			final IMethod method= (IMethod) element;
			if (!method.exists())
				return false;
			final String type= method.getReturnType();
			if (PrimitiveType.toCode(Signature.toString(type)) == null)
				return Checks.isAvailable(method);
		} else if (element instanceof IField) {
			final IField field= (IField) element;
			if (!field.exists())
				return false;
			if (!JdtFlags.isEnum(field))
				return Checks.isAvailable(field);
		}
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:21,代码来源:RefactoringAvailabilityTester.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Max类代码示例发布时间:2022-05-22
下一篇:
Java StripesConstants类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap