Search in sources :

Example 1 with MethodsSourcePositionComparator

use of org.eclipse.jdt.internal.corext.util.MethodsSourcePositionComparator in project che by eclipse.

the class IntroduceFactoryRefactoring method getUnimplementedMethods.

private IMethodBinding[] getUnimplementedMethods(ITypeBinding binding) {
    IMethodBinding[] unimplementedMethods = StubUtility2.getUnimplementedMethods(binding, true);
    Arrays.sort(unimplementedMethods, new MethodsSourcePositionComparator(binding));
    return unimplementedMethods;
}
Also used : IMethodBinding(org.eclipse.jdt.core.dom.IMethodBinding) MethodsSourcePositionComparator(org.eclipse.jdt.internal.corext.util.MethodsSourcePositionComparator)

Example 2 with MethodsSourcePositionComparator

use of org.eclipse.jdt.internal.corext.util.MethodsSourcePositionComparator in project che by eclipse.

the class AddUnimplementedMethodsOperation method getUnimplementedMethods.

private IMethodBinding[] getUnimplementedMethods(ASTNode typeNode) {
    ITypeBinding binding = null;
    boolean implementAbstractsOfInput = false;
    if (typeNode instanceof AnonymousClassDeclaration) {
        AnonymousClassDeclaration decl = (AnonymousClassDeclaration) typeNode;
        binding = decl.resolveBinding();
    } else if (typeNode instanceof AbstractTypeDeclaration) {
        AbstractTypeDeclaration decl = (AbstractTypeDeclaration) typeNode;
        binding = decl.resolveBinding();
    } else if (typeNode instanceof EnumConstantDeclaration) {
        EnumConstantDeclaration enumConstantDeclaration = (EnumConstantDeclaration) typeNode;
        if (enumConstantDeclaration.getAnonymousClassDeclaration() != null) {
            binding = enumConstantDeclaration.getAnonymousClassDeclaration().resolveBinding();
        } else {
            IVariableBinding varBinding = enumConstantDeclaration.resolveVariable();
            if (varBinding != null) {
                binding = varBinding.getDeclaringClass();
                implementAbstractsOfInput = true;
            }
        }
    }
    if (binding == null)
        return new IMethodBinding[0];
    IMethodBinding[] unimplementedMethods = StubUtility2.getUnimplementedMethods(binding, implementAbstractsOfInput);
    Arrays.sort(unimplementedMethods, new MethodsSourcePositionComparator(binding));
    return unimplementedMethods;
}
Also used : IMethodBinding(org.eclipse.jdt.core.dom.IMethodBinding) EnumConstantDeclaration(org.eclipse.jdt.core.dom.EnumConstantDeclaration) ITypeBinding(org.eclipse.jdt.core.dom.ITypeBinding) AnonymousClassDeclaration(org.eclipse.jdt.core.dom.AnonymousClassDeclaration) IVariableBinding(org.eclipse.jdt.core.dom.IVariableBinding) MethodsSourcePositionComparator(org.eclipse.jdt.internal.corext.util.MethodsSourcePositionComparator) AbstractTypeDeclaration(org.eclipse.jdt.core.dom.AbstractTypeDeclaration)

Aggregations

IMethodBinding (org.eclipse.jdt.core.dom.IMethodBinding)2 MethodsSourcePositionComparator (org.eclipse.jdt.internal.corext.util.MethodsSourcePositionComparator)2 AbstractTypeDeclaration (org.eclipse.jdt.core.dom.AbstractTypeDeclaration)1 AnonymousClassDeclaration (org.eclipse.jdt.core.dom.AnonymousClassDeclaration)1 EnumConstantDeclaration (org.eclipse.jdt.core.dom.EnumConstantDeclaration)1 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)1 IVariableBinding (org.eclipse.jdt.core.dom.IVariableBinding)1