Examples of ProjectionsTrait


Examples of com.asakusafw.dmdl.semantics.trait.ProjectionsTrait

*/
public class ProjectionDriver extends JavaDataModelDriver {

    @Override
    public List<Type> getInterfaces(EmitContext context, ModelDeclaration model) {
        ProjectionsTrait trait = model.getTrait(ProjectionsTrait.class);
        if (trait == null) {
            return Collections.emptyList();
        }
        List<Type> results = Lists.create();
        for (ModelSymbol projection : trait.getProjections()) {
            results.add(context.resolve(projection));
        }
        return results;
    }
View Full Code Here

Examples of com.asakusafw.dmdl.semantics.trait.ProjectionsTrait

        PropertyDeclaration b = simple.findPropertyDeclaration("b");
        assertThat(b, not(nullValue()));
        assertThat(b.getType(), is(type(BasicTypeKind.LONG)));

        ProjectionsTrait trait = simple.getTrait(ProjectionsTrait.class);
        assertThat(trait, not(nullValue()));
        assertThat(trait.getProjections(), has(model("a")));
        assertThat(trait.getProjections(), has(model("b")));
    }
View Full Code Here

Examples of com.asakusafw.dmdl.semantics.trait.ProjectionsTrait

    public void invalid_auto_projection_extra() {
        shouldSemanticError();
    }

    private List<ModelSymbol> projections(ModelDeclaration model) {
        ProjectionsTrait trait = model.getTrait(ProjectionsTrait.class);
        if (trait == null) {
            return Collections.emptyList();
        }
        return trait.getProjections();
    }
View Full Code Here

Examples of com.asakusafw.dmdl.semantics.trait.ProjectionsTrait

            ModelDeclaration declaration,
            AstAttribute attribute) {
        environment.reportAll(AttributeUtil.reportInvalidElements(attribute, attribute.elements));
        List<ModelSymbol> autoProjectios = collectProjections(environment, declaration);

        ProjectionsTrait projections = declaration.getTrait(ProjectionsTrait.class);
        if (projections == null) {
            projections = new ProjectionsTrait(declaration.getOriginalAst().expression, autoProjectios);
        } else {
            List<ModelSymbol> composite = Lists.create();
            composite.addAll(projections.getProjections());
            composite.addAll(autoProjectios);
            projections = new ProjectionsTrait(declaration.getOriginalAst().expression, composite);
        }
        declaration.putTrait(ProjectionsTrait.class, projections);
    }
View Full Code Here

Examples of com.asakusafw.dmdl.semantics.trait.ProjectionsTrait

            properties.put(property.getName().identifier, property.getType());
        }

        Set<String> saw = Sets.create();
        saw.add(model.getName().identifier);
        ProjectionsTrait projections = model.getTrait(ProjectionsTrait.class);
        if (projections != null) {
            for (ModelSymbol symbol : projections.getProjections()) {
                saw.add(symbol.getName().identifier);
            }
        }

        List<ModelSymbol> autoProjectios = Lists.create();
View Full Code Here

Examples of com.asakusafw.dmdl.semantics.trait.ProjectionsTrait

        assert model != null;
        assert expression != null;
        LOG.debug("Resolving record: {}", model.getName()); //$NON-NLS-1$
        RecordExpressionResolver resolver = new RecordExpressionResolver();
        expression.accept(model, resolver);
        ProjectionsTrait projections = new ProjectionsTrait(expression, resolver.projections);
        LOG.debug("Record {} has projections: {}", model.getName(), projections.getProjections()); //$NON-NLS-1$
        model.putTrait(ProjectionsTrait.class, projections);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.