Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

determine if a declaration is annotated with all of 'Type<Annotation>[]' #707

Open
jvasileff opened this issue Jun 1, 2015 · 0 comments
Labels
Milestone

Comments

@jvasileff
Copy link
Member

It's possible to search for models that are annotated with all annotations in a Type<Annotation>[], such as with:

shared formal Attribute<Container,Get,Set>[]
    getAttributes<Container = Nothing, Get = Anything, Set = Nothing>
    (Type<Annotation>[] annotationTypes)

but there doesn't seem to be an easy way to test if a model or declaration that you already have contains all annotations in a list. There is some overlap with #706.

The best I've come up with so far (without API support), is:

shared
Boolean annotatedTake1(
        AnnotatedDeclaration programElement,
        Type<Annotation> *annotations)
    =>  annotations.every((annotation)
        =>  !`function AnnotatedDeclaration.annotations`
                .memberApply
                    <AnnotatedDeclaration, [Annotation*], []>
                    (`AnnotatedDeclaration`, annotation)
                    (programElement)().empty);

// or

shared
Boolean annotatedTake2(
        AnnotatedDeclaration programElement,
        Type<Annotation> *annotations)
    =>  annotations.empty || ( 
        let (allAnnotations =
                programElement.annotations<Annotation>()) 
        annotations.every((requiredAnnotation)
            =>  allAnnotations.any((presentAnnotation)
                =>  type(presentAnnotation)
                        .subtypeOf(requiredAnnotation))));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants