Search in sources :

Example 6 with ICommonsBuilder

use of org.whole.lang.commons.builders.ICommonsBuilder in project whole by wholeplatform.

the class ModelsArtifactsTemplateManager method newModelArtifact.

public ITemplateFactory<Workspace> newModelArtifact(final EntityDescriptor<?> fileContentRootED) {
    return new AbstractTemplateFactory<Workspace>() {

        public void apply(org.whole.lang.builders.IBuilderOperation op) {
            IArtifactsBuilder b0 = (IArtifactsBuilder) op.wGetBuilder(ArtifactsLanguageKit.URI);
            ICommonsBuilder cb = (ICommonsBuilder) op.wGetBuilder(CommonsLanguageKit.URI);
            b0.Workspace_();
            cb.Resolver();
            b0.Projects_(1);
            b0.Project_();
            cb.Variable("projectName", ArtifactsEntityDescriptorEnum.Name, QuantifierEnum.MANDATORY);
            cb.Resolver();
            b0.Metadata();
            b0.Artifacts_(1);
            b0.FolderArtifact_();
            cb.Variable("sourceFolderName", ArtifactsEntityDescriptorEnum.Name, QuantifierEnum.MANDATORY);
            b0.Metadata();
            b0.Artifacts_(1);
            b0.PackageArtifact_();
            cb.Variable("packageName", ArtifactsEntityDescriptorEnum.Name, QuantifierEnum.MANDATORY);
            b0.Metadata();
            b0.Artifacts_(1);
            b0.FileArtifact_();
            b0.NameWithExtension_();
            cb.Variable("modelFileName", ArtifactsEntityDescriptorEnum.Name, QuantifierEnum.MANDATORY);
            b0.Extension("java");
            b0._NameWithExtension();
            b0.Metadata_();
            b0.wFeature(ArtifactsFeatureDescriptorEnum.persistenceKitId);
            b0.PersistenceKitId("org.whole.lang.java.codebase.JavaBuilderPersistenceKit");
            b0._Metadata();
            cb.StageUpFragment_();
            cb.Variable("modelFileContent", fileContentRootED, QuantifierEnum.MANDATORY);
            cb._StageUpFragment();
            b0._FileArtifact();
            b0._Artifacts();
            b0._PackageArtifact();
            b0._Artifacts();
            b0._FolderArtifact();
            b0._Artifacts();
            b0._Project();
            b0._Projects();
            b0._Workspace();
        }
    };
}
Also used : IArtifactsBuilder(org.whole.lang.artifacts.builders.IArtifactsBuilder) AbstractTemplateFactory(org.whole.lang.templates.AbstractTemplateFactory) ICommonsBuilder(org.whole.lang.commons.builders.ICommonsBuilder)

Example 7 with ICommonsBuilder

use of org.whole.lang.commons.builders.ICommonsBuilder in project whole by wholeplatform.

the class ResourceTemplateTest method getMetadataPattern.

private IEntity getMetadataPattern() {
    ModelBuilderOperation op = new ModelBuilderOperation();
    IArtifactsBuilder ab = (IArtifactsBuilder) op.wGetBuilder(ArtifactsLanguageKit.URI);
    ICommonsBuilder cb = (ICommonsBuilder) op.wGetBuilder(CommonsLanguageKit.URI);
    ab.Metadata_();
    cb.Resolver();
    cb.Resolver();
    cb.Resolver();
    ab.Attributes_(1);
    ab.Attribute(AttributeEnum.readonly);
    ab._Attributes();
    cb.Resolver();
    ab._Metadata();
    return op.wGetResult();
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IArtifactsBuilder(org.whole.lang.artifacts.builders.IArtifactsBuilder) ICommonsBuilder(org.whole.lang.commons.builders.ICommonsBuilder)

Example 8 with ICommonsBuilder

use of org.whole.lang.commons.builders.ICommonsBuilder in project whole by wholeplatform.

the class ResourceTemplateTest method getFilesystemPattern.

private IEntity getFilesystemPattern() {
    ModelBuilderOperation op = new ModelBuilderOperation();
    IArtifactsBuilder ab = (IArtifactsBuilder) op.wGetBuilder(ArtifactsLanguageKit.URI);
    ICommonsBuilder cb = (ICommonsBuilder) op.wGetBuilder(CommonsLanguageKit.URI);
    ab.FolderArtifact_();
    ab.Name("testfolder");
    cb.Resolver();
    ab.Artifacts_(3);
    ab.FolderArtifact_();
    ab.Name("empty.folder");
    cb.Resolver();
    ab.Artifacts();
    ab._FolderArtifact();
    ab.FolderArtifact_();
    ab.Name("subfolder");
    cb.Resolver();
    ab.Artifacts_(1);
    ab.FileArtifact_();
    ab.NameWithExtension_();
    ab.Name("test");
    ab.Extension("txt");
    ab._NameWithExtension();
    cb.Resolver();
    cb.Resolver();
    ab._FileArtifact();
    ab._Artifacts();
    ab._FolderArtifact();
    ab.FileArtifact_();
    ab.NameWithExtension_();
    ab.Name("test.extensions");
    ab.Extension("txt");
    ab._NameWithExtension();
    cb.Resolver();
    cb.Resolver();
    ab._FileArtifact();
    ab.FileArtifact_();
    ab.Name("withoutext");
    cb.Resolver();
    cb.Resolver();
    ab._FileArtifact();
    return op.wGetResult();
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IArtifactsBuilder(org.whole.lang.artifacts.builders.IArtifactsBuilder) ICommonsBuilder(org.whole.lang.commons.builders.ICommonsBuilder)

Example 9 with ICommonsBuilder

use of org.whole.lang.commons.builders.ICommonsBuilder in project whole by wholeplatform.

the class Factorial method apply.

public void apply(IBuilderOperation op) {
    IImpBuilder b0 = (IImpBuilder) op.wGetBuilder(ImpLanguageKit.URI);
    ICommonsBuilder cb = (ICommonsBuilder) op.wGetBuilder(CommonsLanguageKit.URI);
    b0.FunctionDeclaration_();
    b0.PrimitiveType("void");
    b0.Name("testFactorial");
    cb.Resolver();
    b0.BlockStatement_(4);
    b0.FunctionDeclaration_();
    b0.PrimitiveType("int");
    b0.Name("ifact");
    b0.Parameters_(1);
    b0.Parameter_();
    b0.PrimitiveType("int");
    b0.Name("n");
    b0._Parameter();
    b0._Parameters();
    b0.BlockStatement_(3);
    b0.VariableDeclaration_();
    b0.PrimitiveType("int");
    b0.Name("result");
    b0.IntLiteral(1);
    b0._VariableDeclaration();
    b0.WhileStatement_();
    b0.GreaterThan_();
    b0.NameExpression("n");
    b0.IntLiteral(0);
    b0._GreaterThan();
    b0.BlockStatement_(2);
    b0.ExpressionStatement_();
    b0.AssignmentExpression_();
    b0.Name("result");
    b0.Multiplication_();
    b0.NameExpression("result");
    b0.NameExpression("n");
    b0._Multiplication();
    b0._AssignmentExpression();
    b0._ExpressionStatement();
    b0.ExpressionStatement_();
    b0.AssignmentExpression_();
    b0.Name("n");
    b0.Subtraction_();
    b0.NameExpression("n");
    b0.IntLiteral(1);
    b0._Subtraction();
    b0._AssignmentExpression();
    b0._ExpressionStatement();
    b0._BlockStatement();
    b0._WhileStatement();
    b0.ReturnStatement_();
    b0.NameExpression("result");
    b0._ReturnStatement();
    b0._BlockStatement();
    b0._FunctionDeclaration();
    b0.FunctionDeclaration_();
    b0.PrimitiveType("int");
    b0.Name("rfact");
    b0.Parameters_(1);
    b0.Parameter_();
    b0.PrimitiveType("int");
    b0.Name("n");
    b0._Parameter();
    b0._Parameters();
    b0.IfElseStatement_();
    b0.LessOrEquals_();
    b0.NameExpression("n");
    b0.IntLiteral(1);
    b0._LessOrEquals();
    b0.ReturnStatement_();
    b0.IntLiteral(1);
    b0._ReturnStatement();
    b0.ReturnStatement_();
    b0.Multiplication_();
    b0.NameExpression("n");
    b0.FunctionInvocationExpression_();
    b0.NameExpression("rfact");
    b0.Arguments_(1);
    b0.Subtraction_();
    b0.NameExpression("n");
    b0.IntLiteral(1);
    b0._Subtraction();
    b0._Arguments();
    b0._FunctionInvocationExpression();
    b0._Multiplication();
    b0._ReturnStatement();
    b0._IfElseStatement();
    b0._FunctionDeclaration();
    b0.PrintlnStatement_();
    b0.FunctionInvocationExpression_();
    b0.NameExpression("ifact");
    b0.Arguments_(1);
    b0.IntLiteral(4);
    b0._Arguments();
    b0._FunctionInvocationExpression();
    b0._PrintlnStatement();
    b0.PrintlnStatement_();
    b0.FunctionInvocationExpression_();
    b0.NameExpression("rfact");
    b0.Arguments_(1);
    b0.IntLiteral(3);
    b0._Arguments();
    b0._FunctionInvocationExpression();
    b0._PrintlnStatement();
    b0._BlockStatement();
    b0._FunctionDeclaration();
}
Also used : IImpBuilder(org.whole.examples.lang.imp.builders.IImpBuilder) ICommonsBuilder(org.whole.lang.commons.builders.ICommonsBuilder)

Example 10 with ICommonsBuilder

use of org.whole.lang.commons.builders.ICommonsBuilder in project whole by wholeplatform.

the class AttributesMatcherFactory method getDefaultNsDeclPattern.

private static IEntity getDefaultNsDeclPattern() {
    if (defaultNsDeclPattern == null) {
        ModelBuilderOperation mop = new ModelBuilderOperation();
        IXmlBuilder xb = (IXmlBuilder) mop.wGetBuilder(XmlLanguageKit.URI);
        ICommonsBuilder cb = (ICommonsBuilder) mop.wGetBuilder(CommonsLanguageKit.URI);
        xb.Attribute_();
        xb.Name("xmlns");
        cb.Variable_();
        cb.VarType(XmlEntityDescriptorEnum.Value);
        cb.VarName("uri");
        cb.Quantifier(QuantifierEnum.MANDATORY);
        cb._Variable();
        xb._Attribute();
        defaultNsDeclPattern = mop.wGetResult();
    }
    return defaultNsDeclPattern;
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IXmlBuilder(org.whole.lang.xml.builders.IXmlBuilder) ICommonsBuilder(org.whole.lang.commons.builders.ICommonsBuilder)

Aggregations

ICommonsBuilder (org.whole.lang.commons.builders.ICommonsBuilder)17 ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)8 IArtifactsBuilder (org.whole.lang.artifacts.builders.IArtifactsBuilder)5 IXmlBuilder (org.whole.lang.xml.builders.IXmlBuilder)5 IImpBuilder (org.whole.examples.lang.imp.builders.IImpBuilder)3 IModelsBuilder (org.whole.lang.models.builders.IModelsBuilder)3 IBuilder (org.whole.lang.builders.IBuilder)1 IBuilderFactory (org.whole.lang.builders.IBuilderFactory)1 CommonsGenericBuilderAdapter (org.whole.lang.commons.builders.CommonsGenericBuilderAdapter)1 CommonsSpecificBuilderAdapter (org.whole.lang.commons.builders.CommonsSpecificBuilderAdapter)1 CommonsContentAssistVisitor (org.whole.lang.commons.visitors.CommonsContentAssistVisitor)1 CommonsDynamicCompilerVisitor (org.whole.lang.commons.visitors.CommonsDynamicCompilerVisitor)1 CommonsInterpreterVisitor (org.whole.lang.commons.visitors.CommonsInterpreterVisitor)1 CommonsPrettyPrinterVisitor (org.whole.lang.commons.visitors.CommonsPrettyPrinterVisitor)1 IEntityContext (org.whole.lang.contexts.IEntityContext)1 IOperation (org.whole.lang.operations.IOperation)1 PrettyPrinterOperation (org.whole.lang.operations.PrettyPrinterOperation)1 AbstractTemplateFactory (org.whole.lang.templates.AbstractTemplateFactory)1 IVisitor (org.whole.lang.visitors.IVisitor)1 IVisitorFactory (org.whole.lang.visitors.IVisitorFactory)1