public void checkReturnType(ClassNode attrType, ASTNode node) { if (attrType.isArray()) { checkReturnType(attrType.getComponentType(), node); } else if (ClassHelper.isPrimitiveType(attrType)) { } else if (ClassHelper.STRING_TYPE.equals(attrType)) { } else if (ClassHelper.CLASS_Type.equals(attrType)) { } else if (attrType.isDerivedFrom(ClassHelper.Enum_Type)) { } else if (isValidAnnotationClass(attrType)) { } else { addError("Unexpected return type " + attrType.getName(), node); } }
private void visitConstructorOrMethod(MethodNode node, int methodTarget) { visitAnnotations(node, methodTarget); for (int i = 0; i < node.getParameters().length; i++) { Parameter parameter = node.getParameters()[i]; visitAnnotations(parameter, AnnotationNode.PARAMETER_TARGET); } if (this.currentClass.isAnnotationDefinition() && !node.isStaticConstructor()) { ErrorCollector errorCollector = new ErrorCollector(this.source.getConfiguration()); AnnotationVisitor visitor = new AnnotationVisitor(this.source, errorCollector); visitor.setReportClass(currentClass); visitor.checkReturnType(node.getReturnType(), node); if (node.getParameters().length > 0) { addError("Annotation members may not have parameters.", node.getParameters()[0]); } if (node.getExceptions().length > 0) { addError("Annotation members may not have a throws clause.", node.getExceptions()[0]); } ReturnStatement code = (ReturnStatement) node.getCode(); if (code != null) { visitor.visitExpression(node.getName(), code.getExpression(), node.getReturnType()); visitor.checkCircularReference(currentClass, node.getReturnType(), code.getExpression()); } this.source.getErrorCollector().addCollectorContents(errorCollector); } Statement code = node.getCode(); if (code != null) { code.visit(this); } }
public void checkReturnType(ClassNode attrType,ASTNode node) { if(attrType.isArray()) { checkReturnType(attrType.getComponentType(),node); } else if (ClassHelper.isPrimitiveType(attrType)) { return; } else if (ClassHelper.STRING_TYPE.equals(attrType)) { return; } else if (ClassHelper.CLASS_Type.equals(attrType)) { return; } else if (attrType.isDerivedFrom(ClassHelper.Enum_Type)) { return; } else if (isValidAnnotationClass(attrType)) { return; } else { addError("Unexpected return type "+attrType.getName(),node); } }
public void checkReturnType(ClassNode attrType, ASTNode node) { if (attrType.isArray()) { checkReturnType(attrType.getComponentType(), node); } else if (ClassHelper.isPrimitiveType(attrType)) { return; } else if (ClassHelper.STRING_TYPE.equals(attrType)) { return; } else if (ClassHelper.CLASS_Type.equals(attrType)) { return; } else if (attrType.isDerivedFrom(ClassHelper.Enum_Type)) { return; } else if (isValidAnnotationClass(attrType)) { return; } else { addError("Unexpected return type " + attrType.getName(), node); } }
public void checkReturnType(ClassNode attrType,ASTNode node) { if(attrType.isArray()) { checkReturnType(attrType.getComponentType(),node); } else if (ClassHelper.isPrimitiveType(attrType)) { return; } else if (ClassHelper.STRING_TYPE.equals(attrType)) { return; } else if (ClassHelper.CLASS_Type.equals(attrType)) { return; } else if (attrType.isDerivedFrom(ClassHelper.Enum_Type)) { return; } else if (isValidAnnotationClass(attrType)) { return; } else { addError("Unexpected return type "+attrType.getName(),node); } }
public void visitMethod(MethodNode node) { visitAnnotations(node, AnnotationNode.METHOD_TARGET); for (int i = 0; i < node.getParameters().length; i++) { Parameter parameter = node.getParameters()[i]; visitAnnotations(parameter, AnnotationNode.PARAMETER_TARGET); } if (this.currentClass.isAnnotationDefinition()) { ErrorCollector errorCollector = new ErrorCollector(this.source.getConfiguration()); AnnotationVisitor visitor = new AnnotationVisitor(this.source, errorCollector); visitor.setReportClass(currentClass); visitor.checkReturnType(node.getReturnType(),node); if (node.getParameters().length>0) { addError ("Annotation members may not have parameters.",node.getParameters()[0]); } if (node.getExceptions().length>0) { addError ("Annotation members may not have a throws clause.",node.getExceptions()[0]); } ReturnStatement code = (ReturnStatement) node.getCode(); if (code!=null) { visitor.visitExpression(node.getName(),code.getExpression(),node.getReturnType()); visitor.checkcircularReference(currentClass,node.getReturnType(),code.getExpression()); } this.source.getErrorCollector().addCollectorContents(errorCollector); } }
private void visitConstructorOrMethod(MethodNode node, int methodTarget) { visitAnnotations(node, methodTarget); for (int i = 0; i < node.getParameters().length; i++) { Parameter parameter = node.getParameters()[i]; visitAnnotations(parameter, AnnotationNode.PARAMETER_TARGET); } if (this.currentClass.isAnnotationDefinition()) { ErrorCollector errorCollector = new ErrorCollector(this.source.getConfiguration()); AnnotationVisitor visitor = new AnnotationVisitor(this.source, errorCollector); visitor.setReportClass(currentClass); visitor.checkReturnType(node.getReturnType(),node); if (node.getParameters().length>0) { addError ("Annotation members may not have parameters.",node.getParameters()[0]); } if (node.getExceptions().length>0) { addError ("Annotation members may not have a throws clause.",node.getExceptions()[0]); } ReturnStatement code = (ReturnStatement) node.getCode(); if (code!=null) { visitor.visitExpression(node.getName(),code.getExpression(),node.getReturnType()); visitor.checkcircularReference(currentClass,node.getReturnType(),code.getExpression()); } this.source.getErrorCollector().addCollectorContents(errorCollector); } }
private void visitConstructorOrMethod(MethodNode node, int methodTarget) { visitAnnotations(node, methodTarget); for (int i = 0; i < node.getParameters().length; i++) { Parameter parameter = node.getParameters()[i]; visitAnnotations(parameter, AnnotationNode.PARAMETER_TARGET); } if (this.currentClass.isAnnotationDefinition() && !node.isStaticConstructor()) { ErrorCollector errorCollector = new ErrorCollector(this.source.getConfiguration()); AnnotationVisitor visitor = new AnnotationVisitor(this.source, errorCollector); visitor.setReportClass(currentClass); visitor.checkReturnType(node.getReturnType(), node); if (node.getParameters().length > 0) { addError("Annotation members may not have parameters.", node.getParameters()[0]); } if (node.getExceptions().length > 0) { addError("Annotation members may not have a throws clause.", node.getExceptions()[0]); } ReturnStatement code = (ReturnStatement) node.getCode(); if (code != null) { visitor.visitExpression(node.getName(), code.getExpression(), node.getReturnType()); visitor.checkCircularReference(currentClass, node.getReturnType(), code.getExpression()); } this.source.getErrorCollector().addCollectorContents(errorCollector); } }