Java Code Examples for org.eclipse.jdt.core.dom.Modifier#isAbstract()

The following examples show how to use org.eclipse.jdt.core.dom.Modifier#isAbstract() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElementTypeTeller.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
public static boolean isAbstract(TypeDeclaration typeDeclaration) {
	for (Object elem : typeDeclaration.modifiers()) {
		IExtendedModifier extendedModifier = (IExtendedModifier) elem;
		if (extendedModifier.isModifier()) {
			Modifier modifier = (Modifier) extendedModifier;
			if (modifier.isAbstract()) {
				return true;
			}
		}
	}
	return false;
}
 
Example 2
Source File: GenerateHashCodeEqualsAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private RefactoringStatus checkHashCodeEqualsExists(ITypeBinding someType, boolean superClass) {

		RefactoringStatus status= new RefactoringStatus();
		HashCodeEqualsInfo info= getTypeInfo(someType, true);

		String concreteTypeWarning= superClass ? ActionMessages.GenerateMethodAbstractAction_super_class : ActionMessages.GenerateHashCodeEqualsAction_field_type;
		String concreteMethWarning= (someType.isInterface() || Modifier.isAbstract(someType.getModifiers()))
				? ActionMessages.GenerateHashCodeEqualsAction_interface_does_not_declare_hashCode_equals_error
				: ActionMessages.GenerateHashCodeEqualsAction_type_does_not_implement_hashCode_equals_error;
		String concreteHCEWarning= null;

		if (!info.foundEquals && (!info.foundHashCode))
			concreteHCEWarning= ActionMessages.GenerateHashCodeEqualsAction_equals_and_hashCode;
		else if (!info.foundEquals)
			concreteHCEWarning= ActionMessages.GenerateHashCodeEqualsAction_equals;
		else if (!info.foundHashCode)
			concreteHCEWarning= ActionMessages.GenerateHashCodeEqualsAction_hashCode;

		if (!info.foundEquals || !info.foundHashCode)
			status.addWarning(Messages.format(concreteMethWarning, new String[] {
					Messages.format(concreteTypeWarning, BindingLabelProvider.getBindingLabel(someType, JavaElementLabels.ALL_FULLY_QUALIFIED)), concreteHCEWarning }),
					createRefactoringStatusContext(someType.getJavaElement()));

		if (superClass && (info.foundFinalEquals || info.foundFinalHashCode)) {
			status.addError(Messages.format(ActionMessages.GenerateMethodAbstractAction_final_method_in_superclass_error, new String[] {
					Messages.format(concreteTypeWarning, BasicElementLabels.getJavaElementName(someType.getQualifiedName())), ActionMessages.GenerateHashCodeEqualsAction_hashcode_or_equals }),
					createRefactoringStatusContext(someType.getJavaElement()));
		}

		return status;
	}
 
Example 3
Source File: GenerateHashCodeEqualsOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean needsNoSuperCall(ITypeBinding typeBinding, String name, ITypeBinding[] parameters) {
	Assert.isNotNull(typeBinding);
	IMethodBinding binding= Bindings.findMethodInHierarchy(typeBinding.getSuperclass(), name, parameters);
	if (binding != null && !Modifier.isAbstract(binding.getModifiers())) {
		ITypeBinding declaring= binding.getDeclaringClass();
		return declaring.getQualifiedName().equals(JAVA_LANG_OBJECT);
	}
	return true;
}
 
Example 4
Source File: JdtFlags.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static boolean isDefaultMethod(IMethodBinding method) {
	int modifiers= method.getModifiers();
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=405517#c7
	ITypeBinding declaringClass= method.getDeclaringClass();
	if (declaringClass.isInterface()) {
		return !Modifier.isAbstract(modifiers) && !Modifier.isStatic(modifiers);
	}
	return false;
}
 
Example 5
Source File: IntroduceFactoryRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException {
	try {
		pm.beginTask(RefactoringCoreMessages.IntroduceFactory_checking_preconditions, 1);
		RefactoringStatus result= new RefactoringStatus();

		if (fFactoryClassName != null)
			result.merge(setFactoryClass(fFactoryClassName));
		if (result.hasFatalError())
			return result;
		fArgTypes= fCtorBinding.getParameterTypes();
		fCtorIsVarArgs= fCtorBinding.isVarargs();
		fAllCallsTo= findAllCallsTo(fCtorBinding, pm, result);
		fFormalArgNames= findCtorArgNames();

		ICompilationUnit[]	affectedFiles= collectAffectedUnits(fAllCallsTo);
		result.merge(Checks.validateModifiesFiles(ResourceUtil.getFiles(affectedFiles), getValidationContext()));

		if (fCallSitesInBinaryUnits)
			result.merge(RefactoringStatus.createWarningStatus(RefactoringCoreMessages.IntroduceFactory_callSitesInBinaryClass));

		if(Modifier.isAbstract(fCtorBinding.getDeclaringClass().getModifiers())){
			result.merge(RefactoringStatus.createWarningStatus(RefactoringCoreMessages.IntroduceFactory_abstractClass));
		}

		return result;
	} finally {
		pm.done();
	}
}
 
Example 6
Source File: BindingLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static int getAdornmentFlags(IBinding binding) {
	int adornments= 0;
	final int modifiers= binding.getModifiers();
	if (Modifier.isAbstract(modifiers))
		adornments|= JavaElementImageDescriptor.ABSTRACT;
	if (Modifier.isFinal(modifiers))
		adornments|= JavaElementImageDescriptor.FINAL;
	if (Modifier.isStatic(modifiers))
		adornments|= JavaElementImageDescriptor.STATIC;
	
	if (binding.isDeprecated())
		adornments|= JavaElementImageDescriptor.DEPRECATED;
	
	if (binding instanceof IMethodBinding) {
		if (((IMethodBinding) binding).isConstructor())
			adornments|= JavaElementImageDescriptor.CONSTRUCTOR;
		if (Modifier.isSynchronized(modifiers))
			adornments|= JavaElementImageDescriptor.SYNCHRONIZED;
		if (Modifier.isNative(modifiers))
			adornments|= JavaElementImageDescriptor.NATIVE;
		ITypeBinding type= ((IMethodBinding) binding).getDeclaringClass();
		if (type.isInterface() && !Modifier.isAbstract(modifiers) && !Modifier.isStatic(modifiers))
			adornments|= JavaElementImageDescriptor.DEFAULT_METHOD;
		if (((IMethodBinding) binding).getDefaultValue() != null)
			adornments|= JavaElementImageDescriptor.ANNOTATION_DEFAULT;
	}
	if (binding instanceof IVariableBinding && ((IVariableBinding) binding).isField()) {
		if (Modifier.isTransient(modifiers))
			adornments|= JavaElementImageDescriptor.TRANSIENT;
		if (Modifier.isVolatile(modifiers))
			adornments|= JavaElementImageDescriptor.VOLATILE;
	}
	return adornments;
}
 
Example 7
Source File: InJavaImporter.java    From jdt2famix with Eclipse Public License 1.0 5 votes vote down vote up
private void extractBasicModifiersFromBinding(int modifiers, NamedEntity entity) {
	Boolean publicModifier = Modifier.isPublic(modifiers);
	Boolean protectedModifier = Modifier.isProtected(modifiers);
	Boolean privateModifier = Modifier.isPrivate(modifiers);
	if (publicModifier)
		entity.addModifiers("public");
	if (protectedModifier)
		entity.addModifiers("protected");
	if (privateModifier)
		entity.addModifiers("private");
	if (!(publicModifier || protectedModifier || privateModifier))
		entity.addModifiers("package");
	if (Modifier.isFinal(modifiers))
		entity.addModifiers("final");
	if (Modifier.isAbstract(modifiers))
		entity.addModifiers("abstract");
	if (Modifier.isNative(modifiers))
		entity.addModifiers("native");
	if (Modifier.isSynchronized(modifiers))
		entity.addModifiers("synchronized");
	if (Modifier.isTransient(modifiers))
		entity.addModifiers("transient");
	if (Modifier.isVolatile(modifiers))
		entity.addModifiers("volatile");
	/*
	 * We do not extract the static modifier here because we want to set the
	 * hasClassScope property and we do that specifically only for attributes and
	 * methods
	 */
}
 
Example 8
Source File: NumberOfMethods.java    From ck with Apache License 2.0 5 votes vote down vote up
@Override
public void visit(MethodDeclaration node) {
	methods++;

	// visibility
	boolean isPublic = Modifier.isPublic(node.getModifiers());
	boolean isPrivate = Modifier.isPrivate(node.getModifiers());
	boolean isProtected = Modifier.isProtected(node.getModifiers());

	if(isPublic)
		publicMethods++;
	else if(isPrivate)
		privateMethods++;
	else if(isProtected)
		protectedMethods++;
	else
		defaultMethods++;

	// other characteristics

	boolean isFinal = Modifier.isFinal(node.getModifiers());
	boolean isSynchronized = Modifier.isSynchronized(node.getModifiers());
	boolean isAbstract = Modifier.isAbstract(node.getModifiers());
	boolean isStatic = Modifier.isStatic(node.getModifiers());

	if(isStatic)
		staticMethods++;

	if(isAbstract)
		abstractMethods++;

	if(isFinal)
		finalMethods++;

	if(isSynchronized)
		synchronizedMethods++;
}
 
Example 9
Source File: ASTFlattenerUtils.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public boolean isLambdaCase(final ClassInstanceCreation creation) {
  final AnonymousClassDeclaration anonymousClazz = creation.getAnonymousClassDeclaration();
  if (((anonymousClazz != null) && (anonymousClazz.bodyDeclarations().size() == 1))) {
    final Object declaredMethod = anonymousClazz.bodyDeclarations().get(0);
    if (((declaredMethod instanceof MethodDeclaration) && (creation.getType().resolveBinding() != null))) {
      final IMethodBinding methodBinding = ((MethodDeclaration) declaredMethod).resolveBinding();
      if ((methodBinding != null)) {
        final IMethodBinding overrides = this.findOverride(methodBinding, methodBinding.getDeclaringClass(), true);
        return ((overrides != null) && Modifier.isAbstract(overrides.getModifiers()));
      }
    }
  }
  return false;
}
 
Example 10
Source File: OverrideMethodsOperation.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private static OverridableMethod convertToSerializableMethod(IMethodBinding binding, boolean unimplemented) {
	OverridableMethod result = new OverridableMethod();
	result.bindingKey = binding.getKey();
	result.name = binding.getName();
	result.parameters = getMethodParameterTypes(binding, false);
	result.unimplemented = unimplemented || Modifier.isAbstract(binding.getModifiers());
	result.declaringClass = binding.getDeclaringClass().getQualifiedName();
	result.declaringClassType = binding.getDeclaringClass().isInterface() ? "interface" : "class";
	return result;
}
 
Example 11
Source File: SM_Type.java    From DesigniteJava with Apache License 2.0 5 votes vote down vote up
private void setTypeInfo() {
	int modifier = typeDeclaration.getModifiers();
	if (Modifier.isAbstract(modifier)) {
		isAbstract = true;
	}
	if (typeDeclaration.isInterface()) {
		isInterface = true;
	}
}
 
Example 12
Source File: JdtUtils.java    From j2cl with Apache License 2.0 4 votes vote down vote up
private static boolean isAbstract(IBinding binding) {
  return Modifier.isAbstract(binding.getModifiers());
}
 
Example 13
Source File: ModifierChangeCorrectionProposal.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected ASTRewrite getRewrite() throws CoreException {
	CompilationUnit astRoot = ASTResolving.findParentCompilationUnit(fNode);
	ASTNode boundNode = astRoot.findDeclaringNode(fBinding);
	ASTNode declNode = null;

	if (boundNode != null) {
		declNode = boundNode; // is same CU
	} else {
		//setSelectionDescription(selectionDescription);
		CompilationUnit newRoot = ASTResolving.createQuickFixAST(getCompilationUnit(), null);
		declNode = newRoot.findDeclaringNode(fBinding.getKey());
	}
	if (declNode != null) {
		AST ast = declNode.getAST();
		ASTRewrite rewrite = ASTRewrite.create(ast);

		if (declNode.getNodeType() == ASTNode.VARIABLE_DECLARATION_FRAGMENT) {
			VariableDeclarationFragment fragment = (VariableDeclarationFragment) declNode;
			ASTNode parent = declNode.getParent();
			if (parent instanceof FieldDeclaration) {
				FieldDeclaration fieldDecl = (FieldDeclaration) parent;
				if (fieldDecl.fragments().size() > 1 && (fieldDecl.getParent() instanceof AbstractTypeDeclaration)) { // split
					VariableDeclarationRewrite.rewriteModifiers(fieldDecl, new VariableDeclarationFragment[] { fragment }, fIncludedModifiers, fExcludedModifiers, rewrite, null);
					return rewrite;
				}
			} else if (parent instanceof VariableDeclarationStatement) {
				VariableDeclarationStatement varDecl = (VariableDeclarationStatement) parent;
				if (varDecl.fragments().size() > 1 && (varDecl.getParent() instanceof Block)) { // split
					VariableDeclarationRewrite.rewriteModifiers(varDecl, new VariableDeclarationFragment[] { fragment }, fIncludedModifiers, fExcludedModifiers, rewrite, null);
					return rewrite;
				}
			} else if (parent instanceof VariableDeclarationExpression) {
				// can't separate
			}
			declNode = parent;
		} else if (declNode.getNodeType() == ASTNode.METHOD_DECLARATION) {
			MethodDeclaration methodDecl = (MethodDeclaration) declNode;
			if (!methodDecl.isConstructor()) {
				IMethodBinding methodBinding = methodDecl.resolveBinding();
				if (methodDecl.getBody() == null && methodBinding != null && Modifier.isAbstract(methodBinding.getModifiers()) && Modifier.isStatic(fIncludedModifiers)) {
					// add body
					ICompilationUnit unit = getCompilationUnit();
					String delimiter = unit.findRecommendedLineSeparator();
					String bodyStatement = ""; //$NON-NLS-1$

					Block body = ast.newBlock();
					rewrite.set(methodDecl, MethodDeclaration.BODY_PROPERTY, body, null);
					Type returnType = methodDecl.getReturnType2();
					if (returnType != null) {
						Expression expression = ASTNodeFactory.newDefaultExpression(ast, returnType, methodDecl.getExtraDimensions());
						if (expression != null) {
							ReturnStatement returnStatement = ast.newReturnStatement();
							returnStatement.setExpression(expression);
							bodyStatement = ASTNodes.asFormattedString(returnStatement, 0, delimiter, unit.getJavaProject().getOptions(true));
						}
					}
					String placeHolder = CodeGeneration.getMethodBodyContent(unit, methodBinding.getDeclaringClass().getName(), methodBinding.getName(), false, bodyStatement, delimiter);
					if (placeHolder != null) {
						ReturnStatement todoNode = (ReturnStatement) rewrite.createStringPlaceholder(placeHolder, ASTNode.RETURN_STATEMENT);
						body.statements().add(todoNode);
					}
				}
			}
		}
		ModifierRewrite listRewrite = ModifierRewrite.create(rewrite, declNode);
		PositionInformation trackedDeclNode = listRewrite.setModifiers(fIncludedModifiers, fExcludedModifiers, null);

		LinkedProposalPositionGroupCore positionGroup = new LinkedProposalPositionGroupCore("group"); //$NON-NLS-1$
		positionGroup.addPosition(trackedDeclNode);
		getLinkedProposalModel().addPositionGroup(positionGroup);

		if (boundNode != null) {
			// only set end position if in same CU
			setEndPosition(rewrite.track(fNode));
		}
		return rewrite;
	}
	return null;
}
 
Example 14
Source File: AbstractMethodCorrectionProposal.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
private MethodDeclaration getStub(ASTRewrite rewrite, ASTNode targetTypeDecl) throws CoreException {
	ImportRewriteContext context=new ContextSensitiveImportRewriteContext(targetTypeDecl, getImportRewrite());

	AST ast= targetTypeDecl.getAST();
	MethodDeclaration decl= ast.newMethodDeclaration();

	SimpleName newNameNode= getNewName(rewrite);

	decl.setConstructor(isConstructor());

	addNewModifiers(rewrite, targetTypeDecl, decl.modifiers());

	ArrayList<String> takenNames= new ArrayList<>();
	addNewTypeParameters(rewrite, takenNames, decl.typeParameters(), context);

	decl.setName(newNameNode);

	IVariableBinding[] declaredFields= fSenderBinding.getDeclaredFields();
	for (int i= 0; i < declaredFields.length; i++) { // avoid to take parameter names that are equal to field names
		takenNames.add(declaredFields[i].getName());
	}

	String bodyStatement= ""; //$NON-NLS-1$
	boolean isAbstractMethod= Modifier.isAbstract(decl.getModifiers()) || (fSenderBinding.isInterface() && !Modifier.isStatic(decl.getModifiers()) && !Modifier.isDefault(decl.getModifiers()));
	if (!isConstructor()) {
		Type returnType= getNewMethodType(rewrite, context);
		decl.setReturnType2(returnType);

		boolean isVoid= returnType instanceof PrimitiveType && PrimitiveType.VOID.equals(((PrimitiveType)returnType).getPrimitiveTypeCode());
		if (!isAbstractMethod && !isVoid) {
			ReturnStatement returnStatement= ast.newReturnStatement();
			returnStatement.setExpression(ASTNodeFactory.newDefaultExpression(ast, returnType, 0));
			bodyStatement= ASTNodes.asFormattedString(returnStatement, 0, String.valueOf('\n'), getCompilationUnit().getJavaProject().getOptions(true));
		}
	}

	addNewParameters(rewrite, takenNames, decl.parameters(), context);
	addNewExceptions(rewrite, decl.thrownExceptionTypes(), context);

	Block body= null;
	if (!isAbstractMethod && !Flags.isAbstract(decl.getModifiers())) {
		body= ast.newBlock();
		if (bodyStatement.length() > 0) {
			ReturnStatement todoNode = (ReturnStatement) rewrite.createStringPlaceholder(bodyStatement,
					ASTNode.RETURN_STATEMENT);
			body.statements().add(todoNode);
		}
	}
	decl.setBody(body);

	CodeGenerationSettings settings = PreferenceManager.getCodeGenerationSettings(getCompilationUnit().getResource());
	if (settings.createComments && !fSenderBinding.isAnonymous()) {
		String string = CodeGeneration.getMethodComment(getCompilationUnit(), fSenderBinding.getName(), decl, null,
				String.valueOf('\n'));
		if (string != null) {
			Javadoc javadoc= (Javadoc) rewrite.createStringPlaceholder(string, ASTNode.JAVADOC);
			decl.setJavadoc(javadoc);
		}
	}
	return decl;
}
 
Example 15
Source File: JdtFlags.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
public static boolean isAbstract(IMethodBinding member) {
	return Modifier.isAbstract(member.getModifiers());
}
 
Example 16
Source File: IntroduceFactoryRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates and returns a new MethodDeclaration that represents the factory method to be used in
 * place of direct calls to the constructor in question.
 * 
 * @param ast An AST used as a factory for various AST nodes
 * @param ctorBinding binding for the constructor being wrapped
 * @param unitRewriter the ASTRewrite to be used
 * @return the new method declaration
 * @throws CoreException if an exception occurs while accessing its corresponding resource
 */
private MethodDeclaration createFactoryMethod(AST ast, IMethodBinding ctorBinding, ASTRewrite unitRewriter) throws CoreException{
	MethodDeclaration		newMethod= ast.newMethodDeclaration();
	SimpleName				newMethodName= ast.newSimpleName(fNewMethodName);
	ClassInstanceCreation	newCtorCall= ast.newClassInstanceCreation();
	ReturnStatement			ret= ast.newReturnStatement();
	Block		body= ast.newBlock();
	List<Statement>		stmts= body.statements();
	String		retTypeName= ctorBinding.getName();

	createFactoryMethodSignature(ast, newMethod);

	newMethod.setName(newMethodName);
	newMethod.setBody(body);

	ITypeBinding declaringClass= fCtorBinding.getDeclaringClass();
	ITypeBinding[] ctorOwnerTypeParameters= declaringClass.getTypeParameters();

	setMethodReturnType(newMethod, retTypeName, ctorOwnerTypeParameters, ast);

	newMethod.modifiers().addAll(ASTNodeFactory.newModifiers(ast, Modifier.STATIC | Modifier.PUBLIC));

	setCtorTypeArguments(newCtorCall, retTypeName, ctorOwnerTypeParameters, ast);

	createFactoryMethodConstructorArgs(ast, newCtorCall);

	if (Modifier.isAbstract(declaringClass.getModifiers())) {
		AnonymousClassDeclaration decl= ast.newAnonymousClassDeclaration();
		IMethodBinding[] unimplementedMethods= getUnimplementedMethods(declaringClass);
		CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings(fCUHandle.getJavaProject());
		ImportRewriteContext context= new ContextSensitiveImportRewriteContext(fFactoryCU, decl.getStartPosition(), fImportRewriter);
		for (int i= 0; i < unimplementedMethods.length; i++) {
			IMethodBinding unImplementedMethod= unimplementedMethods[i];
			MethodDeclaration newMethodDecl= StubUtility2.createImplementationStub(fCUHandle, unitRewriter, fImportRewriter, context, unImplementedMethod, unImplementedMethod.getDeclaringClass()
					.getName(), settings, false);
			decl.bodyDeclarations().add(newMethodDecl);
		}
		newCtorCall.setAnonymousClassDeclaration(decl);
	}

	ret.setExpression(newCtorCall);
	stmts.add(ret);

	return newMethod;
}
 
Example 17
Source File: JavaASTVisitor.java    From SnowGraph with Apache License 2.0 4 votes vote down vote up
private static boolean isAbstract(MethodDeclaration decl) {
    int modifiers = decl.getModifiers();
    return (Modifier.isAbstract(modifiers));
}
 
Example 18
Source File: JdtFlags.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static boolean isAbstract(IMethodBinding member) {
	return Modifier.isAbstract(member.getModifiers());
}
 
Example 19
Source File: StubUtility2.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private static void findUnimplementedInterfaceMethods(ITypeBinding typeBinding, HashSet<ITypeBinding> visited,
		ArrayList<IMethodBinding> allMethods, IPackageBinding currPack, ArrayList<IMethodBinding> toImplement) {
	
	if (visited.add(typeBinding)) {
		IMethodBinding[] typeMethods= typeBinding.getDeclaredMethods();
		
		nextMethod: for (int i= 0; i < typeMethods.length; i++) {
			IMethodBinding curr= typeMethods[i];
			for (Iterator<IMethodBinding> allIter= allMethods.iterator(); allIter.hasNext();) {
				IMethodBinding oneMethod= allIter.next();
				if (Bindings.isSubsignature(oneMethod, curr)) {
					// We've already seen a method that is a subsignature of curr.
					if (!Bindings.isSubsignature(curr, oneMethod)) {
						// oneMethod is a true subsignature of curr; let's go with oneMethod
						continue nextMethod;
					}
					// Subsignatures are equivalent.
					// Check visibility and return types ('getErasure()' tries to achieve effect of "rename type variables")
					if (Bindings.isVisibleInHierarchy(oneMethod, currPack)
							&& oneMethod.getReturnType().getErasure().isSubTypeCompatible(curr.getReturnType().getErasure())) {
						// oneMethod is visible and curr doesn't have a stricter return type; let's go with oneMethod
						continue nextMethod;
					}
					// curr is stricter than oneMethod, so let's remove oneMethod
					allIter.remove();
					toImplement.remove(oneMethod);
				} else if (Bindings.isSubsignature(curr, oneMethod)) {
					// curr is a true subsignature of oneMethod. Let's remove oneMethod.
					allIter.remove();
					toImplement.remove(oneMethod);
				}
			}
			if (Modifier.isAbstract(curr.getModifiers())) {
				toImplement.add(curr);
				allMethods.add(curr);
			}
		}
		ITypeBinding[] superInterfaces= typeBinding.getInterfaces();
		for (int i= 0; i < superInterfaces.length; i++)
			findUnimplementedInterfaceMethods(superInterfaces[i], visited, allMethods, currPack, toImplement);
	}
}
 
Example 20
Source File: JavaASTVisitor.java    From SnowGraph with Apache License 2.0 4 votes vote down vote up
private static boolean isAbstract(TypeDeclaration decl) {
    int modifiers = decl.getModifiers();
    return (Modifier.isAbstract(modifiers));
}