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


Java JdtFlags.isAbstract方法代码示例

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


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

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

示例2: getOverrideIndicators

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
/**
 * Note: This method is for internal use only. Clients should not call this method.
 * 
 * @param method The element to decorate
 * @return Resulting decorations (combination of JavaElementImageDescriptor.IMPLEMENTS and
 *         JavaElementImageDescriptor.OVERRIDES)
 * @throws JavaModelException if accessing a Java Model element fails
 * @noreference This method is not intended to be referenced by clients.
 */
protected int getOverrideIndicators(IMethod method) throws JavaModelException {
	CompilationUnit astRoot= SharedASTProvider.getAST(method.getTypeRoot(), SharedASTProvider.WAIT_ACTIVE_ONLY, null);
	if (astRoot != null) {
		int res= findInHierarchyWithAST(astRoot, method);
		if (res != -1) {
			return res;
		}
	}

	IType type= method.getDeclaringType();

	MethodOverrideTester methodOverrideTester= SuperTypeHierarchyCache.getMethodOverrideTester(type);
	IMethod defining= methodOverrideTester.findOverriddenMethod(method, true);
	if (defining != null) {
		if (JdtFlags.isAbstract(defining)) {
			return JavaElementImageDescriptor.IMPLEMENTS;
		} else {
			return JavaElementImageDescriptor.OVERRIDES;
		}
	}
	return 0;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:32,代码来源:OverrideIndicatorLabelDecorator.java

示例3: getAffectedSubTypes

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private static Set<IType> getAffectedSubTypes(final ITypeHierarchy hierarchy, final IType type) throws JavaModelException {
	 IType[] types= null;
	 final boolean isInterface= type.isInterface();
	if (isInterface) {
		 final Collection<IType> remove= new ArrayList<IType>();
		 final List<IType> list= new ArrayList<IType>(Arrays.asList(hierarchy.getSubtypes(type)));
		 for (final Iterator<IType> iterator= list.iterator(); iterator.hasNext();) {
            final IType element= iterator.next();
            if (element.isInterface())
            	remove.add(element);
           }
		 list.removeAll(remove);
		 types= list.toArray(new IType[list.size()]);
	 } else
		 types= hierarchy.getSubclasses(type);
	final Set<IType> result= new HashSet<IType>();
	for (int index= 0; index < types.length; index++) {
		if (!isInterface && JdtFlags.isAbstract(types[index]))
			result.addAll(getAffectedSubTypes(hierarchy, types[index]));
		else
			result.add(types[index]);
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:PullUpRefactoringProcessor.java

示例4: findInHierarchyWithAST

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private int findInHierarchyWithAST(CompilationUnit astRoot, IMethod method) throws JavaModelException {
	ASTNode node= NodeFinder.perform(astRoot, method.getNameRange());
	if (node instanceof SimpleName && node.getParent() instanceof MethodDeclaration) {
		IMethodBinding binding= ((MethodDeclaration) node.getParent()).resolveBinding();
		if (binding != null) {
			IMethodBinding defining= Bindings.findOverriddenMethod(binding, true);
			if (defining != null) {
				if (JdtFlags.isAbstract(defining)) {
					return JavaElementImageDescriptor.IMPLEMENTS;
				} else {
					return JavaElementImageDescriptor.OVERRIDES;
				}
			}
			return 0;
		}
	}
	return -1;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:OverrideIndicatorLabelDecorator.java

示例5: isInterfaceMigrationAvailable

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
public static boolean isInterfaceMigrationAvailable(IMethod method, boolean allowConcreteClasses,
		Optional<IProgressMonitor> monitor) throws JavaModelException {
	if (!Checks.isAvailable(method))
		return false;
	if (method.isConstructor())
		return false;
	if (JdtFlags.isNative(method))
		return false;
	if (JdtFlags.isStatic(method))
		return false;
	if (JdtFlags.isAbstract(method))
		return false;
	// TODO: Should this be here?
	if (JdtFlags.isSynchronized(method))
		return false;
	// TODO: Should this be here?
	if (JdtFlags.isFinal(method))
		return false;
	if (method.getResource().isDerived(IResource.CHECK_ANCESTORS))
		return false;

	final IType declaring = method.getDeclaringType();
	if (declaring != null)
		if (declaring.isInterface())
			return false; // Method is already in an interface
		else if (!allowConcreteClasses && !Flags.isAbstract(declaring.getFlags()))
			return false; // no concrete types allowed.

	// ensure that there is a target method.
	IMethod targetMethod = MigrateSkeletalImplementationToInterfaceRefactoringProcessor.getTargetMethod(method,
			monitor);
	if (targetMethod == null) // no possible target.
		return false;

	return true;
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:37,代码来源:RefactoringAvailabilityTester.java

示例6: mustAnalyzeAstOfDeclaringCu

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private boolean mustAnalyzeAstOfDeclaringCu() throws JavaModelException{
	if (JdtFlags.isAbstract(getMethod()))
		return false;
	else if (JdtFlags.isNative(getMethod()))
		return false;
	else if (getMethod().getDeclaringType().isInterface())
		return false;
	else
		return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:11,代码来源:ChangeSignatureProcessor.java

示例7: checkFinalConditions

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context) throws CoreException, OperationCanceledException {
	try {
		monitor.beginTask(RefactoringCoreMessages.PushDownRefactoring_checking, 5);
		clearCaches();
		ICompilationUnit unit= getDeclaringType().getCompilationUnit();
		if (fLayer)
			unit= unit.findWorkingCopy(fOwner);
		resetWorkingCopies(unit);
		final RefactoringStatus result= new RefactoringStatus();
		result.merge(checkMembersInDestinationClasses(new SubProgressMonitor(monitor, 1)));
		result.merge(checkElementsAccessedByModifiedMembers(new SubProgressMonitor(monitor, 1)));
		result.merge(checkReferencesToPushedDownMembers(new SubProgressMonitor(monitor, 1)));
		if (!JdtFlags.isAbstract(getDeclaringType()) && getAbstractDeclarationInfos().length != 0)
			result.merge(checkConstructorCalls(getDeclaringType(), new SubProgressMonitor(monitor, 1)));
		else
			monitor.worked(1);
		if (result.hasFatalError())
			return result;
		List<IMember> members= new ArrayList<IMember>(fMemberInfos.length);
		for (int index= 0; index < fMemberInfos.length; index++) {
			if (fMemberInfos[index].getAction() != MemberActionInfo.NO_ACTION)
				members.add(fMemberInfos[index].getMember());
		}
		fMembersToMove= members.toArray(new IMember[members.size()]);
		fChangeManager= createChangeManager(new SubProgressMonitor(monitor, 1), result);
		if (result.hasFatalError())
			return result;

		Checks.addModifiedFilesToChecker(ResourceUtil.getFiles(fChangeManager.getAllCompilationUnits()), context);

		return result;
	} finally {
		monitor.done();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:40,代码来源:PushDownRefactoringProcessor.java

示例8: declareMethodAbstract

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private void declareMethodAbstract(MemberActionInfo info, CompilationUnitRewrite sourceRewrite, CompilationUnitRewrite unitRewrite) throws JavaModelException {
	Assert.isTrue(!info.isFieldInfo());
	IMethod method= (IMethod) info.getMember();
	if (JdtFlags.isAbstract(method))
		return;
	final MethodDeclaration declaration= ASTNodeSearchUtil.getMethodDeclarationNode(method, sourceRewrite.getRoot());
	unitRewrite.getASTRewrite().remove(declaration.getBody(), null);
	sourceRewrite.getImportRemover().registerRemovedNode(declaration.getBody());
	ModifierRewrite.create(unitRewrite.getASTRewrite(), declaration).setModifiers(info.getNewModifiersForOriginal(declaration.getModifiers()), null);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:PushDownRefactoringProcessor.java

示例9: getAbstractMethodsToPullUp

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private IMethod[] getAbstractMethodsToPullUp() throws JavaModelException {
	final List<IMember> result= new ArrayList<IMember>(fMembersToMove.length);
	for (int i= 0; i < fMembersToMove.length; i++) {
		final IMember member= fMembersToMove[i];
		if (member instanceof IMethod && JdtFlags.isAbstract(member))
			result.add(member);
	}
	return result.toArray(new IMethod[result.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:10,代码来源:PullUpRefactoringProcessor.java

示例10: getAffectedMemberInfos

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private MemberActionInfo[] getAffectedMemberInfos() throws JavaModelException {
	List<MemberActionInfo> result= new ArrayList<MemberActionInfo>(fMemberInfos.length);
	for (int i= 0; i < fMemberInfos.length; i++) {
		MemberActionInfo info= fMemberInfos[i];
		if (info.isToBeCreatedInSubclassesOfDeclaringClass() && !JdtFlags.isAbstract(info.getMember()))
			result.add(info);
	}
	return result.toArray(new MemberActionInfo[result.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:PushDownRefactoringProcessor.java

示例11: checkFinalConditions

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public RefactoringStatus checkFinalConditions(final IProgressMonitor monitor, final CheckConditionsContext context) throws CoreException, OperationCanceledException {
	try {
		monitor.beginTask(RefactoringCoreMessages.PullUpRefactoring_checking, 12);
		clearCaches();

		final RefactoringStatus result= new RefactoringStatus();
		result.merge(createWorkingCopyLayer(new SubProgressMonitor(monitor, 4)));
		if (result.hasFatalError())
			return result;
		if (monitor.isCanceled())
			throw new OperationCanceledException();
		result.merge(checkGenericDeclaringType(new SubProgressMonitor(monitor, 1)));
		result.merge(checkFinalFields(new SubProgressMonitor(monitor, 1)));
		if (monitor.isCanceled())
			throw new OperationCanceledException();
		result.merge(checkAccesses(new SubProgressMonitor(monitor, 1)));
		result.merge(checkMembersInTypeAndAllSubtypes(new SubProgressMonitor(monitor, 2)));
		result.merge(checkIfSkippingOverElements(new SubProgressMonitor(monitor, 1)));
		if (monitor.isCanceled())
			throw new OperationCanceledException();
		if (!JdtFlags.isAbstract(getDestinationType()) && getAbstractMethods().length > 0)
			result.merge(checkConstructorCalls(getDestinationType(), new SubProgressMonitor(monitor, 1)));
		else
			monitor.worked(1);
		if (result.hasFatalError())
			return result;
		fCompilationUnitRewrites= new HashMap<ICompilationUnit, CompilationUnitRewrite>(3);
		result.merge(checkProjectCompliance(getCompilationUnitRewrite(fCompilationUnitRewrites, getDeclaringType().getCompilationUnit()), getDestinationType(), fMembersToMove));
		fChangeManager= createChangeManager(new SubProgressMonitor(monitor, 1), result);

		Checks.addModifiedFilesToChecker(ResourceUtil.getFiles(fChangeManager.getAllCompilationUnits()), context);

		return result;
	} finally {
		monitor.done();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:42,代码来源:PullUpRefactoringProcessor.java

示例12: getAbstractMemberInfos

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private MemberActionInfo[] getAbstractMemberInfos() throws JavaModelException {
	List<MemberActionInfo> result= new ArrayList<MemberActionInfo>(fMemberInfos.length);
	for (int index= 0; index < fMemberInfos.length; index++) {
		MemberActionInfo info= fMemberInfos[index];
		if (info.isToBeCreatedInSubclassesOfDeclaringClass() && JdtFlags.isAbstract(info.getMember()))
			result.add(info);
	}
	return result.toArray(new MemberActionInfo[result.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:10,代码来源:PushDownRefactoringProcessor.java

示例13: checkRemoval

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
public static RefactoringStatus checkRemoval(IMethod sourceMethod, IType destinationInterface, IType typeToRemove,
		Set<IMethod> methodsToMigrate, Optional<IProgressMonitor> monitor) throws JavaModelException {
	RefactoringStatus status = new RefactoringStatus();
	monitor.ifPresent(m -> m.beginTask("Checking if type can be removed ...", IProgressMonitor.UNKNOWN));
	try {
		// TODO: Add code to also remove concrete types #25.
		if (!JdtFlags.isAbstract(typeToRemove))
			status.addError("For now, can only remove abstact skeletal implementation classes.",
					new RefactoringStatusContext() {

						@Override
						public Object getCorrespondingElement() {
							return typeToRemove;
						}
					});

		if (!willBeEmpty(typeToRemove, methodsToMigrate))
			status.addError("The skeletal implementation class is not empty after migrating methods.",
					new RefactoringStatusContext() {

						@Override
						public Object getCorrespondingElement() {
							return typeToRemove;
						}
					});

		if (!superClassImplementsDestinationInterface(typeToRemove, destinationInterface,
				monitor.map(m -> new SubProgressMonitor(m, IProgressMonitor.UNKNOWN))))
			status.addError(
					"The skeletal implementation class has a superclass that does not implement the destination interface.",
					new RefactoringStatusContext() {

						@Override
						public Object getCorrespondingElement() {
							try {
								return typeToRemove.newSupertypeHierarchy(new NullProgressMonitor())
										.getSuperclass(typeToRemove);
							} catch (JavaModelException e) {
								throw new RuntimeException(e);
							}
						}
					});

		// if the type to remove doesn't have a superclass and its subtypes
		// contain super references.
		if (typeToRemove.getSuperclassName() == null && subclassesContainSuperReferences(sourceMethod, typeToRemove,
				monitor.map(m -> new SubProgressMonitor(m, IProgressMonitor.UNKNOWN))))
			status.addError(
					"The skeletal implementation class has no superclass but its subtypes contain references to super.",
					new RefactoringStatusContext() {

						@Override
						public Object getCorrespondingElement() {
							return typeToRemove;
						}
					});
	} finally {
		monitor.ifPresent(IProgressMonitor::done);
	}
	return status;
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:62,代码来源:SkeletalImplementatonClassRemovalUtils.java

示例14: mustAnalyzeAstOfDeclaringCu

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private boolean mustAnalyzeAstOfDeclaringCu() throws JavaModelException {
  if (JdtFlags.isAbstract(getMethod())) return false;
  else if (JdtFlags.isNative(getMethod())) return false;
  else if (getMethod().getDeclaringType().isInterface()) return false;
  else return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:7,代码来源:ChangeSignatureProcessor.java

示例15: createChangeManager

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private TextEditBasedChangeManager createChangeManager(final IProgressMonitor monitor, final RefactoringStatus status) throws CoreException {
	Assert.isNotNull(monitor);
	Assert.isNotNull(status);
	try {
		monitor.beginTask(RefactoringCoreMessages.PushDownRefactoring_checking, 7);
		final ICompilationUnit source= getDeclaringType().getCompilationUnit();
		final CompilationUnitRewrite sourceRewriter= new CompilationUnitRewrite(source);
		final Map<ICompilationUnit, CompilationUnitRewrite> rewrites= new HashMap<ICompilationUnit, CompilationUnitRewrite>(2);
		rewrites.put(source, sourceRewriter);
		IType[] types= getHierarchyOfDeclaringClass(new SubProgressMonitor(monitor, 1)).getSubclasses(getDeclaringType());
		final Set<ICompilationUnit> result= new HashSet<ICompilationUnit>(types.length + 1);
		for (int index= 0; index < types.length; index++) {
			ICompilationUnit cu= types[index].getCompilationUnit();
			if (cu != null) { // subclasses can be in binaries
				result.add(cu);
			}
		}
		result.add(source);
		final Map<IMember, IncomingMemberVisibilityAdjustment> adjustments= new HashMap<IMember, IncomingMemberVisibilityAdjustment>();
		final List<MemberVisibilityAdjustor> adjustors= new ArrayList<MemberVisibilityAdjustor>();
		final ICompilationUnit[] units= result.toArray(new ICompilationUnit[result.size()]);
		ICompilationUnit unit= null;
		CompilationUnitRewrite rewrite= null;
		final IProgressMonitor sub= new SubProgressMonitor(monitor, 4);
		try {
			sub.beginTask(RefactoringCoreMessages.PushDownRefactoring_checking, units.length * 4);
			for (int index= 0; index < units.length; index++) {
				unit= units[index];
				rewrite= getCompilationUnitRewrite(rewrites, unit);
				if (unit.equals(sourceRewriter.getCu())) {
					final AbstractTypeDeclaration declaration= ASTNodeSearchUtil.getAbstractTypeDeclarationNode(getDeclaringType(), rewrite.getRoot());
					if (!JdtFlags.isAbstract(getDeclaringType()) && getAbstractDeclarationInfos().length != 0)
						ModifierRewrite.create(rewrite.getASTRewrite(), declaration).setModifiers((Modifier.ABSTRACT | declaration.getModifiers()), rewrite.createCategorizedGroupDescription(RefactoringCoreMessages.PushDownRefactoring_make_abstract, SET_PUSH_DOWN));
					deleteDeclarationNodes(sourceRewriter, false, rewrite, Arrays.asList(getDeletableMembers()), SET_PUSH_DOWN);
					MemberActionInfo[] methods= getAbstractDeclarationInfos();
					for (int offset= 0; offset < methods.length; offset++)
						declareMethodAbstract(methods[offset], sourceRewriter, rewrite);
				}
				final IMember[] members= getAbstractMembers(getAbstractDestinations(new SubProgressMonitor(monitor, 1)));
				final IType[] classes= new IType[members.length];
				for (int offset= 0; offset < members.length; offset++)
					classes[offset]= (IType) members[offset];
				copyMembers(adjustors, adjustments, rewrites, status, getAbstractMemberInfos(), classes, sourceRewriter, rewrite, sub);
				copyMembers(adjustors, adjustments, rewrites, status, getAffectedMemberInfos(), getAbstractDestinations(new SubProgressMonitor(monitor, 1)), sourceRewriter, rewrite, sub);
				if (monitor.isCanceled())
					throw new OperationCanceledException();
			}
		} finally {
			sub.done();
		}
		if (!adjustors.isEmpty() && !adjustments.isEmpty()) {
			final MemberVisibilityAdjustor adjustor= adjustors.get(0);
			adjustor.rewriteVisibility(new SubProgressMonitor(monitor, 1));
		}
		final TextEditBasedChangeManager manager= new TextEditBasedChangeManager();
		for (final Iterator<ICompilationUnit> iterator= rewrites.keySet().iterator(); iterator.hasNext();) {
			unit= iterator.next();
			rewrite= rewrites.get(unit);
			if (rewrite != null)
				manager.manage(unit, rewrite.createChange(true));
		}
		return manager;
	} finally {
		monitor.done();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:67,代码来源:PushDownRefactoringProcessor.java


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