Search in sources :

Example 1 with ParameterContext

use of org.finos.legend.pure.m3.inlinedsl.path.serialization.grammar.NavigationParser.ParameterContext in project legend-pure by finos.

the class NavigationGraphBuilder method visitPropertyWithParametersBlock.

private void visitPropertyWithParametersBlock(PropertyWithParametersContext ctx, MutableList<PathElement> props, Token firstChar) {
    MutableList<ValueSpecification> parameters = FastList.newList();
    Token property = ctx.VALID_STRING().getSymbol();
    ClassInstance ppeType = (ClassInstance) this.processorSupport.package_getByUserPath(M3Paths.PropertyPathElement);
    PropertyPathElement propertyPathElement = (PropertyPathElement) this.repository.newAnonymousCoreInstance(this.sourceInformation.getPureSourceInformation(property), ppeType, true);
    GenericType classifierGT = GenericTypeInstance.createPersistent(this.repository);
    classifierGT._rawTypeCoreInstance(ppeType);
    propertyPathElement._classifierGenericType(classifierGT);
    PropertyStub propStub = PropertyStubInstance.createPersistent(this.repository, this.sourceInformation.getPureSourceInformation(property), null, property.getText());
    propertyPathElement._propertyCoreInstance(propStub);
    if (ctx.parameter() != null) {
        for (ParameterContext parameterContext : ctx.parameter()) {
            parameters.add(visitParameterBlock(parameterContext));
        }
    }
    if (!parameters.isEmpty()) {
        propertyPathElement._parameters(parameters);
    }
    props.add(propertyPathElement);
}
Also used : PropertyStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub) GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification) Token(org.antlr.v4.runtime.Token) ParameterContext(org.finos.legend.pure.m3.inlinedsl.path.serialization.grammar.NavigationParser.ParameterContext) ClassInstance(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.ClassInstance) PropertyPathElement(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.path.PropertyPathElement)

Example 2 with ParameterContext

use of org.finos.legend.pure.m3.inlinedsl.path.serialization.grammar.NavigationParser.ParameterContext in project legend-pure by finos.

the class GraphAntlrTreeWalker method visitGraphPathContext.

private String visitGraphPathContext(GraphPathContext graphPathContext) {
    SourceInformation definitionSourceInfo = this.sourceInformation.getPureSourceInformation(graphPathContext.start, graphPathContext.start, graphPathContext.stop);
    SourceInformation propertySourceInfo = this.sourceInformation.getPureSourceInformation(graphPathContext.identifier().start, graphPathContext.identifier().start, graphPathContext.identifier().stop);
    MutableList<String> subTrees = FastList.newList();
    if (graphPathContext.graphDefinition() != null) {
        for (GraphPathContext subGraphPathContext : graphPathContext.graphDefinition().graphPaths().graphPath()) {
            subTrees.add(this.visitGraphPathContext(subGraphPathContext));
        }
    }
    MutableList<String> parameters = FastList.newList();
    if (graphPathContext.propertyParameters() != null) {
        for (ParameterContext parameterContext : graphPathContext.propertyParameters().parameter()) {
            parameters.add(this.visitParameterContext(parameterContext));
        }
    }
    String subType = "";
    if (graphPathContext.subtype() != null) {
        SourceInformation subTypeSourceInfo = this.sourceInformation.getPureSourceInformation(graphPathContext.subtype().qualifiedName().start, graphPathContext.subtype().qualifiedName().start, graphPathContext.subtype().qualifiedName().stop);
        subType = "^meta::pure::metamodel::import::ImportStub " + subTypeSourceInfo.toM4String() + " (importGroup = system::imports::" + this.importId._name() + ", idOrPath = '" + graphPathContext.subtype().qualifiedName().getText() + "')";
    }
    String alias = "";
    if (graphPathContext.alias() != null) {
        alias = graphPathContext.alias().STRING().getText();
    }
    return "^meta::pure::graphFetch::PropertyGraphFetchTree " + definitionSourceInfo.toM4String() + " (" + "property = " + "^meta::pure::metamodel::import::PropertyStub " + propertySourceInfo.toM4String() + " (propertyName = '" + graphPathContext.identifier().getText() + "'), " + "parameters = " + parameters.makeString("[", ", ", "]") + ", " + "subTrees = " + subTrees.makeString("[", ", ", "]") + ", " + "subType = [" + subType + "]" + ", " + "alias = [" + alias + "]" + ")";
}
Also used : GraphPathContext(org.finos.legend.pure.m3.inlinedsl.graph.serialization.grammar.GraphParser.GraphPathContext) ScalarParameterContext(org.finos.legend.pure.m3.inlinedsl.graph.serialization.grammar.GraphParser.ScalarParameterContext) ParameterContext(org.finos.legend.pure.m3.inlinedsl.graph.serialization.grammar.GraphParser.ParameterContext) AntlrSourceInformation(org.finos.legend.pure.m4.serialization.grammar.antlr.AntlrSourceInformation) SourceInformation(org.finos.legend.pure.m4.coreinstance.SourceInformation)

Example 3 with ParameterContext

use of org.finos.legend.pure.m3.inlinedsl.path.serialization.grammar.NavigationParser.ParameterContext in project legend-pure by finos.

the class NavigationGraphBuilder method visitParameterBlock.

private ValueSpecification visitParameterBlock(ParameterContext ctx) {
    ListIterable<CoreInstance> rawValue;
    if (ctx.scalar() != null) {
        MutableList<CoreInstance> elements = FastList.newList();
        CoreInstance result = visitScalar(ctx.scalar());
        elements.add(result);
        rawValue = elements;
    } else {
        rawValue = visitCollectionBlock(ctx.collection());
    }
    InstanceValueInstance instanceVal = InstanceValueInstance.createPersistent(this.repository, null, null);
    instanceVal._values(rawValue);
    return instanceVal;
}
Also used : InstanceValueInstance(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValueInstance) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance)

Aggregations

Token (org.antlr.v4.runtime.Token)1 PropertyStub (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub)1 PropertyPathElement (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.path.PropertyPathElement)1 ClassInstance (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.ClassInstance)1 GenericType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType)1 InstanceValueInstance (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValueInstance)1 ValueSpecification (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification)1 GraphPathContext (org.finos.legend.pure.m3.inlinedsl.graph.serialization.grammar.GraphParser.GraphPathContext)1 ParameterContext (org.finos.legend.pure.m3.inlinedsl.graph.serialization.grammar.GraphParser.ParameterContext)1 ScalarParameterContext (org.finos.legend.pure.m3.inlinedsl.graph.serialization.grammar.GraphParser.ScalarParameterContext)1 ParameterContext (org.finos.legend.pure.m3.inlinedsl.path.serialization.grammar.NavigationParser.ParameterContext)1 CoreInstance (org.finos.legend.pure.m4.coreinstance.CoreInstance)1 SourceInformation (org.finos.legend.pure.m4.coreinstance.SourceInformation)1 AntlrSourceInformation (org.finos.legend.pure.m4.serialization.grammar.antlr.AntlrSourceInformation)1