@Override public List<MethodNode> getAbstractMethods() { List<MethodNode> allMethods = new LinkedList<MethodNode>(); for (ClassNode delegate : delegates) { allMethods.addAll(delegate.getAbstractMethods()); } return allMethods; }
private void checkAbstractMethodVisibility(ClassNode node) { // we only do check abstract classes (including enums), no interfaces or non-abstract classes if (!isAbstract(node.getModifiers()) || isInterface(node.getModifiers())) return; List<MethodNode> abstractMethods = node.getAbstractMethods(); if (abstractMethods == null || abstractMethods.isEmpty()) return; for (MethodNode method : abstractMethods) { if (method.isPrivate()) { addError("Method '" + method.getName() + "' from " + getDescription(node) + " must not be private as it is declared as an abstract method.", method); } } }
private void checkNoAbstractMethodsNonabstractClass(ClassNode node) { if (isAbstract(node.getModifiers())) return; List<MethodNode> abstractMethods = node.getAbstractMethods(); if (abstractMethods == null) return; for (MethodNode method : abstractMethods) { MethodNode sameArgsMethod = node.getMethod(method.getName(), method.getParameters()); if (sameArgsMethod==null || method.getReturnType().equals(sameArgsMethod.getReturnType())) { addError("Can't have an abstract method in a non-abstract class." + " The " + getDescription(node) + " must be declared abstract or" + " the " + getDescription(method) + " must be implemented.", node); } else { addError("Abstract "+getDescription(method)+" is not implemented but a " + "method of the same name but different return type is defined: "+ (sameArgsMethod.isStatic()?"static ":"")+ getDescription(sameArgsMethod), method ); } } }
List<MethodNode> methods = type.getAbstractMethods(); MethodNode found = null; if (methods != null) {
protected void addPropertyMethod(MethodNode method) { classNode.addMethod(method); markAsGenerated(classNode, method); // GROOVY-4415 / GROOVY-4645: check that there's no abstract method which corresponds to this one List<MethodNode> abstractMethods = classNode.getAbstractMethods(); if (abstractMethods == null) return; String methodName = method.getName(); Parameter[] parameters = method.getParameters(); ClassNode methodReturnType = method.getReturnType(); for (MethodNode node : abstractMethods) { if (!node.getDeclaringClass().equals(classNode)) continue; if (node.getName().equals(methodName) && node.getParameters().length == parameters.length) { if (parameters.length == 1) { // setter ClassNode abstractMethodParameterType = node.getParameters()[0].getType(); ClassNode methodParameterType = parameters[0].getType(); if (!methodParameterType.isDerivedFrom(abstractMethodParameterType) && !methodParameterType.implementsInterface(abstractMethodParameterType)) { continue; } } ClassNode nodeReturnType = node.getReturnType(); if (!methodReturnType.isDerivedFrom(nodeReturnType) && !methodReturnType.implementsInterface(nodeReturnType)) { continue; } // matching method, remove abstract status and use the same body node.setModifiers(node.getModifiers() ^ ACC_ABSTRACT); node.setCode(method.getCode()); } } }
private void checkNoAbstractMethodsNonabstractClass(ClassNode node) { if (Modifier.isAbstract(node.getModifiers())) return; List abstractMethods = node.getAbstractMethods(); if (abstractMethods == null) return; for (Iterator iter = abstractMethods.iterator(); iter.hasNext();) { MethodNode method = (MethodNode) iter.next(); addError("Can't have an abstract method in a non-abstract class." + " The " + getDescription(node) + " must be declared abstract or" + " the " + getDescription(method) + " must be implemented.", node); } }
private void checkNoAbstractMethodsNonabstractClass(ClassNode node) { if (Modifier.isAbstract(node.getModifiers())) return; List abstractMethods = node.getAbstractMethods(); if (abstractMethods == null) return; for (Iterator iter = abstractMethods.iterator(); iter.hasNext();) { MethodNode method = (MethodNode) iter.next(); addError("Can't have an abstract method in a non-abstract class." + " The " + getDescription(node) + " must be declared abstract or" + " the " + getDescription(method) + " must be implemented.", node); } }
private void checkNoAbstractMethodsNonabstractClass(ClassNode node) { if (Modifier.isAbstract(node.getModifiers())) return; List abstractMethods = node.getAbstractMethods(); if (abstractMethods == null) return; for (Iterator iter = abstractMethods.iterator(); iter.hasNext();) { MethodNode method = (MethodNode) iter.next(); addError("Can't have an abstract method in a non-abstract class." + " The " + getDescription(node) + " must be declared abstract or" + " the " + getDescription(method) + " must be implemented.", node); } }
private void checkNoAbstractMethodsNonabstractClass(ClassNode node) { if (isAbstract(node.getModifiers())) return; List<MethodNode> abstractMethods = node.getAbstractMethods(); if (abstractMethods == null) return; for (MethodNode method : abstractMethods) { addError("Can't have an abstract method in a non-abstract class." + " The " + getDescription(node) + " must be declared abstract or" + " the " + getDescription(method) + " must be implemented.", node); } }
protected void addPropertyMethod(MethodNode method) { classNode.addMethod(method); // GROOVY-4415 / GROOVY-4645: check that there's no abstract method which corresponds to this one List<MethodNode> abstractMethods = classNode.getAbstractMethods(); if (abstractMethods==null) return; String methodName = method.getName(); Parameter[] parameters = method.getParameters(); ClassNode methodReturnType = method.getReturnType(); for (MethodNode node : abstractMethods) { if (!node.getDeclaringClass().equals(classNode)) continue; if (node.getName().equals(methodName) && node.getParameters().length==parameters.length) { if (parameters.length==1) { // setter ClassNode abstractMethodParameterType = node.getParameters()[0].getType(); ClassNode methodParameterType = parameters[0].getType(); if (!methodParameterType.isDerivedFrom(abstractMethodParameterType) && !methodParameterType.implementsInterface(abstractMethodParameterType)) { continue; } } ClassNode nodeReturnType = node.getReturnType(); if (!methodReturnType.isDerivedFrom(nodeReturnType) && !methodReturnType.implementsInterface(nodeReturnType)) { continue; } // matching method, remove abstract status and use the same body node.setModifiers(node.getModifiers() ^ ACC_ABSTRACT); node.setCode(method.getCode()); } } }